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