I can read a .vtu file and get the nodes and data. I would like to add a filter CellCenters so I get the parametric cell centers. I need to setup a filter to do this, but I’m new to VTK in Python and unfamiliar with the correct syntax. Here’s what I have that works to read the VTU files:
def read_vtu(file):
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(file)
reader.Update()
output = reader.GetOutput()
# coordinates of nodes in the mesh
nodes_vtk = output.GetPoints().GetData()
nodes = vtk_to_numpy(nodes_vtk)
data = vtk_to_numpy(output.GetCellData().GetArray("MyVar"))
return data, nodes