SEGFAULT: vtkExodusIIWriter Write
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
With Python, VTK 6.2, the following script produces a segfault:
import numpy as np
import vtk
points = np.array([
[-0.5, -0.5, -5. ],
[-0.5, 0.5, -5. ],
[ 0.5, -0.5, -5. ],
[-0.5, -0.5, 5. ],
[ 0.5, 0.5, -5. ],
[ 0.5, 0.5, 5. ],
[-0.5, 0.5, 5. ],
[ 0.5, -0.5, 5. ]
])
cells = np.array([
[0, 1, 2, 3],
[1, 4, 2, 5],
[1, 2, 3, 5],
[1, 3, 6, 5],
[2, 3, 5, 7]
])
mesh = vtk.vtkUnstructuredGrid()
vtk_points = vtk.vtkPoints()
for point in points:
vtk_points.InsertNextPoint(point[0], point[1], point[2])
mesh.SetPoints(vtk_points)
for cell in cells:
pts = vtk.vtkIdList()
pts.SetNumberOfIds(4)
# Get the connectivity for this element.
for k, node_index in enumerate(cell):
pts.InsertId(k, node_index)
mesh.InsertNextCell(vtk.VTK_TETRA, pts)
# works fine:
# writer = vtk.vtkUnstructuredGridWriter()
# writer.SetFileTypeToASCII()
# writer.SetFileName('test.vtk')
writer = vtk.vtkExodusIIWriter()
writer.SetFileName('test.e')
writer.SetInputData(mesh)
writer.Write() # Segmentation fault (core dumped)