pyvista.DataSetFilters.partition#
- DataSetFilters.partition( )[source]#
Break down input dataset into a requested number of partitions.
Cells on boundaries are uniquely assigned to each partition without duplication.
It uses a kdtree implementation that builds balances the cell centers among a requested number of partitions. The current implementation only supports power-of-2 target partition. If a non-power of two value is specified for
n_partitions
, then the load balancing simply uses the power-of-two greater than the requested valueFor more details, see vtkRedistributeDataSetFilter.
- Parameters:
- n_partitions
int
Specify the number of partitions to split the input dataset into. Current implementation results in a number of partitions equal to the power of 2 greater than or equal to the chosen value.
- generate_global_idbool, default:
False
Generate global cell ids if
None
are present in the input. If global cell ids are present in the input then this flag is ignored.This is stored as
"vtkGlobalCellIds"
within thecell_data
of the output dataset(s).- as_compositebool, default:
True
Return the partitioned dataset as a
pyvista.MultiBlock
.
- n_partitions
- Returns:
pyvista.MultiBlock
orpyvista.UnstructuredGrid
UnStructuredGrid if
as_composite=False
and MultiBlock whenTrue
.
See also
Examples
Partition a simple ImageData into a
pyvista.MultiBlock
containing each partition.>>> import pyvista as pv >>> grid = pv.ImageData(dimensions=(5, 5, 5)) >>> out = grid.partition(4, as_composite=True) >>> out.plot(multi_colors=True, show_edges=True)
Partition of the Stanford bunny.
>>> from pyvista import examples >>> mesh = examples.download_bunny() >>> out = mesh.partition(4, as_composite=True) >>> out.plot(multi_colors=True, cpos='xy')