Hello, I have a vtkUnstructuredGrid dataset that I filter with a vtkmCleanGrid VTK object in a programmable filter, whose objective is to perform the divergence operator on the VTK-numpy wrapped output of the vtkmCleanGrid filter. The programmable filter is the following:
import vtk
from vtk.numpy_interface import algorithms as algs
from vtk.numpy_interface import dataset_adapter as dsa
input0 = inputs[0]
input0_vtk = input0.VTKObject
print(f"Input0 nb of points: {input0_vtk.GetNumberOfPoints()}")
vtkClean = vtk.vtkmCleanGrid()
vtkClean.SetInputData(0, input0_vtk)
vtkClean.Update()
print(f"vtkClean output nb of points: {vtkClean.GetOutput().GetNumberOfPoints()}")
print()
print(f"Wrapped Input0 nb of tuples: {input0.PointData['AERO_Velocity_Vector'].shape}")
vtkClean_wrapped = dsa.WrapDataObject(vtkClean.GetOutput())
print(f"Wrapped vtkClean output nb of tuples: {vtkClean_wrapped.PointData['AERO_Velocity_Vector'].shape}")
algs.divergence(vtkClean_wrapped.PointData["AERO_Velocity_Vector"])
However, there seems to be a mismatch between the number of points in the vtkmCleanGrid VTK output and the number of tuples of arrays in the vtkmCleanGrid wrapped output. More precisely, it seems that the wrapped output contains as many tuples as the VTK input of vtkmCleanGrid (input0: 56912), but not as many as the vtkmCleanGrid output (56855). This raises the following RuntimeError when trying to perform algorithms.divergence on the wrapped vtkmCleanGrid output:
Traceback (most recent call last):
File "<string>", line 22, in <module>
File "<string>", line 22, in RequestData
File "C:\ParaView\bin\Lib\site-packages\vtkmodules\numpy_interface\algorithms.py", line 125, in new_dsfunc
return dsfunc(array, ds)
File "C:\ParaView\bin\Lib\site-packages\vtkmodules\numpy_interface\internal_algorithms.py", line 257, in divergence
g = gradient(narray, dataset)
File "C:\ParaView\bin\Lib\site-packages\vtkmodules\numpy_interface\internal_algorithms.py", line 320, in gradient
res = _cell_derivatives(narray, dataset, attribute_type, cd)
File "C:\ParaView\bin\Lib\site-packages\vtkmodules\numpy_interface\internal_algorithms.py", line 44, in _cell_derivatives
raise RuntimeError('The number of points does not match the number of tuples in the array')
RuntimeError: The number of points does not match the number of tuples in the array
Input0 nb of points: 56912
vtkClean output nb of points: 56855
Wrapped Input0 nb of tuples: (56912, 3)
Wrapped vtkClean output nb of tuples: (56912, 3)
I am using Paraview 5.10.1 (VTK 9.0.20210922). Please find data to reproduce the issue :
data.vtu (5.8 MB)
Is this problem a known issue ? Has it been solved in more recent versions of Paraview/VTK ?
Thanks a lot, Have a nice day.