OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::ConcreteData< T, DESCRIPTOR, PLATFORM > Class Template Referencefinal

Storage of any FIELD_TYPE data on PLATFORM. More...

#include <data.h>

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

Public Member Functions

 ConcreteData ()
 Construct empty.
 
 ConcreteData (std::size_t size)
 Construct Array<FIELD> of size for each FIELD in DESCRIPTOR and mark for serialization.
 
template<typename FIELD_TYPE >
bool provides () const
 Returns true iff FIELD_TYPE is allocated and can be accessed.
 
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.
 
template<typename F >
void forEach (F f)
 Call f for each managed AnyFieldType.
 
template<typename TYPE , typename F >
void forEachCastable (F f)
 Call f for each managed AnyFieldType of TYPE.
 
void resize (std::size_t newSize) override
 
void setProcessingContext (ProcessingContext context) override
 Set processing context of all managed fields.
 
auto & getRegistry ()
 Expose FieldTypeRegistry for device-support.
 
template<typename FIELD_TYPE >
void setSerialization (bool active)
 Sets FIELD_TYPE serialization state to active.
 
std::size_t getNblock () const override
 Number of data blocks for the serializable interface.
 
std::size_t getSerializableSize () const override
 Binary size for the serializer.
 
bool * getBlock (std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
 Return a pointer to the memory of the current block and its size for the serializable interface.
 
- Public Member Functions inherited from olb::Data< T, DESCRIPTOR >
 Data (Platform platform)
 
virtual ~Data ()=default
 
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.
 
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
 
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 ()
 

Additional Inherited Members

- Protected Member Functions inherited from olb::Data< T, DESCRIPTOR >
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 inherited from olb::Data< T, DESCRIPTOR >
const Platform _platform
 

Detailed Description

template<typename T, typename DESCRIPTOR, Platform PLATFORM>
class olb::ConcreteData< T, DESCRIPTOR, PLATFORM >

Storage of any FIELD_TYPE data on PLATFORM.

Manages access and serialization of dynamically allocated FIELD_TYPE data. This is the core storage class used for ConcreteBlockLattice on any platform supported by OpenLB.

See Data<T,DESCRIPTOR> for the platform-agnostic interface.

Definition at line 424 of file data.h.

Constructor & Destructor Documentation

◆ ConcreteData() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::ConcreteData ( )
inline

Construct empty.

Definition at line 435 of file data.h.

435 :
436 Data<T,DESCRIPTOR>(PLATFORM)
437 { }
Data(Platform platform)
Definition data.h:340

◆ ConcreteData() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::ConcreteData ( std::size_t size)
inline

Construct Array<FIELD> of size for each FIELD in DESCRIPTOR and mark for serialization.

Definition at line 440 of file data.h.

440 :
441 Data<T,DESCRIPTOR>(PLATFORM)
442 {
443 DESCRIPTOR::fields_t::for_each([&](auto id) {
444 using field = typename decltype(id)::type;
445 using field_type = Array<field>;
448 });
449 }
auto & allocate(ARGS &&... args)
Allocate and return FIELD_TYPE data.
Definition data.h:459
void setSerialization(bool active)
Sets FIELD_TYPE serialization state to active.
Definition data.h:520
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::allocate(), and olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::setSerialization().

+ Here is the call graph for this function:

Member Function Documentation

◆ allocate()

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

Allocate and return FIELD_TYPE data.

Definition at line 459 of file data.h.

459 {
460 _map[typeid(FIELD_TYPE)] = std::make_unique<AnyFieldTypeD<T,DESCRIPTOR,PLATFORM>>(
461 meta::id<FIELD_TYPE>(), std::forward<decltype(args)>(args)...);
462
463 AnyFieldTypeD<T,DESCRIPTOR,PLATFORM>* newField = _map[typeid(FIELD_TYPE)].get();
464 _registry.template track<FIELD_TYPE>(newField);
465 return *newField->template as<FIELD_TYPE>();
466 }
const auto & get() const
Return reference to data of FIELD_TYPE.
Definition data.h:470

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::get().

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

◆ forEach()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename F >
void olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::forEach ( F f)
inline

Call f for each managed AnyFieldType.

Definition at line 481 of file data.h.

481 {
482 for (auto& [_, field] : _map) {
483 f(*field);
484 }
485 }
+ Here is the caller graph for this function:

◆ forEachCastable()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename TYPE , typename F >
void olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::forEachCastable ( F f)
inline

Call f for each managed AnyFieldType of TYPE.

Used to e.g. iterate over all field arrays

Definition at line 492 of file data.h.

492 {
493 forEach([&f](AnyFieldTypeD<T,DESCRIPTOR,PLATFORM>& any) {
494 if (auto casted = any.template tryAs<TYPE>()) {
495 f(*casted);
496 }
497 });
498 }
void forEach(F f)
Call f for each managed AnyFieldType.
Definition data.h:481

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::forEach().

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

◆ get() [1/2]

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

Return reference to data of FIELD_TYPE.

Definition at line 475 of file data.h.

475 {
476 return *_registry.template get<FIELD_TYPE>()->template as<FIELD_TYPE>();
477 }

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::get().

+ Here is the call graph for this function:

◆ get() [2/2]

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

Return reference to data of FIELD_TYPE.

Definition at line 470 of file data.h.

470 {
471 return *_registry.template get<FIELD_TYPE>()->template as<FIELD_TYPE>();
472 }

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::get().

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

◆ getBlock()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
bool * olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
overridevirtual

Return a pointer to the memory of the current block and its size for the serializable interface.

Implements olb::Serializable.

Definition at line 52 of file data.hh.

53{
54 std::size_t currentBlock = 0;
55 bool* dataPtr = nullptr;
56
57 for (const auto& [_, serializable] : _serializationNames) {
58 this->registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, *serializable, loadingMode);
59 }
60
61 return dataPtr;
62}
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.
Definition serializer.h:239

◆ getNblock()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::size_t olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 32 of file data.hh.

33{
34 std::size_t nBlock = 0;
35 for (const auto& [_, serializable] : _serializationNames) {
36 nBlock += serializable->getNblock();
37 }
38 return nBlock;
39}

◆ getRegistry()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
auto & olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::getRegistry ( )
inline

Expose FieldTypeRegistry for device-support.

Definition at line 514 of file data.h.

514 {
515 return _registry;
516 }
+ Here is the caller graph for this function:

◆ getSerializableSize()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
std::size_t olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 42 of file data.hh.

43{
44 std::size_t size = 0;
45 for (const auto& [_, serializable] : _serializationNames) {
46 size += serializable->getSerializableSize();
47 }
48 return size;
49}

◆ provides()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
template<typename FIELD_TYPE >
bool olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::provides ( ) const
inline

Returns true iff FIELD_TYPE is allocated and can be accessed.

Definition at line 453 of file data.h.

453 {
454 return _registry.template provides<FIELD_TYPE>();
455 }
bool provides() const
Returns true iff FIELD_TYPE is allocated and can be accessed.
Definition data.h:453

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::provides().

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

◆ resize()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::resize ( std::size_t newSize)
inlineoverridevirtual

Implements olb::Data< T, DESCRIPTOR >.

Definition at line 500 of file data.h.

500 {
501 forEachCastable<ColumnVectorBase>([&](auto columnVector) {
502 columnVector->resize(newSize);
503 });
504 }
void forEachCastable(F f)
Call f for each managed AnyFieldType of TYPE.
Definition data.h:492

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::forEachCastable().

+ Here is the call graph for this function:

◆ setProcessingContext()

template<typename T , typename DESCRIPTOR , Platform PLATFORM>
void olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::setProcessingContext ( ProcessingContext context)
inlineoverridevirtual

Set processing context of all managed fields.

Implements olb::Data< T, DESCRIPTOR >.

Definition at line 507 of file data.h.

507 {
508 forEach([context](AnyFieldTypeD<T,DESCRIPTOR,PLATFORM>& any) {
509 any.setProcessingContext(context);
510 });
511 }

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::forEach(), and olb::AnyFieldTypeD< T, DESCRIPTOR, PLATFORM >::setProcessingContext().

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

◆ setSerialization()

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

Sets FIELD_TYPE serialization state to active.

Definition at line 520 of file data.h.

520 {
521 if (active) {
522 _serializationNames[meta::name<FIELD_TYPE>()] = _registry.template get<FIELD_TYPE>()->asSerializable();
523 } else {
524 _serializationNames.erase(meta::name<FIELD_TYPE>());
525 }
526 }
std::string name()
Returns distinct name on GCC, Clang and ICC but may return arbitrary garbage as per the standard.
Definition meta.h:100

References olb::ConcreteData< T, DESCRIPTOR, PLATFORM >::get(), and olb::meta::name().

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

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