OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
olb::opti::DualPorousBGKdynamics< 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::DualPorousBGKdynamics< T, DESCRIPTOR, MOMENTA >:
+ Collaboration diagram for olb::opti::DualPorousBGKdynamics< T, DESCRIPTOR, MOMENTA >:

Public Types

using MomentaF = typename MOMENTA::template type<DESCRIPTOR>
 
- 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
 

Public Member Functions

 DualPorousBGKdynamics (T omega_)
 Constructor.
 
virtual T computeEquilibrium (int iPop, T rho, const T u[DESCRIPTOR::d]) const
 Compute equilibrium distribution function.
 
virtual void computeRhoU (const T fPop[DESCRIPTOR::q], T &rho, T u[DESCRIPTOR::d]) const
 Compute moments.
 
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.
 

Detailed Description

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

Implementation of the dual BGK collision step with external force.

Definition at line 273 of file dualDynamics.h.

Member Typedef Documentation

◆ MomentaF

template<typename T , typename DESCRIPTOR , typename MOMENTA = momenta::BulkTuple>
using olb::opti::DualPorousBGKdynamics< T, DESCRIPTOR, MOMENTA >::MomentaF = typename MOMENTA::template type<DESCRIPTOR>

Definition at line 275 of file dualDynamics.h.

Constructor & Destructor Documentation

◆ DualPorousBGKdynamics()

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

303 : legacy::BasicDynamics<T,DESCRIPTOR,MOMENTA>(),
304 omega(omega_)
305{
306 this->getName() = "DualPorousBGKdynamics";
307 OLB_PRECONDITION( DESCRIPTOR::template provides<descriptors::POROSITY>() );
308}
#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::DualPorousBGKdynamics< T, DESCRIPTOR, MOMENTA >::collide ( Cell< T, DESCRIPTOR > & cell)
virtual

Collision step.

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

Definition at line 348 of file dualDynamics.h.

350{
351 // Revert for backwards-in-time propagation
352 cell.revert();
353
354 // Preparation
355 auto pop_f = cell.template getField<descriptors::F>();
356 auto dJdF = cell.template getFieldPointer<descriptors::DJDF>();
357 T d = cell.template getField<descriptors::POROSITY>();
358
359 // Forward density and velocity
360 T rho_f, u_f[DESCRIPTOR::d];
361 this->computeRhoU( pop_f.data(), rho_f, u_f);
362
363 // Adjoint equilibrium
364 T pheq[DESCRIPTOR::q];
365 for (int i=0; i < DESCRIPTOR::q; ++i) {
366 pheq[i] = T{0};
367 for (int j=0; j < DESCRIPTOR::q; ++j) {
368 T feq_j = computeEquilibrium(j, rho_f, u_f)
369 + descriptors::t<T,DESCRIPTOR>(j);
370 T dot_ij = T();
371 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
372 dot_ij += ( descriptors::c<DESCRIPTOR>(j,iD) - d*u_f[iD] )
373 * ( descriptors::c<DESCRIPTOR>(i,iD) - u_f[iD] );
374 }
375 pheq[i] += cell[j]*feq_j*( T{1} + descriptors::invCs2<T,DESCRIPTOR>()*d*dot_ij );
376 }
377 pheq[i] /= rho_f;
378 }
379
380 // Collision
381 for (int i=0; i < DESCRIPTOR::q; ++i) {
382 cell[i] = cell[i] - omega*( cell[i] - pheq[i] ) + dJdF[i];
383 }
384
385 // Statistics
386 T rho_phi, u_phi[DESCRIPTOR::d];
387 MomentaF().computeRhoU( cell, rho_phi, u_phi );
388 T uSqr_phi = util::normSqr<T,DESCRIPTOR::d>( u_phi );
389
390 // Undo revert
391 cell.revert();
392 return {rho_phi, uSqr_phi};
393}
typename MOMENTA::template type< DESCRIPTOR > MomentaF
virtual T computeEquilibrium(int iPop, T rho, const T u[DESCRIPTOR::d]) const
Compute equilibrium distribution function.
virtual void computeRhoU(const T fPop[DESCRIPTOR::q], T &rho, T u[DESCRIPTOR::d]) const
Compute moments.
constexpr int d() any_platform

References olb::dynamics::Tuple< T, DESCRIPTOR, MOMENTA, EQUILIBRIUM, COLLISION, COMBINATION_RULE >::computeRhoU(), 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::DualPorousBGKdynamics< 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 318 of file dualDynamics.h.

320{
321 // Compute equilibrium minus weights
322 // used in iniEquilibrium
323 return equilibrium<DESCRIPTOR>::secondOrder(iPop, rho, u);
324}
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:

◆ computeRhoU()

template<typename T , typename DESCRIPTOR , typename MOMENTA >
void olb::opti::DualPorousBGKdynamics< T, DESCRIPTOR, MOMENTA >::computeRhoU ( const T fPop[DESCRIPTOR::q],
T & rho,
T u[DESCRIPTOR::d] ) const
virtual

Compute moments.

Definition at line 328 of file dualDynamics.h.

330{
331 rho_f = T();
332 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
333 u_f[iD] = T();
334 }
335 for (int iPop=0; iPop < DESCRIPTOR::q; ++iPop) {
336 rho_f += fPop[iPop];
337 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
338 u_f[iD] += fPop[iPop]*descriptors::c<DESCRIPTOR>(iPop,iD);
339 }
340 }
341 rho_f += (T)1;
342 for (int iD=0; iD < DESCRIPTOR::d; ++iD) {
343 u_f[iD] /= rho_f;
344 }
345}

◆ defineRho()

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

Does nothing.

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

Definition at line 311 of file dualDynamics.h.

312{
313 // The meaning of this function is not clear. Please contact Julius.
314 throw std::bad_function_call();
315}

◆ getOmega()

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

Get local relaxation parameter of the dynamics.

Definition at line 396 of file dualDynamics.h.

397{
398 return omega;
399}

◆ setOmega()

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

Set local relaxation parameter of the dynamics.

Definition at line 402 of file dualDynamics.h.

403{
404 omega = omega_;
405}

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