quickpaver.get_owner_neigh_indices#

quickpaver.get_owner_neigh_indices(grid: RectilinearGrid, span_owner: Tuple[slice, slice, slice], span_neigh: Tuple[slice, slice, slice], owner_indices_to_keep: ndarray[tuple[Any, ...], dtype[int64]] | None = None, neigh_indices_to_keep: ndarray[tuple[Any, ...], dtype[int64]] | None = None) Tuple[ndarray[tuple[Any, ...], dtype[int64]], ndarray[tuple[Any, ...], dtype[int64]]][source]#

Return paired owner and neighbour flattened grid-cell indices.

The function converts two matching 3D spans into flattened node-number arrays: one span for owner cells and one span for neighbouring cells. The returned arrays are paired element-wise, meaning that indices_owner[k] is connected to indices_neigh[k].

Optional keep-lists can be used to remove pairs where either the owner or the neighbour does not belong to a selected subset of grid cells.

Parameters:
  • grid (RectilinearGrid) – Rectilinear grid defining the shape and flattened indexing convention.

  • span_owner (Tuple[slice, slice, slice]) – Three-dimensional NumPy-style span selecting owner cells in an array of shape (grid.nx, grid.ny, grid.nz).

  • span_neigh (Tuple[slice, slice, slice]) – Three-dimensional NumPy-style span selecting neighbour cells in an array of shape (grid.nx, grid.ny, grid.nz). This span must select the same number of cells as span_owner so that owner and neighbour indices can be paired element-wise.

  • owner_indices_to_keep (Optional[NDArrayInt], optional) – Optional flattened owner-cell indices to keep. If provided, only pairs whose owner index belongs to this array are retained. By default None.

  • neigh_indices_to_keep (Optional[NDArrayInt], optional) – Optional flattened neighbour-cell indices to keep. If provided, only pairs whose neighbour index belongs to this array are retained. By default None.

Returns:

Two one-dimensional arrays (indices_owner, indices_neigh) containing paired flattened grid-cell indices.

Return type:

Tuple[NDArrayInt, NDArrayInt]

Notes

The flattened numbering convention is:

node_number = ix + iy * grid.nx + iz * grid.ny * grid.nx

This helper is mainly used to build sparse finite-difference, finite-volume, or permutation matrices where each row/column contribution is based on owner-neighbour cell pairs.