OpenLB 1.8.1
Loading...
Searching...
No Matches
advectionDiffusionBoundaryPostProcessor3D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2006, 2016 Robin Trunk
4 * E-mail contact: info@openlb.net
5 * The most recent release of OpenLB can be downloaded at
6 * <http://www.openlb.net/>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22*/
23#ifndef ADVECTION_DIFFUSION_BOUNDARY_POST_PROCESSOR_3D_HH
24#define ADVECTION_DIFFUSION_BOUNDARY_POST_PROCESSOR_3D_HH
25
27#include "core/util.h"
28#include "dynamics/lbm.h"
29
30namespace olb {
31
33// TODO: @Fedor please write the difference of this and your zeroGradientBC here
34template<typename T, typename DESCRIPTOR>
36ConvectionBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_,
37 int discreteNormalX, int discreteNormalY, int discreteNormalZ)
38 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_)
39{
40 OLB_PRECONDITION(x0==x1 || y0==y1 || z0==z1);
41
42 this->getName() = "ConvectionBoundaryProcessor3D";
43
44 interpolationPop[0] = 0;
45 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
46 interpolationPop[iPop] = 0;
47 // find incoming iPop from material 0
48 if (descriptors::c<DESCRIPTOR>(iPop,0)*discreteNormalX + descriptors::c<DESCRIPTOR>(iPop,1)*discreteNormalY + descriptors::c<DESCRIPTOR>(iPop,2)*discreteNormalZ > 0) {
49 // check for material number of neighbours has to be one level higher
50 interpolationPop[iPop] = 1;
51 }
52 }
53}
54
55template<typename T, typename DESCRIPTOR>
57processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_,
58 int y1_, int z0_, int z1_)
59{
60 int newX0, newX1, newY0, newY1, newZ0, newZ1;
61 if ( util::intersect (
62 x0, x1, y0, y1, z0, z1,
63 x0_, x1_, y0_, y1_, z0_, z1_,
64 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
65
66 auto& pop = blockLattice.template getField<descriptors::POPULATION>();
67
68#ifdef PARALLEL_MODE_OMP
69 #pragma omp parallel for
70#endif
71 for (int iPop = 1; iPop < DESCRIPTOR::q; ++iPop) {
72 if (interpolationPop[iPop] != 0) {
73 for (int iX=newX0; iX<=newX1; ++iX) {
74 for (int iY=newY0; iY<=newY1; ++iY) {
75 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
76 const auto c = descriptors::c<DESCRIPTOR>(iPop);
77 if (blockLattice.isInside(iX+c[0],iY+c[0],iZ+c[0]) && blockLattice.isInside(iX+2*c[0],iY+2*c[0],iZ+2*c[0])) {
78 //do reflection
79 T v = 0.5 * ( pop[iPop][blockLattice.getCellId(iX+ c[0],iY+ c[1],iZ+ c[2])]
80 + pop[iPop][blockLattice.getCellId(iX+2*c[0],iY+2*c[1],iZ+2*c[2])]);
81 pop[iPop][blockLattice.getCellId(iX,iY,iZ)] = v;
82 }
83 }
84 }
85 }
86 }
87 }
88 }
89}
90
91template<typename T, typename DESCRIPTOR>
94{
95 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
96}
97
99
100template<typename T, typename DESCRIPTOR>
102ConvectionBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_,
103 int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
104 : PostProcessorGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_),
105 discreteNormalX(discreteNormalX_), discreteNormalY(discreteNormalY_),
106 discreteNormalZ(discreteNormalZ_)
107{ }
108
109template<typename T, typename DESCRIPTOR>
112{
113 return new ConvectionBoundaryProcessor3D<T,DESCRIPTOR>(this->x0, this->x1, this->y0,
114 this->y1, this->z0, this->z1,
115 discreteNormalX,
116 discreteNormalY,
117 discreteNormalZ);
118}
119
120template<typename T, typename DESCRIPTOR>
123{
124 return new ConvectionBoundaryProcessorGenerator3D<T,DESCRIPTOR>(this->x0, this->x1,
125 this->y0, this->y1, this->z0, this->z1,
126 discreteNormalX, discreteNormalY, discreteNormalZ);
127}
128
129}
130
131#endif
This class interpolates missing f_i from values near the boundary to get a more stable outflow condit...
ConvectionBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_) override
Execute post-processing step on a sublattice.
PostProcessorGenerator3D< T, DESCRIPTOR > * clone() const override
ConvectionBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
PostProcessor3D< T, DESCRIPTOR > * generate() const override
std::string & getName()
read and write access to name
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83
bool intersect(int x0, int x1, int y0, int y1, int x0_, int x1_, int y0_, int y1_, int &newX0, int &newX1, int &newY0, int &newY1)
Definition util.h:85
Top level namespace for all of OpenLB.
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46
Set of functions commonly used in LB computations – header file.