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
cppStorage3D();Constructor. Creates empty storage object.
cppStorage3D(const Storage3D<T,0>& rhs);Copy constructor. Creates the storage object and initializes it with the content of rhs.
cppStorage3D(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.
cppStorage3D(const GridParameters Dimensions, const long int bc);Constructor. Creates and allocates memory for the storage of the given size.
cppvoid Allocate(const Storage3D<T,0>& rhs);Allocates previously created empty object to the dimensions of the rhs.
cppvoid AllocateCopy(const Storage3D<T,0>& rhs);Allocates previously created empty object to the dimensions of the rhs and initializes it with rhs's content.
cppsize_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.
cppsize_t Allocate(const GridParameters Dimensions, const long int bc);Allocates previously created empty object to the given dimensions.
cppvoid 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.
cppStorage3D<T,0>& operator=(const Storage3D<T,0>& rhs);Assignment operator. Assigns the copy of the rhs to the current container.
Access operators
cppT& 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.
cppT 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.
cppT at(const double x, const double y, const double z) const;Returns the interpolated data in the given location between the grid points.
cppT& operator[](size_t idx);Random access operator. Returns the reference to the data stored in a given flattened storage location.
cppT const& operator[](const size_t idx) const;Random access operator. Returns const reference to the data stored in a given flattened storage location.
cppT* data(void);Returns the pointer to the internal raw data storage.
cppconst T* data(void) const;Returns const pointer to the internal raw data storage.
Container properties
cppbool IsNotAllocated() const;Returns true if current container is not allocated.
cppbool IsAllocated() const;Returns true if current container is allocated.
cppbool IsSize(const long int Nx, const long int Ny, const long int Nz);Returns true if current container has given dimensions.
cpplong int sizeX() const;Returns X dimension of the storage.
cpplong int sizeY() const;Returns Y dimension of the storage.
cpplong int sizeZ() const;Returns Z dimension of the storage.
cpplong int Bcells() const;Returns the number of boundary cells
cpplong int BcellsX() const;Returns the number of boundary cells in X directions
cpplong int BcellsY() const;Returns the number of boundary cells in Y directions
cpplong int BcellsZ() const;Returns the number of boundary cells in Z directions
cpplong int dNx() const;Returns 1 is X dimension is active, 0 otherwise.
cpplong int dNy() const;Returns 1 is Y dimension is active, 0 otherwise.
cpplong int dNz() const;Returns 1 is Z dimension is active, 0 otherwise.
cppsize_t size() const;Returns the size of the internal flattened storage.
cppbool 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.
cpplong 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
cppvoid 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.
cppbool rotate(const long int newdimx, const long int newdimy, const long int newdimz);Switching storage dimensions, e.g. changes storage dimensions arrangement.
cppvoid set_to_value(T val);Sets all entries in the container to the given value.
cppvoid SetNewBcells(const int new_b_cells);Sets new number of boundary cells. Destroys the stored data.
cppvoid Clear(void);Clears the data while keeping the allocated storage dimension unchanged.
MPI communication methods
cppstd::vector<double> pack(std::vector<long int> window);Packs (writes) selected container content to the MPI communication buffer.
cppvoid unpack(std::vector<double>& buffer, std::vector<long int> window);Unpacks (reads) selected container content from the MPI communication buffer.
cppstd::vector<double> pack();Packs (writes) the entire container content to the MPI communication buffer.
cppvoid unpack(std::vector<double>& buffer);Unpacks (reads) the entire container content from the MPI communication buffer.
Input/output methods
cppvoid WriteToFile(std::string FileName);Writes container content to the file in MPI-parallel mode.