pyvista.UnstructuredGrid#
- class UnstructuredGrid(*args, **kwargs)[source]#
Dataset used for arbitrary combinations of all possible cell types.
Can be initialized by the following:
Creating an empty grid
From a
vtk.vtkPolyData
orvtk.vtkStructuredGrid
objectFrom cell, cell types, and point arrays
From a file
- Parameters:
Examples
>>> import pyvista as pv >>> from pyvista import examples >>> import vtk
Create an empty grid
>>> grid = pv.UnstructuredGrid()
Copy a vtk.vtkUnstructuredGrid
>>> vtkgrid = vtk.vtkUnstructuredGrid() >>> grid = pv.UnstructuredGrid(vtkgrid)
From a filename.
>>> grid = pv.UnstructuredGrid(examples.hexbeamfile) >>> grid.plot(show_edges=True)
From arrays. Here we create a single tetrahedron.
>>> cells = [4, 0, 1, 2, 3] >>> celltypes = [pv.CellType.TETRA] >>> points = [ ... [1.0, 1.0, 1.0], ... [1.0, -1.0, -1.0], ... [-1.0, 1.0, -1.0], ... [-1.0, -1.0, 1.0], ... ] >>> grid = pv.UnstructuredGrid(cells, celltypes, points) >>> grid.plot(show_edges=True)
See the Creating an Unstructured Grid example for more details on creating unstructured grids within PyVista.
Methods
Cast to an explicit structured grid.
UnstructuredGrid.linear_copy
([deep])Return a copy of the unstructured grid containing only linear cells.
Attributes
Return a the vtk cell connectivity as a numpy array.
Return the cell data as a numpy object.
Return a dictionary that contains all cells mapped from cell types.
Return the cell types array.
Return polyhedron face locations.
Return the polyhedron faces.
Return the cell locations array.
Return the polyhedron face locations.
Return the polyhedron faces.