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
cppStorage3D();Constructor. Creates empty object.
cpptorage3D(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.
cppStorage3D(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.
cppStorage3D(const Storage3D<T,Rank>& rhs);Copy constructor. Creates the storage object and initializes it with the content of.
cppvoid 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.
cppvoid Allocate(const GridParameters Dimensions, const std::array<size_t,Rank> nn, const long int bc);Allocates previously created empty object to the given dimensions.
cppvoid Allocate(const Storage3D<T,Rank>& rhs);Allocates previously created empty object to the dimensions of the rhs.
cppvoid AllocateCopy(const Storage3D<T,Rank>& rhs);Allocates previously created empty object to the dimensions of the rhs and initializes it with rhs's content.
cppStorage3D<T,Rank>& operator=(const Storage3D<T,Rank>& rhs);Assignment operator. Assigns the copy of the rhs to the current container.
cppvoid 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
cppTensor<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.
cppTensor<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.
cppT& 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.
cppconst 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.
cppTensor<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.
cppTensor<T, Rank>& operator[](const size_t idx);Random access operator. Returns the reference to the tensor object stored in a given flattened storage location.
cppTensor<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.
cppauto* data(void);Returns the pointer to the 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.
cppconstexpr size_t tensor_rank(void) const;Returns the rank of the stored tensors.
cppsize_t tensor_size(size_t n) const;Returns the size of the tensor dimension n.
cppsize_t tensor_size() const;Returns the size of the storage occupied by the single tensor
cppsize_t size() const;Returns the size of the storage of tensors.
cppint 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.
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
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.
cppvoid SetNewBcells(const int new_b_cells);Sets new number of boundary cells. Destroys the stored data.
cppvoid set_to_value(Tensor<T, Rank>& val);Sets all entries in the container to the given value.
cppvoid Clear(void);Clears the data while keeping the allocate storage dimensions 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.
cppvoid ReadFromFile(std::string FileName);Reads container content from the file