24#ifndef DYNAMICS_INTERFACE_H
25#define DYNAMICS_INTERFACE_H
35template <
typename T,
typename DESCRIPTOR>
class Cell;
36template <
typename T,
typename DESCRIPTOR>
class ConstCell;
48 return rho != T{-1} &&
uSqr != T{-1};
53template <
typename T,
typename DESCRIPTOR>
61 virtual std::type_index
id() = 0;
75 throw std::bad_function_call();
108 T uShift[DESCRIPTOR::d];
111 for (
unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
119 for (
unsigned iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
140 template <
typename DESCRIPTOR,
typename MOMENTA>
143 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM>
146 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
149 template <
typename DESCRIPTOR,
typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION>
155template <
typename DYNAMICS,
typename =
void>
162template <
typename DYNAMICS>
165 std::enable_if_t<!DYNAMICS::is_vectorizable>
166> : std::false_type { };
169template <
typename DYNAMICS>
178 typename T,
typename DESCRIPTOR,
179 typename MOMENTA,
typename EQUILIBRIUM,
typename COLLISION,
183 using MomentaF =
typename COMBINATION_RULE::template combined_momenta<DESCRIPTOR,MOMENTA>;
184 using EquilibriumF =
typename COMBINATION_RULE::template combined_equilibrium<DESCRIPTOR,MOMENTA,EQUILIBRIUM>;
185 using CollisionO =
typename COMBINATION_RULE::template combined_collision<DESCRIPTOR,MOMENTA,EQUILIBRIUM,COLLISION>;
187 using parameters =
typename COMBINATION_RULE::template combined_parameters<DESCRIPTOR,MOMENTA,EQUILIBRIUM,COLLISION>;
191 template <
typename NEW_MOMENTA>
194 NEW_MOMENTA, EQUILIBRIUM, COLLISION,
198 template <
typename NEW_RULE>
201 MOMENTA, EQUILIBRIUM, COLLISION,
205 template <
template<
typename>
typename WRAPPER>
208 MOMENTA, EQUILIBRIUM, WRAPPER<COLLISION>,
212 std::type_index
id()
override {
213 return typeid(
Tuple);
217 return "dynamics::Tuple<"
219 + EQUILIBRIUM::getName() +
","
220 + COLLISION::getName() +
","
221 + COMBINATION_RULE::getName() +
226 template <
typename FIELD>
228 return parameters::template contains<FIELD>();
233 return block.template getData<OperatorParameters<Tuple>>();
242 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
245 auto params =
static_cast<
266 MomentaF().computeStress(cell, rho, u, pi);
269 MomentaF().computeRhoU(cell, rho, u);
273 MomentaF().computeAllMomenta(cell, rho, u, pi);
283 MomentaF().defineRhoU(cell, rho, u);
287 MomentaF().defineAllMomenta(cell, rho, u, pi);
290 MomentaF().inverseShiftRhoU(cell, rho, u);
294template <
typename T,
typename DESCRIPTOR,
typename MOMENTA>
299 using MomentaF =
typename MOMENTA::template type<DESCRIPTOR>;
316 MomentaF().computeStress(cell, rho, u, pi);
319 MomentaF().computeRhoU(cell, rho, u);
323 MomentaF().computeAllMomenta(cell, rho, u, pi);
333 MomentaF().defineRhoU(cell, rho, u);
337 MomentaF().defineAllMomenta(cell, rho, u, pi);
340 MomentaF().inverseShiftRhoU(cell, rho, u);
356template <
typename PARAMETER,
typename DYNAMICS>
358 typename DYNAMICS::value_t,
359 typename DYNAMICS::descriptor_t,
360 typename DYNAMICS::MomentaF::abstract
372 std::type_index
id()
override {
378 return block.template getData<OperatorParameters<ParameterFromCell>>();
381 template <CONCEPT(MinimalCell) CELL,
typename PARAMETERS,
typename V=
typename CELL::value_t>
384 cell.template getField<PARAMETER>());
389 return DYNAMICS().computeEquilibrium(iPop, rho, u);
393 return "ParameterFromCell<" + DYNAMICS().getName() +
">";
399template <
typename DYNAMICS,
typename CELL,
typename PARAMETERS,
typename =
void>
403template <
typename DYNAMICS,
typename CELL,
typename PARAMETERS>
405 DYNAMICS, CELL, PARAMETERS,
406 std::enable_if_t<std::is_member_function_pointer_v<decltype(&DYNAMICS::template apply<CELL,PARAMETERS>)>>
407> : std::true_type { };
413template <
typename T,
typename DESCRIPTOR,
typename DYNAMICS>
417template <
typename DYNAMICS,
typename =
void>
424template <
typename DYNAMICS>
427 std::enable_if_t<DYNAMICS::has_parametrized_momenta>
428> : std::true_type { };
431template <
typename DYNAMICS>
Platform-abstracted block lattice for external access and inter-block interaction.
Highest-level interface to Cell data.
Highest-level interface to read-only Cell data.
File provides a generic interface for the computation and definition of momenta (density,...
void copyN(T c[], const T a[], const unsigned dim) any_platform
Top level namespace for all of OpenLB.
typename ParametersD< T, DESCRIPTOR >::template include< typename OPERATOR::parameters > ParametersOfOperatorD
Deduce ParametersD of OPERATOR w.r.t. T and DESCRIPTOR.
Dynamic access interface for FIELD-valued parameters.
Return value of any collision.
Interface for per-cell dynamics.
virtual void inverseShiftRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const
Calculate population momenta s.t. the physical momenta are reproduced by the computeRhoU.
virtual T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const any_platform=0
Return iPop equilibrium for given first and second momenta.
virtual T computeRho(ConstCell< T, DESCRIPTOR > &cell) const =0
Compute particle density.
virtual std::type_index id()=0
Expose unique type-identifier for RTTI.
void iniRegularized(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n])
Initialize cell to equilibrium and non-equilibrum part.
virtual void computeU(ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const =0
Compute fluid velocity.
virtual void computeStress(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const =0
Compute stress tensor.
virtual void defineU(Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d])=0
Set fluid velocity.
virtual void defineRhoU(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d])=0
Define fluid velocity and particle density.
virtual std::string getName() const
Return human-readable name.
virtual void initialize(Cell< T, DESCRIPTOR > &cell)
Initialize dynamics-specific data for cell.
virtual ~Dynamics() any_platform
void iniEquilibrium(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d])
Initialize to equilibrium distribution.
virtual void computeRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const =0
Compute fluid velocity and particle density.
virtual AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block)=0
Parameters access for legacy post processors.
virtual void defineRho(Cell< T, DESCRIPTOR > &cell, T rho)=0
Set particle density.
virtual void computeAllMomenta(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const =0
Compute all momenta up to second order.
virtual void computeJ(ConstCell< T, DESCRIPTOR > &cell, T j[DESCRIPTOR::d]) const =0
Compute fluid momentum.
virtual void defineAllMomenta(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n])=0
Define all momenta up to second order.
virtual CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell)
Perform purely-local collision step on Cell interface (legacy, to be deprecated)
void inverseShiftRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
Calculate population momenta s.t. the physical momenta are reproduced by the computeRhoU.
typename MOMENTA::template type< DESCRIPTOR > MomentaF
void computeU(ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
Compute fluid velocity.
void initialize(Cell< T, DESCRIPTOR > &cell) override
Initialize dynamics-specific data for cell.
void defineAllMomenta(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n]) override
Define all momenta up to second order.
void defineRhoU(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d]) override
Define fluid velocity and particle density.
void computeJ(ConstCell< T, DESCRIPTOR > &cell, T j[DESCRIPTOR::d]) const override
Compute fluid momentum.
void computeRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
Compute fluid velocity and particle density.
void computeStress(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
Compute stress tensor.
T computeRho(ConstCell< T, DESCRIPTOR > &cell) const override
Compute particle density.
void computeAllMomenta(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
Compute all momenta up to second order.
void defineRho(Cell< T, DESCRIPTOR > &cell, T rho) override
Set particle density.
void defineU(Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d]) override
Set fluid velocity.
Default combination rule used by dynamics::Tuple.
static std::string getName()
typename EQUILIBRIUM::template type< DESCRIPTOR, MOMENTA > combined_equilibrium
typename COLLISION::parameters combined_parameters
typename MOMENTA::template type< DESCRIPTOR > combined_momenta
typename COLLISION::template type< DESCRIPTOR, MOMENTA, EQUILIBRIUM > combined_collision
Set PARAMETER of DYNAMICS from CELL (for CustomCollision-based DYNAMICS)
typename DYNAMICS::descriptor_t descriptor_t
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
typename DYNAMICS::value_t value_t
std::string getName() const override
Return human-readable name.
typename DYNAMICS::parameters parameters
AbstractParameters< value_t, descriptor_t > & getParameters(BlockLattice< value_t, descriptor_t > &block) override
value_t computeEquilibrium(int iPop, value_t rho, const value_t u[descriptor_t::d]) const override
std::type_index id() override
Expose unique type-identifier for RTTI.
typename DYNAMICS::MomentaF MomentaF
Dynamics constructed as a tuple of momenta, equilibrium and collision.
void inverseShiftRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
Calculate population momenta s.t. the physical momenta are reproduced by the computeRhoU.
void defineU(Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d]) override
Set fluid velocity.
typename COMBINATION_RULE::template combined_momenta< DESCRIPTOR, MOMENTA > MomentaF
std::string getName() const override
Return human-readable name.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override any_platform
Return iPop equilibrium for given first and second momenta.
void defineRhoU(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d]) override
Define fluid velocity and particle density.
T computeRho(ConstCell< T, DESCRIPTOR > &cell) const override
Compute particle density.
void computeStress(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
Compute stress tensor.
void computeAllMomenta(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
Compute all momenta up to second order.
void defineAllMomenta(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n]) override
Define all momenta up to second order.
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Interim workaround for accessing dynamics parameters in legacy post processors.
void initialize(Cell< T, DESCRIPTOR > &cell) override
Initialize MOMENTA-specific data for cell.
constexpr bool hasParameter() const
Return true iff FIELD is a parameter.
typename COMBINATION_RULE::template combined_equilibrium< DESCRIPTOR, MOMENTA, EQUILIBRIUM > EquilibriumF
void defineRho(Cell< T, DESCRIPTOR > &cell, T rho) override
Set particle density.
void computeRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
Compute fluid velocity and particle density.
void computeJ(ConstCell< T, DESCRIPTOR > &cell, T j[DESCRIPTOR::d]) const override
Compute fluid momentum.
typename COMBINATION_RULE::template combined_parameters< DESCRIPTOR, MOMENTA, EQUILIBRIUM, COLLISION > parameters
std::type_index id() override
Expose unique type-identifier for RTTI.
void computeU(ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
Compute fluid velocity.
typename COMBINATION_RULE::template combined_collision< DESCRIPTOR, MOMENTA, EQUILIBRIUM, COLLISION > CollisionO
CellStatistic< V > apply(CELL &cell, PARAMETERS ¶meters) any_platform
Apply purely-local collision step to a generic CELL.
DYNAMICS is not explicitly marked as requiring parameters outside DYNAMICS::apply.
DYNAMICS doesn't provide apply method template.
DYNAMICS is not explicitly marked as unvectorizable.
Compute number of elements of a symmetric d-dimensional tensor.