VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
LevelGridBuilder.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#include "LevelGridBuilder.h"
35
36#include <functional>
37#include <numeric>
38#include <optional>
39#include <stdio.h>
40#include <iostream>
41#include <algorithm>
42
43#include "GbSpatialData3D.h"
48
51#include "grid/Grid.h"
52#include "grid/GridFactory.h"
53#include "grid/GridInterface.h"
54#include "grid/NodeValues.h"
55
57#include "io/QLineWriter.h"
59
61
64
65#define GEOFLUID 19
66#define GEOSOLID 16
67
68namespace vf::gpu {
69
79
80std::shared_ptr<LevelGridBuilder> LevelGridBuilder::makeShared()
81{
83}
84
86{
87 for (uint level = 0; level < getNumberOfGridLevels(); level++)
88 {
90 setSlipGeometryBoundaryCondition(normalX, normalY, normalZ);
91 }else{
92 SPtr<SlipBoundaryCondition> slipBoundaryCondition = SlipBoundaryCondition::make(normalX, normalY, normalZ);
93
94 auto side = SideFactory::make(sideType);
95
96 slipBoundaryCondition->side = side;
97 slipBoundaryCondition->side->addIndices(grids, level, slipBoundaryCondition);
98
99 slipBoundaryCondition->fillSlipNormalLists();
100 boundaryConditions[level]->slipBoundaryConditions.push_back(slipBoundaryCondition);
101
102 VF_LOG_INFO("Set Slip BC on level {} with {}", level, slipBoundaryCondition->indices.size());
103 }
104 }
105}
106
108{
109 geometryHasValues = true;
110
111 for (uint level = 0; level < getNumberOfGridLevels(); level++)
112 {
113 if (boundaryConditions[level]->geometryBoundaryCondition != nullptr)
114 {
115 boundaryConditions[level]->geometryBoundaryCondition->normalX = normalX;
116 boundaryConditions[level]->geometryBoundaryCondition->normalY = normalY;
117 boundaryConditions[level]->geometryBoundaryCondition->normalZ = normalZ;
118 boundaryConditions[level]->geometryBoundaryCondition->side->addIndices(grids, level, boundaryConditions[level]->geometryBoundaryCondition);
119
120 boundaryConditions[level]->geometryBoundaryCondition->fillSlipNormalLists();
121
122 VF_LOG_INFO("Set Geometry Slip BC on level {} with {}", level, boundaryConditions[level]->geometryBoundaryCondition->indices.size());
123 }
124 }
125}
126
127//=======================================================================================
134 real normalX, real normalY, real normalZ,
135 uint samplingOffset, real vonKarmanConstant, real roughnessLength, real deltaX, std::shared_ptr<GbSpatialData3D<real>> roughnessMap)
136{
137 for (uint level = 0; level < getNumberOfGridLevels(); level++)
138 {
139 SPtr<StressBoundaryCondition> stressBoundaryCondition = StressBoundaryCondition::make(normalX, normalY, normalZ, samplingOffset, vonKarmanConstant, roughnessLength*std::exp2(level)/deltaX, std::move(roughnessMap));
140
141 stressBoundaryCondition->side = SideFactory::make(sideType);
142 stressBoundaryCondition->side->addIndices(grids, level, stressBoundaryCondition);
143
144 stressBoundaryCondition->fillLists();
145
146 boundaryConditions[level]->stressBoundaryConditions.push_back(stressBoundaryCondition);
147
148 VF_LOG_INFO("Set Stress BC on level {} with {}", level, stressBoundaryCondition->indices.size());
149 }
150}
151//=======================================================================================
165 real normalY, real normalZ, uint samplingOffset, real vonKarmanConstant,
166 real roughnessLength, real roughnessLengthTemperature, real surfaceHeatFlux, real surfaceTemperature, real heatingRate,
167 real deltaX, real deltaT, std::shared_ptr<GbSpatialData3D<real>> roughnessMap)
168{
169 for (uint level = 0; level < getNumberOfGridLevels(); level++) {
170 const real deltaXLevel = deltaX * std::exp2(-static_cast<int>(level));
171 const real deltaTLevel = deltaT * std::exp2(-static_cast<int>(level));
172 const real normalizedRoughnessLength = roughnessLength / deltaXLevel;
173 const real normalizedRoughnessLengthTemperature = roughnessLengthTemperature / deltaXLevel;
174 const real normalizedSurfaceHeatFlux = surfaceHeatFlux * deltaT / deltaX;
175 const real normalizedHeatingRate = heatingRate * deltaTLevel;
176
178 normalX, normalY, normalZ, samplingOffset, vonKarmanConstant, normalizedRoughnessLength, normalizedRoughnessLengthTemperature,
179 normalizedSurfaceHeatFlux, surfaceTemperature, normalizedHeatingRate, std::move(roughnessMap));
180 auto side = SideFactory::make(sideType);
181
182 surfaceLayerBoundaryCondition->side = side;
183 surfaceLayerBoundaryCondition->side->addIndices(grids, level, surfaceLayerBoundaryCondition);
184
185 surfaceLayerBoundaryCondition->fillLists();
186
187 boundaryConditions[level]->surfaceLayerBoundaryConditions.push_back(surfaceLayerBoundaryCondition);
188
189 VF_LOG_INFO("Set SurfaceLayer BC on level {} with {}", level, surfaceLayerBoundaryCondition->indices.size());
190 }
191}
192
193void LevelGridBuilder::setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz, std::optional<std::function<void(real x,real y,real z, real& vx, real& vy, real& vz)>> velocityProfile)
194{
197 else
198 {
199 for (uint level = 0; level < getNumberOfGridLevels(); level++)
200 {
201 SPtr<VelocityBoundaryCondition> velocityBoundaryCondition = VelocityBoundaryCondition::make(vx, vy, vz);
202
203 auto side = SideFactory::make(sideType);
204
205 velocityBoundaryCondition->side = side;
206 velocityBoundaryCondition->side->addIndices(grids, level, velocityBoundaryCondition);
207
208 velocityBoundaryCondition->fillVelocityLists();
210 velocityBoundaryCondition->setVelocityProfile(grids[level], velocityProfile.value());
211
212 boundaryConditions[level]->velocityBoundaryConditions.push_back(velocityBoundaryCondition);
213
214 VF_LOG_INFO("Set Velocity BC on level {} with {}", level, velocityBoundaryCondition->indices.size());
215 }
216 }
217}
218
220{
221 geometryHasValues = true;
222
223 for (uint level = 0; level < getNumberOfGridLevels(); level++)
224 {
225 if (boundaryConditions[level]->geometryBoundaryCondition != nullptr)
226 {
227 boundaryConditions[level]->geometryBoundaryCondition->vx = vx;
228 boundaryConditions[level]->geometryBoundaryCondition->vy = vy;
229 boundaryConditions[level]->geometryBoundaryCondition->vz = vz;
230 boundaryConditions[level]->geometryBoundaryCondition->side->addIndices(grids, level, boundaryConditions[level]->geometryBoundaryCondition);
231
232 boundaryConditions[level]->geometryBoundaryCondition->fillVelocityLists();
233
234 VF_LOG_INFO("Set Geometry BC on level {} with {}", level, boundaryConditions[level]->geometryBoundaryCondition->indices.size());
235 }
236 }
237}
238
240{
241 for (uint level = 0; level < getNumberOfGridLevels(); level++)
242 {
244
245 auto side = SideFactory::make(sideType);
246 pressureBoundaryCondition->side = side;
247 pressureBoundaryCondition->side->addIndices(grids, level, pressureBoundaryCondition);
248
249 boundaryConditions[level]->pressureBoundaryConditions.push_back(pressureBoundaryCondition);
250
251 VF_LOG_INFO("Set Pressure BC on level {} with {}", level, pressureBoundaryCondition->indices.size());
252 }
253}
254
256{
257 for (uint level = 0; level < getNumberOfGridLevels(); level++)
258 {
260
261 auto side = SideFactory::make(sideType);
262 boundaryCondition->side = side;
263 boundaryCondition->side->addIndices(grids, level, boundaryCondition);
264
265 boundaryConditions[level]->adNoFluxBoundaryConditions.push_back(boundaryCondition);
266
267 VF_LOG_INFO("Set NoFlux Advection-Diffusion BC on level {} with {}", level, boundaryCondition->indices.size());
268 }
269}
270
271void LevelGridBuilder::setADFluxBoundaryCondition(SideType sideType, real normalX, real normalY, real normalZ, real gradient, real deltaX)
272{
273 for (uint level = 0; level < getNumberOfGridLevels(); level++)
274 {
275 const real normalizedGradient = gradient * deltaX * std::exp2(-static_cast<real>(level));
276 SPtr<ADFluxBoundaryCondition> boundaryCondition = ADFluxBoundaryCondition::make(normalX, normalY, normalZ, normalizedGradient);
277
278 auto side = SideFactory::make(sideType);
279 boundaryCondition->side = side;
280 boundaryCondition->side->addIndices(grids, level, boundaryCondition);
281 boundaryCondition->fillBoundaryValueLists();
282
283 boundaryConditions[level]->adFluxBoundaryConditions.push_back(boundaryCondition);
284
285 VF_LOG_INFO("Set Flux Advection-Diffusion BC on level {} with {}", level, boundaryCondition->indices.size());
286 }
287}
288
290{
291 for (uint level = 0; level < getNumberOfGridLevels(); level++)
292 {
293 SPtr<ADDirichletBoundaryCondition> boundaryCondition = ADDirichletBoundaryCondition::make(value, vx, vy, vz);
294
295 auto side = SideFactory::make(sideType);
296 boundaryCondition->side = side;
297 boundaryCondition->side->addIndices(grids, level, boundaryCondition);
298 boundaryCondition->fillBoundaryValueLists();
299
300 boundaryConditions[level]->adDirichletBoundaryConditions.push_back(boundaryCondition);
301
302 VF_LOG_INFO("Set Dirichlet Advection-Diffusion BC on level {} with {}", level, boundaryCondition->indices.size());
303 }
304}
305
307{
308 for (uint level = 0; level < getNumberOfGridLevels(); level++)
309 {
310 SPtr<ADNeumannBoundaryCondition> boundaryCondition = ADNeumannBoundaryCondition::make(gradient * (exp2(-(real)level)*dx), vx, vy, vz);
311
312 auto side = SideFactory::make(sideType);
313 boundaryCondition->side = side;
314 boundaryCondition->side->addIndices(grids, level, boundaryCondition);
315 boundaryCondition->fillBoundaryValueLists();
316
317 boundaryConditions[level]->adNeumannBoundaryConditions.push_back(boundaryCondition);
318
319 VF_LOG_INFO("Set Neumann Advection-Diffusion BC on level {} with {}", level, boundaryCondition->indices.size());
320 }
321}
322
324{
325 for( uint level = 0; level < this->grids.size(); level++ )
326 grids[level]->setPeriodicity(periodic_X, periodic_Y, periodic_Z);
327}
328
330{
331 shift = std::fmod(shift, length);
332 shift = shift < 0 ? shift + length : shift;
333 return std::rint(shift/delta) * delta;
334}
335
337{
338 shift = adjustShift(shift, grids[0]->getDelta(), grids[0]->getEndY() - grids[0]->getStartY());
339 for( uint level = 0; level < this->grids.size(); level++ )
340 grids[level]->setPeriodicBoundaryShiftsOnXinY(shift);
341}
342
344{
345 shift = adjustShift(shift, grids[0]->getDelta(), grids[0]->getEndZ() - grids[0]->getStartZ());
346 for( uint level = 0; level < this->grids.size(); level++ )
347 grids[level]->setPeriodicBoundaryShiftsOnXinZ(shift);
348}
349
351{
352 shift = adjustShift(shift, grids[0]->getDelta(), grids[0]->getEndX() - grids[0]->getStartX());
353 for( uint level = 0; level < this->grids.size(); level++ )
354 grids[level]->setPeriodicBoundaryShiftsOnYinX(shift);
355}
356
358{
359 shift = adjustShift(shift, grids[0]->getDelta(), grids[0]->getEndZ() - grids[0]->getStartZ());
360 for( uint level = 0; level < this->grids.size(); level++ )
361 grids[level]->setPeriodicBoundaryShiftsOnYinZ(shift);
362}
363
365{
366 shift = adjustShift(shift, grids[0]->getDelta(), grids[0]->getEndX() - grids[0]->getStartX());
367 for( uint level = 0; level < this->grids.size(); level++ )
368 grids[level]->setPeriodicBoundaryShiftsOnZinX(shift);
369}
370
372{
373 shift = adjustShift(shift, grids[0]->getDelta(), grids[0]->getEndY() - grids[0]->getStartY());
374 for( uint level = 0; level < this->grids.size(); level++ )
375 grids[level]->setPeriodicBoundaryShiftsOnZinY(shift);
376}
377
379{
382 else {
383 for (uint level = 0; level < getNumberOfGridLevels(); level++) {
384 SPtr<VelocityBoundaryCondition> noSlipBoundaryCondition = VelocityBoundaryCondition::make(0.0, 0.0, 0.0);
385
386 auto side = SideFactory::make(sideType);
387
388 noSlipBoundaryCondition->side = side;
389 noSlipBoundaryCondition->side->addIndices(grids, level, noSlipBoundaryCondition);
390
391 noSlipBoundaryCondition->fillVelocityLists();
392
393 // now effectively just a wrapper for velocityBC with zero velocity. No distinction in Gridgenerator.
394 boundaryConditions[level]->velocityBoundaryConditions.push_back(noSlipBoundaryCondition);
395 }
396 }
397}
398
400{
401 geometryHasValues = true;
402
403 for (uint level = 0; level < getNumberOfGridLevels(); level++)
404 {
405 if (boundaryConditions[level]->geometryBoundaryCondition != nullptr)
406 {
407 boundaryConditions[level]->geometryBoundaryCondition->side->addIndices(grids, level, boundaryConditions[level]->geometryBoundaryCondition);
408
409 VF_LOG_INFO("Set Geometry No-Slip BC on level {} with {}", level, boundaryConditions[level]->geometryBoundaryCondition->indices.size());
410 }
411 }
412}
413
414void LevelGridBuilder::setPrecursorBoundaryCondition(SideType sideType, SPtr<FileCollection> fileCollection, int timeStepsBetweenReads, bool cycleFiles,
415 real velocityX, real velocityY, real velocityZ, std::vector<uint> fileLevelToGridLevelMap)
416{
417 if(fileLevelToGridLevelMap.empty())
418 {
419 VF_LOG_INFO("Mapping precursor file levels to the corresponding grid levels");
420
421 for (uint level = 0; level < getNumberOfGridLevels(); level++)
422 fileLevelToGridLevelMap.push_back(level);
423 }
424 else
425 {
427 throw std::runtime_error("In setPrecursorBoundaryCondition: fileLevelToGridLevelMap does not match with the number of levels");
428 VF_LOG_INFO("Using user defined file to grid level mapping");
429 }
430
431 for (uint level = 0; level < getNumberOfGridLevels(); level++)
432 {
433 auto reader = createReaderForCollection(fileCollection, fileLevelToGridLevelMap[level], cycleFiles);
434 SPtr<PrecursorBoundaryCondition> precursorBoundaryCondition = PrecursorBoundaryCondition::make( reader, timeStepsBetweenReads, velocityX, velocityY, velocityZ);
435
436 auto side = SideFactory::make(sideType);
437
438 precursorBoundaryCondition->side = side;
439 precursorBoundaryCondition->side->addIndices(grids, level, precursorBoundaryCondition);
440
441 boundaryConditions[level]->precursorBoundaryConditions.push_back(precursorBoundaryCondition);
442
443 VF_LOG_INFO("Set Precursor BC on level {} with {}", level, precursorBoundaryCondition->indices.size());
444 }
445}
446
447void LevelGridBuilder::setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall)
448{
449 for (uint level = 0; level < this->grids.size(); level++)
450 grids[level]->setEnableFixRefinementIntoTheWall(enableFixRefinementIntoTheWall);
451}
452
454{
455 this->communicationProcesses[direction] = process;
456}
457
459{
460 return this->communicationProcesses[direction];
461}
462
464{
465 for (const auto& grid : grids)
466 grid->freeMemory();
467}
468
470{
471 return grids[level];
472}
473
474
475void LevelGridBuilder::getGridInformations(std::vector<int>& gridX, std::vector<int>& gridY,
476 std::vector<int>& gridZ, std::vector<int>& distX, std::vector<int>& distY,
477 std::vector<int>& distZ)
478{
479 for (const auto &grid : grids)
480 {
481 gridX.push_back(int(grid->getNumberOfNodesX()));
482 gridY.push_back(int(grid->getNumberOfNodesY()));
483 gridZ.push_back(int(grid->getNumberOfNodesZ()));
484
485 distX.push_back(int(grid->getStartX()));
486 distY.push_back(int(grid->getStartY()));
487 distZ.push_back(int(grid->getStartZ()));
488 }
489}
490
491
493{
494 return uint(grids.size());
495}
496
498{
499 return this->grids[level]->getNumberOfNodesCF();
500}
501
503{
504 return this->grids[level]->getNumberOfNodesFC();
505}
506
508{
509 this->grids[level]->getGridInterfaceIndices(iCellCfc, iCellCff, iCellFcc, iCellFcf);
510}
511
513{
514 for (uint i = 0; i < getNumberOfNodesFC(level); i++)
515 {
516 uint offset = this->grids[level]->getFC_offset()[i];
517
518 xOffFC[i] = - this->grids[level]->getDirection()[ 3*offset + 0 ];
519 yOffFC[i] = - this->grids[level]->getDirection()[ 3*offset + 1 ];
520 zOffFC[i] = - this->grids[level]->getDirection()[ 3*offset + 2 ];
521 }
522}
523
525{
526 for (uint i = 0; i < getNumberOfNodesCF(level); i++)
527 {
528 uint offset = this->grids[level]->getCF_offset()[i];
529
530 xOffCF[i] = - this->grids[level]->getDirection()[ 3*offset + 0 ];
531 yOffCF[i] = - this->grids[level]->getDirection()[ 3*offset + 1 ];
532 zOffCF[i] = - this->grids[level]->getDirection()[ 3*offset + 2 ];
533 }
534}
535
537{
538 return this->grids[level]->getNumberOfSendNodes(direction);
539}
540
542{
543 return this->grids[level]->getNumberOfReceiveNodes(direction);
544}
545
546void LevelGridBuilder::getSendIndices(uint* sendIndices, int direction, int level)
547{
548 SPtr<Grid> grid = this->grids[level];
549 for( uint i = 0; i < getNumberOfSendIndices(direction, level); i++ )
550 {
551 sendIndices[i] = grid->getSparseIndex( grid->getSendIndex(direction, i) ) + 1;
552 }
553}
554
555void LevelGridBuilder::getReceiveIndices(uint* receiveIndices, int direction, int level)
556{
557 SPtr<Grid> grid = this->grids[level];
558 for( uint i = 0; i < getNumberOfReceiveIndices(direction, level); i++ )
559 {
560 receiveIndices[i] = grid->getSparseIndex( grid->getReceiveIndex(direction, i) ) + 1;
561 }
562}
563
565{
566 return grids[level]->getSparseSize();
567}
568
569std::shared_ptr<Grid> LevelGridBuilder::getGrid(int level, int box)
570{
571 return this->grids[level];
572}
573
575{
576 if (level >= (int)grids.size())
577 {
578 std::cout << "wrong level input... return to caller\n";
579 return;
580 }
581}
582
583void LevelGridBuilder::getDimensions(int &nx, int &ny, int &nz, const int level) const
584{
585 nx = grids[level]->getNumberOfNodesX();
586 ny = grids[level]->getNumberOfNodesY();
587 nz = grids[level]->getNumberOfNodesZ();
588}
589
591 uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative,
592 uint *geo, const int level) const
593{
594 grids[level]->getNodeValues(xCoords, yCoords, zCoords, neighborX, neighborY, neighborZ, neighborNegative, geo);
595}
596
597
598void LevelGridBuilder::getFluidNodeIndices(uint *fluidNodeIndices, const int level) const
599{
600 grids[level]->getFluidNodeIndices(fluidNodeIndices);
601}
602
603void LevelGridBuilder::getFluidNodeIndicesBorder(uint *fluidNodeIndices, const int level) const
604{
605 grids[level]->getFluidNodeIndicesBorder(fluidNodeIndices);
606}
607
609{
610 return grids[level]->getNumberOfFluidNodes();
611}
612
614{
615 return grids[level]->getNumberOfFluidNodesBorder();
616}
617
619{
620 uint size = 0;
621 for (const auto& boundaryCondition : boundaryConditions[level]->slipBoundaryConditions)
622 size += uint(boundaryCondition->indices.size());
623 return size;
624}
625
626void LevelGridBuilder::getSlipValues(real* normalX, real* normalY, real* normalZ, int* indices, int level) const
627{
628 int allIndicesCounter = 0;
629 for (const auto& boundaryCondition : boundaryConditions[level]->slipBoundaryConditions)
630 {
631 for (uint index = 0; index < boundaryCondition->indices.size(); index++)
632 {
633 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1;
634
635 normalX[allIndicesCounter] = boundaryCondition->getNormalx(index);
636 normalY[allIndicesCounter] = boundaryCondition->getNormaly(index);
637 normalZ[allIndicesCounter] = boundaryCondition->getNormalz(index);
639 }
640 }
641}
642
643void LevelGridBuilder::getSlipQs(real* qs[27], int level) const
644{
646 for (const auto& boundaryCondition : boundaryConditions[level]->slipBoundaryConditions)
647 {
648 for (uint index = 0; index < boundaryCondition->indices.size(); index++)
649 {
650 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
651 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
653 }
654 }
655}
656
658{
659 uint size = 0;
660 for (const auto& boundaryCondition : boundaryConditions[level]->stressBoundaryConditions)
661 size += uint(boundaryCondition->indices.size());
662 return size;
663}
664
665void LevelGridBuilder::getStressValues( real* normalX, real* normalY, real* normalZ,
666 int* indices, uint* samplingIndices, real* samplingDistances, real* vonKarmanConstants, real* roughnessLengths, int level) const
667{
668
670 for (const auto& boundaryCondition : boundaryConditions[level]->stressBoundaryConditions)
671 {
672 for (uint index = 0; index < boundaryCondition->indices.size(); index++)
673 {
674 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1;
675 samplingIndices[allIndicesCounter] = static_cast<uint>(grids[level]->getSparseIndex(boundaryCondition->getSamplingIndex(index)) + 1);
676
677 normalX[allIndicesCounter] = boundaryCondition->getNormalx(index);
678 normalY[allIndicesCounter] = boundaryCondition->getNormaly(index);
679 normalZ[allIndicesCounter] = boundaryCondition->getNormalz(index);
680
681 samplingDistances[allIndicesCounter] = boundaryCondition->getSamplingDistance(index);
682 roughnessLengths[allIndicesCounter] = boundaryCondition->getRoughnessLength(index);
683 vonKarmanConstants[allIndicesCounter] = boundaryCondition->getVonKarmanConstant();
685 }
686 }
687}
688
689void LevelGridBuilder::getStressQs(real* qs[27], int level) const
690{
692 for (const auto& boundaryCondition : boundaryConditions[level]->stressBoundaryConditions)
693 {
694 for (uint index = 0; index < boundaryCondition->indices.size(); index++)
695 {
696 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
697 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
699 }
700 }
701}
703{
704 uint size = 0;
705 for (auto& boundaryCondition : boundaryConditions[level]->surfaceLayerBoundaryConditions)
706 size += uint(boundaryCondition->indices.size());
707 return size;
708}
709
710void LevelGridBuilder::getSurfaceLayerValues(real* normalX, real* normalY, real* normalZ, int* indices,
714 int level) const
715{
717 for (const auto& boundaryCondition : boundaryConditions[level]->surfaceLayerBoundaryConditions)
718 {
719 for (uint index = 0; index < boundaryCondition->indices.size(); index++)
720 {
721 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1;
722
723 normalX[allIndicesCounter] = boundaryCondition->getNormalx(index);
724 normalY[allIndicesCounter] = boundaryCondition->getNormaly(index);
725 normalZ[allIndicesCounter] = boundaryCondition->getNormalz(index);
726
727 samplingDistances[allIndicesCounter] = boundaryCondition->getSamplingDistance(index);
728 samplingIndices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->getSamplingIndex(index)) + 1;
729 vonKarmanConstants[allIndicesCounter] = boundaryCondition->getVonKarmanConstant();
730 roughnessLengths[allIndicesCounter] = boundaryCondition->getRoughnessLength(index);
731 roughnessLengthsTemperature[allIndicesCounter] = boundaryCondition->getRoughnessLengthTemperature(index);
732 surfaceHeatFluxes[allIndicesCounter] = boundaryCondition->getSurfaceHeatFlux(index);
733 surfaceTemperatures[allIndicesCounter] = boundaryCondition->getSurfaceTemperature(index);
734 heatingRates[allIndicesCounter] = boundaryCondition->getHeatingRate(index);
735
737 }
738 }
739}
740
741void LevelGridBuilder::getSurfaceLayerQs(real* qs[27], int level) const
742{
744 for (const auto& boundaryCondition : boundaryConditions[level]->surfaceLayerBoundaryConditions)
745 {
746 for (uint index = 0; index < boundaryCondition->indices.size(); index++)
747 {
748 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
749 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
751 }
752 }
753}
754
755
756
758{
759 uint size = 0;
760 for (const auto& boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions)
761 size += uint(boundaryCondition->indices.size());
762 return size;
763}
764
765void LevelGridBuilder::getVelocityValues(real* vx, real* vy, real* vz, int* indices, int level) const
766{
767 int allIndicesCounter = 0;
768 for (const auto& boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions)
769 {
770 for (uint i = 0; i < (uint)boundaryCondition->indices.size(); i++)
771 {
772 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) +1;
773
774 vx[allIndicesCounter] = boundaryCondition->getVx(i);
775 vy[allIndicesCounter] = boundaryCondition->getVy(i);
776 vz[allIndicesCounter] = boundaryCondition->getVz(i);
778 }
779 }
780}
781
782void LevelGridBuilder::getVelocityQs(real* qs[27], int level) const
783{
784 int allIndicesCounter = 0;
785 for (const auto& boundaryCondition : boundaryConditions[level]->velocityBoundaryConditions)
786 {
787 for ( uint index = 0; index < boundaryCondition->indices.size(); index++ )
788 {
789 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
790 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
792 }
793 }
794}
795
797{
798 uint size = 0;
799 for (const auto& boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions)
800 size += uint(boundaryCondition->indices.size());
801 return size;
802}
803
804void LevelGridBuilder::getPressureValues(real* rho, int* indices, int* neighborIndices, int level) const
805{
807 for (const auto& boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions)
808 {
809 for (std::size_t i = 0; i < boundaryCondition->indices.size(); i++)
810 {
811 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1;
812
813 neighborIndices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->neighborIndices[i]) + 1;
814
815 rho[allIndicesCounter] = boundaryCondition->rho;
817 }
818 }
819}
820
821void LevelGridBuilder::getPressureQs(real* qs[27], int level) const
822{
824 for (const auto& boundaryCondition : boundaryConditions[level]->pressureBoundaryConditions)
825 {
826 for ( uint index = 0; index < boundaryCondition->indices.size(); index++ )
827 {
828 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
829 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
831 }
832 }
833}
834
836{
837 return boundaryConditions[level]->pressureBoundaryConditions.size();
838}
839
841{
842 return boundaryConditions[level]->pressureBoundaryConditions[indexInBoundaryConditionVector]->indices.size();
843}
844
845void LevelGridBuilder::getPressureValues(real* density, int* indices, int* neighborIndices, uint level,
847{
848 const auto& boundaryCondition = boundaryConditions[level]->pressureBoundaryConditions[indexInBoundaryConditionVector];
849
850 for (std::size_t index = 0; index < boundaryCondition->indices.size(); index++) {
851 indices[index] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1;
852
853 neighborIndices[index] = grids[level]->getSparseIndex(boundaryCondition->neighborIndices[index]) + 1;
854
855 density[index] = boundaryCondition->rho;
856 }
857}
858
860{
861 const auto& boundaryCondition = boundaryConditions[level]->pressureBoundaryConditions[indexInBoundaryConditionVector];
862
863 for (uint index = 0; index < boundaryCondition->indices.size(); index++) {
864 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++) {
865 qs[dir][index] = boundaryCondition->qs[index][dir];
866 }
867 }
868}
869
871{
872 return boundaryConditions[level]->pressureBoundaryConditions[indexInBoundaryConditionVector]->side->getD3Q27Direction();
873};
874
876{
877 uint size = 0;
878 for (auto& boundaryCondition : boundaryConditions[level]->precursorBoundaryConditions)
879 size += uint(boundaryCondition->indices.size());
880 return size;
881}
882
884 real* weights0PP, real* weights0PM, real* weights0MP, real* weights0MM,
885 int* indices, std::vector<SPtr<TransientBCInputFileReader>>& reader,
886 int& numberOfPrecursorNodes, size_t& numberOfQuantities, uint& timeStepsBetweenReads,
887 real& velocityX, real& velocityY, real& velocityZ, int level) const
888{
892 size_t tmpNumberOfQuantities = 0;
893
894 for (auto& boundaryCondition : boundaryConditions[level]->precursorBoundaryConditions)
895 {
896 if( tmpTimeStepsBetweenReads == 0 )
897 tmpTimeStepsBetweenReads = boundaryCondition->timeStepsBetweenReads;
898 if( tmpTimeStepsBetweenReads != boundaryCondition->timeStepsBetweenReads )
899 throw std::runtime_error("All precursor boundary conditions must have the same timeStepsBetweenReads value");
900 auto BCreader = boundaryCondition->getReader();
901 BCreader->setWritingOffset(allIndicesCounter);
902 reader.push_back(BCreader);
903
904 std::vector<real> y, z;
905 real xTmp, yTmp, zTmp;
906 for(uint i = 0; i<boundaryCondition->indices.size(); i++)
907 {
908 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1;
909 grids[level]->transIndexToCoords(boundaryCondition->indices[i], xTmp, yTmp, zTmp);
910 y.push_back(yTmp);
911 z.push_back(zTmp);
913 }
914 BCreader->fillArrays(y, z);
916 BCreader->getWeights(weights0PP, weights0PM, weights0MP, weights0MM);
917 if(tmpNumberOfQuantities == 0)
918 tmpNumberOfQuantities = BCreader->getNumberOfQuantities();
919 if(tmpNumberOfQuantities != BCreader->getNumberOfQuantities())
920 throw std::runtime_error("All precursor files must have the same quantities.");
921 allNodesCounter += BCreader->getNPointsRead();
922 velocityX = boundaryCondition->getVelocityX();
923 velocityY = boundaryCondition->getVelocityY();
924 velocityZ = boundaryCondition->getVelocityZ();
925 }
926 numberOfPrecursorNodes = allNodesCounter;
927
929 throw std::runtime_error("timeStepsBetweenReads of precursor needs to be larger than 0.");
930 timeStepsBetweenReads = tmpTimeStepsBetweenReads;
931
932 if (tmpNumberOfQuantities == 0)
933 throw std::runtime_error("Number of quantities in precursor needs to be larger than 0.");
934 numberOfQuantities = tmpNumberOfQuantities;
935}
936
937void LevelGridBuilder::getPrecursorQs(real* qs[27], int level) const
938{
940 for (auto& boundaryCondition : boundaryConditions[level]->precursorBoundaryConditions)
941 {
942 for ( uint index = 0; index < boundaryCondition->indices.size(); index++ )
943 {
944 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
945 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
947 }
948 }
949}
950
952{
953 uint size = 0;
954 for (auto& boundaryCondition : boundaryConditions[level]->adNoFluxBoundaryConditions)
955 size += uint(boundaryCondition->indices.size());
956 return size;
957}
958
959void LevelGridBuilder::getADNoFluxValues(int* indices, int level) const
960{
962 for (auto& boundaryCondition : boundaryConditions[level]->adNoFluxBoundaryConditions) {
963 for (uint i = 0; i < boundaryCondition->indices.size(); i++) {
964 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1;
966 }
967 }
968}
969
970void LevelGridBuilder::getADNoFluxQs(real* qs[27], int level) const
971{
973 for (auto& boundaryCondition : boundaryConditions[level]->adNoFluxBoundaryConditions) {
974 for (uint index = 0; index < boundaryCondition->indices.size(); index++) {
975 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
976 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
978 }
979 }
980}
981
983{
984 uint size = 0;
985 for (auto& boundaryCondition : boundaryConditions[level]->adFluxBoundaryConditions)
986 size += uint(boundaryCondition->indices.size());
987 return size;
988}
989
990void LevelGridBuilder::getADFluxValues(real* normalX, real* normalY, real* normalZ, real* gradient, int* indices,
991 int level) const
992{
994 for (auto& boundaryCondition : boundaryConditions[level]->adFluxBoundaryConditions) {
995 for (uint i = 0; i < boundaryCondition->indices.size(); i++) {
996 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1;
997 normalX[allIndicesCounter] = boundaryCondition->getNormalX(i);
998 normalY[allIndicesCounter] = boundaryCondition->getNormalY(i);
999 normalZ[allIndicesCounter] = boundaryCondition->getNormalZ(i);
1000 gradient[allIndicesCounter] = boundaryCondition->getGradient(i);
1002 }
1003 }
1004}
1005
1006void LevelGridBuilder::getADFluxQs(real* qs[27], int level) const
1007{
1009 for (auto& boundaryCondition : boundaryConditions[level]->adFluxBoundaryConditions) {
1010 for (uint index = 0; index < boundaryCondition->indices.size(); index++) {
1011 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
1012 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
1014 }
1015 }
1016}
1017
1019{
1020 uint size = 0;
1021 for (auto& boundaryCondition : boundaryConditions[level]->adDirichletBoundaryConditions)
1022 size += uint(boundaryCondition->indices.size());
1023 return size;
1024}
1025
1026void LevelGridBuilder::getADDirichletValues(real* values, real* vx, real* vy, real* vz, int* indices, int level) const
1027{
1029 for (auto& boundaryCondition : boundaryConditions[level]->adDirichletBoundaryConditions) {
1030 for (uint i = 0; i < boundaryCondition->indices.size(); i++) {
1031 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1;
1032 values[allIndicesCounter] = boundaryCondition->getBCvalue(i);
1033 vx[allIndicesCounter] = boundaryCondition->getVx(i);
1034 vy[allIndicesCounter] = boundaryCondition->getVy(i);
1035 vz[allIndicesCounter] = boundaryCondition->getVz(i);
1037 }
1038 }
1039}
1040
1041void LevelGridBuilder::getADDirichletQs(real* qs[27], int level) const
1042{
1044 for (auto& boundaryCondition : boundaryConditions[level]->adDirichletBoundaryConditions) {
1045 for (uint index = 0; index < boundaryCondition->indices.size(); index++) {
1046 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
1047 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
1049 }
1050 }
1051}
1052
1054{
1055 uint size = 0;
1056 for (auto& boundaryCondition : boundaryConditions[level]->adNeumannBoundaryConditions)
1057 size += uint(boundaryCondition->indices.size());
1058 return size;
1059}
1060
1061void LevelGridBuilder::getADNeumannValues(real* gradients, real* vx, real* vy, real* vz, int* indices, int level) const
1062{
1064 for (auto& boundaryCondition : boundaryConditions[level]->adNeumannBoundaryConditions) {
1065 for (uint i = 0; i < boundaryCondition->indices.size(); i++) {
1066 indices[allIndicesCounter] = grids[level]->getSparseIndex(boundaryCondition->indices[i]) + 1;
1067 gradients[allIndicesCounter] = boundaryCondition->getBCgradient(i);
1068 vx[allIndicesCounter] = boundaryCondition->getVx(i);
1069 vy[allIndicesCounter] = boundaryCondition->getVy(i);
1070 vz[allIndicesCounter] = boundaryCondition->getVz(i);
1072 }
1073 }
1074}
1075
1076void LevelGridBuilder::getADNeumannQs(real* qs[27], int level) const
1077{
1079 for (auto& boundaryCondition : boundaryConditions[level]->adNeumannBoundaryConditions) {
1080 for (uint index = 0; index < boundaryCondition->indices.size(); index++) {
1081 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
1082 qs[dir][allIndicesCounter] = boundaryCondition->qs[index][dir];
1084 }
1085 }
1086}
1087
1089{
1090 for (uint level = 0; level < getNumberOfGridLevels(); level++) {
1092
1093 auto side = SideFactory::make(sideType);
1094 boundaryCondition->side = side;
1095 boundaryCondition->side->addIndices(grids, level, boundaryCondition);
1096
1097 boundaryConditions[level]->adOutflowBoundaryConditions.push_back(boundaryCondition);
1098
1099 VF_LOG_INFO("Set Outflow Advection-Diffusion BC on level {} with {}", level, boundaryCondition->indices.size());
1100 }
1101}
1102
1104{
1105 return boundaryConditions[level]->adOutflowBoundaryConditions.size();
1106}
1107
1109{
1110 return boundaryConditions[level]->adOutflowBoundaryConditions[indexInBoundaryConditionVector]->indices.size();
1111}
1112
1113void LevelGridBuilder::getADOutflowValues(int* indices, int* neighborIndices, uint level,
1115{
1116 const auto& boundaryCondition = boundaryConditions[level]->adOutflowBoundaryConditions[indexInBoundaryConditionVector];
1117 for (std::size_t index = 0; index < boundaryCondition->indices.size(); index++) {
1118 indices[index] = grids[level]->getSparseIndex(boundaryCondition->indices[index]) + 1;
1119 neighborIndices[index] = grids[level]->getSparseIndex(boundaryCondition->neighborIndices[index]) + 1;
1120 }
1121}
1122
1124{
1125 const auto& boundaryCondition = boundaryConditions[level]->adOutflowBoundaryConditions[indexInBoundaryConditionVector];
1126 for (uint index = 0; index < boundaryCondition->indices.size(); index++) {
1127 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
1128 qs[dir][index] = boundaryCondition->qs[index][dir];
1129 }
1130}
1131
1133{
1134 return boundaryConditions[level]->adOutflowBoundaryConditions[indexInBoundaryConditionVector]->side->getD3Q27Direction();
1135}
1136
1138{
1139 if (boundaryConditions[level]->geometryBoundaryCondition)
1140 return (uint)boundaryConditions[level]->geometryBoundaryCondition->indices.size();
1141
1142 return 0;
1143}
1144
1145void LevelGridBuilder::getGeometryIndices(int* indices, int level) const
1146{
1147 for (uint i = 0; i < boundaryConditions[level]->geometryBoundaryCondition->indices.size(); i++)
1148 {
1149 indices[i] = grids[level]->getSparseIndex(boundaryConditions[level]->geometryBoundaryCondition->indices[i]) + 1;
1150 }
1151}
1152
1154{
1155 return geometryHasValues;
1156}
1157
1158void LevelGridBuilder::getGeometryValues(real* vx, real* vy, real* vz, int level) const
1159{
1160 for (uint i = 0; i < boundaryConditions[level]->geometryBoundaryCondition->indices.size(); i++)
1161 {
1162 vx[i] = boundaryConditions[level]->geometryBoundaryCondition->getVx(i);
1163 vy[i] = boundaryConditions[level]->geometryBoundaryCondition->getVy(i);
1164 vz[i] = boundaryConditions[level]->geometryBoundaryCondition->getVz(i);
1165 }
1166}
1167
1168void LevelGridBuilder::getGeometryQs(real* qs[27], int level) const
1169{
1170 for (std::size_t i = 0; i < boundaryConditions[level]->geometryBoundaryCondition->indices.size(); i++)
1171 {
1172 for (int dir = 0; dir <= grids[level]->getEndDirection(); dir++)
1173 {
1174 qs[dir][i] = boundaryConditions[level]->geometryBoundaryCondition->qs[i][dir];
1175 }
1176 }
1177}
1178
1179void LevelGridBuilder::writeArrows(std::string fileName) const
1180{
1181 QLineWriter::writeArrows(fileName, boundaryConditions[getNumberOfGridLevels() - 1]->geometryBoundaryCondition, grids[getNumberOfGridLevels() - 1]);
1182}
1183
1185{
1186 for (auto bc : this->boundaryConditions[level]->slipBoundaryConditions)
1187 if (bc->isSide(side))
1188 return bc;
1189
1190 for (auto bc : this->boundaryConditions[level]->velocityBoundaryConditions)
1191 if( bc->isSide(side) )
1192 return bc;
1193
1194 for (auto bc : this->boundaryConditions[level]->pressureBoundaryConditions)
1195 if (bc->isSide(side))
1196 return bc;
1197
1198 auto bc = this->boundaryConditions[level]->geometryBoundaryCondition;
1199
1200 if (bc && bc->isSide(side))
1201 return bc;
1202
1203 return nullptr;
1204}
1205
1207{
1208 return this->boundaryConditions[level]->geometryBoundaryCondition;
1209}
1210
1212{
1213 VF_LOG_TRACE("Start findFluidNodes()");
1214 for (uint i = 0; i < grids.size(); i++)
1215 grids[i]->findFluidNodeIndices(splitDomain);
1216 VF_LOG_TRACE("Done findFluidNodes()");
1217}
1218
1219
1220void LevelGridBuilder::addFluidNodeIndicesMacroVars(const std::vector<uint>& fluidNodeIndicesMacroVars, uint level)
1221{
1222 grids[level]->addFluidNodeIndicesMacroVars(fluidNodeIndicesMacroVars);
1223}
1224
1225void LevelGridBuilder::addFluidNodeIndicesApplyBodyForce(const std::vector<uint>& fluidNodeIndicesApplyBodyForce, uint level)
1226{
1227 grids[level]->addFluidNodeIndicesApplyBodyForce(fluidNodeIndicesApplyBodyForce);
1228}
1229
1230void LevelGridBuilder::addFluidNodeIndicesAllFeatures(const std::vector<uint>& fluidNodeIndicesAllFeatures, uint level)
1231{
1232 grids[level]->addFluidNodeIndicesAllFeatures(fluidNodeIndicesAllFeatures);
1233}
1234
1235
1237{
1238 grids[level]->addAllFluidNodeIndicesToAllFeatures();
1239}
1240
1241
1243{
1244 grids[level]->sortFluidNodeIndicesMacroVars();
1245}
1246
1248{
1249 grids[level]->sortFluidNodeIndicesApplyBodyForce();
1250}
1251
1253{
1254 grids[level]->sortFluidNodeIndicesAllFeatures();
1255}
1256
1258{
1259 return grids[level]->getNumberOfFluidNodeIndicesMacroVars();
1260}
1261
1262void LevelGridBuilder::getFluidNodeIndicesMacroVars(uint *fluidNodeIndicesMacroVars, const int level) const
1263{
1264 grids[level]->getFluidNodeIndicesMacroVars(fluidNodeIndicesMacroVars);
1265}
1266
1268{
1269 return grids[level]->getNumberOfFluidNodeIndicesApplyBodyForce();
1270}
1271
1272void LevelGridBuilder::getFluidNodeIndicesApplyBodyForce(uint *fluidNodeIndicesApplyBodyForce, const int level) const
1273{
1274 grids[level]->getFluidNodeIndicesApplyBodyForce(fluidNodeIndicesApplyBodyForce);
1275}
1276
1278{
1279 return grids[level]->getNumberOfFluidNodeIndicesAllFeatures();
1280}
1281
1282void LevelGridBuilder::getFluidNodeIndicesAllFeatures(uint *fluidNodeIndicesAllFeatures, const int level) const
1283{
1284 grids[level]->getFluidNodeIndicesAllFeatures(fluidNodeIndicesAllFeatures);
1285}
1286
1287}
1288
#define VF_LOG_TRACE(...)
Definition Logger.h:48
#define VF_LOG_INFO(...)
Definition Logger.h:50
static SPtr< ADDirichletBoundaryCondition > make(real BCvalue, real vx, real vy, real vz)
static SPtr< ADFluxBoundaryCondition > make(real normalX, real normalY, real normalZ, real gradient)
static SPtr< ADNeumannBoundaryCondition > make(real BCvalue, real vx, real vy, real vz)
static SPtr< ADNoFluxBoundaryCondition > make()
static SPtr< ADOutflowBoundaryCondition > make()
void getADOutflowQs(real *qs[27], uint level, uint indexInBoundaryConditionVector) const override
uint getPressureSize(int level) const override
uint getNumberOfGridLevels() const override
bool hasGeometryValues() const override
void sortFluidNodeIndicesApplyBodyForce(uint level) override
void setADOutflowBoundaryCondition(SideType sideType)
uint getSlipSize(int level) const override
void setADDirichletBoundaryCondition(SideType sideType, real value, real vx, real vy, real vz)
void getPrecursorValues(uint *neighbor0PP, uint *neighbor0PM, uint *neighbor0MP, uint *neighbor0MM, real *weights0PP, real *weights0PM, real *weights0MP, real *weights0MM, int *indices, std::vector< SPtr< TransientBCInputFileReader > > &reader, int &numberOfPrecursorNodes, size_t &numberOfQuantities, uint &timeStepsBetweenReads, real &velocityX, real &velocityY, real &velocityZ, int level) const override
uint getSurfaceLayerSize(int level) const override
virtual void setPressureBoundaryCondition(SideType sideType, real rho)
void setSlipGeometryBoundaryCondition(real normalX, real normalY, real normalZ)
size_t getPressureBoundaryConditionDirection(uint level, uint indexInBoundaryConditionVector) const override
void setADFluxBoundaryCondition(SideType sideType, real normalX, real normalY, real normalZ, real gradient, real deltaX)
virtual void setNoSlipBoundaryCondition(SideType sideType)
void setADNeumannBoundaryCondition(SideType sideType, real gradient, real vx, real vy, real vz, real dx)
virtual void setPeriodicBoundaryCondition(bool periodic_X, bool periodic_Y, bool periodic_Z)
void getSlipValues(real *normalX, real *normalY, real *normalZ, int *indices, int level) const override
uint getADNeumannSize(int level) const override
void getADDirichletValues(real *values, real *vx, real *vy, real *vz, int *indices, int level) const override
void getPressureValues(real *rho, int *indices, int *neighborIndices, int level) const override
void getVelocityValues(real *vx, real *vy, real *vz, int *indices, int level) const override
uint getNumberOfSendIndices(int direction, uint level) override
void getFluidNodeIndices(uint *fluidNodeIndices, const int level) const override
void getADFluxValues(real *normalX, real *normalY, real *normalZ, real *gradient, int *indices, int level) const override
void getADFluxQs(real *qs[27], int level) const override
void addAllFluidNodeIndicesToAllFeatures(uint level) override
void getVelocityQs(real *qs[27], int level) const override
uint getNumberOfFluidNodesApplyBodyForce(unsigned int level) const override
void setPeriodicShiftOnXBoundaryInYDirection(real shift)
void getGeometryIndices(int *indices, int level) const override
uint getNumberOfNodesFC(int level) override
void getADDirichletQs(real *qs[27], int level) const override
void getFluidNodeIndicesApplyBodyForce(uint *fluidNodeIndicesApplyBodyForce, const int level) const override
uint getNumberOfFluidNodesMacroVars(unsigned int level) const override
void setPeriodicShiftOnYBoundaryInXDirection(real shift)
void getSurfaceLayerQs(real *qs[27], int level) const override
virtual void setCommunicationProcess(int direction, uint process)
void setADNoFluxBoundaryCondition(SideType sideType)
void sortFluidNodeIndicesAllFeatures(uint level) override
void getADNeumannQs(real *qs[27], int level) const override
void addFluidNodeIndicesAllFeatures(const std::vector< uint > &fluidNodeIndicesAllFeatures, uint level) override
void getFluidNodeIndicesBorder(uint *fluidNodeIndices, const int level) const override
void getNodeValues(real *xCoords, real *yCoords, real *zCoords, uint *neighborX, uint *neighborY, uint *neighborZ, uint *neighborNegative, uint *geo, const int level) const override
uint getNumberOfReceiveIndices(int direction, uint level) override
void getOffsetCF(real *xOffFc, real *yOffFc, real *zOffFc, int level) override
void setPeriodicShiftOnZBoundaryInYDirection(real shift)
void getSurfaceLayerValues(real *normalX, real *normalY, real *normalZ, int *indices, real *samplingDistances, uint *samplingIndices, real *vonKarmanConstants, real *roughnessLengths, real *roughnessLengthsTemperature, real *surfaceHeatFluxes, real *surfaceTemperatures, real *heatingRates, int level) const override
virtual void setVelocityBoundaryCondition(SideType sideType, real vx, real vy, real vz, std::optional< std::function< void(real x, real y, real z, real &vx, real &vy, real &vz)> > velocityProfile=std::nullopt)
SPtr< Grid > getGrid(uint level) override
SPtr< grid_generator::BoundaryCondition > getBoundaryCondition(SideType side, uint level) const override
virtual void setStressBoundaryCondition(SideType sideType, real normalX, real normalY, real normalZ, uint samplingOffset, real vonKarmanConstant, real roughnessLength, real deltaX, std::shared_ptr< GbSpatialData3D< real > > roughnessMap=nullptr)
Set stress boundary condition using iMEM.
void setPeriodicShiftOnZBoundaryInXDirection(real shift)
size_t getSizeOfADOutflowBoundaryCondition(uint level, uint indexInBoundaryConditionVector) const override
void getADOutflowValues(int *indices, int *neighborIndices, uint level, uint indexInBoundaryConditionVector) const override
void getReceiveIndices(uint *sendIndices, int direction, int level) override
void getDimensions(int &nx, int &ny, int &nz, const int level) const override
uint getADNoFluxSize(int level) const override
void setEnableFixRefinementIntoTheWall(bool enableFixRefinementIntoTheWall)
size_t getNumberOfPressureBoundaryConditions(uint level) const override
void getSlipQs(real *qs[27], int level) const override
uint getPrecursorSize(int level) const override
void getPressureQs(real *qs[27], int level) const override
uint getNumberOfFluidNodesBorder(unsigned int level) const override
void setVelocityGeometryBoundaryCondition(real vx, real vy, real vz)
uint getNumberOfNodes(unsigned int level) const override
void getFluidNodeIndicesAllFeatures(uint *fluidNodeIndicesAllFeatures, const int level) const override
uint getStressSize(int level) const override
uint getADFluxSize(int level) const override
uint getGeometrySize(int level) const override
virtual void setPrecursorBoundaryCondition(SideType sideType, SPtr< FileCollection > fileCollection, int timeStepsBetweenReads, bool cycleFiles, real velocityX=vf::basics::constant::c0o1, real velocityY=vf::basics::constant::c0o1, real velocityZ=vf::basics::constant::c0o1, std::vector< uint > fileLevelToGridLevelMap={})
void getGridInterfaceIndices(uint *iCellCfc, uint *iCellCff, uint *iCellFcc, uint *iCellFcf, int level) const override
uint getVelocitySize(int level) const override
uint getNumberOfFluidNodes(unsigned int level) const override
std::vector< std::shared_ptr< Grid > > grids
void getADNeumannValues(real *gradients, real *vx, real *vy, real *vz, int *indices, int level) const override
std::vector< SPtr< BoundaryConditions > > boundaryConditions
void getSendIndices(uint *sendIndices, int direction, int level) override
void setPeriodicShiftOnYBoundaryInZDirection(real shift)
void getPrecursorQs(real *qs[27], int level) const override
uint getNumberOfFluidNodesAllFeatures(unsigned int level) const override
size_t getSizeOfPressureBoundaryCondition(uint level, uint indexInBoundaryConditionVector) const override
void getGeometryValues(real *vx, real *vy, real *vz, int level) const override
void getGridInformations(std::vector< int > &gridX, std::vector< int > &gridY, std::vector< int > &gridZ, std::vector< int > &distX, std::vector< int > &distY, std::vector< int > &distZ) override
uint getCommunicationProcess(int direction) override
void getADNoFluxValues(int *indices, int level) const override
void writeArrows(std::string fileName) const override
std::array< uint, 6 > communicationProcesses
size_t getNumberOfADOutflowBoundaryConditions(uint level) const override
void getStressValues(real *normalX, real *normalY, real *normalZ, int *indices, uint *samplingIndices, real *samplingDistances, real *vonKarmanConstants, real *roughnessLengths, int level) const override
uint getADDirichletSize(int level) const override
void findFluidNodes(bool splitDomain) override
SPtr< GeometryBoundaryCondition > getGeometryBoundaryCondition(uint level) const override
void getADNoFluxQs(real *qs[27], int level) const override
virtual void setSlipBoundaryCondition(SideType sideType, real normalX, real normalY, real normalZ)
static std::shared_ptr< LevelGridBuilder > makeShared()
void getStressQs(real *qs[27], int level) const override
size_t getADOutflowBoundaryConditionDirection(uint level, uint indexInBoundaryConditionVector) const override
void addFluidNodeIndicesApplyBodyForce(const std::vector< uint > &fluidNodeIndicesApplyBodyForce, uint level) override
uint getNumberOfNodesCF(int level) override
void setSurfaceLayerBoundaryCondition(SideType sideType, real normalX, real normalY, real normalZ, uint samplingOffset, real vonKarmanConstant, real roughnessLength, real roughnessLengthTemperature, real surfaceHeatFlux, real surfaceTemperature, real heatingRate, real deltaX, real deltaT, std::shared_ptr< GbSpatialData3D< real > > roughnessMap=nullptr)
Set surface layer boundary condition using iMEM.
void getGeometryQs(real *qs[27], int level) const override
void getOffsetFC(real *xOffCf, real *yOffCf, real *zOffCf, int level) override
void addFluidNodeIndicesMacroVars(const std::vector< uint > &fluidNodeIndicesMacroVars, uint level) override
void getFluidNodeIndicesMacroVars(uint *fluidNodeIndicesMacroVars, const int level) const override
void setPeriodicShiftOnXBoundaryInZDirection(real shift)
void sortFluidNodeIndicesMacroVars(uint level) override
static SPtr< PrecursorBoundaryCondition > make(SPtr< TransientBCInputFileReader > reader, int timeStepsBetweenReads, real velocityX, real velocityY, real velocityZ)
static SPtr< PressureBoundaryCondition > make(real rho)
static void writeArrows(std::string fileName, SPtr< GeometryBoundaryCondition > geometryBoundaryCondition, SPtr< Grid > grid)
static SPtr< Side > make(SideType sideType)
Definition Side.h:267
static SPtr< SlipBoundaryCondition > make(real normalX, real normalY, real normalZ)
static SPtr< StressBoundaryCondition > make(real normalX, real normalY, real normalZ, uint samplingOffset, real vonKarmanConstant, real roughnessLength, std::shared_ptr< GbSpatialData3D< real > > roughnessMap)
static SPtr< SurfaceLayerBoundaryCondition > make(real normalX, real normalY, real normalZ, uint samplingOffset, real vonKarmanConstant, real roughnessLength, real roughnessLengthTemperature, real surfaceHeatFlux, real surfaceTemperature, real heatingRate, std::shared_ptr< GbSpatialData3D< real > > roughnessMap)
static SPtr< VelocityBoundaryCondition > make(real vx, real vy, real vz)
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
#define INVALID_INDEX
Definition DataTypes.h:48
@ z
Definition Axis.h:44
@ x
Definition Axis.h:42
@ y
Definition Axis.h:43
SPtr< TransientBCInputFileReader > createReaderForCollection(SPtr< FileCollection > fileCollection, uint readLevel, bool cycleFiles)
real adjustShift(real shift, real delta, real length)
SideType
Definition Side.h:63