OpenLB 1.8.1
Loading...
Searching...
No Matches
olb::MultiFieldArrayD< T, DESCRIPTOR, PLATFORM, FIELDS > Class Template Reference

Storage for a fixed set of 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 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 410 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 418 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 420 of file fieldArrayD.h.

420 :
421 _count(count),
422 // Trickery to construct each member of _static with `count`.
423 // Uses the comma operator in conjunction with type dropping.
424 _static((std::void_t<FIELDS>(), count)...)
425 { }

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)
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 435 of file fieldArrayD.h.

436 {
437 static_assert(meta::contains<FIELD,FIELDS...>(), "FIELD not contained in FIELDS");
438 return std::get<(fields_t::template index<FIELD>())>(_static);
439 }
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 428 of file fieldArrayD.h.

429 {
430 static_assert(meta::contains<FIELD,FIELDS...>(), "FIELD not contained in FIELDS");
431 return std::get<(fields_t::template index<FIELD>())>(_static);
432 }

References olb::meta::contains().

+ Here is the call graph for this function:
+ Here is the caller 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:373

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 443 of file fieldArrayD.h.

444 {
445 return get<FIELD>().getRow(iCell);
446 }

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

+ Here is the call graph for this function:

◆ 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 466 of file fieldArrayD.h.

467 {
468 return get<FIELD>().getRowPointer(iCell);
469 }

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

+ Here is the call graph for this function:

◆ 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 461 of file fieldArrayD.h.

462 {
463 return get<FIELD>().getRowPointer(iCell);
464 }

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

+ Here is the call graph for this function:

◆ 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 484 of file fieldArrayD.h.

485 {
486 forFields([newCount](auto& fieldArray) {
487 fieldArray.resize(newCount);
488 });
489 _count = newCount;
490 }
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 450 of file fieldArrayD.h.

451 {
452 get<FIELD>().setRow(iCell, v);
453 }

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

+ Here is the call graph for this function:

◆ setProcessingContext()

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

Definition at line 500 of file fieldArrayD.h.

500 {
501 forFields([context](auto& fieldArray) {
502 fieldArray.setProcessingContext(context);
503 });
504 }

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 493 of file fieldArrayD.h.

494 {
495 forFields([i,j](auto& fieldArray) {
496 fieldArray.swap(i,j);
497 });
498 }

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: