OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA > Class Template Reference

Implementation of the MRT collision step with stochastic relaxation based on " A stochastic subgrid model with application to turbulent flow and scalar mixing"; Phys. More...

#include <stochasticSGSdynamics.h>

+ Inheritance diagram for olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >:
+ Collaboration diagram for olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >:

Public Types

template<typename M >
using exchange_momenta = StochasticSGSdynamics<T,DESCRIPTOR,M>
 
- Public Types inherited from olb::dynamics::Tuple< T, DESCRIPTOR, MOMENTA, EQUILIBRIUM, COLLISION, COMBINATION_RULE >
using MomentaF = typename COMBINATION_RULE::template combined_momenta<DESCRIPTOR,MOMENTA>
 
using EquilibriumF = typename COMBINATION_RULE::template combined_equilibrium<DESCRIPTOR,MOMENTA,EQUILIBRIUM>
 
using CollisionO = typename COMBINATION_RULE::template combined_collision<DESCRIPTOR,MOMENTA,EQUILIBRIUM,COLLISION>
 
using parameters = typename COMBINATION_RULE::template combined_parameters<DESCRIPTOR,MOMENTA,EQUILIBRIUM,COLLISION>
 
template<typename NEW_MOMENTA >
using exchange_momenta
 
template<typename NEW_RULE >
using exchange_combination_rule
 
template<template< typename > typename WRAPPER>
using wrap_collision
 
- Public Types inherited from olb::Dynamics< T, DESCRIPTOR >
using value_t = T
 
using descriptor_t = DESCRIPTOR
 

Public Member Functions

 StochasticSGSdynamics (T omega_, T turbulenceInt_, T charU_, T smagoConst_, T dx_=1, T dt_=1)
 Constructor.
 
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 getSmagorinskyOmega (Cell< T, DESCRIPTOR > &cell_, T X_lang_n_)
 Get local smagorinsky 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.
 
virtual T getRandomWalk (Cell< T, DESCRIPTOR > &cell_, T drift_, T result_)
 Get local Random number of BoxMüllertransform -> returns randBM.
 
- Public Member Functions inherited from olb::dynamics::Tuple< T, DESCRIPTOR, MOMENTA, EQUILIBRIUM, COLLISION, COMBINATION_RULE >
std::type_index id () override
 Expose unique type-identifier for RTTI.
 
std::string getName () const override
 Return human-readable name.
 
template<typename FIELD >
constexpr bool hasParameter () const
 Return true iff FIELD is a parameter.
 
AbstractParameters< T, DESCRIPTOR > & getParameters (BlockLattice< T, DESCRIPTOR > &block) override
 Interim workaround for accessing dynamics parameters in legacy post processors.
 
void initialize (Cell< T, DESCRIPTOR > &cell) override
 Initialize MOMENTA-specific data for cell.
 
template<CONCEPT(MinimalCell) CELL, typename PARAMETERS , typename V = typename CELL::value_t>
CellStatistic< V > apply (CELL &cell, PARAMETERS &parameters) any_platform
 Apply purely-local collision step to a generic CELL.
 
computeEquilibrium (int iPop, T rho, const T u[DESCRIPTOR::d]) const override any_platform
 Return iPop equilibrium for given first and second momenta.
 
computeRho (ConstCell< T, DESCRIPTOR > &cell) const override
 Compute particle density.
 
void computeU (ConstCell< T, DESCRIPTOR > &cell, T u[DESCRIPTOR::d]) const override
 Compute fluid velocity.
 
void computeJ (ConstCell< T, DESCRIPTOR > &cell, T j[DESCRIPTOR::d]) const override
 Compute fluid momentum.
 
void computeStress (ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T pi[util::TensorVal< DESCRIPTOR >::n]) const override
 Compute stress tensor.
 
void computeRhoU (ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
 Compute fluid velocity and particle density.
 
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 defineRho (Cell< T, DESCRIPTOR > &cell, T rho) override
 Set particle density.
 
void defineU (Cell< T, DESCRIPTOR > &cell, const T u[DESCRIPTOR::d]) override
 Set fluid velocity.
 
void defineRhoU (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d]) override
 Define fluid velocity and particle density.
 
void defineAllMomenta (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n]) override
 Define all momenta up to second order.
 
void inverseShiftRhoU (ConstCell< T, DESCRIPTOR > &cell, T &rho, T u[DESCRIPTOR::d]) const override
 Calculate population momenta s.t. the physical momenta are reproduced by the computeRhoU.
 
- Public Member Functions inherited from olb::Dynamics< T, DESCRIPTOR >
virtual ~Dynamics () any_platform
 
virtual CellStatistic< T > collide (Cell< T, DESCRIPTOR > &cell)
 Perform purely-local collision step on Cell interface (legacy, to be deprecated)
 
void iniEquilibrium (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d])
 Initialize to equilibrium distribution.
 
void iniRegularized (Cell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], const T pi[util::TensorVal< DESCRIPTOR >::n])
 Initialize cell to equilibrium and non-equilibrum part.
 

Additional Inherited Members

- Static Public Attributes inherited from olb::dynamics::Tuple< T, DESCRIPTOR, MOMENTA, EQUILIBRIUM, COLLISION, COMBINATION_RULE >
static constexpr bool is_vectorizable = is_vectorizable_v<CollisionO>
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename MOMENTA = momenta::BulkTuple>
class olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >

Implementation of the MRT collision step with stochastic relaxation based on " A stochastic subgrid model with application to turbulent flow and scalar mixing"; Phys.

of Fluids 19; 2007

Definition at line 39 of file stochasticSGSdynamics.h.

Member Typedef Documentation

◆ exchange_momenta

template<typename T , typename DESCRIPTOR , typename MOMENTA = momenta::BulkTuple>
template<typename M >
using olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::exchange_momenta = StochasticSGSdynamics<T,DESCRIPTOR,M>

Definition at line 42 of file stochasticSGSdynamics.h.

Constructor & Destructor Documentation

◆ StochasticSGSdynamics()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::StochasticSGSdynamics ( T omega_,
T turbulenceInt_,
T charU_,
T smagoConst_,
T dx_ = 1,
T dt_ = 1 )

Constructor.

Implementation of the Stochastic relaxation based on " A stochastic subgrid model with application to turbulent flow and scalar mixing"; Phys.

of Fluids 19; 2007

Parameters
vs2_speed of sound
momenta_a Momenta object to know how to compute velocity momenta
momenta_a Momenta object to know how to compute velocity momenta

Definition at line 60 of file stochasticSGSdynamics.hh.

62 : MRTdynamics<T,DESCRIPTOR,MOMENTA>(omega_),
63 turbulenceInt(turbulenceInt_),
64 smagoConst(smagoConst_),
65 charU(charU_),
66 preFactor(computePreFactor(omega_,smagoConst_) )
67
68{
69
70 // T invM_S_SGS[DESCRIPTOR::q][DESCRIPTOR::q];
71 // T rtSGS[DESCRIPTOR::q]; // relaxation times vector for SGS approach.
72 // for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop)
73 // {
74 // rtSGS[iPop] = DESCRIPTOR::S[iPop];
75 // }
76 // for (int iPop = 0; iPop < DESCRIPTOR::shearIndexes; ++iPop)
77 // {
78 // rtSGS[DESCRIPTOR::shearViscIndexes[iPop]] = omega;
79 // }
80 // for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop)
81 // {
82 // for (int jPop = 0; jPop < DESCRIPTOR::q; ++jPop)
83 // {
84 // invM_S_SGS[iPop][jPop] = T();
85 // for (int kPop = 0; kPop < DESCRIPTOR::q; ++kPop)
86 // {
87 // if (kPop == jPop)
88 // {
89 // invM_S_SGS[iPop][jPop] += DESCRIPTOR::invM[iPop][kPop] *
90 // rtSGS[kPop];
91 // cout << "wert"<<iPop <<jPop << "= "<< invM_S_SGS[iPop][jPop]<< std::endl;
92 // }
93 // }
94 // }
95 // }
96 //
97
98
99}

Member Function Documentation

◆ collide()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
CellStatistic< T > olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::collide ( Cell< T, DESCRIPTOR > & cell,
LatticeStatistics< T > & statistics_ )
virtual

Definition at line 103 of file stochasticSGSdynamics.hh.

106{
107 T rho, u[DESCRIPTOR::d], pi[util::TensorVal<DESCRIPTOR >::n];
108
109
110
111 T drift = computeTimeScale(preFactor, rho, pi, smagoConst, X_lang_n);
112 T result = getRandBMTrans(cell, turbulenceInt, charU);
113
114 // cout << "vor neu setzen: "<<X_lang_n<< std::endl;
115 X_lang_n = getRandomWalk(cell, drift, result);
116 // cout << "nach neu setzen: "<<X_lang_n<< std::endl;
117 //cout << X_lang_n<< std::endl;
118 // cout << drift<< std::endl;
119 // cout << result<< std::endl;
120
121
122 MOMENTA().computeAllMomenta(cell, rho, u, pi);
123 T newOmega = computeOmega(this->getOmega(), preFactor, rho, pi, X_lang_n);
124
125
126 T invM_S_SGS[DESCRIPTOR::q][DESCRIPTOR::q];
127 T rtSGS[DESCRIPTOR::q]; // relaxation times vector for SGS approach.
128 for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
129 rtSGS[iPop] = DESCRIPTOR::S[iPop];
130 }
131 for (int iPop = 0; iPop < DESCRIPTOR::shearIndexes; ++iPop) {
132 rtSGS[DESCRIPTOR::shearViscIndexes[iPop]] = newOmega;
133 }
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) {
138 if (kPop == jPop) {
139 invM_S_SGS[iPop][jPop] += DESCRIPTOR::invM[iPop][kPop] *
140 rtSGS[kPop];
141 //cout << "wert"<<iPop <<jPop << "= "<< invM_S_SGS[iPop][jPop]<< std::endl;
142 }
143 }
144 }
145 }
146
147 T uSqr = mrt<DESCRIPTOR>::mrtSGSCollision(cell, rho, u, newOmega, invM_S_SGS);
148 statistics.incrementStats(rho, uSqr);
149}
virtual T getRandomWalk(Cell< T, DESCRIPTOR > &cell_, T drift_, T result_)
Get local Random number of BoxMüllertransform -> returns randBM.
virtual T getRandBMTrans(Cell< T, DESCRIPTOR > &cell_, T turbulenceInt_, T charU_)
Get local Random number of BoxMüllertransform -> returns randBM.
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.
Definition mrt.h:111
static constexpr int n
result stored in n
Definition util.h:211

References olb::LatticeStatistics< T >::incrementStats(), and olb::mrt< DESCRIPTOR >::mrtSGSCollision().

+ Here is the call graph for this function:

◆ getRandBMTrans()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
T olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::getRandBMTrans ( Cell< T, DESCRIPTOR > & cell_,
T turbulenceInt_,
T charU_ )
virtual

Get local Random number of BoxMüllertransform -> returns randBM.

Random number generator based on Box Müller transform to produuce random normal distributed numbers with zero mean and

Definition at line 170 of file stochasticSGSdynamics.hh.

173{
176
177 T mean = 0.;
178 T TKE_ini = 1.5*turbulenceInt*turbulenceInt*charU*charU;
179 T velStDev = util::sqrt(2./3.*TKE_ini);
180 static double n2 = 0.0;
181 static int n2_cached = 0;
182 if (!n2_cached) {
183 double x, y, r;
184 do {
185 x = 2.0*rand()/RAND_MAX - 1;
186 y = 2.0*rand()/RAND_MAX - 1;
187
188 r = x*x + y*y;
189 }
190 while ( util::nearZero(r) || r > 1.0);
191 {
192 double d = util::sqrt(-2.0*util::log(r)/r);
193 double n1 = x*d;
194 n2 = y*d;
195 double result = n1*velStDev + mean;
196 n2_cached = 1;
197 return result;
198 }
199 }
200 else {
201 n2_cached = 0;
202 return n2*velStDev + mean;
203 }
204}
constexpr int d() any_platform
cpu::simd::Pack< T > sqrt(cpu::simd::Pack< T > value)
Definition pack.h:100
ADf< T, DIM > log(const ADf< T, DIM > &a)
Definition aDiff.h:475
bool nearZero(const ADf< T, DIM > &a)
Definition aDiff.h:1087

References olb::util::log(), olb::util::nearZero(), and olb::util::sqrt().

+ Here is the call graph for this function:

◆ getRandomWalk()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
T olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::getRandomWalk ( Cell< T, DESCRIPTOR > & cell_,
T drift_,
T result_ )
virtual

Get local Random number of BoxMüllertransform -> returns randBM.

Create Random walk.

initialisation of model standard variation, see Pope pp 484

Definition at line 209 of file stochasticSGSdynamics.hh.

212{
214 T sigma = 2.3;
215 X_lang_n *=drift;
216
217 X_lang_n += sigma*util::sqrt(drift*2)*result;
218
219 return X_lang_n;
220
221
222}

References olb::util::sqrt().

+ Here is the call graph for this function:

◆ getSmagorinskyOmega()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
T olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::getSmagorinskyOmega ( Cell< T, DESCRIPTOR > & cell_,
T X_lang_n_ )
virtual

Get local smagorinsky relaxation parameter of the dynamics.

Definition at line 159 of file stochasticSGSdynamics.hh.

160{
161 T rho, uTemp[DESCRIPTOR::d], pi[util::TensorVal<DESCRIPTOR >::n];
162 MOMENTA().computeAllMomenta(cell, rho, uTemp, pi);
163 T newOmega = computeOmega(this->getOmega(), preFactor, rho, pi, X_lang_n);
164 return newOmega;
165}

◆ setOmega()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
void olb::StochasticSGSdynamics< T, DESCRIPTOR, MOMENTA >::setOmega ( T omega_)
virtual

Set local relaxation parameter of the dynamics.

Definition at line 152 of file stochasticSGSdynamics.hh.

153{
154 this->setOmega(omega);
155 preFactor = computePreFactor(omega, smagoConst);
156}
virtual void setOmega(T omega_)
Set local relaxation parameter of the dynamics.

The documentation for this class was generated from the following files: