# Combining multiblock data with different field names

**URL:** https://discourse.paraview.org/t/combining-multiblock-data-with-different-field-names/9788
**Category:** ParaView Support
**Created:** [June 10, 2022, 7:31pm UTC](https://discourse.paraview.org/t/combining-multiblock-data-with-different-field-names/9788 "2022-06-10T19:31:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![woodscn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/woodscn/32/3226_2.png) [@woodscn](https://discourse.paraview.org/u/woodscn)
#### Post date: [June 10, 2022, 7:31pm UTC](https://discourse.paraview.org/t/combining-multiblock-data-with-different-field-names/9788/1 "2022-06-10T19:31:41Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [June 13, 2022, 8:04am UTC](https://discourse.paraview.org/t/combining-multiblock-data-with-different-field-names/9788/2 "2022-06-13T08:04:58Z")

</div>

Is that in a programmable filter ?

---

<div class="post-metadata">

### Author: ![woodscn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/woodscn/32/3226_2.png) [@woodscn](https://discourse.paraview.org/u/woodscn)
#### Post date: [June 13, 2022, 3:19pm UTC](https://discourse.paraview.org/t/combining-multiblock-data-with-different-field-names/9788/3 "2022-06-13T15:19:59Z")

</div>

Yes, that’s correct.

---

<div class="post-metadata">

### Author: ![woodscn](https://discourse.paraview.org/user_avatar/discourse.paraview.org/woodscn/32/3226_2.png) [@woodscn](https://discourse.paraview.org/u/woodscn)
#### Post date: [June 21, 2022, 10:30pm UTC](https://discourse.paraview.org/t/combining-multiblock-data-with-different-field-names/9788/4 "2022-06-21T22:30:30Z")

</div>

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.org)](https://www.paraview.org/Wiki/Python_Programmable_Filter#:~:text=The%20python%20programmable%20filter%20is%20a%20general%20purpose,to%20wrap%20paraview%27s%20classes%20into%20python%20callable%20format.), [ParaView/Simple ParaView 3 Python Filters - KitwarePublic](https://www.paraview.org/Wiki/ParaView/Simple_ParaView_3_Python_Filters)). 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)

```auto
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']
  else:
    component_names = None
  if component_names:
    components = [block_in.CellData[name] for name in component_names]
    velocity = numpy_to_vtk(algs.make_vector(*components))
    velocity.SetName('Velocity')
    block_out.CellData.AddArray(velocity)

```
