MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fcdescriptor.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef FCDESCRIPTOR_H
8#define FCDESCRIPTOR_H
9
11#include "UTIL/functions.h"
12#include "UTIL/maiamath.h"
13
14// Description: This file contains arrays depending on number of space
15// dimensions D. All these template arrays are wrapped in
16// the struct FcDescriptor.
17// Usage: Defining a template specific typedef once in a class all arrays
18// can be easily accesed, p.e.:
19// using Fd = fcDescriptor<nDim>;
20
21//--declarations of lattice descriptor------------------------------------------
22namespace fcDescriptor {
23
24// Holds the lobatto points for the first 4 poly degrees
25// The array is filled with -1
26inline constexpr MFloat lobattoPoints[4][3] = {
27 {-F1, -F1, -F1}, {F0, -F1, -F1}, {-F1 / SQRT5, F1 / SQRT5, -F1}, {-SQRT3 / SQRT7, F0, SQRT3 / SQRT7}};
28
29// Holds the position of the neighboring cells in the neighbor list that share
30// vertex number v of the current cell with the current cell
31template <MInt D>
32inline constexpr MInt vertexNghbrs[IPOW2(D)][IPOW2(D) - 1] = {};
33
34// Holds the position of the neighboring cells in the neighbor list that share
35// edge number e of the current cell with the current cell
36inline constexpr MInt edgeNghbrs3d[12][3] = {{0, 2, 6}, {0, 4, 10}, {0, 5, 11}, {0, 3, 7}, {2, 4, 14}, {2, 5, 15},
37 {3, 4, 16}, {3, 5, 17}, {1, 2, 8}, {1, 4, 12}, {1, 5, 13}, {1, 3, 9}};
38
39// Holds the position of the neighboring cell in the neighbor list that shares
40// surface number s of the current cell with the current cell
41template <MInt D>
42inline constexpr MInt surfaceNghbrs[D * 2] = {};
43
44// Holds the directions in which the vertices are located for a cell
45// The order is based on the order of the legendre points in the cell
46template <MInt D>
47inline constexpr MFloat vertexPos[IPOW2(D)][D] = {};
48
49// Holds the directions in which the edges are located for a 3D cell
50// The order is based on the order of the legendre points in the cell
51// Edges of surface 0: (-x,-y) -> (-x,-z) -> (-x,+z) -> (-x,-y)
52// Edges of surface 1: (-y,-z) -> (-x,+z)
53// Edges of surface 4: (+y,-z) -> (+y,+z)
54// Edges of surface 5: (+x,-y) -> (+x,-z) -> (+x,+z) -> (+x,+y)
55inline constexpr MFloat edgePos3d[12][3] = {{-F1, -F1, F0}, {-F1, F0, -F1}, {-F1, F0, F1}, {-F1, F1, F0},
56 {F0, -F1, -F1}, {F0, -F1, F1}, {F0, F1, -F1}, {F0, F1, F1},
57 {F1, -F1, F0}, {F1, F0, -F1}, {F1, F0, F1}, {F1, F1, F0}};
58
59template <MInt D>
60inline constexpr MFloat surfacePos[D * 2][D] = {};
61
62template <MInt D>
63inline constexpr MInt oppositeVertex[IPOW2(D)][IPOW2(D) - 1] = {};
64
65// Holds the opposite edges for each edge of a 3D cell for each neighboring cell.
66// Works as the oppositeVertex3d array
67inline constexpr MInt oppositeEdge3d[12][3] = {{8, 3, 11}, {9, 2, 10}, {10, 1, 9}, {11, 0, 8}, {6, 5, 7}, {7, 4, 6},
68 {4, 7, 5}, {5, 6, 4}, {0, 11, 3}, {1, 10, 2}, {2, 9, 1}, {3, 8, 0}};
69
70template <MInt D>
71inline constexpr MInt oppositeSurface[2 * D] = {};
72} // namespace fcDescriptor
73
74//--definitions of descriptor for specific d ------------------------
75namespace fcDescriptor {
76
77// Holds the position of the neighboring cells in the neighbor list that share
78// vertex number v of the current cell with the current cell
79template <>
80inline constexpr MInt vertexNghbrs<2>[4][3] = {{0, 2, 6}, {0, 3, 7}, {1, 2, 5}, {1, 3, 4}};
81
82// Holds the position of the neighboring cells in the neighbor list that share
83// vertex number v of the current cell with the current cell
84template <>
85inline constexpr MInt vertexNghbrs<3>[8][7] = {
86 {0, 2, 4, 6, 10, 14, 18}, {0, 2, 5, 6, 11, 15, 19}, {0, 3, 4, 7, 10, 16, 20}, {0, 3, 5, 7, 11, 17, 21},
87 {1, 2, 4, 8, 12, 14, 22}, {1, 2, 5, 8, 13, 15, 23}, {1, 3, 4, 9, 12, 16, 24}, {1, 3, 5, 9, 13, 17, 25}};
88
89// Holds the position of the neighboring cell in the neighbor list that shares
90// surface number s of the current cell with the current cell
91template <>
92inline constexpr MInt surfaceNghbrs<2>[4] = {0, 2, 3, 1};
93
94// Holds the position of the neighboring cell in the neighbor list that shares
95// surface number s of the current cell with the current cell
96template <>
97inline constexpr MInt surfaceNghbrs<3>[6] = {0, 2, 4, 5, 3, 1};
98
99// Holds the directions in which the vertices are located for a 2D cell
100// The order is based on the order of the legendre points in the cell
101template <>
102inline constexpr MFloat vertexPos<2>[4][2] = {{-F1, -F1}, {-F1, F1}, {F1, -F1}, {F1, F1}};
103
104template <>
105// Holds the directions in which the vertices are located for a 3D cell
106// The order is based on the order of the legendre points in the cell
107inline constexpr MFloat vertexPos<3>[8][3] = {{-F1, -F1, -F1}, {-F1, -F1, F1}, {-F1, F1, -F1}, {-F1, F1, F1},
108 {F1, -F1, -F1}, {F1, -F1, F1}, {F1, F1, -F1}, {F1, F1, F1}};
109
110// Holds the directions in which the edges are located for a 2D cell
111// __2__
112// | |
113// 0| |3
114// |__ __|
115// 1
116template <>
117inline constexpr MFloat surfacePos<2>[4][2] = {{-F1, F0}, {F0, -F1}, {F0, F1}, {F1, F0}};
118
119// Holds the direction in which the surfaces are located for a 3D cell
120// The order is based on the order of the legendre points in the cell
121// -x -> -y -> -z -> +z -> +y -> +x
122template <>
123inline constexpr MFloat surfacePos<3>[6][3] = {{-F1, F0, F0}, {F0, -F1, F0}, {F0, F0, -F1},
124 {F0, F0, F1}, {F0, F1, F0}, {F1, F0, F0}};
125
126// Holds the opposite vertices for each vertex of a 3D cell for each neighboring cell.
127// Based on vertexPos3d and vertexNghbrs3d
128// For example, vertex 0 of cell a is shared with 7 other cells. Their location is
129// given in the arry vertexNghbrs3d. In the neighbors vertex order the corresponding
130// vertex has the number as given in this array
131//->For vertex 0 in cell A the 3. neighbor is located at position 4 of the neighbor list
132// the corresponding vertex position is 1
133template <>
134inline constexpr MInt oppositeVertex<3>[8][7] = {{4, 2, 1, 6, 5, 3, 7}, {5, 3, 0, 7, 4, 2, 6}, {6, 0, 3, 4, 7, 1, 5},
135 {7, 1, 2, 5, 6, 0, 4}, {0, 6, 5, 2, 1, 7, 3}, {1, 7, 4, 3, 0, 6, 2},
136 {2, 4, 7, 0, 3, 5, 1}, {3, 5, 6, 1, 2, 4, 0}};
137
138// Holds the opposite vertices for each vertex of a 2D cell for each neighboring cell.
139// Based on vertexPos2d and vertexNghbrs2d
140// For example, vertex 0 of cell a is shared with 3 other cells. Their location is
141// given in the arry vertexNghbrs2d. In the neighbors vertex order the corresponding
142// vertex has the number as given in this array
143//->For vertex 0 in cell A the 3. neighbor is located at position 6 of the neighbor list
144// the corresponding vertex position is 1
145template <>
146inline constexpr MInt oppositeVertex<2>[4][3] = {{2, 1, 3}, {3, 0, 2}, {0, 3, 1}, {1, 2, 0}};
147
148// Holds the opposite edge for each edge of a 2D cell for each neighboring cell.
149// Works as the oppositeVertex2d array
150template <>
151inline constexpr MInt oppositeSurface<2>[4] = {3, 2, 1, 0};
152
153// Holds the opposite surface for each edge of a 3D cell for each neighboring cell.
154// Works as the oppositeVertex3d array
155template <>
156inline constexpr MInt oppositeSurface<3>[6] = {5, 4, 3, 2, 1, 0};
157
158} // namespace fcDescriptor
159
160//--wrapper struct for lattice descriptor---------------------------------------
167template <MInt D>
169 FcDescriptor() = delete;
170
171 static constexpr MFloat legendreFunction(const MInt order, const MFloat pos) {
172 MFloat p = pos;
173 MFloat p_deriv = F1;
174 maia::math::calculateLegendrePolyAndDeriv(order, pos, &p, &p_deriv);
175 return p;
176 }
177
178 static constexpr MFloat legendreDerivFunction(const MInt order, const MFloat pos) {
179 MFloat p = pos;
180 MFloat p_deriv = F1;
181 maia::math::calculateLegendrePolyAndDeriv(order, pos, &p, &p_deriv);
182 return p_deriv;
183 }
184
185 static constexpr void gaussPoint(const MInt order, MFloat* nodes, MFloat* weights) {
187 }
188
189 static constexpr void nodePosition(const MInt node, const MInt nodesPerDir, MInt* nodePos) {
190 MInt remainNoNodes = node;
191 for(MInt d = D - 1; d >= 0; d--) {
192 nodePos[d] = remainNoNodes % nodesPerDir;
193 remainNoNodes = remainNoNodes / nodesPerDir;
194 }
195 }
196
197 static constexpr MFloat nodePosEquidist(const MInt order, const MInt node) {
198 const MFloat p = (MFloat)order;
199 const MFloat base = F2 / (p + F1);
200 const MFloat exp = (MFloat)node;
201
202 MFloat nodePos = -F1 + exp * base;
203 return nodePos;
204 }
205
206 static constexpr MFloat nodePosLobattoPoints(MInt i, MInt j) { return fcDescriptor::lobattoPoints[i][j]; }
207
208 static constexpr MInt nghbrCellOfVertex(MInt i, MInt j) { return fcDescriptor::vertexNghbrs<D>[i][j]; }
209
210 static constexpr MInt nghbrCellOfEdge(MInt i, MInt j) { return fcDescriptor::edgeNghbrs3d[i][j]; }
211
212 static constexpr MInt nghbrCellOfSurface(MInt i) { return fcDescriptor::surfaceNghbrs<D>[i]; }
213
214 static constexpr MFloat vertexPosition(MInt i, MInt j) { return fcDescriptor::vertexPos<D>[i][j]; }
215
216 static constexpr MFloat edgePosition(MInt i, MInt j) { return fcDescriptor::edgePos3d[i][j]; }
217
218 static constexpr MFloat surfacePosition(MInt i, MInt j) { return fcDescriptor::surfacePos<D>[i][j]; }
219
220 static constexpr MInt vertexIdOfOppCell(MInt i, MInt j) { return fcDescriptor::oppositeVertex<D>[i][j]; }
221
222 static constexpr MInt edgeIdOfOppCell(MInt i, MInt j) { return fcDescriptor::oppositeEdge3d[i][j]; }
223
224 static constexpr MInt surfaceIdOfOppCell(MInt i) { return fcDescriptor::oppositeSurface<D>[i]; }
225};
226
227#endif
constexpr MLong IPOW2(MInt x)
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
constexpr MInt oppositeEdge3d[12][3]
Definition: fcdescriptor.h:67
constexpr MFloat lobattoPoints[4][3]
Definition: fcdescriptor.h:26
constexpr MInt vertexNghbrs< 2 >[4][3]
Definition: fcdescriptor.h:80
constexpr MInt surfaceNghbrs< 3 >[6]
Definition: fcdescriptor.h:97
constexpr MInt surfaceNghbrs[D *2]
Definition: fcdescriptor.h:42
constexpr MFloat edgePos3d[12][3]
Definition: fcdescriptor.h:55
constexpr MInt oppositeSurface< 2 >[4]
Definition: fcdescriptor.h:151
constexpr MFloat vertexPos[IPOW2(D)][D]
Definition: fcdescriptor.h:47
constexpr MInt oppositeSurface[2 *D]
Definition: fcdescriptor.h:71
constexpr MInt oppositeVertex< 2 >[4][3]
Definition: fcdescriptor.h:146
constexpr MInt vertexNghbrs< 3 >[8][7]
Definition: fcdescriptor.h:85
constexpr MInt vertexNghbrs[IPOW2(D)][IPOW2(D) - 1]
Definition: fcdescriptor.h:32
constexpr MFloat surfacePos[D *2][D]
Definition: fcdescriptor.h:60
constexpr MInt surfaceNghbrs< 2 >[4]
Definition: fcdescriptor.h:92
constexpr MInt oppositeVertex[IPOW2(D)][IPOW2(D) - 1]
Definition: fcdescriptor.h:63
constexpr MFloat surfacePos< 3 >[6][3]
Definition: fcdescriptor.h:123
constexpr MInt edgeNghbrs3d[12][3]
Definition: fcdescriptor.h:36
constexpr MInt oppositeVertex< 3 >[8][7]
Definition: fcdescriptor.h:134
constexpr MFloat surfacePos< 2 >[4][2]
Definition: fcdescriptor.h:117
constexpr MInt oppositeSurface< 3 >[6]
Definition: fcdescriptor.h:156
constexpr MFloat vertexPos< 2 >[4][2]
Definition: fcdescriptor.h:102
constexpr MFloat vertexPos< 3 >[8][3]
Definition: fcdescriptor.h:107
void calculateLegendrePolyAndDeriv(MInt Nmax, MFloat x, MFloat *polynomial, MFloat *derivative)
Evaluates the Legendre polynomial and its derivative of degree Nmax at point x.
Definition: maiamath.h:754
void calculateLegendreGaussNodesAndWeights(MInt Nmax, MFloat *nodes, MFloat *wInt)
Calculate the Gauss integration nodes and weight for the Legendre polynomials on the interval [-1,...
Definition: maiamath.h:806
LB lattice descriptor for arrays depending on D.
Definition: fcdescriptor.h:168
static constexpr MInt edgeIdOfOppCell(MInt i, MInt j)
Definition: fcdescriptor.h:222
FcDescriptor()=delete
static constexpr void gaussPoint(const MInt order, MFloat *nodes, MFloat *weights)
Definition: fcdescriptor.h:185
static constexpr MFloat vertexPosition(MInt i, MInt j)
Definition: fcdescriptor.h:214
static constexpr MFloat nodePosEquidist(const MInt order, const MInt node)
Definition: fcdescriptor.h:197
static constexpr MInt nghbrCellOfSurface(MInt i)
Definition: fcdescriptor.h:212
static constexpr void nodePosition(const MInt node, const MInt nodesPerDir, MInt *nodePos)
Definition: fcdescriptor.h:189
static constexpr MInt vertexIdOfOppCell(MInt i, MInt j)
Definition: fcdescriptor.h:220
static constexpr MFloat edgePosition(MInt i, MInt j)
Definition: fcdescriptor.h:216
static constexpr MFloat nodePosLobattoPoints(MInt i, MInt j)
Definition: fcdescriptor.h:206
static constexpr MFloat legendreFunction(const MInt order, const MFloat pos)
Definition: fcdescriptor.h:171
static constexpr MFloat legendreDerivFunction(const MInt order, const MFloat pos)
Definition: fcdescriptor.h:178
static constexpr MInt surfaceIdOfOppCell(MInt i)
Definition: fcdescriptor.h:224
static constexpr MInt nghbrCellOfEdge(MInt i, MInt j)
Definition: fcdescriptor.h:210
static constexpr MFloat surfacePosition(MInt i, MInt j)
Definition: fcdescriptor.h:218
static constexpr MInt nghbrCellOfVertex(MInt i, MInt j)
Definition: fcdescriptor.h:208