MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
lblatticedescriptor.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 LBLATTICEDESCRIPTOR_H
8#define LBLATTICEDESCRIPTOR_H
9
11#include "UTIL/functions.h"
12
13// Description: This file contains arrays depending on number of space
14// dimensions D and of populations Q. All these template arrays are wrapped in
15// the struct LbLatticeDescriptorBase if only depending on D and in
16// LbLatticeDescriptor if depending and D and Q.
17// Usage: Defining a template specific typedef once in a class all arrays can be
18// easily accesed, p.e.:
19// using Ld = LbLatticeDescriptor<nDim, nDist>;
20// Ld::idFld(i, j);
21
22//--declarations of lattice descriptor------------------------------------------
23namespace lbDescriptor {
24
25//-- Dx --
27inline constexpr MInt dirFld2[3][3] = {{6, 0, 7}, {2, 8, 3}, {5, 1, 4}};
28inline constexpr MInt dirFld3[3][3][3] = {{{18, 6, 19}, {10, 0, 11}, {20, 7, 21}},
29 {{14, 2, 15}, {4, 26, 5}, {16, 3, 17}},
30 {{22, 8, 23}, {12, 1, 13}, {24, 9, 25}}};
31
33template <MInt D>
34inline constexpr MInt idFld[POWX(3, D)][D] = {};
35
37template <MInt D>
38inline constexpr MInt intNghbrArray[POWX(2, D)][POWX(2, D)] = {};
39
41template <MInt D>
42inline constexpr MFloat linearInterpolationCoefficients[POWX(2, D)][POWX(2, D)] = {};
43
45template <MInt D>
46inline constexpr MInt mFld1[24] = {};
48inline constexpr MInt mFld2[24] = {0, 2, 4, 0, 2, 5, 0, 3, 4, 0, 3, 5, 1, 2, 4, 1, 2, 5, 1, 3, 4, 1, 3, 5};
49
51template <MInt D>
52inline constexpr MInt nFld[D][POWX(3, D - 1)] = {};
54template <MInt D>
55inline constexpr MInt pFld[D][POWX(3, D - 1)] = {};
56
58template <MInt D>
59inline constexpr MInt nodalConnectivityVector[D * POWX(2, D - 1)][2] = {};
60
62template <MInt D>
63inline constexpr MInt oppositeDist[POWX(3, D)] = {};
64
66template <MInt D>
67inline constexpr MFloat ppdfDir[POWX(3, D)][D] = {};
68
69//-- DxQy --
71template <MInt D, MInt Q>
72inline constexpr MInt distFld[3] = {};
73
75template <MInt D, MInt Q>
76inline constexpr MInt distType[Q] = {};
77
79template <MInt D, MInt Q>
80inline constexpr MInt dxQyFld = {};
81
83template <MInt D, MInt Q>
84inline constexpr MFloat tp[4] = {};
85} // namespace lbDescriptor
86
87//--definitions of lattice descriptor for specific dxqy-------------------------
88namespace lbDescriptor {
89//-- D2Qx --
90template <>
91inline constexpr MInt idFld<2>[9][2] = {{0, 1}, {2, 1}, {1, 0}, {1, 2}, {2, 2}, {2, 0}, {0, 0}, {0, 2}, {1, 1}};
92template <>
93inline constexpr MInt intNghbrArray<2>[4][4] = {{dirFld2[0][0], dirFld2[1][0], dirFld2[0][1], dirFld2[1][1]}, //
94 {dirFld2[1][0], dirFld2[2][0], dirFld2[1][1], dirFld2[2][1]}, //
95 {dirFld2[0][1], dirFld2[1][1], dirFld2[0][2], dirFld2[1][2]}, //
96 {dirFld2[1][1], dirFld2[2][1], dirFld2[1][2], dirFld2[2][2]}};
97template <>
98inline constexpr MFloat linearInterpolationCoefficients<2>[4][4] = {{F1B16, F3B16, F3B16, F9B16},
99 {F3B16, F1B16, F9B16, F3B16},
100 {F3B16, F9B16, F1B16, F3B16},
101 {F9B16, F3B16, F3B16, F1B16}};
102template <>
103inline constexpr MInt mFld1<2>[24] = {1, 3, 1, 2, 0, 2, 0, 3, -1, -1, -1, -1,
104 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
105template <>
106inline constexpr MInt nFld<2>[2][3] = {{7, 6, 0}, {6, 2, 5}};
107template <>
108inline constexpr MInt pFld<2>[2][3] = {{1, 4, 5}, {7, 3, 4}};
109template <>
110inline constexpr MInt nodalConnectivityVector<2>[4][2] = {{6, 7}, // left edge
111 {4, 5}, // right edge
112 {5, 6}, // bottom edge
113 {7, 4}}; // top edge
114template <>
115inline constexpr MInt oppositeDist<2>[9] = {1, 0, 3, 2, 6, 7, 4, 5, 8};
116template <>
117inline constexpr MFloat ppdfDir<2>[9][2] = {{-1.0, 0.0}, {1.0, 0.0}, {0.0, -1.0}, {0.0, 1.0}, {1.0, 1.0},
118 {1.0, -1.0}, {-1.0, -1.0}, {-1.0, 1.0}, {0.0, 0.0}};
119
120//-- D3Qx --
121template <>
122inline constexpr MInt idFld<3>[27][3] = {{0, 1, 1}, {2, 1, 1}, // Dist. 0, 1
123 {1, 0, 1}, {1, 2, 1}, // Dist. 2, 3
124 {1, 1, 0}, {1, 1, 2}, // Dist. 4, 5
125
126
127 {0, 0, 1}, {0, 2, 1}, // Dist. 6, 7
128 {2, 0, 1}, {2, 2, 1}, // Dist. 8, 9
129
130 {0, 1, 0}, {0, 1, 2}, // Dist. 10, 11
131 {2, 1, 0}, {2, 1, 2}, // Dist. 12, 13
132
133 {1, 0, 0}, {1, 0, 2}, // Dist. 14, 15
134 {1, 2, 0}, {1, 2, 2}, // Dist. 16, 17
135
136 {0, 0, 0}, {0, 0, 2}, // Dist. 18, 19
137 {0, 2, 0}, {0, 2, 2}, // Dist. 20, 21
138 {2, 0, 0}, {2, 0, 2}, // Dist. 22, 23
139 {2, 2, 0}, {2, 2, 2}, // Dist. 24, 25
140
141 {1, 1, 1}}; // Dist. 26
142template <>
143inline constexpr MInt intNghbrArray<3>[8][8] = {
144 {dirFld3[0][0][0], dirFld3[1][0][0], dirFld3[0][1][0], dirFld3[1][1][0], dirFld3[0][0][1], dirFld3[1][0][1],
145 dirFld3[0][1][1], dirFld3[1][1][1]},
146 {dirFld3[1][0][0], dirFld3[2][0][0], dirFld3[1][1][0], dirFld3[2][1][0], dirFld3[1][0][1], dirFld3[2][0][1],
147 dirFld3[1][1][1], dirFld3[2][1][1]},
148 {dirFld3[0][1][0], dirFld3[1][1][0], dirFld3[0][2][0], dirFld3[1][2][0], dirFld3[0][1][1], dirFld3[1][1][1],
149 dirFld3[0][2][1], dirFld3[1][2][1]},
150 {dirFld3[1][1][0], dirFld3[2][1][0], dirFld3[1][2][0], dirFld3[2][2][0], dirFld3[1][1][1], dirFld3[2][1][1],
151 dirFld3[1][2][1], dirFld3[2][2][1]},
152 {dirFld3[0][0][1], dirFld3[1][0][1], dirFld3[0][1][1], dirFld3[1][1][1], dirFld3[0][0][2], dirFld3[1][0][2],
153 dirFld3[0][1][2], dirFld3[1][1][2]},
154 {dirFld3[1][0][1], dirFld3[2][0][1], dirFld3[1][1][1], dirFld3[2][1][1], dirFld3[1][0][2], dirFld3[2][0][2],
155 dirFld3[1][1][2], dirFld3[2][1][2]},
156 {dirFld3[0][1][1], dirFld3[1][1][1], dirFld3[0][2][1], dirFld3[1][2][1], dirFld3[0][1][2], dirFld3[1][1][2],
157 dirFld3[0][2][2], dirFld3[1][2][2]},
158 {dirFld3[1][1][1], dirFld3[2][1][1], dirFld3[1][2][1], dirFld3[2][2][1], dirFld3[1][1][2], dirFld3[2][1][2],
159 dirFld3[1][2][2], dirFld3[2][2][2]}};
160template <>
162 {F1B64, F3B64, F3B64, F9B64, F3B64, F9B64, F9B64, F27B64},
163 {F3B64, F1B64, F9B64, F3B64, F9B64, F3B64, F27B64, F9B64},
164 {F3B64, F9B64, F1B64, F3B64, F9B64, F27B64, F3B64, F9B64},
165 {F9B64, F3B64, F3B64, F1B64, F27B64, F9B64, F9B64, F3B64},
166 {F3B64, F9B64, F9B64, F27B64, F1B64, F3B64, F3B64, F9B64},
167 {F9B64, F3B64, F27B64, F9B64, F3B64, F1B64, F9B64, F3B64},
168 {F9B64, F27B64, F3B64, F9B64, F3B64, F9B64, F1B64, F3B64},
169 {F27B64, F9B64, F9B64, F3B64, F9B64, F3B64, F3B64, F1B64}};
170template <>
171inline constexpr MInt mFld1<3>[24] = {0, 2, 0, 3, 1, 2, 1, 3, 0, 4, 0, 5, 1, 4, 1, 5, 2, 4, 2, 5, 3, 4, 3, 5};
172template <>
173inline constexpr MInt nFld<3>[3][9] = {
174 {0, 6, 7, 10, 11, 18, 19, 20, 21}, {2, 6, 8, 14, 15, 18, 19, 22, 23}, {4, 10, 12, 14, 16, 18, 20, 22, 24}};
175template <>
176inline constexpr MInt pFld<3>[3][9] = {
177 {1, 8, 9, 12, 13, 22, 23, 24, 25}, {3, 7, 9, 16, 17, 20, 21, 24, 25}, {5, 11, 13, 15, 17, 19, 21, 23, 25}};
178template <>
179inline constexpr MInt nodalConnectivityVector<3>[12][2] = {{18, 19}, // edge of Dist. 6
180 {20, 21}, // edge of Dist. 7
181 {22, 23}, // edge of Dist. 8
182 {24, 25}, // edge of Dist. 9
183 {18, 20}, // edge of Dist. 10
184 {19, 21}, // edge of Dist. 11
185 {22, 24}, // edge of Dist. 12
186 {23, 25}, // edge of Dist. 13
187 {18, 22}, // edge of Dist. 14
188 {19, 23}, // edge of Dist. 15
189 {20, 24}, // edge of Dist. 16
190 {21, 25}}; // edge of Dist. 17
191
192template <>
193inline constexpr MInt oppositeDist<3>[27] = {1, 0, 3, 2, 5, 4, 9, 8, 7, 6, 13, 12, 11, 10,
194 17, 16, 15, 14, 25, 24, 23, 22, 21, 20, 19, 18, 26};
195template <>
196inline constexpr MFloat ppdfDir<3>[27][3] = {
197 {-1.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {0.0, -1.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, -1.0}, {0.0, 0.0, 1.0},
198 {-1.0, -1.0, 0.0}, {-1.0, 1.0, 0.0}, {1.0, -1.0, 0.0}, {1.0, 1.0, 0.0}, {-1.0, 0.0, -1.0}, {-1.0, 0.0, 1.0},
199 {1.0, 0.0, -1.0}, {1.0, 0.0, 1.0}, {0.0, -1.0, -1.0}, {0.0, -1.0, 1.0}, {0.0, 1.0, -1.0}, {0.0, 1.0, 1.0},
200 {-1.0, -1.0, -1.0}, {-1.0, -1.0, 1.0}, {-1.0, 1.0, -1.0}, {-1.0, 1.0, 1.0}, {1.0, -1.0, -1.0}, {1.0, -1.0, 1.0},
201 {1.0, 1.0, -1.0}, {1.0, 1.0, 1.0}, {0.0, 0.0, 0.0}};
202
203//-- D2Q9 --
204template <>
205inline constexpr MInt distFld<2, 9>[3] = {4, 4, 0};
206template <>
207inline constexpr MInt dxQyFld<2, 9> = 3;
208template <>
209inline constexpr MFloat tp<2, 9>[4] = {F4B9, F1B9, F1B36, 0};
210
211//-- D3Q15 --
212template <>
213inline constexpr MInt distFld<3, 15>[3] = {6, 8, 0};
214template <>
215inline constexpr MInt dxQyFld<3, 15> = 5;
216template <>
217inline constexpr MFloat tp<3, 15>[4] = {F2B9, F1B9, F1B72, 0};
218
219//-- D3Q19 --
220template <>
221inline constexpr MInt distFld<3, 19>[3] = {6, 12, 0};
222template <>
223inline constexpr MInt dxQyFld<3, 19> = 5;
224template <>
225inline constexpr MFloat tp<3, 19>[4] = {F1B3, F1B18, F1B36, 0};
226
227//-- D3Q27 --
228template <>
229inline constexpr MInt distFld<3, 27>[3] = {6, 12, 8};
230template <>
231inline constexpr MInt dxQyFld<3, 27> = 9;
232template <>
233inline constexpr MFloat tp<3, 27>[4] = {F8B27, F2B27, F1B54, F1B216};
234
235} // namespace lbDescriptor
236
237
238//--wrapper struct for lattice descriptor---------------------------------------
245template <MInt D>
248
249 static constexpr MInt dirFld(MInt i, MInt j, MInt k) {
250 if(D == 2) {
251 return lbDescriptor::dirFld2[i][j];
252 } // else if(D == 3) {
253 return lbDescriptor::dirFld3[i][j][k];
254 }
255
257 static constexpr MInt distType(MInt i) {
258 MInt sum = 0;
259 for(MInt k = 0; k < D; k++) {
260 sum += std::abs(idFld(i, k) - 1);
261 }
262 return sum;
263 }
264 static constexpr MInt idFld(MInt i, MInt j) { return lbDescriptor::idFld<D>[i][j]; }
265 static constexpr MInt intNghbrArray(MInt i, MInt j) { return lbDescriptor::intNghbrArray<D>[i][j]; }
267 return lbDescriptor::linearInterpolationCoefficients<D>[i][j];
268 }
269 static constexpr MInt mFld1(MInt i) { return lbDescriptor::mFld1<D>[i]; }
270 static constexpr MInt mFld2(MInt i) { return lbDescriptor::mFld2[i]; }
271
272 static constexpr MInt nFld(MInt i, MInt j) { return lbDescriptor::nFld<D>[i][j]; }
273 static constexpr MInt pFld(MInt i, MInt j) { return lbDescriptor::pFld<D>[i][j]; }
274 static constexpr MInt componentFld(MInt i, MInt j) {
275 if(i % 2 == 0) {
276 return nFld(i / 2, j);
277 } else {
278 return pFld(i / 2, j);
279 }
280 }
281
282 static constexpr MInt nodalConnectivityVector(MInt i, MInt j) {
283 return lbDescriptor::nodalConnectivityVector<D>[i][j];
284 }
285 static constexpr MInt oppositeDist(MInt i) { return lbDescriptor::oppositeDist<D>[i]; }
286 static constexpr MFloat ppdfDir(MInt i, MInt j) { return lbDescriptor::ppdfDir<D>[i][j]; }
287 static constexpr const MFloat* ppdfDir(MInt i) { return lbDescriptor::ppdfDir<D>[i]; }
288};
289
296template <MInt D, MInt Q>
299
300 static constexpr MInt lastId() { return Q - 1; }
301 static constexpr MInt d() { return D; }
302 static constexpr MInt q() { return Q; }
303
304 static constexpr MInt distFld(MInt i) { return lbDescriptor::distFld<D, Q>[i]; }
305 static constexpr MInt dxQyFld() { return lbDescriptor::dxQyFld<D, Q>; }
306 static constexpr MFloat tp(MInt i) { return lbDescriptor::tp<D, Q>[i]; }
307};
308
309#endif
T constexpr POWX(T base, MUint exponent)
Compile time power calculation.
Definition: functions.h:146
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
constexpr MInt nodalConnectivityVector< 3 >[12][2]
constexpr MInt idFld[POWX(3, D)][D]
Basic movements for the distributions , 0=backwards, 1=stop, 2=forwards.
constexpr MInt dxQyFld
Number of distributions which have one space direction in common.
constexpr MInt intNghbrArray< 2 >[4][4]
constexpr MFloat tp[4]
taylor-polynom coefficients for equilibrium calculation (0:rest, 1:face, 2:edge, 3:corner)
constexpr MInt dirFld2[3][3]
Convert directions into distribution id.
constexpr MFloat linearInterpolationCoefficients[POWX(2, D)][POWX(2, D)]
Linear interpolation coefficients.
constexpr MInt mFld1< 2 >[24]
constexpr MFloat linearInterpolationCoefficients< 2 >[4][4]
constexpr MInt mFld1< 3 >[24]
constexpr MInt idFld< 2 >[9][2]
constexpr MFloat ppdfDir< 2 >[9][2]
constexpr MFloat ppdfDir< 3 >[27][3]
constexpr MInt mFld2[24]
Ids for the calculation of the second term of the maxwellian.
constexpr MFloat tp< 3, 15 >[4]
constexpr MInt distFld< 2, 9 >[3]
constexpr MInt nFld< 3 >[3][9]
constexpr MInt nFld< 2 >[2][3]
constexpr MInt dxQyFld< 3, 27 >
constexpr MInt distFld< 3, 19 >[3]
constexpr MInt nodalConnectivityVector[D *POWX(2, D - 1)][2]
Distribution ids required to form a vector for nodal connectivity.
constexpr MInt intNghbrArray[POWX(2, D)][POWX(2, D)]
Directions of the interpolation neighbors [positionChild][positionIntepolationParent].
constexpr MInt oppositeDist[POWX(3, D)]
Opposite distribution.
constexpr MInt distFld< 3, 27 >[3]
constexpr MInt dxQyFld< 3, 19 >
constexpr MFloat tp< 3, 27 >[4]
constexpr MInt nodalConnectivityVector< 2 >[4][2]
constexpr MInt oppositeDist< 2 >[9]
constexpr MFloat ppdfDir[POWX(3, D)][D]
Direction of motion of each PPDF, needed for bounce-back schemes.
constexpr MFloat linearInterpolationCoefficients< 3 >[8][8]
constexpr MInt pFld< 3 >[3][9]
constexpr MInt distFld[3]
Number of distributions - (1d,2d,3d)
constexpr MInt dirFld3[3][3][3]
constexpr MInt distFld< 3, 15 >[3]
constexpr MInt pFld[D][POWX(3, D - 1)]
Distributions with components in positive axis direction [axis][distribution].
constexpr MInt mFld1[24]
Ids for the calculation of the first term of the maxwellian.
constexpr MInt distType[Q]
constexpr MInt intNghbrArray< 3 >[8][8]
constexpr MInt pFld< 2 >[2][3]
constexpr MInt nFld[D][POWX(3, D - 1)]
Distributions with components in negative axis direction [axis][distribution].
constexpr MInt dxQyFld< 2, 9 >
constexpr MInt dxQyFld< 3, 15 >
constexpr MInt idFld< 3 >[27][3]
constexpr MFloat tp< 2, 9 >[4]
constexpr MInt oppositeDist< 3 >[27]
constexpr MFloat tp< 3, 19 >[4]
LB lattice descriptor for arrays depending on D.
static constexpr MInt idFld(MInt i, MInt j)
static constexpr MInt componentFld(MInt i, MInt j)
static constexpr MInt nodalConnectivityVector(MInt i, MInt j)
static constexpr MFloat ppdfDir(MInt i, MInt j)
static constexpr MInt mFld1(MInt i)
static constexpr MInt oppositeDist(MInt i)
static constexpr MInt pFld(MInt i, MInt j)
static constexpr MInt mFld2(MInt i)
static constexpr const MFloat * ppdfDir(MInt i)
static constexpr MInt distType(MInt i)
Type of the distribution (0:rest, 1:face, 2:edge, 3:corner)
static constexpr MInt nFld(MInt i, MInt j)
static constexpr MInt intNghbrArray(MInt i, MInt j)
static constexpr MFloat linearInterpolationCoefficients(MInt i, MInt j)
static constexpr MInt dirFld(MInt i, MInt j, MInt k)
LbLatticeDescriptorBase()=delete
LB lattice descriptor for arrays depending on D and Q.
static constexpr MFloat tp(MInt i)
static constexpr MInt distFld(MInt i)
static constexpr MInt lastId()
LbLatticeDescriptor()=delete
static constexpr MInt dxQyFld()
static constexpr MInt q()
static constexpr MInt d()