OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::opti::DualForcedMRTdynamics< T, DESCRIPTOR, MOMENTA > Class Template Reference

Implementation of the dual MRT collision step with external force. More...

#include <dualMrtDynamics.h>

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

Public Member Functions

 DualForcedMRTdynamics (T omega_)
 Constructor.
 
virtual CellStatistic< T > collide (Cell< T, DESCRIPTOR > &cell, LatticeStatistics< T > &statistics_)
 Collision step.
 
virtual void defineRho (Cell< T, DESCRIPTOR > &cell, T rho)
 Set particle density.
 
- 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<concepts::Cell CELL, concepts::Parameters PARAMETERS, concepts::BaseType V = typename CELL::value_t>
CellStatistic< V > collide (CELL &cell, PARAMETERS &parameters) any_platform
 Apply purely-local collision step to a generic CELL.
 
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.
 
void computeEquilibrium (ConstCell< T, DESCRIPTOR > &cell, T rho, const T u[DESCRIPTOR::d], T fEq[DESCRIPTOR::q]) const override
 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

- 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_T >
using exchange_value_type
 
template<typename NEW_MOMENTA >
using exchange_momenta
 
template<concepts::CombinationRule 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
 
- 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::opti::DualForcedMRTdynamics< T, DESCRIPTOR, MOMENTA >

Implementation of the dual MRT collision step with external force.

Definition at line 56 of file dualMrtDynamics.h.

Constructor & Destructor Documentation

◆ DualForcedMRTdynamics()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
olb::opti::DualForcedMRTdynamics< T, DESCRIPTOR, MOMENTA >::DualForcedMRTdynamics ( T omega_)

Constructor.

Parameters
omega_relaxation parameter, related to the dynamic viscosity
momenta_a Momenta object to know how to compute velocity momenta

Definition at line 79 of file dualMrtDynamics.h.

82{
83 T rt[DESCRIPTOR::q]; // relaxation times vector.
84 for (int iPop = 0; iPop < DESCRIPTOR::q; ++iPop) {
85 rt[iPop] = DESCRIPTOR::S[iPop];
86 }
87 for (int iPop = 0; iPop < DESCRIPTOR::shearIndexes; ++iPop) {
88 rt[DESCRIPTOR::shearViscIndexes[iPop]] = omega_;
89 }
90
91 T tmp[DESCRIPTOR::q][DESCRIPTOR::q];
92
93 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
94 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
95 Mt_S_M[iPop][jPop] = T();
96 Mt_S_invMt[iPop][jPop] = T();
97 invM_invMt[iPop][jPop] = T();
98 tmp[iPop][jPop] = T();
99 }
100 }
101
102 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
103 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
104 for (int kPop=0; kPop < DESCRIPTOR::q; ++kPop) {
105 if (jPop==kPop) {
106 tmp[iPop][jPop] += DESCRIPTOR::M[kPop][iPop]*rt[kPop];
107 }
108 }
109 }
110 }
111 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
112 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
113 for (int kPop=0; kPop < DESCRIPTOR::q; ++kPop) {
114 Mt_S_M[iPop][jPop] += tmp[iPop][kPop]**DESCRIPTOR::M[kPop][jPop];
115 Mt_S_invMt[iPop][jPop] += tmp[iPop][kPop]**DESCRIPTOR::invM[jPop][kPop];
116 invM_invMt[iPop][jPop] += DESCRIPTOR::invM[iPop][kPop]**DESCRIPTOR::invM[jPop][kPop];
117 }
118 }
119 }
120
121 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
122 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
123 //std::cout << Mt_S_M[iPop][jPop];
124 // std::cout <<Mt_S_invMt[iPop][jPop];
125 // std::cout <<invM_invMt[iPop][jPop];
126 //if (iPop == jPop) {
127 // Mt_S_M[iPop][jPop] = omega_;
128 // Mt_S_invMt[iPop][jPop] = omega_;
129 // invM_invMt[iPop][jPop] = 1.;
130 //}
131 }
132 }
133
134 OLB_PRECONDITION( DESCRIPTOR::template provides<descriptors::FORCE>() );
135}
dynamics::Tuple< T, DESCRIPTOR, MOMENTA, equilibria::SecondOrder, collision::MRT > MRTdynamics
Original implementation based on: D'Humieres et al., "Multiple-relaxation-time lattice Boltzmann mode...
Definition mrtDynamics.h:45
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46

References OLB_PRECONDITION.

Member Function Documentation

◆ collide()

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

Collision step.

Definition at line 149 of file dualMrtDynamics.h.

152{
153
154 cell.revert();
155
156
157 T rho_phi_x = T();
158 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
159 rho_phi_x += cell[iPop];
160 }
161
162 // Who am I?
163 T* ct = cell[DESCRIPTOR::q+3];
164 int c[3];
165 c[0] = (int)ct[0];
166 c[1] = (int)ct[1];
167 c[2] = (int)ct[2];
168
169
170
171 // Preparation
172 auto pop_f = cell.template getFieldPointer<opti::F>();
173 auto dJdF = cell.template getFieldPointer<opti::DJDF>();
174
175 T rho_f;
176 T u_f[3];
177 rho_f = T();
178 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
179 u_f[iD] = T();
180 }
181 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
182 rho_f += pop_f[iPop];
183 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
184 u_f[iD] += pop_f[iPop]*descriptors::c<DESCRIPTOR>(iPop,iD);
185 }
186 }
187 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
188 u_f[iD] /= rho_f;
189 }
190
191 // Computation of dual equillibrium
192 T Meq_phi[DESCRIPTOR::q][DESCRIPTOR::q];
193 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
194 T u_c = T();
195 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
196 u_c += u_f[iD]*descriptors::c<DESCRIPTOR>(iPop,iD);
197 }
198 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
199 T sum = T();
200 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
202 }
203 Meq_phi[iPop][jPop] = descriptors::t<T,DESCRIPTOR>(iPop)*(1.+sum);
204 }
205 }
206
207 // Computation of dual force
208 auto force = cell.template getFieldPointer<descriptors::FORCE>();
209 T F1_phi[DESCRIPTOR::q][DESCRIPTOR::q];
210 T F2_phi[DESCRIPTOR::q][DESCRIPTOR::q];
211 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
212 T f_c = T();
213 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
214 f_c += force[iD]*descriptors::c<DESCRIPTOR>(iPop,iD);
215 }
216 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
217 T sum = T();
218 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
220 }
223 }
224 }
225
226
227 // Computation of dual collision
228 T dualMRTcollision[DESCRIPTOR::q];
229 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
230 dualMRTcollision[iPop] = T();
231 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
232 T I=T();
233 if (iPop==jPop) {
234 I=T(1);
235 }
236 dualMRTcollision[iPop] += (I - (I - Meq_phi[jPop][iPop])*Mt_S_invMt[iPop][iPop] + F1_phi[jPop][iPop] + F2_phi[jPop][iPop]*(1. - 0.5*Mt_S_invMt[iPop][iPop]))*cell[jPop];
237 }
238 }
239
240
241 // Adding dirivitive of objective and writing back to cell
242 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
243 cell[iPop] = dualMRTcollision[iPop] + dJdF[iPop];
244 }
245
246 // Incrementing statistic values for convergence
247 T phi2 = T();
248 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
249 phi2 += cell[iPop]*cell[iPop];
250 }
251
252 statistics.incrementStats(1.0 + cell[0], phi2);
253 cell.revert();
254}
platform_constant int c[Q][D]
Definition functions.h:57
constexpr T invCs2() any_platform
Definition functions.h:107
constexpr T t(unsigned iPop, tag::CUM) any_platform
Definition cum.h:108
constexpr int c(unsigned iPop, unsigned iDim) any_platform
Definition functions.h:83

References olb::descriptors::c(), olb::LatticeStatistics< T >::incrementStats(), olb::descriptors::invCs2(), and olb::descriptors::t().

+ Here is the call graph for this function:

◆ defineRho()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
void olb::opti::DualForcedMRTdynamics< T, DESCRIPTOR, MOMENTA >::defineRho ( Cell< T, DESCRIPTOR > & cell,
T rho )
virtual

Set particle density.

Implements olb::Dynamics< T, DESCRIPTOR >.

Definition at line 138 of file dualMrtDynamics.h.

139{
140
141 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
142 cell[iPop]=rho;
143 }
144}

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