OGS
ElementCoordinatesMappingLocal.cpp
Go to the documentation of this file.
1
11
12#include <cassert>
13#include <limits>
14
16#include "MathLib/MathTools.h"
17#include "MathLib/Point3d.h"
19#include "MeshLib/Node.h"
20
21namespace detail
22{
25 std::vector<MathLib::Point3d>& points)
26{
27 std::transform(points.begin(), points.end(), points.begin(),
28 [&matR2local](auto const& pnt) { return matR2local * pnt; });
29}
30
35 const unsigned element_dimension,
36 const unsigned global_dim,
37 const std::vector<MathLib::Point3d>& points)
38{
39 Eigen::Matrix3d matR;
40 // compute R in x=R*x' where x are original coordinates and x' are local
41 // coordinates
42 if (element_dimension == 1)
43 {
44 Eigen::Vector3d const xx =
45 (points[1].asEigenVector3d() - points[0].asEigenVector3d())
46 .normalized();
47 if (global_dim == 2)
48 {
50 }
51 else
52 {
54 }
55 matR.transposeInPlace();
56 }
57 else if (global_dim == 3 && element_dimension == 2)
58 {
59 // get plane normal
60 auto const [plane_normal, d] = GeoLib::getNewellPlane(points);
61 // compute a rotation matrix to XY
62 matR = GeoLib::computeRotationMatrixToXY(plane_normal);
63 // set a transposed matrix
64 matR.transposeInPlace();
65 }
66 return matR;
67}
68} // namespace detail
69
70namespace MeshLib
71{
73 const Element& e, const unsigned global_dim)
74 : _global_dim(global_dim), _matR2global(Eigen::Matrix3d::Identity())
75{
76 unsigned const space_dim = std::max(e.space_dimension_, _global_dim);
77 assert(e.getDimension() <= space_dim);
78 _points.reserve(e.getNumberOfNodes());
79 for (unsigned i = 0; i < e.getNumberOfNodes(); i++)
80 {
81 _points.emplace_back(*(e.getNode(i)));
82 }
83
84 auto const element_dim = e.getDimension();
85
86 if (element_dim != space_dim)
87 {
89 detail::getRotationMatrixToGlobal(element_dim, space_dim, _points);
91 }
92}
93
94} // namespace MeshLib
Definition of analytical geometry functions.
Definition of the Element class.
Definition of the Node class.
Definition of the Point3d class.
ElementCoordinatesMappingLocal(const Element &e, const unsigned global_dim)
virtual unsigned getNumberOfNodes() const =0
virtual const Node * getNode(unsigned idx) const =0
virtual constexpr unsigned getDimension() const =0
Get dimension of the mesh element.
unsigned space_dimension_
Dimension of the space, where the element exists.
Definition Element.h:190
Eigen::Matrix3d compute3DRotationMatrixToX(Eigen::Vector3d const &v)
Eigen::Matrix3d computeRotationMatrixToXY(Eigen::Vector3d const &n)
std::pair< Eigen::Vector3d, double > getNewellPlane(InputIterator pnts_begin, InputIterator pnts_end)
Eigen::Matrix3d compute2DRotationMatrixToX(Eigen::Vector3d const &v)
Eigen::Matrix< double, 3u, 3u, Eigen::RowMajor > RotationMatrix
void rotateToLocal(const MeshLib::RotationMatrix &matR2local, std::vector< MathLib::Point3d > &points)
rotate points to local coordinates
MeshLib::RotationMatrix getRotationMatrixToGlobal(const unsigned element_dimension, const unsigned global_dim, const std::vector< MathLib::Point3d > &points)