File fieldgroup.hxx

Functions

FieldGroup operator+(const FieldGroup &lhs, const FieldGroup &rhs)

Combine two FieldGroups.

class FieldGroup
#include <fieldgroup.hxx>

Group together fields for easier communication

Note: The FieldData class is used as a base class, which is inherited by Field2D, Field3D, Vector2D and Vector3D however Vector2D and Vector3D are stored by reference to their components (x,y,z) as Field2D or Field3D objects.

Public Types

using iterator = std::vector::iterator

Iteration over all fields.

using const_iterator = std::vector::const_iterator

Const iteration over all fields.

Public Functions

FieldGroup()
FieldGroup(const FieldGroup &other)
FieldGroup(FieldGroup &&other)
FieldGroup &operator=(const FieldGroup &other)
FieldGroup &operator=(FieldGroup &&other)
FieldGroup(FieldData &f)

Constructor with a single FieldData f.

FieldGroup(Field3D &f)

Constructor with a single Field3D f.

FieldGroup(Vector2D &v)

Constructor with a single Vector2D v

This is needed so that fvec only contains Field2D or Field3D

FieldGroup(Vector3D &v)

Constructor with a single Vector3D v

This is needed so that fvec only contains Field2D or Field3D

template<typename ...Ts>
FieldGroup(Ts&... ts)

Variadic constructor. Allows an arbitrary number of FieldData arguments

The explicit keyword prevents FieldGroup being constructed with arbitrary types. In particular arguments to add() cannot be implicitly converted to FieldGroup, leading to an infinite loop.

void add(const FieldGroup &other)

Copy contents of another FieldGroup other into this group.

FieldGroup &operator+=(const FieldGroup &other)

Add the contents of other to this.

void add(FieldData &f)

Add a FieldData f to the group.

A pointer to this field will be stored internally, so the lifetime of this variable should be longer than the lifetime of this group.

void add(Field3D &f)
void add(Vector2D &v)

Add a Vector2D v to the group.

Pointers to this vector’s components will be stored internally, so the lifetime of this variable should be longer than the lifetime of this group.

void add(Vector3D &v)

Add a Vector3D v to the group.

Pointers to this vector’s components will be stored internally, so the lifetime of this variable should be longer than the lifetime of this group.

template<typename ...Ts>
void add(FieldData &t, Ts&... ts)

Add multiple fields to this group

This is a variadic template which allows Field3D objects to be treated as a special case. An arbitrary number of fields can be added.

template<typename ...Ts>
void add(Field3D &t, Ts&... ts)
template<typename ...Ts>
void add(Vector3D &t, Ts&... ts)
template<typename ...Ts>
void add(Vector2D &t, Ts&... ts)
int size() const

Return number of fields.

int size_field3d() const

Return number of Field3Ds.

bool empty() const

Test whether this group is empty.

void clear()

Remove all fields from this group.

iterator begin()
iterator end()
const_iterator begin() const
const_iterator end() const
const std::vector<FieldData *> &get() const
const std::vector<Field3D *> &field3d() const

Iteration over 3D fields.

void makeUnique()

Ensure that each field appears only once.

Private Members

std::vector<FieldData *> fvec
std::vector<Field3D *> f3vec