VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
D3Q27Interactor.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//
35//=======================================================================================
36
37#include "D3Q27Interactor.h"
40
42
43#include "BC.h"
44#include "BCArray3D.h"
45#include "BCSet.h"
46#include "Block3D.h"
47#include "BoundaryConditions.h"
48#include "Grid3D.h"
49#include "LBMKernel.h"
50#include <GbCuboid3D.h>
51#include <GbLine3D.h>
52
53using namespace std;
54
64 : Interactor3D(geoObject3D, grid, type), relevantForForces(false)
66 this->reinitWithStoredQsFlag = false;
67 this->initRayVectors();
71 : Interactor3D(geoObject3D, grid, type), relevantForForces(false)
72{
73 this->reinitWithStoredQsFlag = false;
74 this->addBC(BC);
75 this->initRayVectors();
76}
80 : Interactor3D(geoObject3D, grid, type, a), relevantForForces(false)
81{
82 this->reinitWithStoredQsFlag = false;
83 this->addBC(BC);
84 this->initRayVectors();
85}
90{
91 using namespace vf::lbm::dir;
92 using namespace vf::basics::constant;
93
94 int fdir;
95 real c1oS2 = vf::basics::constant::c1oSqrt2;
96 real c1oS3 = vf::basics::constant::c1oSqrt3;
97 fdir = dP00;
98 rayX1[fdir] = c1o1;
99 rayX2[fdir] = c0o1;
100 rayX3[fdir] = c0o1;
101 fdir = dM00;
102 rayX1[fdir] = -c1o1;
103 rayX2[fdir] = c0o1;
104 rayX3[fdir] = c0o1;
105 fdir = d0P0;
106 rayX1[fdir] = c0o1;
107 rayX2[fdir] = c1o1;
108 rayX3[fdir] = c0o1;
109 fdir = d0M0;
110 rayX1[fdir] = c0o1;
111 rayX2[fdir] = -c1o1;
112 rayX3[fdir] = c0o1;
113 fdir = d00P;
114 rayX1[fdir] = c0o1;
115 rayX2[fdir] = c0o1;
116 rayX3[fdir] = c1o1;
117 fdir = d00M;
118 rayX1[fdir] = c0o1;
119 rayX2[fdir] = c0o1;
120 rayX3[fdir] = -c1o1;
121 fdir = dPP0;
122 rayX1[fdir] = c1oS2;
123 rayX2[fdir] = c1oS2;
124 rayX3[fdir] = c0o1;
125 fdir = dMM0;
126 rayX1[fdir] = -c1oS2;
127 rayX2[fdir] = -c1oS2;
128 rayX3[fdir] = c0o1;
129 fdir = dPM0;
130 rayX1[fdir] = c1oS2;
131 rayX2[fdir] = -c1oS2;
132 rayX3[fdir] = c0o1;
133 fdir = dMP0;
134 rayX1[fdir] = -c1oS2;
135 rayX2[fdir] = c1oS2;
136 rayX3[fdir] = c0o1;
137 fdir = dP0P;
138 rayX1[fdir] = c1oS2;
139 rayX2[fdir] = c0o1;
140 rayX3[fdir] = c1oS2;
141 fdir = dM0M;
142 rayX1[fdir] = -c1oS2;
143 rayX2[fdir] = c0o1;
144 rayX3[fdir] = -c1oS2;
145 fdir = dP0M;
146 rayX1[fdir] = c1oS2;
147 rayX2[fdir] = c0o1;
148 rayX3[fdir] = -c1oS2;
149 fdir = dM0P;
150 rayX1[fdir] = -c1oS2;
151 rayX2[fdir] = c0o1;
152 rayX3[fdir] = c1oS2;
153 fdir = d0PP;
154 rayX1[fdir] = c0o1;
155 rayX2[fdir] = c1oS2;
156 rayX3[fdir] = c1oS2;
157 fdir = d0MM;
158 rayX1[fdir] = c0o1;
159 rayX2[fdir] = -c1oS2;
160 rayX3[fdir] = -c1oS2;
161 fdir = d0PM;
162 rayX1[fdir] = c0o1;
163 rayX2[fdir] = c1oS2;
164 rayX3[fdir] = -c1oS2;
165 fdir = d0MP;
166 rayX1[fdir] = c0o1;
167 rayX2[fdir] = -c1oS2;
168 rayX3[fdir] = c1oS2;
169
170 fdir = dMPP;
171 rayX1[fdir] = -c1oS3;
172 rayX2[fdir] = c1oS3;
173 rayX3[fdir] = c1oS3;
174 fdir = dPPP;
175 rayX1[fdir] = c1oS3;
176 rayX2[fdir] = c1oS3;
177 rayX3[fdir] = c1oS3;
178 fdir = dMMP;
179 rayX1[fdir] = -c1oS3;
180 rayX2[fdir] = -c1oS3;
181 rayX3[fdir] = c1oS3;
182 fdir = dPMP;
183 rayX1[fdir] = c1oS3;
184 rayX2[fdir] = -c1oS3;
185 rayX3[fdir] = c1oS3;
186 fdir = dMPM;
187 rayX1[fdir] = -c1oS3;
188 rayX2[fdir] = c1oS3;
189 rayX3[fdir] = -c1oS3;
190 fdir = dPPM;
191 rayX1[fdir] = c1oS3;
192 rayX2[fdir] = c1oS3;
193 rayX3[fdir] = -c1oS3;
194 fdir = dMMM;
195 rayX1[fdir] = -c1oS3;
196 rayX2[fdir] = -c1oS3;
197 rayX3[fdir] = -c1oS3;
198 fdir = dPMM;
199 rayX1[fdir] = c1oS3;
200 rayX2[fdir] = -c1oS3;
201 rayX3[fdir] = -c1oS3;
202}
205{
206 UBLOG(logDEBUG5, "D3Q27Interactor::initInteractor - "
207 << " for timestep = " << timeStep);
208
210 // init bcs
211 int nofAdapter = (int)BCs.size();
212 if (nofAdapter == 0) {
213 UBLOG(logWARNING, "WARNING - D3Q27Interactor::initInteractor Warning - no nodeAdapter available");
214 }
215 bool needTimeDependence = false;
216 for (int pos = 0; pos < nofAdapter; ++pos) {
217 BCs[pos]->init(this, timeStep);
218 if (BCs[pos]->isTimeDependent())
219 needTimeDependence = true;
220 }
222 this->setTimeDependent();
223 else
224 this->unsetTimeDependent();
225
226 updateBlocks();
227}
230{
231 UBLOG(logDEBUG5, "D3Q27Interactor::updateInteractor - for timestep = " << timestep);
232
234 // update bcs
235 int nofAdapter = (int)BCs.size();
236 if (nofAdapter == 0) {
237 UBLOG(logERROR, "WARNING - D3Q27Interactor::updateInteractor Warning - no nodeAdapter available for ");
238 }
239
240 bool needTimeDependence = false;
241
242 for (int pos = 0; pos < nofAdapter; ++pos) {
243 BCs[pos]->update(this, timestep);
244 if (BCs[pos]->isTimeDependent())
245 needTimeDependence = true;
246 }
248 this->setTimeDependent();
249 else
250 this->unsetTimeDependent();
251
252 for (BcNodeIndicesMap::value_type t : bcNodeIndicesMap) {
253 SPtr<Block3D> block = t.first;
254 std::set<std::vector<int>> &transNodeIndicesSet = t.second;
255
256 if (block->isNotActive() || !block)
257 continue;
258
259 SPtr<LBMKernel> kernel = block->getKernel();
260 SPtr<BCArray3D> bcArray = kernel->getBCSet()->getBCArray();
261
262 set<std::vector<int>>::iterator setPos;
263
264 for (setPos = transNodeIndicesSet.begin(); setPos != transNodeIndicesSet.end(); ++setPos) {
265 int x1 = (*setPos)[0];
266 int x2 = (*setPos)[1];
267 int x3 = (*setPos)[2];
268 GbVector3D coords = grid.lock()->getNodeCoordinates(block, x1, x2, x3);
269 real worldX1 = coords[0];
270 real worldX2 = coords[1];
271 real worldX3 = coords[2];
272
273 SPtr<BoundaryConditions> bc = bcArray->getBC(x1, x2, x3);
274 if (bc) // may be that the BC has been deleted by the solid setting of another interactor
275 {
276 for (size_t i = 0; i < BCs.size(); i++)
277 BCs[i]->adaptBC(*this, bc, worldX1, worldX2, worldX3, timestep);
278 }
279 }
280 }
281}
283// calculation takes place in the real coordinate system !!!
284// not normalized!
285// x1, x2, x3 are the coordinates at the bottom left of the "system"
286// extendedBoundingGeoOfGeoObject MUST already have been magnified by delta_x_level in each direction for SOLID
288{
289 using namespace vf::lbm::dir;
290 using namespace vf::basics::constant;
291
292 if (!block)
293 return false;
294
295 if (block->isNotActive())
296 return false; // continue;
297
302
303 real timestep = c0o1;
304 bool oneEntryGotBC = false;
305 bool gotQs = false;
307
308 SPtr<LBMKernel> kernel = block->getKernel();
309 SPtr<BCArray3D> bcArray = kernel->getBCSet()->getBCArray();
310
312
313 int startIX1 = 0;
314 int startIX2 = 0;
315 int startIX3 = 0;
316 int stopIX1 = (int)bcArray->getNX1();
317 int stopIX2 = (int)bcArray->getNX2();
318 int stopIX3 = (int)bcArray->getNX3();
319
320 real dx = grid.lock()->getDeltaX(block);
321
322 // other boundingRect than in init, because here the boundrect has to be increased by one dx
324 geoObject3D->getX1Minimum() - 1.02 * dx, geoObject3D->getX2Minimum() - 1.02 * dx,
325 geoObject3D->getX3Minimum() - 1.02 * dx, geoObject3D->getX1Maximum() + 1.02 * dx,
326 geoObject3D->getX2Maximum() + 1.02 * dx, geoObject3D->getX3Maximum() + 1.02 * dx);
327
328 real deltaX1 = dx, deltaX2 = dx, deltaX3 = dx;
329
330 if (geoObject3D->hasRaytracing() || (this->isInverseSolid() && geoObject3D->raytracingSupportsPointsInside())) {
331 // if deltaX1==deltaX2==deltaX3 (must for LB!!)
332 if (!ub_math::zero(deltaX1 - deltaX2 + deltaX1 - deltaX3 + deltaX2 - deltaX3))
333 throw UbException(
334 UB_EXARGS, "fuer den bei LB nicht vorkommenden Fall deltaX1!=deltaX2!=deltaX3 nicht implementiert ");
335
336 vector<real> distNeigh(d3q27_system::FENDDIR + 1, vf::basics::constant::cSqrt2 * deltaX1);
337 distNeigh[dP00] = distNeigh[dM00] = distNeigh[d0P0] = deltaX1;
338 distNeigh[d0M0] = distNeigh[d00P] = distNeigh[d00M] = deltaX1;
339 distNeigh[dPP0] = distNeigh[dMP0] = distNeigh[dMM0] =
340 distNeigh[dPM0] = vf::basics::constant::cSqrt2 * deltaX1;
341 distNeigh[dP0P] = distNeigh[d0PP] = distNeigh[dM0P] =
342 distNeigh[d0MP] = vf::basics::constant::cSqrt2 * deltaX1;
343 distNeigh[dP0M] = distNeigh[d0PM] = distNeigh[dM0M] =
344 distNeigh[d0MM] = vf::basics::constant::cSqrt2 * deltaX1;
345 distNeigh[dPPP] = distNeigh[dMPP] = distNeigh[dPMP] =
346 distNeigh[dMMP] = vf::basics::constant::cSqrt3 * deltaX1;
347 distNeigh[dPPM] = distNeigh[dMPM] = distNeigh[dPMM] =
348 distNeigh[dMMM] = vf::basics::constant::cSqrt3 * deltaX1;
349 real q;
350 bool pointOnBoundary = false;
351
352 //#ifdef _OPENMP
353 // #pragma omp parallel for private(internX1,internX2,internX3,gotQs,bc,q )
354 //#endif
355 for (int ix3 = startIX3; ix3 < stopIX3; ix3++) {
356 for (int ix2 = startIX2; ix2 < stopIX2; ix2++) {
357 for (int ix1 = startIX1; ix1 < stopIX1; ix1++) {
358 // TODO: further, investigate if this is not a mistake
359 if (bcArray->isUndefined(ix1, ix2, ix3))
360 continue;
361
362 GbVector3D coords = grid.lock()->getNodeCoordinates(block, ix1, ix2, ix3);
363 internX1 = coords[0];
364 internX2 = coords[1];
365 internX3 = coords[2];
366
367 // Point in the object test is superfluous, since the start and stop indices already exist
368 // are determined -> only point-in-cube indexes are considered
369 if (extendedBoundingGeoOfGeoObject.isPointInGbObject3D(internX1, internX2, internX3)) {
370 if (this->isSolid()) {
371 if (this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3)) {
372 {
373 solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3));
374 bcArray->setSolid(ix1, ix2, ix3);
375 }
376 continue;
377 }
378 } else if (this->isInverseSolid()) {
379 // in inverse solid all nodes are OUTSIDE and on the boundary SOLID
380 if (!this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3,
382 pointOnBoundary == true) {
383
384 {
385 solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3));
386 bcArray->setSolid(ix1, ix2, ix3);
387 }
388 continue;
389 }
390 }
391
392 if (bcArray->isSolid(ix1, ix2, ix3))
393 continue;
394
395 gotQs = false;
396
397 for (int fdir = d3q27_system::FSTARTDIR; fdir <= d3q27_system::FENDDIR; fdir++) {
398 q = geoObject3D->getIntersectionRaytraceFactor(internX1, internX2, internX3, rayX1[fdir],
399 rayX2[fdir], rayX3[fdir]);
400 q /= distNeigh[fdir];
401
402 // assert(UbMath::lessEqual(q, c1o1));
403
404 if (ub_math::inClosedInterval(q, c1o1, c1o1))
405 q = c1o1;
406 if (ub_math::greater(q, c0o1) && ub_math::lessEqual(q, c1o1)) {
407 //#pragma omp critical (BC_CHANGE)
408 {
409 bc = bcArray->getBC(ix1, ix2, ix3);
410 if (!bc) {
411 bc = std::make_shared<BoundaryConditions>();
412 bcArray->setBC(ix1, ix2, ix3, bc);
413 }
414
415 if (bc->hasNoSlipBoundary()) {
416 bc->setBoundaryVelocityX1(c0o1);
417 bc->setBoundaryVelocityX2(c0o1);
418 bc->setBoundaryVelocityX3(c0o1);
419 }
420
421 for (int index = (int)BCs.size() - 1; index >= 0; --index)
422 BCs[index]->adaptBCForDirection(*this, bc, internX1, internX2, internX3,
423 q, fdir, timestep);
424 }
425
426 gotQs = true;
427 }
428 }
429
430 if (gotQs) {
431 {
432 oneEntryGotBC = true;
433
434 std::vector<int> p(3);
435 p[0] = ix1;
436 p[1] = ix2;
437 p[2] = ix3;
438 transNodeIndices.insert(p);
439
440 for (int index = (int)BCs.size() - 1; index >= 0; --index)
441 BCs[index]->adaptBC(*this, bc, internX1, internX2, internX3, timestep);
442 }
443 }
444 } else if (this->isInverseSolid()) {
445 // bei inverse solid sind alle Knoten AUSSERHALB und auf der boundary SOLID
446 if (!this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3, pointOnBoundary) ||
447 pointOnBoundary == true) {
448 {
449 solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3));
450 bcArray->setSolid(ix1, ix2, ix3);
451 }
452 continue;
453 }
454 }
455 }
456 }
457 }
458 } else // clipping -> slower (currently also used for all inverse Solid objects whose raytracing does not work for
459 // nodes INSIDE the geo)
460 {
461 bool pointOnBoundary = false;
462 for (int ix1 = startIX1; ix1 < stopIX1; ix1++) {
463 for (int ix2 = startIX2; ix2 < stopIX2; ix2++) {
464 for (int ix3 = startIX3; ix3 < stopIX3; ix3++) {
465 if (bcArray->isSolid(ix1, ix2, ix3) || bcArray->isUndefined(ix1, ix2, ix3))
466 continue;
467
468 GbVector3D coords = grid.lock()->getNodeCoordinates(block, ix1, ix2, ix3);
469 internX1 = coords[0];
470 internX2 = coords[1];
471 internX3 = coords[2];
472
473 if (extendedBoundingGeoOfGeoObject.isPointInGbObject3D(internX1, internX2, internX3)) {
474 if (this->isSolid() && this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3)) {
475 {
476 solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3));
477 bcArray->setSolid(ix1, ix2, ix3);
478 }
479 continue;
480 } else if (this->isInverseSolid()) {
481 // bei inverse solid sind alle Knoten AUSSERHALB und auf der boundary SOLID
482 if (!this->geoObject3D->isPointInGbObject3D(internX1, internX2, internX3,
484 pointOnBoundary == true) {
485 {
486 solidNodeIndices.insert(UbTupleInt3(ix1, ix2, ix3));
487 bcArray->setSolid(ix1, ix2, ix3);
488 }
489 continue;
490 }
491 }
492
493 gotQs = false;
494
496 for (int fdir = d3q27_system::FSTARTDIR; fdir <= d3q27_system::FENDDIR; fdir++) {
497 real x1B = internX1 + d3q27_system::DX1[fdir] * deltaX1;
498 real x2B = internX2 + d3q27_system::DX2[fdir] * deltaX2;
499 real x3B = internX3 + d3q27_system::DX3[fdir] * deltaX3;
500
503
504 if (clippedLine) {
505 real q = c0o1;
506 if (!this->isInverseSolid()) // A is outside
507 {
508 real distanceAB = pointA.getDistance(&pointB); // pointA to B
509 real distanceAP = ub_math::min(pointA.getDistance(clippedLine->getPoint1()),
510 pointA.getDistance(clippedLine->getPoint2()));
512 } else {
513 bool pointIsOnBoundary = false;
514 if (!clippedLine->getPoint1()->equals(&pointB) &&
515 !clippedLine->getPoint2()->equals(&pointB)) {
516 // A is inside, a clipped line must not contain B
517 real distanceAB = pointA.getDistance(&pointB); // pointA to B
518 real distanceAP = clippedLine->getLength();
520 } else if (this->geoObject3D->isPointInGbObject3D(
521 pointB.getX1Coordinate(), pointB.getX2Coordinate(),
522 pointB.getX3Coordinate(), pointIsOnBoundary) &&
524 // A is definitely inside, B is exactly on ObjectBoundary => q = c1o1
525 q = c1o1;
526 } else {
527 q = c0o1;
528 }
529 }
530
531 if (ub_math::inClosedInterval(q, c1o1, c1o1))
532 q = c1o1;
533 if (ub_math::lessEqual(q, c1o1) && ub_math::greater(q, c0o1)) {
534 {
535 bc = bcArray->getBC(ix1, ix2, ix3);
536 if (!bc) {
537 bc = std::make_shared<BoundaryConditions>();
538 bcArray->setBC(ix1, ix2, ix3, bc);
539 }
540 for (int index = (int)BCs.size() - 1; index >= 0; --index)
541 BCs[index]->adaptBCForDirection(*this, bc, internX1, internX2,
542 internX3, q, fdir, timestep);
543 }
544
545 gotQs = true;
546 }
547
548 clippedLine->deletePoint1();
549 clippedLine->deletePoint2();
550 delete clippedLine;
551 }
552 }
553
554 if (gotQs) {
555 {
556 oneEntryGotBC = true;
557
558 std::vector<int> p(3);
559 p[0] = ix1;
560 p[1] = ix2;
561 p[2] = ix3;
562 transNodeIndices.insert(p);
563
564 for (int index = (int)BCs.size() - 1; index >= 0; --index)
565 BCs[index]->adaptBC(*this, bc, internX1, internX2, internX3, timestep);
566 }
567 }
568 }
569 }
570 }
571 }
572 }
573
574 return oneEntryGotBC;
575}
577void D3Q27Interactor::addQsLineSet(std::vector<UbTupleFloat3> &nodes, std::vector<UbTupleInt2> &lines)
578{
579 using namespace vf::lbm::dir;
580
581 for (SPtr<Block3D> block : bcBlocks) {
582 if (!block)
583 continue;
584
585 real dx = grid.lock()->getDeltaX(block);
586 UbTupleDouble3 orgDelta = grid.lock()->getNodeOffset(block);
587
588 SPtr<LBMKernel> kernel = block->getKernel();
589 SPtr<BCArray3D> bcArray = kernel->getBCSet()->getBCArray();
590
592 if (pos == bcNodeIndicesMap.end()) {
593 UB_THROW(UbException(UB_EXARGS, "block nicht in indizes map!!!"));
594 }
596 set<std::vector<int>>::iterator setPos;
597
598 std::size_t node1Index, node2Index;
599
600 UbTupleDouble3 blockOrg = grid.lock()->getBlockWorldCoordinates(block);
601
602 for (setPos = transNodeIndicesSet.begin(); setPos != transNodeIndicesSet.end(); ++setPos) {
603 int ix1 = (*setPos)[0];
604 int ix2 = (*setPos)[1];
605 int ix3 = (*setPos)[2];
606
607 if (bcArray->isFluid(
608 ix1, ix2,
609 ix3)) // it may be that the node is replaced by another interactor e.g. was marked as solid !!!
610 {
611 if (!bcArray->hasBC(ix1, ix2, ix3))
612 continue;
613 SPtr<BoundaryConditions> bc = bcArray->getBC(ix1, ix2, ix3);
614
615 real x1a = val<1>(blockOrg) - val<1>(orgDelta) + ix1 * dx;
616 real x2a = val<2>(blockOrg) - val<2>(orgDelta) + ix2 * dx;
617 real x3a = val<3>(blockOrg) - val<3>(orgDelta) + ix3 * dx;
618 nodes.push_back(makeUbTuple((float)x1a, (float)x2a, (float)x3a));
619 node1Index = nodes.size() - 1;
620
621 for (int dir = d3q27_system::FSTARTDIR; dir <= d3q27_system::FENDDIR; dir++) {
622 if (bc->hasBoundaryConditionFlag(d3q27_system::INVDIR[dir])) {
623 real x1b, x2b, x3b, q = bc->getQ(dir);
624 switch (dir) {
625 case dP00:
626 x1b = x1a + q * dx;
627 x2b = x2a;
628 x3b = x3a;
629 break;
630 case d0P0:
631 x1b = x1a;
632 x2b = x2a + q * dx;
633 x3b = x3a;
634 break;
635 case dM00:
636 x1b = x1a - q * dx;
637 x2b = x2a;
638 x3b = x3a;
639 break;
640 case d0M0:
641 x1b = x1a;
642 x2b = x2a - q * dx;
643 x3b = x3a;
644 break;
645 case dPP0:
646 x1b = x1a + q * dx;
647 x2b = x2a + q * dx;
648 x3b = x3a;
649 break;
650 case dMP0:
651 x1b = x1a - q * dx;
652 x2b = x2a + q * dx;
653 x3b = x3a;
654 break;
655 case dMM0:
656 x1b = x1a - q * dx;
657 x2b = x2a - q * dx;
658 x3b = x3a;
659 break;
660 case dPM0:
661 x1b = x1a + q * dx;
662 x2b = x2a - q * dx;
663 x3b = x3a;
664 break;
665 case d00P:
666 x1b = x1a;
667 x2b = x2a;
668 x3b = x3a + q * dx;
669 break;
670 case dP0P:
671 x1b = x1a + q * dx;
672 x2b = x2a;
673 x3b = x3a + q * dx;
674 break;
675 case d0PP:
676 x1b = x1a;
677 x2b = x2a + q * dx;
678 x3b = x3a + q * dx;
679 break;
680 case dM0P:
681 x1b = x1a - q * dx;
682 x2b = x2a;
683 x3b = x3a + q * dx;
684 break;
685 case d0MP:
686 x1b = x1a;
687 x2b = x2a - q * dx;
688 x3b = x3a + q * dx;
689 break;
690 case d00M:
691 x1b = x1a;
692 x2b = x2a;
693 x3b = x3a - q * dx;
694 break;
695 case dP0M:
696 x1b = x1a + q * dx;
697 x2b = x2a;
698 x3b = x3a - q * dx;
699 break;
700 case d0PM:
701 x1b = x1a;
702 x2b = x2a + q * dx;
703 x3b = x3a - q * dx;
704 break;
705 case dM0M:
706 x1b = x1a - q * dx;
707 x2b = x2a;
708 x3b = x3a - q * dx;
709 break;
710 case d0MM:
711 x1b = x1a;
712 x2b = x2a - q * dx;
713 x3b = x3a - q * dx;
714 break;
715 case dPPP:
716 x1b = x1a + q * dx;
717 x2b = x2a + q * dx;
718 x3b = x3a + q * dx;
719 break;
720 case dMMM:
721 x1b = x1a - q * dx;
722 x2b = x2a - q * dx;
723 x3b = x3a - q * dx;
724 break;
725 case dPPM:
726 x1b = x1a + q * dx;
727 x2b = x2a + q * dx;
728 x3b = x3a - q * dx;
729 break;
730 case dMMP:
731 x1b = x1a - q * dx;
732 x2b = x2a - q * dx;
733 x3b = x3a + q * dx;
734 break;
735 case dPMP:
736 x1b = x1a + q * dx;
737 x2b = x2a - q * dx;
738 x3b = x3a + q * dx;
739 break;
740 case dMPM:
741 x1b = x1a - q * dx;
742 x2b = x2a + q * dx;
743 x3b = x3a - q * dx;
744 break;
745 case dPMM:
746 x1b = x1a + q * dx;
747 x2b = x2a - q * dx;
748 x3b = x3a - q * dx;
749 break;
750 case dMPP:
751 x1b = x1a - q * dx;
752 x2b = x2a + q * dx;
753 x3b = x3a + q * dx;
754 break;
755 default:
756 throw UbException(UB_EXARGS, "unknown direction");
757 }
758
759 nodes.push_back(makeUbTuple((float)x1b, (float)x2b, (float)x3b));
760 node2Index = nodes.size() - 1;
761
762 lines.push_back(makeUbTuple((int)node1Index, (int)node2Index));
763 }
764 }
765 }
766 }
767 }
768}
771{
772 using namespace vf::lbm::dir;
773
776
777 UbTupleInt3 blocknx = grid.lock()->getBlockNX();
778
779 int blocknx1 = val<1>(blocknx);
780 int blocknx2 = val<2>(blocknx);
781 int blocknx3 = val<3>(blocknx);
782
783 for (SPtr<Block3D> block : bcBlocks) {
784 SPtr<LBMKernel> kernel = block->getKernel();
785 SPtr<BCArray3D> bcMatrix = kernel->getBCSet()->getBCArray();
786 UbTupleDouble3 nodeOffset = grid.lock()->getNodeOffset(block);
787
788 // Check whether top row is real in the system or not
789 bool include_N_Face = false; // x1=[0..blocknx1[ && x3=[0..blocknx3[
790 bool include_E_Face = false; // x2=[0..blocknx2[ && x3=[0..blocknx3[
791 bool include_T_Face = false; // x1=[0..blocknx1[ && x2=[0..blocknx2[
792 bool include_NE_Edge = false; //(x1/x2/x3)=(blocknx1/blocknx2/[0..blocknx3[)
793 bool include_TN_Edge = false; //(x1/x2/x3)=([0..blocknx1[/blocknx2/blocknx1)
794 bool include_TE_Edge = false; //(x1/x2/x3)=(blocknx1/[0..blocknx2[/blocknx2)
795 if (block) {
796 if (!block->getConnector(d0P0))
797 include_N_Face = true;
798 if (!block->getConnector(dP00))
799 include_E_Face = true;
800 if (!block->getConnector(d00P))
801 include_T_Face = true;
802 if (!block->getConnector(dPP0) && include_N_Face && include_E_Face)
803 include_NE_Edge = true;
804 if (!block->getConnector(d0PP) && include_T_Face && include_N_Face)
805 include_TN_Edge = true;
806 if (!block->getConnector(dP0P) && include_T_Face && include_E_Face)
807 include_TE_Edge = true;
808 }
809
811 if (pos == bcNodeIndicesMap.end())
812 throw UbException(UB_EXARGS, "block nicht in indizes map!!!" + block->toString());
814 set<std::vector<int>>::iterator setPos;
815
816 real x1, x2, x3, dx;
817 grid.lock()->calcStartCoordinatesAndDelta(block, x1, x2, x3, dx);
818
819 for (setPos = transNodeIndicesSet.begin(); setPos != transNodeIndicesSet.end(); ++setPos) {
820 int ix1 = (*setPos)[0];
821 int ix2 = (*setPos)[1];
822 int ix3 = (*setPos)[2];
823
824 if ((ix1 < blocknx1 && ix2 < blocknx2 && ix3 < blocknx3) ||
825 (include_E_Face && ix1 == blocknx1 && ix2 < blocknx2 && ix3 < blocknx3) ||
826 (include_N_Face && ix2 == blocknx2 && ix1 < blocknx1 && ix3 < blocknx3) ||
827 (include_T_Face && ix3 == blocknx3 && ix1 < blocknx1 && ix2 < blocknx2) ||
828 (include_NE_Edge && ix1 == blocknx1 && ix2 == blocknx2) ||
829 (include_TN_Edge && ix2 == blocknx2 && ix3 == blocknx3) ||
830 (include_TE_Edge && ix1 == blocknx1 && ix3 == blocknx3)) {
831 if (bcMatrix->isFluid(
832 ix1, ix2,
833 ix3)) // it may be that the node is replaced by another interactor e.g. was marked as solid !!!
834 {
835 if (!bcMatrix->hasBC(ix1, ix2, ix3))
836 continue;
837 SPtr<BoundaryConditions> bc = bcMatrix->getBC(ix1, ix2, ix3);
838 real x1a = x1 - val<1>(nodeOffset) + dx * ix1;
839 real x2a = x2 - val<2>(nodeOffset) + dx * ix2;
840 real x3a = x3 - val<3>(nodeOffset) + dx * ix3;
841 pointpair.first.setX1(x1a);
842 pointpair.first.setX2(x2a);
843 pointpair.first.setX3(x3a);
844 for (int dir = d3q27_system::FSTARTDIR; dir <= d3q27_system::FENDDIR; dir++) {
845 if (bc->hasBoundaryConditionFlag(d3q27_system::INVDIR[dir])) {
846 real x1b, x2b, x3b, q = bc->getQ(dir);
847 switch (dir) {
848 case dP00:
849 x1b = x1a + q * dx;
850 x2b = x2a;
851 x3b = x3a;
852 break;
853 case d0P0:
854 x1b = x1a;
855 x2b = x2a + q * dx;
856 x3b = x3a;
857 break;
858 case dM00:
859 x1b = x1a - q * dx;
860 x2b = x2a;
861 x3b = x3a;
862 break;
863 case d0M0:
864 x1b = x1a;
865 x2b = x2a - q * dx;
866 x3b = x3a;
867 break;
868 case dPP0:
869 x1b = x1a + q * dx;
870 x2b = x2a + q * dx;
871 x3b = x3a;
872 break;
873 case dMP0:
874 x1b = x1a - q * dx;
875 x2b = x2a + q * dx;
876 x3b = x3a;
877 break;
878 case dMM0:
879 x1b = x1a - q * dx;
880 x2b = x2a - q * dx;
881 x3b = x3a;
882 break;
883 case dPM0:
884 x1b = x1a + q * dx;
885 x2b = x2a - q * dx;
886 x3b = x3a;
887 break;
888 case d00P:
889 x1b = x1a;
890 x2b = x2a;
891 x3b = x3a + q * dx;
892 break;
893 case dP0P:
894 x1b = x1a + q * dx;
895 x2b = x2a;
896 x3b = x3a + q * dx;
897 break;
898 case d0PP:
899 x1b = x1a;
900 x2b = x2a + q * dx;
901 x3b = x3a + q * dx;
902 break;
903 case dM0P:
904 x1b = x1a - q * dx;
905 x2b = x2a;
906 x3b = x3a + q * dx;
907 break;
908 case d0MP:
909 x1b = x1a;
910 x2b = x2a - q * dx;
911 x3b = x3a + q * dx;
912 break;
913 case d00M:
914 x1b = x1a;
915 x2b = x2a;
916 x3b = x3a - q * dx;
917 break;
918 case dP0M:
919 x1b = x1a + q * dx;
920 x2b = x2a;
921 x3b = x3a - q * dx;
922 break;
923 case d0PM:
924 x1b = x1a;
925 x2b = x2a + q * dx;
926 x3b = x3a - q * dx;
927 break;
928 case dM0M:
929 x1b = x1a - q * dx;
930 x2b = x2a;
931 x3b = x3a - q * dx;
932 break;
933 case d0MM:
934 x1b = x1a;
935 x2b = x2a - q * dx;
936 x3b = x3a - q * dx;
937 break;
938 case dPPP:
939 x1b = x1a + q * dx;
940 x2b = x2a + q * dx;
941 x3b = x3a + q * dx;
942 break;
943 case dMMM:
944 x1b = x1a - q * dx;
945 x2b = x2a - q * dx;
946 x3b = x3a - q * dx;
947 break;
948 case dPPM:
949 x1b = x1a + q * dx;
950 x2b = x2a + q * dx;
951 x3b = x3a - q * dx;
952 break;
953 case dMMP:
954 x1b = x1a - q * dx;
955 x2b = x2a - q * dx;
956 x3b = x3a + q * dx;
957 break;
958 case dPMP:
959 x1b = x1a + q * dx;
960 x2b = x2a - q * dx;
961 x3b = x3a + q * dx;
962 break;
963 case dMPM:
964 x1b = x1a - q * dx;
965 x2b = x2a + q * dx;
966 x3b = x3a - q * dx;
967 break;
968 case dPMM:
969 x1b = x1a + q * dx;
970 x2b = x2a - q * dx;
971 x3b = x3a - q * dx;
972 break;
973 case dMPP:
974 x1b = x1a - q * dx;
975 x2b = x2a + q * dx;
976 x3b = x3a + q * dx;
977 break;
978 default:
979 throw UbException(UB_EXARGS, "unknown direction");
980 }
981 pointpair.second.setX1(x1b);
982 pointpair.second.setX2(x2b);
983 pointpair.second.setX3(x3b);
984 QsLineSet.push_back(pointpair);
985 }
986 }
987 }
988 }
989 }
990 }
991 return QsLineSet;
992}
993
995{
996 UBLOG(logINFO, "D3Q27Interactor::writeValidationAVSFile(" << filename << ") - start ");
997 ofstream out(filename.c_str(), ios::out);
998 if (!out)
999 throw UbException(UB_EXARGS, "couldn't open file " + filename);
1000
1001 int numpoints, numlines;
1003 numlines = (unsigned)qsLineSet.size();
1004 numpoints = numlines * 2;
1005
1006 out << "# UCD-File created by D3Q27Interactor\n";
1007 out << numpoints << " " << numlines << " 0 0 0 " << endl;
1008 int nr = 1;
1009 for (int i = 0; i < numlines; i++) {
1010 out << nr++ << " " << qsLineSet[i].first.getX1Coordinate() << " " << qsLineSet[i].first.getX2Coordinate() << " "
1011 << qsLineSet[i].first.getX3Coordinate() << " \n";
1012 out << nr++ << " " << qsLineSet[i].second.getX1Coordinate() << " " << qsLineSet[i].second.getX2Coordinate()
1013 << " " << qsLineSet[i].second.getX3Coordinate() << " \n";
1014 }
1015 nr = 1;
1016 for (int i = 0; i < numlines; i++) {
1017 int el = nr + 1;
1018 out << i + 1 << " " << 2 << " line " << nr << " " << el << " " << endl;
1019 nr = el + 1;
1020 }
1021 UBLOG(logINFO, "D3Q27Interactor::writeValidationAVSFile(" << filename << ") - end");
1022}
1023
Abstract class of baundary conditions adapter.
Definition BC.h:48
virtual void addBC(const SPtr< BC > BC)
real rayX3[d3q27_system::FENDDIR+1]
std::vector< SPtr< BC > > BCs
SolidNodeIndicesMap solidNodeIndicesMap
BcNodeIndicesMap bcNodeIndicesMap
real rayX2[d3q27_system::FENDDIR+1]
real rayX1[d3q27_system::FENDDIR+1]
This Class provides basic 3D box objects.
Definition GbCuboid3D.h:53
This Class provides basic 3D line objects.
Definition GbLine3D.h:59
This Class provides basic 3D point objects.
Definition GbPoint3D.h:49
double getX1Coordinate() const
Definition GbPoint3D.h:82
This Class provides basic 3D vector objects.
Definition GbVector3D.h:47
A base class for grid generation.
WPtr< Grid3D > grid
SPtr< GbObject3D > geoObject3D
bool isTimeDependent()
void setTimeDependent()
bool isInverseSolid()
void unsetTimeDependent()
std::vector< SPtr< Block3D > > bcBlocks
A class implements a tuple.
Definition UbTuple.h:477
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
void writeValidationAVSFile(std::string filename)
bool setDifferencesToGbObject3D(const SPtr< Block3D > block) override
virtual std::vector< std::pair< GbPoint3D, GbPoint3D > > getQsLineSet()
void initInteractor(const real &timeStep=0) override
void addQsLineSet(std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleInt2 > &lines)
~D3Q27Interactor() override
void updateInteractor(const real &timestep=0) override
double getDistance(const GbPoint3D &point)
Definition GbLine3D.cpp:167
GbLine3D * createClippedLine3D(GbCuboid3D *cuboid)
Definition GbLine3D.cpp:155
const real dx
#define UB_THROW(e)
Definition UbException.h:78
#define UBLOG(level, logtext)
Definition UbLogger.h:327
#define UB_EXARGS
Definition UbException.h:73
UbTuple< int, int, int > UbTupleInt3
Definition UbTuple.h:626
UbTuple< T1 > makeUbTuple(T1 const &a1)
Definition UbTuple.h:554
@ logDEBUG5
Definition UbLogger.h:54
@ logWARNING
Definition UbLogger.h:54
@ logINFO
Definition UbLogger.h:54
@ logERROR
Definition UbLogger.h:54
const int INVDIR[]
const int DX1[]
const int DX3[]
const int DX2[]
const T & min(const T &a1, const T &a2)
Definition UbMath.h:389
bool lessEqual(const T1 &value, const T2 &reference)
Definition UbMath.h:209
bool greater(const T1 &value, const T2 &reference)
Definition UbMath.h:216
bool inClosedInterval(const T1 &value, const T2 &threshold1, const T3 &threshold2)
Definition UbMath.h:309
bool zero(const T &value)
Definition UbMath.h:139