ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
Dynamic_UBB_single_precisionCUDA.h
Go to the documentation of this file.
1//======================================================================================================================
2//
3// This file is part of waLBerla. waLBerla is free software: you can
4// redistribute it and/or modify it under the terms of the GNU General Public
5// License as published by the Free Software Foundation, either version 3 of
6// the License, or (at your option) any later version.
7//
8// waLBerla is distributed in the hope that it will be useful, but WITHOUT
9// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11// for more details.
12//
13// You should have received a copy of the GNU General Public License along
14// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
15//
16//! \\file Dynamic_UBB_single_precisionCUDA.h
17//! \\author pystencils
18//======================================================================================================================
19
20// kernel generated with pystencils v1.3.3, lbmpy v1.3.3,
21// lbmpy_walberla/pystencils_walberla from waLBerla commit
22// b0842e1a493ce19ef1bbb8d2cf382fc343970a7f
23
24#pragma once
25#include "core/DataTypes.h"
26#include "core/logging/Logging.h"
27
28#include "blockforest/StructuredBlockForest.h"
29#include "core/debug/Debug.h"
30#include "domain_decomposition/BlockDataID.h"
31#include "domain_decomposition/IBlock.h"
32#include "field/FlagField.h"
33#include "gpu/FieldCopy.h"
34#include "gpu/GPUField.h"
35#include "gpu/GPUWrapper.h"
36
37#include <set>
38#include <vector>
39
40#ifdef __GNUC__
41#define RESTRICT __restrict__
42#elif _MSC_VER
43#define RESTRICT __restrict
44#else
45#define RESTRICT
46#endif
47
48#ifdef WALBERLA_BUILD_WITH_HALF_PRECISION_SUPPORT
49using walberla::half;
50#endif
51
52namespace walberla {
53namespace lbm {
54
56public:
57 struct IndexInfo {
58 int32_t x;
59 int32_t y;
60 int32_t z;
61 int32_t dir;
62 float vel_0;
63 float vel_1;
64 float vel_2;
65 IndexInfo(int32_t x_, int32_t y_, int32_t z_, int32_t dir_)
66 : x(x_), y(y_), z(z_), dir(dir_), vel_0(), vel_1(), vel_2() {}
67 bool operator==(const IndexInfo &o) const {
68 return x == o.x && y == o.y && z == o.z && dir == o.dir &&
69 floatIsEqual(vel_0, o.vel_0) && floatIsEqual(vel_1, o.vel_1) &&
70 floatIsEqual(vel_2, o.vel_2);
71 }
72 };
73
75 public:
76 using CpuIndexVector = std::vector<IndexInfo>;
77
78 enum Type { ALL = 0, INNER = 1, OUTER = 2, NUM_TYPES = 3 };
79
80 IndexVectors() = default;
81 bool operator==(IndexVectors const &other) const {
82 return other.cpuVectors_ == cpuVectors_;
83 }
84
86 for (auto &gpuVec : gpuVectors_)
87 WALBERLA_GPU_CHECK(gpuFree(gpuVec));
88 }
89 CpuIndexVector &indexVector(Type t) { return cpuVectors_[t]; }
90 IndexInfo *pointerCpu(Type t) { return cpuVectors_[t].data(); }
91
92 IndexInfo *pointerGpu(Type t) { return gpuVectors_[t]; }
93 void syncGPU() {
94 for (auto &gpuVec : gpuVectors_)
95 WALBERLA_GPU_CHECK(gpuFree(gpuVec));
96 gpuVectors_.resize(cpuVectors_.size());
97
98 WALBERLA_ASSERT_EQUAL(cpuVectors_.size(), NUM_TYPES);
99 for (size_t i = 0; i < cpuVectors_.size(); ++i) {
100 auto &gpuVec = gpuVectors_[i];
101 auto &cpuVec = cpuVectors_[i];
102 WALBERLA_GPU_CHECK(
103 gpuMalloc(&gpuVec, sizeof(IndexInfo) * cpuVec.size()));
104 WALBERLA_GPU_CHECK(gpuMemcpy(gpuVec, &cpuVec[0],
105 sizeof(IndexInfo) * cpuVec.size(),
106 gpuMemcpyHostToDevice));
107 }
108 }
109
110 private:
111 std::vector<CpuIndexVector> cpuVectors_{NUM_TYPES};
112
113 using GpuIndexVector = IndexInfo *;
114 std::vector<GpuIndexVector> gpuVectors_;
115 };
116
118 const shared_ptr<StructuredBlockForest> &blocks, BlockDataID pdfsID_,
119 std::function<Vector3<float>(const Cell &,
120 const shared_ptr<StructuredBlockForest> &,
121 IBlock &)> &velocityCallback)
122 : elementInitialiser(velocityCallback), pdfsID(pdfsID_) {
123 auto createIdxVector = [](IBlock *const, StructuredBlockStorage *const) {
124 return new IndexVectors();
125 };
126 indexVectorID = blocks->addStructuredBlockData<IndexVectors>(
127 createIdxVector, "IndexField_Dynamic_UBB_single_precisionCUDA");
128 };
129
130 void run(IBlock *block, gpuStream_t stream = nullptr);
131
132 void operator()(IBlock *block, gpuStream_t stream = nullptr) {
133 run(block, stream);
134 }
135
136 void inner(IBlock *block, gpuStream_t stream = nullptr);
137
138 void outer(IBlock *block, gpuStream_t stream = nullptr);
139
140 std::function<void(IBlock *)> getSweep(gpuStream_t stream = nullptr) {
141 return [this, stream](IBlock *b) { this->run(b, stream); };
142 }
143
144 std::function<void(IBlock *)> getInnerSweep(gpuStream_t stream = nullptr) {
145 return [this, stream](IBlock *b) { this->inner(b, stream); };
146 }
147
148 std::function<void(IBlock *)> getOuterSweep(gpuStream_t stream = nullptr) {
149 return [this, stream](IBlock *b) { this->outer(b, stream); };
150 }
151
152 template <typename FlagField_T>
153 void fillFromFlagField(const shared_ptr<StructuredBlockForest> &blocks,
154 ConstBlockDataID flagFieldID, FlagUID boundaryFlagUID,
155 FlagUID domainFlagUID) {
156 for (auto blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt)
157 fillFromFlagField<FlagField_T>(blocks, &*blockIt, flagFieldID,
158 boundaryFlagUID, domainFlagUID);
159 }
160
161 template <typename FlagField_T>
162 void fillFromFlagField(const shared_ptr<StructuredBlockForest> &blocks,
163 IBlock *block, ConstBlockDataID flagFieldID,
164 FlagUID boundaryFlagUID, FlagUID domainFlagUID) {
165 auto *indexVectors = block->getData<IndexVectors>(indexVectorID);
166 auto &indexVectorAll = indexVectors->indexVector(IndexVectors::ALL);
167 auto &indexVectorInner = indexVectors->indexVector(IndexVectors::INNER);
168 auto &indexVectorOuter = indexVectors->indexVector(IndexVectors::OUTER);
169
170 auto *flagField = block->getData<FlagField_T>(flagFieldID);
171
172 if (!(flagField->flagExists(boundaryFlagUID) &&
173 flagField->flagExists(domainFlagUID)))
174 return;
175
176 auto boundaryFlag = flagField->getFlag(boundaryFlagUID);
177 auto domainFlag = flagField->getFlag(domainFlagUID);
178
179 auto inner = flagField->xyzSize();
180 inner.expand(cell_idx_t(-1));
181
182 indexVectorAll.clear();
183 indexVectorInner.clear();
184 indexVectorOuter.clear();
185
186 for (auto it = flagField->beginWithGhostLayerXYZ(
187 cell_idx_c(flagField->nrOfGhostLayers() - 1));
188 it != flagField->end(); ++it) {
189 if (!isFlagSet(it, domainFlag))
190 continue;
191
192 if (isFlagSet(it.neighbor(0, 0, 0, 0), boundaryFlag)) {
193 auto element = IndexInfo(it.x(), it.y(), it.z(), 0);
194 auto const InitialisationAdditionalData = elementInitialiser(
195 Cell(it.x() + 0, it.y() + 0, it.z() + 0), blocks, *block);
196 element.vel_0 = InitialisationAdditionalData[0];
197 element.vel_1 = InitialisationAdditionalData[1];
198 element.vel_2 = InitialisationAdditionalData[2];
199 indexVectorAll.push_back(element);
200 if (inner.contains(it.x(), it.y(), it.z()))
201 indexVectorInner.push_back(element);
202 else
203 indexVectorOuter.push_back(element);
204 }
205 }
206
207 for (auto it = flagField->beginWithGhostLayerXYZ(
208 cell_idx_c(flagField->nrOfGhostLayers() - 1));
209 it != flagField->end(); ++it) {
210 if (!isFlagSet(it, domainFlag))
211 continue;
212
213 if (isFlagSet(it.neighbor(0, 1, 0, 0), boundaryFlag)) {
214 auto element = IndexInfo(it.x(), it.y(), it.z(), 1);
215 auto const InitialisationAdditionalData = elementInitialiser(
216 Cell(it.x() + 0, it.y() + 1, it.z() + 0), blocks, *block);
217 element.vel_0 = InitialisationAdditionalData[0];
218 element.vel_1 = InitialisationAdditionalData[1];
219 element.vel_2 = InitialisationAdditionalData[2];
220 indexVectorAll.push_back(element);
221 if (inner.contains(it.x(), it.y(), it.z()))
222 indexVectorInner.push_back(element);
223 else
224 indexVectorOuter.push_back(element);
225 }
226 }
227
228 for (auto it = flagField->beginWithGhostLayerXYZ(
229 cell_idx_c(flagField->nrOfGhostLayers() - 1));
230 it != flagField->end(); ++it) {
231 if (!isFlagSet(it, domainFlag))
232 continue;
233
234 if (isFlagSet(it.neighbor(0, -1, 0, 0), boundaryFlag)) {
235 auto element = IndexInfo(it.x(), it.y(), it.z(), 2);
236 auto const InitialisationAdditionalData = elementInitialiser(
237 Cell(it.x() + 0, it.y() - 1, it.z() + 0), blocks, *block);
238 element.vel_0 = InitialisationAdditionalData[0];
239 element.vel_1 = InitialisationAdditionalData[1];
240 element.vel_2 = InitialisationAdditionalData[2];
241 indexVectorAll.push_back(element);
242 if (inner.contains(it.x(), it.y(), it.z()))
243 indexVectorInner.push_back(element);
244 else
245 indexVectorOuter.push_back(element);
246 }
247 }
248
249 for (auto it = flagField->beginWithGhostLayerXYZ(
250 cell_idx_c(flagField->nrOfGhostLayers() - 1));
251 it != flagField->end(); ++it) {
252 if (!isFlagSet(it, domainFlag))
253 continue;
254
255 if (isFlagSet(it.neighbor(-1, 0, 0, 0), boundaryFlag)) {
256 auto element = IndexInfo(it.x(), it.y(), it.z(), 3);
257 auto const InitialisationAdditionalData = elementInitialiser(
258 Cell(it.x() - 1, it.y() + 0, it.z() + 0), blocks, *block);
259 element.vel_0 = InitialisationAdditionalData[0];
260 element.vel_1 = InitialisationAdditionalData[1];
261 element.vel_2 = InitialisationAdditionalData[2];
262 indexVectorAll.push_back(element);
263 if (inner.contains(it.x(), it.y(), it.z()))
264 indexVectorInner.push_back(element);
265 else
266 indexVectorOuter.push_back(element);
267 }
268 }
269
270 for (auto it = flagField->beginWithGhostLayerXYZ(
271 cell_idx_c(flagField->nrOfGhostLayers() - 1));
272 it != flagField->end(); ++it) {
273 if (!isFlagSet(it, domainFlag))
274 continue;
275
276 if (isFlagSet(it.neighbor(1, 0, 0, 0), boundaryFlag)) {
277 auto element = IndexInfo(it.x(), it.y(), it.z(), 4);
278 auto const InitialisationAdditionalData = elementInitialiser(
279 Cell(it.x() + 1, it.y() + 0, it.z() + 0), blocks, *block);
280 element.vel_0 = InitialisationAdditionalData[0];
281 element.vel_1 = InitialisationAdditionalData[1];
282 element.vel_2 = InitialisationAdditionalData[2];
283 indexVectorAll.push_back(element);
284 if (inner.contains(it.x(), it.y(), it.z()))
285 indexVectorInner.push_back(element);
286 else
287 indexVectorOuter.push_back(element);
288 }
289 }
290
291 for (auto it = flagField->beginWithGhostLayerXYZ(
292 cell_idx_c(flagField->nrOfGhostLayers() - 1));
293 it != flagField->end(); ++it) {
294 if (!isFlagSet(it, domainFlag))
295 continue;
296
297 if (isFlagSet(it.neighbor(0, 0, 1, 0), boundaryFlag)) {
298 auto element = IndexInfo(it.x(), it.y(), it.z(), 5);
299 auto const InitialisationAdditionalData = elementInitialiser(
300 Cell(it.x() + 0, it.y() + 0, it.z() + 1), blocks, *block);
301 element.vel_0 = InitialisationAdditionalData[0];
302 element.vel_1 = InitialisationAdditionalData[1];
303 element.vel_2 = InitialisationAdditionalData[2];
304 indexVectorAll.push_back(element);
305 if (inner.contains(it.x(), it.y(), it.z()))
306 indexVectorInner.push_back(element);
307 else
308 indexVectorOuter.push_back(element);
309 }
310 }
311
312 for (auto it = flagField->beginWithGhostLayerXYZ(
313 cell_idx_c(flagField->nrOfGhostLayers() - 1));
314 it != flagField->end(); ++it) {
315 if (!isFlagSet(it, domainFlag))
316 continue;
317
318 if (isFlagSet(it.neighbor(0, 0, -1, 0), boundaryFlag)) {
319 auto element = IndexInfo(it.x(), it.y(), it.z(), 6);
320 auto const InitialisationAdditionalData = elementInitialiser(
321 Cell(it.x() + 0, it.y() + 0, it.z() - 1), blocks, *block);
322 element.vel_0 = InitialisationAdditionalData[0];
323 element.vel_1 = InitialisationAdditionalData[1];
324 element.vel_2 = InitialisationAdditionalData[2];
325 indexVectorAll.push_back(element);
326 if (inner.contains(it.x(), it.y(), it.z()))
327 indexVectorInner.push_back(element);
328 else
329 indexVectorOuter.push_back(element);
330 }
331 }
332
333 for (auto it = flagField->beginWithGhostLayerXYZ(
334 cell_idx_c(flagField->nrOfGhostLayers() - 1));
335 it != flagField->end(); ++it) {
336 if (!isFlagSet(it, domainFlag))
337 continue;
338
339 if (isFlagSet(it.neighbor(-1, 1, 0, 0), boundaryFlag)) {
340 auto element = IndexInfo(it.x(), it.y(), it.z(), 7);
341 auto const InitialisationAdditionalData = elementInitialiser(
342 Cell(it.x() - 1, it.y() + 1, it.z() + 0), blocks, *block);
343 element.vel_0 = InitialisationAdditionalData[0];
344 element.vel_1 = InitialisationAdditionalData[1];
345 element.vel_2 = InitialisationAdditionalData[2];
346 indexVectorAll.push_back(element);
347 if (inner.contains(it.x(), it.y(), it.z()))
348 indexVectorInner.push_back(element);
349 else
350 indexVectorOuter.push_back(element);
351 }
352 }
353
354 for (auto it = flagField->beginWithGhostLayerXYZ(
355 cell_idx_c(flagField->nrOfGhostLayers() - 1));
356 it != flagField->end(); ++it) {
357 if (!isFlagSet(it, domainFlag))
358 continue;
359
360 if (isFlagSet(it.neighbor(1, 1, 0, 0), boundaryFlag)) {
361 auto element = IndexInfo(it.x(), it.y(), it.z(), 8);
362 auto const InitialisationAdditionalData = elementInitialiser(
363 Cell(it.x() + 1, it.y() + 1, it.z() + 0), blocks, *block);
364 element.vel_0 = InitialisationAdditionalData[0];
365 element.vel_1 = InitialisationAdditionalData[1];
366 element.vel_2 = InitialisationAdditionalData[2];
367 indexVectorAll.push_back(element);
368 if (inner.contains(it.x(), it.y(), it.z()))
369 indexVectorInner.push_back(element);
370 else
371 indexVectorOuter.push_back(element);
372 }
373 }
374
375 for (auto it = flagField->beginWithGhostLayerXYZ(
376 cell_idx_c(flagField->nrOfGhostLayers() - 1));
377 it != flagField->end(); ++it) {
378 if (!isFlagSet(it, domainFlag))
379 continue;
380
381 if (isFlagSet(it.neighbor(-1, -1, 0, 0), boundaryFlag)) {
382 auto element = IndexInfo(it.x(), it.y(), it.z(), 9);
383 auto const InitialisationAdditionalData = elementInitialiser(
384 Cell(it.x() - 1, it.y() - 1, it.z() + 0), blocks, *block);
385 element.vel_0 = InitialisationAdditionalData[0];
386 element.vel_1 = InitialisationAdditionalData[1];
387 element.vel_2 = InitialisationAdditionalData[2];
388 indexVectorAll.push_back(element);
389 if (inner.contains(it.x(), it.y(), it.z()))
390 indexVectorInner.push_back(element);
391 else
392 indexVectorOuter.push_back(element);
393 }
394 }
395
396 for (auto it = flagField->beginWithGhostLayerXYZ(
397 cell_idx_c(flagField->nrOfGhostLayers() - 1));
398 it != flagField->end(); ++it) {
399 if (!isFlagSet(it, domainFlag))
400 continue;
401
402 if (isFlagSet(it.neighbor(1, -1, 0, 0), boundaryFlag)) {
403 auto element = IndexInfo(it.x(), it.y(), it.z(), 10);
404 auto const InitialisationAdditionalData = elementInitialiser(
405 Cell(it.x() + 1, it.y() - 1, it.z() + 0), blocks, *block);
406 element.vel_0 = InitialisationAdditionalData[0];
407 element.vel_1 = InitialisationAdditionalData[1];
408 element.vel_2 = InitialisationAdditionalData[2];
409 indexVectorAll.push_back(element);
410 if (inner.contains(it.x(), it.y(), it.z()))
411 indexVectorInner.push_back(element);
412 else
413 indexVectorOuter.push_back(element);
414 }
415 }
416
417 for (auto it = flagField->beginWithGhostLayerXYZ(
418 cell_idx_c(flagField->nrOfGhostLayers() - 1));
419 it != flagField->end(); ++it) {
420 if (!isFlagSet(it, domainFlag))
421 continue;
422
423 if (isFlagSet(it.neighbor(0, 1, 1, 0), boundaryFlag)) {
424 auto element = IndexInfo(it.x(), it.y(), it.z(), 11);
425 auto const InitialisationAdditionalData = elementInitialiser(
426 Cell(it.x() + 0, it.y() + 1, it.z() + 1), blocks, *block);
427 element.vel_0 = InitialisationAdditionalData[0];
428 element.vel_1 = InitialisationAdditionalData[1];
429 element.vel_2 = InitialisationAdditionalData[2];
430 indexVectorAll.push_back(element);
431 if (inner.contains(it.x(), it.y(), it.z()))
432 indexVectorInner.push_back(element);
433 else
434 indexVectorOuter.push_back(element);
435 }
436 }
437
438 for (auto it = flagField->beginWithGhostLayerXYZ(
439 cell_idx_c(flagField->nrOfGhostLayers() - 1));
440 it != flagField->end(); ++it) {
441 if (!isFlagSet(it, domainFlag))
442 continue;
443
444 if (isFlagSet(it.neighbor(0, -1, 1, 0), boundaryFlag)) {
445 auto element = IndexInfo(it.x(), it.y(), it.z(), 12);
446 auto const InitialisationAdditionalData = elementInitialiser(
447 Cell(it.x() + 0, it.y() - 1, it.z() + 1), blocks, *block);
448 element.vel_0 = InitialisationAdditionalData[0];
449 element.vel_1 = InitialisationAdditionalData[1];
450 element.vel_2 = InitialisationAdditionalData[2];
451 indexVectorAll.push_back(element);
452 if (inner.contains(it.x(), it.y(), it.z()))
453 indexVectorInner.push_back(element);
454 else
455 indexVectorOuter.push_back(element);
456 }
457 }
458
459 for (auto it = flagField->beginWithGhostLayerXYZ(
460 cell_idx_c(flagField->nrOfGhostLayers() - 1));
461 it != flagField->end(); ++it) {
462 if (!isFlagSet(it, domainFlag))
463 continue;
464
465 if (isFlagSet(it.neighbor(-1, 0, 1, 0), boundaryFlag)) {
466 auto element = IndexInfo(it.x(), it.y(), it.z(), 13);
467 auto const InitialisationAdditionalData = elementInitialiser(
468 Cell(it.x() - 1, it.y() + 0, it.z() + 1), blocks, *block);
469 element.vel_0 = InitialisationAdditionalData[0];
470 element.vel_1 = InitialisationAdditionalData[1];
471 element.vel_2 = InitialisationAdditionalData[2];
472 indexVectorAll.push_back(element);
473 if (inner.contains(it.x(), it.y(), it.z()))
474 indexVectorInner.push_back(element);
475 else
476 indexVectorOuter.push_back(element);
477 }
478 }
479
480 for (auto it = flagField->beginWithGhostLayerXYZ(
481 cell_idx_c(flagField->nrOfGhostLayers() - 1));
482 it != flagField->end(); ++it) {
483 if (!isFlagSet(it, domainFlag))
484 continue;
485
486 if (isFlagSet(it.neighbor(1, 0, 1, 0), boundaryFlag)) {
487 auto element = IndexInfo(it.x(), it.y(), it.z(), 14);
488 auto const InitialisationAdditionalData = elementInitialiser(
489 Cell(it.x() + 1, it.y() + 0, it.z() + 1), blocks, *block);
490 element.vel_0 = InitialisationAdditionalData[0];
491 element.vel_1 = InitialisationAdditionalData[1];
492 element.vel_2 = InitialisationAdditionalData[2];
493 indexVectorAll.push_back(element);
494 if (inner.contains(it.x(), it.y(), it.z()))
495 indexVectorInner.push_back(element);
496 else
497 indexVectorOuter.push_back(element);
498 }
499 }
500
501 for (auto it = flagField->beginWithGhostLayerXYZ(
502 cell_idx_c(flagField->nrOfGhostLayers() - 1));
503 it != flagField->end(); ++it) {
504 if (!isFlagSet(it, domainFlag))
505 continue;
506
507 if (isFlagSet(it.neighbor(0, 1, -1, 0), boundaryFlag)) {
508 auto element = IndexInfo(it.x(), it.y(), it.z(), 15);
509 auto const InitialisationAdditionalData = elementInitialiser(
510 Cell(it.x() + 0, it.y() + 1, it.z() - 1), blocks, *block);
511 element.vel_0 = InitialisationAdditionalData[0];
512 element.vel_1 = InitialisationAdditionalData[1];
513 element.vel_2 = InitialisationAdditionalData[2];
514 indexVectorAll.push_back(element);
515 if (inner.contains(it.x(), it.y(), it.z()))
516 indexVectorInner.push_back(element);
517 else
518 indexVectorOuter.push_back(element);
519 }
520 }
521
522 for (auto it = flagField->beginWithGhostLayerXYZ(
523 cell_idx_c(flagField->nrOfGhostLayers() - 1));
524 it != flagField->end(); ++it) {
525 if (!isFlagSet(it, domainFlag))
526 continue;
527
528 if (isFlagSet(it.neighbor(0, -1, -1, 0), boundaryFlag)) {
529 auto element = IndexInfo(it.x(), it.y(), it.z(), 16);
530 auto const InitialisationAdditionalData = elementInitialiser(
531 Cell(it.x() + 0, it.y() - 1, it.z() - 1), blocks, *block);
532 element.vel_0 = InitialisationAdditionalData[0];
533 element.vel_1 = InitialisationAdditionalData[1];
534 element.vel_2 = InitialisationAdditionalData[2];
535 indexVectorAll.push_back(element);
536 if (inner.contains(it.x(), it.y(), it.z()))
537 indexVectorInner.push_back(element);
538 else
539 indexVectorOuter.push_back(element);
540 }
541 }
542
543 for (auto it = flagField->beginWithGhostLayerXYZ(
544 cell_idx_c(flagField->nrOfGhostLayers() - 1));
545 it != flagField->end(); ++it) {
546 if (!isFlagSet(it, domainFlag))
547 continue;
548
549 if (isFlagSet(it.neighbor(-1, 0, -1, 0), boundaryFlag)) {
550 auto element = IndexInfo(it.x(), it.y(), it.z(), 17);
551 auto const InitialisationAdditionalData = elementInitialiser(
552 Cell(it.x() - 1, it.y() + 0, it.z() - 1), blocks, *block);
553 element.vel_0 = InitialisationAdditionalData[0];
554 element.vel_1 = InitialisationAdditionalData[1];
555 element.vel_2 = InitialisationAdditionalData[2];
556 indexVectorAll.push_back(element);
557 if (inner.contains(it.x(), it.y(), it.z()))
558 indexVectorInner.push_back(element);
559 else
560 indexVectorOuter.push_back(element);
561 }
562 }
563
564 for (auto it = flagField->beginWithGhostLayerXYZ(
565 cell_idx_c(flagField->nrOfGhostLayers() - 1));
566 it != flagField->end(); ++it) {
567 if (!isFlagSet(it, domainFlag))
568 continue;
569
570 if (isFlagSet(it.neighbor(1, 0, -1, 0), boundaryFlag)) {
571 auto element = IndexInfo(it.x(), it.y(), it.z(), 18);
572 auto const InitialisationAdditionalData = elementInitialiser(
573 Cell(it.x() + 1, it.y() + 0, it.z() - 1), blocks, *block);
574 element.vel_0 = InitialisationAdditionalData[0];
575 element.vel_1 = InitialisationAdditionalData[1];
576 element.vel_2 = InitialisationAdditionalData[2];
577 indexVectorAll.push_back(element);
578 if (inner.contains(it.x(), it.y(), it.z()))
579 indexVectorInner.push_back(element);
580 else
581 indexVectorOuter.push_back(element);
582 }
583 }
584
585 indexVectors->syncGPU();
586 }
587
588private:
589 void run_impl(IBlock *block, IndexVectors::Type type,
590 gpuStream_t stream = nullptr);
591
592 BlockDataID indexVectorID;
593 std::function<Vector3<float>(
594 const Cell &, const shared_ptr<StructuredBlockForest> &, IBlock &)>
595 elementInitialiser;
596
597public:
598 BlockDataID pdfsID;
599};
600
601} // namespace lbm
602} // namespace walberla
Definition Cell.hpp:97
void inner(IBlock *block, gpuStream_t stream=nullptr)
void outer(IBlock *block, gpuStream_t stream=nullptr)
void fillFromFlagField(const shared_ptr< StructuredBlockForest > &blocks, IBlock *block, ConstBlockDataID flagFieldID, FlagUID boundaryFlagUID, FlagUID domainFlagUID)
std::function< void(IBlock *)> getOuterSweep(gpuStream_t stream=nullptr)
void run(IBlock *block, gpuStream_t stream=nullptr)
std::function< void(IBlock *)> getSweep(gpuStream_t stream=nullptr)
void fillFromFlagField(const shared_ptr< StructuredBlockForest > &blocks, ConstBlockDataID flagFieldID, FlagUID boundaryFlagUID, FlagUID domainFlagUID)
void operator()(IBlock *block, gpuStream_t stream=nullptr)
Dynamic_UBB_single_precisionCUDA(const shared_ptr< StructuredBlockForest > &blocks, BlockDataID pdfsID_, std::function< Vector3< float >(const Cell &, const shared_ptr< StructuredBlockForest > &, IBlock &)> &velocityCallback)
std::function< void(IBlock *)> getInnerSweep(gpuStream_t stream=nullptr)
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
static double * block(double *p, std::size_t index, std::size_t size)
Definition elc.cpp:172
\file PackInfoPdfDoublePrecision.cpp \author pystencils