Skip to content

Keep unstructured mesh VTK data aligned with written elements - #138

Open
shimwell wants to merge 1 commit into
developfrom
um-vtkhdf-unsupported
Open

shimwell wants to merge 1 commit into
developfrom
um-vtkhdf-unsupported

Conversation

@shimwell

@shimwell shimwell commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Description

If an unstructured mesh has elements that aren't linear tets or hexes, write_data_to_vtk skips them but still writes their data. So the cell arrays end up longer than the number of cells and everything after a skipped element is shifted onto the wrong cell. This happens for both .vtkhdf and the legacy .vtk/.vtu output.

This PR drops the data (and volumes) for the skipped elements so things line up again. It also stops volume normalization from modifying the user's array in place.

Spotted by CodeRabbit on openmc-dev#3877.

The new test writes a small mesh with one unsupported element in the middle and checks the values read back from both file formats.

Checklist

  • I have performed a self-review of my own code
  • I have followed the style guidelines for Python source files (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Elements of an unsupported type are skipped when an UnstructuredMesh is
written to VTK, but the values for those elements were still written to
the cell data. The cell arrays then had more values than cells and every
value after a skipped element was shifted onto the wrong cell. This
affected both the VTKHDF and the legacy VTK/VTU writers.

The data and the volumes used for normalization are now filtered to the
written elements. This also stops volume normalization from dividing the
caller's array in place.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant