neighbors#
- ExplicitStructuredGrid.neighbors(ind, rel='connectivity') list [source]#
Return the indices of neighboring cells.
- Parameters:
- ind
int
or iterable(int
) Cell IDs.
- rel
str
,optional
Defines the neighborhood relationship. If
'topological'
, returns the(i-1, j, k)
,(i+1, j, k)
,(i, j-1, k)
,(i, j+1, k)
,(i, j, k-1)
and(i, j, k+1)
cells. If'connectivity'
(default), returns only the topological neighbors considering faces connectivity. If'geometric'
, returns the cells in the(i-1, j)
,(i+1, j)
,(i,j-1)
and(i, j+1)
vertical cell groups whose faces intersect.
- ind
- Returns:
Examples
>>> import pyvista as pv >>> from pyvista import examples >>> grid = examples.load_explicit_structured() >>> cell = grid.extract_cells(31) >>> ind = grid.neighbors(31) >>> neighbors = grid.extract_cells(ind) >>> >>> plotter = pv.Plotter() >>> plotter.add_axes() >>> plotter.add_mesh(cell, color='r', show_edges=True) >>> plotter.add_mesh(neighbors, color='w', show_edges=True) >>> plotter.show()