Add spatial hash describe function - #2796
Conversation
erikvansebille
left a comment
There was a problem hiding this comment.
Thanks for this PR, @wyatt-fluidnumerics. I like it a lot!
See below a screenshot for one of my Delft3D curvilinear meshes

Very useful information; as I now wonder why the max faces per occupied cell is more than 175k(!)
See below some suggestions/comments on this PR itself
|
Interesting, 44 certainly seems a lot more reasonable, let me dig into this some myself as well. My understanding was that keys only stores hash cells that contain faces from the model grid's mesh, but this could be wrong. |
|
If And note that the computation of |
|
I am pretty sure that every entry in keys corresponds to an occupied hash cell. |
|
OK, but if I do So, could these be all the grid cells with NaN lon/lat locations from Delft3D? |
|
This would make sense, the actual meaning of |
|
I think I found where the problem occurs. The code snippet below prints 0. So if you have a NaN value then it gets clipped to (0, 0, 0) coord equivalent int in Normally I think this would produce a RuntimeWarning but those are silenced for the block of code. |
…s-code/Parcels into add-SpatialHash-describe-function
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
for more information, see https://pre-commit.ci
…s-code/Parcels into add-SpatialHash-describe-function
for more information, see https://pre-commit.ci
erikvansebille
left a comment
There was a problem hiding this comment.
PR looks great; thanks!

Description
Currently, it is difficult to get a sense for many of the dimensions of the spatial hash table that gets built over unstructured, and many structured grids. This makes understanding the performance speed up due to spatial hashing, or potential bugs in the spatial hashing such as that addressed by PR #2780, difficult. This PR adds functionality for
.describe()to theSpatialHashclass. The function is used exclusively for debugging or logging and provides useful statistics regarding the size of the hash grid and the ratio of hash grid cells to mesh grid faces.Checklist
mainfor normal development,v3-supportfor v3 support)AI Disclosure
spatialhash_describefunction. I then made significant modifications to the resulting code to improve the utility of the reported statistics.