Skip to content

Hexagonal Lattice Roundtrip - #3003

Merged
paulromano merged 4 commits into
openmc-dev:developfrom
pshriwise:hex-lattice-rt
May 25, 2024
Merged

paulromano merged 4 commits into
openmc-dev:developfrom
pshriwise:hex-lattice-rt

Conversation

@pshriwise

@pshriwise pshriwise commented May 14, 2024 •

Copy link
Copy Markdown
Contributor

Description

This fixes a bug described in #3002 where hexagonal lattices don't round trip in and out of XML correctly. A break condition in HexagonalLattice.from_xml_element was occurring before the index into the flat array of universe IDs is incremented, causing the next universe ID used for the second axial to be the last universe from the first layer. The universes in the resulting HexagonalLattice object are scrambled. This is a silent bug unless one of the universe IDs is omitted from the new lattice entirely in which case it's possible (but not guaranteed) that the abandoned universe will be read in later as part of the cell parsing and treated as the root universe of the geometry.

I've added a test to check that the universes of a multi-layer hex lattice are roundtripped correctly both: a) when the universes in each layer are the same and b) when the universes for each lattice cell are unique.

Fixes #3002

Checklist

  • I have performed a self-review of my own code
  • ~ I have run clang-format (version 15) on any C++ source files (if applicable)~
  • I have followed the style guidelines for Python source files (if applicable)
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

@paulromano paulromano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix and the nice test!

@paulromano
paulromano enabled auto-merge (squash) May 24, 2024 22:56
@paulromano
paulromano merged commit 12ecc17 into openmc-dev:develop May 25, 2024
church89 pushed a commit to openmsr/openmc that referenced this pull request Jul 18, 2024
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
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.

Hexagonal Lattices Don't Roundtrip

2 participants