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

Highest-level interface to read-only Cell data. More...

#include <cell.h>

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

Public Types

using value_t = T
 
using descriptor_t = DESCRIPTOR
 

Public Member Functions

 ConstCell (const BlockLattice< T, DESCRIPTOR > &block, std::size_t iCell)
 
std::size_t getCellId () const
 Return memory ID of the currently represented cell.
 
void setCellId (std::size_t iCell)
 Jump to arbitrary cell memory ID.
 
bool operator== (ConstCell< T, DESCRIPTOR > &rhs) const
 
bool operator!= (ConstCell< T, DESCRIPTOR > &rhs) const
 
bool operator< (ConstCell< T, DESCRIPTOR > &rhs) const
 
bool operator<= (ConstCell< T, DESCRIPTOR > &rhs) const
 
ConstCell< T, DESCRIPTOR > neighbor (Vector< int, DESCRIPTOR::d > c) const
 
operator[] (unsigned iPop) const
 Read-only access to distribution functions.
 
template<typename FIELD >
auto getFieldPointer (FIELD field=FIELD()) const
 Return read-only field accessor.
 
template<typename FIELD >
auto getFieldComponent (unsigned iD) const
 Return copy of field component.
 
template<typename FIELD >
auto getField (FIELD field=FIELD()) const
 Return copy of descriptor-declared FIELD as a vector.
 
const Dynamics< T, DESCRIPTOR > * getDynamics () const
 Get a pointer to the dynamics.
 
template<typename FIELD >
void computeField (T *data) const
 Copy FIELD content to given memory location.
 
computeRho () const
 Compute particle density on the cell.
 
void computeU (T u[descriptors::d< DESCRIPTOR >()]) const
 Compute fluid velocity on the cell.
 
void computeJ (T j[descriptors::d< DESCRIPTOR >()]) const
 Compute fluid momentum (j = rho * u) on the cell.
 
void computeStress (T pi[util::TensorVal< DESCRIPTOR >::n]) const
 Compute components of the stress tensor on the cell.
 
void computeRhoU (T &rho, T u[descriptors::d< DESCRIPTOR >()]) const
 Compute fluid velocity and particle density on the cell.
 
void computeFeq (T fEq[descriptors::q< DESCRIPTOR >()]) const
 Compute equilibrium part of cell distribution.
 
void computeFneq (T fNeq[descriptors::q< DESCRIPTOR >()]) const
 Compute non-equilibrium part of cell distribution.
 
void computeAllMomenta (T &rho, T u[descriptors::d< DESCRIPTOR >()], T pi[util::TensorVal< DESCRIPTOR >::n]) const
 Compute all momenta on the celll, up to second order.
 

Protected Attributes

friend Cell< T, DESCRIPTOR >
 
std::size_t _iCell
 Memory ID of currently represented cell.
 
BlockLattice< T, DESCRIPTOR > & _block
 Underlying BlockLattice.
 
Vector< T *, DESCRIPTOR::q > _populations
 Pointers to population values of current cell.
 

Detailed Description

template<typename T, typename DESCRIPTOR>
class olb::ConstCell< T, DESCRIPTOR >

Highest-level interface to read-only Cell data.

Only use where access to the specific ConcreteBlockLattice resp. Dynamics information is not (yet) possible.

Definition at line 53 of file cell.h.

Member Typedef Documentation

◆ descriptor_t

template<typename T , typename DESCRIPTOR >
using olb::ConstCell< T, DESCRIPTOR >::descriptor_t = DESCRIPTOR

Definition at line 78 of file cell.h.

◆ value_t

template<typename T , typename DESCRIPTOR >
using olb::ConstCell< T, DESCRIPTOR >::value_t = T

Definition at line 77 of file cell.h.

Constructor & Destructor Documentation

◆ ConstCell()

template<typename T , typename DESCRIPTOR >
olb::ConstCell< T, DESCRIPTOR >::ConstCell ( const BlockLattice< T, DESCRIPTOR > & block,
std::size_t iCell )

Definition at line 43 of file cell.hh.

44 :
45 _iCell(iCell),
46 _block(const_cast<BlockLattice<T,DESCRIPTOR>&>(block)),
47 _populations{_block.getPopulationPointers(iCell)}
48{ }
BlockLattice< T, DESCRIPTOR > & _block
Underlying BlockLattice.
Definition cell.h:63
std::size_t _iCell
Memory ID of currently represented cell.
Definition cell.h:61
Vector< T *, DESCRIPTOR::q > _populations
Pointers to population values of current cell.
Definition cell.h:74

Member Function Documentation

◆ computeAllMomenta()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeAllMomenta ( T & rho,
T u[descriptors::d< DESCRIPTOR >()],
T pi[util::TensorVal< DESCRIPTOR >::n] ) const

Compute all momenta on the celll, up to second order.

Definition at line 259 of file cell.hh.

263{
264 getDynamics()->computeAllMomenta(self(), rho, u, pi);
265}
const Dynamics< T, DESCRIPTOR > * getDynamics() const
Get a pointer to the dynamics.
Definition cell.hh:168
+ Here is the caller graph for this function:

◆ computeFeq()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeFeq ( T fEq[descriptors::q< DESCRIPTOR >()]) const

Compute equilibrium part of cell distribution.

Definition at line 238 of file cell.hh.

239{
240 T rho{};
241 Vector<T,descriptors::d<DESCRIPTOR>()> u;
242 computeRhoU(rho, u.data());
243 const T uSqr = norm_squared(u);
244 for (int iPop=0; iPop < descriptors::q<DESCRIPTOR>(); ++iPop) {
245 fEq[iPop] = lbm<DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr);
246 }
247}
void computeRhoU(T &rho, T u[descriptors::d< DESCRIPTOR >()]) const
Compute fluid velocity and particle density on the cell.
Definition cell.hh:232
constexpr T norm_squared(const ScalarVector< T, D, IMPL > &a)
Squared euclidean vector norm.

References olb::norm_squared().

+ Here is the call graph for this function:

◆ computeField()

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
void olb::ConstCell< T, DESCRIPTOR >::computeField ( T * data) const

Copy FIELD content to given memory location.

Definition at line 181 of file cell.hh.

182{
183 auto field = getFieldPointer<FIELD>();
184 for (long unsigned int i=0; i < DESCRIPTOR::template size<FIELD>(); ++i) {
185 data[i] = field[i];
186 }
187}
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.

◆ computeFneq()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeFneq ( T fNeq[descriptors::q< DESCRIPTOR >()]) const

Compute non-equilibrium part of cell distribution.

Definition at line 250 of file cell.hh.

251{
252 T rho{};
253 T u[descriptors::d<DESCRIPTOR>()] { };
254 computeRhoU(rho, u);
255 lbm<DESCRIPTOR>::computeFneq(self(), fNeq, rho, u);
256}
static void computeFneq(CELL &cell, FNEQ &fNeq, const RHO &rho, const U &u) any_platform
Computation of non-equilibrium distribution.
Definition lbm.h:271

References olb::lbm< DESCRIPTOR >::computeFneq().

+ Here is the call graph for this function:

◆ computeJ()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeJ ( T j[descriptors::d< DESCRIPTOR >()]) const

Compute fluid momentum (j = rho * u) on the cell.

Definition at line 218 of file cell.hh.

219{
220 getDynamics()->computeJ(self(), j);
221}

◆ computeRho()

template<typename T , typename DESCRIPTOR >
T olb::ConstCell< T, DESCRIPTOR >::computeRho ( ) const

Compute particle density on the cell.

Definition at line 206 of file cell.hh.

207{
208 return getDynamics()->computeRho(self());
209}
+ Here is the caller graph for this function:

◆ computeRhoU()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeRhoU ( T & rho,
T u[descriptors::d< DESCRIPTOR >()] ) const

Compute fluid velocity and particle density on the cell.

Definition at line 232 of file cell.hh.

233{
234 getDynamics()->computeRhoU(self(), rho, u);
235}
+ Here is the caller graph for this function:

◆ computeStress()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeStress ( T pi[util::TensorVal< DESCRIPTOR >::n]) const

Compute components of the stress tensor on the cell.

Definition at line 224 of file cell.hh.

225{
226 T rho, u[descriptors::d<DESCRIPTOR>()];
227 getDynamics()->computeRhoU(self(), rho, u);
228 getDynamics()->computeStress(self(), rho, u, pi);
229}

◆ computeU()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::computeU ( T u[descriptors::d< DESCRIPTOR >()]) const

Compute fluid velocity on the cell.

Definition at line 212 of file cell.hh.

213{
214 getDynamics()->computeU(self(), u);
215}
+ Here is the caller graph for this function:

◆ getCellId()

template<typename T , typename DESCRIPTOR >
std::size_t olb::ConstCell< T, DESCRIPTOR >::getCellId ( ) const

Return memory ID of the currently represented cell.

Definition at line 51 of file cell.hh.

52{
53 return _iCell;
54}
+ Here is the caller graph for this function:

◆ getDynamics()

template<typename T , typename DESCRIPTOR >
const Dynamics< T, DESCRIPTOR > * olb::ConstCell< T, DESCRIPTOR >::getDynamics ( ) const

Get a pointer to the dynamics.

Definition at line 168 of file cell.hh.

169{
170 return _block.getDynamics(_iCell);
171}

◆ getField()

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
auto olb::ConstCell< T, DESCRIPTOR >::getField ( FIELD field = FIELD()) const

Return copy of descriptor-declared FIELD as a vector.

Definition at line 139 of file cell.hh.

140{
141 return _block.template getField<FIELD>().get(_iCell);
142}

◆ getFieldComponent()

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
auto olb::ConstCell< T, DESCRIPTOR >::getFieldComponent ( unsigned iD) const

Return copy of field component.

Definition at line 82 of file cell.hh.

83{
84 static_assert(descriptors::is_data_field<FIELD>::value,
85 "FIELD must be structured data field");
86 return _block.template getField<FIELD>()[iD][_iCell];
87}

◆ getFieldPointer()

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
auto olb::ConstCell< T, DESCRIPTOR >::getFieldPointer ( FIELD field = FIELD()) const

Return read-only field accessor.

Definition at line 64 of file cell.hh.

65{
66 static_assert(descriptors::is_data_field<FIELD>::value,
67 "FIELD must be structured data field");
68 return _block.template getField<FIELD>().getPointer(_iCell);
69}

◆ neighbor()

template<typename T , typename DESCRIPTOR >
ConstCell< T, DESCRIPTOR > olb::ConstCell< T, DESCRIPTOR >::neighbor ( Vector< int, DESCRIPTOR::d > c) const

Definition at line 90 of file cell.hh.

91{
92 return ConstCell<T,DESCRIPTOR>(_block, _iCell + _block.getNeighborDistance(c));
93}

◆ operator!=()

template<typename T , typename DESCRIPTOR >
bool olb::ConstCell< T, DESCRIPTOR >::operator!= ( ConstCell< T, DESCRIPTOR > & rhs) const

Definition at line 120 of file cell.hh.

121{
122 return getCellId() != rhs.getCellId();
123}
std::size_t getCellId() const
Return memory ID of the currently represented cell.
Definition cell.hh:51

◆ operator<()

template<typename T , typename DESCRIPTOR >
bool olb::ConstCell< T, DESCRIPTOR >::operator< ( ConstCell< T, DESCRIPTOR > & rhs) const

Definition at line 126 of file cell.hh.

127{
128 return getCellId() < rhs.getCellId();
129}

◆ operator<=()

template<typename T , typename DESCRIPTOR >
bool olb::ConstCell< T, DESCRIPTOR >::operator<= ( ConstCell< T, DESCRIPTOR > & rhs) const

Definition at line 132 of file cell.hh.

133{
134 return getCellId() <= rhs.getCellId();
135}

◆ operator==()

template<typename T , typename DESCRIPTOR >
bool olb::ConstCell< T, DESCRIPTOR >::operator== ( ConstCell< T, DESCRIPTOR > & rhs) const

Definition at line 114 of file cell.hh.

115{
116 return getCellId() == rhs.getCellId();
117}

◆ operator[]()

template<typename T , typename DESCRIPTOR >
T olb::ConstCell< T, DESCRIPTOR >::operator[] ( unsigned iPop) const

Read-only access to distribution functions.

Parameters
iPopindex of the accessed distribution function

Definition at line 102 of file cell.hh.

103{
104 return *_populations[iPop];
105}

◆ setCellId()

template<typename T , typename DESCRIPTOR >
void olb::ConstCell< T, DESCRIPTOR >::setCellId ( std::size_t iCell)
inline

Jump to arbitrary cell memory ID.

Caller is responsible that this is valid.

Definition at line 90 of file cell.h.

91 {
92 _iCell = iCell;
93 _populations = _block.getPopulationPointers(iCell);
94 }

References olb::ConstCell< T, DESCRIPTOR >::_block, olb::ConstCell< T, DESCRIPTOR >::_iCell, and olb::ConstCell< T, DESCRIPTOR >::_populations.

Member Data Documentation

◆ _block

template<typename T , typename DESCRIPTOR >
BlockLattice<T,DESCRIPTOR>& olb::ConstCell< T, DESCRIPTOR >::_block
protected

Underlying BlockLattice.

Definition at line 63 of file cell.h.

◆ _iCell

template<typename T , typename DESCRIPTOR >
std::size_t olb::ConstCell< T, DESCRIPTOR >::_iCell
protected

Memory ID of currently represented cell.

Definition at line 61 of file cell.h.

◆ _populations

template<typename T , typename DESCRIPTOR >
Vector<T*,DESCRIPTOR::q> olb::ConstCell< T, DESCRIPTOR >::_populations
protected

Pointers to population values of current cell.

Workaround to increase performance of post-processors, post-processing functors until they are ported to work on concrete lattices again (as is already the case for dynamics)

Validity of neighborhood accesses via these pointers not guaranteed (e.g. consider CPU_SIMD vs. CPU_SISD)

Definition at line 74 of file cell.h.

◆ Cell< T, DESCRIPTOR >

template<typename T , typename DESCRIPTOR >
friend olb::ConstCell< T, DESCRIPTOR >::Cell< T, DESCRIPTOR >
protected

Definition at line 58 of file cell.h.


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