OpenLB 1.8.1
Loading...
Searching...
No Matches
boundaryPostProcessors3D.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2006, 2007 Jonas Latt
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 * Generic collision, which modifies the particle distribution
9 * functions, implemented by Orestis Malaspinas, 2007
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public
22 * License along with this program; if not, write to the Free
23 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25*/
26
27#ifndef BOUNDARY_POST_PROCESSORS_3D_H
28#define BOUNDARY_POST_PROCESSORS_3D_H
29
30#include "core/postProcessing.h"
31
32#include "core/operator.h"
33
34namespace olb {
35
41template<typename T, typename DESCRIPTOR, int direction, int orientation>
43public:
45
46 int getPriority() const {
47 return 0;
48 }
49
50 template <concepts::DynamicCell CELL>
51 void apply(CELL& cell) any_platform;
52
53private:
54 template <int deriveDirection, typename CELL, typename V=CELL::value_t>
55 void interpolateGradients(CELL& cell, V velDeriv[DESCRIPTOR::d]) const any_platform;
56
57};
58
59
60template <typename T, typename DESCRIPTOR, int direction, int orientation>
62public:
64
66 util::populationsContributingToVelocity<DESCRIPTOR,direction,-orientation>().size()
67 > { };
68
69 int getPriority() const {
70 return 0;
71 }
72
73 template <concepts::DynamicCell CELL>
74 void initialize(CELL& cell) any_platform;
75
76 template <concepts::DynamicCell CELL>
77 void apply(CELL& cell) any_platform;
78
79};
80
81
87template <typename T, typename DESCRIPTOR, int plane, int normal1, int normal2>
89public:
91
92 int getPriority() const {
93 return 0;
94 }
95
96 template <concepts::DynamicCell CELL>
97 void apply(CELL& cell) any_platform;
98
99private:
100 template <typename CELL, typename V=CELL::value_t>
101 V getNeighborRho(CELL& cell, int step1, int step2) any_platform;
102
103 template <int deriveDirection, int orientation, typename CELL, typename V=CELL::value_t>
104 void interpolateGradients(CELL& cell, V velDeriv[DESCRIPTOR::d]) const any_platform;
105
106};
107
108
109template<typename T, typename DESCRIPTOR,
110 int xNormal, int yNormal, int zNormal>
113
114 int getPriority() const {
115 return 1;
116 }
117
118 template <concepts::DynamicCell CELL>
119 void apply(CELL& cell) any_platform;
120};
121
126template<typename T, typename DESCRIPTOR>
127class SlipBoundaryProcessor3D : public LocalPostProcessor3D<T,DESCRIPTOR> {
128public:
129 SlipBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_);
130 int extent() const override
131 {
132 return 0;
133 }
134 int extent(int whichDirection) const override
135 {
136 return 0;
137 }
138 void process(BlockLattice<T,DESCRIPTOR>& blockLattice) override;
139 void processSubDomain ( BlockLattice<T,DESCRIPTOR>& blockLattice,
140 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ ) override;
141private:
142 int reflectionPop[DESCRIPTOR::q];
143 int x0, x1, y0, y1, z0, z1;
144};
145
146
147template<typename T, typename DESCRIPTOR>
149public:
150 SlipBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_);
151 PostProcessor3D<T,DESCRIPTOR>* generate() const override;
153private:
154 int discreteNormalX;
155 int discreteNormalY;
156 int discreteNormalZ;
157};
158
163template<typename T, typename DESCRIPTOR>
165public:
166 PartialSlipBoundaryProcessor3D(T tuner_, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_);
167 int extent() const override
168 {
169 return 0;
170 }
171 int extent(int whichDirection) const override
172 {
173 return 0;
174 }
175 void process(BlockLattice<T,DESCRIPTOR>& blockLattice) override;
176 void processSubDomain ( BlockLattice<T,DESCRIPTOR>& blockLattice,
177 int x0_, int x1_, int y0_, int y1_, int z0_, int z1_ ) override;
178private:
179 int reflectionPop[DESCRIPTOR::q];
180 int x0, x1, y0, y1, z0, z1;
181 T tuner;
182};
183
184
185template<typename T, typename DESCRIPTOR>
187public:
188 PartialSlipBoundaryProcessorGenerator3D(T tuner_, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_);
189 PostProcessor3D<T,DESCRIPTOR>* generate() const override;
191private:
192 int discreteNormalX;
193 int discreteNormalY;
194 int discreteNormalZ;
195 T tuner;
196};
197
198
207template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
209public:
211
212 int getPriority() const {
213 return 0;
214 }
215
216 template <concepts::DynamicCell CELL>
217 void apply(CELL& cell) any_platform {
218
219 cell.template setField<descriptors::CHEM_POTENTIAL>(
220 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).template getField<descriptors::CHEM_POTENTIAL>());
221
222 T rhoBoundary = cell.computeRho();
223 T rhoBulk = cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).computeRho();
224
225 cell.template setField<descriptors::CHEM_POTENTIAL>(
226 cell.template getField<descriptors::CHEM_POTENTIAL>() + (rhoBulk / rhoBoundary - 1) / descriptors::invCs2<T,DESCRIPTOR>());
227
228 }
229
230};
231
232template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
234public:
236
237 int getPriority() const {
238 return 0;
239 }
240
241 template <concepts::DynamicCell CELL>
242 void apply(CELL& cell) any_platform {
243
244 cell.template setField<descriptors::CHEM_POTENTIAL>(
245 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).template getField<descriptors::CHEM_POTENTIAL>());
246
247 }
248
249};
250
251template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
253public:
255
256 int getPriority() const {
257 return 0;
258 }
259
260 template <concepts::DynamicCell CELL>
261 void apply(CELL& cell) any_platform {
262
263 T rhoBoundaryNew, rhoBoundaryOld, rhoBulk, u[3];
264
265 rhoBoundaryOld = cell.computeRho();
266
267 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).computeRhoU(rhoBulk, u);
268
269 T uPerp = 0;
270
271 Vector<T, 3> normalVec({NORMAL_X,NORMAL_Y,NORMAL_Z});
272
273 if (normalVec[2] == 0) {
274 if (normalVec[1] == 0) {
275 if (normalVec[0] < 0) {
276 uPerp = -u[0];
277 } else {
278 uPerp = u[0];
279 }
280 } else if (normalVec[0] == 0) {
281 if (normalVec[1] < 0) {
282 uPerp = -u[1];
283 } else {
284 uPerp = u[1];
285 }
286 } else {
287 uPerp = util::sqrt(u[0] * u[0] + u[1] * u[1]);
288 }
289 } else if (normalVec[1] == 0) {
290 if (normalVec[0] == 0) {
291 if (normalVec[2] < 0) {
292 uPerp = -u[2];
293 } else {
294 uPerp = u[2];
295 }
296 } else {
297 uPerp = util::sqrt(u[0] * u[0] + u[2] * u[2]);
298 }
299 } else if (normalVec[0] == 0) {
300 uPerp = util::sqrt(u[1] * u[1] + u[2] * u[2]);
301 } else {
302 uPerp = util::sqrt(u[0] * u[0] + u[1] * u[1] + u[2] * u[2]);
303 }
304
305 rhoBoundaryNew = (rhoBoundaryOld + uPerp * rhoBulk) / (1. + uPerp);
306 cell.defineRho(rhoBoundaryNew);
307
308 cell.template setField<descriptors::CHEM_POTENTIAL>(
309 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).template getField<descriptors::CHEM_POTENTIAL>());
310
311 cell.template setField<descriptors::CHEM_POTENTIAL>(
312 cell.template getField<descriptors::CHEM_POTENTIAL>() + (rhoBulk / rhoBoundaryNew - 1) / descriptors::invCs2<T,DESCRIPTOR>());
313
314 }
315
316};
317
318template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
320public:
322
323 int getPriority() const {
324 return 0;
325 }
326
327 template <concepts::DynamicCell CELL>
328 void apply(CELL& cell) any_platform {
329
330 T rhoBoundaryNew, rhoBoundaryOld, rhoBulk, u[3];
331
332 rhoBoundaryOld = cell.computeRho();
333
334 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).computeRhoU(rhoBulk, u);
335
336 T uPerp = 0;
337
338 Vector<T, 3> normalVec({NORMAL_X,NORMAL_Y,NORMAL_Z});
339
340 if (normalVec[2] == 0) {
341 if (normalVec[1] == 0) {
342 if (normalVec[0] < 0) {
343 uPerp = -u[0];
344 } else {
345 uPerp = u[0];
346 }
347 } else if (normalVec[0] == 0) {
348 if (normalVec[1] < 0) {
349 uPerp = -u[1];
350 } else {
351 uPerp = u[1];
352 }
353 } else {
354 uPerp = util::sqrt(u[0] * u[0] + u[1] * u[1]);
355 }
356 } else if (normalVec[1] == 0) {
357 if (normalVec[0] == 0) {
358 if (normalVec[2] < 0) {
359 uPerp = -u[2];
360 } else {
361 uPerp = u[2];
362 }
363 } else {
364 uPerp = util::sqrt(u[0] * u[0] + u[2] * u[2]);
365 }
366 } else if (normalVec[0] == 0) {
367 uPerp = util::sqrt(u[1] * u[1] + u[2] * u[2]);
368 } else {
369 uPerp = util::sqrt(u[0] * u[0] + u[1] * u[1] + u[2] * u[2]);
370 }
371
372 rhoBoundaryNew = (rhoBoundaryOld + uPerp * rhoBulk) / (1. + uPerp);
373 cell.defineRho(rhoBoundaryNew);
374
375 cell.template setField<descriptors::CHEM_POTENTIAL>(
376 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).template getField<descriptors::CHEM_POTENTIAL>());
377
378 }
379
380};
381
382template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
384public:
386
387 int getPriority() const {
388 return 0;
389 }
390
391 template <concepts::DynamicCell CELL>
392 void apply(CELL& cell) any_platform;
393
394};
395
396template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
398public:
400
401 int getPriority() const {
402 return 0;
403 }
404
405 template <concepts::DynamicCell CELL>
406 void apply(CELL& cell) any_platform;
407
408};
409
410
415template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
417public:
419
421
422 int getPriority() const {
423 return 0;
424 }
425
426 template <concepts::DynamicCell CELL, typename PARAMETERS>
427 void apply(CELL& cell, PARAMETERS& parameters) any_platform;
428
429};
430
431template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
433public:
436
437 int getPriority() const {
438 return 0;
439 }
440
441 template <concepts::DynamicCell CELL, typename PARAMETERS>
442 void apply(CELL& cell, PARAMETERS& parameters) any_platform {
443
444 auto addend = parameters.template get<descriptors::ADDEND>();
445
446 T rhoBulk = cell.neighbor({-NORMAL_X, -NORMAL_Y, -NORMAL_Z}).computeRho();
447 T rhoTmp = 0.;
448
449 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
450 rhoTmp += cell[iPop];
451 }
452
453 T rhoBoundary = rhoBulk + addend;
454 rhoBoundary -= rhoTmp;
455
456 cell[0] = rhoBoundary - 1.;
457
458 cell.template setField<descriptors::CHEM_POTENTIAL>(
459 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).template getField<descriptors::CHEM_POTENTIAL>());
460
461 cell.template setField<descriptors::CHEM_POTENTIAL>(
462 cell.template getField<descriptors::CHEM_POTENTIAL>() + (rhoBulk / rhoBoundary - 1) / descriptors::invCs2<T,DESCRIPTOR>());
463
464 }
465
466};
467
468template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
470public:
473
474 int getPriority() const {
475 return 0;
476 }
477
478 template <concepts::DynamicCell CELL, typename PARAMETERS>
479 void apply(CELL& cell, PARAMETERS& parameters) any_platform {
480
481 auto addend = parameters.template get<descriptors::ADDEND>();
482
483 T rhoBulk = cell.neighbor({-NORMAL_X, -NORMAL_Y, -NORMAL_Z}).computeRho();
484 T rhoTmp = 0.;
485
486 for (int iPop = 1; iPop < DESCRIPTOR::q ; ++iPop) {
487 rhoTmp += cell[iPop];
488 }
489
490 T rhoBoundary = rhoBulk + addend;
491 rhoBoundary -= rhoTmp;
492
493 cell[0] = rhoBoundary - 1.;
494
495 cell.template setField<descriptors::CHEM_POTENTIAL>(
496 cell.neighbor({-NORMAL_X,-NORMAL_Y,-NORMAL_Z}).template getField<descriptors::CHEM_POTENTIAL>());
497
498 }
499
500};
501
505template<typename T, typename DESCRIPTOR, int NORMAL_X, int NORMAL_Y, int NORMAL_Z>
507public:
509
510 int getPriority() const {
511 return 0;
512 }
513
514 template <concepts::DynamicCell CELL>
515 void apply(CELL& cell) any_platform;
516};
517
518
519}
520
521#endif
PostProcessor for the density / velocity outflow boundaries in the free energy model.
void apply(CELL &cell, PARAMETERS &parameters) any_platform
void apply(CELL &cell, PARAMETERS &parameters) any_platform
PostProcessor for the wetting boundary condition in the free energy model.
meta::list< olb::descriptors::ADDEND > parameters
static constexpr OperatorScope scope
void apply(CELL &cell, PARAMETERS &parameters) any_platform
This class computes the skordos BC on a convex edge wall in 3D but with a limited number of terms add...
static constexpr OperatorScope scope
This class computes a partial slip BC in 3D.
int extent() const override
Extent of application area (0 for purely local operations)
PartialSlipBoundaryProcessor3D(T tuner_, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
int extent(int whichDirection) const override
Extent of application area along a direction (0 or 1)
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.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
PartialSlipBoundaryProcessorGenerator3D(T tuner_, int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
PostProcessor3D< T, DESCRIPTOR > * generate() const override
PostProcessorGenerator3D< T, DESCRIPTOR > * clone() const override
This class computes the skordos BC on a plane wall in 3D but with a limited number of terms added to ...
static constexpr OperatorScope scope
void apply(CELL &cell) any_platform
This class computes a slip BC in 3D.
int extent(int whichDirection) const override
Extent of application area along a direction (0 or 1)
int extent() const override
Extent of application area (0 for purely local operations)
SlipBoundaryProcessor3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
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.
void process(BlockLattice< T, DESCRIPTOR > &blockLattice) override
Execute post-processing step.
PostProcessorGenerator3D< T, DESCRIPTOR > * clone() const override
SlipBoundaryProcessorGenerator3D(int x0_, int x1_, int y0_, int y1_, int z0_, int z1_, int discreteNormalX_, int discreteNormalY_, int discreteNormalZ_)
PostProcessor3D< T, DESCRIPTOR > * generate() const override
Plain old scalar vector.
constexpr T invCs2() any_platform
Definition functions.h:107
Expr sqrt(Expr x)
Definition expr.cpp:225
Top level namespace for all of OpenLB.
OperatorScope
Block-wide operator application scopes.
@ PerCell
Per-cell application, i.e. OPERATOR::apply is passed a CELL concept implementation.
@ PerCellWithParameters
Per-cell application with parameters, i.e. OPERATOR::apply is passed a CELL concept implementation an...
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77
Interface for post-processing steps – header file.
PostProcessors for the chemical potential boundary condition in the free energy model.
static constexpr OperatorScope scope
void apply(CELL &cell) any_platform
void apply(CELL &cell) any_platform
static constexpr OperatorScope scope
Base of a field whose size is defined by [C_0,C_1,C_2]^T * [1,D,Q].
Definition fields.h:52
Plain wrapper for list of types.
Definition meta.h:276