OpenLB 1.7
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
olb::BlockData< D, T, U > Class Template Reference

#include <blockData.h>

+ Inheritance diagram for olb::BlockData< D, T, U >:
+ Collaboration diagram for olb::BlockData< D, T, U >:

Classes

struct  DUMMY_FIELD
 

Public Member Functions

 BlockData (Cuboid< T, D > &cuboid, int overlap=0, int size=1)
 
 BlockData (BlockStructureD< D > &&block, int size=1)
 
 BlockData (BlockF< U, D > &blockF)
 
 BlockData (BlockData< D, T, U > &&)=default
 
virtual ~BlockData ()=default
 
bool operator() (T output[], const int input[])
 
Column< U > & getColumn (unsigned iD)
 
U & get (std::size_t iCell, int iD=0)
 
U & get (LatticeR< D > latticeR, int iD=0)
 
get (LatticeR< D > latticeR, int iD=0) const
 
Platform getPlatform () const
 
bool hasCommunicatable (std::type_index field) const
 
auto & getCommunicatable (std::type_index field)
 
unsigned getSize () const
 
std::size_t getNblock () const override
 Returns the number of blocks.
 
std::size_t getSerializableSize () const override
 Returns the binary size of the data to be saved.
 
bool * getBlock (std::size_t iBlock, std::size_t &sizeBlock, bool loadingMode) override
 Returns the address of the i-th block and its size.
 
- Public Member Functions inherited from olb::BlockStructureD< D >
 BlockStructureD (Vector< int, D > size, int padding=0)
 
 BlockStructureD ()
 
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, CellIDgetCellId (L... latticeR) 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.
 
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
 
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 ()
 

Static Public Attributes

static constexpr Platform platform = Platform::CPU_SISD
 

Protected Attributes

const unsigned _size
 
std::vector< cpu::sisd::Column< U > > _data
 
ConcreteCommunicatable< std::vector< cpu::sisd::Column< U > > > _communicatable
 
- Protected Attributes inherited from olb::BlockStructureD< D >
LatticeR< D > _core
 
LatticeR< D > _size
 
LatticeR< D > _projection
 
int _padding
 

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<unsigned D, typename T, typename U>
class olb::BlockData< D, T, U >

Definition at line 41 of file blockData.h.

Constructor & Destructor Documentation

◆ BlockData() [1/4]

template<unsigned D, typename T , typename U >
olb::BlockData< D, T, U >::BlockData ( Cuboid< T, D > & cuboid,
int overlap = 0,
int size = 1 )

Definition at line 41 of file blockData.hh.

41 :
42 BlockStructureD<D>(cuboid.getExtent(), overlap),
43 _size(size),
45{
46 for (unsigned iD=0; iD < _size; ++iD) {
47 _data.emplace_back(this->getNcells());
48 }
49}
std::vector< cpu::sisd::Column< U > > _data
Definition blockData.h:45
ConcreteCommunicatable< std::vector< cpu::sisd::Column< U > > > _communicatable
Definition blockData.h:46
const unsigned _size
Definition blockData.h:44
std::size_t getNcells() const
Get number of cells.

References olb::BlockData< D, T, U >::_data, olb::BlockData< D, T, U >::_size, and olb::BlockStructureD< D >::getNcells().

+ Here is the call graph for this function:

◆ BlockData() [2/4]

template<unsigned D, typename T , typename U >
olb::BlockData< D, T, U >::BlockData ( BlockStructureD< D > && block,
int size = 1 )

Definition at line 52 of file blockData.hh.

52 :
53 BlockStructureD<D>(block),
54 _size(size),
56{
57 for (unsigned iD=0; iD < _size; ++iD) {
58 _data.emplace_back(this->getNcells());
59 }
60}

◆ BlockData() [3/4]

template<unsigned D, typename T , typename U >
olb::BlockData< D, T, U >::BlockData ( BlockF< U, D > & blockF)

Definition at line 63 of file blockData.hh.

63 :
64 BlockStructureD<D>(blockF.getBlockStructure()),
65 _size(blockF.getTargetDim())
66{
67 for (unsigned iD=0; iD < _size; ++iD) {
68 _data.emplace_back(this->getNcells());
69 }
70 int input[D];
71 U output[_size];
72 this->forCoreSpatialLocations([&](LatticeR<D> latticeR) {
73 for (unsigned iD=0; iD < D; ++iD) {
74 input[iD] = latticeR[iD];
75 }
76 blockF(output, input);
77 for (unsigned iD=0; iD < _size; ++iD) {
78 get(latticeR,iD) = output[iD];
79 }
80 });
81}
U & get(std::size_t iCell, int iD=0)
Definition blockData.hh:94
void forCoreSpatialLocations(F f) const

◆ BlockData() [4/4]

template<unsigned D, typename T , typename U >
olb::BlockData< D, T, U >::BlockData ( BlockData< D, T, U > && )
default

◆ ~BlockData()

template<unsigned D, typename T , typename U >
virtual olb::BlockData< D, T, U >::~BlockData ( )
virtualdefault

Member Function Documentation

◆ get() [1/3]

template<unsigned D, typename T , typename U >
U & olb::BlockData< D, T, U >::get ( LatticeR< D > latticeR,
int iD = 0 )

Definition at line 100 of file blockData.hh.

101{
102 return get(this->getCellId(latticeR), iD);
103}
CellID getCellId(LatticeR< D > latticeR) const
Get 1D cell ID.

◆ get() [2/3]

template<unsigned D, typename T , typename U >
U olb::BlockData< D, T, U >::get ( LatticeR< D > latticeR,
int iD = 0 ) const

Definition at line 106 of file blockData.hh.

107{
108 return _data[iD][this->getCellId(latticeR)];
109}

◆ get() [3/3]

template<unsigned D, typename T , typename U >
U & olb::BlockData< D, T, U >::get ( std::size_t iCell,
int iD = 0 )

Definition at line 94 of file blockData.hh.

95{
96 return _data[iD][iCell];
97}
+ Here is the caller graph for this function:

◆ getBlock()

template<unsigned D, typename T , typename U >
bool * olb::BlockData< D, T, U >::getBlock ( std::size_t iBlock,
std::size_t & sizeBlock,
bool loadingMode )
overridevirtual

Returns the address of the i-th block and its size.

Parameters
iBlockIndex of the block to be returned
sizeBlockReference to the size of the returned block
Returns
Pointer to the current block

Each getBlock() method should look like this:

std::size_t currentBlock = 0;
bool* dataPtr = nullptr;

// ... register methods...

return dataPtr;

Implements olb::Serializable.

Definition at line 136 of file blockData.hh.

137{
138 std::size_t currentBlock = 0;
139 bool* dataPtr = nullptr;
140
141 for (unsigned iD=0; iD < _size; ++iD) {
142 registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _data[iD], loadingMode);
143 }
144
145 return dataPtr;
146}
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

◆ getColumn()

template<unsigned D, typename T , typename U >
Column< U > & olb::BlockData< D, T, U >::getColumn ( unsigned iD)

Definition at line 112 of file blockData.hh.

113{
114 return _data[iD];
115}
+ Here is the caller graph for this function:

◆ getCommunicatable()

template<unsigned D, typename T , typename U >
auto & olb::BlockData< D, T, U >::getCommunicatable ( std::type_index field)
inline

Definition at line 74 of file blockData.h.

74 {
75 OLB_ASSERT(field == typeid(DUMMY_FIELD),
76 "BlockData only offers DUMMY_FIELD for communication");
77 return _communicatable;
78 }
#define OLB_ASSERT(COND, MESSAGE)
Definition olbDebug.h:45

References olb::BlockData< D, T, U >::_communicatable, and OLB_ASSERT.

◆ getNblock()

template<unsigned D, typename T , typename U >
std::size_t olb::BlockData< D, T, U >::getNblock ( ) const
overridevirtual

Returns the number of blocks.

All Serializable classes have to implement this method.

Implements olb::Serializable.

Definition at line 124 of file blockData.hh.

125{
126 return _data.size() * _data[0].getNblock();
127}

References olb::cpu::sisd::Column< T >::size().

+ Here is the call graph for this function:

◆ getPlatform()

template<unsigned D, typename T , typename U >
Platform olb::BlockData< D, T, U >::getPlatform ( ) const
inline

Definition at line 67 of file blockData.h.

67 {
68 return platform;
69 }
static constexpr Platform platform
Definition blockData.h:49

References olb::BlockData< D, T, U >::platform.

◆ getSerializableSize()

template<unsigned D, typename T , typename U >
std::size_t olb::BlockData< D, T, U >::getSerializableSize ( ) const
overridevirtual

Returns the binary size of the data to be saved.

This method must be overloaded by all child classes.

Implements olb::Serializable.

Definition at line 130 of file blockData.hh.

131{
132 return _data.size() * _data[0].getSerializableSize();
133}

◆ getSize()

template<unsigned D, typename T , typename U >
unsigned olb::BlockData< D, T, U >::getSize ( ) const

Definition at line 118 of file blockData.hh.

119{
120 return _size;
121}
+ Here is the caller graph for this function:

◆ hasCommunicatable()

template<unsigned D, typename T , typename U >
bool olb::BlockData< D, T, U >::hasCommunicatable ( std::type_index field) const
inline

Definition at line 71 of file blockData.h.

71 {
72 return field == typeid(DUMMY_FIELD);
73 }
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.

◆ operator()()

template<unsigned D, typename T , typename U >
bool olb::BlockData< D, T, U >::operator() ( T output[],
const int input[] )

Definition at line 84 of file blockData.hh.

85{
86 const std::size_t iCell = this->getCellId(input);
87 for (unsigned iD=0; iD < _size; ++iD) {
88 output[iD] = _data[iD][iCell];
89 }
90 return true;
91}

Member Data Documentation

◆ _communicatable

template<unsigned D, typename T , typename U >
ConcreteCommunicatable<std::vector<cpu::sisd::Column<U> > > olb::BlockData< D, T, U >::_communicatable
protected

Definition at line 46 of file blockData.h.

◆ _data

template<unsigned D, typename T , typename U >
std::vector<cpu::sisd::Column<U> > olb::BlockData< D, T, U >::_data
protected

Definition at line 45 of file blockData.h.

◆ _size

template<unsigned D, typename T , typename U >
const unsigned olb::BlockData< D, T, U >::_size
protected

Definition at line 44 of file blockData.h.

◆ platform

template<unsigned D, typename T , typename U >
constexpr Platform olb::BlockData< D, T, U >::platform = Platform::CPU_SISD
staticconstexpr

Definition at line 49 of file blockData.h.


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