22template <MInt nDim, MInt nDist,
class SysEqn, MBool bubble = false>
43template <MInt nDim, MInt nDist,
class SysEqn, MBool bubble>
46 const MInt solverId = m_solver->m_solverId;
48 m_Cs = Context::getSolverProperty<MFloat>(
"smagorinskyConstant", solverId, AT_);
52template <MInt nDim, MInt nDist,
class SysEqn, MBool bubble>
57 s->m_nu = s->m_Ma * LBCS / s->m_Re * s->m_referenceLength;
58 maia::parallelFor<false>(0, s->m_currentMaxNoCells, [=](
MInt index) {
59 const MInt pCellId = s->m_activeCellList[index];
60 const MInt lvlDiff = s->maxLevel() - s->a_level(pCellId);
61 if((globalTimeStep - 1) % IPOW2(lvlDiff) != 0) return;
64 s->a_nu(pCellId) = s->m_nu;
67 constexpr MInt nDimSqr = nDim * nDim;
69 const MFloat rho = s->a_variable(pCellId, s->PV->RHO);
71 const MFloat*
const u = &s->a_variable(pCellId, s->PV->U);
72 const MFloat*
const dist = &s->a_oldDistribution(pCellId, 0);
77 for(
MInt d = 0; d < nDim; d++) {
78 u[d] = s->a_variable(pCellId, d);
80 for(
MInt d = 0; d < nDist; d++) {
81 dist[d] = s->a_oldDistribution(pCellId, d);
85 const MFloat Q = sqrt(2.0 * std::inner_product(&c[0], &c[nDimSqr], &c[0], .0));
87 if constexpr(bubble) {
90 const MFloat u_d = sqrt(
POW2(s->a_uOtherPhase(pCellId, 0) - u[0]) +
POW2(s->a_uOtherPhase(pCellId, 1) - u[1])
91 +
POW2(s->a_uOtherPhase(pCellId, 2) - u[2]));
92 nu_BIT = m_Cs * s->a_alphaGasLim(pCellId) * u_d;
97 MFloat tauBase = F1B2 + 3.0 * (s->m_nu + nu_BIT) *
FFPOW2(s->maxLevel() - s->a_level(pCellId));
100 + sqrt(tauBase * tauBase
101 + 2.0 * m_Cs * m_Cs * m_deltaX * m_deltaX * (F1BCSsq * F1BCSsq) * Q
102 *
FPOW2(s->maxLevel() - s->a_level(pCellId))));
105 if constexpr(bubble) {
106 if(s->m_cells.saveOldNu()) {
107 s->a_oldNu(pCellId) = s->a_nu(pCellId);
110 s->a_nu(pCellId) = (2.0 * tau - 1.0) * CSsq *
FPOW2(s->maxLevel() - s->a_level(pCellId)) / 2.0;
111 if constexpr(bubble) {
112 if(s->m_isEELiquid) {
113 if(s->m_cells.saveOldNu()) {
114 s->a_oldNuT(pCellId) = s->a_nuT(pCellId);
116 s->a_nuT(pCellId) = s->a_nu(pCellId) - s->m_nu - nu_BIT;
123static const LbRegSrcTerm<LbSrcTerm_smagorinsky<2, 9, LbSysEqnIncompressible<2, 9>,
false>>
124 reg_Smagorinskyd2q9(
"LB_SRC_SMAGORINSKY");
125static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 19, LbSysEqnIncompressible<3, 19>,
false>>
126 reg_Smagorinskyd3q19(
"LB_SRC_SMAGORINSKY");
127static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 27, LbSysEqnIncompressible<3, 27>,
false>>
128 reg_Smagorinskyd3q27(
"LB_SRC_SMAGORINSKY");
130static const LbRegSrcTerm<LbSrcTerm_smagorinsky<2, 9, LbSysEqnIncompressible<2, 9>,
true>>
131 reg_SmagorinskydBubble2q9(
"LB_SRC_SMAGORINSKY_BUBBLE");
132static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 19, LbSysEqnIncompressible<3, 19>,
true>>
133 reg_SmagorinskydBubble3q19(
"LB_SRC_SMAGORINSKY_BUBBLE");
134static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 27, LbSysEqnIncompressible<3, 27>,
true>>
135 reg_SmagorinskydBubble3q27(
"LB_SRC_SMAGORINSKY_BUBBLE");
137static const LbRegSrcTerm<LbSrcTerm_smagorinsky<2, 9, LbSysEqnCompressible<2, 9>,
false>>
138 reg_Smagorinskyd2q9C(
"LB_SRC_SMAGORINSKY");
139static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 19, LbSysEqnCompressible<3, 19>,
false>>
140 reg_Smagorinskyd3q19C(
"LB_SRC_SMAGORINSKY");
141static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 27, LbSysEqnCompressible<3, 27>,
false>>
142 reg_Smagorinskyd3q27C(
"LB_SRC_SMAGORINSKY");
144static const LbRegSrcTerm<LbSrcTerm_smagorinsky<2, 9, LbSysEqnCompressible<2, 9>,
true>>
145 reg_SmagorinskydBubble2q9C(
"LB_SRC_SMAGORINSKY_BUBBLE");
146static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 19, LbSysEqnCompressible<3, 19>,
true>>
147 reg_SmagorinskydBubble3q19C(
"LB_SRC_SMAGORINSKY_BUBBLE");
148static const LbRegSrcTerm<LbSrcTerm_smagorinsky<3, 27, LbSysEqnCompressible<3, 27>,
true>>
149 reg_SmagorinskydBubble3q27C(
"LB_SRC_SMAGORINSKY_BUBBLE");
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
This class represents all LB models.
constexpr SysEqn sysEqn() const
Class to handle sub-grid scale model (Smagorinsky)
LbSrcTerm_smagorinsky(LbSolverDxQy< nDim, nDist, SysEqn > *p_solver)
MFloat m_Cs
Smagorinsky constant.
void apply_preCollision() override
LbSolverDxQy< nDim, nDist, SysEqn > * m_solver
void readProperties() override
void apply_postPropagation() override
const MFloat m_deltaX
Filter width.
void apply_postCollision() override
Abstract class for lb source terms.
constexpr Real POW2(const Real x)
constexpr MFloat FPOW2(MInt x)
constexpr MFloat FFPOW2(MInt x)
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)