OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::BlockD< T, DESCRIPTOR > Class Template Referenceabstract

#include <blockD.h>

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

Public Member Functions

 BlockD (Vector< int, DESCRIPTOR::d > size, int padding, Platform platform)
 
virtual ~BlockD ()
 
virtual void setProcessingContext (ProcessingContext)=0
 Set processing context.
 
virtual void resize (Vector< int, DESCRIPTOR::d > size)=0
 
Platform getPlatform () const
 Return platform used to process lattice.
 
template<Platform PLATFORM>
ConcreteBlockD< T, DESCRIPTOR, PLATFORM > & asConcrete ()
 
template<typename FIELD_TYPE >
bool hasData ()
 Return whether FIELD_TYPE is available / has been allocated.
 
template<typename FIELD_TYPE >
const auto & getData (FIELD_TYPE field=FIELD_TYPE{}) const
 Return abstract interface for concrete FIELD_TYPE data.
 
template<typename FIELD_TYPE >
auto & getData (FIELD_TYPE field=FIELD_TYPE{})
 Return abstract interface for concrete FIELD_TYPE data.
 
template<typename FIELD >
const auto & getField (FIELD field=FIELD{}) const
 Return abstract interface for FIELD array.
 
template<typename FIELD >
auto getField (LatticeR< DESCRIPTOR::d > loc) const
 Return value of FIELD at loc.
 
template<typename FIELD >
auto & getField (FIELD field=FIELD{})
 Return abstract interface for FIELD array.
 
template<typename FIELD >
void setField (LatticeR< DESCRIPTOR::d > loc, const FieldD< T, DESCRIPTOR, FIELD > &fieldD)
 Set FIELD to fieldD at loc.
 
template<typename FIELD >
void setParameter (FieldD< T, DESCRIPTOR, FIELD > value)
 Set value of parameter FIELD.
 
template<typename PARAMETER , typename FIELD >
void setParameter (AbstractFieldArrayD< T, DESCRIPTOR, FIELD > &fieldArray)
 
template<typename PARAMETER , Platform PLATFORM, typename FIELD >
void setParameter (FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > &fieldArray)
 
BlockLatticeRowView< T, DESCRIPTOR > get (std::size_t iCell)
 
template<typename OPERATOR >
void apply ()
 
virtual bool hasCommunicatable (std::type_index) const =0
 
virtual Communicatable & getCommunicatable (std::type_index)=0
 
- Public Member Functions inherited from olb::BlockStructureD< D >
 BlockStructureD (Vector< int, D > size, int padding=0)
 
 BlockStructureD ()
 
void resize (Vector< int, D > size)
 
auto getCore () const
 
int getNx () const
 Read only access to block width.
 
int getNy () const
 Read only access to block height.
 
int getNz () const
 Read only access to block height.
 
LatticeR< D > getExtent () const
 
int getPadding () const
 Read only access to padding.
 
std::size_t getNcells () const
 Get number of cells.
 
CellID getCellId (LatticeR< D > latticeR) const
 Get 1D cell ID.
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, CellID > getCellId (L... latticeR) const
 
LatticeR< D > getLatticeR (CellID iCell) const
 
CellDistance getNeighborDistance (LatticeR< D > dir) const
 Get 1D neighbor distance.
 
bool isInside (LatticeR< D > latticeR) const
 Return whether location is valid.
 
bool isInsideCore (LatticeR< D > latticeR) const
 Return whether location is inside core.
 
bool isPadding (LatticeR< D > latticeR) const
 Return whether location is valid.
 
bool isPadding (LatticeR< D > latticeR, int overlap) const
 
bool isPadding (CellID iCell) const
 
template<typename... L>
std::enable_if_t< sizeof...(L)==D, bool > isInside (L... latticeR) const
 
CellDistance getNeighborhoodRadius (LatticeR< D > latticeR) const
 Return maximum valid neighborhood sphere radius w.r.t. latticeR.
 
template<typename F >
void forSpatialLocations (F f) const
 
template<typename F >
void forSpatialLocationsParallel (F f) const
 
template<typename F >
void forSpatialLocations (LatticeR< D > min, LatticeR< D > max, F f) const
 
template<typename F >
void forCoreSpatialLocations (F f) const
 
template<typename F >
void forCellIndices (F f) const
 
- Public Member Functions inherited from olb::Serializable
virtual ~Serializable ()=default
 
virtual bool * getBlock (const std::size_t iBlock, std::size_t &sizeBlock, const bool loadingMode=false)=0
 Returns the address of the i-th block and its size.
 
virtual std::size_t getNblock () const =0
 Returns the number of blocks.
 
virtual std::size_t getSerializableSize () const =0
 Returns the binary size of the data to be saved.
 
template<bool includeLogOutputDir = true>
bool save (std::string fileName="", const bool enforceUint=false)
 Save Serializable into file fileName
 
template<bool includeLogOutputDir = true>
bool load (std::string fileName="", const bool enforceUint=false)
 Load Serializable from file fileName
 
bool save (std::uint8_t *buffer)
 Save Serializable into buffer of length getSerializableSize
 
bool load (const std::uint8_t *buffer)
 Load Serializable from buffer of length getSerializableSize
 
virtual void postLoad ()
 

Protected Member Functions

template<typename F >
auto dispatch (F &&f) const
 Calls f on concrete implementation of the BlockD interface.
 
template<typename F >
auto dispatch (F &&f)
 
- Protected Member Functions inherited from olb::Serializable
template<typename DataType >
void registerVar (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, const DataType &data, const size_t arrayLength=1) const
 Register primitive data types (int, double, ...) or arrays of those.
 
template<typename DataType >
void registerSerializableOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType &data, const bool loadingMode=false)
 Register Serializable object of constant size.
 
template<typename DataType >
void registerSerializablesOfConstSize (const std::size_t iBlock, std::size_t &sizeBlock, std::size_t &currentBlock, bool *&dataPtr, DataType *data, const size_t arrayLength, const bool loadingMode=false)
 Register an array of Serializable objects of constant size.
 

Protected Attributes

const Platform _platform
 
- Protected Attributes inherited from olb::BlockStructureD< D >
LatticeR< D > _core
 
LatticeR< D > _size
 
LatticeR< D > _projection
 
int _padding
 

Detailed Description

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

Definition at line 32 of file operator.h.

Constructor & Destructor Documentation

◆ BlockD()

template<typename T , typename DESCRIPTOR >
olb::BlockD< T, DESCRIPTOR >::BlockD ( Vector< int, DESCRIPTOR::d > size,
int padding,
Platform platform )

Definition at line 33 of file blockD.hh.

34 : BlockStructure<DESCRIPTOR>(size, padding),
35 _platform(platform)
36{ }
const Platform _platform
Definition blockD.h:114
BlockStructureD< DESCRIPTOR::d > BlockStructure

◆ ~BlockD()

template<typename T , typename DESCRIPTOR >
olb::BlockD< T, DESCRIPTOR >::~BlockD ( )
virtual

Definition at line 39 of file blockD.hh.

40{ }

Member Function Documentation

◆ apply()

template<typename T , typename DESCRIPTOR >
template<typename OPERATOR >
void olb::BlockD< T, DESCRIPTOR >::apply ( )
inline

Definition at line 235 of file blockD.h.

235 {
236 dispatch([&](auto* lattice) {
237 lattice->template apply<OPERATOR>();
238 });
239 }
auto dispatch(F &&f) const
Calls f on concrete implementation of the BlockD interface.
Definition blockD.h:118
void apply()
Definition blockD.h:235

References olb::BlockD< T, DESCRIPTOR >::apply(), and olb::BlockD< T, DESCRIPTOR >::dispatch().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ asConcrete()

template<typename T , typename DESCRIPTOR >
template<Platform PLATFORM>
ConcreteBlockD< T, DESCRIPTOR, PLATFORM > & olb::BlockD< T, DESCRIPTOR >::asConcrete ( )
inline

Definition at line 151 of file blockD.h.

151 {
152 if (auto* ptr = dynamic_cast<ConcreteBlockD<T,DESCRIPTOR,PLATFORM>*>(this)) [[likely]] {
153 return *ptr;
154 } else {
155 throw std::runtime_error("Invalid PLATFORM");
156 }
157 }

◆ dispatch() [1/2]

template<typename T , typename DESCRIPTOR >
template<typename F >
auto olb::BlockD< T, DESCRIPTOR >::dispatch ( F && f)
inlineprotected

Definition at line 125 of file blockD.h.

125 {
127 _platform,
128 this,
129 f);
130 }
auto callUsingConcretePlatform(Platform platform, typename CONCRETIZABLE::base_t *ptr, F f)
Dispatcher for concrete platform access.
Definition dispatch.h:41

References olb::BlockD< T, DESCRIPTOR >::_platform, and olb::callUsingConcretePlatform().

+ Here is the call graph for this function:

◆ dispatch() [2/2]

template<typename T , typename DESCRIPTOR >
template<typename F >
auto olb::BlockD< T, DESCRIPTOR >::dispatch ( F && f) const
inlineprotected

Calls f on concrete implementation of the BlockD interface.

Definition at line 118 of file blockD.h.

118 {
120 _platform,
121 this,
122 f);
123 }

References olb::BlockD< T, DESCRIPTOR >::_platform, and olb::callUsingConcretePlatform().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

template<typename T , typename DESCRIPTOR >
BlockLatticeRowView< T, DESCRIPTOR > olb::BlockD< T, DESCRIPTOR >::get ( std::size_t iCell)
inline

Definition at line 230 of file blockD.h.

230 {
231 return {*this, iCell};
232 }
+ Here is the caller graph for this function:

◆ getCommunicatable()

template<typename T , typename DESCRIPTOR >
virtual Communicatable & olb::BlockD< T, DESCRIPTOR >::getCommunicatable ( std::type_index )
pure virtual

◆ getData() [1/2]

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
auto & olb::BlockD< T, DESCRIPTOR >::getData ( FIELD_TYPE field = FIELD_TYPE{})
inline

Return abstract interface for concrete FIELD_TYPE data.

Definition at line 177 of file blockD.h.

177 {})
178 {
179 return *dispatch([&](auto* lattice) -> auto* {
180 return &(lattice->template getData<FIELD_TYPE>().asAbstract());
181 });
182 }
const auto & getData(FIELD_TYPE field=FIELD_TYPE{}) const
Return abstract interface for concrete FIELD_TYPE data.
Definition blockD.h:169

◆ getData() [2/2]

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
const auto & olb::BlockD< T, DESCRIPTOR >::getData ( FIELD_TYPE field = FIELD_TYPE{}) const
inline

Return abstract interface for concrete FIELD_TYPE data.

Definition at line 169 of file blockD.h.

169 {}) const
170 {
171 return *dispatch([&](const auto* lattice) -> const auto* {
172 return &(lattice->template getData<FIELD_TYPE>().asAbstract());
173 });
174 }

◆ getField() [1/3]

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
auto & olb::BlockD< T, DESCRIPTOR >::getField ( FIELD field = FIELD{})
inline

Return abstract interface for FIELD array.

Definition at line 199 of file blockD.h.

199 {})
200 {
201 return getData(Array<FIELD>{});
202 }

◆ getField() [2/3]

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
const auto & olb::BlockD< T, DESCRIPTOR >::getField ( FIELD field = FIELD{}) const
inline

Return abstract interface for FIELD array.

Definition at line 186 of file blockD.h.

186 {}) const
187 {
188 return getData(Array<FIELD>{});
189 }
+ Here is the caller graph for this function:

◆ getField() [3/3]

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
auto olb::BlockD< T, DESCRIPTOR >::getField ( LatticeR< DESCRIPTOR::d > loc) const
inline

Return value of FIELD at loc.

Definition at line 192 of file blockD.h.

193 {
194 return getField<FIELD>().get(this->getCellId(loc));
195 }
const auto & getField(FIELD field=FIELD{}) const
Return abstract interface for FIELD array.
Definition blockD.h:186
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.

References olb::BlockStructureD< D >::getCellId(), and olb::BlockD< T, DESCRIPTOR >::getField().

+ Here is the call graph for this function:

◆ getPlatform()

template<typename T , typename DESCRIPTOR >
Platform olb::BlockD< T, DESCRIPTOR >::getPlatform ( ) const
inline

Return platform used to process lattice.

Definition at line 146 of file blockD.h.

146 {
147 return _platform;
148 }

References olb::BlockD< T, DESCRIPTOR >::_platform.

◆ hasCommunicatable()

template<typename T , typename DESCRIPTOR >
virtual bool olb::BlockD< T, DESCRIPTOR >::hasCommunicatable ( std::type_index ) const
pure virtual

◆ hasData()

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
bool olb::BlockD< T, DESCRIPTOR >::hasData ( )
inline

Return whether FIELD_TYPE is available / has been allocated.

Definition at line 161 of file blockD.h.

161 {
162 return dispatch([&](const auto* lattice) -> bool {
163 return lattice->template hasData<FIELD_TYPE>();
164 });
165 }
bool hasData()
Return whether FIELD_TYPE is available / has been allocated.
Definition blockD.h:161

References olb::BlockD< T, DESCRIPTOR >::dispatch(), and olb::BlockD< T, DESCRIPTOR >::hasData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resize()

template<typename T , typename DESCRIPTOR >
virtual void olb::BlockD< T, DESCRIPTOR >::resize ( Vector< int, DESCRIPTOR::d > size)
pure virtual

◆ setField()

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
void olb::BlockD< T, DESCRIPTOR >::setField ( LatticeR< DESCRIPTOR::d > loc,
const FieldD< T, DESCRIPTOR, FIELD > & fieldD )
inline

Set FIELD to fieldD at loc.

Definition at line 205 of file blockD.h.

206 {
207 getField<FIELD>().set(this->getCellId(loc), fieldD);
208 }

References olb::BlockStructureD< D >::getCellId(), and olb::BlockD< T, DESCRIPTOR >::getField().

+ Here is the call graph for this function:

◆ setParameter() [1/3]

template<typename T , typename DESCRIPTOR >
template<typename PARAMETER , typename FIELD >
void olb::BlockD< T, DESCRIPTOR >::setParameter ( AbstractFieldArrayD< T, DESCRIPTOR, FIELD > & fieldArray)
inline

Definition at line 218 of file blockD.h.

218 {
219 dispatch([&](auto* lattice) {
220 lattice->template setParameter<PARAMETER>(fieldArray);
221 });
222 }
void setParameter(FieldD< T, DESCRIPTOR, FIELD > value)
Set value of parameter FIELD.
Definition blockD.h:212

References olb::BlockD< T, DESCRIPTOR >::dispatch(), and olb::BlockD< T, DESCRIPTOR >::setParameter().

+ Here is the call graph for this function:

◆ setParameter() [2/3]

template<typename T , typename DESCRIPTOR >
template<typename PARAMETER , Platform PLATFORM, typename FIELD >
void olb::BlockD< T, DESCRIPTOR >::setParameter ( FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & fieldArray)
inline

Definition at line 224 of file blockD.h.

224 {
225 dispatch([&](auto* lattice) {
226 lattice->template setParameter<PARAMETER>(fieldArray);
227 });
228 }

References olb::BlockD< T, DESCRIPTOR >::dispatch(), and olb::BlockD< T, DESCRIPTOR >::setParameter().

+ Here is the call graph for this function:

◆ setParameter() [3/3]

template<typename T , typename DESCRIPTOR >
template<typename FIELD >
void olb::BlockD< T, DESCRIPTOR >::setParameter ( FieldD< T, DESCRIPTOR, FIELD > value)
inline

Set value of parameter FIELD.

Definition at line 212 of file blockD.h.

212 {
213 dispatch([&](auto* lattice) {
214 lattice->template setParameter<FIELD>(value);
215 });
216 }

References olb::BlockD< T, DESCRIPTOR >::dispatch(), and olb::BlockD< T, DESCRIPTOR >::setParameter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setProcessingContext()

template<typename T , typename DESCRIPTOR >
virtual void olb::BlockD< T, DESCRIPTOR >::setProcessingContext ( ProcessingContext )
pure virtual

Set processing context.

This is currently used to trigger data transfers between host and GPU data for Platform::GPU_CUDA.

Implemented in olb::ConcreteBlockD< T, DESCRIPTOR, PLATFORM >, and olb::ConcreteBlockD< T, olb::descriptors::LATTICE_DESCRIPTOR< DESCRIPTOR >, PLATFORM >.

Member Data Documentation

◆ _platform

template<typename T , typename DESCRIPTOR >
const Platform olb::BlockD< T, DESCRIPTOR >::_platform
protected

Definition at line 114 of file blockD.h.


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