Skip to content

Storage1D

Storage1D<T> is the templated dynamic storage container to store one-dimensional, in terms of space dimension, data. It provides boundary "ghost" cells to facilitate boundary conditions and provides local linear interpolation between the grid points. The container can store any type of data T.

The data inside of the Storage1D container is manipulated using a number of dedicated methods:

Constructors

cpp
Storage1D();

Default constructor. Creates empty container.

cpp
Storage1D(const Storage1D<T>& rhs);

Copy constructor. Creates and initializes the container with the copy of the rhs.

cpp
Storage1D(const long int nx, const long int bc);

Constructor. Creates a container of the specified size. nx is the 1D domain length and bc is the number of boundary cells.

cpp
void Allocate(const long int nx, const long int bc);

Allocates previously created empty storage container.

cpp
void Reallocate(const long int nx);

Reallocates non-empty container to new size while keeping the number of boundary cells.

cpp
void AllocateCopy(const Storage1D<T>& rhs);

Allocates current container and initializes it with the data from the rhs.

Access operators

cpp
T& operator()(const long int x);

Random access operator. Returns the reference to the element pointed to by the index x.

cpp
T const& operator()(const long int x) const;

Random access operator. Returns const reference to the element pointed to by the index x.

cpp
T at(const double x) const;

Arbitrary position access operator. Returns interpolated value at arbitrary location inside of the container dimensions.

cpp
T& operator[](size_t idx);

Random access operator to the raw storage. Returns the reference to the element pointed to by the index x.

cpp
T const& operator[](const size_t idx) const;

Random access operator to the raw storage. Returns const reference to the element pointed to by the index x.

cpp
T* data(void);

Returns pointer to the raw data storage.

cpp
const T* data(void) const;

Returns const pointer to the raw data storage.

Data manipulation methods

cpp
void Remesh(const long int nx);

Remeshes the storage to new dimensions while keeping the data. Uses linear interpolation.

cpp
Storage1D<T>& operator=(const Storage1D<T>& rhs);

Assignment operator. Assigns the copy of the rhs to the current container.

cpp
void Clear(void);

Clears the container while keeping its storage size.

cpp
void set_to_value(T value);

Sets all entries of the container to the specified value.

Container properties

cpp
bool IsNotAllocated() const;

Returns true if the storage is not allocated.

cpp
bool IsAllocated() const;

Returns true if the storage is allocated.

cpp
bool IsSize(const long int Nx);

Returns true if the current storage is of the specified size Nx.

cpp
size_t sizeX() const;

Returns the size of the current container without boundary cells.

cpp
long int Bcells() const;

Returns the number of boundary cells.

cpp
size_t size() const;

Returns total size of the container including boundary cells.

cpp
void SetNewBcells(const int new_b_cells);

Sets new number of boundary cells. Scrambles stored data.

cpp
bool InLimits(const long int idx);

Returns true if the specified idx is inside of the container dimensions.

MPI communication methods

cpp
std::vector<double> pack();

Packs (writes) the content of the current container into the MPI communication buffer.

cpp
void unpack(std::vector<double>& buffer);

Unpacks (reads) the content of the current container from the MPI communication buffer.

Released under the GNU GPLv3 License.