4.2.1.4. pde.grids.boundaries.axis module

This module handles the boundaries of a single axis of a grid. There are generally only two options, depending on whether the axis of the underlying grid is defined as periodic or not. If it is periodic, the class BoundaryPeriodic should be used, while non-periodic axes have more option, which are represented by BoundaryPair.

class BoundaryAxisBase(low: BCBase, high: BCBase)[source]

Bases: object

base class for defining boundaries of a single axis in a grid

Parameters
  • low (BCBase) – Instance describing the lower boundary

  • high (BCBase) – Instance describing the upper boundary

property axis: int

The axis along which the boundaries are defined

Type

int

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_mathematical_representation(field_name: str = 'C') Tuple[str, str][source]

return mathematical representation of the boundary condition

property grid: GridBase

Underlying grid

Type

GridBase

high: BCBase

Boundary condition at upper end

Type

BCBase

low: BCBase

Boundary condition at lower end

Type

BCBase

make_ghost_cell_setter() Callable[[...], None][source]

return function that sets the ghost cells for this axis on a full array

property periodic: bool

whether the axis is periodic

Type

bool

property rank: int

rank of the associated boundary condition

Type

int

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

set the ghost cell values for all boundaries

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

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

class BoundaryPair(low: BCBase, high: BCBase)[source]

Bases: BoundaryAxisBase

represents the two boundaries of an axis along a single dimension

Parameters
  • low (BCBase) – Instance describing the lower boundary

  • high (BCBase) – Instance describing the upper boundary

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

copy() BoundaryPair[source]

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

extract_component(*indices) BoundaryPair[source]

extracts the boundary pair of the given index.

Parameters

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

classmethod from_data(grid: GridBase, axis: int, data, rank: int = 0, normal: bool = False) BoundaryPair[source]

create boundary pair 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

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

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

  • normal (bool) – Flag indicating whether the condition is only applied in the normal direction.

Returns

the instance created from the data

Return type

BoundaryPair

Throws:

ValueError if data cannot be interpreted as a boundary pair

classmethod get_help() str[source]

Return information on how boundary conditions can be set

high: BCBase

Boundary condition at upper end

Type

BCBase

low: BCBase

Boundary condition at lower end

Type

BCBase

class BoundaryPeriodic(grid: GridBase, axis: int, flip_sign: bool = False)[source]

Bases: BoundaryPair

represent a periodic axis

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

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

  • flip_sign (bool) – Impose different signs on the two sides of the boundary

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

copy() BoundaryPeriodic[source]

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

extract_component(*indices) BoundaryPeriodic[source]

extracts the boundary pair of the given extract_component.

Parameters

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

property flip_sign

Whether different signs are imposed on the two sides of the boundary

Type

bool

high: BCBase

Boundary condition at upper end

Type

BCBase

low: BCBase

Boundary condition at lower end

Type

BCBase

get_boundary_axis(grid: GridBase, axis: int, data, rank: int = 0, normal: bool = False) BoundaryAxisBase[source]

return object representing the boundary condition for a single axis

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

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

  • data (str or tuple or dict) – Data describing the boundary conditions for this axis

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

  • normal (bool) – Flag indicating whether the condition is only applied in the normal direction.

Returns

Appropriate boundary condition for the axis

Return type

BoundaryAxisBase