1 // --------------------------------------------------------------------------
4 // Markus Wittmann, 2016-2017
5 // RRZE, University of Erlangen-Nuremberg, Germany
6 // markus.wittmann -at- fau.de or hpc -at- rrze.fau.de
9 // LSS, University of Erlangen-Nuremberg, Germany
11 // Michael Hussnaetter, 2017-2018
12 // University of Erlangen-Nuremberg, Germany
13 // michael.hussnaetter -at- fau.de
15 // This file is part of the Lattice Boltzmann Benchmark Kernels (LbmBenchKernels).
17 // LbmBenchKernels is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
22 // LbmBenchKernels is distributed in the hope that it will be useful,
23 // but WITHOUT ANY WARRANTY; without even the implied warranty of
24 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 // GNU General Public License for more details.
27 // You should have received a copy of the GNU General Public License
28 // along with LbmBenchKernels. If not, see <http://www.gnu.org/licenses/>.
30 // --------------------------------------------------------------------------
37 #ifdef DATA_LAYOUT_NAME
38 #error DATA_LAYOUT_NAME must not be defined here.
41 #ifdef PROP_MODEL_NAME
42 #error PROP_MODEL_NAME must not be defined here.
46 #ifdef DATA_LAYOUT_SOA
47 #define DATA_LAYOUT_NAME SoA
50 #ifdef DATA_LAYOUT_AOS
51 #define DATA_LAYOUT_NAME AoS
54 #ifdef DATA_LAYOUT_AOSOA
55 #define DATA_LAYOUT_NAME AoSoA
56 // number of cells consecutively stored (-> array length)
57 #define AOSOA_BLOCK_SIZE 8
60 #ifdef PROP_MODEL_PUSH
61 #define PROP_MODEL_NAME Push
64 #ifdef PROP_MODEL_PULL
65 #define PROP_MODEL_NAME Pull
69 #define PROP_MODEL_NAME Aa
75 #elif defined(PRECISION_SP)
78 #error PRECISION must be defined as dp or sp.
81 #define F(number) (PdfT)(number)
111 #define D3Q19_C 18 // IMPORTANT: Center particle must be the last one.
116 #error X is not allowed to be defined here!
119 // The following list must be sorted ascending according
120 // to the index of the direction, i.e. D3Q19_N, D3Q19_S, ...
122 X(N, D3Q19_N, D3Q19_S, 0, 1, 0) \
123 X(S, D3Q19_S, D3Q19_N, 0, -1, 0) \
124 X(E, D3Q19_E, D3Q19_W, 1, 0, 0) \
125 X(W, D3Q19_W, D3Q19_E, -1, 0, 0) \
126 X(NE, D3Q19_NE, D3Q19_SW, 1, 1, 0) \
127 X(SE, D3Q19_SE, D3Q19_NW, 1, -1, 0) \
128 X(NW, D3Q19_NW, D3Q19_SE, -1, 1, 0) \
129 X(SW, D3Q19_SW, D3Q19_NE, -1, -1, 0) \
130 X(T, D3Q19_T, D3Q19_B, 0, 0, 1) \
131 X(TN, D3Q19_TN, D3Q19_BS, 0, 1, 1) \
132 X(TE, D3Q19_TE, D3Q19_BW, 1, 0, 1) \
133 X(TW, D3Q19_TW, D3Q19_BE, -1, 0, 1) \
134 X(TS, D3Q19_TS, D3Q19_BN, 0, -1, 1) \
135 X(B, D3Q19_B, D3Q19_T, 0, 0, -1) \
136 X(BS, D3Q19_BS, D3Q19_TN, 0, -1, -1) \
137 X(BN, D3Q19_BN, D3Q19_TS, 0, 1, -1) \
138 X(BW, D3Q19_BW, D3Q19_TE, -1, 0, -1) \
139 X(BE, D3Q19_BE, D3Q19_TW, 1, 0, -1) \
140 X(C, D3Q19_C, D3Q19_C, 0, 0, 0)
142 #define D3Q19_LIST_WO_C \
143 X(N, D3Q19_N, D3Q19_S, 0, 1, 0) \
144 X(S, D3Q19_S, D3Q19_N, 0, -1, 0) \
145 X(E, D3Q19_E, D3Q19_W, 1, 0, 0) \
146 X(W, D3Q19_W, D3Q19_E, -1, 0, 0) \
147 X(NE, D3Q19_NE, D3Q19_SW, 1, 1, 0) \
148 X(SE, D3Q19_SE, D3Q19_NW, 1, -1, 0) \
149 X(NW, D3Q19_NW, D3Q19_SE, -1, 1, 0) \
150 X(SW, D3Q19_SW, D3Q19_NE, -1, -1, 0) \
151 X(T, D3Q19_T, D3Q19_B, 0, 0, 1) \
152 X(TN, D3Q19_TN, D3Q19_BS, 0, 1, 1) \
153 X(TE, D3Q19_TE, D3Q19_BW, 1, 0, 1) \
154 X(TW, D3Q19_TW, D3Q19_BE, -1, 0, 1) \
155 X(TS, D3Q19_TS, D3Q19_BN, 0, -1, 1) \
156 X(B, D3Q19_B, D3Q19_T, 0, 0, -1) \
157 X(BS, D3Q19_BS, D3Q19_TN, 0, -1, -1) \
158 X(BN, D3Q19_BN, D3Q19_TS, 0, 1, -1) \
159 X(BW, D3Q19_BW, D3Q19_TE, -1, 0, -1) \
160 X(BE, D3Q19_BE, D3Q19_TW, 1, 0, -1)
163 extern int D3Q19_X[N_D3Q19];
164 extern int D3Q19_Y[N_D3Q19];
165 extern int D3Q19_Z[N_D3Q19];
166 extern int D3Q19_INV[N_D3Q19];
168 extern const char * D3Q19_NAMES[N_D3Q19];
172 typedef struct CaseData_ {
183 int StatisticsModulus;
187 typedef struct KernelData_ {
197 int * BounceBackPdfsSrc;
198 int * BounceBackPdfsDst;
200 double LoopBalance; // loopBalance when set in kernel init, Main.c may use it to derive metrics
201 double Duration; // duration when set in kernel routine, Main.c may use it to derive metrics
203 void (* BoundaryConditionsGetPdf)(struct KernelData_ * kd, int x, int y, int z, int dir, PdfT * pdf);
204 void (* BoundaryConditionsSetPdf)(struct KernelData_ * kd, int x, int y, int z, int dir, PdfT pdf);
206 void (* GetNode)(struct KernelData_ * kd, int x, int y, int z, PdfT * pdfs);
207 void (* SetNode)(struct KernelData_ * kd, int x, int y, int z, PdfT * pdfs);
209 void (* Kernel)(LatticeDesc * ld, struct KernelData_ * kd, CaseData * cd);
214 #define X_KERNEL_START(_kd) do { _kd->Duration = Time(); } while (0)
215 #define X_KERNEL_END(_kd) do { _kd->Duration = Time() - _kd->Duration; } while (0)
217 typedef struct Parameters_ {
224 void KernelComputeBoundaryConditions(KernelData * kd, LatticeDesc * ld, CaseData * cd);
226 PdfT KernelDensity(KernelData * kd, LatticeDesc * ld);
228 void KernelStatistics(KernelData * kd, LatticeDesc * ld, CaseData * cd, int iteration);
229 void KernelStatisticsAdv(KernelData * kd, LatticeDesc * ld, CaseData * cd, int iteration, int forceOutput);
232 void KernelSetInitialDensity (LatticeDesc * ld, KernelData * kd, CaseData * cd);
233 void KernelSetInitialVelocity(LatticeDesc * ld, KernelData * kd, CaseData * cd);
235 void KernelVerifiy(LatticeDesc * ld, KernelData * kd, CaseData * cd, PdfT * errorNorm);
237 void KernelAddBodyForce(KernelData * kd, LatticeDesc * ld, CaseData * cd);
239 #endif // __KERNEL_H__