Combining multiblock data with different field names

I’m working with a multiblock dataset. Block 0 has fields “vel_x” and “vel_y”, while block 2 has fields “vel_x_p” and “vel_y_p”. Block 1 does not have these fields. I’d like to write a programmable filter that assembles these fields into a “velocity” vector field for blocks 0 and 2.

Here’s what I have so far:

from vtk.numpy_interface import algorithms
output = inputs[0].ShallowCopy()
data = dataset_adapter.WrapDataObject(inputs[0])
vel = algorithms.make_vector(data.CellData['vel_x'], data.cellData['vel_y'])
vel_p = algorithms.make_vector(data.CellData['vel_x_p'], data.cellData['vel_y_p'])

How can I add these into the appropriate places in the output?

Is that in a programmable filter ?

Yes, that’s correct.

Dealing with multiblock data is a real pain, and a lot of the new approaches don’t seem to work. This is mainly built out of guesswork and the old wiki ( Python Programmable Filter - KitwarePublic (, ParaView/Simple ParaView 3 Python Filters - KitwarePublic). It seems to do what I want it to, but I’d still like to know if there’s a better way. (Paraview 5.10.0 on Windows)

from paraview.vtk.numpy_interface import algorithms as algs
from paraview.vtk.util.numpy_support import numpy_to_vtk
for ind, (block_in, block_out) in enumerate(zip(inputs[0], output)):
  if ind == 0:
    component_names = ['vel_x', 'vel_y']
  elif ind == 2:
    component_names = ['vel_x_p', 'vel_y_p']
    component_names = None
  if component_names:
    components = [block_in.CellData[name] for name in component_names]
    velocity = numpy_to_vtk(algs.make_vector(*components))