Storage1D
Storage1D<T> is the templated dynamic storage container to store one-dimensional, in terms of space dimension, data. 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.
The data inside of the Storage1D container is manipulated using a number of dedicated methods:
Constructors
cppStorage1D();Default constructor. Creates empty container.
cppStorage1D(const Storage1D<T>& rhs);Copy constructor. Creates and initializes the container with the copy of the rhs.
cppStorage1D(const long int nx, const long int bc);Constructor. Creates a container of the specified size.
nxis the 1D domain length andbcis the number of boundary cells.
cppvoid Allocate(const long int nx, const long int bc);Allocates previously created empty storage container.
cppvoid Reallocate(const long int nx);Reallocates non-empty container to new size while keeping the number of boundary cells.
cppvoid AllocateCopy(const Storage1D<T>& rhs);Allocates current container and initializes it with the data from the rhs.
Access operators
cppT& operator()(const long int x);Random access operator. Returns the reference to the element pointed to by the index x.
cppT const& operator()(const long int x) const;Random access operator. Returns const reference to the element pointed to by the index x.
cppT at(const double x) const;Arbitrary position access operator. Returns interpolated value at arbitrary location inside of the container dimensions.
cppT& operator[](size_t idx);Random access operator to the raw storage. Returns the reference to the element pointed to by the index x.
cppT 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.
cppT* data(void);Returns pointer to the raw data storage.
cppconst T* data(void) const;Returns const pointer to the raw data storage.
Data manipulation methods
cppvoid Remesh(const long int nx);Remeshes the storage to new dimensions while keeping the data. Uses linear interpolation.
cppStorage1D<T>& operator=(const Storage1D<T>& rhs);Assignment operator. Assigns the copy of the rhs to the current container.
cppvoid Clear(void);Clears the container while keeping its storage size.
cppvoid set_to_value(T value);Sets all entries of the container to the specified value.
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.
cppsize_t size() const;Returns total size of the container including boundary cells.
cppvoid SetNewBcells(const int new_b_cells);Sets new number of boundary cells. Scrambles stored data.
cppbool InLimits(const long int idx);Returns true if the specified idx is inside of the container dimensions.
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.