Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getNeighboringCellIndices #1614

Merged
merged 3 commits into from
Jan 25, 2024

Conversation

mgjarrett
Copy link
Contributor

@mgjarrett mgjarrett commented Jan 24, 2024

What is the change?

The staticmethod to get neighboring cell indices in a StructuredGrid is implemented incorrectly:

@staticmethod
def getNeighboringCellIndices(i, j=0, k=0):
"""Return the indices of the immediate neighbors of a mesh point in the plane."""
return ((i + 1, j, k), (1, j + 1, k), (i - 1, j, k), (i, j - 1, k))

It looks like a typo; there is a 1 where there should be an i.

Also, a unit test is added to cover this function.

Why is the change being made?

The previous implementation is incorrect.


Checklist

  • The release notes (location doc/release/0.X.rst) are up-to-date with any important changes.
  • The documentation is still up-to-date in the doc folder.
  • If any requirements were affected, mention it in the release notes.
  • The dependencies are still up-to-date in pyproject.toml.

@john-science john-science added the bug Something is wrong: Highest Priority label Jan 24, 2024
@opotowsky
Copy link
Member

Whoah nice catch! Will this affect internal integration testing?

@john-science
Copy link
Member

Whoah nice catch! Will this affect internal integration testing?

Michael did that testing. This is ready for prime time.

@opotowsky opotowsky merged commit 31aa020 into terrapower:main Jan 25, 2024
11 checks passed
@drewj-usnctech
Copy link
Contributor

FWIW this existed prior to the refactoring in #1373

armi/armi/reactor/grids.py

Lines 929 to 932 in da28372

@staticmethod
def getNeighboringCellIndices(i, j=0, k=0):
"""Return the indices of the immediate neighbors of a mesh point in the plane."""
return ((i + 1, j, k), (1, j + 1, k), (i - 1, j, k), (i, j - 1, k))

My intention there was just to copy code off Grid and move it to StructuredGrid. But I'm glad it has been discovered and fixed!

@mgjarrett
Copy link
Contributor Author

Ah, I didn't look that closely. Didn't see the side-by-side diff because it was moved to a new file.

It looks like this had been around for over 5 years (probably much longer). I guess this shows how little exercise the Cartesian code gets.

image

@mgjarrett mgjarrett deleted the fixCartesianNeighbors branch February 15, 2024 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is wrong: Highest Priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants