27#ifndef STOCHASTIC_SGS_DYNAMICS_HH
28#define STOCHASTIC_SGS_DYNAMICS_HH
59template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
61 T omega_, T turbulenceInt_, T charU_, T smagoConst_, T dx_, T dt_)
63 turbulenceInt(turbulenceInt_),
64 smagoConst(smagoConst_),
66 preFactor(computePreFactor(omega_,smagoConst_) )
102template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
111 T drift = computeTimeScale(preFactor, rho, pi, smagoConst, X_lang_n);
112 T result = getRandBMTrans(cell, turbulenceInt, charU);
115 X_lang_n = getRandomWalk(cell, drift, result);
122 MOMENTA().computeAllMomenta(cell, rho, u, pi);
123 T newOmega = computeOmega(this->getOmega(), preFactor, rho, pi, X_lang_n);
126 T invM_S_SGS[DESCRIPTOR::q][DESCRIPTOR::q];
127 T rtSGS[DESCRIPTOR::q];
128 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
129 rtSGS[iPop] = DESCRIPTOR::S[iPop];
131 for (
int iPop = 0; iPop < DESCRIPTOR::shearIndexes; ++iPop) {
132 rtSGS[DESCRIPTOR::shearViscIndexes[iPop]] = newOmega;
134 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
135 for (
int jPop = 0; jPop < DESCRIPTOR::q; ++jPop) {
136 invM_S_SGS[iPop][jPop] = T();
137 for (
int kPop = 0; kPop < DESCRIPTOR::q; ++kPop) {
139 invM_S_SGS[iPop][jPop] += DESCRIPTOR::invM[iPop][kPop] *
151template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
154 this->setOmega(omega);
155 preFactor = computePreFactor(omega, smagoConst);
158template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
162 MOMENTA().computeAllMomenta(cell, rho, uTemp, pi);
163 T newOmega = computeOmega(this->getOmega(), preFactor, rho, pi, X_lang_n);
169template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
172 T turbulenceInt, T CharU )
178 T TKE_ini = 1.5*turbulenceInt*turbulenceInt*charU*charU;
180 static double n2 = 0.0;
181 static int n2_cached = 0;
185 x = 2.0*rand()/RAND_MAX - 1;
186 y = 2.0*rand()/RAND_MAX - 1;
195 double result = n1*velStDev + mean;
202 return n2*velStDev + mean;
208template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
236template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
241 T PiNeqNormSqr = pi[0]*pi[0] + 2.0*pi[1]*pi[1] + pi[2]*pi[2];
243 PiNeqNormSqr += pi[2]*pi[2] + pi[3]*pi[3] + 2*pi[4]*pi[4] +pi[5]*pi[5];
249 T diss_corr = smagoConst*smagoConst*PiNeqNorm*PiNeqNorm*PiNeqNorm*(1+ X_lang_n);
251 T tau= Const*
util::pow(( 1. / diss_corr ), 1./3.);
268template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
269T StochasticSGSdynamics<T,DESCRIPTOR,MOMENTA>::computePreFactor(T omega, T smagoConst)
271 return (T)smagoConst*smagoConst*descriptors::invCs2<T,DESCRIPTOR>()*descriptors::invCs2<T,DESCRIPTOR>()*2*
util::sqrt(2);
274template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
277 T PiNeqNormSqr = pi[0]*pi[0] + 2.0*pi[1]*pi[1] + pi[2]*pi[2];
279 PiNeqNormSqr += pi[2]*pi[2] + pi[3]*pi[3] + 2*pi[4]*pi[4] +pi[5]*pi[5];
283 T tau_mol = 1. /omega0;
285 T tau_turb = 0.5*(
util::sqrt(tau_mol*tau_mol+(preFactor*tau_eff*PiNeqNorm*(1+X_lang_n)))-tau_mol);
287 tau_eff = tau_mol+tau_turb;
288 T omega_new= 1./tau_eff;
Definition of a LB cell – header file.
Highest-level interface to Cell data.
void incrementStats(T rho, T uSqr)
Implementation of the MRT collision step with stochastic relaxation based on " A stochastic subgrid m...
virtual T getRandomWalk(Cell< T, DESCRIPTOR > &cell_, T drift_, T result_)
Get local Random number of BoxMüllertransform -> returns randBM.
virtual T getSmagorinskyOmega(Cell< T, DESCRIPTOR > &cell_, T X_lang_n_)
Get local smagorinsky relaxation parameter of the dynamics.
virtual CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell, LatticeStatistics< T > &statistics_)
virtual void setOmega(T omega_)
Set local relaxation parameter of the dynamics.
virtual T getRandBMTrans(Cell< T, DESCRIPTOR > &cell_, T turbulenceInt_, T charU_)
Get local Random number of BoxMüllertransform -> returns randBM.
StochasticSGSdynamics(T omega_, T turbulenceInt_, T charU_, T smagoConst_, T dx_=1, T dt_=1)
Constructor.
This object is a MRT LB dynamics as described in D.Yu et al.
Helper functions for the implementation of LB dynamics.
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
ADf< T, DIM > log(const ADf< T, DIM > &a)
cpu::simd::Pack< T > pow(cpu::simd::Pack< T > base, cpu::simd::Pack< T > exp)
bool nearZero(const ADf< T, DIM > &a)
Top level namespace for all of OpenLB.
MRT Dynamics with adjusted omega – header file.
Return value of any collision.
Dynamics constructed as a tuple of momenta, equilibrium and collision.
static V mrtSGSCollision(CELL &cell, const RHO &rho, const U &u, const OMEGA &omega, const INVM_S_SGS &invM_S_SGS)
MRT SGS collision step.
Compute number of elements of a symmetric d-dimensional tensor.
static constexpr int n
result stored in n
Set of functions commonly used in LB computations – header file.