25#ifndef CPU_SISD_COLUMN_H
26#define CPU_SISD_COLUMN_H
48 std::unique_ptr<T[]> _data;
55 _data(new T[count] {})
64 _data(rhs._data.release())
69 _data(new T[_count] {})
71 std::copy(rhs._data.get(),
72 rhs._data.get() + _count,
80 std::unique_ptr<T[]>
data = std::unique_ptr<T[]>(
new T[count] { });
81 std::copy(_data.get(), _data.get() + std::min(_count, count),
data.get());
118 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
132 const std::size_t _count;
133 std::unique_ptr<T[]> _data;
135 std::ptrdiff_t _shift;
136 std::size_t _remainder;
137 std::array<T*,2> _start;
144 _data(new T[count] {}),
153 _data(rhs._data.release()),
155 _remainder(rhs._remainder)
164 return (i > _remainder ? _start[1] : _start[0])[i];
169 return (i > _remainder ? _start[1] : _start[0])[i];
179 const std::ptrdiff_t n =
size();
180 T*
const base = _data.get();
182 _remainder = n - _shift - 1;
183 _start[0] = base + _shift;
184 _start[1] = base - (n - _shift);
187 _remainder = -_shift - 1;
188 _start[0] = base + (n + _shift);
189 _start[1] = base + _shift;
195 const std::ptrdiff_t n =
size();
200 else if (_shift <= -n) {
208 throw std::logic_error(
"Cyclic column can not be resized");
218 bool*
getBlock(std::size_t iBlock, std::size_t& sizeBlock,
bool loadingMode)
override;
Base class for serializable objects of constant size. For dynamic size use BufferSerializable.
Plain column for SISD CPU targets (default)
void setProcessingContext(ProcessingContext)
void resize(std::size_t count)
const T & operator[](std::size_t i) const override
Column(std::size_t count)
Column(Column< T > &&rhs)
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.
Column(const Column< T > &rhs)
std::size_t getSerializableSize() const override
Binary size for the serializer.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
T & operator[](std::size_t i) override
virtual ~Column()=default
Cyclic column for usage in ColumnVector.
std::size_t getNblock() const override
Number of data blocks for the serializable interface.
CyclicColumn(std::size_t count)
const T & operator[](std::size_t i) const override
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.
std::size_t getSerializableSize() const override
Binary size for the serializer.
void setProcessingContext(ProcessingContext)
T & operator[](std::size_t i) override
void rotate(std::ptrdiff_t offset)
CyclicColumn(CyclicColumn< T > &&rhs)
void resize(std::size_t count)
Top level namespace for all of OpenLB.
ProcessingContext
OpenLB processing contexts.
Platform
OpenLB execution targets.
Abstract declarator of Column-like storage.
Abstract declarator of cyclic Column-like storage.
Specializable declarator for concrete implementations of abstract storage types.