I have a thermomechanical FEM dataset that includes “deformation” vectors. The data comes to me in a giant collection NumPy arrays. The data may have cell connectivity, wherever it is created - but I never see it, and have to create my own:
# Read in location, skin the surface:
pd = vtkPolyData()
pts = vtkPoints()
for loc in locations:
pts.InsertNextPoint(loc)
pd.SetPoints(pts)
d2 = vtkDelaunay2D()
d2.SetInputData(pd)
d2.Update()
# Read temperature and deformation data:
displacement = numpy_to_vtk(displacement_data)
displacement.SetName("Displacement")
d2.GetOutputDataObject(0).GetPointData().AddArray(displacement)
d2.GetOutputDataObject(0).GetPointData().SetActiveVectors("Displacement")
temperature = numpy_to_vtk(temperature_data)
temperature.SetName("Temperature")
d2.GetOutputDataObject(0).GetPointData().AddArray(temperature)
d2.GetOutputDataObject(0).GetPointData().SetActiveScalars("Temperature")
Ok, that’s roughly how I set it up, if I stop in a debugger, the arrays are there (after all, I just added them). Once I run them through vtkWarpVector … they’re gone. I can get this done in ParaView … but I need a script …
wv = vtkWarpVector()
wv.SetInputConnection(d2.GetOutputPort())
wv.Update()
print(wv.GetOutputDataObject(0).GetPointData())
# ^^ arrays are gone :(