18template <
int GlobalDim>
22 double const& value)
const
24 return Eigen::Matrix<double, GlobalDim, GlobalDim>::Identity() * value;
28 Eigen::Vector2d
const& values)
const
30 if constexpr (GlobalDim == 2)
32 return values.asDiagonal();
34 OGS_FATAL(
"Cannot convert 2d vector to {:d}x{:d} diagonal matrix.",
35 GlobalDim, GlobalDim);
39 Eigen::Vector3d
const& values)
const
41 if constexpr (GlobalDim == 3)
43 return values.asDiagonal();
45 OGS_FATAL(
"Cannot convert 3d vector to {:d}x{:d} diagonal matrix.",
46 GlobalDim, GlobalDim);
50 Eigen::Matrix<double, 2, 2>
const& values)
const
52 if constexpr (GlobalDim == 2)
56 OGS_FATAL(
"Cannot convert a 2d tensor to {:d}x{:d} matrix", GlobalDim,
60 Eigen::Matrix<double, 3, 3>
const& values)
const
62 if constexpr (GlobalDim == 3)
66 OGS_FATAL(
"Cannot convert a 3d tensor to {:d}x{:d} matrix", GlobalDim,
71 Eigen::Matrix<double, 4, 1>
const& values)
const
73 Eigen::Matrix<double, GlobalDim, GlobalDim> result;
74 if constexpr (GlobalDim == 2)
76 result << values[0], values[3], values[3], values[1];
78 if constexpr (GlobalDim == 3)
80 result << values[0], values[3], 0, values[3], values[1], 0, 0, 0,
87 Eigen::Matrix<double, 6, 1>
const& values)
const
89 if constexpr (GlobalDim == 3)
91 Eigen::Matrix<double, GlobalDim, GlobalDim> result;
92 result << values[0], values[3], values[5], values[3], values[1],
93 values[4], values[5], values[4], values[2];
97 OGS_FATAL(
"Cannot convert a symmetric 3d tensor to a {}x{} matrix",
98 GlobalDim, GlobalDim);
102 Eigen::MatrixXd
const& values)
const
104 if (GlobalDim == values.rows() && GlobalDim == values.cols())
109 OGS_FATAL(
"Cannot convert a dynamic {}x{} matrix to a {}x{} matrix",
110 values.rows(), values.cols(), GlobalDim, GlobalDim);
114template <
int GlobalDim>
template Eigen::Matrix< double, 4, 4 > formEigenTensor< 4 >(MaterialPropertyLib::PropertyDataType const &values)
template Eigen::Matrix< double, 6, 6 > formEigenTensor< 6 >(MaterialPropertyLib::PropertyDataType const &values)
template Eigen::Matrix< double, 3, 3 > formEigenTensor< 3 >(MaterialPropertyLib::PropertyDataType const &values)
Eigen::Matrix< double, GlobalDim, GlobalDim > formEigenTensor(MaterialPropertyLib::PropertyDataType const &values)
template Eigen::Matrix< double, 1, 1 > formEigenTensor< 1 >(MaterialPropertyLib::PropertyDataType const &values)
template Eigen::Matrix< double, 2, 2 > formEigenTensor< 2 >(MaterialPropertyLib::PropertyDataType const &values)
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::MatrixXd > PropertyDataType