DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
Quad4.hpp
Go to the documentation of this file.
1#pragma once
2// Auto-generated by tools/gen_shape_functions -- DO NOT EDIT
3// Element: Quad4
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 = xi - 1;
27 const t_real _t1 = ((0.25))*et + (-0.25);
28 const t_real _t2 = xi + 1;
29 const t_real _t3 = ((0.25))*et + (0.25);
30 v(0, 0) = _t0*_t1;
31 v(0, 1) = -_t1*_t2;
32 v(0, 2) = _t2*_t3;
33 v(0, 3) = -_t0*_t3;
34 }
35
36 template <class TPoint, class TArray>
37 DNDS_DEVICE_CALLABLE static inline void Diff1(const TPoint &p, TArray &&v)
38 {
39 t_real xi = p[0];
40 t_real et = p[1];
41 const t_real _t0 = ((0.25))*et;
42 const t_real _t1 = _t0 + (-0.25);
43 const t_real _t2 = _t0 + (0.25);
44 const t_real _t3 = ((0.25))*xi;
45 const t_real _t4 = _t3 + (-0.25);
46 const t_real _t5 = _t3 + (0.25);
47 v(0, 0) = _t1;
48 v(0, 1) = -_t1;
49 v(0, 2) = _t2;
50 v(0, 3) = -_t2;
51 v(1, 0) = _t4;
52 v(1, 1) = -_t5;
53 v(1, 2) = _t5;
54 v(1, 3) = -_t4;
55 }
56
57 template <class TPoint, class TArray>
58 DNDS_DEVICE_CALLABLE static inline void Diff2(const TPoint &p, TArray &&v)
59 {
60 t_real xi = p[0];
61 t_real et = p[1];
62 v(1, 0) = (0.25);
63 v(1, 1) = (-0.25);
64 v(1, 2) = (0.25);
65 v(1, 3) = (-0.25);
66 }
67
68 template <class TPoint, class TArray>
69 DNDS_DEVICE_CALLABLE static inline void Diff3(const TPoint &p, TArray &&v)
70 {
71 t_real xi = p[0];
72 t_real et = p[1];
73 // all zero
74 }
75 };
76 // <GEN_SHAPE_FUNCS_END>
77
78
79 /**
80 * @brief Element traits for 4-node bilinear quadrilateral (Quad4)
81 *
82 * Quad4 is the simplest 2D quadrilateral element, commonly used for:
83 * - Structured and unstructured quadrilateral meshes
84 * - Boundary-fitted grids
85 * - Isoparametric mapping
86 *
87 * Geometry:
88 * - Reference quad: xi in [-1, 1], eta in [-1, 1]
89 * - Nodes at the 4 corners of the reference square
90 * - Parametric space area = 4.0
91 *
92 * Faces:
93 * - 4 edges, each is a Line2 element
94 */
95 template <>
97 {
98 // ============================================================
99 // Core Element Identification
100 // ============================================================
101
102 static constexpr ElemType elemType = Quad4;
103 static constexpr int dim = 2;
104 static constexpr int order = 1;
105 static constexpr int numVertices = 4;
106 static constexpr int numNodes = 4;
107 static constexpr int numFaces = 4;
108 static constexpr ParamSpace paramSpace = QuadSpace;
109 static constexpr t_real paramSpaceVol = 4.0;
110
111 // ============================================================
112 // Geometry Definition
113 // ============================================================
114
115 /**
116 * @brief Standard coordinates of nodes in parametric space
117 *
118 * Reference square [-1,1] x [-1,1] with nodes at corners:
119 * Node 0: (-1, -1) - bottom-left
120 * Node 1: ( 1, -1) - bottom-right
121 * Node 2: ( 1, 1) - top-right
122 * Node 3: (-1, 1) - top-left
123 */
124 static constexpr std::array<t_real, 3 * 4> standardCoords = {
125 -1, -1, 0, // Node 0: bottom-left
126 1, -1, 0, // Node 1: bottom-right
127 1, 1, 0, // Node 2: top-right
128 -1, 1, 0}; // Node 3: top-left
129
130 // ============================================================
131 // Face/Edge Definitions
132 // ============================================================
133
134 /**
135 * @brief Get the element type of a face (edge)
136 * @return Line2 (all edges of quad are linear lines)
137 */
138 static constexpr ElemType GetFaceType(t_index /*iFace*/) { return Line2; }
139
140 /**
141 * @brief Node indices for each face (edge)
142 *
143 * Edge 0: nodes 0-1 (bottom edge)
144 * Edge 1: nodes 1-2 (right edge)
145 * Edge 2: nodes 2-3 (top edge)
146 * Edge 3: nodes 3-0 (left edge)
147 */
148 static constexpr std::array<std::array<t_index, 10>, 4> faceNodes = {{
149 {0, 1}, // Edge 0: bottom
150 {1, 2}, // Edge 1: right
151 {2, 3}, // Edge 2: top
152 {3, 0}}}; // Edge 3: left
153
154 // ============================================================
155 // Order Elevation (P-Refinement)
156 // ============================================================
157
158 /**
159 * @brief Element type after order elevation (O1 -> O2)
160 * Quad4 elevates to Quad9 (9-node biquadratic quad)
161 */
162 static constexpr ElemType elevatedType = Quad9;
163
164 /// @brief Number of additional nodes created during elevation
165 static constexpr int numElevNodes = 5;
166
167 /**
168 * @brief Elevation spans define new node connections
169 *
170 * Elevation creates 5 new nodes:
171 * Spans 0-3: edge midpoints (4 nodes on edges)
172 * Span 4: body center (1 node connecting all 4 vertices)
173 */
174 static constexpr std::array<tElevSpan, 5> elevSpans = {{
175 {0, 1}, // Edge 0 midpoint
176 {1, 2}, // Edge 1 midpoint
177 {2, 3}, // Edge 2 midpoint
178 {3, 0}, // Edge 3 midpoint
179 {0, 1, 2, 3}}}; // Body center (all 4 vertices)
180
181 /// @brief Element type of each elevation span
182 static constexpr std::array<ElemType, 5> elevNodeSpanTypes = {
183 Line2, Line2, Line2, Line2, // Edge midpoints
184 Quad4}; // Body center
185
186 // ============================================================
187 // VTK/Visualization Support
188 // ============================================================
189
190 /// @brief VTK cell type identifier (9 = VTK_QUAD)
191 static constexpr int vtkCellType = 9;
192
193 /**
194 * @brief VTK node ordering map
195 *
196 * VTK uses the same ordering as DNDS for Quad4:
197 * VTK node 0 = DNDS node 0, VTK node 1 = DNDS node 1, etc.
198 */
199 static constexpr std::array<int, 4> vtkNodeOrder = {0, 1, 2, 3};
200 };
201
202} // 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 Quad4.hpp:138
static DNDS_DEVICE_CALLABLE void Diff2(const TPoint &p, TArray &&v)
Definition Quad4.hpp:58
static DNDS_DEVICE_CALLABLE void Diff3(const TPoint &p, TArray &&v)
Definition Quad4.hpp:69
static DNDS_DEVICE_CALLABLE void Diff1(const TPoint &p, TArray &&v)
Definition Quad4.hpp:37
static DNDS_DEVICE_CALLABLE void Diff0(const TPoint &p, TArray &&v)
Definition Quad4.hpp:22
Eigen::Matrix< real, 5, 1 > v
double order
Definition test_ODE.cpp:257