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

Vector of columns. More...

#include <columnVector.h>

+ Inheritance diagram for olb::ColumnVector< COLUMN, D >:
+ Collaboration diagram for olb::ColumnVector< COLUMN, D >:

Classes

class  const_ptr
 Read-only proxy for accessing a column vector entry. More...
 
class  ptr
 Proxy for accessing a column vector entry. More...
 

Public Member Functions

 ColumnVector (std::size_t count)
 
 ColumnVector (ColumnVector &&rhs)
 
std::size_t getSize () const
 
const COLUMN & operator[] (unsigned iDim) const
 
COLUMN & operator[] (unsigned iDim)
 
auto getRow (std::size_t i) const
 Return copy of data at index i.
 
auto setRow (std::size_t i, const Vector< typename COLUMN::value_t, D > &value)
 
ptr getRowPointer (std::size_t i)
 
const_ptr getRowPointer (std::size_t i) const
 
void resize (std::size_t newCount)
 Resize columns, potentially invalidates any inbound pointers.
 
void swap (std::size_t i, std::size_t j)
 Swap contents of row i and row j.
 
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.
 
void postLoad () override
 
- Public Member Functions inherited from olb::ColumnVectorBase
virtual ~ColumnVectorBase ()
 
- 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
 

Static Public Attributes

static constexpr unsigned d = D
 

Protected Attributes

std::size_t _count
 Number of rows.
 
std::array< COLUMN, D > _column
 

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 COLUMN, unsigned D>
class olb::ColumnVector< COLUMN, D >

Vector of columns.

Base storage of FieldArrayD and as such all field data including populations

Definition at line 56 of file columnVector.h.

Constructor & Destructor Documentation

◆ ColumnVector() [1/2]

template<typename COLUMN , unsigned D>
olb::ColumnVector< COLUMN, D >::ColumnVector ( std::size_t count)
inline

Definition at line 68 of file columnVector.h.

68 :
69 _count(count),
70 _column(meta::make_array_f<COLUMN,D>([count](unsigned iDim) -> std::size_t {
71 return count;
72 }))
73 { }
std::size_t _count
Number of rows.
std::array< COLUMN, D > _column

◆ ColumnVector() [2/2]

template<typename COLUMN , unsigned D>
olb::ColumnVector< COLUMN, D >::ColumnVector ( ColumnVector< COLUMN, D > && rhs)
inline

Definition at line 75 of file columnVector.h.

75 :
76 _count(rhs._count),
77 _column(std::move(rhs._column)) { }

Member Function Documentation

◆ getBlock()

template<typename COLUMN , unsigned D>
bool * olb::ColumnVector< COLUMN, D >::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 167 of file columnVector.h.

168{
169 std::size_t currentBlock = 0;
170 bool* dataPtr = nullptr;
171
172 for (unsigned iDim=0; iDim < D; ++iDim) {
173 this->registerSerializableOfConstSize(iBlock, sizeBlock, currentBlock, dataPtr, _column[iDim], loadingMode);
174 }
175
176 return dataPtr;
177}
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 COLUMN , unsigned D>
std::size_t olb::ColumnVector< COLUMN, D >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 155 of file columnVector.h.

156{
157 return D * _column[0].getNblock();
158}

References olb::ColumnVector< COLUMN, D >::getNblock().

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

◆ getRow()

template<typename COLUMN , unsigned D>
auto olb::ColumnVector< COLUMN, D >::getRow ( std::size_t i) const
inline

Return copy of data at index i.

Definition at line 95 of file columnVector.h.

96 {
97 if constexpr (D == 1) {
98 return operator[](0)[i];
99 } else {
100 return Vector<typename COLUMN::value_t,D>([this,i](unsigned iDim) {
101 return operator[](iDim)[i];
102 });
103 }
104 __builtin_unreachable();
105 }
const COLUMN & operator[](unsigned iDim) const

◆ getRowPointer() [1/2]

template<typename COLUMN , unsigned D>
ptr olb::ColumnVector< COLUMN, D >::getRowPointer ( std::size_t i)
inline

Definition at line 114 of file columnVector.h.

115 {
116 return ptr(*this, i);
117 }
+ Here is the caller graph for this function:

◆ getRowPointer() [2/2]

template<typename COLUMN , unsigned D>
const_ptr olb::ColumnVector< COLUMN, D >::getRowPointer ( std::size_t i) const
inline

Definition at line 119 of file columnVector.h.

120 {
121 return const_ptr(*this, i);
122 }

◆ getSerializableSize()

template<typename COLUMN , unsigned D>
std::size_t olb::ColumnVector< COLUMN, D >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 161 of file columnVector.h.

162{
163 return D * _column[0].getSerializableSize();
164}

References olb::ColumnVector< COLUMN, D >::getSerializableSize().

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

◆ getSize()

template<typename COLUMN , unsigned D>
std::size_t olb::ColumnVector< COLUMN, D >::getSize ( ) const
inline

Definition at line 79 of file columnVector.h.

80 {
81 return _count;
82 }

◆ operator[]() [1/2]

template<typename COLUMN , unsigned D>
COLUMN & olb::ColumnVector< COLUMN, D >::operator[] ( unsigned iDim)
inline

Definition at line 89 of file columnVector.h.

90 {
91 return _column[iDim];
92 }

◆ operator[]() [2/2]

template<typename COLUMN , unsigned D>
const COLUMN & olb::ColumnVector< COLUMN, D >::operator[] ( unsigned iDim) const
inline

Definition at line 84 of file columnVector.h.

85 {
86 return _column[iDim];
87 }

◆ postLoad()

template<typename COLUMN , unsigned D>
void olb::ColumnVector< COLUMN, D >::postLoad ( )
overridevirtual

Reimplemented from olb::Serializable.

Definition at line 180 of file columnVector.h.

181{
182 for (unsigned iD=0; iD < D; ++iD) {
183 this->operator[](iD).postLoad();
184 }
185}

References olb::ColumnVector< COLUMN, D >::postLoad().

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

◆ resize()

template<typename COLUMN , unsigned D>
void olb::ColumnVector< COLUMN, D >::resize ( std::size_t newCount)
inline

Resize columns, potentially invalidates any inbound pointers.

Definition at line 125 of file columnVector.h.

126 {
127 for (unsigned iDim=0; iDim < D; ++iDim) {
128 _column[iDim].resize(newCount);
129 }
130 _count = newCount;
131 }

◆ setRow()

template<typename COLUMN , unsigned D>
auto olb::ColumnVector< COLUMN, D >::setRow ( std::size_t i,
const Vector< typename COLUMN::value_t, D > & value )
inline

Definition at line 107 of file columnVector.h.

108 {
109 for (unsigned iDim=0; iDim < D; ++iDim) {
110 operator[](iDim)[i] = value[iDim];
111 }
112 }
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96

◆ swap()

template<typename COLUMN , unsigned D>
void olb::ColumnVector< COLUMN, D >::swap ( std::size_t i,
std::size_t j )
inline

Swap contents of row i and row j.

Required to realize sorted column stores in CellIndexListD

Definition at line 137 of file columnVector.h.

138 {
139 for (unsigned iDim=0; iDim < D; ++iDim) {
140 std::swap(_column[iDim][i], _column[iDim][j]);
141 }
142 }

Member Data Documentation

◆ _column

template<typename COLUMN , unsigned D>
std::array<COLUMN,D> olb::ColumnVector< COLUMN, D >::_column
protected

Definition at line 60 of file columnVector.h.

◆ _count

template<typename COLUMN , unsigned D>
std::size_t olb::ColumnVector< COLUMN, D >::_count
protected

Number of rows.

Definition at line 59 of file columnVector.h.

◆ d

template<typename COLUMN , unsigned D>
constexpr unsigned olb::ColumnVector< COLUMN, D >::d = D
staticconstexpr

Definition at line 66 of file columnVector.h.


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