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
12{
13 namespace Gmsh4
14 {
15 namespace Impl
16 {
17 // forward declaration
18 template <class K, unsigned int dim>
19 class LagrangePointSetBuilder;
20 }
21
22
24
28 template <class K, unsigned int dim>
30 : public EmptyPointSet<K, dim>
31 {
32 using Super = EmptyPointSet<K, dim>;
33
34 public:
35 static const unsigned int dimension = dim;
36
37 LagrangePointSet (std::size_t order)
38 : Super(order)
39 {
40 assert(order > 0);
41 }
42
45 {
46 assert(gt.dim() == dimension);
47 builder_(gt, order(), points_);
48 }
49
51#if DUNE_VERSION_LT(DUNE_LOCALFUNCTIONS,2,8)
52 template <class Topology>
53 bool build ()
54 {
55 build(GeometryType(Topology{}));
56 return true;
57 }
58#else
59 template <GeometryType::Id geometryId>
60 bool build ()
61 {
62 build(GeometryType(geometryId));
63 return true;
64 }
65#endif
66
69#if DUNE_VERSION_LT(DUNE_LOCALFUNCTIONS,2,8)
70 template <class Topology>
71#else
72 template <GeometryType::Id geometryId>
73#endif
74 static bool supports (std::size_t order)
75 {
76 return true;
77 }
78
79 using Super::order;
80
81 private:
82 using Super::points_;
83 Impl::LagrangePointSetBuilder<K,dim> builder_;
84 };
85
86
87 namespace Impl
88 {
89 // Build for Lagrange point sets in different dimensions
90 // Specialized for dim=1,2,3
91 template <class K, unsigned int dim>
92 class LagrangePointSetBuilder
93 {
94 public:
95 template <class Points>
96 void operator()(GeometryType, unsigned int, Points& points) const
97 {
99 "Lagrange points not yet implemented for this GeometryType.");
100 }
101 };
102
103
104 // Lagrange points on point geometries
105 template <class K>
106 class LagrangePointSetBuilder<K,0>
107 {
108 static constexpr int dim = 0;
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 line geometries
120 template <class K>
121 class LagrangePointSetBuilder<K,1>
122 {
123 static constexpr int dim = 1;
124 using LP = LagrangePoint<K,dim>;
125 using Vec = typename LP::Vector;
126 using Key = LocalKey;
127
128 public:
129 template <class Points>
130 void operator()(GeometryType gt, int order, Points& points) const;
131 };
132
133
134 // Lagrange points on 2d geometries
135 template <class K>
136 class LagrangePointSetBuilder<K,2>
137 {
138 static constexpr int dim = 2;
139 using LP = LagrangePoint<K,dim>;
140 using Vec = typename LP::Vector;
141 using Key = LocalKey;
142
143 friend class LagrangePointSetBuilder<K,3>;
144
145 public:
146 template <class Points>
147 void operator()(GeometryType gt, int order, Points& points) const;
148
149 private: // implementation details
150
151 // Construct the point set in a triangle element.
152 // Loop from the outside to the inside
153 template <class Points>
154 void buildTriangle (std::size_t nPoints, int order, Points& points) const;
155
156 // "Barycentric index" is a triplet of integers, each running from 0 to
157 // <Order>. It is the index of a point on the triangle in barycentric
158 // coordinates.
159 static void barycentricIndex (int index, std::array<int,3>& bindex, int order);
160
161 // Construct the point set in the quad element
162 // 1. build equispaced points with index tuple (i,j)
163 // 2. map index tuple to DOF index and LocalKey
164 template <class Points>
165 void buildQuad(std::size_t nPoints, int order, Points& points) const;
166
167 // Obtain the VTK DOF index of the node (i,j) in the quad element
168 // and construct a LocalKey
169 static std::pair<int,Key> calcQuadKey (int i, int j, std::array<int,2> order);
170 };
171
172
173 // Lagrange points on 3d geometries
174 template <class K>
175 class LagrangePointSetBuilder<K,3>
176 {
177 static constexpr int dim = 3;
178 using LP = LagrangePoint<K,dim>;
179 using Vec = typename LP::Vector;
180 using Key = LocalKey;
181
182 public:
183 template <class Points>
184 void operator() (GeometryType gt, unsigned int order, Points& points) const;
185
186 private: // implementation details
187
188 // Construct the point set in the tetrahedron element
189 // 1. construct barycentric (index) coordinates
190 // 2. obtains the DOF index, LocalKey and actual coordinate from barycentric index
191 template <class Points>
192 void buildTetra (std::size_t nPoints, int order, Points& points) const;
193
194 // "Barycentric index" is a set of 4 integers, each running from 0 to
195 // <Order>. It is the index of a point in the tetrahedron in barycentric
196 // coordinates.
197 static void barycentricIndex (std::size_t p, std::array<int,4>& bindex, int order);
198
199 // Construct the point set in the heyhedral element
200 // 1. build equispaced points with index tuple (i,j,k)
201 // 2. map index tuple to DOF index and LocalKey
202 template <class Points>
203 void buildHex (std::size_t nPoints, int order, Points& points) const;
204
205 // Obtain the VTK DOF index of the node (i,j,k) in the hexahedral element
206 static std::pair<int,Key> calcHexKey (int i, int j, int k, std::array<int,3> order);
207 };
208
209 } // end namespace Impl
210 } // end namespace Gmsh4
211} // end namespace Dune
212
213#include <dune/gmsh4/utility/lagrangepoints.impl.hh>
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
A set of Lagrange points compatible with the numbering of VTK and Gmsh.
Definition: lagrangepoints.hh:31
bool build()
Fill the Lagrange points for the given topology type Topology
Definition: lagrangepoints.hh:60
static bool supports(std::size_t order)
Definition: lagrangepoints.hh:74
void build(GeometryType gt)
Fill the Lagrange points for the given geometry type.
Definition: lagrangepoints.hh:44
Default exception for dummy implementations.
Definition: exceptions.hh:357
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
Dune namespace
Definition: alignedallocator.hh:13
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)