tetra_per_cell: int = 5,
mixed: Sequence[int] | bool = False,
pass_cell_ids: bool = True,
pass_data: bool = True,
progress_bar: bool = False,

Create a tetrahedral mesh structured grid.

tetra_per_cellint, default: 5

The number of tetrahedrons to divide each cell into. Can be either 5, 6, or 12. If mixed=True, this value is overridden.

mixedstr, bool, sequence, default: False

When set, subdivides some cells into 5 and some cells into 12. Set to True to use the active cell scalars of the pyvista.RectilinearGrid to be either 5 or 12 to determining the number of tetrahedra to generate per cell.

When a sequence, uses these values to subdivide the cells. When a string uses a cell array rather than the active array to determine the number of tetrahedra to generate per cell.

pass_cell_idsbool, default: True

Set to True to make the tetrahedra have scalar data indicating which cell they came from in the original pyvista.RectilinearGrid. The name of this array is 'vtkOriginalCellIds' within the cell_data.

pass_databool, default: True

Set to True to make the tetrahedra mesh have the cell data from the original pyvista.RectilinearGrid. This uses pass_cell_ids=True internally. If True, pass_cell_ids will also be set to True.

progress_barbool, default: False

Display a progress bar to indicate progress.


UnstructuredGrid containing the tetrahedral cells.


Divide a rectangular grid into tetrahedrons. Each cell contains by default 5 tetrahedrons.

First, create and plot the grid.

>>> import numpy as np
>>> import pyvista as pv
>>> xrng = np.linspace(0, 1, 2)
>>> yrng = np.linspace(0, 1, 2)
>>> zrng = np.linspace(0, 2, 3)
>>> grid = pv.RectilinearGrid(xrng, yrng, zrng)
>>> grid.plot()

Now, generate the tetrahedra plot in the exploded view of the cell.

>>> tet_grid = grid.to_tetrahedra()
>>> tet_grid.explode(factor=0.5).plot(show_edges=True)

Take the same grid but divide the first cell into 5 cells and the other cell into 12 tetrahedrons per cell.

>>> tet_grid = grid.to_tetrahedra(mixed=[5, 12])
>>> tet_grid.explode(factor=0.5).plot(show_edges=True)