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_point_evaluator(fill: numpy.ndarray = None) Callable[[numpy.ndarray, Tuple[int, ...]], NumberOrArray] [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
- property grid: pde.grids.base.GridBase¶
Underlying grid
- Type
- high: pde.grids.boundaries.local.BCBase¶
Boundary condition at upper end
- Type
- low: pde.grids.boundaries.local.BCBase¶
Boundary condition at lower end
- Type
- make_derivative_evaluator(order: int = 1) Callable[[numpy.ndarray, Tuple[int, ...]], NumberOrArray] [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[[numpy.ndarray, Tuple[int, ...]], Tuple[NumberOrArray, NumberOrArray, NumberOrArray]] [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
- set_ghost_cells(data_full: numpy.ndarray, *, args=None) None [source]¶
set the ghost cell values for all boundaries
- Parameters
data_full (
ndarray
) – The full field data including ghost pointsargs – Additional arguments that might be supported by special boundary conditions.
- class BoundaryPair(low: BCBase, high: BCBase)[source]¶
Bases:
pde.grids.boundaries.axis.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
- classmethod from_data(grid: GridBase, axis: int, data, rank: int = 0) BoundaryPair [source]¶
create boundary pair from some data
- Parameters
- Returns
the instance created from the data
- Return type
- Throws:
ValueError if data cannot be interpreted as a boundary pair
- high: pde.grids.boundaries.local.BCBase¶
Boundary condition at upper end
- Type
- low: pde.grids.boundaries.local.BCBase¶
Boundary condition at lower end
- Type
- class BoundaryPeriodic(grid: GridBase, axis: int)[source]¶
Bases:
pde.grids.boundaries.axis.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
- high: pde.grids.boundaries.local.BCBase¶
Boundary condition at upper end
- Type
- low: pde.grids.boundaries.local.BCBase¶
Boundary condition at lower end
- Type