Repository navigation
Preserve face order across an Exodus round trip - #1913
Merged
Merged
Conversation
Exodus element blocks are homogeneous, so `_encode_exodus` regroups a mixed mesh by face size. Nothing recorded that permutation, so the mesh reloaded reordered -- intact, but with any face-centered data now describing the wrong faces, and no error to say so. Carry each face's original position through the regrouping and write it to `elem_num_map`, then undo the permutation on read. Exodus defines `elem_num_map` as a user-facing element ID rather than a position, so the reader only honors it on files this writer produced, identified via `qa_records`, and only when the IDs form a genuine permutation. This restores the exact-order assertions in `test_mixed_exodus` and `test_grid_ugrid_exodus_roundtrip` that the previous commit had to relax. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmdupuis3
marked this pull request as ready for review
December 2, 2026 22:07
Sevans711
approved these changes
Dec 3, 2026
Sevans711
left a comment
Collaborator
There was a problem hiding this comment.
Everything looks reasonable here, and the new tests do catch the old bug when run against main. Happy to approve this one!
Minor non-blocking comments:
- Could you update the PR description to mention the cleanup to the uxgrid example in
test_encode_exodus_mixed_blocks? I don't think it's required for this PR which makes it a minor expansion of scope, but it is definitely good to include, as plotting the old uxgrid example shows some edges intersect with each other. - Could you clarify, in the PR description ("This restores the exact-order assertions in test_mixed_exodus and test_grid_ugrid_exodus_roundtrip that the previous commit had to relax."), which commit is "the previous commit"?
Collaborator
Author
|
pre-commit.ci autofix |
rajeeja
self-requested a review
December 4, 2026 16:31
rajeeja
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1910
Overview
Overview
Exodus element blocks are homogeneous, so
_encode_exodusregroups a mixed mesh by face size. Nothing recorded that permutation, so the mesh reloaded reordered -- intact, but with any face-centered data now describing the wrong faces, and no error to say so.Carry each face's original position through the regrouping and write it to
elem_num_map, then undo the permutation on read. Exodus defineselem_num_mapas a user-facing element ID rather than a position, so the reader only honors it on files this writer produced, identified viaqa_records, and only when the IDs form a genuine permutation.This restores the exact-order assertions in
test_mixed_exodusandtest_grid_ugrid_exodus_roundtrip. #1752 (8d36335, "Fix Exodus encode treating every face as full width") had relaxed them to compare faces as an unordered set via a_face_rowshelper, because the round trip permuted faces. That helper is removed here.Also in this PR (small scope expansion): the hand-built mixed mesh in
test_encode_exodus_mixed_blockswas not a valid mesh. Node 4 sat at (20, 0), on the same line as nodes 0 and 1, and the triangle[0, 3, 4]overlapped the quad, so edges crossed each other. Node 4 moves to (20, -10) and the triangles become[0, 4, 1]and[1, 4, 2], so the three faces now tile without overlapping and share edges. The new round-trip test uses the same mesh.PR Checklist
General
Testing & Benchmarking
Documentation and Examples
docs/api.rst; internal (private) function names start with an underscore (_)AI Disclosure
AI Usage: Claude Opus 5.5