Add corner checks for rectangular lattice crossings
Description
There's a rare bug in rectangular lattice crossings where the incorrect cell would be calculated when a particle crosses a corner in a rectangular lattice. This normally doesn't result in any lost particles in actual transport unless a very large lattice is used with many particle histories. This does result in failures when plotting lattice geometries with ray traced plots though, as the camera often views the geometry from an orientation in which rays intersect lattice corners.
This PR fixes this bug by adding a corner check in RectLattice::distance(...) to ensure that particles are moved to the correct lattice cell. I've tested this against the minimal working example provided by @gridley in #2445, which is a 2x2 lattice made of iron (blue) and air (green).
Particles moving through the centre of the lattice from air -> air should not get attenuated, however the previous lattice offsets were calculated incorrectly and so those particles found their way into the iron cells erroneously (resulting in some attenuation):
Adding a corner check (this PR) to correctly move particles into adjacent cells fixes this issue:
I'm marking this as a draft for the moment until I have the time to add some tests for this fix.
Closes #2445
Checklist
- [x] I have performed a self-review of my own code
- [x] I have run clang-format (version 15) on any C++ source files (if applicable)
- [x] ~~I have followed the style guidelines for Python source files (if applicable)~~
- [x] ~~I have made corresponding changes to the documentation (if applicable)~~
- [x] I have added tests that prove my fix is effective or that my feature works (if applicable)
wow, awesome! Thanks for getting this man. Did this fix the issue in the plotter?
Unfortunately not :frowning_face:. I still get a bunch of Particle (...) could not be located after crossing a boundary of lattice [...] errors, so something else must be going on here.
I just remembered that I had this PR sitting around from a few months ago and completely forgot to add a test for the fix. The test I added here is @gridley's MWE with a reduced mesh tally resolution to ensure we catch those pesky corner crossings.
@pshriwise thought I'd put this in your radar. For some reason, GH didn't automatically request any reviewers (guess I didn't hit any code owners on RectLattice).