OGS
ParameterLib::CoordinateSystem Struct Referencefinal

Detailed Description

A local coordinate system used for tensor transformations.

It offers a simple way for input of anisotropic tensors w.r.t. a coordinate system. The basis vectors form a transformation matrix \(R = (e_0, e_1, e_2)\). For a given anisotropic tensor \(A\) parameter with the corresponding [tag] use_local_coordinate_system the tensor is rotated according to the formula: \(A' = R\cdot A\cdot R^T\).

For computations in transverse isotropic material models, we can create a coordinate system with only one base, where the last base is explicitly given. The other bases are set as implicit and computed from the given base as follows:

  • For a 2D coordinate system, the unit vector orthogonal to the given base is used as the first base,
  • For a 3D coordinate system, the given base vector, unit_direction, is set as the third base, \({\vec e}_2\). An arbitrary unit vector orthogonal to \({\vec e}_2\) is selected as the second base \(e_1\), and the first base \({\vec e}_0\) is calculated as \({\vec e}_0 = {\vec e}_1 \times {\vec e}_2\).

Definition at line 41 of file ParameterLib/CoordinateSystem.h.

#include <CoordinateSystem.h>

Public Member Functions

 CoordinateSystem (Parameter< double > const &unit_direction)
 CoordinateSystem (Parameter< double > const &e0, Parameter< double > const &e1)
 CoordinateSystem (Parameter< double > const &e0, Parameter< double > const &e1, Parameter< double > const &e2)
template<int Dimension>
Eigen::Matrix< double, Dimension, Dimension > transformation (SpatialPosition const &pos) const
Eigen::Matrix< double, 3, 3 > transformation_3d (SpatialPosition const &pos) const
template<int Dimension>
Eigen::Matrix< double, Dimension, Dimension > rotateTensor (std::vector< double > const &values, SpatialPosition const &pos) const
template<int Dimension, typename Derived>
Eigen::Matrix< double, Dimension, Dimension > rotateTensor (Eigen::MatrixBase< Derived > const &tensor, SpatialPosition const &pos) const
template<int Dimension>
Eigen::Matrix< double, Dimension, Dimension > rotateDiagonalTensor (std::vector< double > const &values, SpatialPosition const &pos) const
template<>
Eigen::Matrix< double, 2, 2 > transformation (SpatialPosition const &pos) const
template<>
Eigen::Matrix< double, 3, 3 > transformation (SpatialPosition const &pos) const

Private Member Functions

Eigen::Matrix< double, 3, 3 > transformationFromSingleBase_3d (SpatialPosition const &pos) const

Private Attributes

std::array< Parameter< double > const *, 3 > _base
bool _has_implicit_base

Constructor & Destructor Documentation

◆ CoordinateSystem() [1/3]

ParameterLib::CoordinateSystem::CoordinateSystem ( Parameter< double > const & unit_direction)
explicit

It is used to create a local coordinate system with only one base, where the last base is explicitly given as unit_direction.

Parameters
unit_directionThe specified unit direction.

Definition at line 61 of file ParameterLib/CoordinateSystem.cpp.

62 : _base{nullptr, nullptr, &unit_direction}, _has_implicit_base(true)
63{
64 if (_base[2]->isTimeDependent())
65 {
67 "The unit_normal parameter named {} must not be time dependent.",
68 unit_direction.name);
69 }
70}
#define OGS_FATAL(...)
Definition Error.h:19
std::array< Parameter< double > const *, 3 > _base

References _base, _has_implicit_base, ParameterLib::ParameterBase::name, and OGS_FATAL.

◆ CoordinateSystem() [2/3]

ParameterLib::CoordinateSystem::CoordinateSystem ( Parameter< double > const & e0,
Parameter< double > const & e1 )

Definition at line 72 of file ParameterLib/CoordinateSystem.cpp.

74 : _base{&e0, &e1, nullptr}, _has_implicit_base(false)
75{
76 if (typeid(_base[0]) != typeid(_base[1]))
77 {
79 "The parameter types for the basis must be equal but they are "
80 "'{:s}' and '{:s}'.",
83 }
84 if (_base[0]->isTimeDependent() || _base[1]->isTimeDependent())
85 {
86 OGS_FATAL("The parameters for the basis must not be time dependent.");
87 }
88 if (_base[0]->getNumberOfGlobalComponents() != 2 ||
89 _base[1]->getNumberOfGlobalComponents() != 2)
90 {
91 OGS_FATAL("The parameters for the 2D basis must have two components.");
92 }
93}
std::string typeToString()

References _base, _has_implicit_base, OGS_FATAL, and BaseLib::typeToString().

◆ CoordinateSystem() [3/3]

ParameterLib::CoordinateSystem::CoordinateSystem ( Parameter< double > const & e0,
Parameter< double > const & e1,
Parameter< double > const & e2 )

Definition at line 95 of file ParameterLib/CoordinateSystem.cpp.

98 : _base{&e0, &e1, &e2}, _has_implicit_base(false)
99{
100 if ((typeid(_base[0]) != typeid(_base[1])) ||
101 (typeid(_base[1]) != typeid(_base[2])) ||
102 (typeid(_base[2]) != typeid(_base[0])))
103 {
104 OGS_FATAL(
105 "The parameter types for the basis must be equal but they are "
106 "'{:s}', '{:s}', and '{:s}'.",
110 }
111 if (_base[0]->isTimeDependent() || _base[1]->isTimeDependent(),
112 _base[2]->isTimeDependent())
113 {
114 OGS_FATAL("The parameters for the basis must not be time dependent.");
115 }
116 if (_base[0]->getNumberOfGlobalComponents() != 3 ||
117 _base[1]->getNumberOfGlobalComponents() != 3 ||
118 _base[2]->getNumberOfGlobalComponents() != 3)
119 {
120 OGS_FATAL(
121 "The parameters for the 3D basis must have three components.");
122 }
123}

References _base, _has_implicit_base, OGS_FATAL, and BaseLib::typeToString().

Member Function Documentation

◆ rotateDiagonalTensor()

template<int Dimension>
template Eigen::Matrix< double, 3, 3 > ParameterLib::CoordinateSystem::rotateDiagonalTensor< 3 > ( std::vector< double > const & values,
SpatialPosition const & pos ) const

Definition at line 295 of file ParameterLib/CoordinateSystem.cpp.

297{
298 assert(values.size() == Dimension ||
299 "Input vector has wrong dimension; expected 2 or 3 entries.");
300 auto const tensor = Eigen::Map<Eigen::Matrix<double, Dimension, 1> const>(
301 values.data(), Dimension, 1);
302 auto const R = transformation<Dimension>(pos);
303 return R * tensor.asDiagonal() * R.transpose();
304}
Eigen::Matrix< double, Dimension, Dimension > transformation(SpatialPosition const &pos) const

References transformation().

◆ rotateTensor() [1/2]

template<int Dimension, typename Derived>
Eigen::Matrix< double, Dimension, Dimension > ParameterLib::CoordinateSystem::rotateTensor ( Eigen::MatrixBase< Derived > const & tensor,
SpatialPosition const & pos ) const

Definition at line 86 of file ParameterLib/CoordinateSystem.h.

88{
89 auto const R = transformation<Dimension>(pos);
90 return R * tensor * R.transpose();
91}

References transformation().

◆ rotateTensor() [2/2]

template<int Dimension>
template Eigen::Matrix< double, 3, 3 > ParameterLib::CoordinateSystem::rotateTensor< 3 > ( std::vector< double > const & values,
SpatialPosition const & pos ) const

Definition at line 282 of file ParameterLib/CoordinateSystem.cpp.

284{
285 assert(values.size() == Dimension * Dimension ||
286 "Input vector has wrong dimension; expected 4 or 9 entries.");
287 auto const tensor =
288 Eigen::Map<Eigen::Matrix<double, Dimension, Dimension> const>(
289 values.data(), Dimension, Dimension);
290 return rotateTensor<Dimension>(tensor, pos);
291}
Eigen::Matrix< double, Dimension, Dimension > rotateTensor(std::vector< double > const &values, SpatialPosition const &pos) const

References rotateTensor().

Referenced by rotateTensor().

◆ transformation() [1/3]

template<>
Eigen::Matrix< double, 2, 2 > ParameterLib::CoordinateSystem::transformation ( SpatialPosition const & pos) const

Definition at line 125 of file ParameterLib/CoordinateSystem.cpp.

144{
146 {
148 }
149
150 if (_base[2] != nullptr)
151 {
152 OGS_FATAL(
153 "The coordinate system is 3D but a transformation for 2D case is "
154 "requested.");
155 }
156
157 Eigen::Matrix<double, 2, 2> t;
158 t.col(0) = Eigen::Map<Eigen::Vector2d>(
159 (*_base[0])(0 /* time independent */, pos).data());
160 t.col(1) = Eigen::Map<Eigen::Vector2d>(
161 (*_base[1])(0 /* time independent */, pos).data());
162
164 return t;
165}
Eigen::Matrix< double, 2, 2 > getTransformationFromSingleBase2D(Parameter< double > const &unit_direction, SpatialPosition const &pos)
static void checkTransformationIsSON(Eigen::Matrix< double, Dim, Dim, Eigen::ColMajor, Dim, Dim > const &t)

References ParameterLib::checkNormalization(), ParameterLib::checkTransformationIsSON(), and ParameterLib::ParameterBase::name.

◆ transformation() [2/3]

template<>
Eigen::Matrix< double, 3, 3 > ParameterLib::CoordinateSystem::transformation ( SpatialPosition const & pos) const

Definition at line 167 of file ParameterLib/CoordinateSystem.cpp.

218{
220 {
222 }
223
224 if (_base[2] == nullptr)
225 {
226 OGS_FATAL(
227 "The coordinate system is 2D but a transformation for 3D case is "
228 "requested.");
229 }
230
231 Eigen::Matrix<double, 3, 3> t;
232 t.col(0) = Eigen::Map<Eigen::Vector3d>(
233 (*_base[0])(0 /* time independent */, pos).data());
234 t.col(1) = Eigen::Map<Eigen::Vector3d>(
235 (*_base[1])(0 /* time independent */, pos).data());
236 t.col(2) = Eigen::Map<Eigen::Vector3d>(
237 (*_base[2])(0 /* time independent */, pos).data());
238
240 return t;
241}
Eigen::Matrix< double, 3, 3 > getTransformationFromSingleBase3D(Parameter< double > const &unit_direction, SpatialPosition const &pos)

References ParameterLib::checkNormalization(), ParameterLib::checkTransformationIsSON(), ParameterLib::ParameterBase::name, and ParameterLib::tolerance.

◆ transformation() [3/3]

template<int Dimension>
Eigen::Matrix< double, Dimension, Dimension > ParameterLib::CoordinateSystem::transformation ( SpatialPosition const & pos) const

◆ transformation_3d()

Eigen::Matrix< double, 3, 3 > ParameterLib::CoordinateSystem::transformation_3d ( SpatialPosition const & pos) const

Definition at line 259 of file ParameterLib/CoordinateSystem.cpp.

261{
263 {
265 }
266
267 if (_base[2] != nullptr)
268 {
269 return transformation<3>(pos);
270 }
271
272 auto e0 = (*_base[0])(0 /* time independent */, pos);
273 auto e1 = (*_base[1])(0 /* time independent */, pos);
274 Eigen::Matrix<double, 3, 3> t = Eigen::Matrix<double, 3, 3>::Identity();
275 t.template topLeftCorner<2, 2>() << e0[0], e1[0], e0[1], e1[1];
276
278 return t;
279}
Eigen::Matrix< double, 3, 3 > transformationFromSingleBase_3d(SpatialPosition const &pos) const

References _base, _has_implicit_base, ParameterLib::checkTransformationIsSON(), transformation(), and transformationFromSingleBase_3d().

◆ transformationFromSingleBase_3d()

Eigen::Matrix< double, 3, 3 > ParameterLib::CoordinateSystem::transformationFromSingleBase_3d ( SpatialPosition const & pos) const
private

Definition at line 243 of file ParameterLib/CoordinateSystem.cpp.

245{
246 // If base 2, which stores the unit direction vector, has three components:
247 if ((*_base[2])(0 /* time independent */, pos).size() == 3)
248 {
250 }
251
252 // If base 2, which stores the unit direction vector, has two components
253 Eigen::Matrix<double, 3, 3> t = Eigen::Matrix<double, 3, 3>::Identity();
254 t.template topLeftCorner<2, 2>() = transformation<2>(pos);
255
256 return t;
257}
constexpr int size(int const displacement_dim)
Vectorized tensor size for given displacement dimension.

References _base, ParameterLib::getTransformationFromSingleBase3D(), and transformation().

Referenced by transformation_3d().

Member Data Documentation

◆ _base

std::array<Parameter<double> const*, 3> ParameterLib::CoordinateSystem::_base
private

◆ _has_implicit_base

bool ParameterLib::CoordinateSystem::_has_implicit_base
private

The documentation for this struct was generated from the following files: