openmc-dev / openmc

OpenMC Monte Carlo Code
https://docs.openmc.org
Other
699 stars 444 forks source link

Hexagonal lattice iterators #2921

Open pshriwise opened 1 month ago

pshriwise commented 1 month ago

Description

This contains a fix for the distribcell indexing of hexagonal lattices. It primarily comes into play when a hex lattice is used as a fill for more than one cell. In this case, we aren't correctly indexing into the lattice offset table, used to track the instance number of a universe (and its cells) in the lattice.

For some background, the lattice offsets for a hexagonal lattice contains some padding so that the 2-D indexing of the rings can be treated as a square array. This leaves some empty entries in the array. As a result, we need to jump forward a few entries to get to the next valid entry in the lattice offsets data member.

This is caused by the use of the same iterators for the RectangularLattice and HexagonalLattice classes. The RectangularLattice class uses the same iterator without accounting for this offset. This PR mainly adds an iterator that is specific to the HexagonalLattice class, which accounts for the empty entries based on the structure of the lattice rings.

I've added a test querying cell instances at the center of a hex lattice that fills multiple cells to ensure the correct instance values are calculated in an initialized simulation.

Fixes #2798

Checklist

pshriwise commented 1 month ago

@lewisgross1296

gridley commented 1 week ago

@pshriwise do you still consider this to be a draft?

pshriwise commented 1 week ago

@pshriwise do you still consider this to be a draft?

I've been hesitant about this because the whole of our cell instance bookkeeping needs an overhaul IMO and I kinda feel like this is kicking the can down the road a bit. All the same, it does correct some behavior and we should probably get the fix in. Removing draft status now.