pyvista.ExplicitStructuredGrid

pyvista.ExplicitStructuredGrid#

class ExplicitStructuredGrid(*args, **kwargs)[source]#

Extend the functionality of the vtk.vtkExplicitStructuredGrid class.

Can be initialized by the following:

  • Creating an empty grid

  • From a vtk.StructuredGrid, vtk.vtkExplicitStructuredGrid or vtk.vtkUnstructuredGrid object

  • From a VTU or VTK file

  • From dims and corners arrays

  • From dims, cells and points arrays

Parameters:
argsvtk.vtkExplicitStructuredGrid, vtk.vtkUnstructuredGrid, str, Sequence

See examples below.

deepbool, default: False

Whether to deep copy a vtk.vtkUnstructuredGrid object.

Examples

>>> import numpy as np
>>> import pyvista as pv
>>>
>>> # grid size: ni*nj*nk cells; si, sj, sk steps
>>> ni, nj, nk = 4, 5, 6
>>> si, sj, sk = 20, 10, 1
>>>
>>> # create raw coordinate grid
>>> grid_ijk = np.mgrid[
...     : (ni + 1) * si : si,
...     : (nj + 1) * sj : sj,
...     : (nk + 1) * sk : sk,
... ]
>>>
>>> # repeat array along each Cartesian axis for connectivity
>>> for axis in range(1, 4):
...     grid_ijk = grid_ijk.repeat(2, axis=axis)
>>>
>>> # slice off unnecessarily doubled edge coordinates
>>> grid_ijk = grid_ijk[:, 1:-1, 1:-1, 1:-1]
>>>
>>> # reorder and reshape to VTK order
>>> corners = grid_ijk.transpose().reshape(-1, 3)
>>>
>>> dims = np.array([ni, nj, nk]) + 1
>>> grid = pv.ExplicitStructuredGrid(dims, corners)
>>> grid = grid.compute_connectivity()
>>> grid.plot(show_edges=True)
../../../_images/pyvista-ExplicitStructuredGrid-1_00_00.png

Methods

ExplicitStructuredGrid.cast_to_unstructured_grid()

Cast to an unstructured grid.

ExplicitStructuredGrid.cell_coords(ind)

Return the cell structured coordinates.

ExplicitStructuredGrid.cell_id(coords)

Return the cell ID.

ExplicitStructuredGrid.clean([tolerance, ...])

Merge duplicate points and remove unused points in an ExplicitStructuredGrid.

ExplicitStructuredGrid.compute_connections([...])

Compute an array with the number of connected cell faces.

ExplicitStructuredGrid.compute_connectivity([...])

Compute the faces connectivity flags array.

ExplicitStructuredGrid.hide_cells(ind[, inplace])

Hide specific cells.

ExplicitStructuredGrid.neighbors(ind[, rel])

Return the indices of neighboring cells.

ExplicitStructuredGrid.save(filename[, ...])

Save this VTK object to file.

ExplicitStructuredGrid.show_cells([inplace])

Show hidden cells.

Attributes

ExplicitStructuredGrid.dimensionality

Return the dimensionality of the grid.

ExplicitStructuredGrid.dimensions

Return the topological dimensions of the grid.

ExplicitStructuredGrid.visible_bounds

Return the bounding box of the visible cells.