DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Tet4.hpp
Go to the documentation of this file.
1#pragma once
2// Auto-generated by tools/gen_shape_functions -- DO NOT EDIT
3// Element: Tet4
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 v(0, 0) = -et - xi - zt + 1;
28 v(0, 1) = xi;
29 v(0, 2) = et;
30 v(0, 3) = zt;
31 }
32
33 template <class TPoint, class TArray>
34 DNDS_DEVICE_CALLABLE static inline void Diff1(const TPoint &p, TArray &&v)
35 {
36 t_real xi = p[0];
37 t_real et = p[1];
38 t_real zt = p[2];
39 v(0, 0) = -1;
40 v(0, 1) = 1;
41 v(1, 0) = -1;
42 v(1, 2) = 1;
43 v(2, 0) = -1;
44 v(2, 3) = 1;
45 }
46
47 template <class TPoint, class TArray>
48 DNDS_DEVICE_CALLABLE static inline void Diff2(const TPoint &p, TArray &&v)
49 {
50 t_real xi = p[0];
51 t_real et = p[1];
52 t_real zt = p[2];
53 // all zero
54 }
55
56 template <class TPoint, class TArray>
57 DNDS_DEVICE_CALLABLE static inline void Diff3(const TPoint &p, TArray &&v)
58 {
59 t_real xi = p[0];
60 t_real et = p[1];
61 t_real zt = p[2];
62 // all zero
63 }
64 };
65 // <GEN_SHAPE_FUNCS_END>
66
67
68 /**
69 * @brief Element traits for 4-node linear tetrahedron (Tet4)
70 *
71 * Tet4 is the simplest 3D element, commonly used for:
72 * - Unstructured tetrahedral meshes
73 * - Automatic mesh generation
74 * - Complex geometry representation
75 *
76 * Geometry:
77 * - Reference tetrahedron with vertices at (0,0,0), (1,0,0), (0,1,0), (0,0,1)
78 * - Parametric space volume = 1/6
79 *
80 * Faces:
81 * - 4 triangular faces, each is a Tri3 element
82 */
83 template <>
85 {
86 // ============================================================
87 // Core Element Identification
88 // ============================================================
89
90 static constexpr ElemType elemType = Tet4;
91 static constexpr int dim = 3;
92 static constexpr int order = 1;
93 static constexpr int numVertices = 4;
94 static constexpr int numNodes = 4;
95 static constexpr int numFaces = 4;
96 static constexpr ParamSpace paramSpace = TetSpace;
97 static constexpr t_real paramSpaceVol = 1.0 / 6.0;
98
99 // ============================================================
100 // Geometry Definition
101 // ============================================================
102
103 /**
104 * @brief Standard coordinates of nodes in parametric space
105 *
106 * Reference tetrahedron with nodes at:
107 * Node 0: (0, 0, 0) - origin
108 * Node 1: (1, 0, 0) - on x-axis
109 * Node 2: (0, 1, 0) - on y-axis
110 * Node 3: (0, 0, 1) - on z-axis
111 */
112 static constexpr std::array<t_real, 3 * 4> standardCoords = {
113 0, 0, 0, // Node 0: origin
114 1, 0, 0, // Node 1: x-axis
115 0, 1, 0, // Node 2: y-axis
116 0, 0, 1}; // Node 3: z-axis
117
118 // ============================================================
119 // Face/Edge Definitions
120 // ============================================================
121
122 /**
123 * @brief Get the element type of a face
124 * @return Tri3 (all faces of tet are triangles)
125 */
126 static constexpr ElemType GetFaceType(t_index /*iFace*/) { return Tri3; }
127
128 /**
129 * @brief Node indices for each face (triangular face)
130 *
131 * Face 0: nodes 0-2-1 (bottom face, z=0)
132 * Face 1: nodes 0-1-3 (side face, y=0)
133 * Face 2: nodes 1-2-3 (side face, x=0 is opposite)
134 * Face 3: nodes 2-0-3 (side face, x=0)
135 *
136 * Note: Node ordering follows right-hand rule for outward normals.
137 */
138 static constexpr std::array<std::array<t_index, 10>, 4> faceNodes = {{
139 {0, 2, 1}, // Face 0: bottom (z=0 plane)
140 {0, 1, 3}, // Face 1: side (y=0 plane)
141 {1, 2, 3}, // Face 2: side (diagonal)
142 {2, 0, 3}}}; // Face 3: side (x=0 plane)
143
144 // ============================================================
145 // Order Elevation (P-Refinement)
146 // ============================================================
147
148 /**
149 * @brief Element type after order elevation (O1 -> O2)
150 * Tet4 elevates to Tet10 (10-node quadratic tetrahedron)
151 */
152 static constexpr ElemType elevatedType = Tet10;
153
154 /// @brief Number of additional nodes created during elevation (6 edge midpoints)
155 static constexpr int numElevNodes = 6;
156
157 /**
158 * @brief Elevation spans define edge midpoints
159 *
160 * Each new node is at the midpoint of an edge:
161 * Span 0-2: edges of base triangle
162 * Span 3-5: edges connecting apex to base vertices
163 */
164 static constexpr std::array<tElevSpan, 6> elevSpans = {{
165 {0, 1}, // Edge 0-1 midpoint
166 {1, 2}, // Edge 1-2 midpoint
167 {2, 0}, // Edge 2-0 midpoint
168 {0, 3}, // Edge 0-3 midpoint
169 {1, 3}, // Edge 1-3 midpoint
170 {2, 3}}}; // Edge 2-3 midpoint
171
172 /// @brief Element type of each elevation span (all are Line2 edges)
173 static constexpr std::array<ElemType, 6> elevNodeSpanTypes = {
175
176 // ============================================================
177 // VTK/Visualization Support
178 // ============================================================
179
180 /// @brief VTK cell type identifier (10 = VTK_TETRA)
181 static constexpr int vtkCellType = 10;
182
183 /**
184 * @brief VTK node ordering map
185 *
186 * VTK uses the same ordering as DNDS for Tet4:
187 * VTK node 0 = DNDS node 0, VTK node 1 = DNDS node 1, etc.
188 */
189 static constexpr std::array<int, 4> vtkNodeOrder = {0, 1, 2, 3};
190 };
191
192} // 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)
Get the element type of a face.
Definition Tet4.hpp:126
static DNDS_DEVICE_CALLABLE void Diff0(const TPoint &p, TArray &&v)
Definition Tet4.hpp:22
static DNDS_DEVICE_CALLABLE void Diff2(const TPoint &p, TArray &&v)
Definition Tet4.hpp:48
static DNDS_DEVICE_CALLABLE void Diff3(const TPoint &p, TArray &&v)
Definition Tet4.hpp:57
static DNDS_DEVICE_CALLABLE void Diff1(const TPoint &p, TArray &&v)
Definition Tet4.hpp:34
Eigen::Matrix< real, 5, 1 > v
double order
Definition test_ODE.cpp:257