diff --git a/MaterialLib/MPL/Properties/Constant.cpp b/MaterialLib/MPL/Properties/Constant.cpp index b7f199bbcf39e005758778afd0b72f78d810c278..914b8b436bea6d35c6558e5f89d0abc5eea68658 100644 --- a/MaterialLib/MPL/Properties/Constant.cpp +++ b/MaterialLib/MPL/Properties/Constant.cpp @@ -46,6 +46,11 @@ struct ZeroInitPropertyDataType { return Eigen::Matrix<double, 6, 1>::Zero().eval(); } + + PropertyDataType operator()(Eigen::MatrixXd) const + { + return Eigen::MatrixXd(0, 0); + } }; Constant::Constant(std::string name, PropertyDataType const& v) diff --git a/MaterialLib/MPL/Property.h b/MaterialLib/MPL/Property.h index 17cfb87caa3806600adc8f802bd0c357e10805c6..026b257fef231a82ea61805f6713f360dc821776 100644 --- a/MaterialLib/MPL/Property.h +++ b/MaterialLib/MPL/Property.h @@ -32,7 +32,7 @@ using PropertyDataType = std::variant<double, Eigen::Matrix<double, 2, 1>, Eigen::Matrix<double, 3, 1>, Eigen::Matrix<double, 2, 2>, Eigen::Matrix<double, 3, 3>, Eigen::Matrix<double, 4, 1>, - Eigen::Matrix<double, 6, 1>>; + Eigen::Matrix<double, 6, 1>, Eigen::MatrixXd>; /// Conversion of a vector to PropertyDataType for different sizes of the /// vector. @@ -300,8 +300,9 @@ private: private: /// Corresponds to the PropertyDataType static constexpr std::array property_data_type_names_ = { - "scalar", "2-vector", "3-vector", "2x2-matrix", - "3x3-matrix", "2D-Kelvin vector", "3D-Kelvin vector"}; + "scalar", "2-vector", "3-vector", + "2x2-matrix", "3x3-matrix", "2D-Kelvin vector", + "3D-Kelvin vector", "dynamic matrix type"}; static_assert(property_data_type_names_.size() == std::variant_size_v<PropertyDataType>, "The array of property data type names has different size " diff --git a/MaterialLib/MPL/Utils/FormEigenTensor.cpp b/MaterialLib/MPL/Utils/FormEigenTensor.cpp index 596c339944ea11fb0bf438d8e3f46359156c9e2e..c7ea5b1880fc64ccd886fcefd8446ca3d0b0d73d 100644 --- a/MaterialLib/MPL/Utils/FormEigenTensor.cpp +++ b/MaterialLib/MPL/Utils/FormEigenTensor.cpp @@ -97,6 +97,37 @@ struct FormEigenTensor OGS_FATAL("Cannot convert a symmetric 3d tensor to {:d}x{:d} matrix", GlobalDim); } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + Eigen::MatrixXd const& values) const + { + if constexpr (GlobalDim == 3) + { + if (values.rows() != 6 && values.cols() != 1) + { + OGS_FATAL("Input wrong size."); + } + Eigen::Matrix<double, GlobalDim, GlobalDim> result; + result << values(0, 0), values(3, 0), values(5, 0), values(3, 0), + values(1, 0), values(4, 0), values(5, 0), values(4, 0), + values(2, 0); + return result; + } + if constexpr (GlobalDim == 2) + { + if (values.rows() != 4 && values.cols() != 1) + { + OGS_FATAL("Input wrong size."); + } + // skip the z-direction in this case + Eigen::Matrix<double, GlobalDim, GlobalDim> result; + result << values(0, 0), values(3, 0), values(3, 0), values(1, 0); + return result; + } + + OGS_FATAL("Cannot convert something TODO to {:d}x{:d} matrix", + GlobalDim); + } }; template <int GlobalDim> @@ -115,4 +146,10 @@ template Eigen::Matrix<double, 2, 2> formEigenTensor<2>( template Eigen::Matrix<double, 3, 3> formEigenTensor<3>( MaterialPropertyLib::PropertyDataType const& values); +template Eigen::Matrix<double, 4, 4> formEigenTensor<4>( + MaterialPropertyLib::PropertyDataType const& values); + +template Eigen::Matrix<double, 6, 6> formEigenTensor<6>( + MaterialPropertyLib::PropertyDataType const& values); + } // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Utils/FormEigenVector.cpp b/MaterialLib/MPL/Utils/FormEigenVector.cpp index c1936821ada0f29f1bc14c12d1442ac5e1d0e9a1..edc3b97cbaf4b789a940426892ec4b81bee47ac3 100644 --- a/MaterialLib/MPL/Utils/FormEigenVector.cpp +++ b/MaterialLib/MPL/Utils/FormEigenVector.cpp @@ -76,6 +76,13 @@ struct FormEigenVector { OGS_FATAL("Cannot convert a 6d vector to a {:d}d vector.", GlobalDim); } + + Eigen::Matrix<double, GlobalDim, 1> operator()( + Eigen::MatrixXd const& /*values*/) const + { + OGS_FATAL("Cannot convert dynamic Eigen matrix to a {:d}d vector ", + GlobalDim); + } }; template <int GlobalDim> diff --git a/MaterialLib/MPL/Utils/FormKelvinVectorFromThermalExpansivity.cpp b/MaterialLib/MPL/Utils/FormKelvinVectorFromThermalExpansivity.cpp index 1509f87aaff5a1f81c76c7077e349ccde0899c5a..77ada64578a8a792622fc1aa940657efb2d2e7f1 100644 --- a/MaterialLib/MPL/Utils/FormKelvinVectorFromThermalExpansivity.cpp +++ b/MaterialLib/MPL/Utils/FormKelvinVectorFromThermalExpansivity.cpp @@ -70,6 +70,12 @@ struct FormKelvinVectorFromThermalExpansivity { OGS_FATAL(error_info); } + + MathLib::KelvinVector::KelvinVectorType<GlobalDim> operator()( + Eigen::MatrixXd const& /*values*/) const + { + OGS_FATAL(error_info); + } }; template <int GlobalDim> diff --git a/MaterialLib/MPL/Utils/GetSymmetricTensor.cpp b/MaterialLib/MPL/Utils/GetSymmetricTensor.cpp index 84eaf0b65bc88f8895d29fb89dd00810a3743465..01fd674d5be2b8336b89d33e5cf7d11e016597a0 100644 --- a/MaterialLib/MPL/Utils/GetSymmetricTensor.cpp +++ b/MaterialLib/MPL/Utils/GetSymmetricTensor.cpp @@ -81,6 +81,14 @@ struct GetSymmetricTensor } OGS_FATAL("Cannot convert 2d symmetric tensor to 3d symmetric tensor."); } + + SymmetricTensor<GlobalDim> operator()( + Eigen::MatrixXd const& /*values*/) const + { + OGS_FATAL( + "Cannot convert dynamic Eigen matrix to {:d}d symmetric tensor.", + GlobalDim); + } }; template <int GlobalDim>