23template <MInt nDim, MInt nDist,
class SysEqn>
52template <MInt nDim, MInt nDist,
class SysEqn>
55 const MInt solverId = m_solver->m_solverId;
57 m_model = Context::getSolverProperty<MString>(
"nonNewtonianModel", solverId, AT_);
61 m_nu0 = m_solver->m_nu;
62 const MFloat nu0 = Context::getSolverProperty<MFloat>(
"nu0", solverId, AT_);
63 const MFloat c_nu = nu0 / m_nu0;
65 const MFloat nuInf = Context::getSolverProperty<MFloat>(
"nuInf", solverId, AT_);
66 m_nuInf = nuInf / c_nu;
68 const MFloat lambda = Context::getSolverProperty<MFloat>(
"lambda", solverId, AT_);
70 m_lambda = lambda * m_solver->m_referenceLength / (m_solver->m_Ma * LBCS);
72 m_n = Context::getSolverProperty<MFloat>(
"nonNewtonian_n", solverId, AT_);
73 m_a = Context::getSolverProperty<MFloat>(
"nonNewtonian_a", solverId, AT_);
78 m_n = Context::getSolverProperty<MFloat>(
"nonNewtonian_n", solverId, AT_);
80 m_solver->m_nu = pow(m_solver->m_Ma * LBCS, F2 - m_n) / m_solver->m_Re * pow(m_solver->m_referenceLength, m_n);
81 m_nu0 = m_solver->m_nu;
86 mTerm(1, AT_,
"This is not an implemented model!!!");
91template <MInt nDim, MInt nDist,
class SysEqn>
96 s.m_nu = s.m_Ma * LBCS / s.m_Re * s.m_referenceLength;
98 const MInt pCellId = s.m_activeCellList[index];
99 const MInt lvlDiff = s.maxLevel() - s.a_level(pCellId);
100 if((globalTimeStep - 1) % IPOW2(lvlDiff) != 0) return;
102 constexpr MInt nDimSqr = nDim * nDim;
103 std::array<MFloat, nDimSqr> c{};
104 const MFloat rho = s.a_variable(pCellId, s.PV->RHO);
105#ifndef WAR_NVHPC_PSTL
106 const MFloat*
const u = &s.a_variable(pCellId, s.PV->U);
107 const MFloat*
const dist = &s.a_oldDistribution(pCellId, 0);
108 s.
sysEqn().calcMomentumFlux(rho, u,
dist, c.data());
112 for(
MInt d = 0; d < nDim; d++) {
113 u[d] = s.a_variable(pCellId, d);
115 for(
MInt d = 0; d < nDist; d++) {
116 dist[d] = s.a_oldDistribution(pCellId, d);
118 s.
sysEqn().calcMomentumFlux(rho, u,
dist, c.data());
122 std::array<MFloat, nDimSqr> localS{};
125 MInt noIterations = 0;
126 MBool converged =
false;
127 MFloat nuOld = s.a_oldNu(pCellId);
128 const MFloat F1Brho = F1 / rho;
129 while(!converged && noIterations < 50) {
130 MFloat omega = F2 / (F6 * nuOld * FFPOW2(lvlDiff) + F1);
131 for(MInt d = 0; d < nDimSqr; d++) {
132 localS[d] = -F3B2 * omega * F1Brho * c[d];
136 const MFloat volumeStrains = F1B3 * (localS[0] + localS[4] + localS[8]);
137 localS[0] -= volumeStrains;
138 localS[4] -= volumeStrains;
139 localS[8] -= volumeStrains;
144 for(
MInt d = 0; d < nDimSqr; d++) {
145 D += localS[d] * localS[d];
147 const MFloat gamma_dot = sqrt(F2 * D);
149 nu = (this->*m_getNuFromNonNewtonianModel)(gamma_dot);
151 if(fabs(nuOld - nu) < 1e-10) converged =
true;
157 s.a_nu(pCellId) = nu;
161template <MInt nDim, MInt nDist,
class SysEqn>
166 const MFloat exp = m_n - F1;
167 const MFloat base = gamma_dot;
168 const MFloat nu = m_nu0 * (pow(base, exp));
173template <MInt nDim, MInt nDist,
class SysEqn>
178 const MFloat exp = (m_n - F1) / m_a;
179 const MFloat base = pow(m_lambda * gamma_dot, m_a) + F1;
180 const MFloat nu = m_nuInf + (m_nu0 - m_nuInf) * (pow(base, exp));
187 reg_nonNewtoniand2q9(
"LB_SRC_NONNEWTONIAN");
189 reg_nonNewtoniand3q19(
"LB_SRC_NONNEWTONIAN");
191 reg_nonNewtoniand3q27(
"LB_SRC_NONNEWTONIAN");
193 reg_nonNewtoniand2q9C(
"LB_SRC_NONNEWTONIAN");
195 reg_nonNewtoniand3q19C(
"LB_SRC_NONNEWTONIAN");
197 reg_nonNewtoniand3q27C(
"LB_SRC_NONNEWTONIAN");
This class represents all LB models.
constexpr SysEqn sysEqn() const
Class for registering a source term to the factory registry.
Class to handle non-newtonian fluids.
MFloat carreau(const MFloat gamma_dot)
LbSrcTerm_nonnewtonian(LbSolverDxQy< nDim, nDist, SysEqn > *p_solver)
void readProperties() override
MFloat(LbSrcTerm_nonnewtonian::* m_getNuFromNonNewtonianModel)(const MFloat gamma_dot)
MFloat powerLaw(const MFloat gamma_dot)
LbSolverDxQy< nDim, nDist, SysEqn > * m_solver
void apply_preCollision() override
void apply_postCollision() override
void apply_postPropagation() override
Abstract class for lb source terms.
MInt string2enum(MString theString)
This global function translates strings in their corresponding enum values (integer values)....
void mTerm(const MInt errorCode, const MString &location, const MString &message)
std::basic_string< char > MString
void parallelFor(MInt begin, MInt end, UnaryFunction &&f)
Wrapper function for parallel for loop.
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)