Dune Core Modules (2.11.0)

lagrangepoints.hh
1#pragma once
2
3#include <cassert>
4#include <array>
5
9#include <dune/localfunctions/lagrange/equidistantpoints.hh>
10
11namespace Dune::Vtk
12{
13 namespace Impl
14 {
15 // forward declaration
16 template <class K, unsigned int dim>
17 class LagrangePointSetBuilder;
18 }
19
20
22
26 template <class K, unsigned int dim>
28 : public EmptyPointSet<K, dim>
29 {
30 using Super = EmptyPointSet<K, dim>;
31
32 public:
33 static const unsigned int dimension = dim;
34
35 LagrangePointSet (std::size_t order)
36 : Super(order)
37 {
38 assert(order > 0);
39 }
40
43 {
44 assert(gt.dim() == dimension);
45 builder_(gt, order(), points_);
46 }
47
49 template <GeometryType::Id geometryId>
50 bool build ()
51 {
52 build(GeometryType(geometryId));
53 return true;
54 }
55
58 template <GeometryType::Id geometryId>
59 static bool supports (std::size_t /*order*/)
60 {
61 return true;
62 }
63
64 using Super::order;
65
66 private:
67 using Super::points_;
68 Impl::LagrangePointSetBuilder<K,dim> builder_;
69 };
70
71
72 namespace Impl
73 {
74 // Build for lagrange point sets in different dimensions
75 // Specialized for dim=1,2,3
76 template <class K, unsigned int dim>
77 class LagrangePointSetBuilder
78 {
79 public:
80 template <class Points>
81 void operator()(GeometryType, unsigned int, Points& points) const
82 {
84 "Lagrange points not yet implemented for this GeometryType.");
85 }
86 };
87
88
89 // Lagrange points on point geometries
90 template <class K>
91 class LagrangePointSetBuilder<K,0>
92 {
93 static constexpr int dim = 0;
94 using LP = LagrangePoint<K,dim>;
95 using Vec = typename LP::Vector;
96 using Key = LocalKey;
97
98 public:
99 template <class Points>
100 void operator()(GeometryType gt, int /*order*/, Points& points) const;
101 };
102
103
104 // Lagrange points on line geometries
105 template <class K>
106 class LagrangePointSetBuilder<K,1>
107 {
108 static constexpr int dim = 1;
109 using LP = LagrangePoint<K,dim>;
110 using Vec = typename LP::Vector;
111 using Key = LocalKey;
112
113 public:
114 template <class Points>
115 void operator()(GeometryType gt, int order, Points& points) const;
116 };
117
118
119 // Lagrange points on 2d geometries
120 template <class K>
121 class LagrangePointSetBuilder<K,2>
122 {
123 static constexpr int dim = 2;
124 using LP = LagrangePoint<K,dim>;
125 using Vec = typename LP::Vector;
126 using Key = LocalKey;
127
128 friend class LagrangePointSetBuilder<K,3>;
129
130 public:
131 template <class Points>
132 void operator()(GeometryType gt, int order, Points& points) const;
133
134 // implementation details
135 // ----------------------
136
137 // Construct the point set in a triangle element.
138 // Loop from the outside to the inside
139 template <class Points>
140 void buildTriangle (int order, Points& points) const;
141
142 // "Barycentric index" is a triplet of integers, each running from 0 to
143 // <Order>. It is the index of a point on the triangle in barycentric
144 // coordinates.
145 static void barycentricIndex (int index, std::array<int,3>& bindex, int order);
146
147 // Construct the point set in the quad element
148 // 1. build equispaced points with index tuple (i,j)
149 // 2. map index tuple to DOF index and LocalKey
150 template <class Points>
151 void buildQuad(int orderx, int ordery, Points& points) const;
152
153 // Obtain the VTK DOF index of the node (i,j) in the quad element
154 // and construct a LocalKey
155 static std::pair<int,Key> calcQuadKey (int i, int j, std::array<int,2> order);
156 };
157
158
159 // Lagrange points on 3d geometries
160 template <class K>
161 class LagrangePointSetBuilder<K,3>
162 {
163 static constexpr int dim = 3;
164 using LP = LagrangePoint<K,dim>;
165 using Vec = typename LP::Vector;
166 using Key = LocalKey;
167
168 public:
169 template <class Points>
170 void operator() (GeometryType gt, unsigned int order, Points& points) const;
171
172 // implementation details
173 // ----------------------
174
175 // Construct the point set in the tetrahedron element
176 // 1. construct barycentric (index) coordinates
177 // 2. obtains the DOF index, LocalKey and actual coordinate from barycentric index
178 template <class Points>
179 void buildTetra (int order, Points& points) const;
180
181 // "Barycentric index" is a set of 4 integers, each running from 0 to
182 // <Order>. It is the index of a point in the tetrahedron in barycentric
183 // coordinates.
184 static void barycentricIndex (int p, std::array<int,4>& bindex, int order);
185
186 // Construct the point set in the heyhedral element
187 // 1. build equispaced points with index tuple (i,j,k)
188 // 2. map index tuple to DOF index and LocalKey
189 template <class Points>
190 void buildHex (int order, Points& points) const;
191
192 // Obtain the VTK DOF index of the node (i,j,k) in the hexahedral element
193 static std::pair<int,Key> calcHexKey (int i, int j, int k, std::array<int,3> order);
194
195 // Construct the point set in the prism element
196 // with polynomial order `order_tri` in the triangular faces and along the
197 // z-direction with `order_quad` polynomial order.
198 template <class Points>
199 void buildWedge (int order_tri, int order_quad, Points& points) const;
200 };
201
202 template <class K, unsigned int dim>
203 class LexicographicPointSetBuilder
204 {
205 public:
206 // equidistant points along the line with `a+1` points.
207 template <class Points>
208 static void buildLine(int a, Points& points);
209
210 // equidistant points in the quad with `a+1` points along the x-axis and
211 // `b+1` points along the y-axis, lexicographically ordered.
212 template <class Points>
213 static void buildQuad(int a, int b, Points& points);
214
215 // equidistant points in the hexahedron with `a+1` points along the x-axis,
216 // `b+1` points along the y-axis, and `c+1` points along the z-axis,
217 // lexicographically ordered.
218 template <class Points>
219 static void buildHex(int a, int b, int c, Points& points);
220 };
221
222 } // end namespace Impl
223} // end namespace Dune::Vtk
224
225#include <dune/vtk/utility/lagrangepoints.impl.hh>
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Default exception for dummy implementations.
Definition: exceptions.hh:357
A set of lagrange points compatible with the numbering of VTK and Gmsh.
Definition: lagrangepoints.hh:29
bool build()
Fill the lagrange points for the given topology type Topology
Definition: lagrangepoints.hh:50
void build(GeometryType gt)
Fill the lagrange points for the given geometry type.
Definition: lagrangepoints.hh:42
static bool supports(std::size_t)
Definition: lagrangepoints.hh:59
A few common exception classes.
Various macros to work with Dune module version numbers.
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Feb 14, 23:39, 2026)