OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
olb::cpu::sisd::CyclicColumn< T > Class Template Referencefinal

Cyclic column for usage in ColumnVector. More...

#include <column.h>

+ Inheritance diagram for olb::cpu::sisd::CyclicColumn< T >:
+ Collaboration diagram for olb::cpu::sisd::CyclicColumn< T >:

Public Types

using value_t = T
 
- Public Types inherited from olb::AbstractCyclicColumn< T >
using value_type = T
 

Public Member Functions

 CyclicColumn (std::size_t count)
 
 CyclicColumn (CyclicColumn< T > &&rhs)
 
 ~CyclicColumn ()=default
 
const T & operator[] (std::size_t i) const override
 
T & operator[] (std::size_t i) override
 
std::size_t size () const
 
void refresh ()
 
void rotate (std::ptrdiff_t offset)
 
void resize (std::size_t count)
 
void setProcessingContext (ProcessingContext)
 
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::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
 

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>
class olb::cpu::sisd::CyclicColumn< T >

Cyclic column for usage in ColumnVector.

Column type used for propagatable population storage using the branching PS pattern.

Definition at line 129 of file column.h.

Member Typedef Documentation

◆ value_t

template<typename T >
using olb::cpu::sisd::CyclicColumn< T >::value_t = T

Definition at line 140 of file column.h.

Constructor & Destructor Documentation

◆ CyclicColumn() [1/2]

template<typename T >
olb::cpu::sisd::CyclicColumn< T >::CyclicColumn ( std::size_t count)
inline

Definition at line 142 of file column.h.

142 :
143 _count(count),
144 _data(new T[count] {}),
145 _shift(0),
146 _remainder(count)
147 {
148 refresh();
149 }

◆ CyclicColumn() [2/2]

template<typename T >
olb::cpu::sisd::CyclicColumn< T >::CyclicColumn ( CyclicColumn< T > && rhs)
inline

Definition at line 151 of file column.h.

151 :
152 _count(rhs._count),
153 _data(rhs._data.release()),
154 _shift(rhs._shift),
155 _remainder(rhs._remainder)
156 {
157 refresh();
158 }

References olb::cpu::sisd::CyclicColumn< T >::refresh().

+ Here is the call graph for this function:

◆ ~CyclicColumn()

template<typename T >
olb::cpu::sisd::CyclicColumn< T >::~CyclicColumn ( )
default

Member Function Documentation

◆ getBlock()

template<typename T >
bool * olb::cpu::sisd::CyclicColumn< T >::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 79 of file column.hh.

80{
81 std::size_t currentBlock = 0;
82 bool* dataPtr = nullptr;
83
84 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _shift);
85 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, _count);
86 registerVar(iBlock, sizeBlock, currentBlock, dataPtr, *_data.get(), _count);
87
88 return dataPtr;
89}
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.
Definition serializer.h:212

◆ getNblock()

template<typename T >
std::size_t olb::cpu::sisd::CyclicColumn< T >::getNblock ( ) const
overridevirtual

Number of data blocks for the serializable interface.

Implements olb::Serializable.

Definition at line 67 of file column.hh.

68{
69 return 3;
70}

◆ getSerializableSize()

template<typename T >
std::size_t olb::cpu::sisd::CyclicColumn< T >::getSerializableSize ( ) const
overridevirtual

Binary size for the serializer.

Implements olb::Serializable.

Definition at line 73 of file column.hh.

74{
75 return _count * sizeof(T) + sizeof(std::ptrdiff_t) + sizeof(std::size_t);
76}

◆ operator[]() [1/2]

template<typename T >
const T & olb::cpu::sisd::CyclicColumn< T >::operator[] ( std::size_t i) const
inlineoverridevirtual

Implements olb::AbstractCyclicColumn< T >.

Definition at line 162 of file column.h.

163 {
164 return (i > _remainder ? _start[1] : _start[0])[i];
165 }

◆ operator[]() [2/2]

template<typename T >
T & olb::cpu::sisd::CyclicColumn< T >::operator[] ( std::size_t i)
inlineoverridevirtual

Implements olb::AbstractCyclicColumn< T >.

Definition at line 167 of file column.h.

168 {
169 return (i > _remainder ? _start[1] : _start[0])[i];
170 }

◆ postLoad()

template<typename T >
void olb::cpu::sisd::CyclicColumn< T >::postLoad ( )
inlineoverridevirtual

Reimplemented from olb::Serializable.

Definition at line 219 of file column.h.

219{ refresh(); }

References olb::cpu::sisd::CyclicColumn< T >::refresh().

+ Here is the call graph for this function:

◆ refresh()

template<typename T >
void olb::cpu::sisd::CyclicColumn< T >::refresh ( )
inline

Definition at line 177 of file column.h.

178 {
179 const std::ptrdiff_t n = size();
180 T* const base = _data.get();
181 if (_shift >= 0) {
182 _remainder = n - _shift - 1;
183 _start[0] = base + _shift;
184 _start[1] = base - (n - _shift);
185 }
186 else {
187 _remainder = -_shift - 1;
188 _start[0] = base + (n + _shift);
189 _start[1] = base + _shift;
190 }
191 }
std::size_t size() const
Definition column.h:172

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

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

◆ resize()

template<typename T >
void olb::cpu::sisd::CyclicColumn< T >::resize ( std::size_t count)
inline

Definition at line 206 of file column.h.

207 {
208 throw std::logic_error("Cyclic column can not be resized");
209 }

◆ rotate()

template<typename T >
void olb::cpu::sisd::CyclicColumn< T >::rotate ( std::ptrdiff_t offset)
inline

Definition at line 193 of file column.h.

194 {
195 const std::ptrdiff_t n = size();
196 _shift -= offset;
197 if (_shift >= n) {
198 _shift -= n;
199 }
200 else if (_shift <= -n) {
201 _shift += n;
202 }
203 refresh();
204 }

References olb::cpu::sisd::CyclicColumn< T >::refresh(), and olb::cpu::sisd::CyclicColumn< T >::size().

+ Here is the call graph for this function:

◆ setProcessingContext()

template<typename T >
void olb::cpu::sisd::CyclicColumn< T >::setProcessingContext ( ProcessingContext )
inline

Definition at line 211 of file column.h.

211{ };

◆ size()

template<typename T >
std::size_t olb::cpu::sisd::CyclicColumn< T >::size ( ) const
inline

Definition at line 172 of file column.h.

173 {
174 return _count;
175 }
+ Here is the caller graph for this function:

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