From 51e1df5886e4dbaa2c046305ae6f882a6fccd217 Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Mon, 29 Jan 2018 21:54:43 +0100
Subject: [PATCH] [MaL] Rename kelvinVectorToTensor().

Also specify all of the template arguments as needed for the MSVC
compiler.
---
 MathLib/KelvinVector.cpp           |  8 ++++----
 MathLib/KelvinVector.h             |  8 ++++++--
 Tests/MaterialLib/KelvinVector.cpp | 16 ++++++++--------
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/MathLib/KelvinVector.cpp b/MathLib/KelvinVector.cpp
index 6490719e5d7..9dccaff6bb9 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 ac7bf3b21b3..3274327e755 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 815bbc78764..b7be7b81153 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);
 }
-- 
GitLab