Skip to content
Snippets Groups Projects
Commit 51e1df58 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[MaL] Rename kelvinVectorToTensor().

Also specify all of the template arguments as needed for the MSVC
compiler.
parent e169d832
No related branches found
No related tags found
No related merge requests found
...@@ -58,8 +58,8 @@ Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> inverse( ...@@ -58,8 +58,8 @@ Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> inverse(
} }
template <> template <>
Eigen::Matrix<double, 3, 3> kelvinToTensor( Eigen::Matrix<double, 3, 3> kelvinVectorToTensor(
Eigen::Matrix<double, 4, 1, Eigen::ColMajor> const& v) Eigen::Matrix<double, 4, 1, Eigen::ColMajor, 4, 1> const& v)
{ {
Eigen::Matrix<double, 3, 3> m; 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, 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( ...@@ -68,8 +68,8 @@ Eigen::Matrix<double, 3, 3> kelvinToTensor(
} }
template <> template <>
Eigen::Matrix<double, 3, 3> kelvinToTensor( Eigen::Matrix<double, 3, 3> kelvinVectorToTensor(
Eigen::Matrix<double, 6, 1, Eigen::ColMajor> const& v) Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> const& v)
{ {
Eigen::Matrix<double, 3, 3> m; Eigen::Matrix<double, 3, 3> m;
m << v[0], v[3] / std::sqrt(2.), v[5] / std::sqrt(2.), v[3] / std::sqrt(2.), m << v[0], v[3] / std::sqrt(2.), v[5] / std::sqrt(2.), v[3] / std::sqrt(2.),
......
...@@ -118,8 +118,12 @@ inverse(Eigen::Matrix<double, ...@@ -118,8 +118,12 @@ inverse(Eigen::Matrix<double,
/// Conversion of a Kelvin vector to a 3x3 matrix /// Conversion of a Kelvin vector to a 3x3 matrix
/// Only implementations for KelvinVectorSize 4 and 6 are provided. /// Only implementations for KelvinVectorSize 4 and 6 are provided.
template <int KelvinVectorSize> template <int KelvinVectorSize>
Eigen::Matrix<double, 3, 3> kelvinToTensor( Eigen::Matrix<double, 3, 3> kelvinVectorToTensor(Eigen::Matrix<double,
Eigen::Matrix<double, KelvinVectorSize, 1, Eigen::ColMajor> const& v); KelvinVectorSize,
1,
Eigen::ColMajor,
KelvinVectorSize,
1> const& v);
} // namespace KelvinVector } // namespace KelvinVector
} // namespace MathLib } // namespace MathLib
......
...@@ -72,7 +72,7 @@ struct MaterialLibSolidsKelvinVector6 : public ::testing::Test ...@@ -72,7 +72,7 @@ struct MaterialLibSolidsKelvinVector6 : public ::testing::Test
TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor) TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor)
{ {
auto f = [](KelvinVector<4> const& v) { 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(); 2 * std::numeric_limits<double>::epsilon() * v.norm();
}; };
...@@ -83,7 +83,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor) ...@@ -83,7 +83,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, SelfTestMappingKelvinToTensor)
TEST_F(MaterialLibSolidsKelvinVector6, SelfTestMappingKelvinToTensor) TEST_F(MaterialLibSolidsKelvinVector6, SelfTestMappingKelvinToTensor)
{ {
auto f = [](KelvinVector<6> const& v) { 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(); 1.5 * std::numeric_limits<double>::epsilon() * v.norm();
}; };
...@@ -99,7 +99,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Determinant) ...@@ -99,7 +99,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Determinant)
{ {
auto f = [](KelvinVector<4> const& v) { auto f = [](KelvinVector<4> const& v) {
return std::abs(Invariants<4>::determinant(v) - return std::abs(Invariants<4>::determinant(v) -
kelvinToTensor(v).determinant()) <= kelvinVectorToTensor(v).determinant()) <=
std::numeric_limits<double>::epsilon() * std::numeric_limits<double>::epsilon() *
std::pow(v.norm(), 3.07); std::pow(v.norm(), 3.07);
}; };
...@@ -112,7 +112,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Determinant) ...@@ -112,7 +112,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Determinant)
{ {
auto f = [](KelvinVector<6> const& v) { auto f = [](KelvinVector<6> const& v) {
return std::abs(Invariants<6>::determinant(v) - return std::abs(Invariants<6>::determinant(v) -
kelvinToTensor(v).determinant()) <= kelvinVectorToTensor(v).determinant()) <=
std::numeric_limits<double>::epsilon() * std::numeric_limits<double>::epsilon() *
std::pow(v.norm(), 3.07); std::pow(v.norm(), 3.07);
}; };
...@@ -129,7 +129,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse) ...@@ -129,7 +129,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse)
{ {
auto f = [](KelvinVector<4> const& v) { auto f = [](KelvinVector<4> const& v) {
auto const error = auto const error =
(inverse(v) - tensorToKelvin<4>(kelvinToTensor(v).inverse())) (inverse(v) - tensorToKelvin<4>(kelvinVectorToTensor(v).inverse()))
.norm(); .norm();
// The error is only weekly depending on the input vector 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); return error < 1e-6 && error < 1e-8 * std::pow(v.norm(), 1.4);
...@@ -140,7 +140,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse) ...@@ -140,7 +140,7 @@ TEST_F(MaterialLibSolidsKelvinVector4, Inverse)
ac::make_arbitrary(kelvinVectorGenerator) ac::make_arbitrary(kelvinVectorGenerator)
.discard_if([](KelvinVector<4> const& v) { .discard_if([](KelvinVector<4> const& v) {
// only invertable matrices // only invertable matrices
return (std::abs(kelvinToTensor(v).determinant()) == 0); return (std::abs(kelvinVectorToTensor(v).determinant()) == 0);
}), }),
gtest_reporter); gtest_reporter);
} }
...@@ -149,7 +149,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse) ...@@ -149,7 +149,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse)
{ {
auto f = [](KelvinVector<6> const& v) { auto f = [](KelvinVector<6> const& v) {
auto const error = auto const error =
(inverse(v) - tensorToKelvin<6>(kelvinToTensor(v).inverse())) (inverse(v) - tensorToKelvin<6>(kelvinVectorToTensor(v).inverse()))
.norm(); .norm();
// The error is only weekly depending on the input vector 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); return error < 1e-6 && error < 1e-8 * std::pow(v.norm(), 1.4);
...@@ -160,7 +160,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse) ...@@ -160,7 +160,7 @@ TEST_F(MaterialLibSolidsKelvinVector6, Inverse)
ac::make_arbitrary(kelvinVectorGenerator) ac::make_arbitrary(kelvinVectorGenerator)
.discard_if([](KelvinVector<6> const& v) { .discard_if([](KelvinVector<6> const& v) {
// only invertable matrices // only invertable matrices
return (std::abs(kelvinToTensor(v).determinant()) == 0); return (std::abs(kelvinVectorToTensor(v).determinant()) == 0);
}), }),
gtest_reporter); gtest_reporter);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment