4.2.1.5. pde.grids.boundaries.local module

This module contains classes for handling a single boundary of a non-periodic axis. Since an axis has two boundary, we simply distinguish them by a boolean flag upper, which is True for the side of the axis with the larger coordinate.

The module currently supports different boundary conditions:

  • DirichletBC: Imposing the value of a field at the boundary

  • NeumannBC: Imposing the derivative of a field in the outward normal direction at the boundary

  • MixedBC: Imposing the derivative of a field in the outward normal direction proportional to its value at the boundary

  • CurvatureBC: Imposing the second derivative (curvature) of a field at the boundary

There are also additional classes that impose boundary conditions only for the normal components of fields, which can be important for vector and tensor fields. The classes corresponding to the ones listed above are DirichletNormalBC, NeumannNormalBC, MixedNormalBC, and CurvatureNormalBC.

Note that derivatives are generally given in the direction of the outward normal vector, such that positive derivatives correspond to a function that increases across the boundary.

class BCBase(grid: GridBase, axis: int, upper: bool, *, rank: int = 0)[source]

Bases: object

represents a single boundary in an BoundaryPair instance

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

property axis_coord: float

value of the coordinate that defines this boundary condition

Type

float

check_value_rank(rank: int) None[source]

check whether the values at the boundaries have the correct rank

Parameters

rank (int) – The tensorial rank of the field for this boundary condition

Throws:

RuntimeError: if the value does not have rank rank

abstract copy(upper: Optional[bool] = None, rank: int = None) BCBase[source]
abstract extract_component(*indices)[source]
classmethod from_data(grid: GridBase, axis: int, upper: bool, data: Union[Dict, str, BCBase], rank: int = 0) BCBase[source]

create boundary from some data

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Indicates whether this boundary condition is associated with the upper or lower side of the axis.

  • data (str or dict) – Data that describes the boundary

  • rank (int) – The tensorial rank of the field for this boundary condition

Returns

the instance created from the data

Return type

BCBase

Throws:

ValueError if data cannot be interpreted as a boundary condition

classmethod from_dict(grid: GridBase, axis: int, upper: bool, data: Dict[str, Any], rank: int = 0) BCBase[source]

create boundary from data given in dictionary

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Indicates whether this boundary condition is associated with the upper or lower side of the axis.

  • data (dict) – The dictionary defining the boundary condition

  • rank (int) – The tensorial rank of the field for this boundary condition

classmethod from_str(grid: GridBase, axis: int, upper: bool, condition: str, rank: int = 0, **kwargs) BCBase[source]

creates boundary from a given string identifier

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Indicates whether this boundary condition is associated with the upper or lower side of the axis.

  • condition (str) – Identifies the boundary condition

  • rank (int) – The tensorial rank of the field for this boundary condition

  • **kwargs – Additional arguments passed to the constructor

get_data(idx: Tuple[int, ...]) Tuple[float, Dict[int, float]][source]
classmethod get_help() str[source]

Return information on how boundary conditions can be set

get_virtual_point(arr, idx: Optional[Tuple[int, ...]] = None) float[source]
homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

make_adjacent_evaluator() Callable[[ndarray, int, Tuple[int, ...]], float][source]
make_ghost_cell_setter() Callable[[...], None][source]

return function that sets the ghost cells for this boundary

abstract make_virtual_point_evaluator() Callable[[...], float][source]
names: List[str]

identifiers used to specify the given boundary class

Type

list

normal: bool = False

Flag indicating whether only the normal components are affected

Type

bool

property periodic: bool

whether the axis is periodic

Type

bool

abstract set_ghost_cells(data_full: ndarray, *, args=None) None[source]

set the ghost cell values for this boundary

exception BCDataError[source]

Bases: ValueError

exception that signals that incompatible data was supplied for the BC

class ConstBC1stOrderBase(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: ConstBCBase

represents a single boundary in an BoundaryPair instance

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

get_data(idx: Tuple[int, ...]) Tuple[float, Dict[int, float]][source]

sets the elements of the sparse representation of this condition

Parameters

idx (tuple) – The index of the point that must lie on the boundary condition

Returns

A constant value and a dictionary with indices and factors that can be used to calculate this virtual point

Return type

float, dict

get_virtual_point(arr, idx: Optional[Tuple[int, ...]] = None) float[source]

calculate the value of the virtual point outside the boundary

Parameters
  • arr (array) – The data values associated with the grid

  • idx (tuple) – The index of the point to evaluate. This is a tuple of length grid.num_axes with the either -1 or dim as the entry for the axis associated with this boundary condition. Here, dim is the dimension of the axis. The index is optional if dim == 1.

Returns

Value at the virtual support point

Return type

float

abstract get_virtual_point_data(compiled: bool = False) Tuple[Any, Any, int][source]
make_adjacent_evaluator() Callable[[ndarray, int, Tuple[int, ...]], float][source]

returns a function evaluating the value adjacent to a given point

Returns

A function with signature (arr_1d, i_point, bc_idx), where arr_1d is the one-dimensional data array (the data points along the axis perpendicular to the boundary), i_point is the index into this array for the current point and bc_idx are the remaining indices of the current point, which indicate the location on the boundary plane. The result of the function is the data value at the adjacent point along the axis associated with this boundary condition in the upper (lower) direction when upper is True (False).

Return type

function

make_virtual_point_evaluator() Callable[[...], float][source]

returns a function evaluating the value at the virtual support point

Returns

A function that takes the data array and an index marking the current point, which is assumed to be a virtual point. The result is the data value at this point, which is calculated using the boundary condition.

Return type

function

set_ghost_cells(data_full: ndarray, *, args=None) None[source]

set the ghost cell values for this boundary

Parameters
  • data_full (ndarray) – The full field data including ghost points

  • args – Additional arguments that might be supported by special boundary conditions.

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class ConstBC2ndOrderBase(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: ConstBCBase

abstract base class for boundary conditions of 2nd order

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

get_data(idx: Tuple[int, ...]) Tuple[float, Dict[int, float]][source]

sets the elements of the sparse representation of this condition

Parameters

idx (tuple) – The index of the point that must lie on the boundary condition

Returns

A constant value and a dictionary with indices and factors that can be used to calculate this virtual point

Return type

float, dict

get_virtual_point(arr, idx: Optional[Tuple[int, ...]] = None) float[source]

calculate the value of the virtual point outside the boundary

Parameters
  • arr (array) – The data values associated with the grid

  • idx (tuple) – The index of the point to evaluate. This is a tuple of length grid.num_axes with the either -1 or dim as the entry for the axis associated with this boundary condition. Here, dim is the dimension of the axis. The index is optional if dim == 1.

Returns

Value at the virtual support point

Return type

float

abstract get_virtual_point_data() Tuple[Any, Any, int, Any, int][source]

return data suitable for calculating virtual points

Returns

the data associated with this virtual point

Return type

tuple

make_adjacent_evaluator() Callable[[ndarray, int, Tuple[int, ...]], float][source]

returns a function evaluating the value adjacent to a given point

Returns

A function with signature (arr_1d, i_point, bc_idx), where arr_1d is the one-dimensional data array (the data points along the axis perpendicular to the boundary), i_point is the index into this array for the current point and bc_idx are the remaining indices of the current point, which indicate the location on the boundary plane. The result of the function is the data value at the adjacent point along the axis associated with this boundary condition in the upper (lower) direction when upper is True (False).

Return type

function

make_virtual_point_evaluator() Callable[[...], float][source]

returns a function evaluating the value at the virtual support point

Returns

A function that takes the data array and an index marking the current point, which is assumed to be a virtual point. The result is the data value at this point, which is calculated using the boundary condition.

Return type

function

set_ghost_cells(data_full: ndarray, *, args=None) None[source]

set the ghost cell values for this boundary

Parameters
  • data_full (ndarray) – The full field data including ghost points

  • args – Additional arguments that might be supported by special boundary conditions.

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class ConstBCBase(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: BCBase

base class representing a boundary whose virtual point is set from constants

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

copy(upper: Optional[bool] = None, rank: int = None, value: Optional[Union[float, ndarray, str]] = None) ConstBCBase[source]

return a copy of itself, but with a reference to the same grid

extract_component(*indices)[source]

extracts the boundary conditions for the given component

Parameters

*indices – One or two indices for vector or tensor fields, respectively

link value of this boundary condition to external array

property value: ndarray
value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class CurvatureBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: ConstBC2ndOrderBase

represents a boundary condition imposing the 2nd normal derivative at the boundary

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

get_virtual_point_data() Tuple[ndarray, ndarray, int, ndarray, int][source]

return data suitable for calculating virtual points

Returns

the data structure associated with this virtual point

Return type

tuple

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['curvature', 'second_derivative', 'extrapolate']

identifiers used to specify the given boundary class

Type

list

normal: bool = False

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class CurvatureNormalBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: CurvatureBC

represents a boundary condition imposing the 2nd normal derivative at the boundary only on the normal component of the tensor field

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['curvature_normal']

identifiers used to specify the given boundary class

Type

list

normal: bool = True

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class DirichletBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: ConstBC1stOrderBase

represents a boundary condition imposing the value

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

get_virtual_point_data(compiled: bool = False) Tuple[Any, Any, int][source]

return data suitable for calculating virtual points

Parameters

compiled (bool) – Flag indicating whether a compiled version is required, which automatically takes updated values into account when it is used in numba-compiled code.

Returns

the data structure associated with this virtual point

Return type

BC1stOrderData

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['value', 'dirichlet']

identifiers used to specify the given boundary class

Type

list

normal: bool = False

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class DirichletNormalBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: DirichletBC

represents a boundary condition imposing the normal component of a value

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['normal_value', 'normal_component', 'value_normal', 'dirichlet_normal']

identifiers used to specify the given boundary class

Type

list

normal: bool = True

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class ExpressionBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, str] = 0, target: str = 'virtual_point')[source]

Bases: BCBase

represents a boundary whose virtual point is calculated from an expression

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str) – An expression that determines the value of the boundary condition.

  • target (str) – Selects which value is actually set. Possible choices include value, derivative, and virtual_point.

copy(upper: Optional[bool] = None, rank: int = None) ExpressionBC[source]

return a copy of itself, but with a reference to the same grid

extract_component(*indices)[source]

extracts the boundary conditions for the given component

Parameters

*indices – One or two indices for vector or tensor fields, respectively

get_data(idx: Tuple[int, ...]) Tuple[float, Dict[int, float]][source]
get_virtual_point(arr, idx: Optional[Tuple[int, ...]] = None) float[source]
homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

make_adjacent_evaluator() Callable[[ndarray, int, Tuple[int, ...]], float][source]
make_virtual_point_evaluator() Callable[[...], float][source]

returns a function evaluating the value at the virtual support point

Returns

A function that takes the data array and an index marking the current point, which is assumed to be a virtual point. The result is the data value at this point, which is calculated using the boundary condition.

Return type

function

names: List[str] = ['virtual_point']

identifiers used to specify the given boundary class

Type

list

set_ghost_cells(data_full: ndarray, *, args=None) None[source]

set the ghost cell values for this boundary

Parameters
  • data_full (ndarray) – The full field data including ghost points

  • args – Additional arguments that might be supported by special boundary conditions.

class ExpressionDerivativeBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, str] = 0, target: str = 'derivative')[source]

Bases: ExpressionBC

represents a boundary whose outward derivative is calculated from an expression

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str) – An expression that determines the value of the boundary condition.

  • target (str) – Selects which value is actually set. Possible choices include value, derivative, and virtual_point.

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['derivative_expression', 'derivative_expr']

identifiers used to specify the given boundary class

Type

list

class ExpressionValueBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, str] = 0, target: str = 'value')[source]

Bases: ExpressionBC

represents a boundary whose value is calculated from an expression

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str) – An expression that determines the value of the boundary condition.

  • target (str) – Selects which value is actually set. Possible choices include value, derivative, and virtual_point.

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['value_expression', 'value_expr']

identifiers used to specify the given boundary class

Type

list

class MixedBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0, const: Union[float, ndarray, str] = 0)[source]

Bases: ConstBC1stOrderBase

represents a mixed (or Robin) boundary condition imposing a derivative in the outward normal direction of the boundary that is given by an affine function involving the actual value:

\[\partial_n c + \gamma c = \beta\]

Here, \(c\) is the field to which the condition is applied, \(\gamma\) quantifies the influence of the field and \(\beta\) is the constant term. Note that \(\gamma = 0\) corresponds to Dirichlet conditions imposing \(\beta\) as the derivative. Conversely, \(\gamma \rightarrow \infty\) corresponds to imposing a zero value on \(c\).

This condition can be enforced by using one of the following variants

bc = {'mixed': VALUE}
bc = {'type': 'mixed', 'value': VALUE, 'const': CONST}

where VALUE corresponds to \(\gamma\) and CONST to \(\beta\).

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or array) – The parameter \(\gamma\) quantifying the influence of the field onto its normal derivative. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

  • const (float or ndarray or str) – The parameter \(\beta\) determining the constant term for the boundary condition. Supports the same input as value.

copy(upper: Optional[bool] = None, rank: int = None, value: Optional[Union[float, ndarray, str]] = None, const: Optional[Union[float, ndarray, str]] = None) MixedBC[source]

return a copy of itself, but with a reference to the same grid

get_virtual_point_data(compiled: bool = False) Tuple[Any, Any, int][source]

return data suitable for calculating virtual points

Parameters

compiled (bool) – Flag indicating whether a compiled version is required, which automatically takes updated values into account when it is used in numba-compiled code.

Returns

the data structure associated with this virtual point

Return type

BC1stOrderData

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['mixed', 'robin']

identifiers used to specify the given boundary class

Type

list

normal: bool = False

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class MixedNormalBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0, const: Union[float, ndarray, str] = 0)[source]

Bases: MixedBC

represents a mixed (or Robin) boundary condition imposing a derivative in the outward normal direction of the boundary only for the normal component

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or array) – The parameter \(\gamma\) quantifying the influence of the field onto its normal derivative. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

  • const (float or ndarray or str) – The parameter \(\beta\) determining the constant term for the boundary condition. Supports the same input as value.

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['mixed_normal', 'robin_normal']

identifiers used to specify the given boundary class

Type

list

normal: bool = True

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class NeumannBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: ConstBC1stOrderBase

represents a boundary condition imposing the derivative in the outward normal direction of the boundary

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

get_virtual_point_data(compiled: bool = False) Tuple[Any, Any, int][source]

return data suitable for calculating virtual points

Parameters

compiled (bool) – Flag indicating whether a compiled version is required, which automatically takes updated values into account when it is used in numba-compiled code.

Returns

the data structure associated with this virtual point

Return type

BC1stOrderData

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['derivative', 'neumann']

identifiers used to specify the given boundary class

Type

list

normal: bool = False

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

class NeumannNormalBC(grid: GridBase, axis: int, upper: bool, *, rank: int = 0, value: Union[float, ndarray, str] = 0)[source]

Bases: NeumannBC

represents a boundary condition imposing the derivative in the outward normal direction of the boundary only on the normal component of the tensor field

Warning

This implementation uses exec() and should therefore not be used in a context where malicious input could occur. However, the function is safe when value cannot be an arbitrary string.

Parameters
  • grid (GridBase) – The grid for which the boundary conditions are defined

  • axis (int) – The axis to which this boundary condition is associated

  • upper (bool) – Flag indicating whether this boundary condition is associated with the upper side of an axis or not. In essence, this determines the direction of the local normal vector of the boundary.

  • rank (int) – The tensorial rank of the field for this boundary condition

  • value (float or str or ndarray) – a value stored with the boundary condition. The interpretation of this value depends on the type of boundary condition. If value is a single value (or tensor in case of tensorial boundary conditions), the same value is applied to all points. Inhomogeneous boundary conditions are possible by supplying an expression as a string, which then may depend on the axes names of the respective grid.

homogeneous: bool

determines whether the boundary condition depends on space

Type

bool

names: List[str] = ['derivative_normal', 'neumann_normal']

identifiers used to specify the given boundary class

Type

list

normal: bool = True

Flag indicating whether only the normal components are affected

Type

bool

value_is_linked: bool

flag that indicates whether the value associated with this boundary condition is linked to ndarray managed by external code.

Type

bool

registered_boundary_condition_classes() Dict[str, Type[BCBase]][source]

returns all boundary condition classes that are currently defined

Returns

a dictionary with the names of the boundary condition classes

Return type

dict

registered_boundary_condition_names() Dict[str, Type[BCBase]][source]

returns all named boundary conditions that are currently defined

Returns

a dictionary with the names of the boundary conditions that can be used

Return type

dict