DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Prism18.hpp
Go to the documentation of this file.
1#pragma once
2// Auto-generated by tools/gen_shape_functions -- DO NOT EDIT
3// Element: Prism18
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 DNDS_DEVICE_CALLABLE 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 const t_real _t0 = zt - 1;
28 const t_real _t1 = ((0.5))*zt;
29 const t_real _t2 = _t0*_t1;
30 const t_real _t3 = et + xi - 1;
31 const t_real _t4 = 2*et;
32 const t_real _t5 = 2*xi;
33 const t_real _t6 = _t5 - 1;
34 const t_real _t7 = _t4 + _t6;
35 const t_real _t8 = _t3*_t7;
36 const t_real _t9 = _t6*xi;
37 const t_real _t10 = et*(_t4 - 1);
38 const t_real _t11 = zt + 1;
39 const t_real _t12 = _t1*_t11;
40 const t_real _t13 = _t0*zt;
41 const t_real _t14 = _t13*_t3;
42 const t_real _t15 = _t4*xi;
43 const t_real _t16 = ((zt) * (zt)) - 1;
44 const t_real _t17 = _t16*_t3;
45 const t_real _t18 = _t11*zt;
46 const t_real _t19 = _t18*_t3;
47 const t_real _t20 = 4*xi;
48 v(0, 0) = _t2*_t8;
49 v(0, 1) = _t2*_t9;
50 v(0, 2) = _t10*_t2;
51 v(0, 3) = _t12*_t8;
52 v(0, 4) = _t12*_t9;
53 v(0, 5) = _t10*_t12;
54 v(0, 6) = -_t14*_t5;
55 v(0, 7) = _t13*_t15;
56 v(0, 8) = -_t14*_t4;
57 v(0, 9) = -_t17*_t7;
58 v(0, 10) = -_t16*_t9;
59 v(0, 11) = -_t10*_t16;
60 v(0, 12) = -_t19*_t5;
61 v(0, 13) = _t15*_t18;
62 v(0, 14) = -_t19*_t4;
63 v(0, 15) = _t17*_t20;
64 v(0, 16) = -_t16*_t20*et;
65 v(0, 17) = 4*_t17*et;
66 }
67
68 template <class TPoint, class TArray>
69 DNDS_DEVICE_CALLABLE static inline void Diff1(const TPoint &p, TArray &&v)
70 {
71 t_real xi = p[0];
72 t_real et = p[1];
73 t_real zt = p[2];
74 const t_real _t0 = 4*et;
75 const t_real _t1 = 4*xi;
76 const t_real _t2 = _t0 + _t1 - 3;
77 const t_real _t3 = zt - 1;
78 const t_real _t4 = ((0.5))*zt;
79 const t_real _t5 = _t3*_t4;
80 const t_real _t6 = _t2*_t5;
81 const t_real _t7 = _t1 - 1;
82 const t_real _t8 = zt + 1;
83 const t_real _t9 = _t4*_t8;
84 const t_real _t10 = _t2*_t9;
85 const t_real _t11 = 2*xi;
86 const t_real _t12 = _t11 - 1;
87 const t_real _t13 = _t12 + et;
88 const t_real _t14 = 2*zt;
89 const t_real _t15 = -_t13*_t14;
90 const t_real _t16 = 2*et;
91 const t_real _t17 = _t16*zt;
92 const t_real _t18 = -_t3;
93 const t_real _t19 = ((zt) * (zt)) - 1;
94 const t_real _t20 = -_t19*_t2;
95 const t_real _t21 = _t17*_t8;
96 const t_real _t22 = 4*_t19;
97 const t_real _t23 = -_t19;
98 const t_real _t24 = _t0 - 1;
99 const t_real _t25 = _t11*zt;
100 const t_real _t26 = _t16 - 1;
101 const t_real _t27 = _t26 + xi;
102 const t_real _t28 = -_t14*_t27;
103 const t_real _t29 = _t25*_t8;
104 const t_real _t30 = _t14 - 1;
105 const t_real _t31 = ((0.5))*_t30;
106 const t_real _t32 = et + xi - 1;
107 const t_real _t33 = _t32*(_t12 + _t16);
108 const t_real _t34 = _t12*xi;
109 const t_real _t35 = _t26*et;
110 const t_real _t36 = _t14 + 1;
111 const t_real _t37 = ((0.5))*_t36;
112 const t_real _t38 = -_t30*_t32;
113 const t_real _t39 = _t11*et;
114 const t_real _t40 = -_t32*_t36;
115 const t_real _t41 = 8*xi*zt;
116 v(0, 0) = _t6;
117 v(0, 1) = _t5*_t7;
118 v(0, 3) = _t10;
119 v(0, 4) = _t7*_t9;
120 v(0, 6) = _t15*_t3;
121 v(0, 7) = _t17*_t3;
122 v(0, 8) = _t17*_t18;
123 v(0, 9) = _t20;
124 v(0, 10) = -_t19*_t7;
125 v(0, 12) = _t15*_t8;
126 v(0, 13) = _t21;
127 v(0, 14) = -_t21;
128 v(0, 15) = _t13*_t22;
129 v(0, 16) = _t0*_t23;
130 v(0, 17) = _t0*_t19;
131 v(1, 0) = _t6;
132 v(1, 2) = _t24*_t5;
133 v(1, 3) = _t10;
134 v(1, 5) = _t24*_t9;
135 v(1, 6) = _t18*_t25;
136 v(1, 7) = _t25*_t3;
137 v(1, 8) = _t28*_t3;
138 v(1, 9) = _t20;
139 v(1, 11) = -_t19*_t24;
140 v(1, 12) = -_t29;
141 v(1, 13) = _t29;
142 v(1, 14) = _t28*_t8;
143 v(1, 15) = _t1*_t19;
144 v(1, 16) = _t1*_t23;
145 v(1, 17) = _t22*_t27;
146 v(2, 0) = _t31*_t33;
147 v(2, 1) = _t31*_t34;
148 v(2, 2) = _t31*_t35;
149 v(2, 3) = _t33*_t37;
150 v(2, 4) = _t34*_t37;
151 v(2, 5) = _t35*_t37;
152 v(2, 6) = _t11*_t38;
153 v(2, 7) = _t30*_t39;
154 v(2, 8) = _t16*_t38;
155 v(2, 9) = -_t14*_t33;
156 v(2, 10) = -_t12*_t25;
157 v(2, 11) = -_t17*_t26;
158 v(2, 12) = _t11*_t40;
159 v(2, 13) = _t36*_t39;
160 v(2, 14) = _t16*_t40;
161 v(2, 15) = _t32*_t41;
162 v(2, 16) = -_t41*et;
163 v(2, 17) = 8*_t32*et*zt;
164 }
165
166 template <class TPoint, class TArray>
167 DNDS_DEVICE_CALLABLE static inline void Diff2(const TPoint &p, TArray &&v)
168 {
169 t_real xi = p[0];
170 t_real et = p[1];
171 t_real zt = p[2];
172 const t_real _t0 = zt - 1;
173 const t_real _t1 = 2*zt;
174 const t_real _t2 = _t0*_t1;
175 const t_real _t3 = zt + 1;
176 const t_real _t4 = _t1*_t3;
177 const t_real _t5 = -_t0;
178 const t_real _t6 = 4*zt;
179 const t_real _t7 = _t5*_t6;
180 const t_real _t8 = ((zt) * (zt));
181 const t_real _t9 = 4*_t8 - 4;
182 const t_real _t10 = -_t9;
183 const t_real _t11 = -_t3*_t6;
184 const t_real _t12 = 8*_t8 - 8;
185 const t_real _t13 = et + xi - 1;
186 const t_real _t14 = 2*et;
187 const t_real _t15 = 2*xi;
188 const t_real _t16 = _t15 - 1;
189 const t_real _t17 = _t13*(_t14 + _t16);
190 const t_real _t18 = _t16*xi;
191 const t_real _t19 = _t14 - 1;
192 const t_real _t20 = _t19*et;
193 const t_real _t21 = -_t13;
194 const t_real _t22 = 4*xi;
195 const t_real _t23 = _t21*_t22;
196 const t_real _t24 = 4*et;
197 const t_real _t25 = _t24*xi;
198 const t_real _t26 = _t21*_t24;
199 const t_real _t27 = 8*xi;
200 const t_real _t28 = 8*et;
201 const t_real _t29 = _t1*_t5;
202 const t_real _t30 = -_t4;
203 const t_real _t31 = -3*zt;
204 const t_real _t32 = -_t15;
205 const t_real _t33 = _t6*xi;
206 const t_real _t34 = _t32 + _t33;
207 const t_real _t35 = -_t14;
208 const t_real _t36 = _t24*zt;
209 const t_real _t37 = _t35 + _t36;
210 const t_real _t38 = _t31 + _t34 + _t37 + (1.5);
211 const t_real _t39 = -zt;
212 const t_real _t40 = _t36 + _t39;
213 const t_real _t41 = _t15 + _t33;
214 const t_real _t42 = _t14 + _t36;
215 const t_real _t43 = _t31 + _t41 + _t42 + (-1.5);
216 const t_real _t44 = _t1 - 1;
217 const t_real _t45 = -_t44;
218 const t_real _t46 = -4*zt;
219 const t_real _t47 = _t28*zt;
220 const t_real _t48 = _t46 + _t47;
221 const t_real _t49 = _t1*(-_t22 - _t24 + 3);
222 const t_real _t50 = _t1 + 1;
223 const t_real _t51 = -_t50;
224 const t_real _t52 = _t27*zt;
225 const t_real _t53 = 8*zt;
226 const t_real _t54 = _t33 + _t39;
227 const t_real _t55 = _t46 + _t52;
228 v(0, 0) = _t2;
229 v(0, 1) = _t2;
230 v(0, 3) = _t4;
231 v(0, 4) = _t4;
232 v(0, 6) = _t7;
233 v(0, 9) = _t10;
234 v(0, 10) = _t10;
235 v(0, 12) = _t11;
236 v(0, 15) = _t12;
237 v(1, 0) = _t2;
238 v(1, 2) = _t2;
239 v(1, 3) = _t4;
240 v(1, 5) = _t4;
241 v(1, 8) = _t7;
242 v(1, 9) = _t10;
243 v(1, 11) = _t10;
244 v(1, 14) = _t11;
245 v(1, 17) = _t12;
246 v(2, 0) = _t17;
247 v(2, 1) = _t18;
248 v(2, 2) = _t20;
249 v(2, 3) = _t17;
250 v(2, 4) = _t18;
251 v(2, 5) = _t20;
252 v(2, 6) = _t23;
253 v(2, 7) = _t25;
254 v(2, 8) = _t26;
255 v(2, 9) = -2*_t17;
256 v(2, 10) = -_t15*_t16;
257 v(2, 11) = -_t14*_t19;
258 v(2, 12) = _t23;
259 v(2, 13) = _t25;
260 v(2, 14) = _t26;
261 v(2, 15) = _t13*_t27;
262 v(2, 16) = -_t27*et;
263 v(2, 17) = _t13*_t28;
264 v(3, 0) = _t2;
265 v(3, 3) = _t4;
266 v(3, 6) = _t29;
267 v(3, 7) = _t2;
268 v(3, 8) = _t29;
269 v(3, 9) = _t10;
270 v(3, 12) = _t30;
271 v(3, 13) = _t4;
272 v(3, 14) = _t30;
273 v(3, 15) = _t9;
274 v(3, 16) = _t10;
275 v(3, 17) = _t9;
276 v(4, 0) = _t38;
277 v(4, 2) = _t35 + _t40 + (0.5);
278 v(4, 3) = _t43;
279 v(4, 5) = _t14 + _t40 + (-0.5);
280 v(4, 6) = _t15*_t45;
281 v(4, 7) = _t15*_t44;
282 v(4, 8) = _t24 - _t34 - _t48 - 2;
283 v(4, 9) = _t49;
284 v(4, 11) = _t1*(1 - _t24);
285 v(4, 12) = _t15*_t51;
286 v(4, 13) = _t15*_t50;
287 v(4, 14) = -_t24 - _t41 - _t48 + 2;
288 v(4, 15) = _t52;
289 v(4, 16) = -_t52;
290 v(4, 17) = _t53*(_t19 + xi);
291 v(5, 0) = _t38;
292 v(5, 1) = _t32 + _t54 + (0.5);
293 v(5, 3) = _t43;
294 v(5, 4) = _t15 + _t54 + (-0.5);
295 v(5, 6) = _t22 - _t37 - _t55 - 2;
296 v(5, 7) = _t14*_t44;
297 v(5, 8) = _t14*_t45;
298 v(5, 9) = _t49;
299 v(5, 10) = _t1*(1 - _t22);
300 v(5, 12) = -_t22 - _t42 - _t55 + 2;
301 v(5, 13) = _t14*_t50;
302 v(5, 14) = _t14*_t51;
303 v(5, 15) = _t53*(_t16 + et);
304 v(5, 16) = -_t47;
305 v(5, 17) = _t47;
306 }
307
308 template <class TPoint, class TArray>
309 DNDS_DEVICE_CALLABLE static inline void Diff3(const TPoint &p, TArray &&v)
310 {
311 t_real xi = p[0];
312 t_real et = p[1];
313 t_real zt = p[2];
314 const t_real _t0 = 4*zt;
315 const t_real _t1 = _t0 - 2;
316 const t_real _t2 = _t0 + 2;
317 const t_real _t3 = 8*zt;
318 const t_real _t4 = 4 - _t3;
319 const t_real _t5 = -_t3;
320 const t_real _t6 = -_t3 - 4;
321 const t_real _t7 = 16*zt;
322 const t_real _t8 = 4*et;
323 const t_real _t9 = 4*xi;
324 const t_real _t10 = _t8 + _t9 - 3;
325 const t_real _t11 = _t8 - 1;
326 const t_real _t12 = -_t9;
327 const t_real _t13 = 8*et;
328 const t_real _t14 = -_t13 - _t9 + 4;
329 const t_real _t15 = 8*xi;
330 const t_real _t16 = -_t13 - _t15 + 6;
331 const t_real _t17 = _t9 - 1;
332 const t_real _t18 = -_t15 - _t8 + 4;
333 const t_real _t19 = -_t8;
334 const t_real _t20 = -_t1;
335 const t_real _t21 = -_t2;
336 v(5, 0) = _t1;
337 v(5, 2) = _t1;
338 v(5, 3) = _t2;
339 v(5, 5) = _t2;
340 v(5, 8) = _t4;
341 v(5, 9) = _t5;
342 v(5, 11) = _t5;
343 v(5, 14) = _t6;
344 v(5, 17) = _t7;
345 v(6, 0) = _t10;
346 v(6, 2) = _t11;
347 v(6, 3) = _t10;
348 v(6, 5) = _t11;
349 v(6, 6) = _t12;
350 v(6, 7) = _t9;
351 v(6, 8) = _t14;
352 v(6, 9) = _t16;
353 v(6, 11) = 2 - _t13;
354 v(6, 12) = _t12;
355 v(6, 13) = _t9;
356 v(6, 14) = _t14;
357 v(6, 15) = _t15;
358 v(6, 16) = -_t15;
359 v(6, 17) = _t15 + 16*et - 8;
360 v(7, 0) = _t10;
361 v(7, 1) = _t17;
362 v(7, 3) = _t10;
363 v(7, 4) = _t17;
364 v(7, 6) = _t18;
365 v(7, 7) = _t8;
366 v(7, 8) = _t19;
367 v(7, 9) = _t16;
368 v(7, 10) = 2 - _t15;
369 v(7, 12) = _t18;
370 v(7, 13) = _t8;
371 v(7, 14) = _t19;
372 v(7, 15) = _t13 + 16*xi - 8;
373 v(7, 16) = -_t13;
374 v(7, 17) = _t13;
375 v(8, 0) = _t1;
376 v(8, 1) = _t1;
377 v(8, 3) = _t2;
378 v(8, 4) = _t2;
379 v(8, 6) = _t4;
380 v(8, 9) = _t5;
381 v(8, 10) = _t5;
382 v(8, 12) = _t6;
383 v(8, 15) = _t7;
384 v(9, 0) = _t1;
385 v(9, 3) = _t2;
386 v(9, 6) = _t20;
387 v(9, 7) = _t1;
388 v(9, 8) = _t20;
389 v(9, 9) = _t5;
390 v(9, 12) = _t21;
391 v(9, 13) = _t2;
392 v(9, 14) = _t21;
393 v(9, 15) = _t3;
394 v(9, 16) = _t5;
395 v(9, 17) = _t3;
396 }
397 };
398 // <GEN_SHAPE_FUNCS_END>
399
400
401 /**
402 * @brief Element traits for 18-node quadratic prism (Prism18)
403 *
404 * Prism18 is a high-order 3D prismatic element with:
405 * - 6 corner nodes (vertices)
406 * - 9 edge mid-nodes
407 * - 3 face center nodes (on quadrilateral faces)
408 *
409 * Used for high-order finite element methods with prismatic elements.
410 */
411 template <>
413 {
414 // ============================================================
415 // Core Element Identification
416 // ============================================================
417
418 static constexpr ElemType elemType = Prism18;
419 static constexpr int dim = 3;
420 static constexpr int order = 2;
421 static constexpr int numVertices = 6;
422 static constexpr int numNodes = 18;
423 static constexpr int numFaces = 5;
424 static constexpr ParamSpace paramSpace = PrismSpace;
425 static constexpr t_real paramSpaceVol = 1.0;
426
427 // ============================================================
428 // Geometry Definition
429 // ============================================================
430
431 /**
432 * @brief Standard coordinates of nodes in parametric space
433 *
434 * Nodes 0-5: vertices (same as Prism6)
435 * Nodes 6-8: bottom triangle edge midpoints
436 * Nodes 9-11: vertical edge midpoints
437 * Nodes 12-14: top triangle edge midpoints
438 * Nodes 15-17: side quadrilateral face centers
439 */
440 static constexpr std::array<t_real, 3 * 18> standardCoords = {
441 // Vertices (0-5)
442 0, 0, -1, 1, 0, -1, 0, 1, -1,
443 0, 0, 1, 1, 0, 1, 0, 1, 1,
444 // Bottom edge mids (6-8)
445 0.5, 0, -1, 0.5, 0.5, -1, 0, 0.5, -1,
446 // Vertical edge mids (9-11)
447 0, 0, 0, 1, 0, 0, 0, 1, 0,
448 // Top edge mids (12-14)
449 0.5, 0, 1, 0.5, 0.5, 1, 0, 0.5, 1,
450 // Side face centers (15-17)
451 0.5, 0, 0, 0.5, 0.5, 0, 0, 0.5, 0};
452
453 // ============================================================
454 // Face/Edge Definitions
455 // ============================================================
456
457 /**
458 * @brief Get the element type of a face
459 * @param iFace Face index (0-2 are quads, 3-4 are triangles)
460 * @return Quad9 for side faces, Tri6 for cap faces
461 */
462 static constexpr ElemType GetFaceType(t_index iFace)
463 {
464 return iFace < 3 ? Quad9 : Tri6;
465 }
466
467 /**
468 * @brief Node indices for each face
469 *
470 * Quadrilateral faces have 9 nodes (4 vertices + 4 edge mids + 1 center)
471 * Triangular faces have 6 nodes (3 vertices + 3 edge mids)
472 */
473 static constexpr std::array<std::array<t_index, 10>, 5> faceNodes = {{
474 {0, 1, 4, 3, 6, 10, 12, 9, 15}, // Face 0: side quad
475 {1, 2, 5, 4, 7, 11, 13, 10, 16}, // Face 1: side quad
476 {2, 0, 3, 5, 8, 9, 14, 11, 17}, // Face 2: side quad
477 {0, 2, 1, 8, 7, 6}, // Face 3: bottom triangle
478 {3, 4, 5, 9, 10, 11}}}; // Face 4: top triangle
479
480 // ============================================================
481 // Order Elevation (P-Refinement)
482 // ============================================================
483
484 /// @brief Element type after order elevation (O2 has no higher elevation defined)
485 static constexpr ElemType elevatedType = UnknownElem;
486
487 /// @brief Number of additional nodes created during elevation (none for O2)
488 static constexpr int numElevNodes = 0;
489
490 // ============================================================
491 // Bisection (Adaptive Refinement)
492 // ============================================================
493
494 /**
495 * @brief O2 bisection: 8 sub-prisms created from one Prism18
496 *
497 * Bisection splits the prism by connecting mid-edge nodes,
498 * creating 8 smaller linear prisms (Prism6 elements).
499 */
500 static constexpr int numBisect = 8;
501
502 /// @brief Number of bisection variants (1 standard bisection pattern)
503 static constexpr int numBisectVariants = 1;
504
505 /**
506 * @brief Get the element type of a sub-element after bisection
507 * @return Prism6 (all sub-elements are linear prisms)
508 */
509 static constexpr ElemType GetBisectElemType(t_index /*i*/) { return Prism6; }
510
511 /**
512 * @brief Sub-element connectivity after bisection
513 *
514 * Each row defines one sub-prism using parent node indices.
515 * The 8 sub-prisms fill the volume of the original element.
516 */
517 static constexpr std::array<tBisectSub, 8> bisectElements = {{
518 {0, 6, 8, 9, 15, 17}, // Sub-prism 0: near vertex 0
519 {6, 1, 7, 15, 10, 16}, // Sub-prism 1: near vertex 1
520 {8, 6, 7, 17, 15, 16}, // Sub-prism 2: bottom center
521 {8, 7, 2, 17, 16, 11}, // Sub-prism 3: near vertex 2
522 {9, 15, 17, 3, 12, 14}, // Sub-prism 4: near vertex 3
523 {15, 10, 16, 12, 4, 13}, // Sub-prism 5: near vertex 4
524 {17, 15, 16, 14, 12, 13}, // Sub-prism 6: top center
525 {17, 16, 11, 14, 13, 5}}}; // Sub-prism 7: near vertex 5
526
527 // ============================================================
528 // VTK/Visualization Support
529 // ============================================================
530
531 /// @brief VTK cell type identifier (26 = VTK_BIQUADRATIC_QUADRATIC_WEDGE)
532 static constexpr int vtkCellType = 26;
533
534 /**
535 * @brief VTK node ordering map
536 *
537 * VTK has non-trivial node reordering for Prism18:
538 * VTK nodes 0-5 = vertices 0-5
539 * VTK nodes 6-8 = bottom triangle edge mids 6-8
540 * VTK nodes 9-11 = top triangle edge mids 12-14 (note: reordered!)
541 * VTK nodes 12-14 = vertical edge mids 9-11 (note: reordered!)
542 * Note: Face center nodes 15-17 are not included in VTK ordering
543 */
544 static constexpr std::array<int, 15> vtkNodeOrder = {
545 0, 1, 2, 3, 4, 5, // Vertices
546 6, 7, 8, // Bottom edges
547 12, 13, 14, // Top edges (reordered)
548 9, 10, 11}; // Vertical edges (reordered)
549 };
550
551} // namespace DNDS::Geom::Elem
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_DEVICE_CALLABLE
Definition Defines.hpp:76
int32_t t_index
Definition Geometric.hpp:6
double t_real
Definition Geometric.hpp:8
static constexpr ElemType GetFaceType(t_index iFace)
Get the element type of a face.
Definition Prism18.hpp:462
static constexpr ElemType GetBisectElemType(t_index)
Get the element type of a sub-element after bisection.
Definition Prism18.hpp:509
static DNDS_DEVICE_CALLABLE void Diff2(const TPoint &p, TArray &&v)
Definition Prism18.hpp:167
static DNDS_DEVICE_CALLABLE void Diff1(const TPoint &p, TArray &&v)
Definition Prism18.hpp:69
static DNDS_DEVICE_CALLABLE void Diff0(const TPoint &p, TArray &&v)
Definition Prism18.hpp:22
static DNDS_DEVICE_CALLABLE void Diff3(const TPoint &p, TArray &&v)
Definition Prism18.hpp:309
Eigen::Matrix< real, 5, 1 > v
double order
Definition test_ODE.cpp:257