OGS
GetSymmetricTensor.cpp
Go to the documentation of this file.
1/*
2 * \file
3 * \copyright
4 * Copyright (c) 2012-2024, 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
15
16namespace MaterialPropertyLib
17{
18template <int GlobalDim>
20{
21 SymmetricTensor<GlobalDim> operator()(double const& value) const
22 {
24 result.template head<3>() = Eigen::Vector3d::Constant(value);
25 return result;
26 }
27
28 SymmetricTensor<GlobalDim> operator()(Eigen::Vector2d const& values) const
29 {
31 result.template head<2>() = values;
32 return result;
33 }
34
35 SymmetricTensor<GlobalDim> operator()(Eigen::Vector3d const& values) const
36 {
38 result.template head<3>() = values;
39 return result;
40 }
41
42 SymmetricTensor<GlobalDim> operator()(Eigen::Matrix2d const& values) const
43 {
44 if constexpr (GlobalDim == 2)
45 {
47 result << values(0, 0), values(1, 1), 0., values(0, 1);
48 return result;
49 }
50 OGS_FATAL("Cannot convert 2d matrix to 3d symmetric Tensor.");
51 }
52
53 SymmetricTensor<GlobalDim> operator()(Eigen::Matrix3d const& values) const
54 {
55 if constexpr (GlobalDim == 3)
56 {
58 result << values(0, 0), values(1, 1), values(2, 2), values(0, 1),
59 values(1, 2), values(0, 2);
60 return result;
61 }
62 OGS_FATAL("Cannot convert 3d matrix to 2d symmetric Tensor.");
63 }
64
66 SymmetricTensor<2> const& values) const
67 {
68 if constexpr (GlobalDim == 2)
69 {
70 return values;
71 }
72 OGS_FATAL("Cannot convert 3d symmetric tensor to 2d symmetric tensor.");
73 }
74
76 SymmetricTensor<3> const& values) const
77 {
78 if constexpr (GlobalDim == 3)
79 {
80 return values;
81 }
82 OGS_FATAL("Cannot convert 2d symmetric tensor to 3d symmetric tensor.");
83 }
84
86 Eigen::MatrixXd const& /*values*/) const
87 {
89 "Cannot convert dynamic Eigen matrix to {:d}d symmetric tensor.",
90 GlobalDim);
91 }
92};
93
94template <int GlobalDim>
100
101template Eigen::Matrix<double, 4, 1> getSymmetricTensor<2>(
103
104template Eigen::Matrix<double, 6, 1> getSymmetricTensor<3>(
106
107} // 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::Vector3d const &values) const
SymmetricTensor< GlobalDim > operator()(Eigen::MatrixXd const &) 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