vtkResampleWithDataSet is taking too much time

Hi

In my python script, I am using vtkResampleWithDataSet to resample one structured grid points data on to the coordinates of the other structured grid. My code snippet is shown below:

   resampler = vtk.vtkResampleWithDataSet()
   resampler.SetCellLocatorPrototype(vtk.vtkStaticCellLocator())
   resampler.MarkBlankPointsAndCellsOff() # ghost arrays are not generated
   resampler.AddInputData(unifiedGrid)
   resampler.SetSourceData(attrGrid)   
   
   resamplingStart = time.time()
   resampler.Update()
   resamplingEnd = time.time()
   print("time taken in resampling (seconds) : ", resamplingEnd-resamplingStart)

When resampling a 680X281X1 grid to a 681x281x1 grid, it is taking on an average about 9 seconds to resample, which itself is quiet high. And if I resample 680x281x2 grid to 681x281x2 grid the time taken goes up to about 40 seconds or so.

At the same time, if I do it resampling in paraview, that too of a 681x281x20 structured grid to 6810x281x20 structured grid it only takes a fraction of a second.

Any idea what am I missing, and what would be a way to fix this. I am using vtk 9.2.6 in python.

Thanks
Ashish

ParaView builds VTK with thread parallelization support while the official python wheels of VTK have this option turned off see here. This is why ParaView is faster. You can try the same script in pvpython the python interpreter that comes with ParaView itself.