28#ifndef RTLBM_DYNAMICS_HH
29#define RTLBM_DYNAMICS_HH
43template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
45(T latticeAbsorption, T latticeScattering, std::array<std::array<T,DESCRIPTOR::q>, DESCRIPTOR::q>& anisoMatrix)
46 : legacy::BasicDynamics<T, DESCRIPTOR, MOMENTA>(), _absorption(latticeAbsorption), _scattering(latticeScattering), _anisoMatrix(anisoMatrix)
48 this->
getName() =
"RTLBMdynamicsMcHardy";
51template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
54 return rho*descriptors::t<T,DESCRIPTOR>(iPop) - descriptors::t<T,DESCRIPTOR>(iPop);
58template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
61 std::array<double, DESCRIPTOR::q> feq = {};
62 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop ) {
63 for (
int jPop = 0; jPop < DESCRIPTOR::q; ++jPop ) {
64 feq[iPop] += (cell[jPop] + descriptors::t<T,DESCRIPTOR>(jPop)) * _anisoMatrix[jPop][iPop];
66 feq[iPop] *= descriptors::t<T,DESCRIPTOR>(iPop);
69 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
70 cell[iPop] = (cell[iPop]+descriptors::t<T,DESCRIPTOR>(iPop))
71 - descriptors::norm_c<T,DESCRIPTOR>(iPop)*(_absorption+_scattering) * ( (cell[iPop]+descriptors::t<T,DESCRIPTOR>(iPop))- feq[iPop] )
72 - _absorption*descriptors::norm_c<T,DESCRIPTOR>(iPop) *(cell[iPop]+descriptors::t<T,DESCRIPTOR>(iPop))
73 - descriptors::t<T,DESCRIPTOR>(iPop);
79template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
85template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
91template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
93(T latticeAbsorption, T latticeScattering, std::array<std::array<T,DESCRIPTOR::q>, DESCRIPTOR::q>& anisoMatrix)
94 : legacy::BasicDynamics<T, DESCRIPTOR, MOMENTA>(), _absorption(latticeAbsorption), _scattering(latticeScattering), _anisoMatrix(anisoMatrix)
96 this->
getName() =
"RTLBMdynamicsMcHardyRK";
99template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
102 return rho*descriptors::t<T,DESCRIPTOR>(iPop) - descriptors::t<T,DESCRIPTOR>(iPop);
105template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
109 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop ) {
110 for (
int jPop = 0; jPop < DESCRIPTOR::q; ++jPop ) {
111 feq[iPop] += cell[jPop] * _anisoMatrix[jPop][iPop];
113 feq[iPop] *= descriptors::t<T,DESCRIPTOR>(iPop);
117template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
118std::array<T,DESCRIPTOR::q> RTLBMdynamicsMcHardyRK<T,DESCRIPTOR,MOMENTA>::doCollision(Cell<T,DESCRIPTOR>& cell, std::array<T,DESCRIPTOR::q>& feq)
120 std::array<T,DESCRIPTOR::q> k;
121 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
122 k[iPop] = - descriptors::norm_c<T,DESCRIPTOR>(iPop)*(_absorption+_scattering) * (cell[iPop])
123 + descriptors::norm_c<T,DESCRIPTOR>(iPop)*_scattering * feq[iPop];
128template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
131 std::array<T,DESCRIPTOR::q> feq;
132 std::array<T,DESCRIPTOR::q> f_pre_collision;
134 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop ) {
135 f_pre_collision[iPop] = cell[iPop] + descriptors::t<T,DESCRIPTOR>(iPop);
139 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop ) {
140 cell[iPop] += descriptors::t<T,DESCRIPTOR>(iPop);
142 computeEquilibriumAniso(cell,feq);
143 std::array<T,DESCRIPTOR::q> k1 = doCollision(cell,feq);
145 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
146 cell[iPop] = f_pre_collision[iPop] + 0.5*k1[iPop];
149 computeEquilibriumAniso(cell,feq);
150 std::array<T,DESCRIPTOR::q> k2 = doCollision(cell,feq);
152 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
153 cell[iPop] = f_pre_collision[iPop] + 0.5*k2[iPop];
156 computeEquilibriumAniso(cell,feq);
157 std::array<T,DESCRIPTOR::q> k3 = doCollision(cell,feq);
159 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
160 cell[iPop] = f_pre_collision[iPop] + k3[iPop];
163 computeEquilibriumAniso(cell,feq);
164 std::array<T,DESCRIPTOR::q> k4 = doCollision(cell,feq);
166 for (
int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
167 cell[iPop] = f_pre_collision[iPop] + 1/6.*(k1[iPop] + 2*k2[iPop] + 2*k3[iPop] + k4[iPop])
168 - descriptors::t<T,DESCRIPTOR>(iPop);
174template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
180template<
typename T,
typename DESCRIPTOR,
typename MOMENTA>
Highest-level interface to Cell data.
void incrementStats(T rho, T uSqr)
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell, LatticeStatistics< T > &statistics) override
Collision step.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override
Compute equilibrium distribution function.
void setOmega(T omega)
Set local relaxation parameter of the dynamics.
RTLBMdynamicsMcHardyRK(T latticeAbsorption, T latticeScattering, std::array< std::array< T, DESCRIPTOR::q >, DESCRIPTOR::q > &anisoMatrix)
Constructor.
T getOmega() const
Get local relaxation parameter of the dynamics.
RTLBMdynamicsMcHardy(T latticeAbsorption, T latticeScattering, std::array< std::array< T, DESCRIPTOR::q >, DESCRIPTOR::q > &anisoMatrix)
Constructor.
CellStatistic< T > collide(Cell< T, DESCRIPTOR > &cell, LatticeStatistics< T > &statistics) override
Collision step.
T getOmega() const
Get local relaxation parameter of the dynamics.
T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d], T uSqr) const override
Compute equilibrium distribution function.
void setOmega(T omega)
Set local relaxation parameter of the dynamics.
Top level namespace for all of OpenLB.
A collection of radiative transport dynamics classes – header file.
Return value of any collision.
virtual std::string getName() const
Return human-readable name.
static V computeRho(CELL &cell) any_platform
Computation of density.