Skip to content

Commit

Permalink
Avoid high memory use when writing unstructured mesh VTK files (#2806)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulromano authored Dec 14, 2023
1 parent 3efd242 commit fb65dfd
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions openmc/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2181,7 +2181,6 @@ def write_data_to_vtk(
grid.SetPoints(vtk_pnts)

n_skipped = 0
elems = []
for elem_type, conn in zip(self.element_types, self.connectivity):
if elem_type == self._LINEAR_TET:
elem = vtk.vtkTetra()
Expand All @@ -2195,15 +2194,13 @@ def write_data_to_vtk(
if c == -1:
break
elem.GetPointIds().SetId(i, c)
elems.append(elem)

grid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())

if n_skipped > 0:
warnings.warn(f'{n_skipped} elements were not written because '
'they are not of type linear tet/hex')

for elem in elems:
grid.InsertNextCell(elem.GetCellType(), elem.GetPointIds())

# check that datasets are the correct size
datasets_out = []
if datasets is not None:
Expand Down

0 comments on commit fb65dfd

Please sign in to comment.