21 "The determinant of the coordinate system transformation matrix is '{:g}', "
22 "which is not sufficiently close to unity with the tolerance of '{:g}'. "
23 "Please adjust the accuracy of the local system bases";
27 : _base{&e0, &e1, nullptr}
32 "The parameter types for the basis must be equal but they are "
37 if (
_base[0]->isTimeDependent() ||
_base[1]->isTimeDependent())
39 OGS_FATAL(
"The parameters for the basis must not be time dependent.");
41 if (
_base[0]->getNumberOfGlobalComponents() != 2 ||
42 _base[1]->getNumberOfGlobalComponents() != 2)
44 OGS_FATAL(
"The parameters for the 2D basis must have two components.");
51 : _base{&e0, &e1, &e2}
58 "The parameter types for the basis must be equal but they are "
59 "'{:s}', '{:s}', and '{:s}'.",
64 if (
_base[0]->isTimeDependent() ||
_base[1]->isTimeDependent(),
65 _base[2]->isTimeDependent())
67 OGS_FATAL(
"The parameters for the basis must not be time dependent.");
69 if (
_base[0]->getNumberOfGlobalComponents() != 3 ||
70 _base[1]->getNumberOfGlobalComponents() != 3 ||
71 _base[2]->getNumberOfGlobalComponents() != 3)
74 "The parameters for the 3D basis must have three components.");
79 Eigen::Matrix<double, 2, 2> CoordinateSystem::transformation<2>(
82 if (
_base[2] !=
nullptr)
85 "The coordinate system is 3D but a transformation for 2D case is "
89 auto e0 = (*
_base[0])(0 , pos);
90 auto e1 = (*
_base[1])(0 , pos);
91 Eigen::Matrix<double, 2, 2> t;
92 t << e0[0], e1[0], e0[1], e1[1];
95 if (std::abs(t.determinant() - 1) >
tolerance)
104 Eigen::Matrix<double, 3, 3> CoordinateSystem::transformation<3>(
105 SpatialPosition
const& pos)
const
107 if (
_base[2] ==
nullptr)
110 "The coordinate system is 2D but a transformation for 3D case is "
114 auto e0 = (*
_base[0])(0 , pos);
115 auto e1 = (*
_base[1])(0 , pos);
116 auto e2 = (*
_base[2])(0 , pos);
117 Eigen::Matrix<double, 3, 3> t;
118 t << e0[0], e1[0], e2[0], e0[1], e1[1], e2[1], e0[2], e1[2], e2[2];
121 if (std::abs(t.determinant() - 1) >
tolerance)
132 if (
_base[2] !=
nullptr)
134 return transformation<3>(pos);
137 auto e0 = (*
_base[0])(0 , pos);
138 auto e1 = (*
_base[1])(0 , pos);
139 Eigen::Matrix<double, 3, 3> t = Eigen::Matrix<double, 3, 3>::Identity();
140 t.template topLeftCorner<2, 2>() << e0[0], e1[0], e0[1], e1[1];
143 if (std::abs(t.determinant() - 1) >
tolerance)
151 template <
int Dimension>
155 assert(values.size() == Dimension * Dimension ||
156 "Input vector has wrong dimension; expected 4 or 9 entries.");
158 Eigen::Map<Eigen::Matrix<double, Dimension, Dimension>
const>(
159 values.data(), Dimension, Dimension);
160 auto const R = transformation<Dimension>(pos);
161 return R * tensor * R.transpose();
164 template <
int Dimension>
165 Eigen::Matrix<double, Dimension, Dimension>
169 assert(values.size() == Dimension ||
170 "Input vector has wrong dimension; expected 2 or 3 entries.");
171 auto const tensor = Eigen::Map<Eigen::Matrix<double, Dimension, 1>
const>(
172 values.data(), Dimension, 1);
173 auto const R = transformation<Dimension>(pos);
174 return R * tensor.asDiagonal() * R.transpose();
177 template Eigen::Matrix<double, 2, 2> CoordinateSystem::rotateTensor<2>(
179 template Eigen::Matrix<double, 3, 3> CoordinateSystem::rotateTensor<3>(
181 template Eigen::Matrix<double, 2, 2> CoordinateSystem::rotateDiagonalTensor<2>(
183 template Eigen::Matrix<double, 3, 3> CoordinateSystem::rotateDiagonalTensor<3>(
static double const tolerance
static const char *const error_info
std::array< Parameter< double > const *, 3 > _base
Eigen::Matrix< double, 3, 3 > transformation_3d(SpatialPosition const &pos) const
Eigen::Matrix< double, Dimension, Dimension > rotateTensor(std::vector< double > const &values, SpatialPosition const &pos) const
CoordinateSystem(Parameter< double > const &e0, Parameter< double > const &e1)
Eigen::Matrix< double, Dimension, Dimension > rotateDiagonalTensor(std::vector< double > const &values, SpatialPosition const &pos) const