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

Storage for a fixed set of static FIELDS and arbitrary custom fields. More...

#include <fieldArrayD.h>

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

Public Types

using fields_t = meta::list<FIELDS...>
 

Public Member Functions

 MultiFieldArrayD (std::size_t count=1)
 
template<typename FIELD >
const FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & get (meta::id< FIELD > field=meta::id< FIELD >()) const
 
template<typename FIELD >
FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & get (meta::id< FIELD > field=meta::id< FIELD >())
 
template<typename FIELD >
auto getField (std::size_t iCell) const
 Return copy of FIELD data for cell iCell.
 
template<typename FIELD >
void setField (std::size_t iCell, const FieldD< T, DESCRIPTOR, FIELD > &v)
 Set FIELD data at cell iCell.
 
template<typename FIELD >
const FIELD::template value_type< T > & getFieldComponent (std::size_t iCell, unsigned iDim) const
 
template<typename FIELD >
FIELD::template value_type< T > & getFieldComponent (std::size_t iCell, unsigned iDim)
 
template<typename FIELD >
auto getFieldPointer (std::size_t iCell) const
 
template<typename FIELD >
auto getFieldPointer (std::size_t iCell)
 
template<typename F >
void forFields (F f) const
 Apply generic expression to each FIELD array.
 
template<typename F >
void forFields (F f)
 
template<typename F >
void forFieldsAt (std::size_t idx, F f)
 Apply generic lambda expression to each FIELD of a cell.
 
void resize (std::size_t newCount)
 Change number of rows.
 
void swap (std::size_t i, std::size_t j)
 Swap contents of rows i and j.
 
void setProcessingContext (ProcessingContext context)
 
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::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::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.
 

Detailed Description

template<typename T, typename DESCRIPTOR, Platform PLATFORM, typename... FIELDS>
class olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >

Storage for a fixed set of static FIELDS and arbitrary custom fields.

Actual field data is stored by individual FieldArrayD instances

This class is not tied to block-structured resp. list-like data concepts and may be used for both lattice and (resizable) particle data.

Definition at line 352 of file fieldArrayD.h.

Member Typedef Documentation

◆ fields_t

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
using olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::fields_t = meta::list<FIELDS...>

Definition at line 360 of file fieldArrayD.h.

Constructor & Destructor Documentation

◆ MultiFieldArrayD()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::MultiFieldArrayD ( std::size_t count = 1)
inline

Definition at line 362 of file fieldArrayD.h.

362 :
363 _count(count),
364 // Trickery to construct each member of _static with `count`.
365 // Uses the comma operator in conjunction with type dropping.
366 _static((std::void_t<FIELDS>(), count)...)
367 { }

Member Function Documentation

◆ forFields() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename F >
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::forFields ( F f)

Definition at line 60 of file fieldArrayD.hh.

61{
62 fields_t::for_each([&](auto field) {
63 f(get(field));
64 });
65}
const FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & get(meta::id< FIELD > field=meta::id< FIELD >()) const
static constexpr void for_each(F f)
Calls f for each type of TYPES by-value (in reversed order!)
Definition meta.h:331

◆ forFields() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename F >
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::forFields ( F f) const

Apply generic expression to each FIELD array.

Definition at line 51 of file fieldArrayD.hh.

52{
53 fields_t::for_each([&](auto field) {
54 f(get(field));
55 });
56}
+ Here is the caller graph for this function:

◆ forFieldsAt()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename F >
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::forFieldsAt ( std::size_t idx,
F f )

Apply generic lambda expression to each FIELD of a cell.

Definition at line 69 of file fieldArrayD.hh.

70{
71 fields_t::for_each([&](auto field) {
72 f(get(field).getFieldPointer(idx), field);
73 });
74}
auto getFieldPointer(std::size_t iCell) const

◆ get() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::get ( meta::id< FIELD > field = meta::id<FIELD>())
inline

Definition at line 377 of file fieldArrayD.h.

378 {
379 static_assert(meta::contains<FIELD,FIELDS...>(), "FIELD not contained in FIELDS");
380 return std::get<(fields_t::template index<FIELD>())>(_static);
381 }
constexpr bool contains()
Returns true iff a given type list contains WANTED.
Definition meta.h:125

References olb::meta::contains().

+ Here is the call graph for this function:

◆ get() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
const FieldArrayD< T, DESCRIPTOR, PLATFORM, FIELD > & olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::get ( meta::id< FIELD > field = meta::id<FIELD>()) const
inline

Definition at line 370 of file fieldArrayD.h.

371 {
372 static_assert(meta::contains<FIELD,FIELDS...>(), "FIELD not contained in FIELDS");
373 return std::get<(fields_t::template index<FIELD>())>(_static);
374 }

References olb::meta::contains().

+ Here is the call graph for this function:

◆ getBlock()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
bool * olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::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 89 of file fieldArrayD.hh.

90{
91 std::size_t currentBlock = 0;
92 bool* dataPtr = nullptr;
93
94 meta::tuple_for_each(_static, [&](auto& field) {
95 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, field, loadingMode);
96 });
97
98 return dataPtr;
99}
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
void tuple_for_each(TUPLE &tuple, F &&f)
Apply F to each element of TUPLE.
Definition meta.h:369

References olb::meta::tuple_for_each().

+ Here is the call graph for this function:

◆ getField()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
auto olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::getField ( std::size_t iCell) const
inline

Return copy of FIELD data for cell iCell.

Definition at line 385 of file fieldArrayD.h.

386 {
387 return get<FIELD>().getRow(iCell);
388 }

◆ getFieldComponent() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
FIELD::template value_type< T > & olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::getFieldComponent ( std::size_t iCell,
unsigned iDim )

Definition at line 44 of file fieldArrayD.hh.

45{
46 return get<FIELD>()[iDim][iCell];
47}

◆ getFieldComponent() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
const FIELD::template value_type< T > & olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::getFieldComponent ( std::size_t iCell,
unsigned iDim ) const

Definition at line 36 of file fieldArrayD.hh.

37{
38 return get<FIELD>()[iDim][iCell];
39}

◆ getFieldPointer() [1/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
auto olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::getFieldPointer ( std::size_t iCell)
inline

Definition at line 408 of file fieldArrayD.h.

409 {
410 return get<FIELD>().getRowPointer(iCell);
411 }

◆ getFieldPointer() [2/2]

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
auto olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::getFieldPointer ( std::size_t iCell) const
inline

Definition at line 403 of file fieldArrayD.h.

404 {
405 return get<FIELD>().getRowPointer(iCell);
406 }

◆ getNblock()

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

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 77 of file fieldArrayD.hh.

78{
79 return (get<FIELDS>().getNblock() + ... + 0);
80}
std::size_t getNblock() const override
Number of data blocks for the serializable interface.

◆ getSerializableSize()

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

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 83 of file fieldArrayD.hh.

84{
85 return (get<FIELDS>().getSerializableSize() + ... + 0);
86}
std::size_t getSerializableSize() const override
Binary size for the serializer.

◆ resize()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::resize ( std::size_t newCount)
inline

Change number of rows.

Drops the last (newCount-_count) rows when shrinking

Definition at line 426 of file fieldArrayD.h.

427 {
428 forFields([newCount](auto& fieldArray) {
429 fieldArray.resize(newCount);
430 });
431 _count = newCount;
432 }
void forFields(F f) const
Apply generic expression to each FIELD array.

References olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::forFields().

+ Here is the call graph for this function:

◆ setField()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
template<typename FIELD >
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::setField ( std::size_t iCell,
const FieldD< T, DESCRIPTOR, FIELD > & v )
inline

Set FIELD data at cell iCell.

Definition at line 392 of file fieldArrayD.h.

393 {
394 get<FIELD>().setRow(iCell, v);
395 }

◆ setProcessingContext()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::setProcessingContext ( ProcessingContext context)
inline

Definition at line 442 of file fieldArrayD.h.

442 {
443 forFields([context](auto& fieldArray) {
444 fieldArray.setProcessingContext(context);
445 });
446 }

References olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::forFields().

+ Here is the call graph for this function:

◆ swap()

template<typename T , typename DESCRIPTOR , Platform PLATFORM, typename... FIELDS>
void olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::swap ( std::size_t i,
std::size_t j )
inline

Swap contents of rows i and j.

Definition at line 435 of file fieldArrayD.h.

436 {
437 forFields([i,j](auto& fieldArray) {
438 fieldArray.swap(i,j);
439 });
440 }

References olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS >::forFields().

+ Here is the call graph for this function:

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