53inline auto get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
55 float const &xyz0 = pdf_field->get(cell, uint_t{0u});
56 std::array<float, 19u> pop;
57 pop[0u] = pdf_field->getF(&xyz0, uint_t{0u});
58 pop[1u] = pdf_field->getF(&xyz0, uint_t{1u});
59 pop[2u] = pdf_field->getF(&xyz0, uint_t{2u});
60 pop[3u] = pdf_field->getF(&xyz0, uint_t{3u});
61 pop[4u] = pdf_field->getF(&xyz0, uint_t{4u});
62 pop[5u] = pdf_field->getF(&xyz0, uint_t{5u});
63 pop[6u] = pdf_field->getF(&xyz0, uint_t{6u});
64 pop[7u] = pdf_field->getF(&xyz0, uint_t{7u});
65 pop[8u] = pdf_field->getF(&xyz0, uint_t{8u});
66 pop[9u] = pdf_field->getF(&xyz0, uint_t{9u});
67 pop[10u] = pdf_field->getF(&xyz0, uint_t{10u});
68 pop[11u] = pdf_field->getF(&xyz0, uint_t{11u});
69 pop[12u] = pdf_field->getF(&xyz0, uint_t{12u});
70 pop[13u] = pdf_field->getF(&xyz0, uint_t{13u});
71 pop[14u] = pdf_field->getF(&xyz0, uint_t{14u});
72 pop[15u] = pdf_field->getF(&xyz0, uint_t{15u});
73 pop[16u] = pdf_field->getF(&xyz0, uint_t{16u});
74 pop[17u] = pdf_field->getF(&xyz0, uint_t{17u});
75 pop[18u] = pdf_field->getF(&xyz0, uint_t{18u});
79inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
80 std::array<float, 19u>
const &pop,
Cell const &cell) {
81 float &xyz0 = pdf_field->get(cell, uint_t{0u});
82 pdf_field->getF(&xyz0, uint_t{0u}) = pop[0u];
83 pdf_field->getF(&xyz0, uint_t{1u}) = pop[1u];
84 pdf_field->getF(&xyz0, uint_t{2u}) = pop[2u];
85 pdf_field->getF(&xyz0, uint_t{3u}) = pop[3u];
86 pdf_field->getF(&xyz0, uint_t{4u}) = pop[4u];
87 pdf_field->getF(&xyz0, uint_t{5u}) = pop[5u];
88 pdf_field->getF(&xyz0, uint_t{6u}) = pop[6u];
89 pdf_field->getF(&xyz0, uint_t{7u}) = pop[7u];
90 pdf_field->getF(&xyz0, uint_t{8u}) = pop[8u];
91 pdf_field->getF(&xyz0, uint_t{9u}) = pop[9u];
92 pdf_field->getF(&xyz0, uint_t{10u}) = pop[10u];
93 pdf_field->getF(&xyz0, uint_t{11u}) = pop[11u];
94 pdf_field->getF(&xyz0, uint_t{12u}) = pop[12u];
95 pdf_field->getF(&xyz0, uint_t{13u}) = pop[13u];
96 pdf_field->getF(&xyz0, uint_t{14u}) = pop[14u];
97 pdf_field->getF(&xyz0, uint_t{15u}) = pop[15u];
98 pdf_field->getF(&xyz0, uint_t{16u}) = pop[16u];
99 pdf_field->getF(&xyz0, uint_t{17u}) = pop[17u];
100 pdf_field->getF(&xyz0, uint_t{18u}) = pop[18u];
103inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
104 GhostLayerField<float, uint_t{3u}> *velocity_field,
105 GhostLayerField<float, uint_t{3u}>
const *force_field,
106 std::array<float, 19u>
const &pop,
Cell const &cell) {
107 auto &xyz0 = pdf_field->get(cell, uint_t{0u});
108 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u}) = pop[0u];
109 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u}) = pop[1u];
110 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u}) = pop[2u];
111 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u}) = pop[3u];
112 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u}) = pop[4u];
113 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u}) = pop[5u];
114 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u}) = pop[6u];
115 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u}) = pop[7u];
116 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u}) = pop[8u];
117 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u}) = pop[9u];
118 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u}) = pop[10u];
119 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u}) = pop[11u];
120 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u}) = pop[12u];
121 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u}) = pop[13u];
122 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u}) = pop[14u];
123 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u}) = pop[15u];
124 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u}) = pop[16u];
125 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u}) = pop[17u];
126 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u}) = pop[18u];
127 const auto x = cell.x();
128 const auto y = cell.y();
129 const auto z = cell.z();
130 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
131 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
132 const float vel1Term = f_1 + f_11 + f_15 + f_7;
133 const float momdensity_1 = -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
134 const float vel2Term = f_12 + f_13 + f_5;
135 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 + vel0Term +
137 const float momdensity_2 =
138 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
139 const float rho = delta_rho + 1;
141 force_field->get(x, y, z, 0) * 0.50000000000000000f + momdensity_0;
143 force_field->get(x, y, z, 1) * 0.50000000000000000f + momdensity_1;
145 force_field->get(x, y, z, 2) * 0.50000000000000000f + momdensity_2;
146 const auto rho_inv =
float{1} / rho;
147 velocity_field->get(cell, uint_t{0u}) = md_0 * rho_inv;
148 velocity_field->get(cell, uint_t{1u}) = md_1 * rho_inv;
149 velocity_field->get(cell, uint_t{2u}) = md_2 * rho_inv;
152inline void initialize(GhostLayerField<
float, uint_t{19u}> *pdf_field,
153 std::array<float, 19u>
const &pop) {
154 WALBERLA_FOR_ALL_CELLS_INCLUDING_GHOST_LAYER_XYZ(pdf_field, {
155 float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
156 pdf_field->getF(&xyz0, uint_t{0u}) = pop[0u];
157 pdf_field->getF(&xyz0, uint_t{1u}) = pop[1u];
158 pdf_field->getF(&xyz0, uint_t{2u}) = pop[2u];
159 pdf_field->getF(&xyz0, uint_t{3u}) = pop[3u];
160 pdf_field->getF(&xyz0, uint_t{4u}) = pop[4u];
161 pdf_field->getF(&xyz0, uint_t{5u}) = pop[5u];
162 pdf_field->getF(&xyz0, uint_t{6u}) = pop[6u];
163 pdf_field->getF(&xyz0, uint_t{7u}) = pop[7u];
164 pdf_field->getF(&xyz0, uint_t{8u}) = pop[8u];
165 pdf_field->getF(&xyz0, uint_t{9u}) = pop[9u];
166 pdf_field->getF(&xyz0, uint_t{10u}) = pop[10u];
167 pdf_field->getF(&xyz0, uint_t{11u}) = pop[11u];
168 pdf_field->getF(&xyz0, uint_t{12u}) = pop[12u];
169 pdf_field->getF(&xyz0, uint_t{13u}) = pop[13u];
170 pdf_field->getF(&xyz0, uint_t{14u}) = pop[14u];
171 pdf_field->getF(&xyz0, uint_t{15u}) = pop[15u];
172 pdf_field->getF(&xyz0, uint_t{16u}) = pop[16u];
173 pdf_field->getF(&xyz0, uint_t{17u}) = pop[17u];
174 pdf_field->getF(&xyz0, uint_t{18u}) = pop[18u];
178inline auto get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
179 CellInterval
const &ci) {
180 std::vector<float> out;
181 out.reserve(ci.numCells() * uint_t(19u));
182 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
183 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
184 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
185 float const &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
186 out.emplace_back(pdf_field->getF(&xyz0, uint_t{0u}));
187 out.emplace_back(pdf_field->getF(&xyz0, uint_t{1u}));
188 out.emplace_back(pdf_field->getF(&xyz0, uint_t{2u}));
189 out.emplace_back(pdf_field->getF(&xyz0, uint_t{3u}));
190 out.emplace_back(pdf_field->getF(&xyz0, uint_t{4u}));
191 out.emplace_back(pdf_field->getF(&xyz0, uint_t{5u}));
192 out.emplace_back(pdf_field->getF(&xyz0, uint_t{6u}));
193 out.emplace_back(pdf_field->getF(&xyz0, uint_t{7u}));
194 out.emplace_back(pdf_field->getF(&xyz0, uint_t{8u}));
195 out.emplace_back(pdf_field->getF(&xyz0, uint_t{9u}));
196 out.emplace_back(pdf_field->getF(&xyz0, uint_t{10u}));
197 out.emplace_back(pdf_field->getF(&xyz0, uint_t{11u}));
198 out.emplace_back(pdf_field->getF(&xyz0, uint_t{12u}));
199 out.emplace_back(pdf_field->getF(&xyz0, uint_t{13u}));
200 out.emplace_back(pdf_field->getF(&xyz0, uint_t{14u}));
201 out.emplace_back(pdf_field->getF(&xyz0, uint_t{15u}));
202 out.emplace_back(pdf_field->getF(&xyz0, uint_t{16u}));
203 out.emplace_back(pdf_field->getF(&xyz0, uint_t{17u}));
204 out.emplace_back(pdf_field->getF(&xyz0, uint_t{18u}));
211inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
212 std::vector<float>
const &values, CellInterval
const &ci) {
213 assert(uint_c(values.size()) == ci.numCells() * uint_t(19u));
214 auto pop = values.data();
215 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
216 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
217 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
218 float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
219 pdf_field->getF(&xyz0, uint_t{0u}) = pop[0u];
220 pdf_field->getF(&xyz0, uint_t{1u}) = pop[1u];
221 pdf_field->getF(&xyz0, uint_t{2u}) = pop[2u];
222 pdf_field->getF(&xyz0, uint_t{3u}) = pop[3u];
223 pdf_field->getF(&xyz0, uint_t{4u}) = pop[4u];
224 pdf_field->getF(&xyz0, uint_t{5u}) = pop[5u];
225 pdf_field->getF(&xyz0, uint_t{6u}) = pop[6u];
226 pdf_field->getF(&xyz0, uint_t{7u}) = pop[7u];
227 pdf_field->getF(&xyz0, uint_t{8u}) = pop[8u];
228 pdf_field->getF(&xyz0, uint_t{9u}) = pop[9u];
229 pdf_field->getF(&xyz0, uint_t{10u}) = pop[10u];
230 pdf_field->getF(&xyz0, uint_t{11u}) = pop[11u];
231 pdf_field->getF(&xyz0, uint_t{12u}) = pop[12u];
232 pdf_field->getF(&xyz0, uint_t{13u}) = pop[13u];
233 pdf_field->getF(&xyz0, uint_t{14u}) = pop[14u];
234 pdf_field->getF(&xyz0, uint_t{15u}) = pop[15u];
235 pdf_field->getF(&xyz0, uint_t{16u}) = pop[16u];
236 pdf_field->getF(&xyz0, uint_t{17u}) = pop[17u];
237 pdf_field->getF(&xyz0, uint_t{18u}) = pop[18u];
238 std::advance(pop, 19);
244inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
245 GhostLayerField<float, uint_t{3u}> *velocity_field,
246 GhostLayerField<float, uint_t{3u}>
const *force_field,
247 std::vector<float>
const &values, CellInterval
const &ci) {
248 assert(uint_c(values.size()) == ci.numCells() * uint_t(19u));
249 auto pop = values.data();
250 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
251 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
252 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
253 float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
254 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u}) = pop[0u];
255 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u}) = pop[1u];
256 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u}) = pop[2u];
257 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u}) = pop[3u];
258 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u}) = pop[4u];
259 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u}) = pop[5u];
260 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u}) = pop[6u];
261 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u}) = pop[7u];
262 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u}) = pop[8u];
263 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u}) = pop[9u];
264 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u}) = pop[10u];
265 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u}) = pop[11u];
266 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u}) = pop[12u];
267 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u}) = pop[13u];
268 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u}) = pop[14u];
269 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u}) = pop[15u];
270 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u}) = pop[16u];
271 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u}) = pop[17u];
272 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u}) = pop[18u];
273 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
274 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
275 const float vel1Term = f_1 + f_11 + f_15 + f_7;
276 const float momdensity_1 =
277 -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
278 const float vel2Term = f_12 + f_13 + f_5;
279 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 +
280 vel0Term + vel1Term + vel2Term;
281 const float momdensity_2 =
282 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
283 const float rho = delta_rho + 1;
285 force_field->get(x, y, z, 0) * 0.50000000000000000f + momdensity_0;
287 force_field->get(x, y, z, 1) * 0.50000000000000000f + momdensity_1;
289 force_field->get(x, y, z, 2) * 0.50000000000000000f + momdensity_2;
290 const auto rho_inv =
float{1} / rho;
291 velocity_field->get(x, y, z, uint_t{0u}) = md_0 * rho_inv;
292 velocity_field->get(x, y, z, uint_t{1u}) = md_1 * rho_inv;
293 velocity_field->get(x, y, z, uint_t{2u}) = md_2 * rho_inv;
294 std::advance(pop, 19);
384inline float get(stencil::Direction
const direction,
385 Vector3<float>
const &u = Vector3<float>(
float{0}),
386 float rho =
float{1}) {
388 using namespace stencil;
391 return rho * -0.33333333333333331f * (u[0] * u[0]) +
392 rho * -0.33333333333333331f * (u[1] * u[1]) +
393 rho * -0.33333333333333331f * (u[2] * u[2]) +
394 rho * 0.33333333333333331f;
396 return rho * -0.16666666666666666f * (u[0] * u[0]) +
397 rho * -0.16666666666666666f * (u[2] * u[2]) +
398 rho * 0.055555555555555552f + rho * 0.16666666666666666f * u[1] +
399 rho * 0.16666666666666666f * (u[1] * u[1]);
401 return rho * -0.16666666666666666f * u[1] +
402 rho * -0.16666666666666666f * (u[0] * u[0]) +
403 rho * -0.16666666666666666f * (u[2] * u[2]) +
404 rho * 0.055555555555555552f +
405 rho * 0.16666666666666666f * (u[1] * u[1]);
407 return rho * -0.16666666666666666f * u[0] +
408 rho * -0.16666666666666666f * (u[1] * u[1]) +
409 rho * -0.16666666666666666f * (u[2] * u[2]) +
410 rho * 0.055555555555555552f +
411 rho * 0.16666666666666666f * (u[0] * u[0]);
413 return rho * -0.16666666666666666f * (u[1] * u[1]) +
414 rho * -0.16666666666666666f * (u[2] * u[2]) +
415 rho * 0.055555555555555552f + rho * 0.16666666666666666f * u[0] +
416 rho * 0.16666666666666666f * (u[0] * u[0]);
418 return rho * -0.16666666666666666f * (u[0] * u[0]) +
419 rho * -0.16666666666666666f * (u[1] * u[1]) +
420 rho * 0.055555555555555552f + rho * 0.16666666666666666f * u[2] +
421 rho * 0.16666666666666666f * (u[2] * u[2]);
423 return rho * -0.16666666666666666f * u[2] +
424 rho * -0.16666666666666666f * (u[0] * u[0]) +
425 rho * -0.16666666666666666f * (u[1] * u[1]) +
426 rho * 0.055555555555555552f +
427 rho * 0.16666666666666666f * (u[2] * u[2]);
429 return rho * -0.083333333333333329f * u[0] + rho * -0.25f * u[0] * u[1] +
430 rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[1] +
431 rho * 0.083333333333333329f * (u[0] * u[0]) +
432 rho * 0.083333333333333329f * (u[1] * u[1]);
434 return rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[0] +
435 rho * 0.083333333333333329f * u[1] +
436 rho * 0.083333333333333329f * (u[0] * u[0]) +
437 rho * 0.083333333333333329f * (u[1] * u[1]) +
438 rho * 0.25f * u[0] * u[1];
440 return rho * -0.083333333333333329f * u[0] +
441 rho * -0.083333333333333329f * u[1] + rho * 0.027777777777777776f +
442 rho * 0.083333333333333329f * (u[0] * u[0]) +
443 rho * 0.083333333333333329f * (u[1] * u[1]) +
444 rho * 0.25f * u[0] * u[1];
446 return rho * -0.083333333333333329f * u[1] + rho * -0.25f * u[0] * u[1] +
447 rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[0] +
448 rho * 0.083333333333333329f * (u[0] * u[0]) +
449 rho * 0.083333333333333329f * (u[1] * u[1]);
451 return rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[1] +
452 rho * 0.083333333333333329f * u[2] +
453 rho * 0.083333333333333329f * (u[1] * u[1]) +
454 rho * 0.083333333333333329f * (u[2] * u[2]) +
455 rho * 0.25f * u[1] * u[2];
457 return rho * -0.083333333333333329f * u[1] + rho * -0.25f * u[1] * u[2] +
458 rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[2] +
459 rho * 0.083333333333333329f * (u[1] * u[1]) +
460 rho * 0.083333333333333329f * (u[2] * u[2]);
462 return rho * -0.083333333333333329f * u[0] + rho * -0.25f * u[0] * u[2] +
463 rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[2] +
464 rho * 0.083333333333333329f * (u[0] * u[0]) +
465 rho * 0.083333333333333329f * (u[2] * u[2]);
467 return rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[0] +
468 rho * 0.083333333333333329f * u[2] +
469 rho * 0.083333333333333329f * (u[0] * u[0]) +
470 rho * 0.083333333333333329f * (u[2] * u[2]) +
471 rho * 0.25f * u[0] * u[2];
473 return rho * -0.083333333333333329f * u[2] + rho * -0.25f * u[1] * u[2] +
474 rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[1] +
475 rho * 0.083333333333333329f * (u[1] * u[1]) +
476 rho * 0.083333333333333329f * (u[2] * u[2]);
478 return rho * -0.083333333333333329f * u[1] +
479 rho * -0.083333333333333329f * u[2] + rho * 0.027777777777777776f +
480 rho * 0.083333333333333329f * (u[1] * u[1]) +
481 rho * 0.083333333333333329f * (u[2] * u[2]) +
482 rho * 0.25f * u[1] * u[2];
484 return rho * -0.083333333333333329f * u[0] +
485 rho * -0.083333333333333329f * u[2] + rho * 0.027777777777777776f +
486 rho * 0.083333333333333329f * (u[0] * u[0]) +
487 rho * 0.083333333333333329f * (u[2] * u[2]) +
488 rho * 0.25f * u[0] * u[2];
490 return rho * -0.083333333333333329f * u[2] + rho * -0.25f * u[0] * u[2] +
491 rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[0] +
492 rho * 0.083333333333333329f * (u[0] * u[0]) +
493 rho * 0.083333333333333329f * (u[2] * u[2]);
495 WALBERLA_ABORT(
"Invalid Direction")
501inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
502 Vector3<float>
const &u,
float const rho,
Cell const &cell) {
504 float delta_rho = rho -
float{1};
506 float &xyz0 = pdf_field->get(cell, uint_t{0u});
507 pdf_field->getF(&xyz0, uint_t{0u}) =
508 delta_rho * 0.33333333333333331f +
509 rho * -0.33333333333333331f * (u[0] * u[0]) +
510 rho * -0.33333333333333331f * (u[1] * u[1]) +
511 rho * -0.33333333333333331f * (u[2] * u[2]);
512 pdf_field->getF(&xyz0, uint_t{1u}) =
513 delta_rho * 0.055555555555555552f +
514 rho * -0.16666666666666666f * (u[0] * u[0]) +
515 rho * -0.16666666666666666f * (u[2] * u[2]) +
516 rho * 0.16666666666666666f * u[1] +
517 rho * 0.16666666666666666f * (u[1] * u[1]);
518 pdf_field->getF(&xyz0, uint_t{2u}) =
519 delta_rho * 0.055555555555555552f + rho * -0.16666666666666666f * u[1] +
520 rho * -0.16666666666666666f * (u[0] * u[0]) +
521 rho * -0.16666666666666666f * (u[2] * u[2]) +
522 rho * 0.16666666666666666f * (u[1] * u[1]);
523 pdf_field->getF(&xyz0, uint_t{3u}) =
524 delta_rho * 0.055555555555555552f + rho * -0.16666666666666666f * u[0] +
525 rho * -0.16666666666666666f * (u[1] * u[1]) +
526 rho * -0.16666666666666666f * (u[2] * u[2]) +
527 rho * 0.16666666666666666f * (u[0] * u[0]);
528 pdf_field->getF(&xyz0, uint_t{4u}) =
529 delta_rho * 0.055555555555555552f +
530 rho * -0.16666666666666666f * (u[1] * u[1]) +
531 rho * -0.16666666666666666f * (u[2] * u[2]) +
532 rho * 0.16666666666666666f * u[0] +
533 rho * 0.16666666666666666f * (u[0] * u[0]);
534 pdf_field->getF(&xyz0, uint_t{5u}) =
535 delta_rho * 0.055555555555555552f +
536 rho * -0.16666666666666666f * (u[0] * u[0]) +
537 rho * -0.16666666666666666f * (u[1] * u[1]) +
538 rho * 0.16666666666666666f * u[2] +
539 rho * 0.16666666666666666f * (u[2] * u[2]);
540 pdf_field->getF(&xyz0, uint_t{6u}) =
541 delta_rho * 0.055555555555555552f + rho * -0.16666666666666666f * u[2] +
542 rho * -0.16666666666666666f * (u[0] * u[0]) +
543 rho * -0.16666666666666666f * (u[1] * u[1]) +
544 rho * 0.16666666666666666f * (u[2] * u[2]);
545 pdf_field->getF(&xyz0, uint_t{7u}) =
546 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[0] +
547 rho * -0.25f * u[0] * u[1] + rho * 0.083333333333333329f * u[1] +
548 rho * 0.083333333333333329f * (u[0] * u[0]) +
549 rho * 0.083333333333333329f * (u[1] * u[1]);
550 pdf_field->getF(&xyz0, uint_t{8u}) =
551 delta_rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[0] +
552 rho * 0.083333333333333329f * u[1] +
553 rho * 0.083333333333333329f * (u[0] * u[0]) +
554 rho * 0.083333333333333329f * (u[1] * u[1]) + rho * 0.25f * u[0] * u[1];
555 pdf_field->getF(&xyz0, uint_t{9u}) =
556 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[0] +
557 rho * -0.083333333333333329f * u[1] +
558 rho * 0.083333333333333329f * (u[0] * u[0]) +
559 rho * 0.083333333333333329f * (u[1] * u[1]) + rho * 0.25f * u[0] * u[1];
560 pdf_field->getF(&xyz0, uint_t{10u}) =
561 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[1] +
562 rho * -0.25f * u[0] * u[1] + rho * 0.083333333333333329f * u[0] +
563 rho * 0.083333333333333329f * (u[0] * u[0]) +
564 rho * 0.083333333333333329f * (u[1] * u[1]);
565 pdf_field->getF(&xyz0, uint_t{11u}) =
566 delta_rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[1] +
567 rho * 0.083333333333333329f * u[2] +
568 rho * 0.083333333333333329f * (u[1] * u[1]) +
569 rho * 0.083333333333333329f * (u[2] * u[2]) + rho * 0.25f * u[1] * u[2];
570 pdf_field->getF(&xyz0, uint_t{12u}) =
571 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[1] +
572 rho * -0.25f * u[1] * u[2] + rho * 0.083333333333333329f * u[2] +
573 rho * 0.083333333333333329f * (u[1] * u[1]) +
574 rho * 0.083333333333333329f * (u[2] * u[2]);
575 pdf_field->getF(&xyz0, uint_t{13u}) =
576 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[0] +
577 rho * -0.25f * u[0] * u[2] + rho * 0.083333333333333329f * u[2] +
578 rho * 0.083333333333333329f * (u[0] * u[0]) +
579 rho * 0.083333333333333329f * (u[2] * u[2]);
580 pdf_field->getF(&xyz0, uint_t{14u}) =
581 delta_rho * 0.027777777777777776f + rho * 0.083333333333333329f * u[0] +
582 rho * 0.083333333333333329f * u[2] +
583 rho * 0.083333333333333329f * (u[0] * u[0]) +
584 rho * 0.083333333333333329f * (u[2] * u[2]) + rho * 0.25f * u[0] * u[2];
585 pdf_field->getF(&xyz0, uint_t{15u}) =
586 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[2] +
587 rho * -0.25f * u[1] * u[2] + rho * 0.083333333333333329f * u[1] +
588 rho * 0.083333333333333329f * (u[1] * u[1]) +
589 rho * 0.083333333333333329f * (u[2] * u[2]);
590 pdf_field->getF(&xyz0, uint_t{16u}) =
591 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[1] +
592 rho * -0.083333333333333329f * u[2] +
593 rho * 0.083333333333333329f * (u[1] * u[1]) +
594 rho * 0.083333333333333329f * (u[2] * u[2]) + rho * 0.25f * u[1] * u[2];
595 pdf_field->getF(&xyz0, uint_t{17u}) =
596 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[0] +
597 rho * -0.083333333333333329f * u[2] +
598 rho * 0.083333333333333329f * (u[0] * u[0]) +
599 rho * 0.083333333333333329f * (u[2] * u[2]) + rho * 0.25f * u[0] * u[2];
600 pdf_field->getF(&xyz0, uint_t{18u}) =
601 delta_rho * 0.027777777777777776f + rho * -0.083333333333333329f * u[2] +
602 rho * -0.25f * u[0] * u[2] + rho * 0.083333333333333329f * u[0] +
603 rho * 0.083333333333333329f * (u[0] * u[0]) +
604 rho * 0.083333333333333329f * (u[2] * u[2]);
609inline float get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
611 const float &xyz0 = pdf_field->get(cell, uint_t{0u});
612 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
613 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
614 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
615 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
616 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
617 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
618 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
619 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
620 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
621 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
622 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
623 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
624 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
625 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
626 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
627 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
628 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
629 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
630 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
631 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
632 const float vel1Term = f_1 + f_11 + f_15 + f_7;
633 const float vel2Term = f_12 + f_13 + f_5;
634 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 + vel0Term +
636 const float rho =
density * (delta_rho + 1);
640inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
641 float const rho_in,
float const density,
Cell const &cell) {
642 const float &xyz0 = pdf_field->get(cell, uint_t{0u});
643 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
644 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
645 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
646 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
647 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
648 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
649 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
650 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
651 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
652 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
653 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
654 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
655 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
656 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
657 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
658 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
659 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
660 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
661 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
662 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
663 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
664 const float vel1Term = f_1 + f_11 + f_15 + f_7;
665 const float momdensity_1 = -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
666 const float vel2Term = f_12 + f_13 + f_5;
667 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 + vel0Term +
669 const float momdensity_2 =
670 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
671 const float rho = delta_rho + 1;
674 const float conversion =
float{1} / rho;
676 velocity[0u] = momdensity_0 * conversion;
677 velocity[1u] = momdensity_1 * conversion;
678 velocity[2u] = momdensity_2 * conversion;
684get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
float const density,
685 CellInterval
const &ci) {
686 std::vector<float> out;
687 out.reserve(ci.numCells());
688 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
689 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
690 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
691 const float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
692 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
693 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
694 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
695 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
696 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
697 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
698 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
699 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
700 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
701 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
702 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
703 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
704 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
705 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
706 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
707 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
708 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
709 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
710 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
711 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
712 const float vel1Term = f_1 + f_11 + f_15 + f_7;
713 const float vel2Term = f_12 + f_13 + f_5;
714 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 +
715 vel0Term + vel1Term + vel2Term;
716 const float rho =
density * (delta_rho + 1);
717 out.emplace_back(rho);
724inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
725 std::vector<float>
const &values,
float const density,
726 CellInterval
const &ci) {
727 assert(uint_c(values.size()) == ci.numCells());
728 auto values_it = values.begin();
729 auto const density_inv =
float{1} /
density;
730 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
731 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
732 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
733 const float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
734 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
735 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
736 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
737 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
738 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
739 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
740 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
741 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
742 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
743 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
744 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
745 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
746 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
747 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
748 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
749 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
750 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
751 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
752 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
753 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
754 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
755 const float vel1Term = f_1 + f_11 + f_15 + f_7;
756 const float momdensity_1 =
757 -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
758 const float vel2Term = f_12 + f_13 + f_5;
759 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 +
760 vel0Term + vel1Term + vel2Term;
761 const float momdensity_2 =
762 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
763 const float rho = delta_rho + 1;
766 const float conversion =
float{1} / rho;
768 velocity[0u] = momdensity_0 * conversion;
769 velocity[1u] = momdensity_1 * conversion;
770 velocity[2u] = momdensity_2 * conversion;
782inline auto get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
783 GhostLayerField<float, uint_t{3u}>
const *force_field,
785 const float &xyz0 = pdf_field->get(cell, uint_t{0u});
786 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
787 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
788 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
789 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
790 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
791 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
792 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
793 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
794 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
795 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
796 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
797 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
798 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
799 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
800 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
801 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
802 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
803 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
804 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
805 const auto x = cell.x();
806 const auto y = cell.y();
807 const auto z = cell.z();
808 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
809 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
810 const float vel1Term = f_1 + f_11 + f_15 + f_7;
811 const float momdensity_1 = -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
812 const float vel2Term = f_12 + f_13 + f_5;
813 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 + vel0Term +
815 const float momdensity_2 =
816 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
817 const float rho = delta_rho + 1;
819 force_field->get(x, y, z, 0) * 0.50000000000000000f + momdensity_0;
821 force_field->get(x, y, z, 1) * 0.50000000000000000f + momdensity_1;
823 force_field->get(x, y, z, 2) * 0.50000000000000000f + momdensity_2;
824 const float rho_inv =
float{1} / rho;
826 return Vector3<float>(md_0 * rho_inv, md_1 * rho_inv, md_2 * rho_inv);
829inline auto get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
830 GhostLayerField<float, uint_t{3u}>
const *force_field,
831 CellInterval
const &ci) {
832 std::vector<float> out;
833 out.reserve(ci.numCells() * uint_t(3u));
834 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
835 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
836 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
837 const float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
838 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
839 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
840 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
841 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
842 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
843 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
844 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
845 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
846 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
847 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
848 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
849 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
850 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
851 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
852 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
853 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
854 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
855 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
856 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
857 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
858 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
859 const float vel1Term = f_1 + f_11 + f_15 + f_7;
860 const float momdensity_1 =
861 -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
862 const float vel2Term = f_12 + f_13 + f_5;
863 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 +
864 vel0Term + vel1Term + vel2Term;
865 const float momdensity_2 =
866 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
867 const float rho = delta_rho + 1;
869 force_field->get(x, y, z, 0) * 0.50000000000000000f + momdensity_0;
871 force_field->get(x, y, z, 1) * 0.50000000000000000f + momdensity_1;
873 force_field->get(x, y, z, 2) * 0.50000000000000000f + momdensity_2;
874 const float rho_inv =
float{1} / rho;
875 out.emplace_back(md_0 * rho_inv);
876 out.emplace_back(md_1 * rho_inv);
877 out.emplace_back(md_2 * rho_inv);
884inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
885 GhostLayerField<float, uint_t{3u}> *velocity_field,
886 GhostLayerField<float, uint_t{3u}>
const *force_field,
887 Vector3<float>
const &u,
Cell const &cell) {
888 const float &xyz0 = pdf_field->get(cell, uint_t{0u});
889 const float f_0 = pdf_field->getF(&xyz0, uint_t{0u});
890 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
891 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
892 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
893 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
894 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
895 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
896 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
897 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
898 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
899 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
900 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
901 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
902 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
903 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
904 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
905 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
906 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
907 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
908 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
909 const float vel1Term = f_1 + f_11 + f_15 + f_7;
910 const float vel2Term = f_12 + f_13 + f_5;
911 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 + vel0Term +
913 const float rho = delta_rho + 1;
915 const auto x = cell.x();
916 const auto y = cell.y();
917 const auto z = cell.z();
919 -force_field->get(x, y, z, 0) * 0.50000000000000000f / rho + u[0];
921 -force_field->get(x, y, z, 1) * 0.50000000000000000f / rho + u[1];
923 -force_field->get(x, y, z, 2) * 0.50000000000000000f / rho + u[2];
924 velocity_field->get(x, y, z, uint_t{0u}) = u[0u];
925 velocity_field->get(x, y, z, uint_t{1u}) = u[1u];
926 velocity_field->get(x, y, z, uint_t{2u}) = u[2u];
931inline void set(GhostLayerField<
float, uint_t{19u}> *pdf_field,
932 GhostLayerField<float, uint_t{3u}> *velocity_field,
933 GhostLayerField<float, uint_t{3u}>
const *force_field,
934 std::vector<float>
const &values, CellInterval
const &ci) {
935 assert(uint_c(values.size()) == ci.numCells() * uint_t(3u));
936 auto u = values.data();
937 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
938 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
939 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
940 float &pdf_xyz0 = pdf_field->get(x, y, z, uint_t{0u});
941 float &vel_xyz0 = velocity_field->get(x, y, z, uint_t{0u});
942 const float f_0 = pdf_field->getF(&pdf_xyz0, uint_t{0u});
943 const float f_1 = pdf_field->getF(&pdf_xyz0, uint_t{1u});
944 const float f_2 = pdf_field->getF(&pdf_xyz0, uint_t{2u});
945 const float f_3 = pdf_field->getF(&pdf_xyz0, uint_t{3u});
946 const float f_4 = pdf_field->getF(&pdf_xyz0, uint_t{4u});
947 const float f_5 = pdf_field->getF(&pdf_xyz0, uint_t{5u});
948 const float f_6 = pdf_field->getF(&pdf_xyz0, uint_t{6u});
949 const float f_7 = pdf_field->getF(&pdf_xyz0, uint_t{7u});
950 const float f_8 = pdf_field->getF(&pdf_xyz0, uint_t{8u});
951 const float f_9 = pdf_field->getF(&pdf_xyz0, uint_t{9u});
952 const float f_10 = pdf_field->getF(&pdf_xyz0, uint_t{10u});
953 const float f_11 = pdf_field->getF(&pdf_xyz0, uint_t{11u});
954 const float f_12 = pdf_field->getF(&pdf_xyz0, uint_t{12u});
955 const float f_13 = pdf_field->getF(&pdf_xyz0, uint_t{13u});
956 const float f_14 = pdf_field->getF(&pdf_xyz0, uint_t{14u});
957 const float f_15 = pdf_field->getF(&pdf_xyz0, uint_t{15u});
958 const float f_16 = pdf_field->getF(&pdf_xyz0, uint_t{16u});
959 const float f_17 = pdf_field->getF(&pdf_xyz0, uint_t{17u});
960 const float f_18 = pdf_field->getF(&pdf_xyz0, uint_t{18u});
961 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
962 const float vel1Term = f_1 + f_11 + f_15 + f_7;
963 const float vel2Term = f_12 + f_13 + f_5;
964 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 +
965 vel0Term + vel1Term + vel2Term;
966 const float rho = delta_rho + 1;
969 -force_field->get(x, y, z, 0) * 0.50000000000000000f / rho + u[0];
971 -force_field->get(x, y, z, 1) * 0.50000000000000000f / rho + u[1];
973 -force_field->get(x, y, z, 2) * 0.50000000000000000f / rho + u[2];
974 velocity_field->getF(&vel_xyz0, uint_t{0u}) = u[0u];
975 velocity_field->getF(&vel_xyz0, uint_t{1u}) = u[1u];
976 velocity_field->getF(&vel_xyz0, uint_t{2u}) = u[2u];
989inline void set(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
990 GhostLayerField<float, uint_t{3u}> *velocity_field,
991 GhostLayerField<float, uint_t{3u}> *force_field,
992 Vector3<float>
const &force,
float const density,
994 float const &pdf_xyz0 = pdf_field->get(cell, uint_t{0u});
995 float &vel_xyz0 = velocity_field->get(cell, uint_t{0u});
996 float &laf_xyz0 = force_field->get(cell, uint_t{0u});
997 const float f_0 = pdf_field->getF(&pdf_xyz0, uint_t{0u});
998 const float f_1 = pdf_field->getF(&pdf_xyz0, uint_t{1u});
999 const float f_2 = pdf_field->getF(&pdf_xyz0, uint_t{2u});
1000 const float f_3 = pdf_field->getF(&pdf_xyz0, uint_t{3u});
1001 const float f_4 = pdf_field->getF(&pdf_xyz0, uint_t{4u});
1002 const float f_5 = pdf_field->getF(&pdf_xyz0, uint_t{5u});
1003 const float f_6 = pdf_field->getF(&pdf_xyz0, uint_t{6u});
1004 const float f_7 = pdf_field->getF(&pdf_xyz0, uint_t{7u});
1005 const float f_8 = pdf_field->getF(&pdf_xyz0, uint_t{8u});
1006 const float f_9 = pdf_field->getF(&pdf_xyz0, uint_t{9u});
1007 const float f_10 = pdf_field->getF(&pdf_xyz0, uint_t{10u});
1008 const float f_11 = pdf_field->getF(&pdf_xyz0, uint_t{11u});
1009 const float f_12 = pdf_field->getF(&pdf_xyz0, uint_t{12u});
1010 const float f_13 = pdf_field->getF(&pdf_xyz0, uint_t{13u});
1011 const float f_14 = pdf_field->getF(&pdf_xyz0, uint_t{14u});
1012 const float f_15 = pdf_field->getF(&pdf_xyz0, uint_t{15u});
1013 const float f_16 = pdf_field->getF(&pdf_xyz0, uint_t{16u});
1014 const float f_17 = pdf_field->getF(&pdf_xyz0, uint_t{17u});
1015 const float f_18 = pdf_field->getF(&pdf_xyz0, uint_t{18u});
1016 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
1017 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
1018 const float vel1Term = f_1 + f_11 + f_15 + f_7;
1019 const float momdensity_1 = -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
1020 const float vel2Term = f_12 + f_13 + f_5;
1021 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 + vel0Term +
1022 vel1Term + vel2Term;
1023 const float momdensity_2 =
1024 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
1025 const float rho = delta_rho + 1;
1026 const float md_0 = momdensity_0 + force[0u] * 0.50000000000000000f /
density;
1027 const float md_1 = momdensity_1 + force[1u] * 0.50000000000000000f /
density;
1028 const float md_2 = momdensity_2 + force[2u] * 0.50000000000000000f /
density;
1029 auto const rho_inv =
float{1} / rho;
1031 force_field->getF(&laf_xyz0, uint_t{0u}) = force[0u] /
density;
1032 force_field->getF(&laf_xyz0, uint_t{1u}) = force[1u] /
density;
1033 force_field->getF(&laf_xyz0, uint_t{2u}) = force[2u] /
density;
1035 velocity_field->getF(&vel_xyz0, uint_t{0u}) = md_0 * rho_inv;
1036 velocity_field->getF(&vel_xyz0, uint_t{1u}) = md_1 * rho_inv;
1037 velocity_field->getF(&vel_xyz0, uint_t{2u}) = md_2 * rho_inv;
1040inline void set(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
1041 GhostLayerField<float, uint_t{3u}> *velocity_field,
1042 GhostLayerField<float, uint_t{3u}> *force_field,
1043 std::vector<float>
const &values,
float const density,
1044 CellInterval
const &ci) {
1045 assert(uint_c(values.size()) == ci.numCells() * uint_t(3u));
1046 auto force = values.data();
1047 auto const density_inv =
float{1} /
density;
1048 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
1049 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
1050 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
1051 float const &pdf_xyz0 = pdf_field->get(x, y, z, uint_t{0u});
1052 float &vel_xyz0 = velocity_field->get(x, y, z, uint_t{0u});
1053 float &laf_xyz0 = force_field->get(x, y, z, uint_t{0u});
1054 const float f_0 = pdf_field->getF(&pdf_xyz0, uint_t{0u});
1055 const float f_1 = pdf_field->getF(&pdf_xyz0, uint_t{1u});
1056 const float f_2 = pdf_field->getF(&pdf_xyz0, uint_t{2u});
1057 const float f_3 = pdf_field->getF(&pdf_xyz0, uint_t{3u});
1058 const float f_4 = pdf_field->getF(&pdf_xyz0, uint_t{4u});
1059 const float f_5 = pdf_field->getF(&pdf_xyz0, uint_t{5u});
1060 const float f_6 = pdf_field->getF(&pdf_xyz0, uint_t{6u});
1061 const float f_7 = pdf_field->getF(&pdf_xyz0, uint_t{7u});
1062 const float f_8 = pdf_field->getF(&pdf_xyz0, uint_t{8u});
1063 const float f_9 = pdf_field->getF(&pdf_xyz0, uint_t{9u});
1064 const float f_10 = pdf_field->getF(&pdf_xyz0, uint_t{10u});
1065 const float f_11 = pdf_field->getF(&pdf_xyz0, uint_t{11u});
1066 const float f_12 = pdf_field->getF(&pdf_xyz0, uint_t{12u});
1067 const float f_13 = pdf_field->getF(&pdf_xyz0, uint_t{13u});
1068 const float f_14 = pdf_field->getF(&pdf_xyz0, uint_t{14u});
1069 const float f_15 = pdf_field->getF(&pdf_xyz0, uint_t{15u});
1070 const float f_16 = pdf_field->getF(&pdf_xyz0, uint_t{16u});
1071 const float f_17 = pdf_field->getF(&pdf_xyz0, uint_t{17u});
1072 const float f_18 = pdf_field->getF(&pdf_xyz0, uint_t{18u});
1073 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
1074 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
1075 const float vel1Term = f_1 + f_11 + f_15 + f_7;
1076 const float momdensity_1 =
1077 -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
1078 const float vel2Term = f_12 + f_13 + f_5;
1079 const float delta_rho = f_0 + f_16 + f_17 + f_2 + f_3 + f_6 + f_9 +
1080 vel0Term + vel1Term + vel2Term;
1081 const float momdensity_2 =
1082 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
1083 const float rho = delta_rho + 1;
1085 momdensity_0 + force[0u] * 0.50000000000000000f /
density;
1087 momdensity_1 + force[1u] * 0.50000000000000000f /
density;
1089 momdensity_2 + force[2u] * 0.50000000000000000f /
density;
1090 auto const rho_inv =
float{1} / rho;
1092 force_field->getF(&laf_xyz0, uint_t{0u}) = force[0u] * density_inv;
1093 force_field->getF(&laf_xyz0, uint_t{1u}) = force[1u] * density_inv;
1094 force_field->getF(&laf_xyz0, uint_t{2u}) = force[2u] * density_inv;
1096 velocity_field->getF(&vel_xyz0, uint_t{0u}) = md_0 * rho_inv;
1097 velocity_field->getF(&vel_xyz0, uint_t{1u}) = md_1 * rho_inv;
1098 velocity_field->getF(&vel_xyz0, uint_t{2u}) = md_2 * rho_inv;
1100 std::advance(force, 3);
1108inline auto reduce(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
1109 GhostLayerField<float, uint_t{3u}>
const *force_field,
1111 Vector3<float> momentumDensity(
float{0});
1112 for (
auto z = 0; z < pdf_field->zSize(); ++z) {
1113 for (
auto y = 0; y < pdf_field->ySize(); ++y) {
1114 for (
auto x = 0; x < pdf_field->xSize(); ++x) {
1115 const float &xyz0 = pdf_field->get(x, y, z, uint_t{0u});
1116 const float f_1 = pdf_field->getF(&xyz0, uint_t{1u});
1117 const float f_2 = pdf_field->getF(&xyz0, uint_t{2u});
1118 const float f_3 = pdf_field->getF(&xyz0, uint_t{3u});
1119 const float f_4 = pdf_field->getF(&xyz0, uint_t{4u});
1120 const float f_5 = pdf_field->getF(&xyz0, uint_t{5u});
1121 const float f_6 = pdf_field->getF(&xyz0, uint_t{6u});
1122 const float f_7 = pdf_field->getF(&xyz0, uint_t{7u});
1123 const float f_8 = pdf_field->getF(&xyz0, uint_t{8u});
1124 const float f_9 = pdf_field->getF(&xyz0, uint_t{9u});
1125 const float f_10 = pdf_field->getF(&xyz0, uint_t{10u});
1126 const float f_11 = pdf_field->getF(&xyz0, uint_t{11u});
1127 const float f_12 = pdf_field->getF(&xyz0, uint_t{12u});
1128 const float f_13 = pdf_field->getF(&xyz0, uint_t{13u});
1129 const float f_14 = pdf_field->getF(&xyz0, uint_t{14u});
1130 const float f_15 = pdf_field->getF(&xyz0, uint_t{15u});
1131 const float f_16 = pdf_field->getF(&xyz0, uint_t{16u});
1132 const float f_17 = pdf_field->getF(&xyz0, uint_t{17u});
1133 const float f_18 = pdf_field->getF(&xyz0, uint_t{18u});
1134 const float vel0Term = f_10 + f_14 + f_18 + f_4 + f_8;
1135 const float momdensity_0 = -f_13 - f_17 - f_3 - f_7 - f_9 + vel0Term;
1136 const float vel1Term = f_1 + f_11 + f_15 + f_7;
1137 const float momdensity_1 =
1138 -f_10 - f_12 - f_16 - f_2 + f_8 - f_9 + vel1Term;
1139 const float vel2Term = f_12 + f_13 + f_5;
1140 const float momdensity_2 =
1141 f_11 + f_14 - f_15 - f_16 - f_17 - f_18 - f_6 + vel2Term;
1143 force_field->get(x, y, z, 0) * 0.50000000000000000f + momdensity_0;
1145 force_field->get(x, y, z, 1) * 0.50000000000000000f + momdensity_1;
1147 force_field->get(x, y, z, 2) * 0.50000000000000000f + momdensity_2;
1149 momentumDensity[0u] += md_0 *
density;
1150 momentumDensity[1u] += md_1 *
density;
1151 momentumDensity[2u] += md_2 *
density;
1155 return momentumDensity;
1160inline auto get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
1162 const int x = cell[0];
1163 const int y = cell[1];
1164 const int z = cell[2];
1165 const float f_1 = pdf_field->get(0 + x, -1 + y, 0 + z, uint_t{1u});
1166 const float f_2 = pdf_field->get(0 + x, 1 + y, 0 + z, uint_t{2u});
1167 const float f_3 = pdf_field->get(1 + x, 0 + y, 0 + z, uint_t{3u});
1168 const float f_4 = pdf_field->get(-1 + x, 0 + y, 0 + z, uint_t{4u});
1169 const float f_5 = pdf_field->get(0 + x, 0 + y, -1 + z, uint_t{5u});
1170 const float f_6 = pdf_field->get(0 + x, 0 + y, 1 + z, uint_t{6u});
1171 const float f_7 = pdf_field->get(1 + x, -1 + y, 0 + z, uint_t{7u});
1172 const float f_8 = pdf_field->get(-1 + x, -1 + y, 0 + z, uint_t{8u});
1173 const float f_9 = pdf_field->get(1 + x, 1 + y, 0 + z, uint_t{9u});
1174 const float f_10 = pdf_field->get(-1 + x, 1 + y, 0 + z, uint_t{10u});
1175 const float f_11 = pdf_field->get(0 + x, -1 + y, -1 + z, uint_t{11u});
1176 const float f_12 = pdf_field->get(0 + x, 1 + y, -1 + z, uint_t{12u});
1177 const float f_13 = pdf_field->get(1 + x, 0 + y, -1 + z, uint_t{13u});
1178 const float f_14 = pdf_field->get(-1 + x, 0 + y, -1 + z, uint_t{14u});
1179 const float f_15 = pdf_field->get(0 + x, -1 + y, 1 + z, uint_t{15u});
1180 const float f_16 = pdf_field->get(0 + x, 1 + y, 1 + z, uint_t{16u});
1181 const float f_17 = pdf_field->get(1 + x, 0 + y, 1 + z, uint_t{17u});
1182 const float f_18 = pdf_field->get(-1 + x, 0 + y, 1 + z, uint_t{18u});
1183 const float p_0 = f_10 + f_13 + f_14 + f_17 + f_18 + f_3 + f_4 + f_7 + f_8 +
1184 f_9 + 0.33333333333333333f;
1185 const float p_1 = -f_10 - f_7 + f_8 + f_9;
1186 const float p_2 = -f_13 + f_14 + f_17 - f_18;
1187 const float p_3 = -f_10 - f_7 + f_8 + f_9;
1188 const float p_4 = f_1 + f_10 + f_11 + f_12 + f_15 + f_16 + f_2 + f_7 + f_8 +
1189 f_9 + 0.33333333333333333f;
1190 const float p_5 = f_11 - f_12 - f_15 + f_16;
1191 const float p_6 = -f_13 + f_14 + f_17 - f_18;
1192 const float p_7 = f_11 - f_12 - f_15 + f_16;
1193 const float p_8 = f_11 + f_12 + f_13 + f_14 + f_15 + f_16 + f_17 + f_18 +
1194 f_5 + f_6 + 0.33333333333333333f;
1196 Matrix3<float> pressureTensor;
1197 pressureTensor[0u] = p_0;
1198 pressureTensor[1u] = p_1;
1199 pressureTensor[2u] = p_2;
1201 pressureTensor[3u] = p_3;
1202 pressureTensor[4u] = p_4;
1203 pressureTensor[5u] = p_5;
1205 pressureTensor[6u] = p_6;
1206 pressureTensor[7u] = p_7;
1207 pressureTensor[8u] = p_8;
1209 return pressureTensor *
density;
1212inline auto get(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
1213 float const density, CellInterval
const &ci) {
1214 std::vector<float> out;
1215 out.reserve(ci.numCells() * uint_t(9u));
1216 for (
auto x = ci.xMin(); x <= ci.xMax(); ++x) {
1217 for (
auto y = ci.yMin(); y <= ci.yMax(); ++y) {
1218 for (
auto z = ci.zMin(); z <= ci.zMax(); ++z) {
1219 const float f_1 = pdf_field->get(0 + x, -1 + y, 0 + z, uint_t{1u});
1220 const float f_2 = pdf_field->get(0 + x, 1 + y, 0 + z, uint_t{2u});
1221 const float f_3 = pdf_field->get(1 + x, 0 + y, 0 + z, uint_t{3u});
1222 const float f_4 = pdf_field->get(-1 + x, 0 + y, 0 + z, uint_t{4u});
1223 const float f_5 = pdf_field->get(0 + x, 0 + y, -1 + z, uint_t{5u});
1224 const float f_6 = pdf_field->get(0 + x, 0 + y, 1 + z, uint_t{6u});
1225 const float f_7 = pdf_field->get(1 + x, -1 + y, 0 + z, uint_t{7u});
1226 const float f_8 = pdf_field->get(-1 + x, -1 + y, 0 + z, uint_t{8u});
1227 const float f_9 = pdf_field->get(1 + x, 1 + y, 0 + z, uint_t{9u});
1228 const float f_10 = pdf_field->get(-1 + x, 1 + y, 0 + z, uint_t{10u});
1229 const float f_11 = pdf_field->get(0 + x, -1 + y, -1 + z, uint_t{11u});
1230 const float f_12 = pdf_field->get(0 + x, 1 + y, -1 + z, uint_t{12u});
1231 const float f_13 = pdf_field->get(1 + x, 0 + y, -1 + z, uint_t{13u});
1232 const float f_14 = pdf_field->get(-1 + x, 0 + y, -1 + z, uint_t{14u});
1233 const float f_15 = pdf_field->get(0 + x, -1 + y, 1 + z, uint_t{15u});
1234 const float f_16 = pdf_field->get(0 + x, 1 + y, 1 + z, uint_t{16u});
1235 const float f_17 = pdf_field->get(1 + x, 0 + y, 1 + z, uint_t{17u});
1236 const float f_18 = pdf_field->get(-1 + x, 0 + y, 1 + z, uint_t{18u});
1237 const float p_0 = f_10 + f_13 + f_14 + f_17 + f_18 + f_3 + f_4 + f_7 +
1238 f_8 + f_9 + 0.33333333333333333f;
1239 const float p_1 = -f_10 - f_7 + f_8 + f_9;
1240 const float p_2 = -f_13 + f_14 + f_17 - f_18;
1241 const float p_3 = -f_10 - f_7 + f_8 + f_9;
1242 const float p_4 = f_1 + f_10 + f_11 + f_12 + f_15 + f_16 + f_2 + f_7 +
1243 f_8 + f_9 + 0.33333333333333333f;
1244 const float p_5 = f_11 - f_12 - f_15 + f_16;
1245 const float p_6 = -f_13 + f_14 + f_17 - f_18;
1246 const float p_7 = f_11 - f_12 - f_15 + f_16;
1247 const float p_8 = f_11 + f_12 + f_13 + f_14 + f_15 + f_16 + f_17 +
1248 f_18 + f_5 + f_6 + 0.33333333333333333f;
1250 out.emplace_back(p_0 *
density);
1251 out.emplace_back(p_1 *
density);
1252 out.emplace_back(p_2 *
density);
1254 out.emplace_back(p_3 *
density);
1255 out.emplace_back(p_4 *
density);
1256 out.emplace_back(p_5 *
density);
1258 out.emplace_back(p_6 *
density);
1259 out.emplace_back(p_7 *
density);
1260 out.emplace_back(p_8 *
density);
1267inline auto reduce(GhostLayerField<
float, uint_t{19u}>
const *pdf_field,
1269 Matrix3<float> pressureTensor(
float{0});
1270 for (
auto z = 0; z < pdf_field->zSize(); ++z) {
1271 for (
auto y = 0; y < pdf_field->ySize(); ++y) {
1272 for (
auto x = 0; x < pdf_field->xSize(); ++x) {
1273 const float f_1 = pdf_field->get(0 + x, -1 + y, 0 + z, uint_t{1u});
1274 const float f_2 = pdf_field->get(0 + x, 1 + y, 0 + z, uint_t{2u});
1275 const float f_3 = pdf_field->get(1 + x, 0 + y, 0 + z, uint_t{3u});
1276 const float f_4 = pdf_field->get(-1 + x, 0 + y, 0 + z, uint_t{4u});
1277 const float f_5 = pdf_field->get(0 + x, 0 + y, -1 + z, uint_t{5u});
1278 const float f_6 = pdf_field->get(0 + x, 0 + y, 1 + z, uint_t{6u});
1279 const float f_7 = pdf_field->get(1 + x, -1 + y, 0 + z, uint_t{7u});
1280 const float f_8 = pdf_field->get(-1 + x, -1 + y, 0 + z, uint_t{8u});
1281 const float f_9 = pdf_field->get(1 + x, 1 + y, 0 + z, uint_t{9u});
1282 const float f_10 = pdf_field->get(-1 + x, 1 + y, 0 + z, uint_t{10u});
1283 const float f_11 = pdf_field->get(0 + x, -1 + y, -1 + z, uint_t{11u});
1284 const float f_12 = pdf_field->get(0 + x, 1 + y, -1 + z, uint_t{12u});
1285 const float f_13 = pdf_field->get(1 + x, 0 + y, -1 + z, uint_t{13u});
1286 const float f_14 = pdf_field->get(-1 + x, 0 + y, -1 + z, uint_t{14u});
1287 const float f_15 = pdf_field->get(0 + x, -1 + y, 1 + z, uint_t{15u});
1288 const float f_16 = pdf_field->get(0 + x, 1 + y, 1 + z, uint_t{16u});
1289 const float f_17 = pdf_field->get(1 + x, 0 + y, 1 + z, uint_t{17u});
1290 const float f_18 = pdf_field->get(-1 + x, 0 + y, 1 + z, uint_t{18u});
1291 const float p_0 = f_10 + f_13 + f_14 + f_17 + f_18 + f_3 + f_4 + f_7 +
1292 f_8 + f_9 + 0.33333333333333333f;
1293 const float p_1 = -f_10 - f_7 + f_8 + f_9;
1294 const float p_2 = -f_13 + f_14 + f_17 - f_18;
1295 const float p_3 = -f_10 - f_7 + f_8 + f_9;
1296 const float p_4 = f_1 + f_10 + f_11 + f_12 + f_15 + f_16 + f_2 + f_7 +
1297 f_8 + f_9 + 0.33333333333333333f;
1298 const float p_5 = f_11 - f_12 - f_15 + f_16;
1299 const float p_6 = -f_13 + f_14 + f_17 - f_18;
1300 const float p_7 = f_11 - f_12 - f_15 + f_16;
1301 const float p_8 = f_11 + f_12 + f_13 + f_14 + f_15 + f_16 + f_17 +
1302 f_18 + f_5 + f_6 + 0.33333333333333333f;
1304 pressureTensor[0u] += p_0;
1305 pressureTensor[1u] += p_1;
1306 pressureTensor[2u] += p_2;
1308 pressureTensor[3u] += p_3;
1309 pressureTensor[4u] += p_4;
1310 pressureTensor[5u] += p_5;
1312 pressureTensor[6u] += p_6;
1313 pressureTensor[7u] += p_7;
1314 pressureTensor[8u] += p_8;
1318 return pressureTensor *
density;