OGS
GetSymmetricTensor.cpp
Go to the documentation of this file.
1/*
2 * \file
3 * \copyright
4 * Copyright (c) 2012-2025, OpenGeoSys Community (http://www.opengeosys.org)
5 * Distributed under a Modified BSD License.
6 * See accompanying file LICENSE.txt or
7 * http://www.opengeosys.org/project/license
8 *
9 * Created on March 04, 2020, 5:20 PM
10 */
11
12#include "GetSymmetricTensor.h"
13
16
17namespace MaterialPropertyLib
18{
19template <int GlobalDim>
21{
22 SymmetricTensor<GlobalDim> operator()(double const& value) const
23 {
25 result.template head<3>() = Eigen::Vector3d::Constant(value);
26 return result;
27 }
28
29 SymmetricTensor<GlobalDim> operator()(Eigen::Vector2d const& values) const
30 {
32 result.template head<2>() = values;
33 return result;
34 }
35
36 SymmetricTensor<GlobalDim> operator()(Eigen::Vector3d const& values) const
37 {
39 result.template head<3>() = values;
40 return result;
41 }
42
43 SymmetricTensor<GlobalDim> operator()(Eigen::Matrix2d const& values) const
44 {
45 if constexpr (GlobalDim == 2)
46 {
48 result << values(0, 0), values(1, 1), 0., values(0, 1);
49 return result;
50 }
52 "Cannot convert 2d matrix with values [{}] to 3d symmetric Tensor.",
53 values);
54 }
55
56 SymmetricTensor<GlobalDim> operator()(Eigen::Matrix3d const& values) const
57 {
58 if constexpr (GlobalDim == 3)
59 {
61 result << values(0, 0), values(1, 1), values(2, 2), values(0, 1),
62 values(1, 2), values(0, 2);
63 return result;
64 }
66 "Cannot convert 3d matrix with values [{}] to 2d symmetric "
67 "Tensor.",
68 values);
69 }
70
72 SymmetricTensor<2> const& values) const
73 {
74 if constexpr (GlobalDim == 2)
75 {
76 return values;
77 }
79 "Cannot convert 3d symmetric tensor with values [{}] to 2d "
80 "symmetric tensor.",
81 values);
82 }
83
85 SymmetricTensor<3> const& values) const
86 {
87 if constexpr (GlobalDim == 3)
88 {
89 return values;
90 }
92 "Cannot convert 2d symmetric tensor with values [{}] to 3d "
93 "symmetric tensor.",
94 values);
95 }
96
97 SymmetricTensor<GlobalDim> operator()(Eigen::MatrixXd const& values) const
98 {
100 "Cannot convert dynamic Eigen {}x{} matrix with values [{}] to "
101 "{:d}d symmetric tensor.",
102 values.rows(), values.cols(), values, GlobalDim);
103 }
104};
105
106template <int GlobalDim>
112
113template Eigen::Matrix<double, 4, 1> getSymmetricTensor<2>(
115
116template Eigen::Matrix<double, 6, 1> getSymmetricTensor<3>(
118
119} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
template Eigen::Matrix< double, 4, 1 > getSymmetricTensor< 2 >(MaterialPropertyLib::PropertyDataType const &values)
template Eigen::Matrix< double, 6, 1 > getSymmetricTensor< 3 >(MaterialPropertyLib::PropertyDataType const &values)
Eigen::Matrix< double, symmetric_tensor_size< GlobalDim >, 1 > SymmetricTensor
SymmetricTensor< GlobalDim > getSymmetricTensor(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
Definition Property.h:31
SymmetricTensor< GlobalDim > operator()(double const &value) const
SymmetricTensor< GlobalDim > operator()(Eigen::MatrixXd const &values) const
SymmetricTensor< GlobalDim > operator()(Eigen::Vector3d const &values) const
SymmetricTensor< GlobalDim > operator()(Eigen::Matrix2d const &values) const
SymmetricTensor< GlobalDim > operator()(Eigen::Vector2d const &values) const
SymmetricTensor< GlobalDim > operator()(Eigen::Matrix3d const &values) const
SymmetricTensor< GlobalDim > operator()(SymmetricTensor< 2 > const &values) const
SymmetricTensor< GlobalDim > operator()(SymmetricTensor< 3 > const &values) const