OpenLB 1.7
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/*
100 * Sets the incomming population form a solid cell in a boundary cell to zero.
101 * This way the deposition of particles at the wall can be modelled.
102 * (https://doi.org/10.1016/j.jocs.2016.03.013)
103 * */
104template<typename T, typename DESCRIPTOR>
106ZeroDistributionBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_,
107 int z1_, int discreteNormalX, int discreteNormalY, int discreteNormalZ)
108 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_)
109{
110 this->getName() = "ZeroDistributionBoundaryProcessor3D";
111 OLB_PRECONDITION(x0==x1 || y0==y1 || z0==z1);
112
113 resetPop[0] = 0;
114 for (int iPop = 1; iPop < DESCRIPTOR::q; iPop++) {
115 resetPop[iPop] = 0;
116 // find incoming iPop from material 0
117 if (descriptors::c<DESCRIPTOR>(iPop,0)*discreteNormalX + descriptors::c<DESCRIPTOR>(iPop,1)*discreteNormalY + descriptors::c<DESCRIPTOR>(iPop,2)*discreteNormalZ > 0) {
118 resetPop[iPop] = 1;
119 }
120 }
121}
122
123template<typename T, typename DESCRIPTOR>
125processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_,
126 int y0_, int y1_, int z0_, int z1_)
127{
128 int newX0, newX1, newY0, newY1, newZ0, newZ1;
129 if ( util::intersect (
130 x0, x1, y0, y1, z0, z1,
131 x0_, x1_, y0_, y1_, z0_, z1_,
132 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
133
134#ifdef PARALLEL_MODE_OMP
135 #pragma omp parallel for
136#endif
137 for (int iX=newX0; iX<=newX1; ++iX) {
138 for (int iY=newY0; iY<=newY1; ++iY) {
139 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
140 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
141 if (resetPop[iPop]!=0) {
142 blockLattice.get(iX,iY,iZ)[iPop] = -descriptors::t<T,DESCRIPTOR>(iPop);
143 }
144 }
145 }
146 }
147 }
148 }
149}
150
151template<typename T, typename DESCRIPTOR>
154{
155 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
156}
157
159
160template<typename T, typename DESCRIPTOR, typename FIELD_A, typename FIELD_B>
162ExtFieldBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_,
163 int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
164 : x0(x0_), x1(x1_), y0(y0_), y1(y1_), z0(z0_), z1(z1_),
165 discreteNormalX(discreteNormalX_), discreteNormalY(discreteNormalY_),
166 discreteNormalZ(discreteNormalZ_)
167{
168 OLB_PRECONDITION(x0==x1 || y0==y1 || z0==z1);
169 this->getName() = "ExtFieldBoundaryProcessor3D";
170 tick = true;
171}
172
173template<typename T, typename DESCRIPTOR, typename FIELD_A, typename FIELD_B>
176 int x0_, int x1_,
177 int y0_, int y1_,
178 int z0_, int z1_)
179{
180 int newX0, newX1, newY0, newY1, newZ0, newZ1;
181
182 if ( util::intersect (
183 x0, x1, y0, y1, z0, z1,
184 x0_, x1_, y0_, y1_, z0_, z1_,
185 newX0, newX1, newY0, newY1, newZ0, newZ1 ) ) {
186#ifdef PARALLEL_MODE_OMP
187 #pragma omp parallel for
188#endif
189 for (int iX=newX0; iX<=newX1; ++iX) {
190 for (int iY=newY0; iY<=newY1; ++iY) {
191 for (int iZ=newZ0; iZ<=newZ1; ++iZ) {
192 auto self = blockLattice.get(iX,iY,iZ);
193 auto neighbor = self.neighbor({discreteNormalX, discreteNormalY, discreteNormalZ});
194 if (tick) {
195 self.template setField<FIELD_A>(neighbor.template getField<FIELD_B>());
196 }
197 else {
198 self.template setField<FIELD_B>(neighbor.template getField<FIELD_A>());
199 }
200 }
201 }
202 }
203 }
204 tick = !tick;
205}
206
207template<typename T, typename DESCRIPTOR, typename FIELD_A, typename FIELD_B>
210{
211 processSubDomain(blockLattice, x0, x1, y0, y1, z0, z1);
212}
213
215
216template<typename T, typename DESCRIPTOR>
218ConvectionBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_,
219 int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
220 : PostProcessorGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_),
221 discreteNormalX(discreteNormalX_), discreteNormalY(discreteNormalY_),
222 discreteNormalZ(discreteNormalZ_)
223{ }
224
225template<typename T, typename DESCRIPTOR>
228{
229 return new ConvectionBoundaryProcessor3D<T,DESCRIPTOR>(this->x0, this->x1, this->y0,
230 this->y1, this->z0, this->z1,
231 discreteNormalX,
232 discreteNormalY,
233 discreteNormalZ);
234}
235
236template<typename T, typename DESCRIPTOR>
239{
240 return new ConvectionBoundaryProcessorGenerator3D<T,DESCRIPTOR>(this->x0, this->x1,
241 this->y0, this->y1, this->z0, this->z1,
242 discreteNormalX, discreteNormalY, discreteNormalZ);
243}
244
246
247template<typename T, typename DESCRIPTOR>
249ZeroDistributionBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_,
250 int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
251 : PostProcessorGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_),
252 discreteNormalX(discreteNormalX_), discreteNormalY(discreteNormalY_),
253 discreteNormalZ(discreteNormalZ_)
254{ }
255
256template<typename T, typename DESCRIPTOR>
259{
260 return new ZeroDistributionBoundaryProcessor3D<T,DESCRIPTOR>(this->x0, this->x1,
261 this->y0, this->y1, this->z0, this->z1,
262 discreteNormalX, discreteNormalY, discreteNormalZ);
263}
264
265template<typename T, typename DESCRIPTOR>
268{
270 this->x1, this->y0, this->y1, this->z0, this->z1,
271 discreteNormalX, discreteNormalY, discreteNormalZ);
272}
273
275
276template<typename T, typename DESCRIPTOR, typename FIELD_A, typename FIELD_B>
278ExtFieldBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_,
279 int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
280 : PostProcessorGenerator3D<T,DESCRIPTOR>(x0_, x1_, y0_, y1_, z0_, z1_),
281 discreteNormalX(discreteNormalX_),
282 discreteNormalY(discreteNormalY_),
283 discreteNormalZ(discreteNormalZ_)
284{ }
285
286template<typename T, typename DESCRIPTOR, typename FIELD_A, typename FIELD_B>
289{
290 return new ExtFieldBoundaryProcessor3D<T,DESCRIPTOR,FIELD_A,FIELD_B>(this->x0, this->x1, this->y0,
291 this->y1, this->z0, this->z1,
292 discreteNormalX, discreteNormalY, discreteNormalZ);
293}
294
295template<typename T, typename DESCRIPTOR, typename FIELD_A, typename FIELD_B>
298{
300 this->y0, this->y1, this->z0, this->z1,
301 discreteNormalX, discreteNormalY, discreteNormalZ);
302}
303
304} // namespace olb
305
306
307#endif
Platform-abstracted block lattice for external access and inter-block interaction.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.
bool isInside(LatticeR< D > latticeR) const
Return whether location is valid.
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
This class copies missing values in the external field from the neighbour in normal direction.
ExtFieldBoundaryProcessor3D(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.
ExtFieldBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
PostProcessorGenerator3D< T, DESCRIPTOR > * clone() const override
PostProcessor3D< T, DESCRIPTOR > * generate() const override
std::string & getName()
read and write access to name
This class resets some values of the distribution on the boundary that can have arbitrary values to b...
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.
ZeroDistributionBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
ZeroDistributionBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
PostProcessorGenerator3D< T, DESCRIPTOR > * clone() const override
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:89
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.