33template <
typename DESCRIPTOR>
36 template <
typename RHO,
typename U,
typename V=RHO>
40 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
50 template <
typename RHO,
typename U,
typename USQR,
typename V=RHO>
54 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
66 template <
typename RHO,
typename U,
typename V=RHO>
74 template <
typename RHO,
typename U,
typename USQR,
typename V=RHO>
78 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
83 V aEqThrdXXY = u[0] * u[0] * u[1];
84 V aEqThrdXYY = u[0] * u[1] * u[1];
94 V thirdOrderTerms = V{1. / 2.} * reciSpeedOfSoundHc * (hermite3XXY + hermite3XYY) * (aEqThrdXXY + aEqThrdXYY)
95 + V{1. / 6.} * reciSpeedOfSoundHc * (hermite3XXY - hermite3XYY) * (aEqThrdXXY - aEqThrdXYY);
96 if constexpr (DESCRIPTOR::d == 3) {
97 V aEqThrdXXZ = u[0] * u[0] * u[2];
98 V aEqThrdXZZ = u[0] * u[2] * u[2];
99 V aEqThrdYYZ = u[1] * u[1] * u[2];
100 V aEqThrdYZZ = u[1] * u[2] * u[2];
110 thirdOrderTerms += V{1. / 2.} * reciSpeedOfSoundHc * (hermite3XZZ + hermite3YZZ) * (aEqThrdXZZ + aEqThrdYZZ)
111 + V{1. / 2.} * reciSpeedOfSoundHc * (hermite3YYZ + hermite3XXZ) * (aEqThrdYYZ + aEqThrdXXZ)
112 + V{1. / 6.} * reciSpeedOfSoundHc * (hermite3XZZ - hermite3YZZ) * (aEqThrdXZZ - aEqThrdYZZ)
113 + V{1. / 6.} * reciSpeedOfSoundHc * (hermite3YYZ - hermite3XXZ) * (aEqThrdYYZ - aEqThrdXXZ);
125 template <
typename RHO,
typename U,
typename V=RHO>
133 template <
typename RHO,
typename U,
typename V=RHO>
138 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
145 template <
typename J,
typename JSQR,
typename PRESSURE,
typename V=PRESSURE>
149 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
159 template <
typename J,
typename PRESSURE,
typename V=PRESSURE>
166 template <
typename RHO,
typename U,
typename USQR,
typename PRESSURE,
typename V=PRESSURE>
175 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
182 template <
typename RHO,
typename U,
typename PRESSURE,
typename V=PRESSURE>
191 template <
typename V>
193 const V Jgrad[DESCRIPTOR::d * DESCRIPTOR::d],
196 using L = DESCRIPTOR;
199 for (
int iAlpha=0; iAlpha < L::d; ++iAlpha) {
200 for (
int iBeta=0; iBeta < L::d; ++iBeta) {
202 if (iAlpha == iBeta) {
208 toAdd *= Jgrad[iJgrad++];
224 template <
typename V,
typename PI>
227 using L = DESCRIPTOR;
232 for (
int iAlpha=0; iAlpha < L::d; ++iAlpha) {
233 for (
int iBeta=iAlpha; iBeta < L::d; ++iBeta) {
235 if (iAlpha == iBeta) {
249 template <
typename V>
253 for (
int iD = 0; iD < DESCRIPTOR::d; ++iD) {
263template <
typename DESCRIPTOR>
266 template <concepts::MinimalCell CELL,
typename V=
typename CELL::value_t>
270 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
278 template <concepts::MinimalCell CELL,
typename J,
typename V=
typename CELL::value_t>
281 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
284 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
285 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
292 template <concepts::MinimalCell CELL,
typename RHO,
typename J,
typename V=
typename CELL::value_t>
300 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename V=
typename CELL::value_t>
304 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
310 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename PI,
typename V=
typename CELL::value_t>
314 for (
int iAlpha=0; iAlpha < DESCRIPTOR::d; ++iAlpha) {
315 for (
int iBeta=iAlpha; iBeta < DESCRIPTOR::d; ++iBeta) {
317 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
322 pi[iPi] -= rho*u[iAlpha]*u[iBeta];
332 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename PI,
typename V=
typename CELL::value_t>
339 template <concepts::MinimalCell CELL,
typename FEQ,
typename V=
typename CELL::value_t>
343 V u[DESCRIPTOR::d] {};
346 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
352 template <concepts::MinimalCell CELL,
typename FNEQ,
typename RHO,
typename U,
typename V=
typename CELL::value_t>
356 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
361 template <concepts::MinimalCell CELL,
typename FNEQ,
typename V=
typename CELL::value_t>
365 V u[DESCRIPTOR::d] {};
371 template <concepts::MinimalCell CELL,
typename RHO,
typename VELOCITY,
typename OMEGA,
typename V=
typename CELL::value_t>
375 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
376 cell[iPop] *= V{1} - omega;
383 template <concepts::MinimalCell CELL,
typename RHO,
typename VELOCITY,
typename OMEGA,
typename V=
typename CELL::value_t>
387 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
388 cell[iPop] *= V{1} - omega;
395 template <concepts::MinimalCell CELL,
typename PRESSURE,
typename J,
typename OMEGA,
typename V=
typename CELL::value_t>
399 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
400 cell[iPop] *= V{1} - omega;
407 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename RATIORHO,
typename OMEGA,
typename V=
typename CELL::value_t>
409 const RATIORHO& ratioRho,
const OMEGA& omega)
any_platform
412 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
416 (V{1}-omega)*(cell[iPop]-feq);
422 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename OMEGA,
typename V=
typename CELL::value_t>
428 for (
int iD = 0; iD < DESCRIPTOR::d; ++iD ) {
432 V fEq[DESCRIPTOR::q];
433 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop ) {
435 for (
int iD = 0; iD < DESCRIPTOR::d; ++iD ) {
441 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop ) {
443 for (
int iD = 0; iD < DESCRIPTOR::d; ++iD ) {
447 cell[iPop] = fEq[iPop] + ( V{1} - omega ) * fNeq;
453 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename PI,
typename OMEGA,
typename V=
typename CELL::value_t>
459 for (
int iPop=1; iPop <= DESCRIPTOR::q/2; ++iPop) {
465 cell[iPop+DESCRIPTOR::q/2] += fNeq;
470 template <concepts::MinimalCell CELL,
typename NEWRHO,
typename NEWU,
typename V=
typename CELL::value_t>
473 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
478 template <concepts::MinimalCell CELL,
typename OLDRHO,
typename OLDU,
typename NEWRHO,
typename NEWU,
typename V=
typename CELL::value_t>
480 const OLDRHO& oldRho,
const OLDU& oldU,
485 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
491 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename PI,
typename V=
typename CELL::value_t>
498 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
505 template <concepts::MinimalCell CELL,
typename FORCE,
typename V=
typename CELL::value_t>
513 for (
int Alpha=0; Alpha<DESCRIPTOR::d; ++Alpha) {
514 for (
int Beta=Alpha; Beta<DESCRIPTOR::d; ++Beta) {
515 ForceTensor[iPi] = rho/2.*(force[Alpha]*u[Beta] + u[Alpha]*force[Beta]);
520 for (
int iPi=0; iPi < util::TensorVal<DESCRIPTOR >::n; ++iPi) {
521 pi[iPi] += ForceTensor[iPi];
523 V PiNeqNormSqr = pi[0]*pi[0] + 2.*pi[1]*pi[1] + pi[2]*pi[2];
525 PiNeqNormSqr += pi[2]*pi[2] + pi[3]*pi[3] + 2.*pi[4]*pi[4] +pi[5]*pi[5];
531 template <concepts::MinimalCell CELL,
typename V=
typename CELL::value_t>
536 V PiNeqNormSqr = pi[0]*pi[0] + 2.*pi[1]*pi[1] + pi[2]*pi[2];
538 PiNeqNormSqr += pi[2]*pi[2] + pi[3]*pi[3] + 2.*pi[4]*pi[4] +pi[5]*pi[5];
544 template <concepts::MinimalCell CELL,
typename RHO,
typename U,
typename OMEGA,
typename FORCE,
typename V=
typename CELL::value_t>
547 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
549 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
554 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
562 forceTerm *= V{1} - omega * V{0.5};
564 cell[iPop] += forceTerm;
569 template <
typename CELL,
typename RHO,
typename NABLARHO,
typename U,
typename OMEGA,
typename FORCE,
typename V=
typename CELL::value_t>
570 static void addLiangForce(CELL& cell,
const RHO& rho,
const NABLARHO& nablarho,
const U& u,
const OMEGA& omega,
const FORCE& force)
any_platform
572 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
574 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
578 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
582 forceTerm *= V{1} - omega * V{0.5};
583 cell[iPop] += forceTerm;
588 template <
typename CELL,
typename OMEGA,
typename FORCE,
typename V=
typename CELL::value_t>
591 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
593 for (
int iD=0; iD < DESCRIPTOR::d; ++iD) {
597 forceTerm *= V{1} - omega * V{0.5};
598 cell[iPop] += forceTerm;
603 template <
typename CELL,
typename OMEGA,
typename SOURCE,
typename V=
typename CELL::value_t>
606 for (
int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
constexpr T invCs2() any_platform
constexpr T t(unsigned iPop, tag::CUM) any_platform
constexpr int c(unsigned iPop, unsigned iDim) any_platform
auto normSqr(const ARRAY_LIKE &u) any_platform
Compute norm square of a d-dimensional vector.
Top level namespace for all of OpenLB.
static V fromPiToFneq(int iPop, const PI &pi) any_platform
Compute off-equilibrium part of the f's from the stress tensor Pi.
static V secondOrder(int iPop, const RHO &rho, const U &u) any_platform
Computation of equilibrium distribution, second order in u.
static V incompressible(int iPop, const J &j, const JSQR &jSqr, const PRESSURE &pressure) any_platform
static V thirdOrder(int iPop, const RHO &rho, const U &u, const USQR &uSqr) any_platform
Computation of equilibrium distribution, third order in u.
static V fromJneqToFneq(int iPop, const V jNeq[DESCRIPTOR::d]) any_platform
static V P1(int iPop, const RHO &rho, const U &u) any_platform
static V thirdOrder(int iPop, const RHO &rho, const U &u) any_platform
Computation of equilibrium distribution, third order in u.
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 fromJgradToFneq(int iPop, const V Jgrad[DESCRIPTOR::d *DESCRIPTOR::d], V omega) any_platform
compute off-equilibrium part of the populations from gradient of the flux for asymmetric regularizati...
static V mpincompressible(int iPop, const RHO &rho, const U &u, const USQR &uSqr, const PRESSURE &pressure) any_platform
static V firstOrder(int iPop, const RHO &rho, const U &u) any_platform
Computation of equilibrium distribution, first order in u.
static V mpincompressible(int iPop, const RHO &rho, const U &u, const PRESSURE &pressure) any_platform
static V incompressible(int iPop, const J &j, const PRESSURE &pressure) any_platform
Collection of common computations for LBM.
static V adeBgkCollision(CELL &cell, const RHO &rho, const VELOCITY &u, const OMEGA &omega) any_platform
Advection diffusion BGK collision step.
static void defineEqFirstOrder(CELL &cell, const NEWRHO &newRho, const NEWU &newU) any_platform
static V constRhoBgkCollision(CELL &cell, const RHO &rho, const U &u, const RATIORHO &ratioRho, const OMEGA &omega) any_platform
BGK collision step with density correction.
static void computeFeq(CELL &cell, FEQ &fEq) any_platform
static V computePiNeqNormSqr(CELL &cell) any_platform
Computes squared norm of non-equilibrium part of 2nd momentum for standard (non-forced) dynamics.
static void computeJ(CELL &cell, J &j) any_platform
Computation of momentum.
static void computeFneq(CELL &cell, FNEQ &fNeq, const RHO &rho, const U &u) any_platform
Computation of non-equilibrium distribution.
static void computeAllMomenta(CELL &cell, RHO &rho, U &u, PI &pi) any_platform
Computation of all hydrodynamic variables.
static V rlbCollision(CELL &cell, const RHO &rho, const U &u, const PI &pi, const OMEGA &omega) any_platform
Renormalized DESCRIPTOR Boltzmann collision operator, fIn --> fOut.
static void computeFneq(CELL &cell, FNEQ &fNeq) any_platform
static void addAllenCahnForce(CELL &cell, const OMEGA &omega, const FORCE &force) any_platform
Add a force term after BGK collision for constructing local Allen-Cahn-equation from Liang et al....
static void addLiangForce(CELL &cell, const RHO &rho, const NABLARHO &nablarho, const U &u, const OMEGA &omega, const FORCE &force) any_platform
Add a force term after BGK collision for incompressible binary fluid model (Allen-Cahn phase-field) f...
static V computePiNeqNormSqr(CELL &cell, const FORCE &force) any_platform
Computes squared norm of non-equilibrium part of 2nd momentum for forced dynamics.
static V rlbCollision(CELL &cell, const RHO &rho, const U &u, const OMEGA &omega) any_platform
RLB advection diffusion collision step.
static void addAllenCahnSource(CELL &cell, const OMEGA &omega, const SOURCE &source) any_platform
Add a source term after BGK collision for constructing non-local Allen-Cahn-equation from Liu et al....
static void computeRhoJ(CELL &cell, RHO &rho, J &j) any_platform
Computation of hydrodynamic variables.
static V computeRho(CELL &cell) any_platform
Computation of density.
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.
static V bgkCollision(CELL &cell, const RHO &rho, const VELOCITY &u, const OMEGA &omega) any_platform
BGK collision step.
static void computeStress(CELL &cell, const RHO &rho, const U &u, PI &pi) any_platform
Computation of stress tensor.
static void defineNEq(CELL &cell, const OLDRHO &oldRho, const OLDU &oldU, const NEWRHO &newRho, const NEWU &newU) any_platform
static V incBgkCollision(CELL &cell, const PRESSURE &pressure, const J &j, const OMEGA &omega) any_platform
Incompressible BGK collision step.
static void defineNEqFromPi(CELL &cell, const RHO &rho, const U &u, const PI &pi) any_platform
static void computeRhoU(CELL &cell, RHO &rho, U &u) any_platform
Computation of hydrodynamic variables.
Compute number of elements of a symmetric d-dimensional tensor.
Set of functions commonly used in LB computations – header file.