See partition information in a vtkPartitionedDataSet

Is there a way to get information about the partitions in a vtkPartitionedDataSet object? For blocks that are in a vtkPartitionedDataSetCollection, I can see information about the blocks in the MultiBlock Inspector and other places. However, the ParaView GUI treats a vtkPartitionedDataSet as a single entity.

I understand why ParaView is doing this, except sometimes when debugging meshes I really need to inspect the partitions under the vtkPartitionedDataSet. Is there an easy way to do this?

ConvertToMultiblock should do the trick.

Thanks for the suggestion, @mwestphal . Unfortunately, that is not working for me.

In my case, the vtkPartitionedDataSet is nestled in a vtkPartitionedDataSetCollection. The top level object is converted to a vtkMultiBlockDataSet, but the contained partitions are converted to a vtkMultiPieceDataSet. ParaView seems to be treating the vtkMultiPieceDataSet the same way it treats the vtkPartitionedDataSet.

Yeah, by intention ParaView hides vtkPartitionedDataSet and vtkMultiPieceDataSet, which as you point out, is a pain for debugging.

I was looking for a hack to use dataset id to select partitions from a partitioned dataset, but nothing I tried worked.

The best I can think of is to save the dataset out to the XML partitioned dataset format and load individual partitions from the output on disk.

I hacked away around this. You can use a Programmable Filter to pull out all the partitions to each have its own block. Here is the script that I used:

input0 = inputs[0]

def convert_partitions(src: vtk.vtkPartitionedDataSetCollection,
                       dest: vtk.vtkPartitionedDataSetCollection):
  # Count partitions
  num_partitions = 0
  for block_i in range(0, src.GetNumberOfPartitionedDataSets()):
    block = src.GetPartitionedDataSet(block_i)
    num_partitions += block.GetNumberOfPartitions()
  print("Num partitions", num_partitions)
  dest.SetNumberOfPartitionedDataSets(num_partitions)
  # Convert partitions to blocks
  partition_i = 0
  for block_i in range(0, src.GetNumberOfPartitionedDataSets()):
    block = src.GetPartitionedDataSet(block_i)
    for block_part_i in range(0, block.GetNumberOfPartitions()):
      partition = vtk.vtkPartitionedDataSet()
      partition.SetNumberOfPartitions(1)
      partition.SetPartition(1, block.GetPartition(block_part_i))
      dest.SetPartitionedDataSet(partition_i, partition)
      partition_i += 1

convert_partitions(input0.VTKObject, output.VTKObject)

To make this a bit easier, here is a python script that can be loaded as a plugin. It will create a filter named Partitions To Blocks that will do the same thing.

partitions-to-blocks-plugin.py (1.9 KB)

1 Like

Ha right, my solution seems to work only with a partitioned dataset, not with a pdc.
TBF this could be added to ConvertToMB or ConvertToPDC very easily.

Is that a voluneer? :wink:

That sounds like a good idea to me. But should the behavior of exposing partitions as blocks be the default or only behavior?

It definitely should not be the default imo.