pyvista.DataSetFilters.partition

pyvista.DataSetFilters.partition#

DataSetFilters.partition(
n_partitions: int,
generate_global_id: bool = False,
as_composite: bool = True,
)[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 value

For more details, see vtkRedistributeDataSetFilter.

Parameters:
n_partitionsint

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 the cell_data of the output dataset(s).

as_compositebool, default: True

Return the partitioned dataset as a pyvista.MultiBlock.

Returns:
pyvista.MultiBlock or pyvista.UnstructuredGrid

UnStructuredGrid if as_composite=False and MultiBlock when True.

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)
../../../_images/pyvista-DataSetFilters-partition-1_00_00.png

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')
../../../_images/pyvista-DataSetFilters-partition-1_01_00.png