# Displacement of mesh operator in ParaView

**URL:** https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590
**Category:** ParaView Support
**Created:** [March 7, 2023, 1:12pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590 "2023-03-07T13:12:47Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 7, 2023, 1:12pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/1 "2023-03-07T13:12:48Z")

</div>

While going through the visualization manual of a software, I encountered the following documentation for visualizing in Visit. Is there anything equivalent in ParaView?

 ![image](https://discourse.paraview.org/uploads/default/original/2X/5/504210b2d3cc7359581f9481529f8078ae97fa71.png)

Also related is perhaps this: [4.3.8. Displace operator — VisIt User Manual 2.11 documentation (visit-sphinx-github-user-manual.readthedocs.io)](https://visit-sphinx-github-user-manual.readthedocs.io/en/v3.1.0/gui_manual/Operators/OperatorTypes/Displace_operator.html)

---

<div class="post-metadata">

### Author: ![Christos\_Tsolakis](https://discourse.paraview.org/user_avatar/discourse.paraview.org/christos_tsolakis/32/4450_2.png) [@Christos\_Tsolakis](https://discourse.paraview.org/u/Christos_Tsolakis)
#### Post date: [March 7, 2023, 1:54pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/2 "2023-03-07T13:54:05Z")

</div>

Sounds like the [wrap by vector](https://docs.paraview.org/en/latest/UsersGuide/filteringData.html#warp-by-vector) filter.

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 7, 2023, 2:15pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/3 "2023-03-07T14:15:08Z")

</div>

This is Chombo hdf5 data and whenever I load it, the wrap by vector filter is unavailable. However, I could do this in VisIt using the instructions in the manual I shared.

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [March 7, 2023, 3:23pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/4 "2023-03-07T15:23:36Z")

</div>

This is possible if there’s no 3-component field in the dataset. Assuming that the displacement field is being loaded, is the displacement vector being loaded as three 1-component arrays? If so, you can use the Calculator filter to create a 3-compoment vector out of it.

If you have sample dataset to share, that’ll make it easier to confirm why `Warp by Vector` may not be available.

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 7, 2023, 3:36pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/5 "2023-03-07T15:36:43Z")

</div>

I’m unable to find the `displacement` in `ParaView`. However, that is available from in `VisIt`.  
I’m sharing one such file: [data.0000.hdf5 - Google Drive](https://drive.google.com/file/d/1aCV1yjl0EvwtQVADu7XFY7ePic1sZ-fA/view?usp=sharing)  
@utkarsh.ayachit Please have a look at this and let me know.

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [March 7, 2023, 3:48pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/6 "2023-03-07T15:48:29Z")

</div>

![image](https://discourse.paraview.org/uploads/default/original/2X/f/f82cbc09d05f7427aa57f9136f0b4fb033e85bc2.png)

Attached is the state file generated with \>5.11.0.  
[warp-by-vector.pvsm](https://discourse.paraview.org/uploads/short-url/2pILZeRihnJmDnGiMF8ShtLszbo.pvsm) (515.9 KB)

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 7, 2023, 5:00pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/7 "2023-03-07T17:00:50Z")

</div>

I don’t see the displacement field anywhere in `ParaView` but it gets shown in `VisIt` on loading the same data. Using velocity to morph doesn’t cause the correct geometry of the simulation (spherical in this case) to be produced. I’m attaching what I get in `VisIt` for your reference. Things become even messier as turbulence develops in the velocity fields.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/2/22a081604f6fd62281d5bde26c57a688d1c35577.jpeg)

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [March 7, 2023, 5:20pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/8 "2023-03-07T17:20:38Z")

</div>

For the dataset you shared, there read is not detecting any field named displacement. The only field that resembled a vector field was `v?` and hence I used that for illustration purposes. It’s possible that the Chombo reader in ParaView needs to be updated to read the displacement field, if it is indeed present in the file. Sounds like a bug. I’d recommend reporting an issue on the issue tracker so the development team can track it down.

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 7, 2023, 5:26pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/9 "2023-03-07T17:26:18Z")

</div>

In that case, I think probably somehow the Chombo reader on `ParaView` is missing out the displacement field. This is because the same data on `VisIt` gets to know this field. Any quick way you can suggest to get this done in ParaView? Can you also direct me where I can post an issue regarding this?

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [March 7, 2023, 5:27pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/10 "2023-03-07T17:27:45Z")

</div>

The issue tracker is here: [https://gitlab.kitware.com/paraview/paraview/-/issues](https://gitlab.kitware.com/paraview/paraview/-/issues)  
I’ll let the dev team comment on prioritization etc.

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 7, 2023, 5:49pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/11 "2023-03-07T17:49:20Z")

</div>

Is there any way how I can read and separately pass the displacement field to `ParaView` somehow for the time being?  
Issue raised here: [Chombo reader cannot read displacement field to deal with non-cartesian geometries (#21801) · Issues · ParaView / ParaView · GitLab (kitware.com)](https://gitlab.kitware.com/paraview/paraview/-/issues/21801)

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [March 8, 2023, 7:58am UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/12 "2023-03-08T07:58:55Z")

</div>

The Displacement field is **not** stored in the Chombo dataset. It is instead evaluated at read-time, based on “Expressions” stored in the file:

h5dump -g /Expressions data.0000.hdf5 will give you

```auto
HDF5 "data.0000.hdf5" {
GROUP "/Expressions" {
   ATTRIBUTE "scalar Phi" {
      DATATYPE H5T_STRING {
         STRSIZE 84;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "nodal_constant(Mesh,2.400000e-02)*coords(Mesh)[2]+nodal_constant(Mesh,-1.200000e-01)"
      }
   }
   ATTRIBUTE "scalar R" {
      DATATYPE H5T_STRING {
         STRSIZE 49;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "coords(Mesh)[0]+nodal_constant(Mesh,3.500000e+01)"
      }
   }
   ATTRIBUTE "scalar Theta" {
      DATATYPE H5T_STRING {
         STRSIZE 83;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "nodal_constant(Mesh,2.500000e-02)*coords(Mesh)[1]+nodal_constant(Mesh,1.450000e+00)"
      }
   }
   ATTRIBUTE "scalar X" {
      DATATYPE H5T_STRING {
         STRSIZE 21;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "R*sin(Theta)*cos(Phi)"
      }
   }
   ATTRIBUTE "scalar Y" {
      DATATYPE H5T_STRING {
         STRSIZE 21;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "R*sin(Theta)*sin(Phi)"
      }
   }
   ATTRIBUTE "scalar Z" {
      DATATYPE H5T_STRING {
         STRSIZE 12;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "R*cos(Theta)"
      }
   }
   ATTRIBUTE "vector Displacement" {
      DATATYPE H5T_STRING {
         STRSIZE 20;
         STRPAD H5T_STR_NULLTERM;
         CSET H5T_CSET_ASCII;
         CTYPE H5T_C_S1;
      }
      DATASPACE SCALAR
      DATA {
      (0): "{X,Y,Z}-coords(Mesh)"
      }
   }
}
}

```

this is of course Visit-specific syntax. It is not difficult to translate that into a Python Programmable Filter. Of course the result of warping your AMR collection of regular cartesian grids _would be_ an AMR collection of structured grids, which ParaView does not support. A quick hack is to convert your data to MultiBlock, then merge it into a single unstructured grid, which can be easily warped by ‘Displacement’. Visit’s Expression would be translated to the following code:

```auto
coords = inputs[0].Points 
Phi = 2.400000e-02 * coords[:,2] -1.200000e-01
R = coords[:,0] + 3.500000e+01
Theta = 2.500000e-02 * coords[:,1] + 1.450000e+00
X = R*sin(Theta)*cos(Phi)
Y = R*sin(Theta)*sin(Phi)
Z = R*cos(Theta)
Displacement = make_vector(X,Y,Z) - coords
output.PointData.append(Displacement, "Displacement")
output.PointData.append(mag(Displacement), "Displacement_magnitude")

```

P.S. This is a proof-of-concept. A proper solution would be to conserve the multiblock structure in the Python programmable filter.

 ![Chombo](https://discourse.paraview.org/uploads/default/original/2X/5/53a3671b05e013cd7be923e72ffd381af76793a2.png)

[warp-by-vector+Expression.pvsm](https://discourse.paraview.org/uploads/short-url/24jsqgFxtjZsDdvSSs0dx0v1C3i.pvsm) (997.1 KB)

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 8, 2023, 11:10am UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/13 "2023-03-08T11:10:23Z")

</div>

@jfavre Wow! This is extremely detailed. Thanks a lot for taking so much time to look into this. This works although I get an error message. For a larger dataset (around 13 GB). Most probably `MergeBlocks` take forever and `ParaView` crashes maybe due to RAM overflow.  
On loading the state and choosing the file, I get this error.

 ![Screenshot from 2023-03-08 16-37-58](https://discourse.paraview.org/uploads/default/original/2X/8/82ee9b245387db8c9a48f851d1b0c46153f5070d.png)

EDIT:  
I was able to run larger data with `pvserver` on a cluster. While `VisIt` was able to do this on my PC `ParaView` needed a cluster. This is probably because the filter is unable to the AMR grid directly on `ParaView`. Comparison of slice with `VisIt` is not exact but they are very close and can do a decent job for the time being.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/d/d8d329e927b767443616319f72fc73eebe518192.jpeg)

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 8, 2023, 4:48pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/14 "2023-03-08T16:48:09Z")

</div>

> [@jfavre](#):
>
> A proper solution would be to conserve the multiblock structure in the Python programmable filter.

How can one write something like this?

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [March 8, 2023, 6:22pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/16 "2023-03-08T18:22:59Z")

</div>

A working solution for the multi-block structure is available in the state file attached.  
[warp-by-vector+Expression.1.pvsm](https://discourse.paraview.org/uploads/short-url/bp8pvZJDZ7zahpYAO8zdRpwMspW.pvsm) (325.7 KB)

---

<div class="post-metadata">

### Author: ![dutta-alankar](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dutta-alankar/32/13310_2.png) [@dutta-alankar](https://discourse.paraview.org/u/dutta-alankar)
#### Post date: [March 8, 2023, 6:50pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/17 "2023-03-08T18:50:17Z")

</div>

@jfavre Thanks a lot. This is awesome. It is working and is much more responsive and much less memory demanding with larger data compared to the previous one you shared.

Can you please share some article/resources that has documentation and tutorials on using these custom Programmable filters?

Now for the larger dataset, I didn’t need a cluster and I could do it in my PC with just `ParaView` client. Also, the `VisIt` and `ParaView` dumps are identical.

 ![image](https://discourse.paraview.org/uploads/default/original/2X/0/04bb6d5dfd57b300a33482eeb14b1ea176903dd6.jpeg)

---

<div class="post-metadata">

### Author: ![jfavre](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jfavre](https://discourse.paraview.org/u/jfavre)
#### Post date: [March 8, 2023, 7:19pm UTC](https://discourse.paraview.org/t/displacement-of-mesh-operator-in-paraview/11590/18 "2023-03-08T19:19:58Z")

</div>

[https://docs.paraview.org/en/latest/ReferenceManual/pythonProgrammableFilter.html#](https://docs.paraview.org/en/latest/ReferenceManual/pythonProgrammableFilter.html#)
