Hi Raul, I’m a bit late to the discussion, but maybe this piece of information might still be useful to you. There is a function that computes and returns the eigenvalues and eigenvectors of symmetric tensors: https://dealii.org/developer/doxygen/deal.II/symmetric__tensor_8h.html#aa18a9d623fcd520f022421fd1d6c7a14 <https://dealii.org/developer/doxygen/deal.II/symmetric__tensor_8h.html#aa18a9d623fcd520f022421fd1d6c7a14> (the eigenvalues of non-symmetric tensors are, in general, complex valued and more complicated to compute, so this has not yet been implemented)
You can do this point-wise and, as previously suggested, could be stored for visualisation using the DataPostprocessTensor class. Paraview also has a Tensor glyph (maybe only as an extension?), so maybe that could also be worth investigating. https://kitware.github.io/paraview-docs/latest/python/paraview.simple.TensorGlyph.html <https://kitware.github.io/paraview-docs/latest/python/paraview.simple.TensorGlyph.html> Best, Jean-Paul > On 12. Dec 2022, at 12:27, Raúl Aparicio Yuste <[email protected]> wrote: > > Hello, > > Please find attached a script in which I calculate the principal stress > components by using the eigen library. This example is in 2D for a particular > case, but this piece of code can be modified to generalise the calculation of > the principal stress components in 3D. Hope it will be useful. > > Best > > Raúl > > El lunes, 21 de noviembre de 2022 a las 8:41:38 UTC+1, Raúl Aparicio Yuste > escribió: > Dear Wolfgang and Richard, > > Thank you for your answers. It is good to know how the library works. In my > case I am solving an isotropic linear elasticity problem, so I am going to > implement it by one of the ways I suggested in my previous comment. Your > comments have been really helpful in organising my ideas about Dealii. I will > try to come up with the solution and share it to colaborate with this > interesting resource. Thank you! > > Best > > Raúl > > On Saturday, November 19, 2022 at 5:43:14 PM UTC+1 [email protected] > <applewebdata://9BBA098F-4534-4DE6-8F7C-089A1CFEF93E> wrote: > Hi, > I just recently did something similar and as has been pointed out, there are > as always multiple ways of achieving this. > Since I wanted to not only output the first principal stress, but actually > use it further for my calculations, I wanted to have a DoF vector resembling > the field in my mesh. Thus, there are again (at least) 2 options: > i) introduce a discontinuous field with corresponding DoFs (would require > more effort since I am only using continuous FEs) > ii) use a continuous, averaged field, accepting the introduced error > (constant per element and averaged over neighbors) > If you want to do ii) as well, it boils down to a classical assembly loop, > and one computes the Cauchy stress tensor (or whatever stress tensor you want > to get the principal stresses from) as you did in your momentum balance > equation. > This might look something like the following in integration point q: > { > Tensor<2,dim> F_s = identity_tensor + > gradients_displacement[q]; // displacement gradient > Tensor<2,dim> PK2_stress = > get_PK2_stress<dim>(F_s); // second Piola-Kirchhoff stress tensor, you define > this function based on your constitutive equation > Tensor<2,dim> cauchy_stress = > symmetrize((1.0/determinant(F_s)) * F_s * PK2_s * transpose(F_s)); // Cauchy > stress tensor via Piola transform for finite strain theory > const std::array<double,dim> eigenvalues_cauchy = > eigenvalues(cauchy_stress); > double max_principal_stress = cauchy_stress[0]; > } > Optionally, one could always get a global DoF vector via projecting the > stress components or the first principal stress (or the quantity you need to > plot). This would be much much more accurate than what I suggest in ii). > Going through i) or ii), both ways one ends up with (dis-)continuous global > vectors, possibly averaged over neighbors. These are then easily exported via > the classical dealii::DataOut<dim> data_out; data_out.add_data_vector(...). > If you want to just output the results, maybe try the > dealii::DataPostprocessor<dim> as mentioned by Wolfgang. > > Best regards > Richard > > > [email protected] <> schrieb am Donnerstag, 17. November 2022 um 16:21:30 > UTC+1: > Hello everyone, > > It is the first time I am using the library Deal II. I am wondering, is there > any way/example to get the principal stress components as an output of the > simulation? Thank you very much in advance > > Raul > > -- > The deal.II project is located at http://www.dealii.org/ > <http://www.dealii.org/> > For mailing list/forum options, see > https://groups.google.com/d/forum/dealii?hl=en > <https://groups.google.com/d/forum/dealii?hl=en> > --- > You received this message because you are subscribed to the Google Groups > "deal.II User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/187440c4-5646-43ca-acb3-6ddde9eb46een%40googlegroups.com > > <https://groups.google.com/d/msgid/dealii/187440c4-5646-43ca-acb3-6ddde9eb46een%40googlegroups.com?utm_medium=email&utm_source=footer>. > <principal_stress.cpp> -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/FCCF856B-56A4-4427-A1E3-E11269C5E4CF%40gmail.com.
