Skip to content

NodePF

NodePF is an indexed, dynamic storage container which stores only non-zero values of the local phase fields and their derivatives. It is used as a storage unit in Storage3D container.

The storage unit inside of the NodePF container is the PhaseFieldEntry which contains four entries: index which designates the phase-field index, value which is the value of the stored phase field, gradient, a dVector3 container storing the phase-field gradient, laplacian which is the phase-field Laplacian value. All these parameters are always stored together in one structure.

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

Constructors

cpp
NodePF();

Default constructor. Creates empty node.

cpp
NodePF(const NodePF& n);

Copy constructor. Initializes current container with the copy of n.

Arithmetic operations

cpp
NodePF operator+(const NodePF& 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
NodePF operator-(const NodePF& 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
NodePF 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
NodePF& operator=(const NodePF& 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
NodePF& operator+=(const NodePF& n);
NodePF& operator-=(const NodePF& n);
NodePF& 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 the given phase-field 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 double value);

Sets the value of the entry with the phase-field 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 double value);

Adds the value to the entry with the phase-field 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
double get_value(const size_t n) const;

Returns the value of the phase-field n. If the entry with index n does not exists in the container zero value is returned.

cpp
void set_laplacian(const size_t n, const double laplacian);

Sets Laplacian of the phase-field n.

cpp
void add_laplacian(const size_t n, const double laplacian);

Increments Laplacian of the phase-field with index n.

cpp
void add_laplacian_tmp(const size_t n, const double laplacian);

Increments temporary Laplacian of the phase-field n(used to avoid data race condition in OpenMP parallel mode).

cpp
double get_laplacian(const size_t n) const;

Returns Laplacian of the phase-field n. If the entry with index n does not exists in the container zero value is returned.

cpp
void set_gradient(const size_t n, const dVector3 gradient);

Sets gradient of the phase-field n.

cpp
void add_gradient(const size_t n, const dVector3 gradient);

Increments gradient of the phase-field n.

cpp
void add_gradient_tmp(const size_t n, const dVector3 gradient);

Increments temporary gradient of the phase-field n (used to avoid data race condition in OpenMP parallel mode).

cpp
dVector3 get_gradient(const size_t n) const;

Returns gradient for the phase-field n. If the entry with index n does not exists in the container zero vector is returned.

cpp
NodeA<dVector3> get_gradients() const;

Returns NodeA containing gradients of all phase-fields stored in teh current node.

cpp
void set_derivatives(const size_t n, const double laplacian, const dVector3 gradient);

Sets gradient and Laplacian for the phase-field n.

cpp
void add_derivatives(const size_t n, const double laplacian, const dVector3 gradient);

Increments values of gradient and Laplacian of teh phase field n.

cpp
std::pair<double,dVector3> get_derivatives(const size_t n) const;

Returns std::pair<Laplacian, gradient> containing Laplacian and gradient of the phase field n.

cpp
void set_all(const size_t n, const double value, const double laplacian, const dVector3 gradient);

Sets value, Laplacian and gradient of the phase field n.

cpp
void add_all(const size_t n, const double value, const double laplacian, const dVector3 gradient);

Increments value and Laplacian and gradient of the phase field n.

cpp
void get_all(const size_t n, double& value, double& laplacian, dVector3& gradient) const;

Returns (by reference) value, Laplacian and gradient of the phase field n.

cpp
void add_values(const NodePF& value);

Adds values of phase fields from incoming container to the current one.

cpp
void add_laplacians(const NodePF& value);

Adds Laplacians from incoming container to the current one.

cpp
void add_gradients(const NodePF& value);

Adds gradients from incoming container to the current one.

cpp
void add_derivatives(const NodePF& value);

Adds derivatives from incoming container to the current one.

cpp
void add_existing_values(const NodePF& value);

Adds only values of phase fields existing in the current and incoming nodes simultaneously.

cpp
void add_existing_all(const NodePF& value);

Adds only phase-field entries existing in the current and incoming nodes simultaneously.

cpp
void set_temporary(void);

Sets temporary copy of the node data (used to avoid data race condition in OpenMP parallel mode).

cpp
void copy_from_temporary(void);

Restores node data from its temporary storage (used to avoid data race condition in OpenMP parallel mode).

cpp
PhaseFieldEntry get_max(void) const;

Returns PhaseFieldEntry with the maximum phase-field value.

cpp
PhaseFieldEntry& front(void);

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

cpp
const PhaseFieldEntry& front(void);

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

cpp
void clear()

Clears the container erasing all entries. Sets flag to 0.

cpp
int finalize(void);

Adjusts phase-field values to (0,1] interval. Makes sure that the phase-fields um contraint is fullfilled.

cpp
int majority_index(void) const;

Returns index of the phase field with the highest value in the current container instance.

Node location indicators

cpp
int flag;

Interface flag. It is set to 1 if the node is located near the interface, 2 if it is in the interface and 0 if it is in the bulk.

cpp
bool interface(void) const;

Returns true if flag == 2.

cpp
bool interface_halo(void) const;

Returns true if flag == 1.

cpp
bool wide_interface(void) const;

Returns true if flag != 0.

cpp
bool bulk(void) const;

Returns true if flag != 2.

Iterators

cpp
iterator begin();

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

cpp
iterator end();

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

cpp
const_iterator cbegin();

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

cpp
const_iterator cend();

Constant iterator to the end of the underlying std::vector<> container which stores PhaseFieldEntry 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 (writes) the content of the current NodePF object into the MPI communication buffer.

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

Unpacks (reads) the content of the current NodePF 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 NodePF object from the input stream.

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

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

Released under the GNU GPLv3 License.