OpenLB 1.7
Loading...
Searching...
No Matches
offBoundaryPostProcessors2D.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2012 Jonas Kratzke, Mathias J. Krause
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
24#ifndef OFF_BOUNDARY_POST_PROCESSORS_2D_HH
25#define OFF_BOUNDARY_POST_PROCESSORS_2D_HH
26
28
29#include "core/util.h"
30#include "core/cell.h"
31#include "dynamics/dynamics.h"
32
33namespace olb {
34
35
36template<typename T, typename DESCRIPTOR>
38ZeroVelocityBouzidiLinearPostProcessor2D(int x_, int y_, int iPop_, T dist_)
39 : x(x_), y(y_), iPop(iPop_), dist(dist_)
40{
41 this->getName() = "ZeroVelocityBouzidiLinearPostProcessor2D";
42#ifndef QUIET
43 if (dist < 0 || dist > 1)
44 std::cout << "WARNING: Bogus distance at (" << x << "," << y << "): "
45 << dist << std::endl;
46#endif
47 typedef DESCRIPTOR L;
48 opp = descriptors::opposite<L>(iPop);
49 xN = x + descriptors::c<L>(iPop,0);
50 yN = y + descriptors::c<L>(iPop,1);
51
52 if (dist >= 0.5) {
53 xB = x - descriptors::c<L>(iPop,0);
54 yB = y - descriptors::c<L>(iPop,1);
55 q = 1/(2*dist);
56 iPop2 = opp;
57 }
58 else {
59 xB = x;
60 yB = y;
61 q = 2*dist;
62 iPop2 = iPop;
63 }
64 /*
65 std::cout << "ZeroVelocityLinear (" << x << "," << y << "," <<
66 "), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
67 "), opp: " << opp << ", bP: (" << xB << "," << yB << "," <<
68 "), dist: " << dist << ", q: " << q << std::endl;
69 */
70}
71
72template<typename T, typename DESCRIPTOR>
74processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
75{
76 if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
77 process(blockLattice);
78 }
79}
80
81template<typename T, typename DESCRIPTOR>
84{
85 blockLattice.get(x, y)[opp] = q*blockLattice.get(xN, yN)[iPop] +
86 (1-q)*blockLattice.get(xB, yB)[iPop2];
87}
88
89template<typename T, typename DESCRIPTOR>
91VelocityBouzidiLinearPostProcessor2D(int x_, int y_, int iPop_, T dist_)
92 : x(x_), y(y_), iPop(iPop_), dist(dist_)
93{
94 this->getName() = "VelocityBouzidiLinearPostProcessor2D";
95#ifndef QUIET
96 if (dist < 0 || dist > 1)
97 std::cout << "WARNING: Bogus distance at (" << x << "," << y << "," << "): "
98 << dist << std::endl;
99#endif
100 typedef DESCRIPTOR L;
101 opp = descriptors::opposite<L>(iPop);
102 xN = x + descriptors::c<L>(iPop,0);
103 yN = y + descriptors::c<L>(iPop,1);
104
105 if (dist >= 0.5) {
106 xB = x - descriptors::c<L>(iPop,0);
107 yB = y - descriptors::c<L>(iPop,1);
108 q = 1/(2*dist);
109 ufrac = q;
110 iPop2 = opp;
111 }
112 else {
113 xB = x;
114 yB = y;
115 q = 2*dist;
116 iPop2 = iPop;
117 ufrac = 1;
118 }
119 /*
120 std::cout << "VelocityLinear (" << x << "," << y << "," <<
121 "), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
122 "), opp: " << opp << ", bP: (" << xB << "," << yB << "," <<
123 "), dist: " << dist << ", q: " << q << std::endl;
124 */
125}
126
127template<typename T, typename DESCRIPTOR>
129processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
130{
131 if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
132 process(blockLattice);
133 }
134}
135
136template<typename T, typename DESCRIPTOR>
139{
140 auto cell = blockLattice.get(x, y);
141 auto cellN = blockLattice.get(xN, yN);
142 auto* dynamics = static_cast<legacy::OffDynamics<T,DESCRIPTOR>*>(cellN.getDynamics());
143 T velCoeff = ufrac*dynamics->getVelocityCoefficient(iPop);
144 dynamics->defineRho( cellN, cell.computeRho() );
145 cell[opp] = q*cellN[iPop] + (1-q)*blockLattice.get(xB, yB)[iPop2] + velCoeff;
146}
147
148template<typename T, typename DESCRIPTOR>
150ZeroVelocityBounceBackPostProcessor2D(int x_, int y_, int iPop_, T dist_)
151 : x(x_), y(y_), iPop(iPop_), dist(dist_)
152{
153 this->getName() = "ZeroVelocityBounceBackPostProcessor2D";
154 this->_priority = -1;
155#ifndef QUIET
156 if (dist < 0 || dist > 1)
157 std::cout << "WARNING: Bogus distance at (" << x << "," << y << "," << "): "
158 << dist << std::endl;
159#endif
160 typedef DESCRIPTOR L;
161 opp = descriptors::opposite<L>(iPop);
162 xN = x + descriptors::c<L>(iPop,0);
163 yN = y + descriptors::c<L>(iPop,1);
164 /*
165 std::cout << "Corner (" << x << "," << y << "," <<
166 "), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
167 "), dist: " << dist << std::endl;
168 */
169}
170
171template<typename T, typename DESCRIPTOR>
173processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
174{
175 if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
176 process(blockLattice);
177 }
178}
179
180template<typename T, typename DESCRIPTOR>
183{
184 blockLattice.get(x, y)[opp] = blockLattice.get(xN, yN)[iPop];
185}
186
187
188template<typename T, typename DESCRIPTOR>
190VelocityBounceBackPostProcessor2D(int x_, int y_, int iPop_, T dist_)
191 : x(x_), y(y_), iPop(iPop_), dist(dist_)
192{
193 this->getName() = "VelocityBounceBackPostProcessor2D";
194 this->_priority = -1;
195#ifndef QUIET
196 if (dist < 0 || dist > 1)
197 std::cout << "WARNING: Bogus distance at (" << x << "," << y << "," << "): "
198 << dist << std::endl;
199#endif
200 typedef DESCRIPTOR L;
201 opp = descriptors::opposite<L>(iPop);
202 xN = x + descriptors::c<L>(iPop,0);
203 yN = y + descriptors::c<L>(iPop,1);
204
205 /*
206 std::cout << "Corner (" << x << "," << y << "," <<
207 "), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
208 "), dist: " << dist << std::endl;
209 */
210}
211
212template<typename T, typename DESCRIPTOR>
214processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
215{
216 if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
217 process(blockLattice);
218 }
219}
220
221template<typename T, typename DESCRIPTOR>
224{
225 auto cell = blockLattice.get(x, y);
226 auto cellN = blockLattice.get(xN, yN);
227 auto* dynamics = static_cast<legacy::OffDynamics<T,DESCRIPTOR>*>(cell.getDynamics());
228 T velCoeff = dynamics->getVelocityCoefficient(iPop);
229 dynamics->defineRho( cellN, cell.computeRho() );
230 cell[opp] = cellN[iPop] + velCoeff;
231}
232
233
234template<typename T, typename DESCRIPTOR>
236AntiBounceBackPostProcessor2D(int x_, int y_, int iPop_)
237 : x(x_), y(y_), iPop(iPop_)
238{
239 typedef DESCRIPTOR L;
240 opp = descriptors::opposite<L>(iPop);
241 xN = x + descriptors::c<L>(iPop,0);
242 yN = y + descriptors::c<L>(iPop,1);
243
244 /*
245 std::cout << "Corner (" << x << "," << y << "," <<
246 "), iPop: " << iPop << ", nP: (" << xN << "," << yN << "," <<
247 "), dist: " << dist << std::endl;
248 */
249 this->getName() = "AntiBounceBackPostProcessor2D";
250}
251
252template<typename T, typename DESCRIPTOR>
254processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
255{
256 if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
257 process(blockLattice);
258 }
259}
260
261template<typename T, typename DESCRIPTOR>
264{
265 /*Dynamics<T,DESCRIPTOR>* dynamics = blockLattice.getDynamics(xN, yN);
266 T velCoeff = dynamics->getVelocityCoefficient(iPop);
267 dynamics->defineRho( blockLattice.get(xN, yN), blockLattice.get(x, y).computeRho() );*/
268 if (descriptors::c<DESCRIPTOR>(iPop,1)==0) {
269 blockLattice.get(x, y)[opp] = -blockLattice.get(xN, yN)[iPop]; // + velCoeff;
270 }
271 //std::cout << "here" << std::endl;
272}
273
274
275template<typename T, typename DESCRIPTOR>
277BoundaryStreamPostProcessor2D(int x_, int y_, const bool streamDirection[DESCRIPTOR::q])
278 : x(x_), y(y_)
279{
280 for (int iPop = 0; iPop < DESCRIPTOR::q ; ++iPop) {
281 this->_streamDirections[iPop] = streamDirection[iPop];
282 }
283 this->getName() = "BoundaryStreamPostProcessor2D";
284}
285
286template<typename T, typename DESCRIPTOR>
288processSubDomain(BlockLattice<T,DESCRIPTOR>& blockLattice, int x0_, int x1_, int y0_, int y1_)
289{
290 if (util::contained(x, y, x0_, x1_, y0_, y1_) ) {
291 process(blockLattice);
292 }
293}
294
295template<typename T, typename DESCRIPTOR>
298{
299 auto cell = blockLattice.get(x, y);
300 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
301 if (_streamDirections[iPop]) {
302 blockLattice.get(x + descriptors::c<DESCRIPTOR>(iPop,0), y + descriptors::c<DESCRIPTOR>(iPop,1))[iPop] = cell[iPop];
303 }
304 }
305}
306
307
308
309template<typename T, typename DESCRIPTOR>
311ZeroVelocityBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
312 : PostProcessorGenerator2D<T,DESCRIPTOR>(x_, x_, y_, y_),
313 x(x_), y(y_), iPop(iPop_), dist(dist_)
314{ }
315
316template<typename T, typename DESCRIPTOR>
319{
321 ( this->x, this->y, this->iPop, this->dist);
322}
323
324template<typename T, typename DESCRIPTOR>
331
332template<typename T, typename DESCRIPTOR>
334VelocityBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
335 : PostProcessorGenerator2D<T,DESCRIPTOR>(x_, x_, y_, y_),
336 x(x_), y(y_), iPop(iPop_), dist(dist_)
337{ }
338
339template<typename T, typename DESCRIPTOR>
342{
344 ( this->x, this->y, this->iPop, this->dist);
345}
346
347template<typename T, typename DESCRIPTOR>
350{
352 (this->x, this->y, this->iPop, this->dist);
353}
354
355
356template<typename T, typename DESCRIPTOR>
358AntiBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_)
359 : PostProcessorGenerator2D<T,DESCRIPTOR>(x_, x_, y_, y_),
360 x(x_), y(y_), iPop(iPop_)
361{ }
362
363template<typename T, typename DESCRIPTOR>
370
371template<typename T, typename DESCRIPTOR>
378
379template<typename T, typename DESCRIPTOR>
381BoundaryStreamPostProcessorGenerator2D(int x_, int y_, const bool streamDirections[DESCRIPTOR::q])
382 : PostProcessorGenerator2D<T,DESCRIPTOR>(x_, x_, y_, y_),
383 x(x_), y(y_)
384{
385 for (int iPop = 0; iPop < DESCRIPTOR::q ; ++iPop) {
386 this->_streamDirections[iPop] = streamDirections[iPop];
387 }
388}
389
390template<typename T, typename DESCRIPTOR>
393{
395 ( this->x, this->y, this->_streamDirections);
396}
397
398template<typename T, typename DESCRIPTOR>
401{
403 (this->x, this->y, this->_streamDirections);
404}
405
407
408template<typename T, typename DESCRIPTOR>
410ZeroVelocityBouzidiLinearPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
411 : PostProcessorGenerator2D<T,DESCRIPTOR>(x_, x_, y_, y_),
412 x(x_), y(y_), iPop(iPop_), dist(dist_)
413{ }
414
415template<typename T, typename DESCRIPTOR>
422
423template<typename T, typename DESCRIPTOR>
430
431template<typename T, typename DESCRIPTOR>
433VelocityBouzidiLinearPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
434 : PostProcessorGenerator2D<T,DESCRIPTOR>(x_, x_, y_, y_),
435 x(x_), y(y_), iPop(iPop_), dist(dist_)
436{ }
437
438template<typename T, typename DESCRIPTOR>
441{
443 ( this->x, this->y, this->iPop, this->dist);
444}
445
446template<typename T, typename DESCRIPTOR>
453
454
455} // namespace olb
456
457#endif
Definition of a LB cell – header file.
AntiBounceBackPostProcessor2D(int x_, int y_, int iPop_)
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_) override
Execute post-processing step on a sublattice.
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
PostProcessor2D< T, DESCRIPTOR > * generate() const override
Platform-abstracted block lattice for external access and inter-block interaction.
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
BoundaryStreamPostProcessor2D(int x_, int y_, const bool streamDirections[DESCRIPTOR::q])
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
BoundaryStreamPostProcessorGenerator2D(int x_, int y_, const bool _streamDirections[DESCRIPTOR::q])
PostProcessor2D< T, DESCRIPTOR > * generate() const override
Interface of 2D post-processing steps.
std::string & getName()
read and write access to name
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
VelocityBounceBackPostProcessor2D(int x_, int y_, int iPop_, T dist_)
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
PostProcessor2D< T, DESCRIPTOR > * generate() const override
VelocityBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
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_) override
Execute post-processing step on a sublattice.
VelocityBouzidiLinearPostProcessor2D(int x_, int y_, int iPop_, T dist_)
PostProcessor2D< T, DESCRIPTOR > * generate() const override
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
VelocityBouzidiLinearPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
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_) override
Execute post-processing step on a sublattice.
ZeroVelocityBounceBackPostProcessor2D(int x_, int y_, int iPop_, T dist_)
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
PostProcessor2D< T, DESCRIPTOR > * generate() const override
ZeroVelocityBounceBackPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
ZeroVelocityBouzidiLinearPostProcessor2D(int x_, int y_, int iPop_, T dist_)
void processSubDomain(BlockLattice< T, DESCRIPTOR > &blockLattice, int x0_, int x1_, int y0_, int y1_) override
Execute post-processing step on a sublattice.
PostProcessor2D< T, DESCRIPTOR > * generate() const override
PostProcessorGenerator2D< T, DESCRIPTOR > * clone() const override
ZeroVelocityBouzidiLinearPostProcessorGenerator2D(int x_, int y_, int iPop_, T dist_)
Dynamics for offLattice boundary conditions OffDynamics are basically NoLatticeDynamics with the addi...
Definition dynamics.h:145
T getVelocityCoefficient(int iPop)
Get VelocitySummand for Bouzidi-Boundary Condition.
Definition dynamics.h:449
bool contained(int x, int y, int x0, int x1, int y0, int y1)
Definition util.h:119
Top level namespace for all of OpenLB.
Set of functions commonly used in LB computations – header file.