VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
Grid3D.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
34
35#include "Grid3D.h"
36
37#include <set>
38
41
42#include "Block3DVisitor.h"
43#include "D3Q27System.h"
44#include "Grid3DVisitor.h"
45#include "Interactor3D.h"
46#include "D3Q27System.h"
47#include <Block3D.h>
49#include "UbMath.h"
50
51using namespace std;
52
53Grid3D::Grid3D() { levelSet.resize(d3q27_system::MAXLEVEL + 1); }
55Grid3D::Grid3D(std::shared_ptr<vf::parallel::Communicator> comm)
56
57{
58 levelSet.resize(d3q27_system::MAXLEVEL + 1);
59 bundle = comm->getBundleID();
60 rank = comm->getProcessID();
61}
63Grid3D::Grid3D(std::shared_ptr<vf::parallel::Communicator> comm, int blockNx1, int blockNx2, int blockNx3, int gridNx1, int gridNx2, int gridNx3)
64 :
65
66 blockNx1(blockNx1), blockNx2(blockNx2), blockNx3(blockNx2), nx1(gridNx1), nx2(gridNx2), nx3(gridNx3)
67{
68 using namespace vf::basics::constant;
69
70 levelSet.resize(d3q27_system::MAXLEVEL + 1);
71 bundle = comm->getBundleID();
72 rank = comm->getProcessID();
73 trafo = std::make_shared<CoordinateTransformation3D>(c0o1, c0o1, c0o1, (real)blockNx1, (real)blockNx2,
74 (real)blockNx3);
75 UbTupleInt3 minInd(0, 0, 0);
77 this->fillExtentWithBlocks(minInd, maxInd);
78}
80void Grid3D::addInteractor(SPtr<Interactor3D> interactor) { interactors.push_back(interactor); }
83{
84 interactors.push_back(interactor);
85 interactor->initInteractor(timestep);
86}
91{
92 int startLevel = blockVisitor.getStartLevel();
93 int stopLevel = blockVisitor.getStopLevel();
94
95 if (startLevel < 0 || stopLevel < 0 || startLevel > d3q27_system::MAXLEVEL || stopLevel > d3q27_system::MAXLEVEL)
96 throw UbException(UB_EXARGS, "not valid level!");
97
98 bool dir = startLevel < stopLevel;
99 if (dir)
100 stopLevel += 1;
101 else
102 stopLevel -= 1;
103
104 //#pragma omp parallel
105 // {
106 // for (int l = startLevel; l!=stopLevel;)
107 // {
108 // std::vector<SPtr<Block3D>> blockVector;
109 // getBlocks(l, blockVector);
110 // int sizeb = (int)blockVector.size();
111 //
112 //#pragma omp for
113 // for (int i = 0; i < sizeb; i++)
114 // {
115 // blockVisitor.visit(shared_from_this(), blockVector[i]);
116 // }
117 // if (dir) l++;
118 // else l--;
119 // }
120 // }
121 for (int l = startLevel; l != stopLevel;) {
122 std::vector<SPtr<Block3D>> blockVector;
123 getBlocks(l, blockVector);
124 for (SPtr<Block3D> b : blockVector) {
126 }
127 if (dir)
128 l++;
129 else
130 l--;
131 }
132}
139{
140 if (block) {
141 this->blockIdMap.insert(std::make_pair(block->getGlobalID(), block));
142 int level = block->getLevel();
143 this->levelSet[level].insert(std::make_pair(Block3DKey(block->getX1(), block->getX2(), block->getX3()), block));
144 }
145}
148{
149 return this->deleteBlock(block->getX1(), block->getX2(), block->getX3(), block->getLevel());
150}
152bool Grid3D::deleteBlock(int ix1, int ix2, int ix3, int level)
153{
154 SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3, level);
155 if (block) {
156 this->blockIdMap.erase(block->getGlobalID());
157 return this->levelSet[level].erase(Block3DKey(ix1, ix2, ix3)) > 0;
158 } else {
159 return false;
160 }
161}
163{
164 std::vector<std::vector<SPtr<Block3D>>> blocksVector(25);
165 int minInitLevel = d3q27_system::MINLEVEL;
166 int maxInitLevel = d3q27_system::MAXLEVEL;
167 for (int level = minInitLevel; level < maxInitLevel; level++) {
168 getBlocks(level, blocksVector[level]);
169 for (SPtr<Block3D> block : blocksVector[level]) // blocks of the current level
170 deleteBlock(block);
171 }
172}
175{
176 if (block) {
177 this->deleteBlock(block);
178 this->addBlock(block);
179 }
180}
182SPtr<Block3D> Grid3D::getBlock(int ix1, int ix2, int ix3, int level) const
183{
184 if (!this->hasLevel(level))
185 return SPtr<Block3D>();
186
187 int N1 = (nx1 << level);
188 int N2 = (nx2 << level);
189 int N3 = (nx3 << level);
190
191 if (!this->isPeriodicX1() && (ix1 > N1 - 1 || ix1 < 0))
192 return SPtr<Block3D>();
193 else if (this->isPeriodicX1() && (ix1 >= N1 - 1 || ix1 < 0)) {
194 ix1 = ((ix1 % N1) + N1) % N1;
195 }
196 if (!this->isPeriodicX2() && (ix2 > N2 - 1 || ix2 < 0))
197 return SPtr<Block3D>();
198 else if (this->isPeriodicX2() && (ix2 >= N2 - 1 || ix2 < 0)) {
199 ix2 = ((ix2 % N2) + N2) % N2;
200 }
201 if (!this->isPeriodicX3() && (ix3 > N3 - 1 || ix3 < 0))
202 return SPtr<Block3D>();
203 else if (this->isPeriodicX3() && (ix3 >= N3 - 1 || ix3 < 0)) {
204 ix3 = ((ix3 % N3) + N3) % N3;
205 }
206
207 Block3DMap::const_iterator it;
208 it = levelSet[level].find(Block3DKey(ix1, ix2, ix3));
209 if (it == levelSet[level].end())
210 return SPtr<Block3D>();
211 else
212 return it->second;
213}
216{
217 BlockIDMap::const_iterator it;
218 if ((it = blockIdMap.find(id)) == blockIdMap.end()) {
219 return SPtr<Block3D>();
220 }
221
222 return it->second;
223}
228{
229 int ix1 = block->getX1();
230 int ix2 = block->getX2();
231 int ix3 = block->getX3();
232 int level = block->getLevel();
233 return getSuperBlock(ix1, ix2, ix3, level);
234}
236SPtr<Block3D> Grid3D::getSuperBlock(int ix1, int ix2, int ix3, int level)
237{
238 if (!this->hasLevel(level))
239 return SPtr<Block3D>();
240 if (level < 1)
241 throw UbException(UB_EXARGS, "level <1");
242
243 // from Lower Level to higher: >> 1 in x1,x2,x3
244 SPtr<Block3D> block;
245 for (int l = level - 1; l >= 0; l--) {
246 ix1 = ix1 >> 1;
247 ix2 = ix2 >> 1;
248 ix3 = ix3 >> 1;
249
250 block = this->getBlock(ix1, ix2, ix3, l);
251 if (block)
252 return block;
253 }
254 return SPtr<Block3D>();
255}
257void Grid3D::getSubBlocks(SPtr<Block3D> block, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
258{
259 int ix1 = block->getX1();
260 int ix2 = block->getX2();
261 int ix3 = block->getX3();
262 int level = block->getLevel();
263 getSubBlocks(ix1, ix2, ix3, level, levelDepth, blocks);
264}
266void Grid3D::getSubBlocks(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
267{
268 if (!this->getBlock(ix1, ix2, ix3, level))
269 return;
270 if (level > 0 && !this->getSuperBlock(ix1, ix2, ix3, level))
271 return;
272 if (level >= d3q27_system::MAXLEVEL)
273 throw UbException(UB_EXARGS, "Level bigger then MAXLEVEL");
274
275 int x1[] = { ix1 << 1, (ix1 << 1) + 1 };
276 int x2[] = { ix2 << 1, (ix2 << 1) + 1 };
277 int x3[] = { ix3 << 1, (ix3 << 1) + 1 };
278 int l = level + 1;
279
280 for (int i = 0; i < 2; i++)
281 for (int j = 0; j < 2; j++)
282 for (int k = 0; k < 2; k++) {
283 SPtr<Block3D> block = this->getBlock(x1[i], x2[j], x3[k], l);
284 if (block)
285 blocks.push_back(block);
286 else if (l < levelDepth)
287 this->getSubBlocks(x1[i], x2[j], x3[k], l, levelDepth, blocks);
288 }
289}
291bool Grid3D::expandBlock(int ix1, int ix2, int ix3, int level)
292{
293 this->checkLevel(level);
294
295 SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3, level);
296 if (!block)
297 throw UbException(UB_EXARGS, "block(x1=" + ub_system::toString(ix1) + ", x2=" + ub_system::toString(ix2) +
298 ", x3=" + ub_system::toString(ix3) + ", l=" + ub_system::toString(level) +
299 ") is not exist");
300
301 // da bei periodic der eigentliche block andere indizes hat:
302 ix1 = block->getX1();
303 ix2 = block->getX2();
304 ix3 = block->getX3();
305
306 int l = level + 1;
307 if (l > d3q27_system::MAXLEVEL)
308 throw UbException(UB_EXARGS, "level > Grid3D::MAXLEVEL");
309
310 int west = ix1 << 1;
311 int east = west + 1;
312 int south = ix2 << 1;
313 int north = south + 1;
314 int bottom = ix3 << 1;
315 int top = bottom + 1;
316
317 auto blockBSW = std::make_shared<Block3D>(west, south, bottom, l);
318 auto blockBSE = std::make_shared<Block3D>(east, south, bottom, l);
319 auto blockBNW = std::make_shared<Block3D>(west, north, bottom, l);
320 auto blockBNE = std::make_shared<Block3D>(east, north, bottom, l);
321 auto blockTSW = std::make_shared<Block3D>(west, south, top, l);
322 auto blockTSE = std::make_shared<Block3D>(east, south, top, l);
323 auto blockTNW = std::make_shared<Block3D>(west, north, top, l);
324 auto blockTNE = std::make_shared<Block3D>(east, north, top, l);
325
326 if (!this->deleteBlock(ix1, ix2, ix3, level))
327 throw UbException(UB_EXARGS, "could not delete block");
328
329 this->addBlock(blockBSW);
330 this->addBlock(blockBSE);
331 this->addBlock(blockBNW);
332 this->addBlock(blockBNE);
333 this->addBlock(blockTSW);
334 this->addBlock(blockTSE);
335 this->addBlock(blockTNW);
336 this->addBlock(blockTNE);
337
338 return true;
339}
341SPtr<Block3D> Grid3D::collapseBlock(int fix1, int fix2, int fix3, int flevel, int levelDepth)
342{
344
345 SPtr<Block3D> fblock = this->getBlock(fix1, fix2, fix3, flevel);
346 if (flevel < 1)
347 throw UbException(UB_EXARGS, "level of block (" + toString(fix1) + "," + toString(fix2) + "," + toString(fix3) +
348 "," + toString(flevel) + ") is < 1");
349 if (!fblock) {
350 throw UbException(UB_EXARGS, "specific block(" + toString(fix1) + "," + toString(fix2) + "," + toString(fix3) +
351 "," + toString(flevel) + ") doesn't exists");
352 }
353 if (!fblock->isActive())
354 throw UbException(UB_EXARGS, "block(" + toString(fix1) + "," + toString(fix2) + "," + toString(fix3) + "," +
355 toString(flevel) + ") is not active");
356
357 // da bei periodic der eigentliche block andere indizes hat:
358 fix1 = fblock->getX1();
359 fix2 = fblock->getX2();
360 fix3 = fblock->getX3();
361
362 int cix1 = fblock->getX1() >> 1;
363 int cix2 = fblock->getX2() >> 1;
364 int cix3 = fblock->getX3() >> 1;
365
366 int fx1[2] = { cix1 << 1, (cix1 << 1) + 1 };
367 int fx2[2] = { cix2 << 1, (cix2 << 1) + 1 };
368 int fx3[2] = { cix3 << 1, (cix3 << 1) + 1 };
369 int clevel = flevel - 1;
370
371 vector<SPtr<Block3D>> blocks;
372 for (int i = 0; i < 2; i++)
373 for (int k = 0; k < 2; k++)
374 for (int l = 0; l < 2; l++) {
375 this->getSubBlocks(fx1[k], fx2[i], fx3[l], flevel, levelDepth, blocks);
376 while (!blocks.empty()) {
377 // man muss nur eine von den moeglichen acht "collapsen", die anderen werden
378 // dann (rekursiv) collapsed, da die schleife oben alle vier abfragt
379 this->collapseBlock(blocks[0]->getX1(), blocks[0]->getX2(), blocks[0]->getX3(),
380 blocks[0]->getLevel(), levelDepth);
381 this->getSubBlocks(fx1[k], fx2[i], fx3[l], flevel, levelDepth, blocks);
382 }
383 }
384
386 /*BSW*/ fineBlocks[0] = this->getBlock(fx1[0], fx2[0], fx3[0], flevel);
387 /*BSE*/ fineBlocks[1] = this->getBlock(fx1[1], fx2[0], fx3[0], flevel);
388 /*BNE*/ fineBlocks[2] = this->getBlock(fx1[1], fx2[1], fx3[0], flevel);
389 /*BNW*/ fineBlocks[3] = this->getBlock(fx1[0], fx2[1], fx3[0], flevel);
390 /*TSW*/ fineBlocks[4] = this->getBlock(fx1[0], fx2[0], fx3[1], flevel);
391 /*TSE*/ fineBlocks[5] = this->getBlock(fx1[1], fx2[0], fx3[1], flevel);
392 /*TNE*/ fineBlocks[6] = this->getBlock(fx1[1], fx2[1], fx3[1], flevel);
393 /*TNW*/ fineBlocks[7] = this->getBlock(fx1[0], fx2[1], fx3[1], flevel);
394
395 auto cblock = std::make_shared<Block3D>(cix1, cix2, cix3, clevel);
396
397 for (int i = 0; i < 2; i++)
398 for (int k = 0; k < 2; k++)
399 for (int l = 0; l < 2; l++)
400 if (!this->deleteBlock(fx1[k], fx2[i], fx3[l], flevel))
401 throw UbException(UB_EXARGS, "could not delete block");
402
403 this->addBlock(cblock);
404
405 return cblock;
406}
408// TODO: make visitor for this
410{
411 for (Block3DMap blockMap : levelSet) {
412 for (Block3DMap::value_type b : blockMap) {
413 SPtr<Block3D> block = b.second;
414 block->deleteConnectors();
415 }
416 }
417}
419void Grid3D::setRank(int rank) { this->rank = rank; }
421int Grid3D::getRank() const { return rank; }
423int Grid3D::getBundle() const { return bundle; }
425void Grid3D::setBundle(int bundle) { this->bundle = bundle; }
427bool Grid3D::isPeriodicX1() const { return this->periodicX1; }
429bool Grid3D::isPeriodicX2() const { return this->periodicX2; }
431bool Grid3D::isPeriodicX3() const { return this->periodicX3; }
433void Grid3D::setPeriodicX1(bool value) { this->periodicX1 = value; }
435void Grid3D::setPeriodicX2(bool value) { this->periodicX2 = value; }
437void Grid3D::setPeriodicX3(bool value) { this->periodicX3 = value; }
440{
441 if (!trafo) {
442 return makeUbTuple((int)blockX1Coord, (int)blockX2Coord, (int)blockX3Coord);
443 }
444
445 return makeUbTuple((int)trafo->transformForwardToX1Coordinate(blockX1Coord, blockX2Coord, blockX3Coord),
446 (int)trafo->transformForwardToX2Coordinate(blockX1Coord, blockX2Coord, blockX3Coord),
447 (int)trafo->transformForwardToX3Coordinate(blockX1Coord, blockX2Coord, blockX3Coord));
448}
451{
452 if (!trafo) {
453 return makeUbTuple((int)blockX1Coord, (int)blockX2Coord, (int)blockX3Coord);
454 }
455
456 real dx = getDeltaX(level);
458 blockLentghX1 = blockNx1 * dx;
459 blockLentghX2 = blockNx2 * dx;
460 blockLentghX3 = blockNx3 * dx;
462
465
466 if (!trafo_temp) {
467 return makeUbTuple((int)blockX1Coord, (int)blockX2Coord, (int)blockX3Coord);
468 }
469
470 return makeUbTuple((int)trafo_temp->transformForwardToX1Coordinate(blockX1Coord, blockX2Coord, blockX3Coord),
471 (int)trafo_temp->transformForwardToX2Coordinate(blockX1Coord, blockX2Coord, blockX3Coord),
472 (int)trafo_temp->transformForwardToX3Coordinate(blockX1Coord, blockX2Coord, blockX3Coord));
473}
476{
477 int level = block->getLevel();
478 real delta = 1.0 / (real)(1 << level);
479
480 if (!trafo)
481 makeUbTuple<real, real, real>(delta, delta, delta);
482
483 return makeUbTuple(trafo->getX1CoordinateScaling() * delta, trafo->getX2CoordinateScaling() * delta,
484 trafo->getX3CoordinateScaling() * delta);
485}
487using namespace vf::basics::constant;
488UbTupleDouble6 Grid3D::getBlockOversize() const { return makeUbTuple(0., 0., 0., 0., 0., 0.); }
494void Grid3D::setDeltaX(real dx) { this->orgDeltaX = dx; }
498real Grid3D::getDeltaX(int level) const
499{
500 real delta = this->orgDeltaX / (real)(1 << level);
501 return delta;
502}
504real Grid3D::getDeltaX(SPtr<Block3D> block) const { return getDeltaX(block->getLevel()); }
507{
508 double delta = (double)this->getDeltaX(block);
509 return makeUbTuple((double)offset * delta, (double)offset * delta, (double)offset * delta);
510}
512GbVector3D Grid3D::getNodeCoordinates(SPtr<Block3D> block, int ix1, int ix2, int ix3) const
513{
516 real deltaX = getDeltaX(block);
517
518 real x1 = val<1>(org) - val<1>(nodeOffset) + (real)ix1 * deltaX;
519 real x2 = val<2>(org) - val<2>(nodeOffset) + (real)ix2 * deltaX;
520 real x3 = val<3>(org) - val<3>(nodeOffset) + (real)ix3 * deltaX;
521
522 return GbVector3D(x1, x2, x3);
523}
526 real nodeX3Coord) const
527{
530 real deltaX = getDeltaX(block);
531
532 int ix1, ix2, ix3;
533 real ixx1 = (abs(nodeX1Coord - val<1>(org) + val<1>(nodeOffset)) / deltaX);
534 real ixx2 = (abs(nodeX2Coord - val<2>(org) + val<2>(nodeOffset)) / deltaX);
535 real ixx3 = (abs(nodeX3Coord - val<3>(org) + val<3>(nodeOffset)) / deltaX);
536 if (ixx1 - (int)ixx1 > .9999999999)
537 ix1 = (int)ixx1 + 1;
538 else
539 ix1 = (int)ixx1;
540 if (ixx2 - (int)ixx2 > .9999999999)
541 ix2 = (int)ixx2 + 1;
542 else
543 ix2 = (int)ixx2;
544 if (ixx3 - (int)ixx3 > .9999999999)
545 ix3 = (int)ixx3 + 1;
546 else
547 ix3 = (int)ixx3;
548
549 return makeUbTuple(ix1, ix2, ix3);
550}
552// returns tuple with origin of block in world-coordinates
554{
555 if (!block)
556 throw UbException(UB_EXARGS, "block " + block->toString() + "is not exist");
557
558 int blockX1Index = block->getX1();
559 int blockX2Index = block->getX2();
560 int blockX3Index = block->getX3();
561 int level = block->getLevel();
562
563 return this->getBlockWorldCoordinates(blockX1Index, blockX2Index, blockX3Index, level);
564}
567{
568 real c1oShiftedLevel = 1.0 / (real)(1 << level);
572
573 if (!trafo)
574 return { x1, x2, x3 };
575
576 return { trafo->transformBackwardToX1Coordinate(x1, x2, x3), trafo->transformBackwardToX2Coordinate(x1, x2, x3),
577 trafo->transformBackwardToX3Coordinate(x1, x2, x3) };
578}
580// double Grid3D::getDeltaT(SPtr<Block3D> block) const
581//{
582// int level = block->getLevel();
583// double delta = 1.0/(double)(1<<level);
584// return delta;
585//}
587void Grid3D::checkLevel(int level)
588{
589 if (level < 0) {
590 throw UbException(UB_EXARGS, "l(" + ub_system::toString(level) + (string) ")<0");
591 }
592 if (level > d3q27_system::MAXLEVEL) {
593 throw UbException(UB_EXARGS, "l(" + ub_system::toString(level) + (string) ")>MAXLEVEL");
594 }
595 if (this->levelSet[level].size() == 0) {
596 throw UbException(UB_EXARGS, "levelMap for level(" + ub_system::toString(level) + (string) ")==NULL");
597 }
598}
600bool Grid3D::hasLevel(int level) const
601{
602 if (level < 0)
603 return false;
604 if (level > d3q27_system::MAXLEVEL)
605 return false;
606 if (this->levelSet[level].size() == 0)
607 return false;
608
609 return true;
610}
612void Grid3D::setBlockNX(int nx1, int nx2, int nx3)
613{
614 blockNx1 = nx1;
615 blockNx2 = nx2;
616 blockNx3 = nx3;
617}
619UbTupleInt3 Grid3D::getBlockNX() const { return makeUbTuple(blockNx1, blockNx2, blockNx3); }
621
622SPtr<Block3D> Grid3D::getNeighborBlock(int dir, int ix1, int ix2, int ix3, int level) const
623{
624 return this->getBlock(ix1 + d3q27_system::DX1[dir], ix2 + d3q27_system::DX2[dir], ix3 + d3q27_system::DX3[dir],
625 level);
626}
629{
630 int x1 = block->getX1();
631 int x2 = block->getX2();
632 int x3 = block->getX3();
633 int level = block->getLevel();
634 return this->getNeighborBlock(dir, x1, x2, x3, level);
635}
637void Grid3D::getAllNeighbors(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
638{
639 // for (int dir = D3Q27System::STARTDIR; dir <= D3Q27System::ENDDIR; dir++)FSTARTDIR
640 for (int dir = d3q27_system::FSTARTDIR; dir <= d3q27_system::FENDDIR; dir++)
641 {
642 this->getNeighborBlocksForDirection(dir, ix1, ix2, ix3, level, levelDepth, blocks);
643 }
644}
646void Grid3D::getAllNeighbors(SPtr<Block3D> block, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
647{
648 int x1 = block->getX1();
649 int x2 = block->getX2();
650 int x3 = block->getX3();
651 getAllNeighbors(x1, x2, x3, level, levelDepth, blocks);
652}
654
661void Grid3D::getNeighborsNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
662{
663 SPtr<Block3D> block = this->getBlock(ix1, ix2 + 1, ix3, level);
664 if (block) {
665 blocks.push_back(block);
666 }
667
668 if (level > 0) {
669 block = this->getSuperBlock(ix1, ix2 + 1, ix3, level);
670 if (block) {
671 blocks.push_back(block);
672 }
673 }
674 this->getSubBlocksSouth(ix1, ix2 + 1, ix3, level, blocks, levelDepth);
675}
677void Grid3D::getNeighborsTop(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
678{
679 SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3 + 1, level);
680 if (block) {
681 blocks.push_back(block);
682 }
683
684 if (level > 0) {
685 block = this->getSuperBlock(ix1, ix2, ix3 + 1, level);
686 if (block) {
687 blocks.push_back(block);
688 }
689 }
690 this->getSubBlocksBottom(ix1, ix2, ix3 + 1, level, blocks, levelDepth);
691}
693void Grid3D::getNeighborsBottom(int ix1, int ix2, int ix3, int level, int levelDepth,
694 std::vector<SPtr<Block3D>> &blocks)
695{
696 SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3 - 1, level);
697 if (block) {
698 blocks.push_back(block);
699 }
700
701 if (level > 0) {
702 block = this->getSuperBlock(ix1, ix2, ix3 - 1, level);
703 if (block) {
704 blocks.push_back(block);
705 }
706 }
707 this->getSubBlocksTop(ix1, ix2, ix3 - 1, level, blocks, levelDepth);
708}
710void Grid3D::getNeighborsSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
711{
712 SPtr<Block3D> block = this->getBlock(ix1, ix2 - 1, ix3, level);
713 if (block) {
714 blocks.push_back(block);
715 }
716
717 if (level > 0) {
718 block = this->getSuperBlock(ix1, ix2 - 1, ix3, level);
719 if (block) {
720 blocks.push_back(block);
721 }
722 }
723 this->getSubBlocksNorth(ix1, ix2 - 1, ix3, level, blocks, levelDepth);
724}
726void Grid3D::getNeighborsEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
727{
728 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2, ix3, level);
729 if (block) {
730 blocks.push_back(block);
731 }
732
733 if (level > 0) {
734 block = this->getSuperBlock(ix1 + 1, ix2, ix3, level);
735 if (block) {
736 blocks.push_back(block);
737 }
738 }
739 this->getSubBlocksWest(ix1 + 1, ix2, ix3, level, blocks, levelDepth);
740}
742void Grid3D::getNeighborsWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
743{
744 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2, ix3, level);
745 if (block) {
746 blocks.push_back(block);
747 }
748
749 if (level > 0) {
750 block = this->getSuperBlock(ix1 - 1, ix2, ix3, level);
751 if (block) {
752 blocks.push_back(block);
753 }
754 }
755 this->getSubBlocksEast(ix1 - 1, ix2, ix3, level, blocks, levelDepth);
756}
758// diagonals
760void Grid3D::getNeighborsNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth,
761 std::vector<SPtr<Block3D>> &blocks)
762{
763 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 + 1, ix3, level);
764 if (block) {
765 blocks.push_back(block);
766 }
767
768 if (level > 0) {
769 block = this->getSuperBlock(ix1 + 1, ix2 + 1, ix3, level);
770 if (block) {
771 blocks.push_back(block);
772 }
773 }
774 this->getSubBlocksSouthWest(ix1 + 1, ix2 + 1, ix3, level, blocks, levelDepth);
775}
777void Grid3D::getNeighborsNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth,
778 std::vector<SPtr<Block3D>> &blocks)
779{
780 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 + 1, ix3, level);
781 if (block) {
782 blocks.push_back(block);
783 }
784
785 if (level > 0) {
786 block = this->getSuperBlock(ix1 - 1, ix2 + 1, ix3, level);
787 if (block) {
788 blocks.push_back(block);
789 }
790 }
791 this->getSubBlocksSouthEast(ix1 - 1, ix2 + 1, ix3, level, blocks, levelDepth);
792}
794void Grid3D::getNeighborsSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth,
795 std::vector<SPtr<Block3D>> &blocks)
796{
797 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 - 1, ix3, level);
798 if (block) {
799 blocks.push_back(block);
800 }
801
802 if (level > 0) {
803 block = this->getSuperBlock(ix1 + 1, ix2 - 1, ix3, level);
804 if (block) {
805 blocks.push_back(block);
806 }
807 }
808 this->getSubBlocksNorthWest(ix1 + 1, ix2 - 1, ix3, level, blocks, levelDepth);
809}
811void Grid3D::getNeighborsSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth,
812 std::vector<SPtr<Block3D>> &blocks)
813{
814 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 - 1, ix3, level);
815 if (block) {
816 blocks.push_back(block);
817 }
818
819 if (level > 0) {
820 block = this->getSuperBlock(ix1 - 1, ix2 - 1, ix3, level);
821 if (block) {
822 blocks.push_back(block);
823 }
824 }
825 this->getSubBlocksNorthEast(ix1 - 1, ix2 - 1, ix3, level, blocks, levelDepth);
826}
828// diagonals top
830void Grid3D::getNeighborsTopEast(int ix1, int ix2, int ix3, int level, int levelDepth,
831 std::vector<SPtr<Block3D>> &blocks)
832{
833 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2, ix3 + 1, level);
834 if (block) {
835 blocks.push_back(block);
836 }
837
838 if (level > 0) {
839 block = this->getSuperBlock(ix1 + 1, ix2, ix3 + 1, level);
840 if (block) {
841 blocks.push_back(block);
842 }
843 }
844 this->getSubBlocksBottomWest(ix1 + 1, ix2, ix3 + 1, level, blocks, levelDepth);
845}
847void Grid3D::getNeighborsTopWest(int ix1, int ix2, int ix3, int level, int levelDepth,
848 std::vector<SPtr<Block3D>> &blocks)
849{
850 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2, ix3 + 1, level);
851 if (block) {
852 blocks.push_back(block);
853 }
854
855 if (level > 0) {
856 block = this->getSuperBlock(ix1 - 1, ix2, ix3 + 1, level);
857 if (block) {
858 blocks.push_back(block);
859 }
860 }
861 this->getSubBlocksBottomEast(ix1 - 1, ix2, ix3 + 1, level, blocks, levelDepth);
862}
864void Grid3D::getNeighborsTopNorth(int ix1, int ix2, int ix3, int level, int levelDepth,
865 std::vector<SPtr<Block3D>> &blocks)
866{
867 SPtr<Block3D> block = this->getBlock(ix1, ix2 + 1, ix3 + 1, level);
868 if (block) {
869 blocks.push_back(block);
870 }
871
872 if (level > 0) {
873 block = this->getSuperBlock(ix1, ix2 + 1, ix3 + 1, level);
874 if (block) {
875 blocks.push_back(block);
876 }
877 }
878 this->getSubBlocksBottomSouth(ix1, ix2 + 1, ix3 + 1, level, blocks, levelDepth);
879}
881void Grid3D::getNeighborsTopSouth(int ix1, int ix2, int ix3, int level, int levelDepth,
882 std::vector<SPtr<Block3D>> &blocks)
883{
884 SPtr<Block3D> block = this->getBlock(ix1, ix2 - 1, ix3 + 1, level);
885 if (block) {
886 blocks.push_back(block);
887 }
888
889 if (level > 0) {
890 block = this->getSuperBlock(ix1, ix2 - 1, ix3 + 1, level);
891 if (block) {
892 blocks.push_back(block);
893 }
894 }
895 this->getSubBlocksBottomNorth(ix1, ix2 - 1, ix3 + 1, level, blocks, levelDepth);
896}
898// diagonals bottom
900void Grid3D::getNeighborsBottomEast(int ix1, int ix2, int ix3, int level, int levelDepth,
901 std::vector<SPtr<Block3D>> &blocks)
902{
903 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2, ix3 - 1, level);
904 if (block) {
905 blocks.push_back(block);
906 }
907
908 if (level > 0) {
909 block = this->getSuperBlock(ix1 + 1, ix2, ix3 - 1, level);
910 if (block) {
911 blocks.push_back(block);
912 }
913 }
914 this->getSubBlocksTopWest(ix1 + 1, ix2, ix3 - 1, level, blocks, levelDepth);
915}
917void Grid3D::getNeighborsBottomWest(int ix1, int ix2, int ix3, int level, int levelDepth,
918 std::vector<SPtr<Block3D>> &blocks)
919{
920 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2, ix3 - 1, level);
921 if (block) {
922 blocks.push_back(block);
923 }
924
925 if (level > 0) {
926 block = this->getSuperBlock(ix1 - 1, ix2, ix3 - 1, level);
927 if (block) {
928 blocks.push_back(block);
929 }
930 }
931 this->getSubBlocksTopEast(ix1 - 1, ix2, ix3 - 1, level, blocks, levelDepth);
932}
934void Grid3D::getNeighborsBottomNorth(int ix1, int ix2, int ix3, int level, int levelDepth,
935 std::vector<SPtr<Block3D>> &blocks)
936{
937 SPtr<Block3D> block = this->getBlock(ix1, ix2 + 1, ix3 - 1, level);
938 if (block) {
939 blocks.push_back(block);
940 }
941
942 if (level > 0) {
943 block = this->getSuperBlock(ix1, ix2 + 1, ix3 - 1, level);
944 if (block) {
945 blocks.push_back(block);
946 }
947 }
948 this->getSubBlocksTopSouth(ix1, ix2 + 1, ix3 - 1, level, blocks, levelDepth);
949}
951void Grid3D::getNeighborsBottomSouth(int ix1, int ix2, int ix3, int level, int levelDepth,
952 std::vector<SPtr<Block3D>> &blocks)
953{
954 SPtr<Block3D> block = this->getBlock(ix1, ix2 - 1, ix3 - 1, level);
955 if (block) {
956 blocks.push_back(block);
957 }
958
959 if (level > 0) {
960 block = this->getSuperBlock(ix1, ix2 - 1, ix3 - 1, level);
961 if (block) {
962 blocks.push_back(block);
963 }
964 }
965 this->getSubBlocksTopNorth(ix1, ix2 - 1, ix3 - 1, level, blocks, levelDepth);
966}
968void Grid3D::getNeighborsTopNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth,
969 std::vector<SPtr<Block3D>> &blocks)
970{
971 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 + 1, ix3 + 1, level);
972 if (block) {
973 blocks.push_back(block);
974 }
975
976 if (level > 0) {
977 block = this->getSuperBlock(ix1 + 1, ix2 + 1, ix3 + 1, level);
978 if (block) {
979 blocks.push_back(block);
980 }
981 }
982 this->getSubBlocksBottomSouthWest(ix1 + 1, ix2 + 1, ix3 + 1, level, blocks, levelDepth);
983}
985void Grid3D::getNeighborsTopNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth,
986 std::vector<SPtr<Block3D>> &blocks)
987{
988 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 + 1, ix3 + 1, level);
989 if (block) {
990 blocks.push_back(block);
991 }
992
993 if (level > 0) {
994 block = this->getSuperBlock(ix1 - 1, ix2 + 1, ix3 + 1, level);
995 if (block) {
996 blocks.push_back(block);
997 }
998 }
999 this->getSubBlocksBottomSouthEast(ix1 - 1, ix2 + 1, ix3 + 1, level, blocks, levelDepth);
1000}
1002void Grid3D::getNeighborsTopSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth,
1003 std::vector<SPtr<Block3D>> &blocks)
1004{
1005 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 - 1, ix3 + 1, level);
1006 if (block) {
1007 blocks.push_back(block);
1008 }
1009
1010 if (level > 0) {
1011 block = this->getSuperBlock(ix1 + 1, ix2 - 1, ix3 + 1, level);
1012 if (block) {
1013 blocks.push_back(block);
1014 }
1015 }
1016 this->getSubBlocksBottomNorthWest(ix1 + 1, ix2 - 1, ix3 + 1, level, blocks, levelDepth);
1017}
1019void Grid3D::getNeighborsTopSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth,
1020 std::vector<SPtr<Block3D>> &blocks)
1021{
1022 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 - 1, ix3 + 1, level);
1023 if (block) {
1024 blocks.push_back(block);
1025 }
1026
1027 if (level > 0) {
1028 block = this->getSuperBlock(ix1 - 1, ix2 - 1, ix3 + 1, level);
1029 if (block) {
1030 blocks.push_back(block);
1031 }
1032 }
1033 this->getSubBlocksBottomNorthEast(ix1 - 1, ix2 - 1, ix3 + 1, level, blocks, levelDepth);
1034}
1036void Grid3D::getNeighborsBottomNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth,
1037 std::vector<SPtr<Block3D>> &blocks)
1038{
1039 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 + 1, ix3 - 1, level);
1040 if (block) {
1041 blocks.push_back(block);
1042 }
1043
1044 if (level > 0) {
1045 block = this->getSuperBlock(ix1 + 1, ix2 + 1, ix3 - 1, level);
1046 if (block) {
1047 blocks.push_back(block);
1048 }
1049 }
1050 this->getSubBlocksTopSouthWest(ix1 + 1, ix2 + 1, ix3 - 1, level, blocks, levelDepth);
1051}
1053void Grid3D::getNeighborsBottomNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth,
1054 std::vector<SPtr<Block3D>> &blocks)
1055{
1056 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 + 1, ix3 - 1, level);
1057 if (block) {
1058 blocks.push_back(block);
1059 }
1060
1061 if (level > 0) {
1062 block = this->getSuperBlock(ix1 - 1, ix2 + 1, ix3 - 1, level);
1063 if (block) {
1064 blocks.push_back(block);
1065 }
1066 }
1067 this->getSubBlocksTopSouthEast(ix1 - 1, ix2 + 1, ix3 - 1, level, blocks, levelDepth);
1068}
1070void Grid3D::getNeighborsBottomSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth,
1071 std::vector<SPtr<Block3D>> &blocks)
1072{
1073 SPtr<Block3D> block = this->getBlock(ix1 + 1, ix2 - 1, ix3 - 1, level);
1074 if (block) {
1075 blocks.push_back(block);
1076 }
1077
1078 if (level > 0) {
1079 block = this->getSuperBlock(ix1 + 1, ix2 - 1, ix3 - 1, level);
1080 if (block) {
1081 blocks.push_back(block);
1082 }
1083 }
1084 this->getSubBlocksTopNorthWest(ix1 + 1, ix2 - 1, ix3 - 1, level, blocks, levelDepth);
1085}
1087void Grid3D::getNeighborsBottomSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth,
1088 std::vector<SPtr<Block3D>> &blocks)
1089{
1090 SPtr<Block3D> block = this->getBlock(ix1 - 1, ix2 - 1, ix3 - 1, level);
1091 if (block) {
1092 blocks.push_back(block);
1093 }
1094
1095 if (level > 0) {
1096 block = this->getSuperBlock(ix1 - 1, ix2 - 1, ix3 - 1, level);
1097 if (block) {
1098 blocks.push_back(block);
1099 }
1100 }
1101 this->getSubBlocksTopNorthEast(ix1 - 1, ix2 - 1, ix3 - 1, level, blocks, levelDepth);
1102}
1104void Grid3D::getNeighborBlocksForDirection(int dir, int ix1, int ix2, int ix3, int level, int levelDepth,
1105 std::vector<SPtr<Block3D>> &blocks)
1106{
1107 using namespace vf::lbm::dir;
1108
1109 switch (dir) {
1110 case dP00:
1111 this->getNeighborsEast(ix1, ix2, ix3, level, levelDepth, blocks);
1112 break;
1113 case dM00:
1114 this->getNeighborsWest(ix1, ix2, ix3, level, levelDepth, blocks);
1115 break;
1116 case d0P0:
1117 this->getNeighborsNorth(ix1, ix2, ix3, level, levelDepth, blocks);
1118 break;
1119 case d0M0:
1120 this->getNeighborsSouth(ix1, ix2, ix3, level, levelDepth, blocks);
1121 break;
1122 case d00P:
1123 this->getNeighborsTop(ix1, ix2, ix3, level, levelDepth, blocks);
1124 break;
1125 case d00M:
1126 this->getNeighborsBottom(ix1, ix2, ix3, level, levelDepth, blocks);
1127 break;
1128 case dPP0:
1129 this->getNeighborsNorthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1130 break;
1131 case dMM0:
1132 this->getNeighborsSouthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1133 break;
1134 case dPM0:
1135 this->getNeighborsSouthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1136 break;
1137 case dMP0:
1138 this->getNeighborsNorthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1139 break;
1140 case dP0P:
1141 this->getNeighborsTopEast(ix1, ix2, ix3, level, levelDepth, blocks);
1142 break;
1143 case dM0M:
1144 this->getNeighborsBottomWest(ix1, ix2, ix3, level, levelDepth, blocks);
1145 break;
1146 case dP0M:
1147 this->getNeighborsBottomEast(ix1, ix2, ix3, level, levelDepth, blocks);
1148 break;
1149 case dM0P:
1150 this->getNeighborsTopWest(ix1, ix2, ix3, level, levelDepth, blocks);
1151 break;
1152 case d0PP:
1153 this->getNeighborsTopNorth(ix1, ix2, ix3, level, levelDepth, blocks);
1154 break;
1155 case d0MM:
1156 this->getNeighborsBottomSouth(ix1, ix2, ix3, level, levelDepth, blocks);
1157 break;
1158 case d0PM:
1159 this->getNeighborsBottomNorth(ix1, ix2, ix3, level, levelDepth, blocks);
1160 break;
1161 case d0MP:
1162 this->getNeighborsTopSouth(ix1, ix2, ix3, level, levelDepth, blocks);
1163 break;
1164 case dPPP:
1165 this->getNeighborsTopNorthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1166 break;
1167 case dMPP:
1168 this->getNeighborsTopNorthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1169 break;
1170 case dPMP:
1171 this->getNeighborsTopSouthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1172 break;
1173 case dMMP:
1174 this->getNeighborsTopSouthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1175 break;
1176 case dPPM:
1177 this->getNeighborsBottomNorthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1178 break;
1179 case dMPM:
1180 this->getNeighborsBottomNorthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1181 break;
1182 case dPMM:
1183 this->getNeighborsBottomSouthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1184 break;
1185 case dMMM:
1186 this->getNeighborsBottomSouthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1187 break;
1188 default:
1189 throw UbException(UB_EXARGS, "direction " + ub_system::toString(dir) + " is not exist");
1190 }
1191}
1193void Grid3D::getNeighborsZero(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector<SPtr<Block3D>> &blocks)
1194{
1195 SPtr<Block3D> block = this->getBlock(ix1, ix2, ix3, level);
1196 if (block) {
1197 blocks.push_back(block);
1198 }
1199
1200 if (level > 0) {
1201 block = this->getSuperBlock(ix1, ix2, ix3, level);
1202 if (block) {
1203 blocks.push_back(block);
1204 }
1205 }
1206 // this->getSubBlocksNull(ix1, ix2, ix3, level, blocks, levelDepth);
1207 this->getSubBlocks(ix1, ix2, ix3, level, levelDepth, blocks);
1208}
1210void Grid3D::getSubBlocksZero(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth)
1211{
1212 int x1E = (ix1 << 1) + 1;
1213 int x1W = (ix1 << 1);
1214 int x2S = ix2 << 1;
1215 int x2N = x2S + 1;
1216 int x3B = ix3 << 1;
1217 int x3T = x3B + 1;
1218 int l = level + 1;
1219
1220 SPtr<Block3D> block = this->getBlock(x1E, x2S, x3B, l);
1221 if (block != NULL)
1222 blockVector.push_back(block);
1223 else if (l < levelDepth)
1224 this->getSubBlocksEast(x1E, x2S, x3B, l, blockVector, levelDepth);
1225
1226 block = this->getBlock(x1E, x2N, x3B, l);
1227 if (block != NULL)
1228 blockVector.push_back(block);
1229 else if (l < levelDepth)
1230 this->getSubBlocksEast(x1E, x2N, x3B, l, blockVector, levelDepth);
1231
1232 block = this->getBlock(x1E, x2S, x3T, l);
1233 if (block != NULL)
1234 blockVector.push_back(block);
1235 else if (l < levelDepth)
1236 this->getSubBlocksEast(x1E, x2S, x3T, l, blockVector, levelDepth);
1237
1238 block = this->getBlock(x1E, x2N, x3T, l);
1239 if (block != NULL)
1240 blockVector.push_back(block);
1241 else if (l < levelDepth)
1242 this->getSubBlocksEast(x1E, x2N, x3T, l, blockVector, levelDepth);
1243
1244 block = this->getBlock(x1W, x2S, x3B, l);
1245 if (block != NULL)
1246 blockVector.push_back(block);
1247 else if (l < levelDepth)
1248 this->getSubBlocksEast(x1W, x2S, x3B, l, blockVector, levelDepth);
1249
1250 block = this->getBlock(x1W, x2N, x3B, l);
1251 if (block != NULL)
1252 blockVector.push_back(block);
1253 else if (l < levelDepth)
1254 this->getSubBlocksEast(x1W, x2N, x3B, l, blockVector, levelDepth);
1255
1256 block = this->getBlock(x1W, x2S, x3T, l);
1257 if (block != NULL)
1258 blockVector.push_back(block);
1259 else if (l < levelDepth)
1260 this->getSubBlocksEast(x1W, x2S, x3T, l, blockVector, levelDepth);
1261
1262 block = this->getBlock(x1W, x2N, x3T, l);
1263 if (block != NULL)
1264 blockVector.push_back(block);
1265 else if (l < levelDepth)
1266 this->getSubBlocksEast(x1W, x2N, x3T, l, blockVector, levelDepth);
1267}
1269void Grid3D::getNeighborBlocksForDirectionWithREST(int dir, int ix1, int ix2, int ix3, int level, int levelDepth,
1270 std::vector<SPtr<Block3D>> &blocks)
1271{
1272 using namespace vf::lbm::dir;
1273
1274 switch (dir) {
1275 case dP00:
1276 this->getNeighborsEast(ix1, ix2, ix3, level, levelDepth, blocks);
1277 break;
1278 case dM00:
1279 this->getNeighborsWest(ix1, ix2, ix3, level, levelDepth, blocks);
1280 break;
1281 case d0P0:
1282 this->getNeighborsNorth(ix1, ix2, ix3, level, levelDepth, blocks);
1283 break;
1284 case d0M0:
1285 this->getNeighborsSouth(ix1, ix2, ix3, level, levelDepth, blocks);
1286 break;
1287 case d00P:
1288 this->getNeighborsTop(ix1, ix2, ix3, level, levelDepth, blocks);
1289 break;
1290 case d00M:
1291 this->getNeighborsBottom(ix1, ix2, ix3, level, levelDepth, blocks);
1292 break;
1293 case dPP0:
1294 this->getNeighborsNorthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1295 break;
1296 case dMM0:
1297 this->getNeighborsSouthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1298 break;
1299 case dPM0:
1300 this->getNeighborsSouthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1301 break;
1302 case dMP0:
1303 this->getNeighborsNorthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1304 break;
1305 case dP0P:
1306 this->getNeighborsTopEast(ix1, ix2, ix3, level, levelDepth, blocks);
1307 break;
1308 case dM0M:
1309 this->getNeighborsBottomWest(ix1, ix2, ix3, level, levelDepth, blocks);
1310 break;
1311 case dP0M:
1312 this->getNeighborsBottomEast(ix1, ix2, ix3, level, levelDepth, blocks);
1313 break;
1314 case dM0P:
1315 this->getNeighborsTopWest(ix1, ix2, ix3, level, levelDepth, blocks);
1316 break;
1317 case d0PP:
1318 this->getNeighborsTopNorth(ix1, ix2, ix3, level, levelDepth, blocks);
1319 break;
1320 case d0MM:
1321 this->getNeighborsBottomSouth(ix1, ix2, ix3, level, levelDepth, blocks);
1322 break;
1323 case d0PM:
1324 this->getNeighborsBottomNorth(ix1, ix2, ix3, level, levelDepth, blocks);
1325 break;
1326 case d0MP:
1327 this->getNeighborsTopSouth(ix1, ix2, ix3, level, levelDepth, blocks);
1328 break;
1329 case dPPP:
1330 this->getNeighborsTopNorthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1331 break;
1332 case dMPP:
1333 this->getNeighborsTopNorthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1334 break;
1335 case dPMP:
1336 this->getNeighborsTopSouthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1337 break;
1338 case dMMP:
1339 this->getNeighborsTopSouthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1340 break;
1341 case dPPM:
1342 this->getNeighborsBottomNorthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1343 break;
1344 case dMPM:
1345 this->getNeighborsBottomNorthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1346 break;
1347 case dPMM:
1348 this->getNeighborsBottomSouthEast(ix1, ix2, ix3, level, levelDepth, blocks);
1349 break;
1350 case dMMM:
1351 this->getNeighborsBottomSouthWest(ix1, ix2, ix3, level, levelDepth, blocks);
1352 break;
1353 case d000:
1354 this->getNeighborsZero(ix1, ix2, ix3, level, levelDepth, blocks);
1355 break;
1356 default:
1357 throw UbException(UB_EXARGS, "direction " + ub_system::toString(dir) + " is not exist");
1358 }
1359}
1361void Grid3D::getSubBlocksEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth)
1362{
1363 int x1 = (ix1 << 1) + 1;
1364 int x2S = ix2 << 1;
1365 int x2N = x2S + 1;
1366 int x3B = ix3 << 1;
1367 int x3T = x3B + 1;
1368 int l = level + 1;
1369
1370 SPtr<Block3D> block = this->getBlock(x1, x2S, x3B, l);
1371 if (block != NULL)
1372 blockVector.push_back(block);
1373 else if (l < levelDepth)
1374 this->getSubBlocksEast(x1, x2S, x3B, l, blockVector, levelDepth);
1375
1376 block = this->getBlock(x1, x2N, x3B, l);
1377 if (block != NULL)
1378 blockVector.push_back(block);
1379 else if (l < levelDepth)
1380 this->getSubBlocksEast(x1, x2N, x3B, l, blockVector, levelDepth);
1381
1382 block = this->getBlock(x1, x2S, x3T, l);
1383 if (block != NULL)
1384 blockVector.push_back(block);
1385 else if (l < levelDepth)
1386 this->getSubBlocksEast(x1, x2S, x3T, l, blockVector, levelDepth);
1387
1388 block = this->getBlock(x1, x2N, x3T, l);
1389 if (block != NULL)
1390 blockVector.push_back(block);
1391 else if (l < levelDepth)
1392 this->getSubBlocksEast(x1, x2N, x3T, l, blockVector, levelDepth);
1393}
1394
1396void Grid3D::getSubBlocksWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth)
1397{
1398 int x1 = ix1 << 1;
1399 int x2S = ix2 << 1;
1400 int x2N = x2S + 1;
1401 int x3B = ix3 << 1;
1402 int x3T = x3B + 1;
1403 int l = level + 1;
1404
1405 SPtr<Block3D> block = this->getBlock(x1, x2S, x3B, l);
1406 if (block != NULL)
1407 blockVector.push_back(block);
1408 else if (l < levelDepth)
1409 this->getSubBlocksWest(x1, x2S, x3B, l, blockVector, levelDepth);
1410
1411 block = this->getBlock(x1, x2N, x3B, l);
1412 if (block != NULL)
1413 blockVector.push_back(block);
1414 else if (l < levelDepth)
1415 this->getSubBlocksWest(x1, x2N, x3B, l, blockVector, levelDepth);
1416
1417 block = this->getBlock(x1, x2S, x3T, l);
1418 if (block != NULL)
1419 blockVector.push_back(block);
1420 else if (l < levelDepth)
1421 this->getSubBlocksWest(x1, x2S, x3T, l, blockVector, levelDepth);
1422
1423 block = this->getBlock(x1, x2N, x3T, l);
1424 if (block != NULL)
1425 blockVector.push_back(block);
1426 else if (l < levelDepth)
1427 this->getSubBlocksWest(x1, x2N, x3T, l, blockVector, levelDepth);
1428}
1430void Grid3D::getSubBlocksNorth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth)
1431{
1432 int x1W = ix1 << 1;
1433 int x1E = x1W + 1;
1434 int x2 = (ix2 << 1) + 1;
1435 int x3B = ix3 << 1;
1436 int x3T = x3B + 1;
1437 int l = level + 1;
1438
1439 SPtr<Block3D> block = this->getBlock(x1W, x2, x3B, l);
1440 if (block != NULL)
1441 blockVector.push_back(block);
1442 else if (l < levelDepth)
1443 this->getSubBlocksNorth(x1W, x2, x3B, l, blockVector, levelDepth);
1444
1445 block = this->getBlock(x1E, x2, x3B, l);
1446 if (block != NULL)
1447 blockVector.push_back(block);
1448 else if (l < levelDepth)
1449 this->getSubBlocksNorth(x1E, x2, x3B, l, blockVector, levelDepth);
1450
1451 block = this->getBlock(x1W, x2, x3T, l);
1452 if (block != NULL)
1453 blockVector.push_back(block);
1454 else if (l < levelDepth)
1455 this->getSubBlocksNorth(x1W, x2, x3T, l, blockVector, levelDepth);
1456
1457 block = this->getBlock(x1E, x2, x3T, l);
1458 if (block != NULL)
1459 blockVector.push_back(block);
1460 else if (l < levelDepth)
1461 this->getSubBlocksNorth(x1E, x2, x3T, l, blockVector, levelDepth);
1462}
1464void Grid3D::getSubBlocksSouth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth)
1465{
1466 int x1W = ix1 << 1;
1467 int x1E = x1W + 1;
1468 int x2 = ix2 << 1;
1469 int x3B = ix3 << 1;
1470 int x3T = x3B + 1;
1471 int l = level + 1;
1472
1473 SPtr<Block3D> block = this->getBlock(x1W, x2, x3B, l);
1474 if (block != NULL)
1475 blockVector.push_back(block);
1476 else if (l < levelDepth)
1477 this->getSubBlocksSouth(x1W, x2, x3B, l, blockVector, levelDepth);
1478
1479 block = this->getBlock(x1E, x2, x3B, l);
1480 if (block != NULL)
1481 blockVector.push_back(block);
1482 else if (l < levelDepth)
1483 this->getSubBlocksSouth(x1E, x2, x3B, l, blockVector, levelDepth);
1484
1485 block = this->getBlock(x1W, x2, x3T, l);
1486 if (block != NULL)
1487 blockVector.push_back(block);
1488 else if (l < levelDepth)
1489 this->getSubBlocksSouth(x1W, x2, x3T, l, blockVector, levelDepth);
1490
1491 block = this->getBlock(x1E, x2, x3T, l);
1492 if (block != NULL)
1493 blockVector.push_back(block);
1494 else if (l < levelDepth)
1495 this->getSubBlocksSouth(x1E, x2, x3T, l, blockVector, levelDepth);
1496}
1498void Grid3D::getSubBlocksTop(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector, int levelDepth)
1499{
1500 int x1W = ix1 << 1;
1501 int x1E = x1W + 1;
1502 int x2S = ix2 << 1;
1503 int x2N = x2S + 1;
1504 int x3 = (ix3 << 1) + 1;
1505 int l = level + 1;
1506
1507 SPtr<Block3D> block = this->getBlock(x1W, x2N, x3, l);
1508 if (block != NULL)
1509 blockVector.push_back(block);
1510 else if (l < levelDepth)
1511 this->getSubBlocksTop(x1W, x2N, x3, l, blockVector, levelDepth);
1512
1513 block = this->getBlock(x1E, x2N, x3, l);
1514 if (block != NULL)
1515 blockVector.push_back(block);
1516 else if (l < levelDepth)
1517 this->getSubBlocksTop(x1E, x2N, x3, l, blockVector, levelDepth);
1518
1519 block = this->getBlock(x1W, x2S, x3, l);
1520 if (block != NULL)
1521 blockVector.push_back(block);
1522 else if (l < levelDepth)
1523 this->getSubBlocksTop(x1W, x2S, x3, l, blockVector, levelDepth);
1524
1525 block = this->getBlock(x1E, x2S, x3, l);
1526 if (block != NULL)
1527 blockVector.push_back(block);
1528 else if (l < levelDepth)
1529 this->getSubBlocksTop(x1E, x2S, x3, l, blockVector, levelDepth);
1530}
1532void Grid3D::getSubBlocksBottom(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1533 int levelDepth)
1534{
1535 int x1W = ix1 << 1;
1536 int x1E = x1W + 1;
1537 int x2S = ix2 << 1;
1538 int x2N = x2S + 1;
1539 int x3 = ix3 << 1;
1540 int l = level + 1;
1541
1542 SPtr<Block3D> block = this->getBlock(x1W, x2N, x3, l);
1543 if (block != NULL)
1544 blockVector.push_back(block);
1545 else if (l < levelDepth)
1546 this->getSubBlocksBottom(x1W, x2N, x3, l, blockVector, levelDepth);
1547
1548 block = this->getBlock(x1E, x2N, x3, l);
1549 if (block != NULL)
1550 blockVector.push_back(block);
1551 else if (l < levelDepth)
1552 this->getSubBlocksBottom(x1E, x2N, x3, l, blockVector, levelDepth);
1553
1554 block = this->getBlock(x1W, x2S, x3, l);
1555 if (block != NULL)
1556 blockVector.push_back(block);
1557 else if (l < levelDepth)
1558 this->getSubBlocksBottom(x1W, x2S, x3, l, blockVector, levelDepth);
1559
1560 block = this->getBlock(x1E, x2S, x3, l);
1561 if (block != NULL)
1562 blockVector.push_back(block);
1563 else if (l < levelDepth)
1564 this->getSubBlocksBottom(x1E, x2S, x3, l, blockVector, levelDepth);
1565}
1567// diagonals
1569void Grid3D::getSubBlocksNorthEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1570 int levelDepth)
1571{
1572 int x1 = (ix1 << 1) + 1;
1573 int x2 = (ix2 << 1) + 1;
1574 int x3B = (ix3 << 1);
1575 int x3T = x3B + 1;
1576 int l = level + 1;
1577
1578 SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l);
1579 if (blockB)
1580 blockVector.push_back(blockB);
1581 else if (l < levelDepth)
1582 this->getSubBlocksNorthEast(x1, x2, x3B, l, blockVector, levelDepth);
1583
1584 SPtr<Block3D> blockT = this->getBlock(x1, x2, x3T, l);
1585 if (blockT)
1586 blockVector.push_back(blockT);
1587 else if (l < levelDepth)
1588 this->getSubBlocksNorthEast(x1, x2, x3T, l, blockVector, levelDepth);
1589}
1591void Grid3D::getSubBlocksNorthWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1592 int levelDepth)
1593{
1594 int x1 = (ix1 << 1);
1595 int x2 = (ix2 << 1) + 1;
1596 int x3B = (ix3 << 1);
1597 int x3T = x3B + 1;
1598 int l = level + 1;
1599
1600 SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l);
1601 if (blockB)
1602 blockVector.push_back(blockB);
1603 else if (l < levelDepth)
1604 this->getSubBlocksNorthWest(x1, x2, x3B, l, blockVector, levelDepth);
1605
1606 SPtr<Block3D> blockT = this->getBlock(x1, x2, x3T, l);
1607 if (blockT)
1608 blockVector.push_back(blockT);
1609 else if (l < levelDepth)
1610 this->getSubBlocksNorthWest(x1, x2, x3T, l, blockVector, levelDepth);
1611}
1613void Grid3D::getSubBlocksSouthWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1614 int levelDepth)
1615{
1616 int x1 = ix1 << 1;
1617 int x2 = ix2 << 1;
1618 int x3B = (ix3 << 1);
1619 int x3T = x3B + 1;
1620 int l = level + 1;
1621
1622 SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l);
1623 if (blockB)
1624 blockVector.push_back(blockB);
1625 else if (l < levelDepth)
1626 this->getSubBlocksSouthWest(x1, x2, x3B, l, blockVector, levelDepth);
1627
1628 SPtr<Block3D> blockT = this->getBlock(x1, x2, x3T, l);
1629 if (blockT)
1630 blockVector.push_back(blockT);
1631 else if (l < levelDepth)
1632 this->getSubBlocksSouthWest(x1, x2, x3T, l, blockVector, levelDepth);
1633}
1635void Grid3D::getSubBlocksSouthEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1636 int levelDepth)
1637{
1638 int x1 = (ix1 << 1) + 1;
1639 int x2 = ix2 << 1;
1640 int x3B = (ix3 << 1);
1641 int x3T = x3B + 1;
1642 int l = level + 1;
1643
1644 SPtr<Block3D> blockB = this->getBlock(x1, x2, x3B, l);
1645 if (blockB)
1646 blockVector.push_back(blockB);
1647 else if (l < levelDepth)
1648 this->getSubBlocksSouthEast(x1, x2, x3B, l, blockVector, levelDepth);
1649
1650 SPtr<Block3D> blockT = this->getBlock(x1, x2, x3T, l);
1651 if (blockT)
1652 blockVector.push_back(blockT);
1653 else if (l < levelDepth)
1654 this->getSubBlocksSouthEast(x1, x2, x3T, l, blockVector, levelDepth);
1655}
1657// diagonals
1659void Grid3D::getSubBlocksTopEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1660 int levelDepth)
1661{
1662 int x1 = (ix1 << 1) + 1;
1663 int x2S = (ix2 << 1);
1664 int x2N = x2S + 1;
1665 int x3 = (ix3 << 1) + 1;
1666 int l = level + 1;
1667
1668 SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l);
1669 if (blockN)
1670 blockVector.push_back(blockN);
1671 else if (l < levelDepth)
1672 this->getSubBlocksTopEast(x1, x2N, x3, l, blockVector, levelDepth);
1673
1674 SPtr<Block3D> blockS = this->getBlock(x1, x2S, x3, l);
1675 if (blockS)
1676 blockVector.push_back(blockS);
1677 else if (l < levelDepth)
1678 this->getSubBlocksTopEast(x1, x2S, x3, l, blockVector, levelDepth);
1679}
1681void Grid3D::getSubBlocksTopWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1682 int levelDepth)
1683{
1684 int x1 = ix1 << 1;
1685 int x2S = ix2 << 1;
1686 int x2N = x2S + 1;
1687 int x3 = (ix3 << 1) + 1;
1688 int l = level + 1;
1689
1690 SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l);
1691 if (blockN)
1692 blockVector.push_back(blockN);
1693 else if (l < levelDepth)
1694 this->getSubBlocksTopEast(x1, x2N, x3, l, blockVector, levelDepth);
1695
1696 SPtr<Block3D> blockS = this->getBlock(x1, x2S, x3, l);
1697 if (blockS)
1698 blockVector.push_back(blockS);
1699 else if (l < levelDepth)
1700 this->getSubBlocksTopEast(x1, x2S, x3, l, blockVector, levelDepth);
1701}
1703void Grid3D::getSubBlocksBottomEast(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1704 int levelDepth)
1705{
1706 int x1 = (ix1 << 1) + 1;
1707 int x2S = ix2 << 1;
1708 int x2N = x2S + 1;
1709 int x3 = ix3 << 1;
1710 int l = level + 1;
1711
1712 SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l);
1713 if (blockN)
1714 blockVector.push_back(blockN);
1715 else if (l < levelDepth)
1716 this->getSubBlocksTopEast(x1, x2N, x3, l, blockVector, levelDepth);
1717
1718 SPtr<Block3D> blockS = this->getBlock(x1, x2S, x3, l);
1719 if (blockS)
1720 blockVector.push_back(blockS);
1721 else if (l < levelDepth)
1722 this->getSubBlocksTopEast(x1, x2S, x3, l, blockVector, levelDepth);
1723}
1725void Grid3D::getSubBlocksBottomWest(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1726 int levelDepth)
1727{
1728 int x1 = (ix1 << 1);
1729 int x2S = (ix2 << 1);
1730 int x2N = x2S + 1;
1731 int x3 = ix3 << 1;
1732 int l = level + 1;
1733
1734 SPtr<Block3D> blockN = this->getBlock(x1, x2N, x3, l);
1735 if (blockN)
1736 blockVector.push_back(blockN);
1737 else if (l < levelDepth)
1738 this->getSubBlocksTopEast(x1, x2N, x3, l, blockVector, levelDepth);
1739
1740 SPtr<Block3D> blockS = this->getBlock(x1, x2S, x3, l);
1741 if (blockS)
1742 blockVector.push_back(blockS);
1743 else if (l < levelDepth)
1744 this->getSubBlocksTopEast(x1, x2S, x3, l, blockVector, levelDepth);
1745}
1746
1748// edge-diagonals
1750void Grid3D::getSubBlocksTopNorth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1751 int levelDepth)
1752{
1753 int x1E = (ix1 << 1);
1754 int x1W = x1E + 1;
1755 int x2 = (ix2 << 1) + 1;
1756 int x3 = (ix3 << 1) + 1;
1757 int l = level + 1;
1758
1759 SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l);
1760 if (blockE)
1761 blockVector.push_back(blockE);
1762 else if (l < levelDepth)
1763 this->getSubBlocksTopNorth(x1E, x2, x3, l, blockVector, levelDepth);
1764
1765 SPtr<Block3D> blockW = this->getBlock(x1W, x2, x3, l);
1766 if (blockW)
1767 blockVector.push_back(blockW);
1768 else if (l < levelDepth)
1769 this->getSubBlocksTopNorth(x1W, x2, x3, l, blockVector, levelDepth);
1770}
1772void Grid3D::getSubBlocksTopSouth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1773 int levelDepth)
1774{
1775 int x1E = (ix1 << 1);
1776 int x1W = x1E + 1;
1777 int x2 = (ix2 << 1);
1778 int x3 = (ix3 << 1) + 1;
1779 int l = level + 1;
1780
1781 SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l);
1782 if (blockE)
1783 blockVector.push_back(blockE);
1784 else if (l < levelDepth)
1785 this->getSubBlocksTopSouth(x1E, x2, x3, l, blockVector, levelDepth);
1786
1787 SPtr<Block3D> blockW = this->getBlock(x1W, x2, x3, l);
1788 if (blockW)
1789 blockVector.push_back(blockW);
1790 else if (l < levelDepth)
1791 this->getSubBlocksTopSouth(x1W, x2, x3, l, blockVector, levelDepth);
1792}
1794void Grid3D::getSubBlocksBottomNorth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1795 int levelDepth)
1796{
1797 int x1E = ix1 << 1;
1798 int x1W = x1E + 1;
1799 int x2 = (ix2 << 1) + 1;
1800 int x3 = ix3 << 1;
1801 int l = level + 1;
1802
1803 SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l);
1804 if (blockE)
1805 blockVector.push_back(blockE);
1806 else if (l < levelDepth)
1807 this->getSubBlocksBottomNorth(x1E, x2, x3, l, blockVector, levelDepth);
1808
1809 SPtr<Block3D> blockW = this->getBlock(x1W, x2, x3, l);
1810 if (blockW)
1811 blockVector.push_back(blockW);
1812 else if (l < levelDepth)
1813 this->getSubBlocksBottomNorth(x1W, x2, x3, l, blockVector, levelDepth);
1814}
1816void Grid3D::getSubBlocksBottomSouth(int ix1, int ix2, int ix3, int level, vector<SPtr<Block3D>> &blockVector,
1817 int levelDepth)
1818{
1819 int x1E = (ix1 << 1);
1820 int x1W = x1E + 1;
1821 int x2 = ix2 << 1;
1822 int x3 = ix3 << 1;
1823 int l = level + 1;
1824
1825 SPtr<Block3D> blockE = this->getBlock(x1E, x2, x3, l);
1826 if (blockE)
1827 blockVector.push_back(blockE);
1828 else if (l < levelDepth)
1829 this->getSubBlocksBottomSouth(x1E, x2, x3, l, blockVector, levelDepth);
1830
1831 SPtr<Block3D> blockW = this->getBlock(x1W, x2, x3, l);
1832 if (blockW)
1833 blockVector.push_back(blockW);
1834 else if (l < levelDepth)
1835 this->getSubBlocksBottomSouth(x1W, x2, x3, l, blockVector, levelDepth);
1836}
1838// space-diagonals
1840void Grid3D::getSubBlocksTopNorthEast(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1841 int levelDepth)
1842{
1843 int x1 = (ix1 << 1) + 1;
1844 int x2 = (ix2 << 1) + 1;
1845 int x3 = (ix3 << 1) + 1;
1846 int l = level + 1;
1847
1848 SPtr<Block3D> blockTNE = this->getBlock(x1, x2, x3, l);
1849 if (blockTNE)
1850 blockVector.push_back(blockTNE);
1851 else if (l < levelDepth)
1852 this->getSubBlocksTopNorthEast(x1, x2, x3, l, blockVector, levelDepth);
1853}
1855void Grid3D::getSubBlocksTopNorthWest(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1856 int levelDepth)
1857{
1858 int x1 = ix1 << 1;
1859 int x2 = (ix2 << 1) + 1;
1860 int x3 = (ix3 << 1) + 1;
1861 int l = level + 1;
1862
1863 SPtr<Block3D> blockTNW = this->getBlock(x1, x2, x3, l);
1864 if (blockTNW)
1865 blockVector.push_back(blockTNW);
1866 else if (l < levelDepth)
1867 this->getSubBlocksTopNorthWest(x1, x2, x3, l, blockVector, levelDepth);
1868}
1870void Grid3D::getSubBlocksTopSouthEast(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1871 int levelDepth)
1872{
1873 int x1 = (ix1 << 1) + 1;
1874 int x2 = ix2 << 1;
1875 int x3 = (ix3 << 1) + 1;
1876 int l = level + 1;
1877
1878 SPtr<Block3D> blockTNW = this->getBlock(x1, x2, x3, l);
1879 if (blockTNW)
1880 blockVector.push_back(blockTNW);
1881 else if (l < levelDepth)
1882 this->getSubBlocksTopSouthEast(x1, x2, x3, l, blockVector, levelDepth);
1883}
1885void Grid3D::getSubBlocksTopSouthWest(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1886 int levelDepth)
1887{
1888 int x1 = ix1 << 1;
1889 int x2 = ix2 << 1;
1890 int x3 = (ix3 << 1) + 1;
1891 int l = level + 1;
1892
1893 SPtr<Block3D> blockTSW = this->getBlock(x1, x2, x3, l);
1894 if (blockTSW)
1895 blockVector.push_back(blockTSW);
1896 else if (l < levelDepth)
1897 this->getSubBlocksTopSouthWest(x1, x2, x3, l, blockVector, levelDepth);
1898}
1900void Grid3D::getSubBlocksBottomNorthEast(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1901 int levelDepth)
1902{
1903 int x1 = (ix1 << 1) + 1;
1904 int x2 = (ix2 << 1) + 1;
1905 int x3 = ix3 << 1;
1906 int l = level + 1;
1907
1908 SPtr<Block3D> blockBNE = this->getBlock(x1, x2, x3, l);
1909 if (blockBNE)
1910 blockVector.push_back(blockBNE);
1911 else if (l < levelDepth)
1912 this->getSubBlocksBottomNorthEast(x1, x2, x3, l, blockVector, levelDepth);
1913}
1915void Grid3D::getSubBlocksBottomNorthWest(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1916 int levelDepth)
1917{
1918 int x1 = ix1 << 1;
1919 int x2 = (ix2 << 1) + 1;
1920 int x3 = ix3 << 1;
1921 int l = level + 1;
1922
1923 SPtr<Block3D> blockBNW = this->getBlock(x1, x2, x3, l);
1924 if (blockBNW)
1925 blockVector.push_back(blockBNW);
1926 else if (l < levelDepth)
1927 this->getSubBlocksBottomNorthWest(x1, x2, x3, l, blockVector, levelDepth);
1928}
1930void Grid3D::getSubBlocksBottomSouthEast(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1931 int levelDepth)
1932{
1933 int x1 = (ix1 << 1) + 1;
1934 int x2 = ix2 << 1;
1935 int x3 = ix3 << 1;
1936 int l = level + 1;
1937
1938 SPtr<Block3D> blockBSE = this->getBlock(x1, x2, x3, l);
1939 if (blockBSE)
1940 blockVector.push_back(blockBSE);
1941 else if (l < levelDepth)
1942 this->getSubBlocksBottomSouthEast(x1, x2, x3, l, blockVector, levelDepth);
1943}
1945void Grid3D::getSubBlocksBottomSouthWest(int ix1, int ix2, int ix3, int level, std::vector<SPtr<Block3D>> &blockVector,
1946 int levelDepth)
1947{
1948 int x1 = ix1 << 1;
1949 int x2 = ix2 << 1;
1950 int x3 = ix3 << 1;
1951 int l = level + 1;
1952
1953 SPtr<Block3D> blockBSW = this->getBlock(x1, x2, x3, l);
1954 if (blockBSW)
1955 blockVector.push_back(blockBSW);
1956 else if (l < levelDepth)
1957 this->getSubBlocksBottomSouthWest(x1, x2, x3, l, blockVector, levelDepth);
1958}
1960void Grid3D::getBlocks(int level, std::vector<SPtr<Block3D>> &blockVector)
1961{
1962 for (Block3DMap::value_type b : levelSet[level]) {
1963 blockVector.push_back(b.second);
1964 }
1965}
1967void Grid3D::getBlocks(int level, int rank, std::vector<SPtr<Block3D>> &blockVector)
1968{
1969 for (Block3DMap::value_type b : levelSet[level]) {
1970 SPtr<Block3D> block = b.second;
1971 int blockRank = block->getRank();
1972 if (blockRank == rank) {
1973 blockVector.push_back(b.second);
1974 }
1975 }
1976}
1978void Grid3D::getBlocks(int level, int rank, bool active, std::vector<SPtr<Block3D>> &blockVector)
1979{
1980 for (Block3DMap::value_type b : levelSet[level]) {
1981 SPtr<Block3D> block = b.second;
1982 int blockRank = block->getRank();
1983
1984 if (blockRank == rank && active ? block->isActive() : block->isNotActive()) {
1985 blockVector.push_back(b.second);
1986 }
1987 }
1988}
1991{
1992 for (int i = d3q27_system::MAXLEVEL; i >= 0; i--)
1993 if (this->levelSet[i].size() > 0)
1994 return (i);
1995 return (-1);
1996}
1999{
2000 for (int i = 0; i <= d3q27_system::MAXLEVEL; i++)
2001 if (this->levelSet[i].size() > 0)
2002 return (i);
2003 return (-1);
2004}
2006void Grid3D::setNX1(int nx1) { this->nx1 = nx1; }
2008void Grid3D::setNX2(int nx2) { this->nx2 = nx2; }
2010void Grid3D::setNX3(int nx3) { this->nx3 = nx3; }
2012int Grid3D::getNX1() const { return this->nx1; }
2014int Grid3D::getNX2() const { return this->nx2; }
2016int Grid3D::getNX3() const { return this->nx3; }
2018void Grid3D::deleteBlocks(const std::vector<int> &ids)
2019{
2020 for (int i : ids) {
2021 SPtr<Block3D> block = getBlock(i);
2022 if (block)
2023 this->deleteBlock(block);
2024 }
2025}
2028{
2029 int c = 0;
2030 for (Block3DMap l : levelSet) {
2031 c += (int)l.size();
2032 }
2033 return c;
2034}
2036int Grid3D::getNumberOfBlocks(int level) { return (int)levelSet[level].size(); }
2038void Grid3D::getBlocksByCuboid(real minX1, real minX2, real minX3, real maxX1, real maxX2, real maxX3,
2039 std::vector<SPtr<Block3D>> &blocks)
2040{
2043
2045 // MINIMALE BLOCK-INDIZES BESTIMMEN
2046 //
2047 // min:
2048 real dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3) * (1 << finestLevel);
2049 real dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3) * (1 << finestLevel);
2050 real dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3) * (1 << finestLevel);
2051
2052 // Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden,
2053 // da beim Transformieren der "groessere" Index rauskommt
2054 int iMinX1 = (int)dMinX1;
2055 if (ub_math::zero(dMinX1 - iMinX1))
2056 iMinX1 -= 1;
2057 int iMinX2 = (int)dMinX2;
2058 if (ub_math::zero(dMinX2 - iMinX2))
2059 iMinX2 -= 1;
2060 int iMinX3 = (int)dMinX3;
2061 if (ub_math::zero(dMinX3 - iMinX3))
2062 iMinX3 -= 1;
2063
2064 // max (hier kann die Zusatzabfrage vernachlaessigt werden):
2065 int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel));
2066 int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel));
2067 int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel));
2068
2069 SPtr<Block3D> block;
2070
2071 // set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen
2072 std::set<SPtr<Block3D>> blockset;
2073 for (int level = coarsestLevel; level <= finestLevel; level++) {
2074 // damit bei negativen werten auch der "kleinere" genommen wird -> floor!
2075 int minx1 = (int)std::floor((real)iMinX1 / (1 << (finestLevel - level)));
2076 int minx2 = (int)std::floor((real)iMinX2 / (1 << (finestLevel - level)));
2077 int minx3 = (int)std::floor((real)iMinX3 / (1 << (finestLevel - level)));
2078
2079 int maxx1 = iMaxX1 / (1 << (finestLevel - level));
2080 int maxx2 = iMaxX2 / (1 << (finestLevel - level));
2081 int maxx3 = iMaxX3 / (1 << (finestLevel - level));
2082
2083 for (int ix1 = minx1; ix1 <= maxx1; ix1++)
2084 for (int ix2 = minx2; ix2 <= maxx2; ix2++)
2085 for (int ix3 = minx3; ix3 <= maxx3; ix3++)
2086 if ((block = this->getBlock(ix1, ix2, ix3, level))) {
2087 if (block->getRank() == rank) {
2088 blockset.insert(block);
2089 }
2090 }
2091 }
2092
2093 blocks.resize(blockset.size());
2094 std::copy(blockset.begin(), blockset.end(), blocks.begin());
2095}
2097void Grid3D::getBlocksByCuboid(int level, real minX1, real minX2, real minX3, real maxX1, real maxX2,
2098 real maxX3, std::vector<SPtr<Block3D>> &blocks)
2099{
2101 // MINIMALE BLOCK-INDIZES BESTIMMEN
2102 //
2103 // min:
2104 real dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3) * (1 << level);
2105 real dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3) * (1 << level);
2106 real dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3) * (1 << level);
2107
2108 // Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden:
2109 int iMinX1 = (int)dMinX1;
2110 if (ub_math::zero(dMinX1 - iMinX1))
2111 iMinX1 -= 1;
2112 int iMinX2 = (int)dMinX2;
2113 if (ub_math::zero(dMinX2 - iMinX2))
2114 iMinX2 -= 1;
2115 int iMinX3 = (int)dMinX3;
2116 if (ub_math::zero(dMinX3 - iMinX3))
2117 iMinX3 -= 1;
2118
2119 // max:
2120 int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3) * (1 << level));
2121 int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3) * (1 << level));
2122 int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3) * (1 << level));
2123
2124 // set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen
2125 std::set<SPtr<Block3D>> blockset;
2126 SPtr<Block3D> block;
2127
2128 for (int ix1 = iMinX1; ix1 <= iMaxX1; ix1++)
2129 for (int ix2 = iMinX2; ix2 <= iMaxX2; ix2++)
2130 for (int ix3 = iMinX3; ix3 <= iMaxX3; ix3++)
2131 if ((block = this->getBlock(ix1, ix2, ix3, level))) {
2132 if (block->getRank() == rank) {
2133 blockset.insert(block);
2134 }
2135 }
2136
2137 blocks.resize(blockset.size());
2138 std::copy(blockset.begin(), blockset.end(), blocks.begin());
2139}
2141void Grid3D::getAllBlocksByCuboid(real minX1, real minX2, real minX3, real maxX1, real maxX2, real maxX3,
2142 std::vector<SPtr<Block3D>> &blocks)
2143{
2146
2148 // MINIMALE BLOCK-INDIZES BESTIMMEN
2149 //
2150 // min:
2151 real dMinX1 = trafo->transformForwardToX1Coordinate(minX1, minX2, minX3) * (1 << finestLevel);
2152 real dMinX2 = trafo->transformForwardToX2Coordinate(minX1, minX2, minX3) * (1 << finestLevel);
2153 real dMinX3 = trafo->transformForwardToX3Coordinate(minX1, minX2, minX3) * (1 << finestLevel);
2154
2155 // Achtung, wenn minX1 genau auf grenze zwischen zwei bloecken -> der "kleinere" muss genommen werden,
2156 // da beim Transformieren der "groessere" Index rauskommt
2157 int iMinX1 = (int)dMinX1;
2158 if (ub_math::zero(dMinX1 - iMinX1))
2159 iMinX1 -= 1;
2160 int iMinX2 = (int)dMinX2;
2161 if (ub_math::zero(dMinX2 - iMinX2))
2162 iMinX2 -= 1;
2163 int iMinX3 = (int)dMinX3;
2164 if (ub_math::zero(dMinX3 - iMinX3))
2165 iMinX3 -= 1;
2166
2167 // max (hier kann die Zusatzabfrage vernachlaessigt werden):
2168 int iMaxX1 = (int)(trafo->transformForwardToX1Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel));
2169 int iMaxX2 = (int)(trafo->transformForwardToX2Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel));
2170 int iMaxX3 = (int)(trafo->transformForwardToX3Coordinate(maxX1, maxX2, maxX3) * (1 << finestLevel));
2171
2172 SPtr<Block3D> block;
2173
2174 // set, um doppelte bloecke zu vermeiden, die u.U. bei periodic auftreten koennen
2175 std::set<SPtr<Block3D>> blockset;
2176 for (int level = coarsestLevel; level <= finestLevel; level++) {
2177 // damit bei negativen werten auch der "kleinere" genommen wird -> floor!
2178 int minx1 = (int)std::floor((real)iMinX1 / (1 << (finestLevel - level)));
2179 int minx2 = (int)std::floor((real)iMinX2 / (1 << (finestLevel - level)));
2180 int minx3 = (int)std::floor((real)iMinX3 / (1 << (finestLevel - level)));
2181
2182 int maxx1 = iMaxX1 / (1 << (finestLevel - level));
2183 int maxx2 = iMaxX2 / (1 << (finestLevel - level));
2184 int maxx3 = iMaxX3 / (1 << (finestLevel - level));
2185
2186 for (int ix1 = minx1; ix1 <= maxx1; ix1++)
2187 for (int ix2 = minx2; ix2 <= maxx2; ix2++)
2188 for (int ix3 = minx3; ix3 <= maxx3; ix3++)
2189 if ((block = this->getBlock(ix1, ix2, ix3, level))) {
2190 if (block) {
2191 blockset.insert(block);
2192 }
2193 }
2194 }
2195
2196 blocks.resize(blockset.size());
2197 std::copy(blockset.begin(), blockset.end(), blocks.begin());
2198}
2201 real &deltaX)
2202{
2203 int blocklevel = block->getLevel();
2204 worldX1 = block->getX1() / (float)(1 << blocklevel);
2205 worldX2 = block->getX2() / (float)(1 << blocklevel);
2206 worldX3 = block->getX3() / (float)(1 << blocklevel);
2207 deltaX = (real)1.0 / (real)(this->blockNx1 * (real)(1 << blocklevel));
2208
2209 if (this->trafo) {
2211 worldX1 = this->trafo->transformBackwardToX1Coordinate(x1tmp, x2tmp, x3tmp);
2212 worldX2 = this->trafo->transformBackwardToX2Coordinate(x1tmp, x2tmp, x3tmp);
2213 worldX3 = this->trafo->transformBackwardToX3Coordinate(x1tmp, x2tmp, x3tmp);
2214 deltaX = this->trafo->getX1CoordinateScaling() / (real)(this->blockNx1 * (real)(1 << blocklevel));
2215 }
2216}
2219{
2220 int blocklevel = block->getLevel();
2221 worldX1 = block->getX1() / (float)(1 << blocklevel);
2222 worldX2 = block->getX2() / (float)(1 << blocklevel);
2223 worldX3 = block->getX3() / (float)(1 << blocklevel);
2224
2225 if (this->trafo) {
2227 worldX1 = this->trafo->transformBackwardToX1Coordinate(x1tmp, x2tmp, x3tmp);
2228 worldX2 = this->trafo->transformBackwardToX2Coordinate(x1tmp, x2tmp, x3tmp);
2229 worldX3 = this->trafo->transformBackwardToX3Coordinate(x1tmp, x2tmp, x3tmp);
2230 }
2231}
2234{
2235 return static_cast<int>(offset + 0.5);
2236}
2238void Grid3D::setGhostLayerWidth(int ghostLayerWidth)
2239{
2240 this->offset = static_cast<real>(ghostLayerWidth) - c1o2;
2241}
2243void Grid3D::setTimeStep(real step) { timeStep = step; }
2245real Grid3D::getTimeStep() const { return timeStep; }
2248{
2249 for (int x3 = val<3>(minInd); x3 < val<3>(maxInd); x3++) {
2250 for (int x2 = val<2>(minInd); x2 < val<2>(maxInd); x2++) {
2251 for (int x1 = val<1>(minInd); x1 < val<1>(maxInd); x1++) {
2252 SPtr<Block3D> block(new Block3D(x1, x2, x3, 0));
2253 this->addBlock(block);
2254 }
2255 }
2256 }
2257}
2259// void Grid3D::notifyObservers( double step )
2260//{
2261// for(ObserverPtr o, observers)
2262// {
2263// o->update(step);
2264// }
2265//
2266// //std::list<ObserverWeakPtr>::iterator iter = observers.begin();
2267//
2268// //GridObserversSet::iterator iter = observers.begin();
2269// //while(iter != observers.end())
2270// //{
2271// // if ((*iter).expired())
2272// // {
2273// // iter = observers.erase(iter);
2274// // }
2275// // else
2276// // {
2277// // ObserverPtr observer = (*iter).lock(); // create a shared_ptr from the weak_ptr
2278// // observer->update(step);
2279// // ++iter;
2280// // }
2281// //}
2282//
2283//}
2285// void Grid3D::addObserver( ObserverPtr observer )
2286//{
2287// observers.insert(observer);
2288// //observers.push_back(observer);
2289//}
2291// void Grid3D::removeObserver( ObserverPtr observer )
2292//{
2293// observers.erase(observer);
2294// //observers.remove(observer);
2295//}
2297void Grid3D::deleteBlockIDs() { this->blockIdMap.clear(); }
2300{
2302
2303 int startLevel = getCoarsestInitializedLevel();
2304 int stopLevel = getFinestInitializedLevel();
2305 int counter = 0;
2306
2307 for (int l = startLevel; l <= stopLevel; l++) {
2308 std::vector<SPtr<Block3D>> blockVector;
2309 getBlocks(l, blockVector);
2310 for (SPtr<Block3D> block : blockVector) {
2311 block->setGlobalID(counter);
2312 blockIdMap.insert(std::make_pair(counter, block));
2313 // Block3D::setMaxGlobalID(counter);
2314 counter++;
2315 }
2316 }
2317}
2318
2319
2321void Grid3D::updateDistributedBlocks(std::shared_ptr<vf::parallel::Communicator> comm)
2322{
2323
2324 std::vector<int> blocks;
2325
2326 if (comm->isRoot()) {
2327 int startLevel = getCoarsestInitializedLevel();
2328 int stopLevel = getFinestInitializedLevel();
2329
2330 for (int l = startLevel; l <= stopLevel; l++) {
2331 std::vector<SPtr<Block3D>> blockVector;
2332 getBlocks(l, blockVector);
2333 for (SPtr<Block3D> block : blockVector) {
2334 blocks.push_back(block->getX1());
2335 blocks.push_back(block->getX2());
2336 blocks.push_back(block->getX3());
2337 blocks.push_back(l);
2338 blocks.push_back(block->getGlobalID());
2339 }
2340 }
2341 }
2342
2343 comm->broadcast(blocks);
2344
2345 if (!comm->isRoot()) {
2346 int startLevel = getCoarsestInitializedLevel();
2347 int stopLevel = getFinestInitializedLevel();
2348
2349 blockIdMap.clear();
2350
2351 for (int l = startLevel; l <= stopLevel; l++) {
2352 levelSet[l].clear();
2353 }
2354 this->levelSet.clear();
2355 levelSet.resize(d3q27_system::MAXLEVEL + 1);
2356
2357 int rsize = (int)blocks.size();
2358 for (int i = 0; i < rsize; i += 5) {
2359 SPtr<Block3D> block(new Block3D(blocks[i], blocks[i + 1], blocks[i + 2], blocks[i + 3]));
2360 block->setGlobalID(blocks[i + 4]);
2361 this->addBlock(block);
2362 }
2363 }
2364}
2365
2367
A class implements a block structure.
Definition Block3D.h:49
Abstract class provides interface for visitor design pettern.
A class provides 3d coordinate transformation.
This Class provides basic 3D vector objects.
Definition GbVector3D.h:47
std::map< int, SPtr< Block3D > > BlockIDMap
Definition Grid3D.h:64
ub_keys::Key3< int > Block3DKey
Definition Grid3D.h:62
std::map< Block3DKey, SPtr< Block3D > > Block3DMap
Definition Grid3D.h:63
std::vector< SPtr< Interactor3D > > Interactor3DSet
Definition Grid3D.h:66
Abstract class provides interface for visitor design pettern.
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
const SPtr< CoordinateTransformation3D > getCoordinateTransformator() const
Definition Grid3D.cpp:492
int getFinestInitializedLevel()
Definition Grid3D.cpp:1990
void getNeighborsTopEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:830
void calcStartCoordinatesWithOutOverlap(SPtr< Block3D > block, real &worldX1, real &worldX2, real &worldX3)
Definition Grid3D.cpp:2218
void getNeighborsBottomEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:900
SPtr< Block3D > collapseBlock(int fix1, int fix2, int fix3, int flevel, int levelDepth)
Definition Grid3D.cpp:341
UbTupleDouble3 getBlockLengths(SPtr< Block3D > block) const
Definition Grid3D.cpp:475
void getSubBlocksTopSouthEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1870
UbTupleInt3 getNodeIndexes(SPtr< Block3D > block, real nodeX1Coord, real nodeX2Coord, real nodeX3Coord) const
Definition Grid3D.cpp:525
void setNX2(int nx2)
Definition Grid3D.cpp:2008
void addBlock(SPtr< Block3D > block)
Definition Grid3D.cpp:138
void getNeighborsSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:710
void getSubBlocksBottomSouth(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1816
void getSubBlocksBottomSouthWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1945
void getAllBlocksByCuboid(real minX1, real minX2, real minX3, real maxX1, real maxX2, real maxX3, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:2141
int getNumberOfBlocks()
Definition Grid3D.cpp:2027
void getSubBlocksTopWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1681
void deleteConnectors()
Definition Grid3D.cpp:409
void getNeighborsSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:794
SPtr< Block3D > getNeighborBlock(int dir, int ix1, int ix2, int ix3, int level) const
Definition Grid3D.cpp:622
void getSubBlocksTopNorthWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1855
void getNeighborsTopSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:881
void getNeighborsTopNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:864
void getSubBlocksSouthWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1613
BlockIDMap & getBlockIDs()
Definition Grid3D.cpp:225
void getSubBlocksSouth(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1464
SPtr< Block3D > getBlock(int ix1, int ix2, int ix3, int level) const
Definition Grid3D.cpp:182
void getNeighborsTopSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1002
void getNeighborsTopNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:968
int getNX2() const
Definition Grid3D.cpp:2014
void getSubBlocksNorthWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1591
void getNeighborsTopSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1019
void setTimeStep(real step)
Definition Grid3D.cpp:2243
bool isPeriodicX2() const
Definition Grid3D.cpp:429
GbVector3D getNodeCoordinates(SPtr< Block3D > block, int ix1, int ix2, int ix3) const
Definition Grid3D.cpp:512
void getBlocksByCuboid(real minX1, real minX2, real minX3, real maxX1, real maxX2, real maxX3, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:2038
void getSubBlocksTopNorth(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1750
void accept(Block3DVisitor &blockVisitor)
Definition Grid3D.cpp:90
void calcStartCoordinatesAndDelta(SPtr< Block3D > block, real &worldX1, real &worldX2, real &worldX3, real &deltaX)
Definition Grid3D.cpp:2200
void setBundle(int bundle)
Definition Grid3D.cpp:425
int getBundle() const
Definition Grid3D.cpp:423
bool hasLevel(int level) const
Definition Grid3D.cpp:600
int getNX3() const
Definition Grid3D.cpp:2016
void getSubBlocksTopEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1659
void getNeighborBlocksForDirection(int dir, int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1104
void getAllNeighbors(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:637
void getNeighborsZero(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1193
void checkLevel(int level)
Definition Grid3D.cpp:587
void setNX1(int nx1)
Definition Grid3D.cpp:2006
void getNeighborsTopWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:847
void getSubBlocksZero(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1210
bool isPeriodicX1() const
Definition Grid3D.cpp:427
int getRank() const
Definition Grid3D.cpp:421
void getNeighborsBottomWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:917
UbTupleDouble6 getBlockOversize() const
Definition Grid3D.cpp:488
void addAndInitInteractor(SPtr< Interactor3D > interactor, real timestep=0)
Definition Grid3D.cpp:82
UbTupleDouble3 getBlockWorldCoordinates(SPtr< Block3D > block) const
Definition Grid3D.cpp:553
void setPeriodicX3(bool value)
Definition Grid3D.cpp:437
void getNeighborsNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:661
void getNeighborsWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:742
void getBlocks(int level, std::vector< SPtr< Block3D > > &blockVector)
get blocks for level
Definition Grid3D.cpp:1960
void getSubBlocksNorth(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1430
void getNeighborsSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:811
void getSubBlocksBottomEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1703
UbTupleDouble3 getNodeOffset(SPtr< Block3D > block) const
Definition Grid3D.cpp:506
void getNeighborsEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:726
void updateDistributedBlocks(std::shared_ptr< vf::parallel::Communicator > comm)
Definition Grid3D.cpp:2321
void getSubBlocks(SPtr< Block3D > block, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:257
real getDeltaX(int level) const
Definition Grid3D.cpp:498
UbTupleInt3 getBlockIndexes(real blockX1Coord, real blockX2Coord, real blockX3Coord) const
Definition Grid3D.cpp:439
void getSubBlocksBottomNorthEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1900
void getNeighborBlocksForDirectionWithREST(int dir, int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1269
void getNeighborsBottomSouth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:951
real getTimeStep() const
Definition Grid3D.cpp:2245
void deleteBlocks()
Definition Grid3D.cpp:162
void fillExtentWithBlocks(UbTupleInt3 minInd, UbTupleInt3 maxInd)
Definition Grid3D.cpp:2247
void getSubBlocksBottom(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1532
void getNeighborsBottomSouthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1087
Interactor3DSet getInteractors()
Definition Grid3D.cpp:88
bool isPeriodicX3() const
Definition Grid3D.cpp:431
void setNX3(int nx3)
Definition Grid3D.cpp:2010
void getNeighborsNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:777
void getSubBlocksEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1361
void getNeighborsBottomNorth(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:934
void setCoordinateTransformator(SPtr< CoordinateTransformation3D > trafo)
Definition Grid3D.cpp:490
void getSubBlocksNorthEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1569
void renumberBlockIDs()
Definition Grid3D.cpp:2299
void addInteractor(SPtr< Interactor3D > interactor)
Definition Grid3D.cpp:80
void replaceBlock(SPtr< Block3D > block)
Definition Grid3D.cpp:174
void setPeriodicX2(bool value)
Definition Grid3D.cpp:435
void setPeriodicX1(bool value)
Definition Grid3D.cpp:433
int getCoarsestInitializedLevel()
Definition Grid3D.cpp:1998
void getNeighborsBottomSouthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1070
void getSubBlocksBottomSouthEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1930
void getSubBlocksBottomWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1725
int getNX1() const
Definition Grid3D.cpp:2012
Grid3D()
Definition Grid3D.cpp:53
UbTupleInt3 getBlockNX() const
Definition Grid3D.cpp:619
void getSubBlocksTopSouth(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1772
bool deleteBlock(SPtr< Block3D > block)
Definition Grid3D.cpp:147
void getNeighborsBottom(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:693
void getNeighborsNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:760
void getSubBlocksTopNorthEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1840
void getSubBlocksWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1396
bool expandBlock(int ix1, int ix2, int ix3, int level)
Definition Grid3D.cpp:291
void deleteBlockIDs()
Definition Grid3D.cpp:2297
void getNeighborsBottomNorthEast(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1036
void setGhostLayerWidth(int ghostLayerWidth)
Definition Grid3D.cpp:2238
void getSubBlocksBottomNorthWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1915
void getNeighborsTopNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:985
int getGhostLayerWidth() const
Definition Grid3D.cpp:2233
void setRank(int rank)
Definition Grid3D.cpp:419
void getSubBlocksBottomNorth(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1794
void setDeltaX(real dx)
Definition Grid3D.cpp:494
void getNeighborsBottomNorthWest(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:1053
void getSubBlocksTopSouthWest(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1885
void getSubBlocksTop(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1498
SPtr< Block3D > getSuperBlock(SPtr< Block3D > block)
Definition Grid3D.cpp:227
void setBlockNX(int nx1, int nx2, int nx3)
Definition Grid3D.cpp:612
void getNeighborsTop(int ix1, int ix2, int ix3, int level, int levelDepth, std::vector< SPtr< Block3D > > &blocks)
Definition Grid3D.cpp:677
void getSubBlocksSouthEast(int ix1, int ix2, int ix3, int level, std::vector< SPtr< Block3D > > &blockVector, int levelDepth)
Definition Grid3D.cpp:1635
#define UB_EXARGS
Definition UbException.h:73
UbTuple< double, double, double, double, double, double > UbTupleDouble6
Definition UbTuple.h:636
UbTuple< T1 > makeUbTuple(T1 const &a1)
Definition UbTuple.h:554
const int DX1[]
const int DX3[]
const int DX2[]
bool zero(const T &value)
Definition UbMath.h:139
std::string toString(const T &x, int precision=15)
Definition UbSystem.h:199