DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Tet10.hpp
Go to the documentation of this file.
1#pragma once
2// Auto-generated by tools/gen_shape_functions -- DO NOT EDIT
3// Element: Tet10
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 = et + xi + zt - 1;
28 const t_real _t1 = 2*et;
29 const t_real _t2 = 2*zt;
30 const t_real _t3 = 2*xi - 1;
31 const t_real _t4 = -_t0;
32 const t_real _t5 = 4*xi;
33 const t_real _t6 = 4*_t4;
34 v(0, 0) = _t0*(_t1 + _t2 + _t3);
35 v(0, 1) = _t3*xi;
36 v(0, 2) = et*(_t1 - 1);
37 v(0, 3) = zt*(_t2 - 1);
38 v(0, 4) = _t4*_t5;
39 v(0, 5) = _t5*et;
40 v(0, 6) = _t6*et;
41 v(0, 7) = _t6*zt;
42 v(0, 8) = _t5*zt;
43 v(0, 9) = 4*et*zt;
44 }
45
46 template <class TPoint, class TArray>
47 DNDS_DEVICE_CALLABLE static inline void Diff1(const TPoint &p, TArray &&v)
48 {
49 t_real xi = p[0];
50 t_real et = p[1];
51 t_real zt = p[2];
52 const t_real _t0 = 4*xi;
53 const t_real _t1 = 4*et;
54 const t_real _t2 = 4*zt;
55 const t_real _t3 = _t1 + _t2;
56 const t_real _t4 = _t0 + _t3 - 3;
57 const t_real _t5 = -_t1;
58 const t_real _t6 = -_t2;
59 const t_real _t7 = -_t0;
60 const t_real _t8 = _t0 - 4;
61 v(0, 0) = _t4;
62 v(0, 1) = _t0 - 1;
63 v(0, 4) = -_t3 - 8*xi + 4;
64 v(0, 5) = _t1;
65 v(0, 6) = _t5;
66 v(0, 7) = _t6;
67 v(0, 8) = _t2;
68 v(1, 0) = _t4;
69 v(1, 2) = _t1 - 1;
70 v(1, 4) = _t7;
71 v(1, 5) = _t0;
72 v(1, 6) = -_t2 - _t8 - 8*et;
73 v(1, 7) = _t6;
74 v(1, 9) = _t2;
75 v(2, 0) = _t4;
76 v(2, 3) = _t2 - 1;
77 v(2, 4) = _t7;
78 v(2, 6) = _t5;
79 v(2, 7) = -_t1 - _t8 - 8*zt;
80 v(2, 8) = _t0;
81 v(2, 9) = _t1;
82 }
83
84 template <class TPoint, class TArray>
85 DNDS_DEVICE_CALLABLE static inline void Diff2(const TPoint &p, TArray &&v)
86 {
87 t_real xi = p[0];
88 t_real et = p[1];
89 t_real zt = p[2];
90 v(0, 0) = 4;
91 v(0, 1) = 4;
92 v(0, 4) = -8;
93 v(1, 0) = 4;
94 v(1, 2) = 4;
95 v(1, 6) = -8;
96 v(2, 0) = 4;
97 v(2, 3) = 4;
98 v(2, 7) = -8;
99 v(3, 0) = 4;
100 v(3, 4) = -4;
101 v(3, 5) = 4;
102 v(3, 6) = -4;
103 v(4, 0) = 4;
104 v(4, 6) = -4;
105 v(4, 7) = -4;
106 v(4, 9) = 4;
107 v(5, 0) = 4;
108 v(5, 4) = -4;
109 v(5, 7) = -4;
110 v(5, 8) = 4;
111 }
112
113 template <class TPoint, class TArray>
114 DNDS_DEVICE_CALLABLE static inline void Diff3(const TPoint &p, TArray &&v)
115 {
116 t_real xi = p[0];
117 t_real et = p[1];
118 t_real zt = p[2];
119 // all zero
120 }
121 };
122 // <GEN_SHAPE_FUNCS_END>
123
124
125 /**
126 * @brief Element traits for 10-node quadratic tetrahedron (Tet10)
127 *
128 * Tet10 is a high-order 3D element with:
129 * - 4 corner nodes (vertices)
130 * - 6 edge mid-nodes
131 *
132 * Used for high-order finite element methods requiring curved geometry representation.
133 */
134 template <>
136 {
137 // ============================================================
138 // Core Element Identification
139 // ============================================================
140
141 static constexpr ElemType elemType = Tet10;
142 static constexpr int dim = 3;
143 static constexpr int order = 2;
144 static constexpr int numVertices = 4;
145 static constexpr int numNodes = 10;
146 static constexpr int numFaces = 4;
147 static constexpr ParamSpace paramSpace = TetSpace;
148 static constexpr t_real paramSpaceVol = 1.0 / 6.0;
149
150 // ============================================================
151 // Geometry Definition
152 // ============================================================
153
154 /**
155 * @brief Standard coordinates of nodes in parametric space
156 *
157 * Nodes 0-3: vertices (same as Tet4)
158 * Nodes 4-9: edge midpoints
159 */
160 static constexpr std::array<t_real, 3 * 10> standardCoords = {
161 0, 0, 0, // Node 0: vertex
162 1, 0, 0, // Node 1: vertex
163 0, 1, 0, // Node 2: vertex
164 0, 0, 1, // Node 3: vertex
165 0.5, 0, 0, // Node 4: edge 0-1 midpoint
166 0.5, 0.5, 0, // Node 5: edge 1-2 midpoint
167 0, 0.5, 0, // Node 6: edge 2-0 midpoint
168 0, 0, 0.5, // Node 7: edge 0-3 midpoint
169 0.5, 0, 0.5, // Node 8: edge 1-3 midpoint
170 0, 0.5, 0.5}; // Node 9: edge 2-3 midpoint
171
172 // ============================================================
173 // Face/Edge Definitions
174 // ============================================================
175
176 /**
177 * @brief Get the element type of a face
178 * @return Tri6 (all faces are 6-node quadratic triangles)
179 */
180 static constexpr ElemType GetFaceType(t_index /*iFace*/) { return Tri6; }
181
182 /**
183 * @brief Node indices for each face (quadratic triangle)
184 *
185 * Each face has 6 nodes: 3 vertices + 3 edge midpoints
186 */
187 static constexpr std::array<std::array<t_index, 10>, 4> faceNodes = {{
188 {0, 2, 1, 6, 5, 4}, // Face 0: bottom (nodes + edge mids)
189 {0, 1, 3, 4, 8, 7}, // Face 1: side
190 {1, 2, 3, 5, 9, 8}, // Face 2: side
191 {2, 0, 3, 6, 7, 9}}}; // Face 3: side
192
193 // ============================================================
194 // Order Elevation (P-Refinement)
195 // ============================================================
196
197 /// @brief Element type after order elevation (O2 has no higher elevation defined)
198 static constexpr ElemType elevatedType = UnknownElem;
199
200 /// @brief Number of additional nodes created during elevation (none for O2)
201 static constexpr int numElevNodes = 0;
202
203 // ============================================================
204 // Bisection (Adaptive Refinement)
205 // ============================================================
206
207 /// @brief Number of sub-elements created when bisecting (8 Tet4 elements)
208 static constexpr int numBisect = 8;
209
210 /**
211 * @brief Number of bisection variants (3 different diagonal choices)
212 *
213 * A tetrahedron can be bisected in multiple ways depending on which
214 * internal diagonal is chosen for subdivision.
215 */
216 static constexpr int numBisectVariants = 3;
217
218 /**
219 * @brief Get the element type of a sub-element after bisection
220 * @return Tet4 (all sub-elements are linear tets)
221 */
222 static constexpr ElemType GetBisectElemType(t_index /*i*/) { return Tet4; }
223
224 /**
225 * @brief Node indices for each sub-element created by bisection
226 *
227 * 3 variants x 8 sub-tets = 24 entries total.
228 * Each variant uses a different internal diagonal for subdivision.
229 */
230 static constexpr std::array<tBisectSub, 24> bisectElements = {{
231 // Variant 0 (diagonal 4-9, i.e., node4-node9 in 0-based)
232 {0, 4, 6, 7},
233 {4, 1, 5, 8},
234 {6, 5, 2, 9},
235 {9, 7, 8, 3},
236 {4, 9, 6, 7},
237 {4, 8, 9, 7},
238 {4, 9, 8, 5},
239 {4, 6, 9, 5},
240 // Variant 1 (diagonal 5-7, i.e., node5-node7 in 0-based)
241 {0, 4, 6, 7},
242 {4, 1, 5, 8},
243 {6, 5, 2, 9},
244 {9, 7, 8, 3},
245 {5, 6, 7, 9},
246 {5, 7, 8, 9},
247 {5, 8, 7, 4},
248 {5, 7, 6, 4},
249 // Variant 2 (diagonal 6-8, i.e., node6-node8 in 0-based)
250 {0, 4, 6, 7},
251 {4, 1, 5, 8},
252 {6, 5, 2, 9},
253 {9, 7, 8, 3},
254 {6, 7, 8, 9},
255 {6, 8, 5, 9},
256 {6, 8, 7, 4},
257 {6, 5, 8, 4}}};
258
259 // ============================================================
260 // VTK/Visualization Support
261 // ============================================================
262
263 /// @brief VTK cell type identifier (24 = VTK_QUADRATIC_TETRA)
264 static constexpr int vtkCellType = 24;
265
266 /**
267 * @brief VTK node ordering map
268 *
269 * VTK uses the same ordering as DNDS for Tet10:
270 * VTK nodes 0-3 = corner nodes 0-3
271 * VTK nodes 4-9 = edge mid-nodes 4-9
272 */
273 static constexpr std::array<int, 10> vtkNodeOrder = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
274 };
275
276} // 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 GetBisectElemType(t_index)
Get the element type of a sub-element after bisection.
Definition Tet10.hpp:222
static constexpr ElemType GetFaceType(t_index)
Get the element type of a face.
Definition Tet10.hpp:180
static DNDS_DEVICE_CALLABLE void Diff2(const TPoint &p, TArray &&v)
Definition Tet10.hpp:85
static DNDS_DEVICE_CALLABLE void Diff3(const TPoint &p, TArray &&v)
Definition Tet10.hpp:114
static DNDS_DEVICE_CALLABLE void Diff1(const TPoint &p, TArray &&v)
Definition Tet10.hpp:47
static DNDS_DEVICE_CALLABLE void Diff0(const TPoint &p, TArray &&v)
Definition Tet10.hpp:22
Eigen::Matrix< real, 5, 1 > v
double order
Definition test_ODE.cpp:257