Boundary

enum tug::BC_TYPE

Enum defining the two implemented boundary conditions.

Values:

enumerator BC_TYPE_CLOSED
enumerator BC_TYPE_CONSTANT
enum tug::BC_SIDE

Enum defining all 4 possible sides to a 1D and 2D grid.

Values:

enumerator BC_SIDE_LEFT
enumerator BC_SIDE_RIGHT
enumerator BC_SIDE_TOP
enumerator BC_SIDE_BOTTOM
template<class T>
class Boundary

This class implements the functionality and management of the boundary conditions in the grid to be simulated.

Template Parameters:

Data – type of the boundary condition value

Public Functions

inline Boundary(std::uint32_t length)

Creates a boundary object for a 1D grid.

Parameters:

length – Length of the grid

inline Boundary(std::uint32_t rows, std::uint32_t cols)

Creates a boundary object for a 2D grid.

Parameters:
  • rows – Number of rows of the grid

  • cols – Number of columns of the grid

inline void setBoundarySideClosed(BC_SIDE side)

Creates a boundary object based on the passed grid object and initializes the boundaries as closed.

Sets all elements of the specified boundary side to the boundary condition closed.

Parameters:
  • grid – Grid object on the basis of which the simulation takes place and from which the dimensions (in 2D case) are taken.

  • side – Side to be set to closed, e.g. BC_SIDE_LEFT.

inline void setBoundarySideConstant(BC_SIDE side, double value)

Sets all elements of the specified boundary side to the boundary condition constant. Thereby the concentration values of the boundaries are set to the passed value.

Parameters:
  • side – Side to be set to constant, e.g. BC_SIDE_LEFT.

  • value – Concentration to be set for all elements of the specified page.

inline void setBoundaryElemenClosed(BC_SIDE side, int index)

Specifically sets the boundary element of the specified side defined by the index to the boundary condition closed.

Parameters:
  • side – Side in which an element is to be defined as closed.

  • index – Index of the boundary element on the corresponding boundary side. Must index an element of the corresponding side.

inline void setBoundaryElementConstant(BC_SIDE side, int index, double value)

Specifically sets the boundary element of the specified side defined by the index to the boundary condition constant with the given concentration value.

Parameters:
  • side – Side in which an element is to be defined as constant.

  • index – Index of the boundary element on the corresponding boundary side. Must index an element of the corresponding side.

  • value – Concentration value to which the boundary element should be set.

inline const std::vector<BoundaryElement<T>> &getBoundarySide(BC_SIDE side) const

Returns the boundary condition of a specified side as a vector of BoundarsElement objects.

Parameters:

sideBoundary side from which the boundary conditions are to be returned.

Returns:

Contains the boundary conditions as BoundaryElement<T> objects.

inline Eigen::VectorX<T> getBoundarySideValues(BC_SIDE side) const

Get thes Boundary Side Values as a vector. Value is -1 in case some specific boundary is closed.

Parameters:

sideBoundary side for which the values are to be returned.

Returns:

Vector with values as T.

inline BoundaryElement<T> getBoundaryElement(BC_SIDE side, int index) const

Returns the boundary condition of a specified element on a given side.

Parameters:
  • sideBoundary side in which the boundary condition is located.

  • index – Index of the boundary element on the corresponding boundary side. Must index an element of the corresponding side.

Returns:

Boundary condition as a BoundaryElement<T> object.

inline BC_TYPE getBoundaryElementType(BC_SIDE side, int index) const

Returns the type of a boundary condition, i.e. either BC_TYPE_CLOSED or BC_TYPE_CONSTANT.

Parameters:
  • sideBoundary side in which the boundary condition type is located.

  • index – Index of the boundary element on the corresponding boundary side. Must index an element of the corresponding side.

Returns:

Boundary Type of the corresponding boundary condition.

inline T getBoundaryElementValue(BC_SIDE side, int index) const

Returns the concentration value of a corresponding BoundaryElement<T> object if it is a constant boundary condition.

Parameters:
  • sideBoundary side in which the boundary condition value is located.

  • index – Index of the boundary element on the corresponding boundary side. Must index an element of the corresponding side.

Returns:

Concentration of the corresponding BoundaryElement<T> object.

inline std::vector<BoundaryElement<T>> serialize() const

Serializes the boundary conditions into a vector of BoundaryElement objects.

Returns:

Vector with BoundaryElement objects.

inline void deserialize(const std::vector<BoundaryElement<T>> &serialized)

Deserializes the boundary conditions from a vector of BoundaryElement objects.

Parameters:

serialized – Vector with BoundaryElement objects.

inline void setInnerBoundary(std::uint32_t index, T value)
Parameters:
  • index – Index of the inner constant boundary condition

  • value – Value of the inner constant boundary condition

inline void setInnerBoundary(std::uint32_t row, std::uint32_t col, T value)

Set inner constant boundary condition in 2D case.

Parameters:
  • row – Row index of the inner constant boundary condition

  • col – Column index of the inner constant boundary condition

  • value – Value of the inner constant boundary condition

inline std::pair<bool, T> getInnerBoundary(std::uint32_t index) const

Get inner constant boundary condition in 1D case.

Parameters:

index – Index of the inner constant boundary condition

Returns:

std::pair<bool, T> Pair of boolean (whether constant boundary was set or not) and value of the inner constant boundary condition

inline std::pair<bool, T> getInnerBoundary(std::uint32_t row, std::uint32_t col) const

Get inner constant boundary condition in 2D case.

Parameters:
  • row – Row index of the inner constant boundary condition

  • col – Column index of the inner constant boundary condition

Returns:

std::pair<bool, T> Pair of boolean (whether constant boundary was set or not) and value of the inner constant boundary condition

inline std::vector<std::pair<bool, T>> getInnerBoundaryRow(std::uint32_t row) const

Get inner constant boundary conditions of a row as a vector. Can be used for 1D grids (row == 0) or 2D grids.

Parameters:

row – Index of the row for which the inner boundary conditions are to be returned.

Returns:

std::vector<std::pair<bool, T>> Vector of pairs of boolean (whether constant boundary was set or not) and value of the inner constant boundary condition

inline std::vector<std::pair<bool, T>> getInnerBoundaryCol(std::uint32_t col) const

Get inner constant boundary conditions of a column as a vector. Can only be used for 2D grids.

Parameters:

col – Index of the column for which the inner boundary conditions are to be returned.

Returns:

std::vector<std::pair<bool, T>> Vector of pairs of boolean (whether constant boundary was set or not) and value of the inner constant boundary condition

inline std::map<std::pair<std::uint32_t, std::uint32_t>, T> getInnerBoundaries() const

Get inner constant boundary conditions as a map. Can be read by setInnerBoundaries.

Returns:

Map of inner constant boundary conditions

inline void setInnerBoundaries(const std::map<std::pair<std::uint32_t, std::uint32_t>, T> &inner_boundary)

Set inner constant boundary conditions as a map. Can be obtained by getInnerBoundaries.

Parameters:

inner_boundary – Map of inner constant boundary conditions

template<class T>
class BoundaryElement

This class defines the boundary conditions of individual boundary elements. These can be flexibly used and combined later in other classes. The class serves as an auxiliary class for structuring the Boundary class.

Template Parameters:

T – Data type of the boundary condition element

Public Functions

inline BoundaryElement()

Construct a new Boundary Element object for the closed case. The boundary type is here automatically set to the type BC_TYPE_CLOSED, where the value takes -1 and does not hold any physical meaning.

inline BoundaryElement(T _value)

Construct a new Boundary Element object for the constant case. The boundary type is automatically set to the type BC_TYPE_CONSTANT.

Parameters:

value – Value of the constant concentration to be assumed at the corresponding boundary element.

inline void setType(BC_TYPE type)

Allows changing the boundary type of a corresponding BoundaryElement object.

Parameters:

type – Type of boundary condition. Either BC_TYPE_CONSTANT or BC_TYPE_CLOSED.

inline void setValue(double value)

Sets the value of a boundary condition for the constant case.

Parameters:

value – Concentration to be considered constant for the corresponding boundary element.

inline BC_TYPE getType() const

Return the type of the boundary condition, i.e. whether the boundary is considered closed or constant.

Returns:

Type of boundary condition, either BC_TYPE_CLOSED or BC_TYPE_CONSTANT.

inline T getValue() const

Return the concentration value for the constant boundary condition.

Returns:

Value of the concentration.