OpenLB 1.7
Loading...
Searching...
No Matches
dynamics.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, Mathias J. Krause
4 * 2021 Adrian Kummerlaender
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 DYNAMICS_DYNAMICS_H
26#define DYNAMICS_DYNAMICS_H
27
28#include "interface.h"
29
30#include "core/util.h"
31#include "core/postProcessing.h"
33#include "latticeDescriptors.h"
34
35#include "momenta/interface.h"
36#include "momenta/aliases.h"
37
38#include "collision.h"
39#include "equilibrium.h"
40#include "forcing.h"
41
42#include "collisionModifiers.h"
43
44namespace olb {
45
47template <typename T, typename DESCRIPTOR>
49 T, DESCRIPTOR,
50 // Return 1 for the 0th moment, 0 for all others
56 >,
59>;
60
62template <typename T, typename DESCRIPTOR>
64 T, DESCRIPTOR,
68>;
69
71template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
73 T, DESCRIPTOR,
74 MOMENTA,
75 std::conditional_t< (DESCRIPTOR::d == 3 && DESCRIPTOR::q == 7)
76 || (DESCRIPTOR::d == 2 && DESCRIPTOR::q == 5),
80>;
81
83template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
85 T, DESCRIPTOR,
86 MOMENTA,
89>;
90
92
97template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
99 T, DESCRIPTOR,
100 MOMENTA,
104>;
105
106// BGK collision step with external force (Guo) for multiple component lattices
107template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::ExternalVelocityTuple>
109 T, DESCRIPTOR,
110 MOMENTA,
114>;
115
117
122template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
124 T, DESCRIPTOR,
125 MOMENTA,
129>;
130
132
137template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
139 T, DESCRIPTOR,
140 MOMENTA,
144>;
145
147template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
149
151
154template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
156 T, DESCRIPTOR,
157 MOMENTA,
161>;
162
164template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
166 T, DESCRIPTOR,
167 MOMENTA,
171>;
172
174
179template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
181 T, DESCRIPTOR,
182 MOMENTA,
185>;
186
188
192template <typename T, typename DESCRIPTOR, typename DYNAMICS, typename MOMENTA>
193class CombinedRLBdynamics final : public dynamics::CustomCollision<T,DESCRIPTOR,MOMENTA> {
194private:
195 // Use same MOMENTA in combined and nested (boundary) dynamics
196 using CORRECTED_DYNAMICS = typename DYNAMICS::template exchange_momenta<MOMENTA>;
197
198public:
199 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
200
201 using parameters = typename CORRECTED_DYNAMICS::parameters;
202
203 template <typename M>
205
206 std::type_index id() override {
207 return typeid(CombinedRLBdynamics);
208 }
209
211 return block.template getData<OperatorParameters<CombinedRLBdynamics>>();
212 }
213
214 template <CONCEPT(MinimalCell) CELL, typename PARAMETERS, typename V=typename CELL::value_t>
216 V rho, u[DESCRIPTOR::d], pi[util::TensorVal<DESCRIPTOR>::n];
217 MomentaF().computeAllMomenta(cell,rho,u,pi);
218
219 for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
220 cell[iPop] = typename CORRECTED_DYNAMICS::EquilibriumF().compute(iPop, rho, u)
221 + equilibrium<DESCRIPTOR>::template fromPiToFneq<V>(iPop, pi);
222 }
223
224 return typename CORRECTED_DYNAMICS::CollisionO().apply(cell, parameters);
225 };
226
227 T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override any_platform {
228 return typename CORRECTED_DYNAMICS::EquilibriumF().compute(iPop, rho, u);
229 };
230
231 std::string getName() const override {
232 return "CombinedRLBdynamics<" + CORRECTED_DYNAMICS().getName() + ">";
233 };
234
235};
236
238template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
240 T, DESCRIPTOR,
241 MOMENTA,
244>;
245
247
250template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
252 T, DESCRIPTOR,
253 MOMENTA,
257>;
258
260
265template <typename T, typename DESCRIPTOR>
267 T, DESCRIPTOR,
273 >,
276>;
277
279
284template <typename T, typename DESCRIPTOR>
286 T, DESCRIPTOR,
292 >,
295>;
296
298
303template <typename T, typename DESCRIPTOR>
305 T, DESCRIPTOR,
309>;
310
315template <typename T, typename DESCRIPTOR>
317 T, DESCRIPTOR,
321>;
322
324template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::PoissonTuple>
326 T, DESCRIPTOR,
327 MOMENTA,
330>;
331
333template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::P1Tuple>
335 T, DESCRIPTOR,
336 MOMENTA,
339>;
340
342template <typename T, typename DESCRIPTOR>
344 T, DESCRIPTOR,
345 momenta::Tuple<
346 momenta::BulkDensity,
347 momenta::ZeroMomentum,
348 momenta::ZeroStress,
349 momenta::DefineSeparately
350 >
351> {
353
354 std::type_index id() override {
355 return typeid(ZeroDistributionDynamics);
356 };
357
359 return block.template getData<OperatorParameters<ZeroDistributionDynamics>>();
360 }
361
362 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
364 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
365 cell[iPop] = -descriptors::t<T,DESCRIPTOR>(iPop);
366 }
367 return {-1, -1};
368 };
369
370 T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const any_platform override {
371 return 0;
372 };
373
374 std::string getName() const override {
375 return "ZeroDistributionDynamics";
376 };
377};
378
379template <typename T, typename DESCRIPTOR, typename MOMENTA>
381 T, DESCRIPTOR,
382 MOMENTA,
385>;
386
388
392template <typename T, typename DESCRIPTOR>
394 T, DESCRIPTOR,
398>;
399
401
405template <typename T, typename DESCRIPTOR>
407 T, DESCRIPTOR,
411>;
412
414
418template <typename T, typename DESCRIPTOR, typename MOMENTA=momenta::BulkTuple>
419struct ForcedVANSBGKdynamics final : public dynamics::CustomCollision<T,DESCRIPTOR,MOMENTA> {
420 using MomentaF = typename MOMENTA::template type<DESCRIPTOR>;
421
423
424 std::type_index id() override {
425 return typeid(ForcedVANSBGKdynamics);
426 }
427
429 return block.template getData<OperatorParameters<ForcedVANSBGKdynamics>>();
430 }
431
432 void computeU(ConstCell<T,DESCRIPTOR>& cell, T u[DESCRIPTOR::d]) const override {
433 T rho;
434 T porosity = cell.template getField<descriptors::POROSITY>();
435 MomentaF().computeVANSRhoU(cell, rho, u, &porosity);
436 auto force = cell.template getFieldPointer<descriptors::FORCE>();
437 for (int iVel=0; iVel < DESCRIPTOR::d; ++iVel) {
438 u[iVel] += force[iVel] * T{0.5};
439 }
440 }
441
442 void computeRhoU(ConstCell<T,DESCRIPTOR>& cell, T& rho, T u[DESCRIPTOR::d]) const override {
443 T porosity = cell.template getField<descriptors::POROSITY>();
444 MomentaF().computeVANSRhoU(cell, rho, u, &porosity);
445 auto force = cell.template getFieldPointer<descriptors::FORCE>();
446 for (int iVel=0; iVel<DESCRIPTOR::d; ++iVel) {
447 u[iVel] += force[iVel] * T{0.5};
448 }
449 }
450
451 template <typename CELL, typename PARAMETERS, typename V=typename CELL::value_t>
452 CellStatistic<V> apply(CELL& cell, PARAMETERS& parameters) {
453 V rho, u[DESCRIPTOR::d];
454 V porosity = cell.template getField<descriptors::POROSITY>();
455 MomentaF().computeVANSRhoU(cell, rho, u, &porosity);
456 auto force = cell.template getFieldPointer<descriptors::FORCE>();
457 for (int iVel=0; iVel < DESCRIPTOR::d; ++iVel) {
458 u[iVel] += force[iVel] * V{0.5};
459 u[iVel] /= porosity;
460 }
461 rho *= porosity;
462 const auto omega = parameters.template get<descriptors::OMEGA>();
463 V uSqr = lbm<DESCRIPTOR>::bgkCollision(cell, rho, u, omega);
464 lbm<DESCRIPTOR>::addExternalForce(cell, u, omega, rho);
465 return {rho / porosity, uSqr * porosity * porosity};
466 }
467
468};
469
470}
471
472#endif
473
474#include "legacy/dynamics.h"
Platform-abstracted block lattice for external access and inter-block interaction.
Regularized BGK collision followed by any other Dynamics.
Definition dynamics.h:193
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
Definition dynamics.h:210
std::string getName() const override
Return human-readable name.
Definition dynamics.h:231
typename MOMENTA::template type< DESCRIPTOR > MomentaF
Definition dynamics.h:199
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override any_platform
Return iPop equilibrium for given first and second momenta.
Definition dynamics.h:227
CellStatistic< V > apply(CELL &cell, PARAMETERS &parameters) any_platform
Definition dynamics.h:215
typename CORRECTED_DYNAMICS::parameters parameters
Definition dynamics.h:201
std::type_index id() override
Expose unique type-identifier for RTTI.
Definition dynamics.h:206
Highest-level interface to read-only Cell data.
Definition cell.h:53
Dynamics combination rule implementing the forcing scheme by Shan and Chen.
Definition forcing.h:188
Instantiation of Momenta tuples which define the computation and definition of momenta in a specific ...
Descriptor for all types of 2D and 3D lattices.
Interface for post-processing steps – header file.
File provides a generic interface for the computation and definition of momenta (density,...
Tuple< ZeroDensity, ZeroMomentum, ZeroStress, DefineSeparately > None
Definition aliases.h:217
Tuple< FixedDensity, FixedVelocityMomentumGeneric, ZeroStress, DefineSeparately > EquilibriumBoundaryTuple
Velocity and density are stored in external fields.
Definition aliases.h:100
Tuple< BulkDensity, FixedVelocityMomentum, BulkStress, DefineUSeparately > ExternalVelocityTuple
The Velocity is stored in descriptors::VELOCITY (and computed e.g.
Definition aliases.h:50
Top level namespace for all of OpenLB.
#define any_platform
Define preprocessor macros for device-side functions, constant storage.
Definition platform.h:78
Interface for post-processing steps – header file.
Dynamic access interface for FIELD-valued parameters.
Return value of any collision.
Definition interface.h:43
VANS BGK collision step with external force.
Definition dynamics.h:419
CellStatistic< V > apply(CELL &cell, PARAMETERS &parameters)
Definition dynamics.h:452
void computeU(ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
Compute fluid velocity.
Definition dynamics.h:432
typename MOMENTA::template type< DESCRIPTOR > MomentaF
Definition dynamics.h:420
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
Definition dynamics.h:428
std::type_index id() override
Expose unique type-identifier for RTTI.
Definition dynamics.h:424
void computeRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
Compute fluid velocity and particle density.
Definition dynamics.h:442
Models a density sink by enforcing a zero distribution on the cell.
Definition dynamics.h:351
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
Definition dynamics.h:358
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const any_platform override
Return iPop equilibrium for given first and second momenta.
Definition dynamics.h:370
CellStatistic< V > apply(CELL &cell, PARAMETERS &parameters) any_platform
Definition dynamics.h:363
std::string getName() const override
Return human-readable name.
Definition dynamics.h:374
std::type_index id() override
Expose unique type-identifier for RTTI.
Definition dynamics.h:354
Nguyen-Ladd Velocity Correction using momenta-defined velocity.
Definition collision.h:275
Override COLLISION parameter OMEGA with inverse of cell field TAU_EFF.
Dynamics constructed as a tuple of momenta, equilibrium and collision.
Definition interface.h:182
Dynamics combination rule implementing the forcing scheme by Guo et al.
Definition forcing.h:38
Dynamics combination rule implementing the forcing scheme by Kupershtokh et al.
Definition forcing.h:148
Dynamics combination rule implementing the forcing scheme by Guo et al. with barycentric velocity.
Definition forcing.h:118
static void addExternalForce(CELL &cell, const RHO &rho, const U &u, const OMEGA &omega, const FORCE &force) any_platform
Add a force term after BGK collision.
Definition lbm.h:463
static V bgkCollision(CELL &cell, const RHO &rho, const VELOCITY &u, const OMEGA &omega) any_platform
BGK collision step.
Definition lbm.h:290
Plain wrapper for list of types.
Definition meta.h:276
Standard computation for density in the bulk as zeroth moment of the population.
Definition elements.h:132
The momenta are defined one after the other.
The density is fixed and stored in the external field RHO.
Definition elements.h:182
Momentum is zero at solid material.
Definition elements.h:1049
The stress is always zero.
Definition elements.h:1355
Compute number of elements of a symmetric d-dimensional tensor.
Definition util.h:210
Set of functions commonly used in LB computations – header file.