Skip to content

Storage3D<T,Rank != 0>

Storage3D<T, Rank != 0> is the templated dynamic storage container to store three-dimensional, in terms of space dimensions, Tensor 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 a tensor-like storage of the given Rank in each grid point. The tensor dimensions can be specified during the run time.

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

Constructors

cpp
Storage3D();

Constructor. Creates empty object.

cpp
torage3D(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 std::array<size_t,Rank> nn, const long int bc);

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

cpp
Storage3D(const GridParameters Dimensions, const std::array<size_t,Rank> nn, const long int bc);

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

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

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

cpp
void 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 std::array<size_t,Rank> nn, const long int bc);

Allocates previously created empty object to the given dimensions.

cpp
void Allocate(const GridParameters Dimensions, const std::array<size_t,Rank> nn, const long int bc);

Allocates previously created empty object to the given dimensions.

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

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

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

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

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

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

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 tensor dimensions and the number of boundary cells the same. Destroys the stored data.

Access operators

cpp
Tensor<T, Rank>& operator()(const long int x, const long int y, const long int z);

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

cpp
Tensor<T, Rank> const& operator()(const long int x, const long int y, const long int z) const;

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

cpp
T& operator()(const long int x, const long int y, const long int z, const std::array<size_t, Rank> Position);

Random access operator. Returns the reference to the tensor element stored in a given grid location and position in the tensor.

cpp
const T& operator()(const long int x, const long int y, const long int z, const std::array<size_t, Rank> Position) const;

Random access operator. Returns const reference to the tensor element stored in a given grid location and position in the tensor.

cpp
Tensor<T, Rank> at(const double x, const double y, const double z) const;

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

cpp
Tensor<T, Rank>& operator[](const size_t idx);

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

cpp
Tensor<T, Rank> const& operator[](const size_t idx) const;

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

cpp
auto* data(void);

Returns the pointer to the 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
constexpr size_t tensor_rank(void) const;

Returns the rank of the stored tensors.

cpp
size_t tensor_size(size_t n) const;

Returns the size of the tensor dimension n.

cpp
size_t tensor_size() const;

Returns the size of the storage occupied by the single tensor

cpp
size_t size() const;

Returns the size of the storage of tensors.

cpp
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.

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

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
void SetNewBcells(const int new_b_cells);

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

cpp
void set_to_value(Tensor<T, Rank>& val);

Sets all entries in the container to the given value.

cpp
void Clear(void);

Clears the data while keeping the allocate storage dimensions 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.

cpp
void ReadFromFile(std::string FileName);

Reads container content from the file

Released under the GNU GPLv3 License.