25#ifndef LB_LEGACY_DYNAMICS_H
26#define LB_LEGACY_DYNAMICS_H
34template <
typename T,
typename DESCRIPTOR,
typename MOMENTA>
37 for (
int iPop = 0; iPop < DESCRIPTOR::q; iPop++ ) {
42 std::type_index
id()
override {
47 throw std::bad_function_call();
52template<
typename T,
typename DESCRIPTOR,
typename MOMENTA=momenta::BulkTuple>
64 using MomentaF =
typename MOMENTA::template type<DESCRIPTOR>;
69template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
75template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
78 T rho, u[DESCRIPTOR::d];
79 MomentaF().computeRhoU(cell, rho, u);
84template<
typename T,
typename DESCRIPTOR>
98 T u[DESCRIPTOR::d] )
const override;
102 T j[DESCRIPTOR::d] )
const override;
106 T rho,
const T u[DESCRIPTOR::d],
110 T& rho, T u[DESCRIPTOR::d])
const override;
113 T& rho, T u[DESCRIPTOR::d],
119 const T u[DESCRIPTOR::d])
override;
123 T rho,
const T u[DESCRIPTOR::d])
override;
127 T rho,
const T u[DESCRIPTOR::d],
130 std::type_index
id()
override {
135 throw std::bad_function_call();
146template<
typename T,
typename DESCRIPTOR>
152 OffDynamics(
const T _location[DESCRIPTOR::d], T _distances[DESCRIPTOR::q]);
168 void defineU(
const T u[DESCRIPTOR::d]);
170 void defineU(
int iPop,
const T u[DESCRIPTOR::d]);
174 std::type_index
id()
override {
181 T _u[DESCRIPTOR::q][DESCRIPTOR::d];
182 T location[DESCRIPTOR::d];
183 T distances[DESCRIPTOR::q];
184 T boundaryIntersection[DESCRIPTOR::q][DESCRIPTOR::d];
185 T velocityCoefficient[DESCRIPTOR::q];
190template<
typename T,
typename DESCRIPTOR>
193 this->
getName() =
"NoLatticeDynamics";
196template<
typename T,
typename DESCRIPTOR>
202template<
typename T,
typename DESCRIPTOR>
207template<
typename T,
typename DESCRIPTOR>
213template<
typename T,
typename DESCRIPTOR>
216 T u[DESCRIPTOR::d])
const
218 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
223template<
typename T,
typename DESCRIPTOR>
226 T j[DESCRIPTOR::d])
const
228 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
233template<
typename T,
typename DESCRIPTOR>
236 T rho,
const T u[DESCRIPTOR::d],
239 for (
int iPi=0; iPi<util::TensorVal<DESCRIPTOR >::n; ++iPi) {
244template<
typename T,
typename DESCRIPTOR>
247 T& rho, T u[DESCRIPTOR::d])
const
249 rho = computeRho(cell);
253template<
typename T,
typename DESCRIPTOR>
256 T& rho, T u[DESCRIPTOR::d],
259 computeRhoU(cell, rho, u);
260 computeStress(cell, rho, u, pi);
263template<
typename T,
typename DESCRIPTOR>
267template<
typename T,
typename DESCRIPTOR>
270 const T u[DESCRIPTOR::d])
273template<
typename T,
typename DESCRIPTOR>
276 T rho,
const T u[DESCRIPTOR::d])
279template<
typename T,
typename DESCRIPTOR>
282 T rho,
const T u[DESCRIPTOR::d],
288template<
typename T,
typename DESCRIPTOR>
291 this->
getName() =
"OffDynamics";
292 typedef DESCRIPTOR L;
293 for (
int iD = 0; iD < L::d; iD++) {
294 location[iD] = _location[iD];
296 for (
int iPop = 0; iPop < L::q; iPop++) {
297 distances[iPop] = -1;
298 velocityCoefficient[iPop] = 0;
299 for (
int iD = 0; iD < L::d; iD++) {
300 boundaryIntersection[iPop][iD] = _location[iD];
307template<
typename T,
typename DESCRIPTOR>
310 this->
getName() =
"OffDynamics";
311 typedef DESCRIPTOR L;
312 for (
int iD = 0; iD < L::d; iD++) {
313 location[iD] = _location[iD];
315 for (
int iPop = 0; iPop < L::q; iPop++) {
316 distances[iPop] = _distances[iPop];
317 velocityCoefficient[iPop] = 0;
318 for (
int iD = 0; iD < L::d; iD++) {
319 boundaryIntersection[iPop][iD] = _location[iD] - _distances[iPop]*
descriptors::c<L>(iPop,iD);
326template<
typename T,
typename DESCRIPTOR>
346template<
typename T,
typename DESCRIPTOR>
349 typedef DESCRIPTOR L;
350 for (
int iD = 0; iD < L::d; iD++) {
354 for (
int iPop = 0; iPop < L::q; iPop++) {
356 for (
int iD = 0; iD < L::d; iD++) {
357 u[iD] += _u[iPop][iD];
363 for (
int iD = 0; iD < L::d; iD++) {
370template<
typename T,
typename DESCRIPTOR>
375 typedef DESCRIPTOR L;
376 distances[iPop] = distance;
377 for (
int iD = 0; iD < L::d; iD++) {
378 boundaryIntersection[iPop][iD] = location[iD] - distance*
descriptors::c<L>(iPop,iD);
382template<
typename T,
typename DESCRIPTOR>
385 typedef DESCRIPTOR L;
387 for (
int iD = 0; iD < L::d; iD++) {
388 intersection[iD] = boundaryIntersection[iPop][iD];
395template<
typename T,
typename DESCRIPTOR>
401template<
typename T,
typename DESCRIPTOR>
407template<
typename T,
typename DESCRIPTOR>
410 const T u[DESCRIPTOR::d])
415template<
typename T,
typename DESCRIPTOR>
418 typedef DESCRIPTOR L;
419 for (
int iPop = 0; iPop < L::q; iPop++) {
431template<
typename T,
typename DESCRIPTOR>
433 int iPop,
const T u[DESCRIPTOR::d])
436 typedef DESCRIPTOR L;
437 velocityCoefficient[iPop] = 0;
439 for (
int sum = 0; sum < L::d; sum++) {
445 for (
int iD = 0; iD < L::d; iD++) {
446 _u[iPop][iD] = u[iD];
450template<
typename T,
typename DESCRIPTOR>
453 return velocityCoefficient[iPop];
Highest-level interface to read-only Cell data.
virtual T getOmega() const
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step.
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 any_platform
Yields 0;.
void defineAllMomenta(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n]) override
Does nothing.
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 computeJ(ConstCell< T, DESCRIPTOR > &cell, T j[DESCRIPTOR::d]) const override
Yields 0;.
void defineRho(Cell< T, DESCRIPTOR > &cell, T rho) override
Does nothing.
void computeRhoU(ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
Compute fluid velocity and particle density.
NoLatticeDynamics(T rho=T(1))
You may fix a fictitious density value on no dynamics node via this constructor.
void computeStress(ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
Yields NaN.
T computeRho(ConstCell< T, DESCRIPTOR > &cell) const override
Yields 1;.
void defineRhoU(Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d]) override
Does nothing.
void computeU(ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
Yields 0;.
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
void defineU(Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d]) override
Does nothing.
Dynamics for offLattice boundary conditions OffDynamics are basically NoLatticeDynamics with the addi...
OffDynamics(const T _location[DESCRIPTOR::d])
Constructor.
T getVelocityCoefficient(int iPop)
Get VelocitySummand for Bouzidi-Boundary Condition.
void defineRho(Cell< T, DESCRIPTOR > &cell, T rho) override
Set particle density on the cell.
void computeU(ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
Returns an average of the locally stored u.
std::type_index id() override
Expose unique type-identifier for RTTI.
T computeRho(ConstCell< T, DESCRIPTOR > &cell) const override
Returns local stored rho which is updated if the bc is used as velocity!=0 condition.
void defineU(Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d]) override
Set fluid velocity on the cell.
void setBoundaryIntersection(int iPop, T distance)
Set Intersection of the link and the boundary.
bool getBoundaryIntersection(int iPop, T intersection[DESCRIPTOR::d])
Get Intersection of the link and the boundary.
constexpr T invCs2() any_platform
constexpr T t(unsigned iPop, tag::CUM) any_platform
constexpr int c(unsigned iPop, unsigned iDim) any_platform
bool nearZero(T a) any_platform
return true if a is close to zero
Top level namespace for all of OpenLB.
std::string getName(OperatorScope scope)
Returns human-readable name of scope.
dynamics::Tuple< T, DESCRIPTOR, MOMENTA, std::conditional_t<(DESCRIPTOR::d==3 &&DESCRIPTOR::q==7)||(DESCRIPTOR::d==2 &&DESCRIPTOR::q==5), equilibria::FirstOrder, equilibria::SecondOrder >, collision::BGK > BGKdynamics
Common BGK collision step.
#define OLB_PRECONDITION(COND)
Dynamic access interface for FIELD-valued parameters.
Return value of any collision.
Interface for per-cell dynamics.
virtual std::string getName() const
Return human-readable name.
CellStatistic< V > collide(CELL &cell, PARAMETERS ¶meters) any_platform
Apply purely-local collision step to a generic CELL.
static V secondOrder(int iPop, const RHO &rho, const U &u, const USQR &uSqr) any_platform
Computation of equilibrium distribution, second order in u.
static V bgkCollision(CELL &cell, const RHO &rho, const VELOCITY &u, const OMEGA &omega) any_platform
BGK collision step.
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.
AbstractParameters< T, DESCRIPTOR > & getParameters(BlockLattice< T, DESCRIPTOR > &block) override
Parameters access for legacy post processors.
std::type_index id() override
Expose unique type-identifier for RTTI.
Compute number of elements of a symmetric d-dimensional tensor.