I have an XML unstructured grid with polyhedral elements and would like to read it using Python for post-processing analysis of a simulation. I am using Python 3.7.4 and vtk 8.1.2.
I can read the file with
vtkXMLUnstructuredGridReader and successfully read some arrays from
Points. But, when I try to use the function
vtkCellArray class, it seems that it’s missing from the vtk Python package:
import vtk import numpy # open *.vtu file reader = vtk.vtkXMLUnstructuredGridReader() reader.SetFileName("cells_0.0000.vtu") reader.Update() output = reader.GetOutput() cellEnergy = output.GetCellData().GetArray("cellEnergy") points = output.GetPoints().GetData() vtkCells = output.GetCells() cellConn = output.GetCells().GetConnectivityArray()
AttributeError: 'vtkCommonDataModelPython.vtkCellArray' object has no attribute 'GetConnectivityArray'
I tried to see if I could find it where vtk is installed with
grep below, but it didn’t output anything.
grep -rnwi . -e 'GetConnectivityArray'
Is the function really missing? Or am I doing something wrong?