ExplicitStructuredGrid#
- class ExplicitStructuredGrid(*args, **kwargs)[source]#
Extend the functionality of the vtkExplicitStructuredGrid class.
Can be initialized by the following:
Creating an empty grid
From a vtkStructuredGrid, vtkExplicitStructuredGrid or vtkUnstructuredGrid object
From a VTU or VTK file
From
dimsandcornersarraysFrom
dims,cellsandpointsarrays
- Parameters:
- argsvtkExplicitStructuredGrid, vtkUnstructuredGrid,
str,Sequence See examples below.
- deepbool, default:
False Whether to deep copy a vtkUnstructuredGrid object.
- validatebool |
MeshValidationFields| sequence[MeshValidationFields], default:False Validate the mesh using
validate_mesh()after initialization. Set this toTrueto validate all fields, or specify any combination of fields allowed byvalidate_mesh.Added in version 0.47.
- argsvtkExplicitStructuredGrid, vtkUnstructuredGrid,
See also
Examples#
Download Python source code | Download Jupyter notebook
>>> 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)
Methods#
Cast to an unstructured grid. |
|
Return the cell structured coordinates. |
|
|
Return the cell ID. |
|
Merge duplicate points and remove unused points in an ExplicitStructuredGrid. |
Compute an array with the number of connected cell faces. |
|
Compute the faces connectivity flags array. |
|
|
Hide specific cells. |
|
Return the indices of neighboring cells. |
|
Save this VTK object to file. |
|
Show hidden cells. |
Attributes#
Return the topological dimensions of the grid. |
|
Return the bounding box of the visible cells. |