Skip to content

Storage3D<T,Rank = 0>

Storage3D<T, Rank = 0> is the templated dynamic storage container specialization to store three-dimensional, in terms of space dimensions, data in a contiguous memory storage. 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 in each grid point.

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

Constructors

cpp
Storage3D();

Constructor. Creates empty storage object.

cpp
Storage3D(const Storage3D<T,0>& rhs);

Copy constructor. Creates the storage object and initializes it with the content of rhs.

cpp
Storage3D(const long int nx, const long int ny, const long int nz, const long int dnx, const long int dny, const long int dnz, const long int bc);

Constructor. Creates and allocates memory for the storage of the given size.

cpp
Storage3D(const GridParameters Dimensions, const long int bc);

Constructor. Creates and allocates memory for the storage of the given size.

cpp
void Allocate(const Storage3D<T,0>& rhs);

Allocates previously created empty object to the dimensions of the rhs.

cpp
void AllocateCopy(const Storage3D<T,0>& rhs);

Allocates previously created empty object to the dimensions of the rhs and initializes it with rhs's content.

cpp
size_t Allocate(const long int nx, const long int ny, const long int nz, const long int dnx, const long int dny, const long int dnz, const long int bc);

Allocates previously created empty object to the given dimensions.

cpp
size_t Allocate(const GridParameters Dimensions, const long int bc);

Allocates previously created empty object to the given dimensions.

cpp
void Reallocate(const long int nx, const long int ny, const long int nz);

Reallocates memory of already allocated container to new dimensions. Keeps the number of boundary cells the same. Scrambles the stored data.

cpp
Storage3D<T,0>& operator=(const Storage3D<T,0>& rhs);

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

Access operators

cpp
T& operator()(const long int x, const long int y, const long int z);

Random access operator. Returns the reference to the data stored in a given grid location.

cpp
T const& operator()(const long int x, const long int y, const long int z) const;

Random access operator. Returns const reference to the data stored in a given grid location.

cpp
T at(const double x, const double y, const double z) const;

Returns the interpolated data in the given location between the grid points.

cpp
T& operator[](size_t idx);

Random access operator. Returns the reference to the data stored in a given flattened storage location.

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

Random access operator. Returns const reference to the data stored in a given flattened storage location.

cpp
T* data(void);

Returns the pointer to the internal raw data storage.

cpp
const T* data(void) const;

Returns const pointer to the internal raw data storage.

Container properties

cpp
bool IsNotAllocated() const;

Returns true if current container is not allocated.

cpp
bool IsAllocated() const;

Returns true if current container is allocated.

cpp
bool IsSize(const long int Nx, const long int Ny, const long int Nz);

Returns true if current container has given dimensions.

cpp
long int sizeX() const;

Returns X dimension of the storage.

cpp
long int sizeY() const;

Returns Y dimension of the storage.

cpp
long int sizeZ() const;

Returns Z dimension of the storage.

cpp
long int Bcells() const;

Returns the number of boundary cells

cpp
long int BcellsX() const;

Returns the number of boundary cells in X directions

cpp
long int BcellsY() const;

Returns the number of boundary cells in Y directions

cpp
long int BcellsZ() const;

Returns the number of boundary cells in Z directions

cpp
long int dNx() const;

Returns 1 is X dimension is active, 0 otherwise.

cpp
long int dNy() const;

Returns 1 is Y dimension is active, 0 otherwise.

cpp
long int dNz() const;

Returns 1 is Z dimension is active, 0 otherwise.

cpp
size_t size() const;

Returns the size of the internal flattened storage.

cpp
bool InLimits(const long int x, const long int y, const long int z);

Returns true if the given location is within the dimensions limits of the current container.

cpp
long int ActiveDimensions() const;

Returns the number of active dimensions: 3 for all three dimensions active, 2 for any two dimensions active, and 1 for a single dimension.

Data manipulation methods

cpp
void Remesh(const long int nX, const long int nY, const long int nZ);

Changes the dimensions of the container while keeping the data. Uses linear interpolation to recover the data at the new grid locations.

cpp
bool rotate(const long int newdimx, const long int newdimy, const long int newdimz);

Switching storage dimensions, e.g. changes storage dimensions arrangement.

cpp
void set_to_value(T val);

Sets all entries in the container to the given value.

cpp
void SetNewBcells(const int new_b_cells);

Sets new number of boundary cells. Destroys the stored data.

cpp
void Clear(void);

Clears the data while keeping the allocated storage dimension unchanged.

MPI communication methods

cpp
std::vector<double> pack(std::vector<long int> window);

Packs (writes) selected container content to the MPI communication buffer.

cpp
void unpack(std::vector<double>& buffer, std::vector<long int> window);

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

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

Packs (writes) the entire container content to the MPI communication buffer.

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

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

Input/output methods

cpp
void WriteToFile(std::string FileName);

Writes container content to the file in MPI-parallel mode.

Released under the GNU GPLv3 License.