diff --git a/MathLib/KelvinVector.cpp b/MathLib/KelvinVector.cpp index df6f49ca8203fc5524c44b09425db8c4be7d4320..eca0cf8263021ee6a7fb2dfe4287115b053db920 100644 --- a/MathLib/KelvinVector.cpp +++ b/MathLib/KelvinVector.cpp @@ -180,8 +180,27 @@ kelvinVectorToSymmetricTensor(Eigen::Matrix<double, v.size()); } -KelvinMatrixType<3> fourthOrderRotationMatrix( - Eigen::Matrix3d const& transformation) +template <> +KelvinMatrixType<2> fourthOrderRotationMatrix<2>( + Eigen::Matrix<double, 2, 2> const& transformation) +{ + // 1-based index access for convenience. + auto Q = [&](int const i, int const j) { + return transformation(i - 1, j - 1); + }; + + MathLib::KelvinVector::KelvinMatrixType<2> R; + R << Q(1, 1) * Q(1, 1), Q(1, 2) * Q(1, 2), 0, + std::sqrt(2) * Q(1, 1) * Q(1, 2), Q(2, 1) * Q(2, 1), Q(2, 2) * Q(2, 2), + 0, std::sqrt(2) * Q(2, 1) * Q(2, 2), 0, 0, 1, 0, + std::sqrt(2) * Q(1, 1) * Q(2, 1), std::sqrt(2) * Q(1, 2) * Q(2, 2), 0, + Q(1, 1) * Q(2, 2) + Q(1, 2) * Q(2, 1); + return R; +} + +template <> +KelvinMatrixType<3> fourthOrderRotationMatrix<3>( + Eigen::Matrix<double, 3, 3> const& transformation) { // 1-based index access for convenience. auto Q = [&](int const i, int const j) { diff --git a/MathLib/KelvinVector.h b/MathLib/KelvinVector.h index 2e5043dc37523e7a67765d6005104069bf5fe7d3..c6c09e45101c7ea4a6aa83279ce9d960d4989a50 100644 --- a/MathLib/KelvinVector.h +++ b/MathLib/KelvinVector.h @@ -238,8 +238,11 @@ KelvinVectorType<DisplacementDim> symmetricTensorToKelvinVector( /// Rotation tensor for Kelvin mapped vectors and tensors. It is meant to be /// used for rotation of stress/strain tensors epsilon:Q and tangent stiffness /// tensors Q*C*Q^t. -KelvinMatrixType<3> fourthOrderRotationMatrix( - Eigen::Matrix3d const& transformation); +/// 2D and 3D implementations available. +template <int DisplacementDim> +KelvinMatrixType<DisplacementDim> fourthOrderRotationMatrix( + Eigen::Matrix<double, DisplacementDim, DisplacementDim> const& + transformation); } // namespace KelvinVector } // namespace MathLib