diff --git a/MathLib/KelvinVector.cpp b/MathLib/KelvinVector.cpp index 0c6718ddb8f9b2d73b066ed5cf3420ab59d19240..1359f452a8da828e7910b629659470c4553ae52b 100644 --- a/MathLib/KelvinVector.cpp +++ b/MathLib/KelvinVector.cpp @@ -80,6 +80,32 @@ Eigen::Matrix<double, 3, 3> kelvinVectorToTensor( return m; } +template <> +Eigen::Matrix<double, 3, 3> kelvinVectorToTensor(Eigen::Matrix<double, + Eigen::Dynamic, + 1, + Eigen::ColMajor, + Eigen::Dynamic, + 1> const& v) +{ + if (v.size() == 4) + { + Eigen::Matrix<double, 4, 1, Eigen::ColMajor, 4, 1> v4; + v4 << v[0], v[1], v[2], v[3]; + return kelvinVectorToTensor(v4); + } + if (v.size() == 6) + { + Eigen::Matrix<double, 6, 1, Eigen::ColMajor, 6, 1> v6; + v6 << v[0], v[1], v[2], v[3], v[4], v[5]; + return kelvinVectorToTensor(v6); + } + OGS_FATAL( + "Conversion of dynamic Kelvin vector of size %d to a tensor is not " + "possible. Kelvin vector must be of size 4 or 6.", + v.size()); +} + template <> KelvinVectorType<2> tensorToKelvin<2>(Eigen::Matrix<double, 3, 3> const& m) {