Skip to content

NodeAB

NodeAB<T1,T2> is a templated, double-indexed, dynamic storage container which stores only non-zero values of types T1 and T2. It is used as a storage unit in Storage3D container for dynamically changing fields.

The storage unit inside of the NodeAB<T1,T2> container is the DoubleIndexFieldEntry<T1,T2> which contains four members: indexA and indexB which are the integer indices of the stored entries, and the corresponding values value1<T1> and value<T2> of templated types T1 and T2 which are always stored together.

The data inside of the NodeAB container is manipulated using a number of dedicated methods:

Arithmetic operations

cpp
NodeAB<T1,T2> operator+(const NodeAB<T1,T2>& 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
NodeAB<T1,T2> operator-(const NodeAB<T1,T2>& 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
NodeAB<T1,T2> 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
NodeAB<T1,T2>& operator=(const NodeAB<T1,T2>& 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
NodeAB<T1,T2>& operator+=(const NodeAB<T1,T2>& n);
NodeAB<T1,T2>& operator-=(const NodeAB<T1,T2>& n);
NodeAB<T1,T2>& 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
void set1(const size_t n, const size_t m, const T1 value);

The method, which sets value1 to a specified value following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the enetry with the specified indices already exists in the container, its value1 is overwitten, otherwise a new entry is created with the specified indices and the given value1 and T2-type equivalent of zero for value2.

cpp
void set2(const size_t n, const size_t m, const T2 value);

The method, which sets value2 to a specified value following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the enetry with the specified indices already exists in the container, its value2 is overwitten, otherwise a new entry is created with the specified indices and the given value2 and T1-type equivalent of zero for value1.

cpp
T1 get1(const size_t n, const size_t m) const;

The method, which returns the value1 following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the enetry with the specified indices exists in the container, its value1 is returned, otherwise a T1-type equivalent of zero is returned. The data in the container is unmodified.

cpp
T2 get2(const size_t n, const size_t m) const;

The method, which returns the value2 following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the enetry with the specified indices exists in the container, its value2 is returned, otherwise a T2-type equivalent of zero is returned. The data in the container is unmodified.

cpp
void add1(const size_t n, const size_t m, const T1 value);

The method, which increments the value1 by a specified value following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the enetry with the specified indices already exists in the container, its value1 is incremented by the specified value, otherwise a new entry is created with the specified indices and the given value1 and T2-type equivalent of zero for value2.

cpp
void add2(const size_t n, const size_t m, const T1 value);

The method, which increments the value2 by a specified value following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the enetry with the specified indices already exists in the container, its value2 is incremented by the specified value, otherwise a new entry is created with the specified indices and the given value2 and T1-type equivalent of zero for value2.

cpp
void set_sym1(const size_t n, const size_t m, const T1 value);

The method, which sets value1 to a specified value ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as single entry. If the enetry with the specified indices already exists in the container, its value1 is overwitten, otherwise a new entry is created with the specified indices and the given value1 and T2-type equivalent of zero for value2.

cpp
void set_sym2(const size_t n, const size_t m, const T2 value);

The method, which sets value2 to a specified value ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as single entry. If the enetry with the specified indices already exists in the container, its value2 is overwitten, otherwise a new entry is created with the specified indices and the given value2 and T1-type equivalent of zero for value1.

cpp
T1 get_sym1(const size_t n, const size_t m) const;

The method, which returns the value1 ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as single entry. If the enetry with the specified indices exists in the container, its value1 is returned, otherwise a T1-type equivalent of zero is returned. The data in the container is unmodified.

cpp
T2 get_sym2(const size_t n, const size_t m) const;

The method, which returns the value2 ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as single entry. If the enetry with the specified indices exists in the container, its value2 is returned, otherwise a T2-type equivalent of zero is returned. The data in the container is unmodified.

cpp
void add_sym1(const size_t n, const size_t m, const T1 value);

The method, which increments the value1 by a specified value ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as single entry. If the enetry with the specified indices already exists in the container, its value1 is incremented by the specified value, otherwise a new entry is created with the specified indices and the given value1 and T2-type equivalent of zero for value2.

cpp
void add_sym2(const size_t n, const size_t m, const T1 value);

The method, which increments the value2 by a specified value ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as single entries. If the enetry with the specified indices already exists in the container, its value2 is incremented by the specified value, otherwise a new entry is created with the specified indices and the given value2 and T1-type equivalent of zero for value2.

cpp
void set_asym1(const size_t n, const size_t m, const T1 value);

The method, which sets value1 to a specified value considering strict index order treating entries with (n,m) index order and (m,n) index order as single entry. If the entry with the specified indices already exists in the container, its value1 is overwitten considering index order, e.g. reversing the sign of the value if index order is reversed, otherwise a new entry is created with the specified indices and the given value1 and T2-type equivalent of zero for value2.

cpp
void set_asym2(const size_t n, const size_t m, const T2 value);

The method, which sets value2 to a specified value considering strict index order treating entries with (n,m) index order and (m,n) index order as single entry. If the entry with the specified indices already exists in the container, its value2 is overwitten considering index order, e.g. reversing the sign of the value if index order is reversed, otherwise a new entry is created with the specified indices and the given value2 and T1-type equivalent of zero for value1.

cpp
T1 get_asym1(const size_t n, const size_t m) const;

The method, which returns the value1 considering strict index order treating entries with (n,m) index order and (m,n) index order as single entry. If the entry with the specified indices exists in the container, its value1 is returned considering index order, e.g. reversing the sign of the value if index order is reversed, otherwise a T1-type equivalent of zero is returned. The data in the container is unmodified.

cpp
T2 get_asym2(const size_t n, const size_t m) const;

The method, which returns the value2 considering strict index order treating entries with (n,m) index order and (m,n) index order as single entry. If the entry with the specified indices exists in the container, its value2 is returned considering index order, e.g. reversing the sign of the value if index order is reversed, otherwise a T2-type equivalent of zero is returned. The data in the container is unmodified.

cpp
void add_asym1(const size_t n, const size_t m, const T1 value);

The method, which increments value1 by a specified value considering strict index order treating entries with (n,m) index order and (m,n) index order as single entry. If the entry with the specified indices already exists in the container, its value1 is incremented considering index order, e.g. reversing the sign of the value if index order is reversed, otherwise a new entry is created with the specified indices and the given value1 and T2-type equivalent of zero for value2.

cpp
void add_asym2(const size_t n, const size_t m, const T1 value);

The method, which increments value2 by a specified value considering strict index order treating entries with (n,m) index order and (m,n) index order as single entry. If the entry with the specified indices already exists in the container, its value2 is incremented considering index order, e.g. reversing the sign of the value if index order is reversed, otherwise a new entry is created with the specified indices and the given value2 and T1-type equivalent of zero for value1.

cpp
void set_pair(const size_t n, const size_t m, const T1 value1,
                                              const T2 value2);

The method, which sets value1 and value2 to the specified values following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the entry with the specified indices already exists in the container, its value1 and value2 are overwitten, otherwise a new entry is created with the specified indices and the given value1 and value2.

cpp
void add_pair(const size_t n, const size_t m, const T1 value1,
                                              const T2 value2);

The method, which increments the value1 and value2 by the specified values following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the entry with the specified indices already exists in the container, its value1 and value2 are incremented by the specified values, otherwise a new entry is created with the specified indices and the given value1 and value2.

cpp
std::pair<T1,T2> get_pair(const size_t n, const size_t m) const;

The method, which returns a pair of value1 and value2 following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. If the entry with the specified indices already exists in the container, its value1 and value2 are returned, otherwise an equivalent of T1-type and T2-type zeros are returned.

cpp
void set_sym_pair(const size_t n, const size_t m, const T1 value1,
                                                  const T2 value2);

The method, which sets value1 and value2 to the specified values ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. If the entry with the specified indices already exists in the container, its value1 and value2 are overwitten, otherwise a new entry is created with the specified indices and the given value1 and value2.

cpp
void add_sym_pair(const size_t n, const size_t m, const T1 value1,
                                                  const T2 value2);

The method, which increments the value1 and value2 by the specified values ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. If the entry with the specified indices already exists in the container, its value1 and value2 are incremented by the specified values, otherwise a new entry is created with the specified indices and the given value1 and value2.

cpp
std::pair<T1,T2> get_sym_pair(const size_t n, const size_t m) const;

The method, which returns a pair of value1 and value2 ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. If the entry with the specified indices already exists in the container, its value1 and value2 are returned, otherwise an equivalent of T1-type and T2-type zeros are returned.

cpp
void set_asym_pair(const size_t n, const size_t m, const T1 value1,
                                                   const T2 value2);

The method, which sets value1 and value2 to the specified values considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. If the entry with the specified indices already exists in the container, its value1 and value2 are overwitten, considering strict index order, e.g. inversing the sign of teh values if the index order is reversed, otherwise a new entry is created with the specified indices and the given value1 and value2.

cpp
void add_asym_pair(const size_t n, const size_t m, const T1 value1,
                                                   const T2 value2);

The method, which increments value1 and value2 by the specified values considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. If the entry with the specified indices already exists in the container, its value1 and value2 are incremented, considering strict index order, e.g. inversing the sign of the values if the index order is reversed, otherwise a new entry is created with the specified indices and the given value1 and value2.

cpp
std::pair<T1,T2> get_asym_pair(const size_t n, const size_t m) const;

The method, which returns a pair of value1 and value2 considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. If the entry with the specified indices already exists in the container, its value1 and value2 are returned, considering strict index order, e.g. inversing the sign of the values if the index order is reversed, otherwise an equivalent of T1-type and T2-type zeros are returned.

cpp
void add1(const NodeAB<T1,T2>& value);

The method, which adds value1 of entries with identical indices from two contains following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. The entries with indices existing only in the incoming container are simply copied into the current container. The content of the current container is modified.

cpp
void add2(const NodeAB<T1,T2>& value);

The method, which adds value2 of entries with identical indices from two contains following strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as two independent entries. The entries with indices existing only in the incoming container are simply copied into the current container. The content of the current container is modified.

cpp
void add_sym1(const NodeAB<T1,T2>& value);

The method, which adds value1 of entries with identical indices from two contains ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with indices existing only in the incoming container are simply copied into the current container with value2 set to T2-type equivalent of zero. The content of the current container is modified.

cpp
void add_sym2(const NodeAB<T1,T2>& value);

The method, which adds value2 of entries with identical indices from two contains ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with indices existing only in the incoming container are simply copied into the current container with value1 set to T1-type equivalent of zero. The content of the current container is modified.

cpp
void add_asym1(const NodeAB<T1,T2>& value);

The method, which adds value1 of entries with identical indices from two contains considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with reverse order of indices are added with their signs inverted. The entries with indices existing only in the incoming container are simply copied into the current container with value2 set to T2-type equivalent of zero. The content of the current container is modified.

cpp
void add_asym2(const NodeAB<T1,T2>& value);

The method, which adds value2 of entries with identical indices from two contains considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with reverse order of indices are added with their signs inverted. The entries with indices existing only in the incoming container are simply copied into the current container with value1 set to T1-type equivalent of zero. The content of the current container is modified.

cpp
void add_sym_pairs(const NodeAB<T1,T2>& value);

The method, which adds value1 and value2 of entries with identical indices from two contains ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with indices existing only in the incoming container are simply copied into the current container. The content of the current container is modified.

cpp
void add_asym_pairs(const NodeAB<T1,T2>& value);

The method, which adds value1 and value2 of entries with identical indices from two contains considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with reverse order of indices are added with their signs inverted. The entries with indices existing only in the incoming container are simply copied into the current container. The content of the current container is modified.

cpp
void add_sym1_exist(const NodeAB<T1,T2>& value);

The method, which adds value1 of entries with identical indices existing in both contains ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with indices existing only in one of the containers are erased from the current container. The content of the current container is modified.

cpp
void add_sym2_exist(const NodeAB<T1,T2>& value);

The method, which adds value2 of entries with identical indices existing in both contains ignoring strict index order, e.g. treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with indices existing only in one of the containers are erased from the current container. The content of the current container is modified.

cpp
void add_asym1_exist(const NodeAB<T1,T2>& value);

The method, which adds value1 of entries with identical indices existing in both contains considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with reverse order of indices are added with their signs inverted. The entries with indices existing only in one of the containers are erased from the current container. The content of the current container is modified.

cpp
void add_asym2_exist(const NodeAB<T1,T2>& value);

The method, which adds value2 of entries with identical indices existing in both contains considering strict index order treating entries with (n,m) index order and (m,n) index order as a single entry. The entries with reverse order of indices are added with their signs inverted. The entries with indices existing only in one of the containers are erased from teh current container. The content of the current container is modified.

cpp
DoubleIndexFieldEntry<T1,T2>& front(void);

The method, which returns reference to the first entry in the underlying std::vector<> container.

cpp
const DoubleIndexFieldEntry<T1,T2>& front(void);

The method, which returns constant reference to first entry in the underlying std::vector<> container.

cpp
void clear()

The method, which clears the container erasing all entries.

cpp
bool present(const size_t idxA, const size_t idxB) const;

Returns true if the field with the given indices is present in the node, false otherwise.

Iterators

cpp
iterator begin();

Iterator to the begin of the underlying std::vector<> container which stores DoubleIndexFieldEntry<T1,T2> entries.

cpp
iterator end();

Iterator to the end of the underlying std::vector<> container which stores DoubleIndexFieldEntry<T1,T2> entries.

cpp
const_iterator cbegin();

Constant iterator to the begin of the underlying std::vector<> container which stores DoubleIndexFieldEntry<T1,T2> entries.

cpp
const_iterator cend();

Constant iterator to the end of the underlying std::vector<> container which stores DoubleIndexFieldEntry<T1,T2> entries.

cpp
iterator erase(iterator it);

The method which 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();

The method which returns the size of the underlying std::vector<> container. It is equivalent to the number of stored entries.

cpp
size_t capacity();

The method which 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);

The method, which packs the content of the current NodeAB object into the MPI communication buffer.

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

The method, which unpacks (reads) the content of the current NodeAB object from the MPI communication buffer. The existing data in the container is overwritten.

Read/write methods

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

The method, which reads the content of the current NodeAB object from the input stream.

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

The method, which writes the content of the current NodeAB object into the output stream.

Released under the GNU GPLv3 License.