OpenLB 1.8.1
Loading...
Searching...
No Matches
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.
 
const Dynamics< T, DESCRIPTOR > * getDynamics () const
 
bool isPadding () const
 
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
 
T 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.
 
template<typename FIELD >
void computeField (T *data) const
 Copy FIELD content to given memory location.
 
T 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<concepts::BaseType T, concepts::LatticeDescriptor 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 36 of file interface.h.

Member Typedef Documentation

◆ descriptor_t

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
using olb::ConstCell< T, DESCRIPTOR >::descriptor_t = DESCRIPTOR

Definition at line 79 of file cell.h.

◆ value_t

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
using olb::ConstCell< T, DESCRIPTOR >::value_t = T

Definition at line 78 of file cell.h.

Constructor & Destructor Documentation

◆ ConstCell()

template<concepts::BaseType T, concepts::LatticeDescriptor 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)),
48{ }
virtual Vector< T *, DESCRIPTOR::q > getPopulationPointers(CellID iCell)=0
Returns pointers to host-side population locations of iCell.
BlockLattice< T, DESCRIPTOR > & _block
Underlying BlockLattice.
Definition cell.h:64
std::size_t _iCell
Memory ID of currently represented cell.
Definition cell.h:62
Vector< T *, DESCRIPTOR::q > _populations
Pointers to population values of current cell.
Definition cell.h:75

Member Function Documentation

◆ computeAllMomenta()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 249 of file cell.hh.

253{
254 getDynamics()->computeAllMomenta(self(), rho, u, pi);
255}
const Dynamics< T, DESCRIPTOR > * getDynamics() const
Definition cell.hh:174
+ Here is the caller graph for this function:

◆ computeFeq()

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

Compute equilibrium part of cell distribution.

Definition at line 228 of file cell.hh.

229{
230 T rho{};
232 computeRhoU(rho, u.data());
233 const T uSqr = norm_squared(u);
234 for (int iPop=0; iPop < descriptors::q<DESCRIPTOR>(); ++iPop) {
235 fEq[iPop] = lbm<DESCRIPTOR>::equilibrium(iPop, rho, u, uSqr);
236 }
237}
void computeRhoU(T &rho, T u[descriptors::d< DESCRIPTOR >()]) const
Compute fluid velocity and particle density on the cell.
Definition cell.hh:222
constexpr T norm_squared(const ScalarVector< T, D, IMPL > &a) any_platform
Squared euclidean vector norm.
Vector(T &&t, Ts &&... ts) -> Vector< std::remove_cvref_t< T >, 1+sizeof...(Ts)>

References olb::norm_squared(), and olb::Vector().

+ Here is the call graph for this function:

◆ computeField()

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

Copy FIELD content to given memory location.

Definition at line 187 of file cell.hh.

188{
190 for (long unsigned int i=0; i < DESCRIPTOR::template size<FIELD>(); ++i) {
191 data[i] = field[i];
192 }
193}
auto getFieldPointer(FIELD field=FIELD()) const
Return read-only field accessor.
Definition cell.hh:64
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.

◆ computeFneq()

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

Compute non-equilibrium part of cell distribution.

Definition at line 240 of file cell.hh.

241{
242 T rho{};
244 computeRhoU(rho, u);
245 lbm<DESCRIPTOR>::computeFneq(self(), fNeq, rho, u);
246}
constexpr int d() any_platform
Definition functions.h:127
static void computeFneq(CELL &cell, FNEQ &fNeq, const RHO &rho, const U &u) any_platform
Computation of non-equilibrium distribution.
Definition lbm.h:353

References olb::lbm< DESCRIPTOR >::computeFneq(), and olb::descriptors::d().

+ Here is the call graph for this function:

◆ computeJ()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 208 of file cell.hh.

209{
210 getDynamics()->computeJ(self(), j);
211}

◆ computeRho()

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
T olb::ConstCell< T, DESCRIPTOR >::computeRho ( ) const

Compute particle density on the cell.

Definition at line 196 of file cell.hh.

197{
198 return getDynamics()->computeRho(self());
199}

◆ computeRhoU()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 222 of file cell.hh.

223{
224 getDynamics()->computeRhoU(self(), rho, u);
225}
+ Here is the caller graph for this function:

◆ computeStress()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 214 of file cell.hh.

215{
216 T rho, u[descriptors::d<DESCRIPTOR>()];
217 getDynamics()->computeRhoU(self(), rho, u);
218 getDynamics()->computeStress(self(), rho, u, pi);
219}

References olb::descriptors::d().

+ Here is the call graph for this function:

◆ computeU()

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

Compute fluid velocity on the cell.

Definition at line 202 of file cell.hh.

203{
204 getDynamics()->computeU(self(), u);
205}

◆ getCellId()

template<concepts::BaseType T, concepts::LatticeDescriptor 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<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
const Dynamics< T, DESCRIPTOR > * olb::ConstCell< T, DESCRIPTOR >::getDynamics ( ) const

Definition at line 174 of file cell.hh.

175{
176 return _block.getDynamics(_iCell);
177}
virtual Dynamics< T, DESCRIPTOR > * getDynamics(CellID iCell)=0
Return pointer to dynamics at iCell.

◆ getField()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 145 of file cell.hh.

146{
147 return _block.template getField<FIELD>().get(_iCell);
148}
Cell< T, DESCRIPTOR > get(CellID iCell)
Get Cell interface for index iCell.
auto getField(FIELD field=FIELD()) const
Return copy of descriptor-declared FIELD as a vector.
Definition cell.hh:145

◆ getFieldComponent()

template<concepts::BaseType T, concepts::LatticeDescriptor 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<concepts::BaseType T, concepts::LatticeDescriptor 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}

◆ isPadding()

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
bool olb::ConstCell< T, DESCRIPTOR >::isPadding ( ) const
inline

Definition at line 99 of file cell.h.

99 {
100 return _block.isPadding(_iCell);
101 }
bool isPadding(LatticeR< D > latticeR) const
Return whether location is valid.

References olb::ConstCell< T, DESCRIPTOR >::_block, olb::ConstCell< T, DESCRIPTOR >::_iCell, and olb::BlockStructureD< D >::isPadding().

+ Here is the call graph for this function:

◆ neighbor()

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

Definition at line 90 of file cell.hh.

91{
93}
CellDistance getNeighborDistance(LatticeR< D > dir) const
Get 1D neighbor distance.
ConstCell(const BlockLattice< T, DESCRIPTOR > &block, std::size_t iCell)
Definition cell.hh:43

◆ operator!=()

template<concepts::BaseType T, concepts::LatticeDescriptor 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}
std::size_t getCellId() const
Return memory ID of the currently represented cell.
Definition cell.hh:51

References olb::ConstCell< T, DESCRIPTOR >::getCellId().

+ Here is the call graph for this function:

◆ operator<()

template<concepts::BaseType T, concepts::LatticeDescriptor 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}

References olb::ConstCell< T, DESCRIPTOR >::getCellId().

+ Here is the call graph for this function:

◆ operator<=()

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

Definition at line 138 of file cell.hh.

139{
140 return getCellId() <= rhs.getCellId();
141}

References olb::ConstCell< T, DESCRIPTOR >::getCellId().

+ Here is the call graph for this function:

◆ operator==()

template<concepts::BaseType T, concepts::LatticeDescriptor 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}

References olb::ConstCell< T, DESCRIPTOR >::getCellId().

+ Here is the call graph for this function:

◆ operator[]()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 108 of file cell.hh.

109{
110 return *_populations[iPop];
111}

◆ setCellId()

template<concepts::BaseType T, concepts::LatticeDescriptor 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 91 of file cell.h.

92 {
93 _iCell = iCell;
95 }

References olb::ConstCell< T, DESCRIPTOR >::_block, olb::ConstCell< T, DESCRIPTOR >::_iCell, olb::ConstCell< T, DESCRIPTOR >::_populations, and olb::BlockLattice< T, DESCRIPTOR >::getPopulationPointers().

+ Here is the call graph for this function:

Member Data Documentation

◆ _block

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
BlockLattice<T,DESCRIPTOR>& olb::ConstCell< T, DESCRIPTOR >::_block
protected

Underlying BlockLattice.

Definition at line 64 of file cell.h.

◆ _iCell

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
std::size_t olb::ConstCell< T, DESCRIPTOR >::_iCell
protected

Memory ID of currently represented cell.

Definition at line 62 of file cell.h.

◆ _populations

template<concepts::BaseType T, concepts::LatticeDescriptor 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 75 of file cell.h.

◆ Cell< T, DESCRIPTOR >

template<concepts::BaseType T, concepts::LatticeDescriptor DESCRIPTOR>
friend olb::ConstCell< T, DESCRIPTOR >::Cell< T, DESCRIPTOR >
protected

Definition at line 59 of file cell.h.


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