4.1.2.4 pde.backends.numba.grids module

Compiled functions for dealing with grids.

get_grid_numba_type

Return numba type corresponding to a particular grid.

make_cell_volume_getter

Return a compiled function returning the volume of a grid cell.

make_interpolation_axis_data

Factory for obtaining interpolation information.

make_single_interpolator

Return a compiled function for linear interpolation on the grid.

get_grid_numba_type(grid, rank=0)[source]

Return numba type corresponding to a particular grid.

Parameters:
  • grid (GridBase) – The grid for which we determine the type

  • rank (int) – The rank of the data stored in the grid

Returns:

_description_

Return type:

_type_

make_cell_volume_getter(grid, *, flat_index=False)[source]

Return a compiled function returning the volume of a grid cell.

Parameters:
  • grid (GridBase) – Grid for which the function is defined

  • flat_index (bool) – When True, cell_volumes are indexed by a single integer into the flattened array.

Returns:

returning the volume of the chosen cell

Return type:

function

make_interpolation_axis_data(grid, axis, *, with_ghost_cells=False, cell_coords=False)[source]

Factory for obtaining interpolation information.

Parameters:
  • grid (GridBase) – Grid for which the interpolator is defined

  • axis (int) – The axis along which interpolation is performed

  • with_ghost_cells (bool) – Flag indicating that the interpolator should work on the full data array that includes values for the ghost points. If this is the case, the boundaries are not checked and the coordinates are used as is.

  • cell_coords (bool) – Flag indicating whether points are given in cell coordinates or actual point coordinates.

Returns:

A function that is called with a coordinate value for the axis. The function returns the indices of the neighboring support points as well as the associated weights.

Return type:

callable

make_single_interpolator(grid, *, fill=None, with_ghost_cells=False, cell_coords=False)[source]

Return a compiled function for linear interpolation on the grid.

Parameters:
  • grid (GridBase) – Grid for which the interpolator is defined

  • fill (Number, optional) – Determines how values out of bounds are handled. If None, ValueError is raised when out-of-bounds points are requested. Otherwise, the given value is returned.

  • with_ghost_cells (bool) – Flag indicating that the interpolator should work on the full data array that includes values for the ghost points. If this is the case, the boundaries are not checked and the coordinates are used as is.

  • cell_coords (bool) – Flag indicating whether points are given in cell coordinates or actual point coordinates.

Returns:

A function which returns interpolated values when called with arbitrary positions within the space of the grid. The signature of this function is (data, point), where data is the numpy array containing the field data and position denotes the position in grid coordinates.

Return type:

callable