99e126b720b943ff5ffa4e92651a0811128c6b73
[LbmBenchmarkKernelsPublic.git] / src / Kernel.h
1 // --------------------------------------------------------------------------
2 //
3 // Copyright
4 //   Markus Wittmann, 2016-2017
5 //   RRZE, University of Erlangen-Nuremberg, Germany
6 //   markus.wittmann -at- fau.de or hpc -at- rrze.fau.de
7 //
8 //   Viktor Haag, 2016
9 //   LSS, University of Erlangen-Nuremberg, Germany
10 //
11 //  This file is part of the Lattice Boltzmann Benchmark Kernels (LbmBenchKernels).
12 //
13 //  LbmBenchKernels is free software: you can redistribute it and/or modify
14 //  it under the terms of the GNU General Public License as published by
15 //  the Free Software Foundation, either version 3 of the License, or
16 //  (at your option) any later version.
17 //
18 //  LbmBenchKernels is distributed in the hope that it will be useful,
19 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
20 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 //  GNU General Public License for more details.
22 //
23 //  You should have received a copy of the GNU General Public License
24 //  along with LbmBenchKernels.  If not, see <http://www.gnu.org/licenses/>.
25 //
26 // --------------------------------------------------------------------------
27 #ifndef __KERNEL_H__
28 #define __KERNEL_H__
29
30 #include "Base.h"
31 #include "Lattice.h"
32
33 #ifdef DATA_LAYOUT_NAME
34         #error DATA_LAYOUT_NAME must not be defined here.
35 #endif
36
37 #ifdef PROP_MODEL_NAME
38         #error PROP_MODEL_NAME must not be defined here.
39 #endif
40
41
42 #ifdef DATA_LAYOUT_SOA
43         #define DATA_LAYOUT_NAME SoA
44 #endif
45
46 #ifdef DATA_LAYOUT_AOS
47         #define DATA_LAYOUT_NAME AoS
48 #endif
49
50 #ifdef PROP_MODEL_PUSH
51         #define PROP_MODEL_NAME Push
52 #endif
53
54 #ifdef PROP_MODEL_PULL
55         #define PROP_MODEL_NAME Pull
56 #endif
57
58 #ifdef PROP_MODEL_AA
59         #define PROP_MODEL_NAME Aa
60 #endif
61
62
63
64 typedef double  PdfT;
65
66
67
68 #define D3Q19
69
70
71 #define N_D3Q19         19
72
73 #define D3Q19_N         0
74 #define D3Q19_S         1
75 #define D3Q19_E         2
76 #define D3Q19_W         3
77
78 #define D3Q19_NE        4
79 #define D3Q19_SE        5
80 #define D3Q19_NW        6
81 #define D3Q19_SW        7
82
83 #define D3Q19_T         8
84 #define D3Q19_TN        9
85 #define D3Q19_TE        10
86 #define D3Q19_TW        11
87 #define D3Q19_TS        12
88
89 #define D3Q19_B         13
90 #define D3Q19_BS        14
91 #define D3Q19_BN        15
92 #define D3Q19_BW        16
93 #define D3Q19_BE        17
94
95 #define D3Q19_C         18              // IMPORTANT: Center particle must be the last one.
96
97 // ---
98
99 #ifdef X
100         #error X is not allowed to be defined here!
101 #endif
102
103 // The following list must be sorted ascending according
104 // to the index of the direction, i.e. D3Q19_N, D3Q19_S, ...
105 #define D3Q19_LIST \
106         X(N,  D3Q19_N,  D3Q19_S,          0,  1,  0) \
107         X(S,  D3Q19_S,  D3Q19_N,          0, -1,  0) \
108         X(E,  D3Q19_E,  D3Q19_W,          1,  0,  0) \
109         X(W,  D3Q19_W,  D3Q19_E,         -1,  0,  0) \
110         X(NE, D3Q19_NE, D3Q19_SW,         1,  1,  0) \
111         X(SE, D3Q19_SE, D3Q19_NW,         1, -1,  0) \
112         X(NW, D3Q19_NW, D3Q19_SE,        -1,  1,  0) \
113         X(SW, D3Q19_SW, D3Q19_NE,        -1, -1,  0) \
114         X(T,  D3Q19_T,  D3Q19_B,          0,  0,  1) \
115         X(TN, D3Q19_TN, D3Q19_BS,         0,  1,  1) \
116         X(TE, D3Q19_TE, D3Q19_BW,     1,  0,  1) \
117         X(TW, D3Q19_TW, D3Q19_BE,    -1,  0,  1) \
118         X(TS, D3Q19_TS, D3Q19_BN,     0, -1,  1) \
119         X(B,  D3Q19_B,  D3Q19_T,          0,  0, -1) \
120         X(BS, D3Q19_BS, D3Q19_TN,     0, -1, -1) \
121         X(BN, D3Q19_BN, D3Q19_TS,     0,  1, -1) \
122         X(BW, D3Q19_BW, D3Q19_TE,    -1,  0, -1) \
123         X(BE, D3Q19_BE, D3Q19_TW,     1,  0, -1) \
124         X(C,  D3Q19_C,  D3Q19_C,          0,  0,  0)
125
126 #define D3Q19_LIST_WO_C \
127         X(N,  D3Q19_N,  D3Q19_S,          0,  1,  0) \
128         X(S,  D3Q19_S,  D3Q19_N,          0, -1,  0) \
129         X(E,  D3Q19_E,  D3Q19_W,          1,  0,  0) \
130         X(W,  D3Q19_W,  D3Q19_E,         -1,  0,  0) \
131         X(NE, D3Q19_NE, D3Q19_SW,         1,  1,  0) \
132         X(SE, D3Q19_SE, D3Q19_NW,         1, -1,  0) \
133         X(NW, D3Q19_NW, D3Q19_SE,        -1,  1,  0) \
134         X(SW, D3Q19_SW, D3Q19_NE,        -1, -1,  0) \
135         X(T,  D3Q19_T,  D3Q19_B,          0,  0,  1) \
136         X(TN, D3Q19_TN, D3Q19_BS,         0,  1,  1) \
137         X(TE, D3Q19_TE, D3Q19_BW,     1,  0,  1) \
138         X(TW, D3Q19_TW, D3Q19_BE,    -1,  0,  1) \
139         X(TS, D3Q19_TS, D3Q19_BN,     0, -1,  1) \
140         X(B,  D3Q19_B,  D3Q19_T,          0,  0, -1) \
141         X(BS, D3Q19_BS, D3Q19_TN,     0, -1, -1) \
142         X(BN, D3Q19_BN, D3Q19_TS,     0,  1, -1) \
143         X(BW, D3Q19_BW, D3Q19_TE,    -1,  0, -1) \
144         X(BE, D3Q19_BE, D3Q19_TW,     1,  0, -1)
145
146
147 extern int D3Q19_X[N_D3Q19];
148 extern int D3Q19_Y[N_D3Q19];
149 extern int D3Q19_Z[N_D3Q19];
150 extern int D3Q19_INV[N_D3Q19];
151
152 extern const char * D3Q19_NAMES[N_D3Q19];
153
154
155
156 typedef struct CaseData_ {
157         PdfT Omega;
158         PdfT RhoIn;
159         PdfT RhoOut;
160         PdfT Ux;
161         PdfT Uy;
162         PdfT Uz;
163         PdfT XForce;
164         int MaxIterations;
165         int VtkOutput;
166         int VtkModulus;
167         int StatisticsModulus;
168 } CaseData;
169
170
171 typedef struct KernelData_ {
172         PdfT * Pdfs[2];
173         PdfT * SrcPdfs;
174         PdfT * DstPdfs;
175         PdfT * PdfsActive;
176         int Dims[3];
177         int GlobalDims[3];
178         int Offsets[3];
179         int * ObstIndices;
180         int nObstIndices;
181         int * BounceBackPdfsSrc;
182         int * BounceBackPdfsDst;
183         int nBounceBackPdfs;
184
185         void (* BoundaryConditionsGetPdf)(struct KernelData_ * kd, int x, int y, int z, int dir, PdfT * pdf);
186         void (* BoundaryConditionsSetPdf)(struct KernelData_ * kd, int x, int y, int z, int dir, PdfT pdf);
187
188         void (* GetNode)(struct KernelData_ * kd, int x, int y, int z, PdfT * pdfs);
189         void (* SetNode)(struct KernelData_ * kd, int x, int y, int z, PdfT * pdfs);
190
191         void (* Kernel)(LatticeDesc * ld, struct KernelData_ * kd, CaseData * cd);
192
193 } KernelData;
194
195 typedef struct Parameters_ {
196         int nArgs;
197         char ** Args;
198         int nKernelArgs;
199         char ** KernelArgs;
200 } Parameters;
201
202 void KernelComputeBoundaryConditions(KernelData * kd, LatticeDesc * ld, CaseData * cd);
203
204 PdfT KernelDensity(KernelData * kd, LatticeDesc * ld);
205
206 void KernelStatistics(KernelData * kd, LatticeDesc * ld, CaseData * cd, int iteration);
207 void KernelStatisticsAdv(KernelData * kd, LatticeDesc * ld, CaseData * cd, int iteration, int forceOutput);
208
209
210 void KernelSetInitialDensity (LatticeDesc * ld, KernelData * kd, CaseData * cd);
211 void KernelSetInitialVelocity(LatticeDesc * ld, KernelData * kd, CaseData * cd);
212
213 void KernelVerifiy(LatticeDesc * ld, KernelData * kd, CaseData * cd, PdfT * errorNorm);
214
215 void KernelAddBodyForce(KernelData * kd, LatticeDesc * ld, CaseData * cd);
216
217 #endif // __KERNEL_H__
This page took 0.050217 seconds and 3 git commands to generate.