DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Tri6.hpp
Go to the documentation of this file.
1#pragma once
2// Auto-generated by tools/gen_shape_functions -- DO NOT EDIT
3// Element: Tri6
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 const t_real _t0 = et + xi - 1;
27 const t_real _t1 = 2*et;
28 const t_real _t2 = 2*xi - 1;
29 const t_real _t3 = -_t0;
30 const t_real _t4 = 4*xi;
31 v(0, 0) = _t0*(_t1 + _t2);
32 v(0, 1) = _t2*xi;
33 v(0, 2) = et*(_t1 - 1);
34 v(0, 3) = _t3*_t4;
35 v(0, 4) = _t4*et;
36 v(0, 5) = 4*_t3*et;
37 }
38
39 template <class TPoint, class TArray>
40 DNDS_DEVICE_CALLABLE static inline void Diff1(const TPoint &p, TArray &&v)
41 {
42 t_real xi = p[0];
43 t_real et = p[1];
44 const t_real _t0 = 4*et;
45 const t_real _t1 = 4*xi;
46 const t_real _t2 = _t0 + _t1 - 3;
47 v(0, 0) = _t2;
48 v(0, 1) = _t1 - 1;
49 v(0, 3) = -_t0 - 8*xi + 4;
50 v(0, 4) = _t0;
51 v(0, 5) = -_t0;
52 v(1, 0) = _t2;
53 v(1, 2) = _t0 - 1;
54 v(1, 3) = -_t1;
55 v(1, 4) = _t1;
56 v(1, 5) = -_t1 - 8*et + 4;
57 }
58
59 template <class TPoint, class TArray>
60 DNDS_DEVICE_CALLABLE static inline void Diff2(const TPoint &p, TArray &&v)
61 {
62 t_real xi = p[0];
63 t_real et = p[1];
64 v(0, 0) = 4;
65 v(0, 1) = 4;
66 v(0, 3) = -8;
67 v(1, 0) = 4;
68 v(1, 3) = -4;
69 v(1, 4) = 4;
70 v(1, 5) = -4;
71 v(2, 0) = 4;
72 v(2, 2) = 4;
73 v(2, 5) = -8;
74 }
75
76 template <class TPoint, class TArray>
77 DNDS_DEVICE_CALLABLE static inline void Diff3(const TPoint &p, TArray &&v)
78 {
79 t_real xi = p[0];
80 t_real et = p[1];
81 // all zero
82 }
83 };
84 // <GEN_SHAPE_FUNCS_END>
85
86
87 /**
88 * @brief Element traits for 6-node quadratic triangle (Tri6)
89 *
90 * Tri6 is a high-order 2D triangular element with:
91 * - 3 corner nodes (vertices)
92 * - 3 edge mid-nodes
93 *
94 * Used for high-order finite element methods and curved boundary representation.
95 */
96 template <>
98 {
99 // ============================================================
100 // Core Element Identification
101 // ============================================================
102
103 static constexpr ElemType elemType = Tri6;
104 static constexpr int dim = 2;
105 static constexpr int order = 2;
106 static constexpr int numVertices = 3;
107 static constexpr int numNodes = 6;
108 static constexpr int numFaces = 3;
109 static constexpr ParamSpace paramSpace = TriSpace;
110 static constexpr t_real paramSpaceVol = 0.5;
111
112 // ============================================================
113 // Geometry Definition
114 // ============================================================
115
116 /**
117 * @brief Standard coordinates of nodes in parametric space
118 *
119 * Reference triangle with nodes:
120 * Nodes 0-2: vertices (same as Tri3)
121 * Nodes 3-5: edge midpoints
122 */
123 static constexpr std::array<t_real, 3 * 6> standardCoords = {
124 0, 0, 0, // Node 0: vertex
125 1, 0, 0, // Node 1: vertex
126 0, 1, 0, // Node 2: vertex
127 0.5, 0, 0, // Node 3: edge 0-1 midpoint
128 0.5, 0.5, 0, // Node 4: edge 1-2 midpoint
129 0, 0.5, 0}; // Node 5: edge 2-0 midpoint
130
131 // ============================================================
132 // Face/Edge Definitions
133 // ============================================================
134
135 /**
136 * @brief Get the element type of a face (edge)
137 * @return Line3 (all edges are quadratic lines with 3 nodes)
138 */
139 static constexpr ElemType GetFaceType(t_index /*iFace*/) { return Line3; }
140
141 /**
142 * @brief Node indices for each face (edge)
143 *
144 * Each edge has 3 nodes: 2 vertices + 1 midpoint
145 * Edge 0: nodes 0-1-3
146 * Edge 1: nodes 1-2-4
147 * Edge 2: nodes 2-0-5
148 */
149 static constexpr std::array<std::array<t_index, 10>, 3> faceNodes = {{
150 {0, 1, 3}, // Edge 0: bottom
151 {1, 2, 4}, // Edge 1: hypotenuse
152 {2, 0, 5}}}; // Edge 2: left
153
154 // ============================================================
155 // Order Elevation (P-Refinement)
156 // ============================================================
157
158 /// @brief Element type after order elevation (O2 has no higher elevation defined)
159 static constexpr ElemType elevatedType = UnknownElem;
160
161 /// @brief Number of additional nodes created during elevation (none for O2)
162 static constexpr int numElevNodes = 0;
163
164 // ============================================================
165 // Bisection (Adaptive Refinement)
166 // ============================================================
167
168 /// @brief Number of sub-elements created when bisecting (4 Tri3 elements)
169 static constexpr int numBisect = 4;
170
171 /// @brief Number of bisection variants (only 1 way to uniformly bisect)
172 static constexpr int numBisectVariants = 1;
173
174 /**
175 * @brief Get the element type of a sub-element after bisection
176 * @return Tri3 (all sub-elements are linear triangles)
177 */
178 static constexpr ElemType GetBisectElemType(t_index /*i*/) { return Tri3; }
179
180 /**
181 * @brief Node indices for each sub-element created by bisection
182 *
183 * Bisecting creates 4 sub-triangles by connecting edge midpoints:
184 * Sub-element 0: corner at node 0
185 * Sub-element 1: corner at node 1
186 * Sub-element 2: corner at node 2
187 * Sub-element 3: center triangle
188 */
189 static constexpr std::array<tBisectSub, 4> bisectElements = {{
190 {0, 3, 5}, // Corner triangle at vertex 0
191 {3, 1, 4}, // Corner triangle at vertex 1
192 {5, 3, 4}, // Center triangle
193 {5, 4, 2}}}; // Corner triangle at vertex 2
194
195 // ============================================================
196 // VTK/Visualization Support
197 // ============================================================
198
199 /// @brief VTK cell type identifier (22 = VTK_QUADRATIC_TRIANGLE)
200 static constexpr int vtkCellType = 22;
201
202 /**
203 * @brief VTK node ordering map
204 *
205 * VTK uses the same ordering as DNDS for Tri6:
206 * VTK nodes 0-2 = corner nodes 0-2
207 * VTK nodes 3-5 = edge mid-nodes 3-5
208 */
209 static constexpr std::array<int, 6> vtkNodeOrder = {0, 1, 2, 3, 4, 5};
210 };
211
212} // namespace DNDS::Geom::Elem
213
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 (edge)
Definition Tri6.hpp:139
static constexpr ElemType GetBisectElemType(t_index)
Get the element type of a sub-element after bisection.
Definition Tri6.hpp:178
static DNDS_DEVICE_CALLABLE void Diff2(const TPoint &p, TArray &&v)
Definition Tri6.hpp:60
static DNDS_DEVICE_CALLABLE void Diff0(const TPoint &p, TArray &&v)
Definition Tri6.hpp:22
static DNDS_DEVICE_CALLABLE void Diff1(const TPoint &p, TArray &&v)
Definition Tri6.hpp:40
static DNDS_DEVICE_CALLABLE void Diff3(const TPoint &p, TArray &&v)
Definition Tri6.hpp:77
Eigen::Matrix< real, 5, 1 > v
double order
Definition test_ODE.cpp:257