diff --git a/MathLib/KelvinVector.cpp b/MathLib/KelvinVector.cpp index 6490719e5d7e20af883f6573bfdda906cc5dca4c..9dccaff6bb95ebba0e8eb19e301f5ea34ebd7000 100644 --- a/MathLib/KelvinVector.cpp +++ b/MathLib/KelvinVector.cpp @@ -58,8 +58,8 @@ Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> inverse( } template <> -Eigen::Matrix<double, 3, 3> kelvinToTensor( - Eigen::Matrix<double, 4, 1, Eigen::ColMajor> const& v) +Eigen::Matrix<double, 3, 3> kelvinVectorToTensor( + Eigen::Matrix<double, 4, 1, Eigen::ColMajor, 4, 1> const& v) { Eigen::Matrix<double, 3, 3> m; m << v[0], v[3] / std::sqrt(2.), 0, v[3] / std::sqrt(2.), v[1], 0, 0, 0, @@ -68,8 +68,8 @@ Eigen::Matrix<double, 3, 3> kelvinToTensor( } template <> -Eigen::Matrix<double, 3, 3> kelvinToTensor( - Eigen::Matrix<double, 6, 1, Eigen::ColMajor> const& v) +Eigen::Matrix<double, 3, 3> kelvinVectorToTensor( + Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> const& v) { Eigen::Matrix<double, 3, 3> m; m << v[0], v[3] / std::sqrt(2.), v[5] / std::sqrt(2.), v[3] / std::sqrt(2.), diff --git a/MathLib/KelvinVector.h b/MathLib/KelvinVector.h index ac7bf3b21b3b1b5731d0c6838f6ed468d56ad7f9..3274327e755c6f987dd9eea1892559aa55aff427 100644 --- a/MathLib/KelvinVector.h +++ b/MathLib/KelvinVector.h @@ -118,8 +118,12 @@ inverse(Eigen::Matrix<double, /// Conversion of a Kelvin vector to a 3x3 matrix /// Only implementations for KelvinVectorSize 4 and 6 are provided. template <int KelvinVectorSize> -Eigen::Matrix<double, 3, 3> kelvinToTensor( - Eigen::Matrix<double, KelvinVectorSize, 1, Eigen::ColMajor> const& v); +Eigen::Matrix<double, 3, 3> kelvinVectorToTensor(Eigen::Matrix<double, + KelvinVectorSize, + 1, + Eigen::ColMajor, + KelvinVectorSize, + 1> const& v); } // namespace KelvinVector } // namespace MathLib diff --git a/Tests/MaterialLib/KelvinVector.cpp b/Tests/MaterialLib/KelvinVector.cpp index 815bbc78764026e5e7a69e8d4a26017f854cb6b9..b7be7b8115346045c651e153dc9dd9feea8475bc 100644 --- a/Tests/MaterialLib/KelvinVector.cpp +++ b/Tests/MaterialLib/KelvinVector.cpp @@ -72,7 +72,7 @@ struct MaterialLibSolidsKelvinVector6 : public ::testing::Test TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor) { auto f = [](KelvinVector<4> const& v) { - return (v - tensorToKelvin<4>(kelvinToTensor(v))).norm() <= + return (v - tensorToKelvin<4>(kelvinVectorToTensor(v))).norm() <= 2 * std::numeric_limits<double>::epsilon() * v.norm(); }; @@ -83,7 +83,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor) TEST_F(MaterialLibSolidsKelvinVector6, SelfTestMappingKelvinToTensor) { auto f = [](KelvinVector<6> const& v) { - return (v - tensorToKelvin<6>(kelvinToTensor(v))).norm() <= + return (v - tensorToKelvin<6>(kelvinVectorToTensor(v))).norm() <= 1.5 * std::numeric_limits<double>::epsilon() * v.norm(); }; @@ -99,7 +99,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Determinant) { auto f = [](KelvinVector<4> const& v) { return std::abs(Invariants<4>::determinant(v) - - kelvinToTensor(v).determinant()) <= + kelvinVectorToTensor(v).determinant()) <= std::numeric_limits<double>::epsilon() * std::pow(v.norm(), 3.07); }; @@ -112,7 +112,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Determinant) { auto f = [](KelvinVector<6> const& v) { return std::abs(Invariants<6>::determinant(v) - - kelvinToTensor(v).determinant()) <= + kelvinVectorToTensor(v).determinant()) <= std::numeric_limits<double>::epsilon() * std::pow(v.norm(), 3.07); }; @@ -129,7 +129,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse) { auto f = [](KelvinVector<4> const& v) { auto const error = - (inverse(v) - tensorToKelvin<4>(kelvinToTensor(v).inverse())) + (inverse(v) - tensorToKelvin<4>(kelvinVectorToTensor(v).inverse())) .norm(); // The error is only weekly depending on the input vector norm. return error < 1e-6 && error < 1e-8 * std::pow(v.norm(), 1.4); @@ -140,7 +140,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse) ac::make_arbitrary(kelvinVectorGenerator) .discard_if([](KelvinVector<4> const& v) { // only invertable matrices - return (std::abs(kelvinToTensor(v).determinant()) == 0); + return (std::abs(kelvinVectorToTensor(v).determinant()) == 0); }), gtest_reporter); } @@ -149,7 +149,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse) { auto f = [](KelvinVector<6> const& v) { auto const error = - (inverse(v) - tensorToKelvin<6>(kelvinToTensor(v).inverse())) + (inverse(v) - tensorToKelvin<6>(kelvinVectorToTensor(v).inverse())) .norm(); // The error is only weekly depending on the input vector norm. return error < 1e-6 && error < 1e-8 * std::pow(v.norm(), 1.4); @@ -160,7 +160,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse) ac::make_arbitrary(kelvinVectorGenerator) .discard_if([](KelvinVector<6> const& v) { // only invertable matrices - return (std::abs(kelvinToTensor(v).determinant()) == 0); + return (std::abs(kelvinVectorToTensor(v).determinant()) == 0); }), gtest_reporter); }