Conversation
for more information, see https://pre-commit.ci
erikvansebille
left a comment
There was a problem hiding this comment.
Looks good to me. Just one suggestion below
| degeneracy_count = np.sum(_find_degenerate_xgrid_faces(x, y, z)) | ||
| if degeneracy_count > 0: | ||
| warnings.warn( | ||
| f"Grid contains {degeneracy_count} degenerate faces that span a large portion of the " |
There was a problem hiding this comment.
Any way we can provide more information? E.g. also list the IDs of the (first few) degenerate cells? It wil be cumbersome for users to find out which cells are degenerate
There was a problem hiding this comment.
Good point. I can surface that information
|
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 |
Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
Co-authored-by: Nick Hodgskin <36369090+VeckoTheGecko@users.noreply.github.com>
In #2521 , it was indeed the case that the location of lat,lon = 0 locations corresponded to land cells. In general, any face that is abnormally large in comparison to others will cause problems. 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 |
This PR adds a helper function to
spatialhash.pyto create a mask for degenerate cells. In the spatialhash initialization, this method is called for the case when the grid is anxgridobject withsphericalmesh type. In the event any degenerate faces are found, a warning is emitted. This is related to the action items in #2521