OpenLB 1.7
Loading...
Searching...
No Matches
rtlbmBoundaryDynamics.hh
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2017 Albert Mink
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 RTLBM_BOUNDARY_DYNAMICS_HH
25#define RTLBM_BOUNDARY_DYNAMICS_HH
26
28#include "dynamics/lbm.h"
29
30namespace olb {
31
32
33
34// flat diffuse
35template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
37 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
38{
39 this->getName() = "RtlbmDiffuseBoundaryDynamics";
40}
41
42template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
44{
45 return descriptors::t<T,DESCRIPTOR>(iPop)*rho - descriptors::t<T,DESCRIPTOR>(iPop);
46}
47
48template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
50{
51 typedef DESCRIPTOR L;
52 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
53 T dirichletTemperature = MomentaF().computeRho(cell);
54 constexpr auto missing_iPop = util::subIndexOutgoing<L,direction,orientation>();
55 // compute summ of weights for all missing directions
56 T sumWeights = 0;
57 for ( int i : missing_iPop ) {
58 sumWeights += descriptors::t<T,L>(i);
59 }
60 // construct missing directions such that 0th moment equals emposed dirichletTemperature
61 for ( int i : missing_iPop ) {
62 cell[i] = descriptors::t<T,L>(i)*dirichletTemperature/sumWeights - descriptors::t<T,L>(i);
63 }
64 return {-1, -1};
65}
66
67template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
72
73template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
77
78// edge diffuse
79template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
81 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
82{
83 this->getName() = "RtlbmDiffuseEdgeBoundaryDynamics";
84}
85
86template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
88{
89 return descriptors::t<T,DESCRIPTOR>(iPop)*rho - descriptors::t<T,DESCRIPTOR>(iPop);
90}
91
92template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
94{
95 typedef DESCRIPTOR L;
96 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
97 T dirichletTemperature = MomentaF().computeRho(cell);
98 std::vector<int> missing_iPop = util::subIndexOutgoing3DonEdges<L,plane,normal1,normal2>();
99 // compute summ of weights for all missing directions
100 T sumWeights = 0;
101 for ( int i : missing_iPop ) {
102 sumWeights += descriptors::t<T,L>(i);
103 }
104 // construct missing directions such that 0th moment equals emposed dirichletTemperature
105 for ( int i : missing_iPop ) {
106 cell[i] = descriptors::t<T,L>(i)*dirichletTemperature/sumWeights - descriptors::t<T,L>(i);
107 }
108 return {-1, -1};
109}
110
111template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
116
117template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
121
122// corner diffuse
123template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
125 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
126{
127 this->getName() = "RtlbmDiffuseCornerBoundaryDynamics";
128}
129
130template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
132{
133 return descriptors::t<T,DESCRIPTOR>(iPop)*rho - descriptors::t<T,DESCRIPTOR>(iPop);
134}
135
136template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
138{
139 typedef DESCRIPTOR L;
140 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
141 T dirichletTemperature = MomentaF().computeRho(cell);
142 std::vector<int> const missing_iPop = util::subIndexOutgoing3DonCorners<L,xNormal,yNormal,zNormal>();
143 // compute summ of weights for all missing directions
144 T sumWeights = 0;
145 for ( int i : missing_iPop ) {
146 sumWeights += descriptors::t<T,L>(i);
147 }
148 // construct missing directions such that 0th moment equals emposed dirichletTemperature
149 for ( int i : missing_iPop ) {
150 cell[i] = descriptors::t<T,L>(i)*dirichletTemperature/sumWeights - descriptors::t<T,L>(i);
151 }
152 return {-1, -1};
153}
154
155template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
160
161template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
165
166
167
168
169// flat diffuse constant density
170template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
172 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
173{
174 this->getName() = "RtlbmDiffuseConstBoundaryDynamics";
175}
176
177template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
179{
180 return descriptors::t<T,DESCRIPTOR>(iPop)*rho - descriptors::t<T,DESCRIPTOR>(iPop);
181}
182
183template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
185{
186 // For direction i \in I_in define
187 // cell_i = w_i * dirichlet/sumWeights - w_i
188 // For direction i \in I_out defube
189 // cell_i = - w_i
190 // This construction yields
191 // sum_{i=0}^{q-1} cell_i == dirichlet - 1
192
193 typedef DESCRIPTOR L;
194 // shift all: cell_i = f_i - weight_i
195 for ( int iPop = 0; iPop < L::q; ++iPop ) {
196 cell[iPop] = - descriptors::t<T,L>(iPop);
197 }
198
199 constexpr auto missing_iPop = util::subIndexOutgoing<L,direction,orientation>();
200 // compute summ of weights for all missing directions
201 T sumWeights = 0;
202 for ( int i : missing_iPop ) {
203 sumWeights += descriptors::t<T,L>(i);
204 }
205 // construct missing directions such that 0th moment equals emposed dirichletTemperature
206 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
207 T dirichletTemperature = MomentaF().computeRho(cell);
208 for ( int i : missing_iPop ) {
209 cell[i] = descriptors::t<T,L>(i)*dirichletTemperature/sumWeights - descriptors::t<T,L>(i);
210 }
211 return {-1, -1};
212}
213
214template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
219
220template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
224
225
226
227// edge diffuse with constant density
228template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
230 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
231{
232 this->getName() = "RtlbmDiffuseConstEdgeBoundaryDynamics";
233}
234
235template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
237{
238 return descriptors::t<T,DESCRIPTOR>(iPop)*rho - descriptors::t<T,DESCRIPTOR>(iPop);
239}
240
241template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
243{
244 // For direction i \in I_in define
245 // cell_i = w_i * dirichlet/sumWeights - w_i
246 // For direction i \in I_out defube
247 // cell_i = - w_i
248 // This construction yields
249 // sum_{i=0}^{q-1} cell_i == dirichlet - 1
250
251 typedef DESCRIPTOR L;
252
253 // shift all: cell_i = f_i - weight_i
254 for ( int iPop = 0; iPop < L::q; ++iPop ) {
255 cell[iPop] = - descriptors::t<T,L>(iPop);
256 }
257
258 constexpr auto missing_iPop = util::subIndexOutgoing3DonEdges<L,plane,normal1,normal2>();
259 T sumWeights = 0;
260 for ( int i : missing_iPop ) {
261 sumWeights += descriptors::t<T,L>(i);
262 }
263
264 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
265 T dirichletTemperature = MomentaF().computeRho(cell);
266 for ( int i : missing_iPop ) {
267 cell[i] = descriptors::t<T,L>(i)*dirichletTemperature/sumWeights - descriptors::t<T,L>(i);
268 }
269 return {-1, -1};
270}
271
272template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
277
278template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
282
283
284
285// corner diffuse with constant density
286template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
288 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
289{
290 this->getName() = "RtlbmDiffuseConstCornerBoundaryDynamics";
291}
292
293template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
295{
296 return descriptors::t<T,DESCRIPTOR>(iPop)*rho - descriptors::t<T,DESCRIPTOR>(iPop);
297}
298
299template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
301{
302 // For direction i \in I_in define
303 // cell_i = w_i * dirichlet/sumWeights - w_i
304 // For direction i \in I_out defube
305 // cell_i = - w_i
306 // This construction yields
307 // sum_{i=0}^{q-1} cell_i == dirichlet - 1
308
309 typedef DESCRIPTOR L;
310
311 // shift all: cell_i = f_i - weight_i
312 for ( int iPop = 0; iPop < L::q; ++iPop ) {
313 cell[iPop] = - descriptors::t<T,L>(iPop);
314 }
315
316 auto missing_iPop = util::subIndexOutgoing3DonCorners<L,xNormal,yNormal,zNormal>();
317 T sumWeights = 0;
318 for ( int i : missing_iPop ) {
319 sumWeights += descriptors::t<T,L>(i);
320 }
321
322 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
323 T dirichletTemperature = MomentaF().computeRho(cell);
324 for ( int i : missing_iPop ) {
325 cell[i] = descriptors::t<T,L>(i)*dirichletTemperature/sumWeights - descriptors::t<T,L>(i);
326 }
327
328 return {-1, -1};
329}
330
331template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
336
337template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
341
342
343// directed wall
344template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
346 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
347{
348 this->getName() = "RtlbmDirectedBoundaryDynamics";
349}
350
351template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
353{
354 return rho*descriptors::t<T,DESCRIPTOR>(iPop) - descriptors::t<T,DESCRIPTOR>(iPop);
355}
356
357template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
359{
360 typedef DESCRIPTOR L;
361 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
362 T dirichletTemperature = MomentaF().computeRho(cell);
363
364 for ( int iPop = 0; iPop < L::q; ++iPop ) {
365 cell[iPop] = - descriptors::t<T,L>(iPop);
366 }
367
368 constexpr auto missingDiagonal = util::subIndexOutgoing<L,direction,orientation>();
369 for ( int i : missingDiagonal ) {
370 // compute norm of c_iPopMissing
371 // is direction axis parallel
372 if ( util::normSqr<int>({descriptors::c<L>(i,0), descriptors::c<L>(i,1), descriptors::c<L>(i,2)}) == 1 ) {
373 if ( std::is_base_of<DESCRIPTOR,descriptors::D3Q7<> >::value ) {
374 cell[i] = (1-descriptors::t<T,L>(0))*dirichletTemperature - descriptors::t<T,L>(i);
375 }
376 if ( DESCRIPTOR::template provides<descriptors::tag::RTLBM>() ) {
377 cell[i] = dirichletTemperature - descriptors::t<T,L>(i);
378 }
379 }
380 }
381 if ( std::is_base_of<DESCRIPTOR,descriptors::D3Q7<> >::value ) {
382 cell[0] = descriptors::t<T,L>(0)*dirichletTemperature - descriptors::t<T,L>(0);
383 }
384 return {-1, -1};
385}
386
387template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
392
393template<typename T, typename DESCRIPTOR, typename MOMENTA, int direction, int orientation>
397
398// directed edges
399template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
401 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
402{
403 this->getName() = "RtlbmDirectedEdgeBoundaryDynamics";
404}
405
406template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
408{
409 return rho*descriptors::t<T,DESCRIPTOR>(iPop) - descriptors::t<T,DESCRIPTOR>(iPop);
410}
411
412template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
414{
415 typedef DESCRIPTOR L;
416 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
417 T dirichletTemperature = MomentaF().computeRho(cell);
418
419 for ( int iPop = 0; iPop < L::q; ++iPop ) {
420 cell[iPop] = - descriptors::t<T,L>(iPop);
421 }
422
423 std::vector<int> const missingDiagonal = util::subIndexOutgoing3DonEdges<DESCRIPTOR,plane,normal1,normal2>();
424 for ( int i : missingDiagonal ) {
425 // compute norm of c_iPopMissing
426 // is direction axis parallel
427 if ( util::normSqr<int>({descriptors::c<L>(i,0), descriptors::c<L>(i,1), descriptors::c<L>(i,2)}) == 1 ) {
428 if ( std::is_base_of<DESCRIPTOR,descriptors::D3Q7<> >::value ) {
429 cell[i] = (1-descriptors::t<T,L>(0))*dirichletTemperature - descriptors::t<T,L>(i);
430 }
431 if ( DESCRIPTOR::template provides<descriptors::tag::RTLBM>() ) {
432 cell[i] = dirichletTemperature - descriptors::t<T,L>(i);
433 }
434 }
435 }
436 if ( std::is_base_of<DESCRIPTOR,descriptors::D3Q7<> >::value ) {
437 cell[0] = descriptors::t<T,L>(0)*dirichletTemperature - descriptors::t<T,L>(0);
438 }
439 return {-1, -1};
440}
441
442template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
447
448template<typename T, typename DESCRIPTOR, typename MOMENTA, int plane, int normal1, int normal2>
452
453
454// directed corner
455template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
457 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>()
458{
459 this->getName() = "RtlbmDirectedCornerBoundaryDynamics";
460}
461
462template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
464{
465 return rho*descriptors::t<T,DESCRIPTOR>(iPop) - descriptors::t<T,DESCRIPTOR>(iPop);
466}
467
468template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
470{
471 typedef DESCRIPTOR L;
472 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
473 T dirichletTemperature = MomentaF().computeRho(cell);
474
475 for ( int iPop = 0; iPop < L::q; ++iPop ) {
476 cell[iPop] = - descriptors::t<T,L>(iPop);
477 }
478
479 std::vector<int> const missingDiagonal = util::subIndexOutgoing3DonCorners<DESCRIPTOR,xNormal,yNormal,zNormal>();
480 for ( int i : missingDiagonal ) {
481 // compute norm of c_iPopMissing
482 // is direction axis parallel
483 if ( util::normSqr<int>({descriptors::c<L>(i,0), descriptors::c<L>(i,1), descriptors::c<L>(i,2)}) == 1 ) {
484 if ( std::is_base_of<DESCRIPTOR,descriptors::D3Q7<> >::value ) {
485 cell[i] = (1-descriptors::t<T,L>(0))*dirichletTemperature - descriptors::t<T,L>(i);
486 }
487 if ( DESCRIPTOR::template provides<descriptors::tag::RTLBM>() ) {
488 cell[i] = dirichletTemperature - descriptors::t<T,L>(i);
489 }
490 }
491 }
492 if ( std::is_base_of<DESCRIPTOR,descriptors::D3Q7<> >::value ) {
493 cell[0] = descriptors::t<T,L>(0)*dirichletTemperature - descriptors::t<T,L>(0);
494 }
495 return {-1, -1};
496}
497
498template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
503
504template<typename T, typename DESCRIPTOR, typename MOMENTA, int xNormal, int yNormal, int zNormal>
508
509
510
511
512
513
514} // namespace olb
515
516
517#endif
Highest-level interface to Cell data.
Definition cell.h:148
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for flat boundary.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
RtlbmDiffuseBoundaryDynamics(T omega_)
Constructor.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for flat boundary.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for corner.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for edges.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for corner.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for flat boundary.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
RtlbmDirectedBoundaryDynamics(T omega_)
Constructor.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for directed boundary walls.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for directed boundary walls.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override
Compute equilibrium distribution function.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step for directed boundary walls.
Top level namespace for all of OpenLB.
Return value of any collision.
Definition interface.h:43
virtual std::string getName() const
Return human-readable name.
Definition interface.h:63
typename MOMENTA::template type< DESCRIPTOR > MomentaF
Definition interface.h:299