Transfert PointData from mesh to another

Hello Everybody,

I need some help please. I have two similar meshes A and B with a temperature PointData TA (define on A) and TB (define on B).

I need to calculate (TA-TB) and show it on A mesh for example. I tried with the ResampleWithDataSet, but even if the mesh A and B are very closed (same cells, but Cell_id are not the same), but some little differences in points coordinates cause bad values in the result.

So i tried to build a Programmable Filter with my limited skills. It makes the job, but it is not really optimized, and the execution time could be very prohibitif. I loop on each point of A to find the equivalent point of B with a second loop :roll_eyes:.

Did someone could help me to optimize my probleme please ?

Here my code:

# Code for 'Script
import numpy as np
from paraview.vtk.numpy_interface import algorithms as algs
# Get the two inputs
A = inputs[0]
B = inputs[1]
TA = A.PointData["TK"]
TB = B.PointData["Temperature"]
n1 = A.GetNumberOfPoints()
TBOnA = np.empty(n1, dtype=np.float64)
TA_B = np.empty(n1, dtype=np.float64)
bxMax =algs.max(B.Points[:,0])
byMax =algs.max(B.Points[:,1])
#test = 0
for i in range(n1):
    a1x = A.Points.Arrays[0][i][0]
    a1y = A.Points.Arrays[0][i][1]
    for j in range(n1):
        b1x = B.Points.Arrays[0][j][0]
        b1y = B.Points.Arrays[0][j][1]
        EcX = abs((a1x-b1x)/bxMax)
        EcY = abs((a1y-b1y)/byMax)
        Test1 = (EcX < 1.e-5) and (EcY < 1.e-5)
        if Test1:
            TBOnA[i]=TB.Arrays[0][j]
            TA_B[i]=abs(TA.Arrays[0][i]-TBOnA[i])
#            test += 1
            break
#print('controle : nbre Point à trouver:', n1, '<=> nbre trouvé:', test)
output.PointData.append(TA, "TA")
output.PointData.append(TBOnA, "TBonA")
output.PointData.append(TA_B, "TA_B")

This should work, please share your data.