VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
BoundaryCondition.h
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#ifndef BoundaryCondition_H
35#define BoundaryCondition_H
36
37#include <algorithm>
38#include <iterator>
39#include <memory>
40#include <vector>
41#include <functional>
42
44
46
48
49namespace vf::gpu {
50
51class Grid;
52
53class Side;
54enum class SideType;
55
56class TransientBCInputFileReader;
57
58namespace grid_generator
59{
61{
62public:
63 virtual ~BoundaryCondition() = default;
64
65 std::vector<uint> indices;
67 std::vector<std::vector<real>> qs;
68
69 std::vector<uint> patches;
70
71 virtual char getType() const = 0;
72
73 bool isSide(SideType side) const;
74
75 real getQ(uint index, uint dir) { return this->qs[index][dir]; }
76
77 void getCoords( SPtr<Grid> grid, std::vector<real>& x, std::vector<real>& y, std::vector<real>& z);
78 virtual void setAdditionalIndices(const SPtr<Grid>& /*grid*/, uint /*index*/) {};
79
80};
81
82}
83
85
87{
88public:
93
94 // matrix indices!!!
95 std::vector<uint> neighborIndices;
96
98protected:
100
101public:
102 char getType() const override
103 {
104 return vf::gpu::BC_PRESSURE;
105 }
106
107 real getRho() const
108 {
109 return this->rho;
110 }
111 void setAdditionalIndices(const SPtr<Grid> &grid, uint index) override;
112};
113
115
117{
118public:
123
126protected:
128
129public:
130 char getType() const override
131 {
132 return vf::gpu::BC_SLIP;
133 }
134
136 {
137 for (uint index : this->indices) {
138 (void)index;
139 this->normalXList.push_back(normalX);
140 this->normalYList.push_back(normalY);
141 this->normalZList.push_back(normalZ);
142 }
143 }
144
145 real getNormalx() const { return this->normalX; }
146 real getNormaly() const { return this->normalY; }
147 real getNormalz() const { return this->normalZ; }
148
149 real getNormalx(uint index) { return this->normalXList[index]; }
150 real getNormaly(uint index) { return this->normalYList[index]; }
151 real getNormalz(uint index) { return this->normalZList[index]; }
152};
153
155
157{
158public:
166
170 std::shared_ptr<GbSpatialData3D<real>> roughnessMap;
172 std::vector<real> samplingDistanceList;
173 std::vector<real> roughnessLengthList;
174 std::vector<uint> samplingIndices;
175
176protected:
183
184public:
185 char getType() const override
186 {
187 return vf::gpu::BC_STRESS;
188 }
189
191 {
192 std::fill_n(std::back_inserter(this->normalXList), this->indices.size(), normalX);
193 std::fill_n(std::back_inserter(this->normalYList), this->indices.size(), normalY);
194 std::fill_n(std::back_inserter(this->normalZList), this->indices.size(), normalZ);
195 if(roughnessMap == nullptr)
196 std::fill_n(std::back_inserter(this->roughnessLengthList), this->indices.size(), roughnessLength);
197 }
198
199 real getNormalx() const { return this->normalX; }
200 real getNormaly() const { return this->normalY; }
201 real getNormalz() const { return this->normalZ; }
202
203 real getNormalx(uint index) const { return this->normalXList[index]; }
204 real getNormaly(uint index) const { return this->normalYList[index]; }
205 real getNormalz(uint index) const { return this->normalZList[index]; }
206
207 uint getSamplingOffset() const { return this->samplingOffset; }
208 uint getSamplingIndex(uint index) const { return this->samplingIndices[index]; }
209 real getRoughnessLength() const { return this->roughnessLength; }
210 real getRoughnessLength(uint index) const { return this->roughnessLengthList[index]; }
211 real getSamplingDistance(uint index) const { return this->samplingDistanceList[index]; }
213
214 void setAdditionalIndices(const SPtr<Grid>& grid, uint index) override;
215
216};
217
219{
220public:
231
234
235protected:
246
247public:
249 {
251 if(roughnessMap)
253 else
254 std::fill_n(std::back_inserter(roughnessLengthTemperatureList), indices.size(), roughnessLengthTemperature);
255 std::fill_n(std::back_inserter(surfaceHeatFluxList), indices.size(), surfaceHeatFlux);
256 std::fill_n(std::back_inserter(surfaceTemperatureList), indices.size(), surfaceTemperature);
257 std::fill_n(std::back_inserter(heatingRateList), indices.size(), heatingRate);
258 std::fill_n(std::back_inserter(roughnessLengthTemperatureList), indices.size(), roughnessLengthTemperature);
259 }
260
262 {
263 return this->roughnessLengthTemperature;
264 }
266 {
267 return this->roughnessLengthTemperatureList[index];
268 }
270 {
271 return this->surfaceHeatFlux;
272 }
274 {
275 return this->surfaceHeatFluxList[index];
276 }
278 {
279 return this->surfaceTemperature;
280 }
282 {
283 return this->surfaceTemperatureList[index];
284 }
286 {
287 return this->heatingRate;
288 }
290 {
291 return this->heatingRateList[index];
292 }
293};
294
296
297class VelocityBoundaryCondition : public grid_generator ::BoundaryCondition
298{
299public:
304
306 std::vector<real> vxList, vyList, vzList;
307protected:
309
310public:
311 char getType() const override
312 {
313 return vf::gpu::BC_VELOCITY;
314 }
315
317 {
318 for( uint index : this->indices ) {
319 (void) index;
320 this->vxList.push_back(vx);
321 this->vyList.push_back(vy);
322 this->vzList.push_back(vz);
323 }
324 }
325
326 real getVx() const { return this->vx; }
327 real getVy() const { return this->vy; }
328 real getVz() const { return this->vz; }
329
330 real getVx(uint index) { return this->vxList[index]; }
331 real getVy(uint index) { return this->vyList[index]; }
332 real getVz(uint index) { return this->vzList[index]; }
333
334
335 void setVelocityProfile( SPtr<Grid> grid, std::function<void(real,real,real,real&,real&,real&)> velocityProfile );
336};
337
339
340
342{
343public:
348
350
353
354 std::vector<real> vxList, vyList, vzList;
355
356private:
357 GeometryBoundaryCondition(real vx = 0.0, real vy = 0.0, real vz = 0.0, real normalX = 0.0, real normalY = 0.0, real normalZ = 0.0) :
359
360public:
361 char getType() const override
362 {
363 return vf::gpu::BC_SOLID;
364 }
365
367 for( uint index = 0; index < this->indices.size(); index++ ){
368 if( this->patches[index] == patch ){
369 this->vxList[index] = vx;
370 this->vyList[index] = vy;
371 this->vzList[index] = vz;
372 }
373 }
374 }
375
377 real p1x, real p1y, real p1z,
378 real p2x, real p2y, real p2z,
379 real v, real r );
380
382 {
383 for( uint index : this->indices ) {
384 (void) index;
385 this->vxList.push_back(vx);
386 this->vyList.push_back(vy);
387 this->vzList.push_back(vz);
388 }
389 }
390
391 real getVx() const { return this->vx; }
392 real getVy() const { return this->vy; }
393 real getVz() const { return this->vz; }
394
395 real getVx(uint index) { return this->vxList[index]; }
396 real getVy(uint index) { return this->vyList[index]; }
397 real getVz(uint index) { return this->vzList[index]; }
398
399
401 {
402 for (uint index : this->indices) {
403 (void)index;
404 this->normalXList.push_back(normalX);
405 this->normalYList.push_back(normalY);
406 this->normalZList.push_back(normalZ);
407 }
408 }
409
410 real getNormalx() const { return this->normalX; }
411 real getNormaly() const { return this->normalY; }
412 real getNormalz() const { return this->normalZ; }
413
414 real getNormalx(uint index) { return this->normalXList[index]; }
415 real getNormaly(uint index) { return this->normalYList[index]; }
416 real getNormalz(uint index) { return this->normalZList[index]; }
417};
418
420{
421public:
422 static SPtr<PrecursorBoundaryCondition> make(real velocityX, real velocityY, real velocityZ)
423 {
424 return SPtr<PrecursorBoundaryCondition>(new PrecursorBoundaryCondition(velocityX, velocityY, velocityZ));
425 }
426
429 real getVelocityX() const { return velocityX; }
430 real getVelocityY() const { return velocityY; }
431 real getVelocityZ() const { return velocityZ; }
432
433private:
434 PrecursorBoundaryCondition(real vx, real vy, real vz) : velocityX(vx), velocityY(vy), velocityZ(vz) { };
435 char getType() const override
436 {
437 return vf::gpu::BC_VELOCITY;
438 }
439
440private:
441 real velocityX = 0.0;
442 real velocityY = 0.0;
443 real velocityZ = 0.0;
445};
446
448{
449public:
454
455protected:
457
458public:
459 char getType() const override
460 {
461 return vf::gpu::BC_AD;
462 }
463};
464
465
467{
468public:
473
476
477protected:
481
482public:
483 char getType() const override
484 {
485 return vf::gpu::BC_AD;
486 }
487
489
490 real getNormalX(uint index) {return this->normalXList[index];}
491 real getNormalY(uint index) {return this->normalYList[index];}
492 real getNormalZ(uint index) {return this->normalZList[index];}
493 real getGradient(uint index) {return this->gradientList[index];}
494};
495
496
498{
499public:
501 {
503 }
504
505protected:
506 ADDirichletBoundaryCondition(real BCValue, real vx, real vy, real vz) : BCvalue(BCValue), vx(vx), vy(vy), vz(vz)
507 {
508
509 }
510
511public:
512 char getType() const override
513 {
514 return vf::gpu::BC_AD;
515 }
516
518 {
519 std::fill_n(std::back_inserter(this->vxList), this->indices.size(), vx);
520 std::fill_n(std::back_inserter(this->vyList), this->indices.size(), vy);
521 std::fill_n(std::back_inserter(this->vzList), this->indices.size(), vz);
522 std::fill_n(std::back_inserter(this->BCvalueList), this->indices.size(), BCvalue);
523 }
524
525 real getBCvalue() const { return this->BCvalue; }
526 real getVx() const { return this->vx; }
527 real getVy() const { return this->vy; }
528 real getVz() const { return this->vz; }
529
530 real getBCvalue(uint index) { return this->BCvalueList[index]; }
531 real getVx(uint index) { return this->vxList[index]; }
532 real getVy(uint index) { return this->vyList[index]; }
533 real getVz(uint index) { return this->vzList[index]; }
534
535private:
536 real BCvalue, vx, vy, vz;
537 std::vector<real> BCvalueList, vxList, vyList, vzList;
538};
539
541{
542public:
547
548 // matrix indices of the neighbor node in the outflow direction (kN)
549 std::vector<uint> neighborIndices;
550
551protected:
553
554public:
555 char getType() const override
556 {
557 return vf::gpu::BC_AD;
558 }
559
560 void setAdditionalIndices(const SPtr<Grid>& grid, uint index) override;
561};
562
563
565{
566public:
571
573 std::vector<real> gradientList, vxList, vyList, vzList;
574
575protected:
580
581public:
582 char getType() const override
583 {
584 return vf::gpu::BC_AD;
585 }
586
588
589 real getBCgradient() const { return this->gradient; }
590 real getVx() const { return this->vx; }
591 real getVy() const { return this->vy; }
592 real getVz() const { return this->vz; }
593
594 real getBCgradient(uint index) { return this->gradientList[index]; }
595 real getVx(uint index) { return this->vxList[index]; }
596 real getVy(uint index) { return this->vyList[index]; }
597 real getVz(uint index) { return this->vzList[index]; }
598};
599
600}
601
602#endif
static SPtr< ADDirichletBoundaryCondition > make(real BCvalue, real vx, real vy, real vz)
ADDirichletBoundaryCondition(real BCValue, real vx, real vy, real vz)
static SPtr< ADFluxBoundaryCondition > make(real normalX, real normalY, real normalZ, real gradient)
ADFluxBoundaryCondition(real normalX, real normalY, real normalZ, real gradient)
static SPtr< ADNeumannBoundaryCondition > make(real BCvalue, real vx, real vy, real vz)
ADNeumannBoundaryCondition(real gradient, real vx, real vy, real vz)
static SPtr< ADNoFluxBoundaryCondition > make()
void setAdditionalIndices(const SPtr< Grid > &grid, uint index) override
static SPtr< ADOutflowBoundaryCondition > make()
static SPtr< GeometryBoundaryCondition > make()
void setTangentialVelocityForPatch(SPtr< Grid > grid, uint patch, real p1x, real p1y, real p1z, real p2x, real p2y, real p2z, real v, real r)
void setVelocityForPatch(uint patch, real vx, real vy, real vz)
void setReader(SPtr< TransientBCInputFileReader > newReader)
SPtr< TransientBCInputFileReader > getReader()
static SPtr< PrecursorBoundaryCondition > make(real velocityX, real velocityY, real velocityZ)
void setAdditionalIndices(const SPtr< Grid > &grid, uint index) override
static SPtr< PressureBoundaryCondition > make(real rho)
SlipBoundaryCondition(real normalX, real normalY, real normalZ)
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)
void setAdditionalIndices(const SPtr< Grid > &grid, uint index) override
real getRoughnessLength(uint index) const
StressBoundaryCondition(real normalX, real normalY, real normalZ, uint samplingOffset, real vonKarmanConstant, real roughnessLength, std::shared_ptr< GbSpatialData3D< real > > roughnessMap)
real getSamplingDistance(uint index) const
std::shared_ptr< GbSpatialData3D< real > > roughnessMap
uint getSamplingIndex(uint index) const
SurfaceLayerBoundaryCondition(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< 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)
VelocityBoundaryCondition(real vx, real vy, real vz)
static SPtr< VelocityBoundaryCondition > make(real vx, real vy, real vz)
void setVelocityProfile(SPtr< Grid > grid, std::function< void(real, real, real, real &, real &, real &)> velocityProfile)
void getCoords(SPtr< Grid > grid, std::vector< real > &x, std::vector< real > &y, std::vector< real > &z)
virtual void setAdditionalIndices(const SPtr< Grid > &, uint)
std::vector< std::vector< real > > qs
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
@ z
Definition Axis.h:44
@ x
Definition Axis.h:42
@ y
Definition Axis.h:43
SideType
Definition Side.h:63