how to get difference between two volumetric meshes to calculate the deformation distance for each node

I have created a volumetric mesh using gmsh and then exported it as a .vtk file format (i.e. as an unstructured grid). Then fed this into a vtk program and add different deformations (i.e. scaling, rotate, translation) to this unstructured grid and obtain 100 deformation instances.

Now I need to obtain the displacement vector for each node of the reference geometry (i.e. initial volumetric mesh) compared to each of these deformed instances.

For example, I wrote a code as below in meshio package in order to calculate this displacement for a one particular deformation instance.

My question is that, are the nodes appearing in the same order after deforming the initial geometry (i.e. reference unstructured grid) so that we can obtain by simply subtracting as the below step ?

reference_ellipsoid_file = './Generated_data/reference_geometry/ellipsoid.vtk'
reference_ellipsoid =

deformed_ellipsoid_file = './Generated_data/deformations/dataset/meshes/box_with_ellipsoid0.vtk'
deformed_ellipsoid =

displacement = deformed_ellipsoid.points - reference_ellipsoid.points

What filters did you use to deform your mesh?

As a first thought, that I would need to check by looking at the filters you used, I don’t see why a transform would change points / cells ordering if the data structure is the same. So you’re probably good if you just subtract points of same indices.

A better solution that will always work: use vtkGenerateGlobalIds before you apply your transforms. Each point will be assigned a unique MPI aware global id to each point and / or each cell. You can access this id array through the method GetGlobalIds in your vtkUnstructuredGrid. Then you can trivially map elements from your different meshes by fetching them using this global id.