Skip to content

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

cpp
NodeA<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.

cpp
NodeA<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.

cpp
NodeA<T> operator*(const double n);

Multiplication operator, which multiplies all values stored in the container by a specified number n and copies the result into the output container. The content of the input container is not changed.

cpp
NodeA<T>& operator=(const NodeA<T>& n);

Assignment operator, which copies the content of container n into the receiving container. The initial content of the receiving container is erased and all the entries stored in the right-hand-side container n are copied into it. The content of the container n is unchanged.

cpp
NodeA<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

cpp
bool present(const size_t idx) const;

Checks if the entry with a given index idx exists in the current container. It returns true if the entry if found in the container, false otherwise. The content of the container is unchanged.

cpp
void set_value(const size_t n, const T& value);

Sets the value of the entry with index n to a given value. If the entry already exists in the container its value is overwritten, otherwise the new entry with index n and value value is created.

cpp
void add_value(const size_t n, const T& value);

Adds the value to the entry with the index n in the current container. If the entry with index n does not exists in the container it is created with the value value.

cpp
T get_value(const size_t n) const;

Returns the value with index n. If the entry with index n does not exists in the container the default contracted value T() is returned, which in the case of ordinary arithmetic types amounts to zero.

cpp
void add_values(const NodeA<T>& value);

Has the same effect as operator+=.

cpp
void 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.

cpp
SingleIndexFieldEntry<T>& front(void);

Returns reference to the first entry in the underlying std::vector<> container.

cpp
const SingleIndexFieldEntry<T>& front(void);

Returns constant reference to the first entry in the underlying std::vector<> container.

cpp
void clear()

Clears the container erasing all entries.

Iterators

cpp
iterator begin();

Iterator to the begin of the underlying std::vector<> container which stores SingleIndexFieldEntry<T> entries.

cpp
iterator end();

Iterator to the end of the underlying std::vector<> container which stores SingleIndexFieldEntry<T> entries.

cpp
const_iterator cbegin();

Constant iterator to the begin of the underlying std::vector<> container which stores SingleIndexFieldEntry<T> entries.

cpp
const_iterator cend();

Constant iterator to the end of the underlying std::vector<> container which stores SingleIndexFieldEntry<T> entries.

cpp
iterator 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

cpp
size_t size();

Returns the size of the underlying std::vector<> container. It is equivalent to the number of stored entries.

cpp
size_t capacity();

Returns the capacity of the underlying std::vector<> container. It is equivalent to the number of stored entries.

MPI communication methods

cpp
void pack(std::vector<double>& buffer);

Packs (rites) the content of the current NodeA object into the MPI communication buffer.

cpp
void unpack(std::vector<double>& buffer, size_t& it);

Unpacks (reads) the content of the current NodeA object from the MPI communication buffer. The existing data in the container is overwritten.

Read/write methods

cpp
void read(std::istream& inp);

Reads the content of the current NodeA object from the input stream.

cpp
void write(std::ostream& outp) const;

Writes the content of the current NodeA object into the output stream.

Released under the GNU GPLv3 License.