ExplicitStructuredGrid.cell_id

ExplicitStructuredGrid.cell_id#

ExplicitStructuredGrid.cell_id(coords: ArrayLike[int]) int | NumpyArray[int] | None[source]#

Return the cell ID.

The cell structured coordinates are the (i, j, k) index of a cell along the grid’s three structured axes, with (0, 0, 0) being the first cell. This method maps those coordinates to the flat cell ID used to index the grid’s cells.

Parameters:
coordsArrayLike[int]

Cell structured coordinates.

Returns:
outputint | numpy.ndarray | None

Cell IDs. None if coords is outside the grid extent.

Examples#

Download Python source code | Download Jupyter notebook

>>> from pyvista import examples
>>> grid = examples.load_explicit_structured()
>>> grid.cell_id((3, 4, 0))
np.int64(19)
>>> coords = [(3, 4, 0), (3, 2, 1), (1, 0, 2), (2, 3, 2)]
>>> grid.cell_id(coords)
array([19, 31, 41, 54])

See Also#

pyvista.ExplicitStructuredGrid.cell_coords

Return the cell structured coordinates.