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

Platform-indepentent interface to ConcreteData. More...

#include <data.h>

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

Public Member Functions

 Data (Platform platform)
 
virtual ~Data ()=default
 
virtual void setProcessingContext (ProcessingContext)=0
 Set processing context.
 
Platform getPlatform () const
 Return platform of concrete implementation.
 
template<typename FIELD_TYPE >
bool provides ()
 Return whether FIELD_TYPE is available / has been allocated.
 
template<typename FIELD_TYPE , typename... ARGS>
auto & allocate (ARGS &&... args)
 Allocate and return FIELD_TYPE data.
 
template<typename FIELD_TYPE >
const auto & get () const
 Return reference to data of FIELD_TYPE.
 
template<typename FIELD_TYPE >
auto & get ()
 Return reference to data of FIELD_TYPE.
 
virtual void resize (std::size_t newSize)=0
 
template<typename OPERATOR >
void apply ()
 
template<typename FIELD_TYPE >
void setSerialization (bool active)
 Sets FIELD_TYPE serialization state to active.
 
- 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 Data 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
 

Detailed Description

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

Platform-indepentent interface to ConcreteData.

Definition at line 319 of file data.h.

Constructor & Destructor Documentation

◆ Data()

template<typename T , typename DESCRIPTOR >
olb::Data< T, DESCRIPTOR >::Data ( Platform platform)
inline

Definition at line 340 of file data.h.

340 :
341 _platform{platform}
342 { }
const Platform _platform
Definition data.h:321

◆ ~Data()

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

Member Function Documentation

◆ allocate()

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE , typename... ARGS>
auto & olb::Data< T, DESCRIPTOR >::allocate ( ARGS &&... args)
inline

Allocate and return FIELD_TYPE data.

Must only be called once for each FIELD_TYPE

Definition at line 370 of file data.h.

370 {
371 return *dispatch([&](auto* data) {
372 return &(data->template allocate<FIELD_TYPE>(std::forward<ARGS&&>(args)...).asAbstract());
373 });
374 }
auto dispatch(F &&f) const
Calls f on concrete implementation of the Data interface.
Definition data.h:325
auto & allocate(ARGS &&... args)
Allocate and return FIELD_TYPE data.
Definition data.h:370

References olb::Data< T, DESCRIPTOR >::allocate(), and olb::Data< T, DESCRIPTOR >::dispatch().

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

◆ apply()

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

Definition at line 394 of file data.h.

394 {
395 dispatch([&](auto* data) {
396 data->template apply<OPERATOR>();
397 });
398 }
void apply()
Definition data.h:394

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

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

◆ dispatch() [1/2]

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

Definition at line 332 of file data.h.

332 {
334 _platform,
335 this,
336 f);
337 }
auto callUsingConcretePlatform(Platform platform, typename CONCRETIZABLE::base_t *ptr, F f)
Dispatcher for concrete platform access.
Definition dispatch.h:41

References olb::Data< 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::Data< T, DESCRIPTOR >::dispatch ( F && f) const
inlineprotected

Calls f on concrete implementation of the Data interface.

Definition at line 325 of file data.h.

325 {
327 _platform,
328 this,
329 f);
330 }

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

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

◆ get() [1/2]

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
auto & olb::Data< T, DESCRIPTOR >::get ( )
inline

Return reference to data of FIELD_TYPE.

Definition at line 385 of file data.h.

385 {
386 return *dispatch([&](auto* data) {
387 return &(data->template get<FIELD_TYPE>().asAbstract());
388 });
389 }
const auto & get() const
Return reference to data of FIELD_TYPE.
Definition data.h:378

References olb::Data< T, DESCRIPTOR >::dispatch(), and olb::Data< T, DESCRIPTOR >::get().

+ Here is the call graph for this function:

◆ get() [2/2]

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
const auto & olb::Data< T, DESCRIPTOR >::get ( ) const
inline

Return reference to data of FIELD_TYPE.

Definition at line 378 of file data.h.

378 {
379 return *dispatch([&](const auto* data) {
380 return &(data->template get<FIELD_TYPE>().asAbstract());
381 });
382 }

References olb::Data< T, DESCRIPTOR >::dispatch(), and olb::Data< T, DESCRIPTOR >::get().

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

◆ getPlatform()

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

Return platform of concrete implementation.

Definition at line 353 of file data.h.

353 {
354 return _platform;
355 }

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

◆ provides()

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
bool olb::Data< T, DESCRIPTOR >::provides ( )
inline

Return whether FIELD_TYPE is available / has been allocated.

Definition at line 359 of file data.h.

359 {
360 return dispatch([&](const auto* data) -> bool {
361 return data->template provides<FIELD_TYPE>();
362 });
363 }
bool provides()
Return whether FIELD_TYPE is available / has been allocated.
Definition data.h:359

References olb::Data< T, DESCRIPTOR >::dispatch(), and olb::Data< T, DESCRIPTOR >::provides().

+ 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::Data< T, DESCRIPTOR >::resize ( std::size_t newSize)
pure virtual

◆ setProcessingContext()

template<typename T , typename DESCRIPTOR >
virtual void olb::Data< 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::ConcreteData< T, DESCRIPTOR, PLATFORM >.

◆ setSerialization()

template<typename T , typename DESCRIPTOR >
template<typename FIELD_TYPE >
void olb::Data< T, DESCRIPTOR >::setSerialization ( bool active)
inline

Sets FIELD_TYPE serialization state to active.

By default Data doesn't (de)serialize any fields but ConcreteBlockLattice sets all descriptor-declared field arrays to active.

Definition at line 407 of file data.h.

407 {
408 dispatch([&](auto* data) {
409 data->template setSerialization<FIELD_TYPE>(active);
410 });
411 }
void setSerialization(bool active)
Sets FIELD_TYPE serialization state to active.
Definition data.h:407

References olb::Data< T, DESCRIPTOR >::dispatch(), and olb::Data< T, DESCRIPTOR >::setSerialization().

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

Member Data Documentation

◆ _platform

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

Definition at line 321 of file data.h.


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