diff --git a/MaterialLib/SolidModels/Ehlers-impl.h b/MaterialLib/SolidModels/Ehlers-impl.h index 4f4d5000f83cd1b0945883c4c55474de03c15998..e6327db8434afaa341e42cc7d5db06f995c6c5aa 100644 --- a/MaterialLib/SolidModels/Ehlers-impl.h +++ b/MaterialLib/SolidModels/Ehlers-impl.h @@ -34,6 +34,8 @@ #include <boost/math/special_functions/pow.hpp> +#include "MathLib/LinAlg/Eigen/EigenMapTools.h" + namespace MaterialLib { namespace Solids @@ -673,24 +675,12 @@ SolidEhlers<DisplacementDim>::getInternalVariables() const &state) != nullptr); auto const& ehlers_state = static_cast<StateVariables<DisplacementDim> const&>(state); - auto const& D = ehlers_state.eps_p.D; cache.resize(KelvinVector::RowsAtCompileTime); - - // TODO make a general implementation for converting KelvinVectors - // back to symmetric rank-2 tensors. - for (typename KelvinVector::Index component = 0; - component < KelvinVector::RowsAtCompileTime && component < 3; - ++component) - { // xx, yy, zz components - cache[component] = D[component]; - } - for (typename KelvinVector::Index component = 3; - component < KelvinVector::RowsAtCompileTime; - ++component) - { // mixed xy, yz, xz components - cache[component] = D[component] / std::sqrt(2); - } + MathLib::toVector<KelvinVector>(cache, + KelvinVector::RowsAtCompileTime) = + MathLib::KelvinVector::kelvinVectorToSymmetricTensor( + ehlers_state.eps_p.D); return cache; }}, diff --git a/ProcessLib/SmallDeformation/SmallDeformationFEM.h b/ProcessLib/SmallDeformation/SmallDeformationFEM.h index e96ec20638a355f5f33678808c50f5cf7362275a..c34bcd56ff323322af63131255c3f57694c0b0d6 100644 --- a/ProcessLib/SmallDeformation/SmallDeformationFEM.h +++ b/ProcessLib/SmallDeformation/SmallDeformationFEM.h @@ -320,7 +320,6 @@ public: NumLib::LocalToGlobalIndexMap const& /*dof_table*/, std::vector<double>& cache) const override { - using KelvinVectorType = typename BMatricesType::KelvinVectorType; static const int kelvin_vector_size = MathLib::KelvinVector::KelvinVectorDimensions< DisplacementDim>::value; @@ -331,24 +330,11 @@ public: double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>( cache, kelvin_vector_size, num_intpts); - // TODO make a general implementation for converting KelvinVectors - // back to symmetric rank-2 tensors. for (unsigned ip = 0; ip < num_intpts; ++ip) { auto const& sigma = _ip_data[ip].sigma; - - for (typename KelvinVectorType::Index component = 0; - component < kelvin_vector_size && component < 3; - ++component) - { // xx, yy, zz components - cache_mat(component, ip) = sigma[component]; - } - for (typename KelvinVectorType::Index component = 3; - component < kelvin_vector_size; - ++component) - { // mixed xy, yz, xz components - cache_mat(component, ip) = sigma[component] / std::sqrt(2); - } + cache_mat.col(ip) = + MathLib::KelvinVector::kelvinVectorToSymmetricTensor(sigma); } return cache; @@ -360,7 +346,6 @@ public: NumLib::LocalToGlobalIndexMap const& /*dof_table*/, std::vector<double>& cache) const override { - using KelvinVectorType = typename BMatricesType::KelvinVectorType; auto const kelvin_vector_size = MathLib::KelvinVector::KelvinVectorDimensions< DisplacementDim>::value; @@ -371,24 +356,11 @@ public: double, kelvin_vector_size, Eigen::Dynamic, Eigen::RowMajor>>( cache, kelvin_vector_size, num_intpts); - // TODO make a general implementation for converting KelvinVectors - // back to symmetric rank-2 tensors. for (unsigned ip = 0; ip < num_intpts; ++ip) { auto const& eps = _ip_data[ip].eps; - - for (typename KelvinVectorType::Index component = 0; - component < kelvin_vector_size && component < 3; - ++component) - { // xx, yy, zz components - cache_mat(component, ip) = eps[component]; - } - for (typename KelvinVectorType::Index component = 3; - component < kelvin_vector_size; - ++component) - { // mixed xy, yz, xz components - cache_mat(component, ip) = eps[component] / std::sqrt(2); - } + cache_mat.col(ip) = + MathLib::KelvinVector::kelvinVectorToSymmetricTensor(eps); } return cache;