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

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

#include <dualDynamics.h>

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

Public Member Functions

 DualForcedBGKdynamics (T omega_)
 Constructor.
 
virtual T computeEquilibrium (int iPop, T rho, const T u[DESCRIPTOR::d]) const
 Compute equilibrium distribution function.
 
virtual CellStatistic< T > collide (Cell< T, DESCRIPTOR > &cell)
 Collision step.
 
virtual T getOmega () const
 Get local relaxation parameter of the dynamics.
 
virtual void setOmega (T omega_)
 Set local relaxation parameter of the dynamics.
 
virtual void defineRho (Cell< T, DESCRIPTOR > &cell, T rho)
 Does nothing.
 
- Public Member Functions inherited from olb::legacy::BasicDynamics< T, DESCRIPTOR, MOMENTA >
std::type_index id () override
 Expose unique type-identifier for RTTI.
 
AbstractParameters< T, DESCRIPTOR > & getParameters (BlockLattice< T, DESCRIPTOR > &block) override
 Parameters access for legacy post processors.
 
- Public Member Functions inherited from olb::dynamics::CustomCollision< T, DESCRIPTOR, MOMENTA >
void initialize (Cell< T, DESCRIPTOR > &cell) override
 Initialize dynamics-specific data for cell.
 
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 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 std::string getName () const
 Return human-readable name.
 
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::CustomCollision< T, DESCRIPTOR, MOMENTA >
using value_t = T
 
using descriptor_t = DESCRIPTOR
 
using MomentaF = typename MOMENTA::template type<DESCRIPTOR>
 
- Public Types inherited from olb::Dynamics< T, DESCRIPTOR >
using value_t = T
 
using descriptor_t = DESCRIPTOR
 

Detailed Description

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

Implementation of the dual BGK collision step with external force.

Definition at line 150 of file dualDynamics.h.

Constructor & Destructor Documentation

◆ DualForcedBGKdynamics()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
olb::opti::DualForcedBGKdynamics< T, DESCRIPTOR, MOMENTA >::DualForcedBGKdynamics ( 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 174 of file dualDynamics.h.

176 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>(),
177 omega(omega_)
178{
179 this->getName() = "DualForcedBGKdynamics";
180 OLB_PRECONDITION( DESCRIPTOR::template provides<descriptors::FORCE>() );
181}
#define OLB_PRECONDITION(COND)
Definition olbDebug.h:46
virtual std::string getName() const
Return human-readable name.
Definition interface.h:63

References olb::Dynamics< T, DESCRIPTOR >::getName(), and OLB_PRECONDITION.

+ Here is the call graph for this function:

Member Function Documentation

◆ collide()

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

Collision step.

Reimplemented from olb::Dynamics< T, DESCRIPTOR >.

Definition at line 197 of file dualDynamics.h.

199{
200 cell.revert();
201
202 // Preparation
203 auto dJdF = cell.template getFieldPointer<descriptors::DJDF>();
204 auto f = cell.template getField<descriptors::F>();
205 auto force = cell.template getFieldPointer<descriptors::FORCE>();
206 T rho_f;
207 T u_f[DESCRIPTOR::d];
208
210 T eq_phi[DESCRIPTOR::q];
211 T force_phi[DESCRIPTOR::q];
212
213 // Force
214 T F1_phi[DESCRIPTOR::q][DESCRIPTOR::q];
215 T F2_phi[DESCRIPTOR::q][DESCRIPTOR::q];
216 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
217 T f_c = T();
218 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
219 f_c += force[iD]*descriptors::c<DESCRIPTOR>(iPop,iD);
220 }
221 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
222 T sum = T();
223 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
224 sum += (f_c*descriptors::c<DESCRIPTOR>(iPop,iD)-force[iD]/(T)descriptors::invCs2<T,DESCRIPTOR>())*descriptors::c<DESCRIPTOR>(jPop,iD);
225 }
226 F1_phi[iPop][jPop] = descriptors::t<T,DESCRIPTOR>(iPop)*descriptors::invCs2<T,DESCRIPTOR>()*f_c;
227 F2_phi[iPop][jPop] = descriptors::t<T,DESCRIPTOR>(iPop)*descriptors::invCs2<T,DESCRIPTOR>()*descriptors::invCs2<T,DESCRIPTOR>()*sum;
228 }
229 }
230
231 // Collision preperation
232 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
233 eq_phi[jPop] = T();
234 force_phi[jPop] = T();
235 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
236 eq_phi[jPop] += cell[iPop]*dualLbHelpers<T,DESCRIPTOR>::equilibrium(iPop, jPop, rho_f, u_f);
237 force_phi[jPop] += cell[iPop]*(F1_phi[iPop][jPop] + (1.-.5*omega)*F2_phi[iPop][jPop]);
238 }
239 }
240
241 // Collision
242 for (int jPop=0; jPop < DESCRIPTOR::q; ++jPop) {
243 cell[jPop] = cell[jPop] - omega*(cell[jPop]-eq_phi[jPop]) + force_phi[jPop] + dJdF[jPop];
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 cell.revert();
252
253 return {T(1) + cell[0], phi2};
254}
static void computeRhoU(T const *cell, T &rho, T u[DESCRIPTOR::d])
Computation of hydrodynamic variables.
static T equilibrium(int iPop, int jPop, T rho, const T u[DESCRIPTOR::d])

References olb::opti::dualLbDynamicsHelpers< T, DESCRIPTOR >::computeRhoU(), olb::opti::dualLbHelpers< T, DESCRIPTOR >::equilibrium(), and olb::Cell< T, DESCRIPTOR >::revert().

+ Here is the call graph for this function:

◆ computeEquilibrium()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
T olb::opti::DualForcedBGKdynamics< T, DESCRIPTOR, MOMENTA >::computeEquilibrium ( int iPop,
T rho,
const T u[DESCRIPTOR::d] ) const
virtual

Compute equilibrium distribution function.

Reimplemented from olb::legacy::BasicDynamics< T, DESCRIPTOR, MOMENTA >.

Definition at line 191 of file dualDynamics.h.

192{
193 return equilibrium<DESCRIPTOR>::secondOrder(iPop, rho, u);
194}
static V secondOrder(int iPop, const RHO &rho, const U &u, const USQR &uSqr) any_platform
Computation of equilibrium distribution, second order in u.
Definition lbm.h:51

References olb::equilibrium< DESCRIPTOR >::secondOrder().

+ Here is the call graph for this function:

◆ defineRho()

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

Does nothing.

Reimplemented from olb::dynamics::CustomCollision< T, DESCRIPTOR, MOMENTA >.

Definition at line 184 of file dualDynamics.h.

185{
186 // The meaning of this function is not clear. Please contact Julius.
187 throw std::bad_function_call();
188}

◆ getOmega()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
T olb::opti::DualForcedBGKdynamics< T, DESCRIPTOR, MOMENTA >::getOmega ( ) const
virtual

Get local relaxation parameter of the dynamics.

Definition at line 257 of file dualDynamics.h.

258{
259 return omega;
260}

◆ setOmega()

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

Set local relaxation parameter of the dynamics.

Definition at line 263 of file dualDynamics.h.

264{
265 omega = omega_;
266}

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