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 can read the file with vtkXMLUnstructuredGridReader
and successfully read some arrays from CellData
and Points
doing the following:
import vtk
import numpy
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName("cells_0.0000.vtu")
reader.Update()
output = reader.GetOutput()
cellType = output.GetCellData().GetArray("cellType")
cellEnergy = output.GetCellData().GetArray("cellEnergy")
points = output.GetPoints().GetData()
I can also read Cells
without any problems:
vtkCells = output.GetCells()
print(vtkCells)
Output:
vtkCellArray (0x7fcaa7430a10)
Debug: Off
Modified Time: 587
Reference Count: 2
Registered Events: (none)
Number Of Cells: 1091
Insert Location: 0
Traversal Location: 0
However, I haven’t found functions to read the following arrays from Cell
:
connectivity
offsets
faces
facesoffsets
I have tried some functions from the vtkCellArray
class (https://vtk.org/doc/nightly/html/classvtkCellArray.html), such as GetConnectivityArray()
and GetOffsetsArray()
, but get an error when doing the following:
vtkConnectivity = output.GetCells().GetConnectivityArray()
Output:
AttributeError: 'vtkCommonDataModelPython.vtkCellArray' object has no attribute 'GetConnectivityArray'
What function should I use to read connectivity
, offsets
, faces
, and facesoffsets
arrays?