VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
BoundaryConditionKernelManager.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 <cuda_runtime.h>
35#include <helper_cuda.h>
36#include <iostream>
37#include <stdexcept>
38#include <string>
39
43#include "Parameter/Parameter.h"
45#include "PostProcessor/Cp.h"
48
51
52namespace vf::gpu {
53
55{
56 this->velocityBoundaryConditionPost = bcFactory->getVelocityBoundaryConditionPost();
57 this->noSlipBoundaryConditionPost = bcFactory->getNoSlipBoundaryConditionPost();
58 this->slipBoundaryConditionPost = bcFactory->getSlipBoundaryConditionPost();
59 this->geometryBoundaryConditionPost = bcFactory->getGeometryBoundaryConditionPost();
60 this->stressBoundaryConditionPost = bcFactory->getStressBoundaryConditionPost();
61 this->precursorBoundaryConditionPost = bcFactory->getPrecursorBoundaryConditionPost();
62
63 this->ADNoFluxBoundaryConditionPost = bcFactory->getAdvectionDiffusionNoFluxBoundaryConditionPost();
64 this->ADFluxBoundaryConditionPost = bcFactory->getAdvectionDiffusionFluxBoundaryConditionPost();
65 this->ADDirichletBoundaryConditionPost = bcFactory->getAdvectionDiffusionDirichletBoundaryConditionPost();
66 this->ADNeumannBoundaryConditionPost = bcFactory->getAdvectionDiffusionNeumannBoundaryConditionPost();
67 this->ADDirectionalBoundaryConditionPost = bcFactory->getAdvectionDiffusionDirectionalBoundaryConditionPost();
68
69 this->surfaceLayerBoundaryConditionPost = bcFactory->getSurfaceLayerBoundaryConditionPost();
70
72 this->directionalPressureBoundaryConditionPre =
73 std::get<DirectionalBoundaryConditionKernel>(bcFactory->getPressureBoundaryConditionPre());
74 else
75 this->pressureBoundaryConditionPre = std::get<BoundaryConditionKernel>(bcFactory->getPressureBoundaryConditionPre());
76
77 checkBoundaryCondition(this->velocityBoundaryConditionPost, this->para->getParD(0)->velocityBC,
78 "velocityBoundaryConditionPost");
79 checkBoundaryCondition(this->noSlipBoundaryConditionPost, this->para->getParD(0)->noSlipBC,
80 "noSlipBoundaryConditionPost");
81 checkBoundaryCondition(this->slipBoundaryConditionPost, this->para->getParD(0)->slipBC,
82 "slipBoundaryConditionPost");
83 checkBoundaryCondition(this->geometryBoundaryConditionPost, this->para->getParD(0)->geometryBC,
84 "geometryBoundaryConditionPost");
85 checkBoundaryCondition(this->stressBoundaryConditionPost, this->para->getParD(0)->stressBC,
86 "stressBoundaryConditionPost");
87 checkBoundaryCondition(this->precursorBoundaryConditionPost, this->para->getParD(0)->precursorBC,
88 "precursorBoundaryConditionPost");
89 checkBoundaryCondition(this->pressureBoundaryConditionPre, this->para->getParD(0)->pressureBC,
90 "pressureBoundaryConditionPre");
91 checkBoundaryCondition(this->directionalPressureBoundaryConditionPre, this->para->getParD(0)->pressureBCDirectional,
92 "directionalPressureBoundaryConditionPre");
93 checkBoundaryCondition(this->ADNoFluxBoundaryConditionPost, this->para->getParD(0)->AdvectionDiffusionNoFluxBC,
94 "AdvectionDiffusionNoFluxBoundaryConditionPost");
95 checkBoundaryCondition(this->ADFluxBoundaryConditionPost,
96 this->para->getParD(0)->AdvectionDiffusionFluxBC,
97 "AdvectionDiffusionFluxBoundaryConditionPost");
98 checkBoundaryCondition(this->ADDirichletBoundaryConditionPost, this->para->getParD(0)->AdvectionDiffusionDirichletBC,
99 "AdvectionDiffusionDirichletBoundaryConditionPost");
100 checkBoundaryCondition(this->ADNeumannBoundaryConditionPost, this->para->getParD(0)->AdvectionDiffusionNeumannBC,
101 "AdvectionDiffusionNeumannBoundaryConditionPost");
102 checkBoundaryCondition(this->ADDirectionalBoundaryConditionPost, this->para->getParD(0)->concentrationBCDirectional,
103 "AdvectionDiffusionDirectionalBoundaryConditionPost");
104 checkBoundaryCondition(this->surfaceLayerBoundaryConditionPost, this->para->getParD(0)->surfaceLayerBC,
105 "surfaceLayerBoundaryConditionPost");
106}
107
109{
110 if (para->getParD(level)->velocityBC.numberOfBCnodes > 0)
111 {
113 // high viscosity incompressible
114 // QVelDevIncompHighNu27(
115 // para->getParD(level)->numberofthreads,
116 // para->getParD(level)->velocityBC.Vx,
117 // para->getParD(level)->velocityBC.Vy,
118 // para->getParD(level)->velocityBC.Vz,
119 // para->getParD(level)->distributions.f[0],
120 // para->getParD(level)->velocityBC.k,
121 // para->getParD(level)->velocityBC.q27[0],
122 // para->getParD(level)->velocityBC.numberOfBCnodes,
123 // para->getParD(level)->omega,
124 // para->getParD(level)->neighborX,
125 // para->getParD(level)->neighborY,
126 // para->getParD(level)->neighborZ,
127 // para->getParD(level)->numberOfNodes,
128 // para->getParD(level)->isEvenTimestep);
129
131 // high viscosity compressible
132 // QVelDevCompHighNu27(
133 // para->getParD(level)->numberofthreads,
134 // para->getParD(level)->velocityBC.Vx,
135 // para->getParD(level)->velocityBC.Vy,
136 // para->getParD(level)->velocityBC.Vz,
137 // para->getParD(level)->distributions.f[0],
138 // para->getParD(level)->velocityBC.k,
139 // para->getParD(level)->velocityBC.q27[0],
140 // para->getParD(level)->velocityBC.numberOfBCnodes,
141 // para->getParD(level)->omega,
142 // para->getParD(level)->neighborX,
143 // para->getParD(level)->neighborY,
144 // para->getParD(level)->neighborZ,
145 // para->getParD(level)->numberOfNodes,
146 // para->getParD(level)->isEvenTimestep);
147 }
148}
149
151{
152 if (para->getParD(level)->velocityBC.numberOfBCnodes > 0)
153 {
154 velocityBoundaryConditionPost(para->getParD(level).get(), &(para->getParD(level)->velocityBC));
155
157 // D E P R E C A T E D
159
160 // QVelDevice1h27( para->getParD(level)->numberofthreads, para->getParD(level)->nx, para->getParD(level)->ny,
161 // para->getParD(level)->velocityBC.Vx, para->getParD(level)->velocityBC.Vy, para->getParD(level)->velocityBC.Vz,
162 // para->getParD(level)->distributions.f[0], para->getParD(level)->velocityBC.k, para->getParD(level)->velocityBC.q27[0],
163 // para->getParD(level)->velocityBC.numberOfBCnodes, para->getParD(level)->omega,
164 // para->getPhi(), para->getAngularVelocity(),
165 // para->getParD(level)->neighborX, para->getParD(level)->neighborY, para->getParD(level)->neighborZ,
166 // para->getParD(level)->coordinateX, para->getParD(level)->coordinateY, para->getParD(level)->coordinateZ,
167 // para->getParD(level)->numberOfNodes, para->getParD(level)->isEvenTimestep);
168 // getLastCudaError("QVelDev27 execution failed");
169 }
170}
171
172void BoundaryConditionKernelManager::runGeoBCKernelPre(int level, unsigned int t, CudaMemoryManager* cudaMemoryManager) const{
173 if (para->getParD(level)->geometryBC.numberOfBCnodes > 0){
174 if (para->getCalcDragLift())
175 {
176 //Drag and Lift Part II
178 para->getParD(level)->distributions.f[0],
179 para->getParD(level)->geometryBC.k,
180 para->getParD(level)->geometryBC.q27[0],
181 para->getParD(level)->geometryBC.numberOfBCnodes,
182 para->getParD(level)->DragLiftPreProcessingInXdirection,
183 para->getParD(level)->DragLiftPreProcessingInYdirection,
184 para->getParD(level)->DragLiftPreProcessingInZdirection,
185 para->getParD(level)->neighborX,
186 para->getParD(level)->neighborY,
187 para->getParD(level)->neighborZ,
188 para->getParD(level)->numberOfNodes,
189 para->getParD(level)->isEvenTimestep,
190 para->getParD(level)->numberofthreads);
192 //Calculation of Drag and Lift
194 calcDragLift(para.get(), cudaMemoryManager, level);
196 }
197
198 if (para->getCalcCp())
199 {
201 //Calculation of cp
203
204 if(t > para->getTimestepStartOut())
205 {
208 para->getParD(level)->distributions.f[0],
209 para->getParD(level)->cpTopIndex,
210 para->getParD(level)->numberOfPointsCpTop,
211 para->getParD(level)->cpPressTop,
212 para->getParD(level)->neighborX,
213 para->getParD(level)->neighborY,
214 para->getParD(level)->neighborZ,
215 para->getParD(level)->numberOfNodes,
216 para->getParD(level)->isEvenTimestep,
217 para->getParD(level)->numberofthreads);
220 para->getParD(level)->distributions.f[0],
221 para->getParD(level)->cpBottomIndex,
222 para->getParD(level)->numberOfPointsCpBottom,
223 para->getParD(level)->cpPressBottom,
224 para->getParD(level)->neighborX,
225 para->getParD(level)->neighborY,
226 para->getParD(level)->neighborZ,
227 para->getParD(level)->numberOfNodes,
228 para->getParD(level)->isEvenTimestep,
229 para->getParD(level)->numberofthreads);
232 para->getParD(level)->distributions.f[0],
233 para->getParD(level)->cpBottom2Index,
234 para->getParD(level)->numberOfPointsCpBottom2,
235 para->getParD(level)->cpPressBottom2,
236 para->getParD(level)->neighborX,
237 para->getParD(level)->neighborY,
238 para->getParD(level)->neighborZ,
239 para->getParD(level)->numberOfNodes,
240 para->getParD(level)->isEvenTimestep,
241 para->getParD(level)->numberofthreads);
243 calcCp(para.get(), cudaMemoryManager, level);
244 }
245 }
246
248 // high viscosity incompressible
249 // QDevIncompHighNu27(
250 // para->getParD(level)->numberofthreads,
251 // para->getParD(level)->distributions.f[0],
252 // para->getParD(level)->geometryBC.k,
253 // para->getParD(level)->geometryBC.q27[0],
254 // para->getParD(level)->geometryBC.numberOfBCnodes,
255 // para->getParD(level)->omega,
256 // para->getParD(level)->neighborX,
257 // para->getParD(level)->neighborY,
258 // para->getParD(level)->neighborZ,
259 // para->getParD(level)->numberOfNodes,
260 // para->getParD(level)->isEvenTimestep);
261
263 // high viscosity compressible
264 // QDevCompHighNu27(
265 // para->getParD(level)->numberofthreads,
266 // para->getParD(level)->distributions.f[0],
267 // para->getParD(level)->geometryBC.k,
268 // para->getParD(level)->geometryBC.q27[0],
269 // para->getParD(level)->geometryBC.numberOfBCnodes,
270 // para->getParD(level)->omega,
271 // para->getParD(level)->neighborX,
272 // para->getParD(level)->neighborY,
273 // para->getParD(level)->neighborZ,
274 // para->getParD(level)->numberOfNodes,
275 // para->getParD(level)->isEvenTimestep);
276
277 }
278}
279
281{
282 if (para->getParD(level)->geometryBC.numberOfBCnodes > 0)
283 {
284 if (para->getCalcDragLift())
285 {
286 //Drag and Lift Part I
287 DragLiftPostD27(para->getParD(level)->distributions.f[0],
288 para->getParD(level)->geometryBC.k,
289 para->getParD(level)->geometryBC.q27[0],
290 para->getParD(level)->geometryBC.numberOfBCnodes,
291 para->getParD(level)->DragLiftPostProcessingInXdirection,
292 para->getParD(level)->DragLiftPostProcessingInYdirection,
293 para->getParD(level)->DragLiftPostProcessingInZdirection,
294 para->getParD(level)->neighborX,
295 para->getParD(level)->neighborY,
296 para->getParD(level)->neighborZ,
297 para->getParD(level)->numberOfNodes,
298 para->getParD(level)->isEvenTimestep,
299 para->getParD(level)->numberofthreads);
300 getLastCudaError("DragLift27 execution failed");
301 }
302
303 geometryBoundaryConditionPost(para->getParD(level).get(), &(para->getParD(level)->geometryBC));
304
306 // D E P R E C A T E D
308 // the GridGenerator does currently not provide normals!
309
310 // QSlipGeomDevComp27(
311 // para->getParD(level)->numberofthreads,
312 // para->getParD(level)->distributions.f[0],
313 // para->getParD(level)->geometryBC.k,
314 // para->getParD(level)->geometryBC.q27[0],
315 // para->getParD(level)->geometryBC.numberOfBCnodes,
316 // para->getParD(level)->omega,
317 // para->getParD(level)->geometryBCnormalX.q27[0],
318 // para->getParD(level)->geometryBCnormalY.q27[0],
319 // para->getParD(level)->geometryBCnormalZ.q27[0],
320 // para->getParD(level)->neighborX,
321 // para->getParD(level)->neighborY,
322 // para->getParD(level)->neighborZ,
323 // para->getParD(level)->numberOfNodes,
324 // para->getParD(level)->isEvenTimestep);
325
326 // QSlipNormDevComp27(
327 // para->getParD(level)->numberofthreads,
328 // para->getParD(level)->distributions.f[0],
329 // para->getParD(level)->geometryBC.k,
330 // para->getParD(level)->geometryBC.q27[0],
331 // para->getParD(level)->geometryBC.numberOfBCnodes,
332 // para->getParD(level)->omega,
333 // para->getParD(level)->geometryBCnormalX.q27[0],
334 // para->getParD(level)->geometryBCnormalY.q27[0],
335 // para->getParD(level)->geometryBCnormalZ.q27[0],
336 // para->getParD(level)->neighborX,
337 // para->getParD(level)->neighborY,
338 // para->getParD(level)->neighborZ,
339 // para->getParD(level)->numberOfNodes,
340 // para->getParD(level)->isEvenTimestep);
341 }
342}
343
345{
346 for (auto boundaryConditionStruct : para->getParD(level)->pressureBCDirectional) {
347 this->directionalPressureBoundaryConditionPre(para->getParD(level).get(), &boundaryConditionStruct);
348 }
349 if (para->getParD(level)->pressureBC.numberOfBCnodes > 0)
350 this->pressureBoundaryConditionPre(para->getParD(level).get(), &(para->getParD(level)->pressureBC));
351}
352
354{
355 if (para->getParD(level)->stressBC.numberOfBCnodes > 0)
356 stressBoundaryConditionPost(para->getParD(level).get(), &(para->getParD(level)->stressBC));
357}
358
360 if (para->getParD(level)->slipBC.numberOfBCnodes > 0)
361 slipBoundaryConditionPost(para->getParD(level).get(), &(para->getParD(level)->slipBC));
362}
363
365 if (para->getParD(level)->noSlipBC.numberOfBCnodes > 0)
366 noSlipBoundaryConditionPost(para->getParD(level).get(), &(para->getParD(level)->noSlipBC));
367}
368
370 if (para->getParD(level)->surfaceLayerBC.numberOfBCnodes > 0)
371 surfaceLayerBoundaryConditionPost(para->getParD(level).get(), &(para->getParD(level)->surfaceLayerBC));
372}
373
375{
376 if(para->getParH(level)->precursorBC.numberOfBCnodes == 0) return;
377
378 uint t_level = para->getTimeStep(level, t, true);
379
380 uint lastTime = (para->getParD(level)->precursorBC.nPrecursorReads-2)*para->getParD(level)->precursorBC.timeStepsBetweenReads; // timestep currently loaded into last arrays
381 uint currentTime = (para->getParD(level)->precursorBC.nPrecursorReads-1)*para->getParD(level)->precursorBC.timeStepsBetweenReads; // timestep currently loaded into current arrays
382 uint nextTime = para->getParD(level)->precursorBC.nPrecursorReads *para->getParD(level)->precursorBC.timeStepsBetweenReads; // timestep currently loaded into next arrays
383
385 {
386 //cycle time
389 nextTime += para->getParD(level)->precursorBC.timeStepsBetweenReads;
390
391 //cycle pointers
392 real* tmp = para->getParD(level)->precursorBC.last;
393 para->getParD(level)->precursorBC.last = para->getParD(level)->precursorBC.current;
394 para->getParD(level)->precursorBC.current = para->getParD(level)->precursorBC.next;
395 para->getParD(level)->precursorBC.next = tmp;
396
397 real loadTime = nextTime * para->getScaledTimeRatio(level);
398
399 for(auto reader : para->getParH(level)->transientBCInputFileReader)
400 {
401 reader->getNextData(para->getParH(level)->precursorBC.next, para->getParH(level)->precursorBC.numberOfPrecursorNodes, loadTime);
402 }
403 cudaMemoryManager->cudaCopyPrecursorData(level);
404 para->getParD(level)->precursorBC.nPrecursorReads++;
405 para->getParH(level)->precursorBC.nPrecursorReads++;
406 }
407
408 real tRatio = real(t_level-lastTime)/para->getParD(level)->precursorBC.timeStepsBetweenReads;
409 precursorBoundaryConditionPost(para->getParD(level).get(), &para->getParD(level)->precursorBC, tRatio, para->getVelocityRatio());
410}
411
413{
414 auto* parD = para->getParD(level).get();
415 if (parD->AdvectionDiffusionNoFluxBC.numberOfBCnodes == 0)
416 return;
417 ADNoFluxBoundaryConditionPost(parD, parD->AdvectionDiffusionNoFluxBC);
418}
419
421{
422 auto* parD = para->getParD(level).get();
423 if (parD->AdvectionDiffusionFluxBC.numberOfBCnodes == 0)
424 return;
425 ADFluxBoundaryConditionPost(parD, parD->AdvectionDiffusionFluxBC);
426}
427
429{
430 auto* parD = &para->getParDeviceAsReference(level);
431 if (parD->AdvectionDiffusionDirichletBC.numberOfBCnodes == 0)
432 return;
433 ADDirichletBoundaryConditionPost(parD, parD->AdvectionDiffusionDirichletBC);
434}
436{
437 auto* parD = &para->getParDeviceAsReference(level);
438 if (parD->AdvectionDiffusionNeumannBC.numberOfBCnodes == 0)
439 return;
440 ADNeumannBoundaryConditionPost(parD, parD->AdvectionDiffusionNeumannBC);
441}
442
444{
445 for (auto boundaryConditionStruct : para->getParD(level)->concentrationBCDirectional) {
446 this->ADDirectionalBoundaryConditionPost(para->getParD(level).get(), &boundaryConditionStruct);
447 }
448}
449
450}
451
virtual std::variant< BoundaryConditionKernel, DirectionalBoundaryConditionKernel > getPressureBoundaryConditionPre() const
virtual BoundaryConditionKernel getVelocityBoundaryConditionPost(bool isGeometryBC=false) const
BoundaryConditionKernel getStressBoundaryConditionPost() const
BoundaryConditionKernel getNoSlipBoundaryConditionPost(bool isGeometryBC=false) const
BoundaryConditionKernel getSlipBoundaryConditionPost(bool isGeometryBC=false) const
BoundaryConditionKernel getSurfaceLayerBoundaryConditionPost() const
BoundaryConditionKernel getGeometryBoundaryConditionPost() const
virtual bool hasDirectionalPressureBoundaryCondition() const
AdvectionDiffusionDirichletBoundaryConditionKernel getAdvectionDiffusionDirichletBoundaryConditionPost() const
AdvectionDiffusionNeumannBoundaryConditionKernel getAdvectionDiffusionNeumannBoundaryConditionPost() const
DirectionalADBoundaryConditionKernel getAdvectionDiffusionDirectionalBoundaryConditionPost() const
AdvectionDiffusionFluxBoundaryConditionKernel getAdvectionDiffusionFluxBoundaryConditionPost() const
AdvectionDiffusionNoFluxBoundaryConditionKernel getAdvectionDiffusionNoFluxBoundaryConditionPost() const
PrecursorBoundaryConditionKernel getPrecursorBoundaryConditionPost() const
void runADDirectionalBCKernel(int level) const
calls the device function of the directional advection-diffusion (temperature) outflow BC (post-colli...
void runSurfaceLayerBCKernelPost(int level) const
calls the device function of the surface layer boundary condition (post-collision)
void runVelocityBCKernelPost(int level) const
calls the device function of the velocity boundary condition (post-collision)
void runVelocityBCKernelPre(int level) const
calls the device function of the velocity boundary condition (pre-collision)
void runNoSlipBCKernelPost(int level) const
calls the device function of the no-slip boundary condition (post-collision)
BoundaryConditionKernelManager(SPtr< Parameter > parameter, const BoundaryConditionFactory *bcFactory)
void runGeoBCKernelPost(int level) const
calls the device function of the geometry boundary condition (post-collision)
void runStressWallModelKernelPost(int level) const
calls the device function of the stress wall model (post-collision)
void runPressureBCKernelPre(int level) const
calls the device function of the pressure boundary condition (pre-collision)
void runPrecursorBCKernelPost(int level, uint t, CudaMemoryManager *cudaMemoryManager)
calls the device function of the precursor boundary condition
void runGeoBCKernelPre(int level, unsigned int t, CudaMemoryManager *cudaMemoryManager) const
calls the device function of the geometry boundary condition (pre-collision)
void runSlipBCKernelPost(int level) const
calls the device function of the slip boundary condition (post-collision)
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
void calcDragLift(Parameter *para, CudaMemoryManager *cudaMemoryManager, int lev)
Calculate drag and lift for a geometry.
Definition DragLift.cpp:54
void calcCp(Parameter *para, CudaMemoryManager *cudaMemoryManager, int lev)
Definition Cp.cpp:50