diff --git a/dune/microstructure/prestrainedMaterial.hh b/dune/microstructure/prestrainedMaterial.hh index 3634e4feeb60bb6ef9736ee68a5f6190b3da056e..e04cffb0e6328432c2461b196fcca0b53cf51b0f 100644 --- a/dune/microstructure/prestrainedMaterial.hh +++ b/dune/microstructure/prestrainedMaterial.hh @@ -8,6 +8,7 @@ #include <dune/common/parametertree.hh> #include <dune/fufem/dunepython.hh> #include <dune/microstructure/matrix_operations.hh> +#include <dune/microstructure/voigthelper.hh> // #include <dune/microstructure/materialDefinitions.hh> //deprecated @@ -109,7 +110,7 @@ protected: // MatrixFunc L2_; // MatrixFunc L3_; - // Elasticity tensors (in voigt notation) + // Elasticity tensors (in Voigt notation) Dune::FieldMatrix<double,6,6> L1_; Dune::FieldMatrix<double,6,6> L2_; Dune::FieldMatrix<double,6,6> L3_; @@ -590,20 +591,6 @@ Dune::FieldMatrix<double,6,6> setupPhase(const std::string phaseType, Python::Mo //------------------------------------------------------------------------------- - // --- Helpers - static Dune::FieldVector<double,6> MatrixToVoigt(const MatrixRT& G) - { - // return {G[0][0], G[1][1], G[2][2], G[1][2], G[0][2], G[0][1]}; - return {G[0][0], G[1][1], G[2][2], 2.0*G[1][2], 2.0*G[0][2], 2.0*G[0][1]}; - - } - - static MatrixRT VoigtToMatrix(const Dune::FieldVector<double,6>& v) - { - // return {{v[0], v[5], v[4]}, {v[5], v[1], v[3]}, {v[4], v[3], v[2]}}; - return {{v[0], v[5]/2.0, v[4]/2.0}, {v[5]/2.0, v[1], v[3]/2.0}, {v[4]/2.0, v[3]/2.0, v[2]}}; - } - static Dune::FieldVector<double,6> strainToVoigt(const MatrixRT& G) { // return {G[0][0], G[1][1], G[2][2], G[1][2], G[0][2], G[0][1]}; @@ -630,14 +617,12 @@ Dune::FieldMatrix<double,6,6> setupPhase(const std::string phaseType, Python::Mo return {{v[0], v[5]/2.0, v[4]/2.0}, {v[5]/2.0, v[1], v[3]/2.0}, {v[4]/2.0, v[3]/2.0, v[2]}}; } - - - MatrixRT applyElasticityTensor(const MatrixRT& G, const int& phase) const + MatrixRT applyElasticityTensor(const MatrixRT& G, const int& phase) const { // FieldVector<double,6> G_tmp = {G[0][0], G[1][1], G[2][2], sqrt(2.0)*G[1][2], sqrt(2.0)*G[0][2], sqrt(2.0)*G[0][1]}; // FieldVector<double,6> G_tmp = {G[0][0], G[1][1], G[2][2], G[1][2], G[0][2], G[0][1]}; - Dune::FieldVector<double,6> G_tmp = MatrixToVoigt(G); - Dune::FieldVector<double,6> out(0); + VoigtVector<double,3> G_tmp = matrixToVoigt(G); + VoigtVector<double,3> out(0); // printvector(std::cout, G_tmp, "G_tmp", "--"); // if (phase == 1) @@ -689,7 +674,7 @@ Dune::FieldMatrix<double,6,6> setupPhase(const std::string phaseType, Python::Mo // printvector(std::cout, out, "out", "--"); - return VoigtToMatrix(out); // Muss hier stress zurücktransformieren! + return voigtToMatrix(out); // Muss hier stress zurücktransformieren! // return VoigtToStress(out); // return image as Matrix again // return {{out[0], (1.0/sqrt(2.0))*out[5], (1.0/sqrt(2.0))*out[4]}, {(1.0/sqrt(2.0))*out[5], out[1], (1.0/sqrt(2.0))*out[3]}, {(1.0/sqrt(2.0))*out[4], (1.0/sqrt(2.0))*out[3], out[2]}}; diff --git a/dune/microstructure/voigthelper.hh b/dune/microstructure/voigthelper.hh new file mode 100644 index 0000000000000000000000000000000000000000..fbea65a183f9af269547f4da26dd9ae6376d6bab --- /dev/null +++ b/dune/microstructure/voigthelper.hh @@ -0,0 +1,31 @@ +#ifndef DUNE_MICROSTRUCTURE_VOIGTHELPER_HH +#define DUNE_MICROSTRUCTURE_VOIGTHELPER_HH + +/** \file + * \brief Various helper functions related to Voigt notation + */ + +#include <dune/common/fvector.hh> +#include <dune/common/fmatrix.hh> + + +template<typename T, int dim> +using VoigtVector = Dune::FieldVector<T,dim*(dim+1)/2>; + +template<typename T, int dim> +using VoigtMatrix = Dune::FieldMatrix<T,dim*(dim+1)/2,dim*(dim+1)/2>; + + +template<typename T> +static VoigtVector<T,3> matrixToVoigt(const Dune::FieldMatrix<T,3,3>& matrix) +{ + return {matrix[0][0], matrix[1][1], matrix[2][2], 2.0*matrix[1][2], 2.0*matrix[0][2], 2.0*matrix[0][1]}; +} + +template<typename T> +static Dune::FieldMatrix<T,3,3> voigtToMatrix(const VoigtVector<T,3>& v) +{ + return {{v[0], v[5]/2.0, v[4]/2.0}, {v[5]/2.0, v[1], v[3]/2.0}, {v[4]/2.0, v[3]/2.0, v[2]}}; +} + +#endif // DUNE_MICROSTRUCTURE_VOIGTHELPER_HH