25#ifndef LB_LEGACY_DYNAMICS_H
26#define LB_LEGACY_DYNAMICS_H
34template <
typename T,
typename DESCRIPTOR,
typename MOMENTA>
40 std::type_index
id()
override {
45 throw std::bad_function_call();
50template<
typename T,
typename DESCRIPTOR,
typename MOMENTA=momenta::BulkTuple>
62 using MomentaF =
typename MOMENTA::template type<DESCRIPTOR>;
67template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
73template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
76 T rho, u[DESCRIPTOR::d];
77 MomentaF().computeRhoU(cell, rho, u);
82template<
typename T,
typename DESCRIPTOR>
96 T u[DESCRIPTOR::d] )
const override;
100 T j[DESCRIPTOR::d] )
const override;
104 T rho,
const T u[DESCRIPTOR::d],
108 T& rho, T u[DESCRIPTOR::d])
const override;
111 T& rho, T u[DESCRIPTOR::d],
117 const T u[DESCRIPTOR::d])
override;
121 T rho,
const T u[DESCRIPTOR::d])
override;
125 T rho,
const T u[DESCRIPTOR::d],
128 std::type_index
id()
override {
133 throw std::bad_function_call();
144template<
typename T,
typename DESCRIPTOR>
150 OffDynamics(
const T _location[DESCRIPTOR::d], T _distances[DESCRIPTOR::q]);
166 void defineU(
const T u[DESCRIPTOR::d]);
168 void defineU(
int iPop,
const T u[DESCRIPTOR::d]);
172 std::type_index
id()
override {
179 T _u[DESCRIPTOR::q][DESCRIPTOR::d];
180 T location[DESCRIPTOR::d];
181 T distances[DESCRIPTOR::q];
182 T boundaryIntersection[DESCRIPTOR::q][DESCRIPTOR::d];
183 T velocityCoefficient[DESCRIPTOR::q];
188template<
typename T,
typename DESCRIPTOR>
191 this->
getName() =
"NoLatticeDynamics";
194template<
typename T,
typename DESCRIPTOR>
200template<
typename T,
typename DESCRIPTOR>
205template<
typename T,
typename DESCRIPTOR>
211template<
typename T,
typename DESCRIPTOR>
214 T u[DESCRIPTOR::d])
const
216 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
221template<
typename T,
typename DESCRIPTOR>
224 T j[DESCRIPTOR::d])
const
226 for (
int iD=0; iD<DESCRIPTOR::d; ++iD) {
231template<
typename T,
typename DESCRIPTOR>
234 T rho,
const T u[DESCRIPTOR::d],
237 for (
int iPi=0; iPi<util::TensorVal<DESCRIPTOR >::n; ++iPi) {
242template<
typename T,
typename DESCRIPTOR>
245 T& rho, T u[DESCRIPTOR::d])
const
247 rho = computeRho(cell);
251template<
typename T,
typename DESCRIPTOR>
254 T& rho, T u[DESCRIPTOR::d],
257 computeRhoU(cell, rho, u);
258 computeStress(cell, rho, u, pi);
261template<
typename T,
typename DESCRIPTOR>
265template<
typename T,
typename DESCRIPTOR>
268 const T u[DESCRIPTOR::d])
271template<
typename T,
typename DESCRIPTOR>
274 T rho,
const T u[DESCRIPTOR::d])
277template<
typename T,
typename DESCRIPTOR>
280 T rho,
const T u[DESCRIPTOR::d],
286template<
typename T,
typename DESCRIPTOR>
289 this->getName() =
"OffDynamics";
290 typedef DESCRIPTOR L;
291 for (
int iD = 0; iD < L::d; iD++) {
292 location[iD] = _location[iD];
294 for (
int iPop = 0; iPop < L::q; iPop++) {
295 distances[iPop] = -1;
296 velocityCoefficient[iPop] = 0;
297 for (
int iD = 0; iD < L::d; iD++) {
298 boundaryIntersection[iPop][iD] = _location[iD];
305template<
typename T,
typename DESCRIPTOR>
308 this->getName() =
"OffDynamics";
309 typedef DESCRIPTOR L;
310 for (
int iD = 0; iD < L::d; iD++) {
311 location[iD] = _location[iD];
313 for (
int iPop = 0; iPop < L::q; iPop++) {
314 distances[iPop] = _distances[iPop];
315 velocityCoefficient[iPop] = 0;
316 for (
int iD = 0; iD < L::d; iD++) {
317 boundaryIntersection[iPop][iD] = _location[iD] - _distances[iPop]*descriptors::c<L>(iPop,iD);
324template<
typename T,
typename DESCRIPTOR>
344template<
typename T,
typename DESCRIPTOR>
347 typedef DESCRIPTOR L;
348 for (
int iD = 0; iD < L::d; iD++) {
352 for (
int iPop = 0; iPop < L::q; iPop++) {
354 for (
int iD = 0; iD < L::d; iD++) {
355 u[iD] += _u[iPop][iD];
361 for (
int iD = 0; iD < L::d; iD++) {
368template<
typename T,
typename DESCRIPTOR>
373 typedef DESCRIPTOR L;
374 distances[iPop] = distance;
375 for (
int iD = 0; iD < L::d; iD++) {
376 boundaryIntersection[iPop][iD] = location[iD] - distance*descriptors::c<L>(iPop,iD);
380template<
typename T,
typename DESCRIPTOR>
383 typedef DESCRIPTOR L;
385 for (
int iD = 0; iD < L::d; iD++) {
386 intersection[iD] = boundaryIntersection[iPop][iD];
393template<
typename T,
typename DESCRIPTOR>
399template<
typename T,
typename DESCRIPTOR>
405template<
typename T,
typename DESCRIPTOR>
408 const T u[DESCRIPTOR::d])
413template<
typename T,
typename DESCRIPTOR>
416 typedef DESCRIPTOR L;
417 for (
int iPop = 0; iPop < L::q; iPop++) {
429template<
typename T,
typename DESCRIPTOR>
431 int iPop,
const T u[DESCRIPTOR::d])
434 typedef DESCRIPTOR L;
435 velocityCoefficient[iPop] = 0;
437 for (
int sum = 0; sum < L::d; sum++) {
438 velocityCoefficient[iPop] -= descriptors::c<L>(iPop,sum)*u[sum];
441 velocityCoefficient[iPop] *= 2*descriptors::invCs2<T,L>() * descriptors::t<T,L>(iPop);
443 for (
int iD = 0; iD < L::d; iD++) {
444 _u[iPop][iD] = u[iD];
448template<
typename T,
typename DESCRIPTOR>
451 return velocityCoefficient[iPop];
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.
virtual T getOmega() const
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const override any_platform
Yields 0;.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell) override
Collision step.
std::type_index id() override
Expose unique type-identifier for RTTI.
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.
bool nearZero(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
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.
virtual CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell)
Perform purely-local collision step on Cell interface (legacy, to be deprecated)
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.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) 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.