Skip to content

Add RegularMesh.get_indices_at_coords method - #3824

Merged
paulromano merged 9 commits into
openmc-dev:developfrom
shimwell:find-closest-index-to-mesh-coord
Feb 26, 2026
Merged

paulromano merged 9 commits into
openmc-dev:developfrom
shimwell:find-closest-index-to-mesh-coord

Conversation

@shimwell

@shimwell shimwell commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

Description

To match the CylindricalMesh which has this function class I am keen to add this get_indices_at_coords function to the RegularMesh class.

Fixes # (issue)

Checklist

  • I have performed a self-review of my own code
  • 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)

@GuySten

GuySten commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

I suggest making get_indices_at_coords a required abstract method of StructuredMesh
and implement it also for RectlinearMesh.

@GuySten

GuySten commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

You also should decide on a way to signal that a point is outside the mesh.

@shimwell

shimwell commented Feb 19, 2026 •

Copy link
Copy Markdown
Member Author

Thanks for this idea @GuySten I have made the abstract method.

Would it be ok if I leave the spherical mesh and rectilinear mesh implementation of get_indices_at_coords to another PR, I added not yet implemented errors for those options if that helps in the short term.

Also the point outside of the mesh question, not sure what is best to do there. Cylindrical mesh doesn't do anything special in that case so this PR is following that precedence. Would a warning message that prints when a user puts in a point outside the mesh be the best option for this?

@GuySten

GuySten commented Feb 19, 2026

Copy link
Copy Markdown
Contributor

I think it is fine.

@shimwell

Copy link
Copy Markdown
Member Author

I'm also keen to make two "good first issues" and during the OSSFE conference hackathon we can solve these get indices at coords for spherical and rectilinear mesh. We are looking for straight forward issues to work on during that day.

@paulromano paulromano changed the title adding RegularMesh.get_indices_at_coords to match CylindricalMesh Add RegularMesh.get_indices_at_coords method Feb 25, 2026

@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 @shimwell. Note that I removed the "clamping" behavior since that wasn't consistent with how the similar method for CylindricalMesh worked.

@paulromano
paulromano enabled auto-merge (squash) February 25, 2026 17:37
@paulromano
paulromano merged commit 8081815 into openmc-dev:develop Feb 26, 2026
14 checks passed
jon-proximafusion pushed a commit to shimwell/openmc that referenced this pull request Apr 13, 2026
apingegno pushed a commit to apingegno/openmc that referenced this pull request May 7, 2026
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.

3 participants