Skip to content

Issue 2521 emit warning#2543

Merged
fluidnumerics-joe merged 9 commits intomainfrom
issue-2521-emit-warning
Mar 16, 2026
Merged

Issue 2521 emit warning#2543
fluidnumerics-joe merged 9 commits intomainfrom
issue-2521-emit-warning

Conversation

@fluidnumerics-joe
Copy link
Contributor

This PR adds a helper function to spatialhash.py to create a mask for degenerate cells. In the spatialhash initialization, this method is called for the case when the grid is an xgrid object with spherical mesh type. In the event any degenerate faces are found, a warning is emitted. This is related to the action items in #2521

Copy link
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

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

Looks good to me. Just one suggestion below

@VeckoTheGecko
Copy link
Contributor

Looks good from a code POV

@fluidnumerics-joe am i right to say that all incomplete meshes (i.e., where there are 0s in for lon and lat) will have these incomplete "genereate" cells and hence raise this warning?

Just good to know one way or another - we can't really detect whether these cells are in coastal regions or not anyway so there's a limit to what we can do

fluidnumerics-joe and others added 2 commits March 13, 2026 11:05
Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
@fluidnumerics-joe
Copy link
Contributor Author

fluidnumerics-joe commented Mar 13, 2026

Looks good from a code POV

@fluidnumerics-joe am i right to say that all incomplete meshes (i.e., where there are 0s in for lon and lat) will have these incomplete "genereate" cells and hence raise this warning?

Just good to know one way or another - we can't really detect whether these cells are in coastal regions or not anyway so there's a limit to what we can do

In #2521 , it was indeed the case that the location of lat,lon = 0 locations corresponded to land cells and this mesh was "incomplete". these incomplete meshes will definitely have degenerate cells. In general, any face that is abnormally large in comparison to others will cause problems. Remember that we're constructing faces over the stencil [i:i+1,j:j+1] for lat and lon; if that face ends up spanning the entire grid, that will likely get picked up as a degenerate cell.

The best we could do, is filter out the degenerate cells in the hash table construction. This would prevent them from ever being used in a search and would guard against unnecessary large memory allocations.

After throwing the warning, I'm wondering if we would want to go ahead and filter these out and then construct the hash table. In this case, if a particle ever landed in a degenerate face, the spatial hashing search would just fail to find it.

Right now, we throw a warning and then an oom error will be thrown

@VeckoTheGecko
Copy link
Contributor

Gotcha, thanks for the clarification @fluidnumerics-joe !

@fluidnumerics-joe fluidnumerics-joe merged commit a2f497d into main Mar 16, 2026
15 checks passed
@fluidnumerics-joe fluidnumerics-joe deleted the issue-2521-emit-warning branch March 16, 2026 16:36
@github-project-automation github-project-automation bot moved this from Backlog to Done in Parcels development Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants