Storage1DTensor
Storage1DTensor<T, Rank> is the templated dynamic storage container to store one-dimensional, in terms of space dimensions, Tensor data (in each point) 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. The tensor dimensions can be specified during the run time.
The data inside of the Storage1DTensor container is manipulated using a number of dedicated methods:
Constructors
cppStorage1DTensor();Default constructor. Creates empty container.
cppStorage1DTensor(const long int nx, const std::array<size_t,Rank> tensor_dims, const long int bc);< Constructor. Creates a container of the specified size.
nxis the 1D domain length,tensor_dimsare the dimensions of the stored tensor andbcis the number of boundary cells.
cppStorage1DTensor(const Storage1DTensor<T,Rank>& rhs);Copy constructor. Creates and initializes the container with the copy of the
rhs.
cppvoid Allocate(const long int nx, const std::array<size_t,Rank> tensor_dims, const long int bc);Allocates previously created empty storage container.
nxis the 1D domain length,tensor_dimsare the dimensions of the stored tensor andbcis the number of boundary cells.
cppvoid Allocate(const Storage1DTensor<T,Rank>& rhs);Allocates current container to the dimensions of the
rhs.
cppvoid AllocateCopy(const Storage1DTensor<T,Rank>& rhs);Allocates current container and initializes it with the data from the
rhs.
cppvoid Reallocate(const long int nx);Reallocates non-empty container to new size
nxwhile keeping the number of boundary cells.
cppStorage1DTensor<T,Rank>& operator=(const Storage1DTensor<T,Rank>& rhs);Assignment operator. Assigns the copy of the rhs to the current container.
Access operators
cppTensor<T, Rank>& operator()(const long int x);Random access operator. Returns the reference to the tensor pointed to by the index
x.
cppTensor<T, Rank> const& operator()(const long int x) const;Random access operator. Returns const reference to the tensor pointed to by the index
x.
cppT& operator()(const long int x, const std::array<size_t, Rank> Position);Random access operator. Returns the reference to the storage element pointed to by the index
xandPositioninside of tensor.
cppconst T& operator()(const long int x, const std::array<size_t, Rank> Position) const;Random access operator. Returns const reference to the storage element pointed to by the index
xandPositioninside of tensor.
cppTensor<T, Rank> at(const double x) const;Arbitrary position access operator. Returns interpolated tensor at arbitrary location inside of the container dimensions.
cppTensor<T, Rank>& operator[](const size_t idx);Random access operator to the raw storage. Returns the reference to the element pointed to by the index
x.
cppTensor<T, Rank>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.
cppauto* data(void);Returns pointer to the raw data storage.
Container properties
cppbool IsNotAllocated() const;Returns true if the storage is not allocated.
cppbool IsAllocated() const;Returns true if the storage is allocated.
cppbool IsSize(const long int Nx);Returns true if the current storage is of the specified size Nx.
cppsize_t sizeX() const;Returns the size of the current container without boundary cells.
cpplong int Bcells() const;Returns the number of boundary cells.
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 total size of the container including boundary cells.
cppbool InLimits(const long int idx);Returns true if the specified idx is inside of the container dimensions.
Data manipulation methods
cppvoid Remesh(const long int nx);Remeshes the storage to new dimensions while keeping the data. Uses linear interpolation.
cppvoid SetNewBcells(const int new_b_cells);Sets new number of boundary cells. Scrambles stored data.
cppvoid set_to_value(Tensor<T, Rank>& val);Sets all entries of the container to the specified value
val.
cppvoid Clear(void);Clears the container while keeping its storage size.
MPI communication methods
cppstd::vector<double> pack();Packs (writes) the content of the current container into the MPI communication buffer.
cppvoid unpack(std::vector<double>& buffer);Unpacks (reads) the content of the current container from the MPI communication buffer.