4.2.1.3 pde.grids.boundaries.axes module
This module handles the boundaries of all axes of a grid.
Base class keeping information about how to set conditions on all boundaries. |
|
Defines boundary conditions for all axes individually. |
|
Represents a function that sets ghost cells to determine boundary conditions. |
|
Set a default boundary condition. |
- class BoundariesBase[source]
Bases:
object
Base class keeping information about how to set conditions on all boundaries.
- classmethod from_data(data, **kwargs)[source]
Creates all boundaries from given data.
- Parameters:
data (str or dict or callable) – Data that describes the boundaries. If this is a callable, we create
BoundariesSetter
. In all other, casesBoundariesList
is created and data can either be string denoting a specific boundary condition applied to all sides or a dictionary with detailed information.**kwargs – In some cases additional data can be specified or is even required. For instance,
BoundariesList
expects a grid (GridBase
): to which the boundary condition are associated, and it can use a rank (int), which sets the tensorial rank of the field for this boundary condition.
- Return type:
- classmethod get_help()[source]
Return information on how boundary conditions can be set.
- Return type:
- make_ghost_cell_setter()[source]
Return function that sets the ghost cells on a full array.
- Returns:
Callable with signature
(data_full: np.ndarray, args=None)
, which sets the ghost cells of the full data, potentially using additional information in args (e.g., the time t during solving a PDE)- Return type:
- class BoundariesList(boundaries)[source]
Bases:
BoundariesBase
Defines boundary conditions for all axes individually.
Initialize with a list of boundaries.
- Parameters:
boundaries (list[BoundaryAxisBase])
- check_value_rank(rank)[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
- Return type:
None
- Throws:
RuntimeError: if any value does not have rank rank
- classmethod from_data(data, *, grid, rank=0, **kwargs)[source]
Creates all boundaries from given data.
- Parameters:
grid (
GridBase
) – The grid with which the boundary condition is associateddata (str or dict) – Data that describes the boundaries. This should either be a string naming a boundary condition or a dictionary with detailed information.
rank (int) – The tensorial rank of the field for this boundary condition
- Return type:
- get_mathematical_representation(field_name='C')[source]
Return mathematical representation of the boundary condition.
- make_ghost_cell_setter()[source]
Return function that sets the ghost cells on a full array.
- Return type:
- property periodic: list[bool]
a boolean array indicating which dimensions are periodic according to the boundary conditions.
- Type:
- class BoundariesSetter(setter)[source]
Bases:
BoundariesBase
Represents a function that sets ghost cells to determine boundary conditions.
The function must have accept a
ndarray
, which contains the full field data including the ghost points, and a second, optional argument, which is a dictionary containing additional parameters, like the current time point t in case of a simulation.Example
Here is an example for a simple boundary setter, which sets specific boundary conditions in the x-direction and periodic conditions in the y-direction of a grid with two axes. Note that this boundary condition will not work for grids with other number of axes and no additional checks are performed.
def setter(data, args=None): data[0, :] = data[1, :] # Vanishing derivative at left side data[-1, :] = 2 - data[-2, :] # Fixed value `1` at right side data[:, 0] = data[:, -2] # Periodic BC at top data[:, -1] = data[:, 1] # Periodic BC at bottom
- Parameters:
setter (GhostCellSetter)
- classmethod from_data(data, **kwargs)[source]
Creates all boundaries from given data.
- Parameters:
data (callable) – Function that sets the ghost cells
- Return type:
- make_ghost_cell_setter()[source]
Return function that sets the ghost cells on a full array.
- Returns:
Callable with signature
(data_full: np.ndarray, args=None)
, which sets the ghost cells of the full data, potentially using additional information in args (e.g., the time t during solving a PDE)- Return type:
- set_default_bc(bc_data, default)[source]
Set a default boundary condition.
- Parameters:
- Returns:
Modified bc_data with added defaults
- Return type:
dict[str, dict | str | BCBase] | dict | str | BCBase | tuple[dict | str | BCBase, dict | str | BCBase] | BoundaryAxisBase | Sequence[dict[str, dict | str | BCBase] | dict | str | BCBase | tuple[dict | str | BCBase, dict | str | BCBase] | BoundaryAxisBase] | Callable | BoundariesBase