DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Pyramid5.hpp
Go to the documentation of this file.
1#pragma once
2// Auto-generated by tools/gen_shape_functions -- DO NOT EDIT
3// Element: Pyramid5
4// Regenerate: /usr/bin/python3 -m tools.gen_shape_functions.generate
5
6#include "DNDS/Defines.hpp"
7#include "Geom/Geometric.hpp"
8#include "Geom/ElemEnum.hpp"
10
11namespace DNDS::Geom::Elem
12{
13
14 // Forward declaration (primary template is in ElementTraitsBase.hpp)
15 template <ElemType> struct ShapeFuncImpl;
16
17 // <GEN_SHAPE_FUNCS_BEGIN>
18 template <>
20 {
21 template <class TPoint, class TArray>
22 static inline void Diff0(const TPoint &p, TArray &&v)
23 {
24 t_real xi = p[0];
25 t_real et = p[1];
26 t_real zt = p[2];
27 // singularity guard
28 if (std::abs(1 - zt) < 1e-15)
29 zt -= DNDS::signP(1 - zt) * 1e-15;
30 const t_real _t0 = zt - 1;
31 const t_real _t1 = _t0 + et;
32 const t_real _t2 = _t0 + xi;
33 const t_real _t3 = (1.0 / (4*zt - 4));
34 const t_real _t4 = 1 - zt;
35 const t_real _t5 = _t4 + xi;
36 const t_real _t6 = ((0.25))/_t0;
37 const t_real _t7 = _t4 + et;
38 v(0, 0) = -_t1*_t2*_t3;
39 v(0, 1) = _t1*_t5*_t6;
40 v(0, 2) = -_t3*_t5*_t7;
41 v(0, 3) = _t2*_t6*_t7;
42 v(0, 4) = zt;
43 }
44
45 template <class TPoint, class TArray>
46 static inline void Diff1(const TPoint &p, TArray &&v)
47 {
48 t_real xi = p[0];
49 t_real et = p[1];
50 t_real zt = p[2];
51 // singularity guard
52 if (std::abs(1 - zt) < 1e-15)
53 zt -= DNDS::signP(1 - zt) * 1e-15;
54 const t_real _t0 = zt - 1;
55 const t_real _t1 = _t0 + et;
56 const t_real _t2 = ((0.25))/_t0;
57 const t_real _t3 = 1 - zt;
58 const t_real _t4 = _t3 + et;
59 const t_real _t5 = _t0 + xi;
60 const t_real _t6 = _t3 + xi;
61 const t_real _t7 = 2*zt;
62 const t_real _t8 = et*xi;
63 const t_real _t9 = ((zt) * (zt));
64 const t_real _t10 = -_t7 + _t9 + 1;
65 const t_real _t11 = ((0.25))/_t10;
66 const t_real _t12 = _t11*(_t7 + _t8 - _t9 - 1);
67 const t_real _t13 = _t11*(-_t10 - _t8);
68 v(0, 0) = -_t1*_t2;
69 v(0, 1) = _t1*_t2;
70 v(0, 2) = -_t2*_t4;
71 v(0, 3) = _t2*_t4;
72 v(1, 0) = -_t2*_t5;
73 v(1, 1) = _t2*_t6;
74 v(1, 2) = -_t2*_t6;
75 v(1, 3) = _t2*_t5;
76 v(2, 0) = _t12;
77 v(2, 1) = _t13;
78 v(2, 2) = _t12;
79 v(2, 3) = _t13;
80 v(2, 4) = 1;
81 }
82
83 template <class TPoint, class TArray>
84 static inline void Diff2(const TPoint &p, TArray &&v)
85 {
86 t_real xi = p[0];
87 t_real et = p[1];
88 t_real zt = p[2];
89 // singularity guard
90 if (std::abs(1 - zt) < 1e-15)
91 zt -= DNDS::signP(1 - zt) * 1e-15;
92 const t_real _t0 = ((zt) * (zt));
93 const t_real _t1 = ((zt) * (zt) * (zt));
94 const t_real _t2 = et*xi;
95 const t_real _t3 = -_t2/(-6*_t0 + 2*_t1 + 6*zt - 2);
96 const t_real _t4 = ((0.5))*_t2/(-3*_t0 + _t1 + 3*zt - 1);
97 const t_real _t5 = -1/(4*zt - 4);
98 const t_real _t6 = zt - 1;
99 const t_real _t7 = ((0.25))/_t6;
100 const t_real _t8 = ((0.25))/((_t6) * (_t6));
101 const t_real _t9 = _t8*xi;
102 const t_real _t10 = -_t9;
103 const t_real _t11 = _t8*et;
104 const t_real _t12 = -_t11;
105 v(2, 0) = _t3;
106 v(2, 1) = _t4;
107 v(2, 2) = _t3;
108 v(2, 3) = _t4;
109 v(3, 0) = _t5;
110 v(3, 1) = _t7;
111 v(3, 2) = _t5;
112 v(3, 3) = _t7;
113 v(4, 0) = _t9;
114 v(4, 1) = _t10;
115 v(4, 2) = _t9;
116 v(4, 3) = _t10;
117 v(5, 0) = _t11;
118 v(5, 1) = _t12;
119 v(5, 2) = _t11;
120 v(5, 3) = _t12;
121 }
122
123 template <class TPoint, class TArray>
124 static inline void Diff3(const TPoint &p, TArray &&v)
125 {
126 t_real xi = p[0];
127 t_real et = p[1];
128 t_real zt = p[2];
129 // singularity guard
130 if (std::abs(1 - zt) < 1e-15)
131 zt -= DNDS::signP(1 - zt) * 1e-15;
132 const t_real _t0 = ((zt) * (zt) * (zt) * (zt));
133 const t_real _t1 = ((zt) * (zt));
134 const t_real _t2 = ((zt) * (zt) * (zt));
135 const t_real _t3 = et*xi;
136 const t_real _t4 = ((1.5))*_t3/(_t0 + 6*_t1 - 4*_t2 - 4*zt + 1);
137 const t_real _t5 = -3*_t3/(2*_t0 + 12*_t1 - 8*_t2 - 8*zt + 2);
138 const t_real _t6 = zt - 1;
139 const t_real _t7 = ((0.5))/((_t6) * (_t6) * (_t6));
140 const t_real _t8 = _t7*xi;
141 const t_real _t9 = -_t8;
142 const t_real _t10 = _t7*et;
143 const t_real _t11 = -_t10;
144 const t_real _t12 = ((0.25))/((_t6) * (_t6));
145 const t_real _t13 = -_t12;
146 v(2, 0) = _t4;
147 v(2, 1) = _t5;
148 v(2, 2) = _t4;
149 v(2, 3) = _t5;
150 v(6, 0) = _t9;
151 v(6, 1) = _t8;
152 v(6, 2) = _t9;
153 v(6, 3) = _t8;
154 v(7, 0) = _t11;
155 v(7, 1) = _t10;
156 v(7, 2) = _t11;
157 v(7, 3) = _t10;
158 v(9, 0) = _t12;
159 v(9, 1) = _t13;
160 v(9, 2) = _t12;
161 v(9, 3) = _t13;
162 }
163 };
164 // <GEN_SHAPE_FUNCS_END>
165
166
167 /**
168 * @brief Element traits for 5-node linear pyramid (Pyramid5)
169 *
170 * Pyramid5 is a 3D pyramidal element with a quadrilateral base and triangular sides,
171 * commonly used for:
172 * - Transition between hexahedral and tetrahedral meshes
173 * - Octree-based mesh refinement
174 * - Adaptive meshing with hanging nodes
175 *
176 * Geometry:
177 * - Reference pyramid: square base at z=0, apex at z=1
178 * - 5 nodes: 4 at base corners, 1 at apex
179 * - Parametric space volume = 4/3
180 *
181 * Faces:
182 * - 1 quadrilateral base face
183 * - 4 triangular side faces
184 */
185 template <>
187 {
188 // ============================================================
189 // Core Element Identification
190 // ============================================================
191
192 static constexpr ElemType elemType = Pyramid5;
193 static constexpr int dim = 3;
194 static constexpr int order = 1;
195 static constexpr int numVertices = 5;
196 static constexpr int numNodes = 5;
197 static constexpr int numFaces = 5;
198 static constexpr ParamSpace paramSpace = PyramidSpace;
199 static constexpr t_real paramSpaceVol = 4.0 / 3.0;
200
201 // ============================================================
202 // Geometry Definition
203 // ============================================================
204
205 /**
206 * @brief Standard coordinates of nodes in parametric space
207 *
208 * Reference pyramid: square base [-1,1]x[-1,1] at z=0, apex at (0,0,1)
209 * Nodes 0-3: base corners (counter-clockwise)
210 * Node 4: apex
211 */
212 static constexpr std::array<t_real, 3 * 5> standardCoords = {
213 -1, -1, 0, // Node 0: base corner
214 1, -1, 0, // Node 1: base corner
215 1, 1, 0, // Node 2: base corner
216 -1, 1, 0, // Node 3: base corner
217 0, 0, 1}; // Node 4: apex
218
219 // ============================================================
220 // Face/Edge Definitions
221 // ============================================================
222
223 /**
224 * @brief Get the element type of a face
225 * @param iFace Face index (0 is base, 1-4 are sides)
226 * @return Quad4 for base, Tri3 for sides
227 */
228 static constexpr ElemType GetFaceType(t_index iFace)
229 {
230 return iFace < 1 ? Quad4 : Tri3;
231 }
232
233 /**
234 * @brief Node indices for each face
235 *
236 * Face 0: nodes 0-3-2-1 (base, quadrilateral)
237 * Faces 1-4: triangular side faces
238 */
239 static constexpr std::array<std::array<t_index, 10>, 5> faceNodes = {{
240 {0, 3, 2, 1}, // Face 0: base (quad)
241 {0, 1, 4}, // Face 1: side triangle
242 {1, 2, 4}, // Face 2: side triangle
243 {2, 3, 4}, // Face 3: side triangle
244 {3, 0, 4}}}; // Face 4: side triangle
245
246 // ============================================================
247 // Order Elevation (P-Refinement)
248 // ============================================================
249
250 /**
251 * @brief Element type after order elevation (O1 -> O2)
252 * Pyramid5 elevates to Pyramid14 (14-node quadratic pyramid)
253 */
254 static constexpr ElemType elevatedType = Pyramid14;
255
256 /// @brief Number of additional nodes created during elevation
257 static constexpr int numElevNodes = 9;
258
259 /**
260 * @brief Elevation spans define new node connections
261 *
262 * Elevation creates 9 new nodes:
263 * Spans 0-3: base edge midpoints (4 edges)
264 * Spans 4-7: lateral edge midpoints (4 edges)
265 * Span 8: base face center
266 */
267 static constexpr std::array<tElevSpan, 9> elevSpans = {{
268 {0, 1}, {1, 2}, {2, 3}, {3, 0}, // Base edges
269 {0, 4}, {1, 4}, {2, 4}, {3, 4}, // Lateral edges
270 {0, 3, 2, 1}}}; // Base face center
271
272 /// @brief Element type of each elevation span
273 static constexpr std::array<ElemType, 9> elevNodeSpanTypes = {
274 Line2, Line2, Line2, Line2, // Base edges
275 Line2, Line2, Line2, Line2, // Lateral edges
276 Quad4}; // Base face center
277
278 // ============================================================
279 // VTK/Visualization Support
280 // ============================================================
281
282 /// @brief VTK cell type identifier (14 = VTK_PYRAMID)
283 static constexpr int vtkCellType = 14;
284
285 /**
286 * @brief VTK node ordering map
287 *
288 * VTK uses the same ordering as DNDS for Pyramid5:
289 * VTK nodes 0-3 = base corners 0-3
290 * VTK node 4 = apex
291 */
292 static constexpr std::array<int, 5> vtkNodeOrder = {0, 1, 2, 3, 4};
293 };
294
295} // namespace DNDS::Geom::Elem
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
int32_t t_index
Definition Geometric.hpp:6
double t_real
Definition Geometric.hpp:8
constexpr real signP(real a)
"Signum, biased toward +1": treats 0 as positive.
Definition Defines.hpp:544
static constexpr ElemType GetFaceType(t_index iFace)
Get the element type of a face.
Definition Pyramid5.hpp:228
static void Diff1(const TPoint &p, TArray &&v)
Definition Pyramid5.hpp:46
static void Diff2(const TPoint &p, TArray &&v)
Definition Pyramid5.hpp:84
static void Diff0(const TPoint &p, TArray &&v)
Definition Pyramid5.hpp:22
static void Diff3(const TPoint &p, TArray &&v)
Definition Pyramid5.hpp:124
Eigen::Matrix< real, 5, 1 > v
double order
Definition test_ODE.cpp:257