DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
ElementTraitsBase.hpp
Go to the documentation of this file.
1#pragma once
2// ElementTraitsBase.hpp -- Shared type definitions for element traits
3//
4// This header provides the common type aliases used by ElementTraits
5// specializations. It is included by both ElementTraits.hpp and the
6// individual element trait files in Elements/.
7
8#include <array>
9#include <cstdint>
10#include "DNDS/Defines.hpp"
11#include "Geometric.hpp"
12#include "ElemEnum.hpp"
13
14namespace DNDS::Geom::Elem
15{
16
17 // ----------------------------------------------------------------
18 // ElementTraits<ElemType t> -- primary template (unspecialized = error)
19 // Must be specialized for each valid ElemType in Elements/*.hpp files
20 // ----------------------------------------------------------------
21 template <ElemType t>
22 struct ElementTraits; // Intentionally undefined - forces specialization
23
24 // ----------------------------------------------------------------
25 // Macro to reduce boilerplate in each specialization
26 // ----------------------------------------------------------------
27 /**
28 * @brief Common element trait definitions
29 * @param ETYPE Element type enum value (e.g., Line2, Tri3)
30 * @param DIM_ Spatial dimension (1, 2, or 3)
31 * @param ORDER_ Polynomial order of shape functions
32 * @param NV_ Number of vertices (corner nodes)
33 * @param NN_ Total number of nodes (including edge/face/internal)
34 * @param NF_ Number of faces
35 * @param PSPACE_ Parametric space type (LineSpace, TriSpace, etc.)
36 * @param PSVOL_ Volume of parametric space (length, area, or volume)
37 */
38 #define DNDS_ELEMENT_TRAITS_COMMON(ETYPE, DIM_, ORDER_, NV_, NN_, NF_, PSPACE_, PSVOL_) \
39 static constexpr ElemType elemType = ETYPE; \
40 static constexpr int dim = DIM_; \
41 static constexpr int order = ORDER_; \
42 static constexpr int numVertices = NV_; \
43 static constexpr int numNodes = NN_; \
44 static constexpr int numFaces = NF_; \
45 static constexpr ParamSpace paramSpace = PSPACE_; \
46 static constexpr t_real paramSpaceVol = PSVOL_;
47
48 // ----------------------------------------------------------------
49 // Type Aliases for Element Trait Arrays
50 // ----------------------------------------------------------------
51
52 /**
53 * @brief Maximum width of elevation span (Hex8 body center uses 8 nodes)
54 *
55 * Elevation spans define which parent nodes are connected to create
56 * new nodes during p-refinement (order elevation). For example:
57 * - Edge midpoint: span of 2 nodes
58 * - Quad face center: span of 4 nodes
59 * - Hex body center: span of 8 nodes
60 */
61 static constexpr int elevSpanMaxWidth = 8;
62
63 /**
64 * @brief Elevation span type: array of parent node indices
65 *
66 * Used to define which existing nodes define the position of a new
67 * node created during element order elevation.
68 */
69 using tElevSpan = std::array<t_index, elevSpanMaxWidth>;
70
71 /**
72 * @brief Maximum nodes in a bisection sub-element (Hex8 = 8 nodes)
73 *
74 * Bisection (h-refinement) splits an element into smaller sub-elements.
75 * This defines the maximum nodes any sub-element can have.
76 */
77 static constexpr int bisectSubMaxNodes = 8;
78
79 /**
80 * @brief Bisection sub-element node array type
81 *
82 * Maps local node indices of a sub-element to parent element nodes.
83 * Used in adaptive mesh refinement to define child element connectivity.
84 */
85 using tBisectSub = std::array<t_index, bisectSubMaxNodes>;
86
87 /**
88 * @brief Maximum VTK nodes (Hex27 = 27 nodes)
89 *
90 * VTK uses different node ordering than internal DNDS representation
91 * for higher-order elements. This defines the maximum array size needed.
92 */
93 static constexpr int vtkNodeOrderMax = 27;
94
95 /**
96 * @brief VTK node ordering permutation array type
97 *
98 * Maps DNDS node indices to VTK node indices:
99 * vtkNodeOrder[i] = VTK index of DNDS node i
100 *
101 * Only first numNodes entries are valid; rest are padding.
102 */
103 using tVTKNodeOrder = std::array<int, vtkNodeOrderMax>;
104
105} // namespace DNDS::Geom::Elem
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
std::array< t_index, elevSpanMaxWidth > tElevSpan
Elevation span type: array of parent node indices.
std::array< int, vtkNodeOrderMax > tVTKNodeOrder
VTK node ordering permutation array type.
std::array< t_index, bisectSubMaxNodes > tBisectSub
Bisection sub-element node array type.