OGS
TemplateIsoparametric.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include <cassert>
7#include <numbers>
8
10#include "MeshLib/Node.h"
13
14namespace NumLib
15{
22template <class ShapeFunctionType_, class ShapeMatrixTypes_>
24{
25public:
26 using ShapeFunctionType = ShapeFunctionType_;
27
29 using ShapeMatrices = typename ShapeMatrixTypes_::ShapeMatrices;
30
35
41
47 explicit TemplateIsoparametric(const MeshLib::Element& e) : _ele(&e) {}
48
50 const MeshLib::Element* getMeshElement() const { return _ele; }
51
53 void setMeshElement(const MeshLib::Element& e) { this->_ele = &e; }
63 void computeShapeFunctions(const double* natural_pt, ShapeMatrices& shape,
64 const unsigned global_dim,
65 bool is_axially_symmetric) const
66 {
68 global_dim);
69 computeIntegralMeasure(is_axially_symmetric, shape);
70 }
71
82 template <ShapeMatrixType T_SHAPE_MATRIX_TYPE>
83 void computeShapeFunctions(const double* natural_pt, ShapeMatrices& shape,
84 const unsigned global_dim,
85 bool is_axially_symmetric) const
86 {
87 NaturalCoordsMappingType::template computeShapeMatrices<
88 T_SHAPE_MATRIX_TYPE>(*_ele, natural_pt, shape, global_dim);
89 computeIntegralMeasure(is_axially_symmetric, shape);
90 }
91
95 typename ShapeMatrices::ShapeType const& N) const
96 {
97 auto* nodes = _ele->getNodes();
98 typename ShapeMatrices::ShapeType rs(N.size());
99 for (int i = 0; i < rs.size(); ++i)
100 {
101 rs[i] = (*nodes[i])[0];
102 }
103 auto const r = N.dot(rs);
104 return r;
105 }
106
108 std::array<double, 3> interpolateCoordinates(
109 typename ShapeMatrices::ShapeType const& N) const
110 {
111 auto* nodes = _ele->getNodes();
112 typename ShapeMatrices::ShapeType rs(N.size());
113 std::array<double, 3> interpolated_coords;
114 for (int d = 0; d < 3; ++d)
115 {
116 for (int i = 0; i < rs.size(); ++i)
117 {
118 rs[i] = (*nodes[i])[d];
119 }
120 interpolated_coords[d] = N.dot(rs);
121 }
122 return interpolated_coords;
123 }
124
125private:
126 void computeIntegralMeasure(bool is_axially_symmetric,
127 ShapeMatrices& shape) const
128 {
129 if (!is_axially_symmetric)
130 {
131 shape.integralMeasure = 1.0;
132 return;
133 }
134
135 // Note: If an integration point is located at the rotation axis, r will
136 // be zero which might lead to problems with the assembled equation
137 // system.
138 // E.g., for triangle elements, if an integration point is
139 // located at edge of the unit triangle, it is possible that
140 // r becomes zero.
141 auto const r = interpolateZerothCoordinate(shape.N);
142 shape.integralMeasure = 2. * std::numbers::pi * r;
143 }
144
146};
147
150template <typename ShapeFunction, typename ShapeMatricesType>
159} // namespace NumLib
Template class for isoparametric elements.
void computeShapeFunctions(const double *natural_pt, ShapeMatrices &shape, const unsigned global_dim, bool is_axially_symmetric) const
double interpolateZerothCoordinate(typename ShapeMatrices::ShapeType const &N) const
void setMeshElement(const MeshLib::Element &e)
Sets the mesh element.
void computeIntegralMeasure(bool is_axially_symmetric, ShapeMatrices &shape) const
std::array< double, 3 > interpolateCoordinates(typename ShapeMatrices::ShapeType const &N) const
Interpolates the coordinates of the element with the given shape matrix.
NaturalCoordinatesMapping< ShapeFunctionType, ShapeMatrices > NaturalCoordsMappingType
const MeshLib::Element * getMeshElement() const
return current mesh element
void computeShapeFunctions(const double *natural_pt, ShapeMatrices &shape, const unsigned global_dim, bool is_axially_symmetric) const
TemplateIsoparametric(const MeshLib::Element &e)
typename T_SHAPE_MATRIX_POLICY< ShapePoint1 >::ShapeMatrices ShapeMatrices
std::vector< typename ShapeMatricesType::ShapeMatrices, Eigen::aligned_allocator< typename ShapeMatricesType::ShapeMatrices > > computeShapeMatrices(MeshLib::Element const &e, bool const is_axially_symmetric, PointContainer const &points)
NumLib::TemplateIsoparametric< ShapeFunction, ShapeMatricesType > createIsoparametricFiniteElement(MeshLib::Element const &e)
static void computeShapeMatrices(const MeshLib::Element &ele, const double *natural_pt, ShapeMatrices &shapemat, const unsigned global_dim)