The dataset linked below has a state file in which I resample one dataset with another. It also includes a pvpython script that I expect to do the same thing but doesn’t. In the plot below, you can see that the script version fails to find some of the points and assigns VelocityX a value of 0 at those points. What’s the difference between what I’m doing in the GUI and what I’m doing in the script?
It appears to be a tolerance issue, perhaps because this is 2D data. I can get the same result from my script as I get from the GUI if I call SetComputeTolerance(False)
on the resampling filter. I don’t explicitly set a tolerance, and the default tolerance appears to be 1.0.
In the GUI, it doesn’t seem to matter whether I check Compute Tolerance or not. I get valid data either way. Why does the tolerance not matter in the GUI? Is it not using the same vtkPResampleWithDataSet filter under the hood?
Which filter are you talking about here ?
I’m talking about the vtkResampleWithDataSet filter. When I do my resampling in the ParaView GUI, I have a pipeline that looks like this:
This works, and I can get valid data at all sampling points, regardless of whether I check Compute Tolerance.
I would also like to be able to do this in a script. I believe this to be an equivalent script:
import numpy as np
import vtk
from vtk.util.numpy_support import vtk_to_numpy
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName('flow.vtu')
reader.Update()
flow = reader.GetOutput()
reader = vtk.vtkXMLPolyDataReader()
reader.SetFileName('firstCells.vtp')
reader.Update()
firstCells = reader.GetOutput()
resample = vtk.vtkResampleWithDataSet()
resample.SetInputData(firstCells)
resample.SetSourceData(flow)
resample.SetComputeTolerance(False) # <----- MUST SET THIS
resample.SetMarkBlankPointsAndCells(True)
resample.Update()
out = resample.GetOutput()
The script only gives me valid data at all sampling points if I set Compute Tolerance to False.
For what it’s worth, the source data has very high aspect ratio cells from a 2D boundary layer. The sampling points are all in the first cell layer off the wall, where the cell aspect ratios are close to 1000.
My WeTransfer upload has probably expired by now. I’m happy to re-upload if you’d like to take a look at it.
I confirm it is expired, please reupload.
Here’s a fresh link.
I do not have a explanation but I did not test the python script. I confirm that ComputeTolerance rely on the bounds of the data which could explain why a 2D data fails to compute a proper tolerance but ParaView and VTK should behave the same here.
You may want to open a VTK issue.
VTK issue created:
https://gitlab.kitware.com/vtk/vtk/-/issues/19809
I also managed to recreate the problem on a dataset small enough to attach to the issue.