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
- get_data(idx: Tuple[int, ...]) Tuple[float, Dict[int, float]] [source]¶
sets the elements of the sparse representation of this condition
- get_mathematical_representation(field_name: str = 'C') Tuple[str, str] [source]¶
return mathematical representation of the boundary condition
- get_point_evaluator(fill: Optional[ndarray] = None) Callable[[ndarray, Tuple[int, ...]], Union[int, float, complex, ndarray]] [source]¶
return a function to evaluate values at a given point
The point can either be a point inside the domain or a virtual point right outside the domain
- Parameters
fill (
ndarray
, optional) – Determines how values out of bounds are handled. If None, a DomainError is raised when out-of-bounds points are requested. Otherwise, the given value is returned.- Returns
- A function taking a 1d array and an index as an argument,
returning the value of the array at this index.
- Return type
function
- make_derivative_evaluator(order: int = 1) Callable[[ndarray, Tuple[int, ...]], Union[int, float, complex, ndarray]] [source]¶
return a function to evaluate the derivative at a point
- Parameters
order (int) – The order of the derivative
- Returns
A function that can be called with the data array and a tuple indicating around what point the derivative is evaluated. The function returns the central finite difference at the point. The function takes boundary conditions into account if the point lies on the boundary.
- Return type
function
- make_ghost_cell_setter() Callable[[...], None] [source]¶
return function that sets the ghost cells for this axis on a full array
- make_region_evaluator() Callable[[ndarray, Tuple[int, ...]], Tuple[Union[int, float, complex, ndarray], Union[int, float, complex, ndarray], Union[int, float, complex, ndarray]]] [source]¶
return a function to evaluate values in a neighborhood of a point
- Returns
A function that can be called with the data array and a tuple indicating around what point the region is evaluated. The function returns the data values left of the point, at the point, and right of the point along the axis associated with this boundary condition. The function takes boundary conditions into account if the point lies on the boundary.
- Return type
function
- make_virtual_point_evaluators() Tuple[Callable[[...], float], Callable[[...], float]] [source]¶
returns two functions evaluating the value at virtual support points
- Returns
Two functions that each take a 1d array as an argument and return the associated value at the virtual support point outside the lower and upper boundary, respectively.
- Return type
- class BoundaryPair(low: BCBase, high: BCBase)[source]¶
Bases:
BoundaryAxisBase
represents the two boundaries of an axis along a single dimension
- Parameters
- 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
- class BoundaryPeriodic(grid: GridBase, axis: int, flip_sign: bool = False)[source]¶
Bases:
BoundaryPair
represent a periodic axis
- Parameters
- 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