NodeA
NodeA<T> is a templated, indexed, dynamic storage container which stores only non-zero values of type T. It is used as a storage unit in Storage3D container for dynamically changing fields.
The storage unit inside of the NodeA<T> container is the SingleIndexFieldEntry<T> which contains two members: index and corresponding value of type T which are always stored together.
The data inside of the NodeA container is manipulated using a number of dedicated methods:
Arithmetic operations
cppNodeA<T> operator+(const NodeA<T>& n);Plus operator, which adds values with identical indices from two contains. The entries with indices existing only in one of the containers are simply copied into the resulting output container. The content of both operands is not changed.
cppNodeA<T> operator-(const NodeA<T>& n);Minus operator, which subtracts the values with identical indices from two containers. The entries with indices existing only in the leftmost container are simply copied into the resulting output container. The entries with indices existing only in the rightmost container are copied into the resulting container with their signs inverted. The content of both operands is not changed.
cppNodeA<T> operator*(const double n);Multiplication operator, which multiplies all values stored in the container by a specified number
nand copies the result into the output container. The content of the input container is not changed.
cppNodeA<T>& operator=(const NodeA<T>& n);Assignment operator, which copies the content of container
ninto the receiving container. The initial content of the receiving container is erased and all the entries stored in the right-hand-side containernare copied into it. The content of the containernis unchanged.
cppNodeA<T>& operator+=(const NodeA<T>& n); NodeA<T>& operator-=(const NodeA<T>& n); NodeA<T>& operator*=(const double n);Arithmetic operators similar to the ordinary operators above except they modify the left-hand-side container and return a reference to it instead of returning a new container.
Data access and manipulation
cppbool present(const size_t idx) const;Checks if the entry with a given index
idxexists in the current container. It returnstrueif the entry if found in the container,falseotherwise. The content of the container is unchanged.
cppvoid set_value(const size_t n, const T& value);Sets the value of the entry with index
nto a givenvalue. If the entry already exists in the container its value is overwritten, otherwise the new entry with indexnand valuevalueis created.
cppvoid add_value(const size_t n, const T& value);Adds the
valueto the entry with the indexnin the current container. If the entry with indexndoes not exists in the container it is created with the valuevalue.
cppT get_value(const size_t n) const;Returns the value with index
n. If the entry with indexndoes not exists in the container the default contracted valueT()is returned, which in the case of ordinary arithmetic types amounts to zero.
cppvoid add_values(const NodeA<T>& value);Has the same effect as
operator+=.
cppvoid add_existing_values(const NodeA<T>& value);Adds to the current container the values of the entries with indices existing in the current and the incoming containers. The other values are ignored.
cppSingleIndexFieldEntry<T>& front(void);Returns reference to the first entry in the underlying
std::vector<>container.
cppconst SingleIndexFieldEntry<T>& front(void);Returns constant reference to the first entry in the underlying
std::vector<>container.
cppvoid clear()Clears the container erasing all entries.
Iterators
cppiterator begin();Iterator to the begin of the underlying
std::vector<>container which storesSingleIndexFieldEntry<T>entries.
cppiterator end();Iterator to the end of the underlying
std::vector<>container which storesSingleIndexFieldEntry<T>entries.
cppconst_iterator cbegin();Constant iterator to the begin of the underlying
std::vector<>container which storesSingleIndexFieldEntry<T>entries.
cppconst_iterator cend();Constant iterator to the end of the underlying
std::vector<>container which storesSingleIndexFieldEntry<T>entries.
cppiterator erase(iterator it);Erases the entry pointed to by the iterator it. It returns the next iterator following the erazed one. The storage is modified and its size is reduced.
Container properties
cppsize_t size();Returns the size of the underlying
std::vector<>container. It is equivalent to the number of stored entries.
cppsize_t capacity();Returns the capacity of the underlying
std::vector<>container. It is equivalent to the number of stored entries.
MPI communication methods
cppvoid pack(std::vector<double>& buffer);Packs (rites) the content of the current
NodeAobject into the MPI communication buffer.
cppvoid unpack(std::vector<double>& buffer, size_t& it);Unpacks (reads) the content of the current
NodeAobject from the MPI communication buffer. The existing data in the container is overwritten.
Read/write methods
cppvoid read(std::istream& inp);Reads the content of the current
NodeAobject from the input stream.
cppvoid write(std::ostream& outp) const;Writes the content of the current
NodeAobject into the output stream.