add single precision, add aa-vec-sl-soa kernel, updated doc
[LbmBenchmarkKernelsPublic.git] / src / Kernel.h
CommitLineData
10988083
MW
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
e3f82424 59 #define PROP_MODEL_NAME Aa
10988083
MW
60#endif
61
62
0fde6e45
MW
63#ifdef PRECISION_DP
64 typedef double PdfT;
65#elif defined(PRECISION_SP)
66 typedef float PdfT;
67#else
68 #error PRECISION must be defined as dp or sp.
69#endif
10988083 70
0fde6e45 71 #define F(number) (PdfT)(number)
10988083
MW
72
73
74#define D3Q19
75
76
77#define N_D3Q19 19
78
79#define D3Q19_N 0
80#define D3Q19_S 1
81#define D3Q19_E 2
82#define D3Q19_W 3
83
84#define D3Q19_NE 4
85#define D3Q19_SE 5
86#define D3Q19_NW 6
87#define D3Q19_SW 7
88
89#define D3Q19_T 8
90#define D3Q19_TN 9
91#define D3Q19_TE 10
92#define D3Q19_TW 11
93#define D3Q19_TS 12
94
95#define D3Q19_B 13
96#define D3Q19_BS 14
97#define D3Q19_BN 15
98#define D3Q19_BW 16
99#define D3Q19_BE 17
100
101#define D3Q19_C 18 // IMPORTANT: Center particle must be the last one.
102
103// ---
104
105#ifdef X
106 #error X is not allowed to be defined here!
107#endif
108
109// The following list must be sorted ascending according
110// to the index of the direction, i.e. D3Q19_N, D3Q19_S, ...
111#define D3Q19_LIST \
112 X(N, D3Q19_N, D3Q19_S, 0, 1, 0) \
113 X(S, D3Q19_S, D3Q19_N, 0, -1, 0) \
114 X(E, D3Q19_E, D3Q19_W, 1, 0, 0) \
115 X(W, D3Q19_W, D3Q19_E, -1, 0, 0) \
116 X(NE, D3Q19_NE, D3Q19_SW, 1, 1, 0) \
117 X(SE, D3Q19_SE, D3Q19_NW, 1, -1, 0) \
118 X(NW, D3Q19_NW, D3Q19_SE, -1, 1, 0) \
119 X(SW, D3Q19_SW, D3Q19_NE, -1, -1, 0) \
120 X(T, D3Q19_T, D3Q19_B, 0, 0, 1) \
121 X(TN, D3Q19_TN, D3Q19_BS, 0, 1, 1) \
122 X(TE, D3Q19_TE, D3Q19_BW, 1, 0, 1) \
123 X(TW, D3Q19_TW, D3Q19_BE, -1, 0, 1) \
124 X(TS, D3Q19_TS, D3Q19_BN, 0, -1, 1) \
125 X(B, D3Q19_B, D3Q19_T, 0, 0, -1) \
126 X(BS, D3Q19_BS, D3Q19_TN, 0, -1, -1) \
127 X(BN, D3Q19_BN, D3Q19_TS, 0, 1, -1) \
128 X(BW, D3Q19_BW, D3Q19_TE, -1, 0, -1) \
129 X(BE, D3Q19_BE, D3Q19_TW, 1, 0, -1) \
130 X(C, D3Q19_C, D3Q19_C, 0, 0, 0)
131
132#define D3Q19_LIST_WO_C \
133 X(N, D3Q19_N, D3Q19_S, 0, 1, 0) \
134 X(S, D3Q19_S, D3Q19_N, 0, -1, 0) \
135 X(E, D3Q19_E, D3Q19_W, 1, 0, 0) \
136 X(W, D3Q19_W, D3Q19_E, -1, 0, 0) \
137 X(NE, D3Q19_NE, D3Q19_SW, 1, 1, 0) \
138 X(SE, D3Q19_SE, D3Q19_NW, 1, -1, 0) \
139 X(NW, D3Q19_NW, D3Q19_SE, -1, 1, 0) \
140 X(SW, D3Q19_SW, D3Q19_NE, -1, -1, 0) \
141 X(T, D3Q19_T, D3Q19_B, 0, 0, 1) \
142 X(TN, D3Q19_TN, D3Q19_BS, 0, 1, 1) \
143 X(TE, D3Q19_TE, D3Q19_BW, 1, 0, 1) \
144 X(TW, D3Q19_TW, D3Q19_BE, -1, 0, 1) \
145 X(TS, D3Q19_TS, D3Q19_BN, 0, -1, 1) \
146 X(B, D3Q19_B, D3Q19_T, 0, 0, -1) \
147 X(BS, D3Q19_BS, D3Q19_TN, 0, -1, -1) \
148 X(BN, D3Q19_BN, D3Q19_TS, 0, 1, -1) \
149 X(BW, D3Q19_BW, D3Q19_TE, -1, 0, -1) \
150 X(BE, D3Q19_BE, D3Q19_TW, 1, 0, -1)
151
152
153extern int D3Q19_X[N_D3Q19];
154extern int D3Q19_Y[N_D3Q19];
155extern int D3Q19_Z[N_D3Q19];
156extern int D3Q19_INV[N_D3Q19];
157
158extern const char * D3Q19_NAMES[N_D3Q19];
159
160
161
162typedef struct CaseData_ {
163 PdfT Omega;
164 PdfT RhoIn;
165 PdfT RhoOut;
166 PdfT Ux;
167 PdfT Uy;
168 PdfT Uz;
169 PdfT XForce;
170 int MaxIterations;
171 int VtkOutput;
172 int VtkModulus;
173 int StatisticsModulus;
174} CaseData;
175
176
177typedef struct KernelData_ {
178 PdfT * Pdfs[2];
179 PdfT * SrcPdfs;
180 PdfT * DstPdfs;
181 PdfT * PdfsActive;
182 int Dims[3];
183 int GlobalDims[3];
184 int Offsets[3];
185 int * ObstIndices;
186 int nObstIndices;
187 int * BounceBackPdfsSrc;
188 int * BounceBackPdfsDst;
189 int nBounceBackPdfs;
190
191 void (* BoundaryConditionsGetPdf)(struct KernelData_ * kd, int x, int y, int z, int dir, PdfT * pdf);
192 void (* BoundaryConditionsSetPdf)(struct KernelData_ * kd, int x, int y, int z, int dir, PdfT pdf);
193
194 void (* GetNode)(struct KernelData_ * kd, int x, int y, int z, PdfT * pdfs);
195 void (* SetNode)(struct KernelData_ * kd, int x, int y, int z, PdfT * pdfs);
196
197 void (* Kernel)(LatticeDesc * ld, struct KernelData_ * kd, CaseData * cd);
198
199} KernelData;
200
201typedef struct Parameters_ {
202 int nArgs;
203 char ** Args;
204 int nKernelArgs;
205 char ** KernelArgs;
206} Parameters;
207
208void KernelComputeBoundaryConditions(KernelData * kd, LatticeDesc * ld, CaseData * cd);
209
210PdfT KernelDensity(KernelData * kd, LatticeDesc * ld);
211
212void KernelStatistics(KernelData * kd, LatticeDesc * ld, CaseData * cd, int iteration);
213void KernelStatisticsAdv(KernelData * kd, LatticeDesc * ld, CaseData * cd, int iteration, int forceOutput);
214
215
216void KernelSetInitialDensity (LatticeDesc * ld, KernelData * kd, CaseData * cd);
217void KernelSetInitialVelocity(LatticeDesc * ld, KernelData * kd, CaseData * cd);
218
219void KernelVerifiy(LatticeDesc * ld, KernelData * kd, CaseData * cd, PdfT * errorNorm);
220
221void KernelAddBodyForce(KernelData * kd, LatticeDesc * ld, CaseData * cd);
222
223#endif // __KERNEL_H__
This page took 0.059206 seconds and 5 git commands to generate.