OGS
CoordinateSystem.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <Eigen/Core>
14#include <array>
15#include <vector>
16
17namespace ParameterLib
18{
19template <typename T>
20struct Parameter;
21class SpatialPosition;
22} // namespace ParameterLib
23
24namespace ParameterLib
25{
48struct CoordinateSystem final
49{
56 explicit CoordinateSystem(Parameter<double> const& unit_direction);
57
59
61 Parameter<double> const& e1,
62 Parameter<double> const& e2);
63
64 template <int Dimension>
65 Eigen::Matrix<double, Dimension, Dimension> transformation(
66 SpatialPosition const& pos) const;
67
68 Eigen::Matrix<double, 3, 3> transformation_3d(
69 SpatialPosition const& pos) const;
70
71 template <int Dimension>
72 Eigen::Matrix<double, Dimension, Dimension> rotateTensor(
73 std::vector<double> const& values, SpatialPosition const& pos) const;
74
75 template <int Dimension, typename Derived>
76 Eigen::Matrix<double, Dimension, Dimension> rotateTensor(
77 Eigen::MatrixBase<Derived> const& tensor,
78 SpatialPosition const& pos) const;
79
80 template <int Dimension>
81 Eigen::Matrix<double, Dimension, Dimension> rotateDiagonalTensor(
82 std::vector<double> const& values, SpatialPosition const& pos) const;
83
84private:
85 std::array<Parameter<double> const*, 3> _base;
87
88 Eigen::Matrix<double, 3, 3> transformationFromSingleBase_3d(
89 SpatialPosition const& pos) const;
90};
91
92template <int Dimension, typename Derived>
93Eigen::Matrix<double, Dimension, Dimension> CoordinateSystem::rotateTensor(
94 Eigen::MatrixBase<Derived> const& tensor, SpatialPosition const& pos) const
95{
96 auto const R = transformation<Dimension>(pos);
97 return R * tensor * R.transpose();
98}
99
100extern template Eigen::Matrix<double, 2, 2> CoordinateSystem::rotateTensor<2>(
101 std::vector<double> const& values, SpatialPosition const& pos) const;
102extern template Eigen::Matrix<double, 3, 3> CoordinateSystem::rotateTensor<3>(
103 std::vector<double> const& values, SpatialPosition const& pos) const;
104extern template Eigen::Matrix<double, 2, 2>
105CoordinateSystem::rotateDiagonalTensor<2>(std::vector<double> const& values,
106 SpatialPosition const& pos) const;
107extern template Eigen::Matrix<double, 3, 3>
108CoordinateSystem::rotateDiagonalTensor<3>(std::vector<double> const& values,
109 SpatialPosition const& pos) const;
110} // namespace ParameterLib
A local coordinate system used for tensor transformations.
std::array< Parameter< double > const *, 3 > _base
Eigen::Matrix< double, Dimension, Dimension > transformation(SpatialPosition const &pos) const
Eigen::Matrix< double, 3, 3 > transformationFromSingleBase_3d(SpatialPosition const &pos) const
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
Eigen::Matrix< double, Dimension, Dimension > rotateDiagonalTensor(std::vector< double > const &values, SpatialPosition const &pos) const
CoordinateSystem(Parameter< double > const &unit_direction)