OpenLB 1.8.1
Loading...
Searching...
No Matches
advectionDiffusionBoundaries.h
Go to the documentation of this file.
1/* This file is part of the OpenLB library
2 *
3 * Copyright (C) 2008 Orestis Malaspinas, Andrea Parmigiani
4 * 2022 Nando Suntoyo, Adrian Kummerlaender, Shota Ito
5 * E-mail contact: info@openlb.net
6 * The most recent release of OpenLB can be downloaded at
7 * <http://www.openlb.net/>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public
20 * License along with this program; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
23*/
24
25#ifndef ADVECTION_DIFFUSION_BOUNDARIES_H
26#define ADVECTION_DIFFUSION_BOUNDARIES_H
27
30#include "dynamics/dynamics.h"
31
32namespace olb {
33
34//===================================================================================
35//================= AdvectionDiffusionDynamcis on Flat Boundaries =========
36//===================================================================================
37// D2Q5/D3Q7: moment-based BC (see ref. doi:10.1504/PCFD.2016.077296)
38// D2Q9/D3Q19: non-equilibrium bounce back method (see ref. doi:10.1007/978-3-319-44649-3)
39template<typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int direction, int orientation>
40struct AdvectionDiffusionBoundariesDynamics final : public dynamics::CustomCollision<T,DESCRIPTOR,MOMENTA> {
41 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
42 using EquilibriumF = typename DYNAMICS::template exchange_momenta<MOMENTA>::EquilibriumF;
43
44 using parameters = typename DYNAMICS::parameters;
45
46 template <typename NEW_T>
48 NEW_T, DESCRIPTOR,
49 typename DYNAMICS::template exchange_value_type<NEW_T>,
50 MOMENTA,
51 direction, orientation
52 >;
53
54 template <typename M>
56
57 std::type_index id() override {
59 };
60
62 return block.template getData<OperatorParameters<AdvectionDiffusionBoundariesDynamics>>();
63 }
64
65 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
67 V dirichletTemperature = MomentaF().computeRho(cell);
68
69 // Placeholder - the index calculation of this section can and should be done at compile time
70 constexpr auto unknownIndices = util::subIndexOutgoing<DESCRIPTOR, direction, orientation>();
72
73 if constexpr ((DESCRIPTOR::d == 3 && DESCRIPTOR::q == 7)||(DESCRIPTOR::d == 2 && DESCRIPTOR::q == 5)) {
74 static_assert(unknownIndices.size() == 1 && knownIndices.size() == DESCRIPTOR::q - 1,
75 "More than one population missing");
76 V sum = V{0};
77 for (unsigned iPop : knownIndices) {
78 sum += cell[iPop];
79 }
80
81 // on cell there are non-shifted values -> temperature has to be changed
82 V difference = dirichletTemperature - V{1} - sum;
83 cell[unknownIndices[0]] = difference;
84 return typename DYNAMICS::template exchange_momenta<MOMENTA>::CollisionO().apply(cell, parameters);
85 }
86 else {
87 auto u = cell.template getField<descriptors::VELOCITY>();
88 // part for q=19 copied from AdvectionDiffusionEdgesDynamics.collide()
89 // but here just all missing directions, even at border of inlet area
90 // has to be checked!
91 for (unsigned iPop : unknownIndices) {
92 cell[iPop] =
93 equilibrium<DESCRIPTOR>::firstOrder(iPop, dirichletTemperature, u)
97 dirichletTemperature, u));
98 }
99 return {-1,-1};
100 }
101 };
102
103 void computeEquilibrium(ConstCell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override {
104 for ( int iPop = 0; iPop < DESCRIPTOR::q; iPop++ ) {
105 fEq[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, rho, u);
106 }
107 };
108
109 std::string getName() const override {
110 return "AdvectionDiffusionBoundariesDynamics";
111 };
112
113};
114
115template <typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int...ARGS>
117AdvectionDiffusionBoundariesDynamics< T, DESCRIPTOR, DYNAMICS, MOMENTA, ARGS...>
118>;
119
120//===================================================================================
121//================= AdvectionDiffusionDynamcis On Edges =========
122//===================================================================================
123// non-equilibrium bounce back method (see ref. doi:10.1007/978-3-319-44649-3)
124template<typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int plane, int normal1, int normal2>
125class AdvectionDiffusionEdgesDynamics final : public dynamics::CustomCollision<T,DESCRIPTOR,MOMENTA> {
126public:
127 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
128 using EquilibriumF = typename DYNAMICS::template exchange_momenta<MOMENTA>::EquilibriumF;
129
130 using parameters = typename DYNAMICS::parameters;
131
132 template <typename NEW_T>
134 NEW_T, DESCRIPTOR,
135 typename DYNAMICS::template exchange_value_type<NEW_T>,
136 MOMENTA,
137 plane, normal1, normal2
138 >;
139
140 template <typename M>
142
143 std::type_index id() override {
144 return typeid(AdvectionDiffusionEdgesDynamics);
145 };
146
148 return block.template getData<OperatorParameters<AdvectionDiffusionEdgesDynamics>>();
149 }
150
151 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
153 V temperature = MomentaF().computeRho(cell);
154 auto u = cell.template getField<descriptors::VELOCITY>();
155 // I need to get Missing information on the corners !!!!
157 // here I know all missing and non missing f_i
158
159 // The collision procedure for D2Q5 and D3Q7 lattice is the same ...
160 // Given the rule f_i_neq = -f_opposite(i)_neq
161 // I have the right number of equations for the number of unknowns using these lattices
162
163 for (unsigned iPop : unknownIndexes) {
164 cell[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, temperature, u)
167 temperature,
168 u));
169 }
170
171 // Once all the f_i are known, I can call the collision for the Regularized Model.
172 return typename DYNAMICS::template exchange_momenta<MOMENTA>::CollisionO().apply(cell, parameters);
173 };
174
175 void computeEquilibrium(ConstCell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override {
176 for ( int iPop = 0; iPop < DESCRIPTOR::q; iPop++ ) {
177 fEq[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, rho, u);
178 }
179 };
180
181 std::string getName() const override {
182 return "AdvectionDiffusionEdgesDynamics";
183 };
184};
185
186template <typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int...ARGS>
188AdvectionDiffusionEdgesDynamics< T, DESCRIPTOR, DYNAMICS, MOMENTA, ARGS...>
189>;
190
191//===================================================================================
192//================= AdvectionDiffusionDynamics on Corners for 2D Boundaries =========
193//===================================================================================
194// non-equilibrium bounce back method (see ref. doi:10.1007/978-3-319-44649-3)
195template<typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int xNormal, int yNormal>
196struct AdvectionDiffusionCornerDynamics2D final : public dynamics::CustomCollision<T,DESCRIPTOR,MOMENTA> {
197 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
198 using EquilibriumF = typename DYNAMICS::template exchange_momenta<MOMENTA>::EquilibriumF;
199
200 using parameters = typename DYNAMICS::parameters;
201
202 template <typename NEW_T>
204 NEW_T, DESCRIPTOR,
205 typename DYNAMICS::template exchange_value_type<NEW_T>,
206 MOMENTA,
207 xNormal, yNormal
208 >;
209
210 template <typename M>
212
213 std::type_index id() override {
215 };
216
218 return block.template getData<OperatorParameters<AdvectionDiffusionCornerDynamics2D>>();
219 }
220
221 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
223 V temperature = MomentaF().computeRho(cell);
224 auto u = cell.template getField<descriptors::VELOCITY>();
225 // I need to get Missing information on the corners !!!!
227 // here I know all missing and non missing f_i
228
229 // The collision procedure for D2Q5 and D3Q7 lattice is the same ...
230 // Given the rule f_i_neq = -f_opposite(i)_neq
231 // I have the right number of equations for the number of unknowns using these lattices
232
233 for (unsigned iPop : unknownIndexes) {
234 cell[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, temperature, u)
237 temperature,
238 u));
239 }
240
241 // Once all the f_i are known, I can call the collision for the Regularized Model.
242 return typename DYNAMICS::CollisionO().apply(cell, parameters);
243 };
244
245 void computeEquilibrium(ConstCell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override {
246 for ( int iPop = 0; iPop < DESCRIPTOR::q; iPop++ ) {
247 fEq[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, rho, u);
248 }
249 };
250
251 std::string getName() const override {
252 return "AdvectionDiffusionCornerDynamics2D";
253 };
254
255};
256
257template<typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int... NORMAL>
259 AdvectionDiffusionCornerDynamics2D<T, DESCRIPTOR, DYNAMICS, MOMENTA, NORMAL... >
260>;
261
262//===================================================================================
263//================= AdvectionDiffusionDynamics on Corners for 3D Boundaries =========
264//===================================================================================
265// non-equilibrium bounce back method (see ref. doi:10.1007/978-3-319-44649-3)
266template<typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int xNormal, int yNormal, int zNormal>
267struct AdvectionDiffusionCornerDynamics3D final : public dynamics::CustomCollision<T,DESCRIPTOR,MOMENTA> {
268 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
269 using EquilibriumF = typename DYNAMICS::template exchange_momenta<MOMENTA>::EquilibriumF;
270
271 using parameters = typename DYNAMICS::parameters;
272
273 template <typename NEW_T>
275 NEW_T, DESCRIPTOR,
276 typename DYNAMICS::template exchange_value_type<NEW_T>,
277 MOMENTA,
278 xNormal, yNormal, zNormal
279 >;
280
281 template <typename M>
283
284 std::type_index id() override {
286 };
287
289 return block.template getData<OperatorParameters<AdvectionDiffusionCornerDynamics3D>>();
290 }
291
292 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
294 V temperature = MomentaF().computeRho(cell);
295 auto u = cell.template getField<descriptors::VELOCITY>();
296 // I need to get Missing information on the corners !!!!
298 // here I know all missing and non missing f_i
299
300 // The collision procedure for D2Q5 and D3Q7 lattice is the same ...
301 // Given the rule f_i_neq = -f_opposite(i)_neq
302 // I have the right number of equations for the number of unknowns using these lattices
303
304 for (unsigned iPop : unknownIndexes) {
305 cell[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, temperature, u)
308 temperature,
309 u));
310 }
311
312 // Once all the f_i are known, I can call the collision for the Regularized Model.
313 return typename DYNAMICS::template exchange_momenta<MOMENTA>::CollisionO().apply(cell, parameters);
314 };
315
316 void computeEquilibrium(ConstCell<T,DESCRIPTOR>& cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override {
317 for ( int iPop = 0; iPop < DESCRIPTOR::q; iPop++ ) {
318 fEq[iPop] = equilibrium<DESCRIPTOR>::firstOrder(iPop, rho, u);
319 }
320 };
321
322 std::string getName() const override {
323 return "AdvectionDiffusionCornerDynamics3D";
324 };
325
326};
327
328template<typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA, int... NORMAL>
330 AdvectionDiffusionCornerDynamics3D<T, DESCRIPTOR, DYNAMICS, MOMENTA, NORMAL... >
331>;
332
333
334} // namespace olb
335
336#endif
A collection of dynamics classes (e.g.
std::string getName() const override
Return human-readable name.
typename DYNAMICS::template exchange_momenta< MOMENTA >::EquilibriumF EquilibriumF
typename MOMENTA::template type< DESCRIPTOR > MomentaF
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
CellStatistic< V > collide(CELL &cell, PARAMETERS &parameters) any_platform
void computeEquilibrium(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override
Return iPop equilibrium for given first and second momenta.
std::type_index id() override
Expose unique type-identifier for RTTI.
Highest-level interface to read-only Cell data.
Definition interface.h:36
constexpr int opposite(unsigned iPop) any_platform
Definition functions.h:95
constexpr auto subIndexOutgoingRemaining() any_platform
Definition util.h:278
constexpr auto subIndexOutgoing2DonCorners() any_platform
Definition util.h:316
constexpr auto subIndexOutgoing3DonEdges() any_platform
Definition util.h:292
constexpr auto subIndexOutgoing() any_platform
Compute opposites of wall-incoming population indices.
Definition util.h:262
constexpr auto subIndexOutgoing3DonCorners() any_platform
Definition util.h:327
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:77
Dynamic access interface for FIELD-valued parameters.
typename DYNAMICS::template exchange_momenta< MOMENTA >::EquilibriumF EquilibriumF
std::string getName() const override
Return human-readable name.
std::type_index id() override
Expose unique type-identifier for RTTI.
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
CellStatistic< V > collide(CELL &cell, PARAMETERS &parameters) any_platform
void computeEquilibrium(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override
Return iPop equilibrium for given first and second momenta.
typename MOMENTA::template type< DESCRIPTOR > MomentaF
typename DYNAMICS::template exchange_momenta< MOMENTA >::EquilibriumF EquilibriumF
typename MOMENTA::template type< DESCRIPTOR > MomentaF
CellStatistic< V > collide(CELL &cell, PARAMETERS &parameters) any_platform
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
void computeEquilibrium(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override
Return iPop equilibrium for given first and second momenta.
std::type_index id() override
Expose unique type-identifier for RTTI.
std::string getName() const override
Return human-readable name.
typename DYNAMICS::template exchange_momenta< MOMENTA >::EquilibriumF EquilibriumF
std::string getName() const override
Return human-readable name.
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
typename MOMENTA::template type< DESCRIPTOR > MomentaF
std::type_index id() override
Expose unique type-identifier for RTTI.
void computeEquilibrium(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override
Return iPop equilibrium for given first and second momenta.
CellStatistic< V > collide(CELL &cell, PARAMETERS &parameters) any_platform
Return value of any collision.
Definition interface.h:45
Set PARAMETER of DYNAMICS from CELL (for CustomCollision-based DYNAMICS)
Definition modifiers.h:48
static V firstOrder(int iPop, const RHO &rho, const U &u) any_platform
Computation of equilibrium distribution, first order in u.
Definition lbm.h:37