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 48 of file 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>
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 36 of file CoordinateSystem.cpp.

37 : _base{nullptr, nullptr, &unit_direction}, _has_implicit_base(true)
38{
39 if (_base[2]->isTimeDependent())
40 {
42 "The unit_normal parameter named {} must not be time dependent.",
43 unit_direction.name);
44 }
45}
#define OGS_FATAL(...)
Definition: Error.h:26
std::array< Parameter< double > const *, 3 > _base

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

◆ CoordinateSystem() [2/3]

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

Definition at line 47 of file CoordinateSystem.cpp.

49 : _base{&e0, &e1, nullptr}, _has_implicit_base(false)
50{
51 if (typeid(_base[0]) != typeid(_base[1]))
52 {
54 "The parameter types for the basis must be equal but they are "
55 "'{:s}' and '{:s}'.",
56 typeid(_base[0]).name(),
57 typeid(_base[1]).name());
58 }
59 if (_base[0]->isTimeDependent() || _base[1]->isTimeDependent())
60 {
61 OGS_FATAL("The parameters for the basis must not be time dependent.");
62 }
63 if (_base[0]->getNumberOfGlobalComponents() != 2 ||
64 _base[1]->getNumberOfGlobalComponents() != 2)
65 {
66 OGS_FATAL("The parameters for the 2D basis must have two components.");
67 }
68}

References _base, and OGS_FATAL.

◆ CoordinateSystem() [3/3]

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

Definition at line 70 of file CoordinateSystem.cpp.

73 : _base{&e0, &e1, &e2}, _has_implicit_base(false)
74{
75 if ((typeid(_base[0]) != typeid(_base[1])) ||
76 (typeid(_base[1]) != typeid(_base[2])) ||
77 (typeid(_base[2]) != typeid(_base[0])))
78 {
80 "The parameter types for the basis must be equal but they are "
81 "'{:s}', '{:s}', and '{:s}'.",
82 typeid(_base[0]).name(),
83 typeid(_base[1]).name(),
84 typeid(_base[2]).name());
85 }
86 if (_base[0]->isTimeDependent() || _base[1]->isTimeDependent(),
87 _base[2]->isTimeDependent())
88 {
89 OGS_FATAL("The parameters for the basis must not be time dependent.");
90 }
91 if (_base[0]->getNumberOfGlobalComponents() != 3 ||
92 _base[1]->getNumberOfGlobalComponents() != 3 ||
93 _base[2]->getNumberOfGlobalComponents() != 3)
94 {
96 "The parameters for the 3D basis must have three components.");
97 }
98}

References _base, and OGS_FATAL.

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 315 of file CoordinateSystem.cpp.

317{
318 assert(values.size() == Dimension ||
319 "Input vector has wrong dimension; expected 2 or 3 entries.");
320 auto const tensor = Eigen::Map<Eigen::Matrix<double, Dimension, 1> const>(
321 values.data(), Dimension, 1);
322 auto const R = transformation<Dimension>(pos);
323 return R * tensor.asDiagonal() * R.transpose();
324}

◆ rotateTensor()

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 301 of file CoordinateSystem.cpp.

303{
304 assert(values.size() == Dimension * Dimension ||
305 "Input vector has wrong dimension; expected 4 or 9 entries.");
306 auto const tensor =
307 Eigen::Map<Eigen::Matrix<double, Dimension, Dimension> const>(
308 values.data(), Dimension, Dimension);
309 auto const R = transformation<Dimension>(pos);
310 return R * tensor * R.transpose();
311}

◆ transformation() [1/3]

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

Definition at line 100 of file CoordinateSystem.cpp.

131{
133 {
135 }
136
137 if (_base[2] != nullptr)
138 {
139 OGS_FATAL(
140 "The coordinate system is 3D but a transformation for 2D case is "
141 "requested.");
142 }
143
144 Eigen::Matrix<double, 2, 2> t;
145 t.col(0) = Eigen::Map<Eigen::Vector2d>(
146 (*_base[0])(0 /* time independent */, pos).data());
147 t.col(1) = Eigen::Map<Eigen::Vector2d>(
148 (*_base[1])(0 /* time independent */, pos).data());
149
150#ifndef NDEBUG
151 if (std::abs(t.determinant() - 1) > tolerance)
152 {
153 OGS_FATAL(error_info, t.determinant(), tolerance);
154 }
155#endif // NDEBUG
156 return t;
157}
Eigen::Matrix< double, 2, 2 > getTransformationFromSingleBase2D(Parameter< double > const &unit_direction, SpatialPosition const &pos)
static double const tolerance
static constexpr char error_info[]

References ParameterLib::error_info, ParameterLib::ParameterBase::name, ParameterLib::normalization_error_info, OGS_FATAL, and ParameterLib::tolerance.

◆ transformation() [2/3]

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

Definition at line 159 of file CoordinateSystem.cpp.

227{
229 {
231 }
232
233 if (_base[2] == nullptr)
234 {
235 OGS_FATAL(
236 "The coordinate system is 2D but a transformation for 3D case is "
237 "requested.");
238 }
239
240 Eigen::Matrix<double, 3, 3> t;
241 t.col(0) = Eigen::Map<Eigen::Vector3d>(
242 (*_base[0])(0 /* time independent */, pos).data());
243 t.col(1) = Eigen::Map<Eigen::Vector3d>(
244 (*_base[1])(0 /* time independent */, pos).data());
245 t.col(2) = Eigen::Map<Eigen::Vector3d>(
246 (*_base[2])(0 /* time independent */, pos).data());
247
248#ifndef NDEBUG
249 if (std::abs(t.determinant() - 1) > tolerance)
250 {
251 OGS_FATAL(error_info, t.determinant(), tolerance);
252 }
253#endif // NDEBUG
254 return t;
255}
Eigen::Matrix< double, 3, 3 > getTransformationFromSingleBase3D(Parameter< double > const &unit_direction, SpatialPosition const &pos)

References ParameterLib::error_info, ParameterLib::ParameterBase::name, ParameterLib::normalization_error_info, OGS_FATAL, 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 273 of file CoordinateSystem.cpp.

275{
277 {
279 }
280
281 if (_base[2] != nullptr)
282 {
283 return transformation<3>(pos);
284 }
285
286 auto e0 = (*_base[0])(0 /* time independent */, pos);
287 auto e1 = (*_base[1])(0 /* time independent */, pos);
288 Eigen::Matrix<double, 3, 3> t = Eigen::Matrix<double, 3, 3>::Identity();
289 t.template topLeftCorner<2, 2>() << e0[0], e1[0], e0[1], e1[1];
290
291#ifndef NDEBUG
292 if (std::abs(t.determinant() - 1) > tolerance)
293 {
294 OGS_FATAL(error_info, t.determinant(), tolerance);
295 }
296#endif // NDEBUG
297 return t;
298}
Eigen::Matrix< double, 3, 3 > transformationFromSingleBase_3d(SpatialPosition const &pos) const

References _base, _has_implicit_base, ParameterLib::error_info, OGS_FATAL, ParameterLib::tolerance, and transformationFromSingleBase_3d().

Referenced by MaterialPropertyLib::SaturationDependentSwelling::dValue(), and MaterialPropertyLib::SaturationDependentSwelling::value().

◆ transformationFromSingleBase_3d()

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

Definition at line 257 of file CoordinateSystem.cpp.

259{
260 // If base 2, which stores the unit direction vector, has three components:
261 if ((*_base[2])(0 /* time independent */, pos).size() == 3)
262 {
264 }
265
266 // If base 2, which stores the unit direction vector, has two components
267 Eigen::Matrix<double, 3, 3> t = Eigen::Matrix<double, 3, 3>::Identity();
268 t.template topLeftCorner<2, 2>() = transformation<2>(pos);
269
270 return t;
271}
constexpr int size(int const displacement_dim)
Vectorized tensor size for given displacement dimension.

References _base, and ParameterLib::getTransformationFromSingleBase3D().

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

Definition at line 81 of file CoordinateSystem.h.

Referenced by transformation_3d().


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