Repository navigation
Assigning connectivities based on UGRID conventions - #1736
Conversation
contains test and explanation for how edge_node_connectivity and edge_face_connectivity interact with the trailing dimension "two"
ASV BenchmarkingBenchmark Comparison ResultsBenchmarks that have stayed the same:
Benchmarks that have got worse:
|
n2 to two during open_grid
cmdupuis3
left a comment
There was a problem hiding this comment.
Looks fine, the tests pass and all the cases highlighted here are covered.
Sevans711
left a comment
There was a problem hiding this comment.
Looks pretty good, and makes sense to aim to close both issues with a single PR like this! Left small inline comment.
Aside from that, I'm referring back to my earlier comment in #1725 which flagged this page as related: https://uxarray.readthedocs.io/en/latest/user-guide/representation.html#connectivity
I would suggest to also fix that page (i.e. the Connectivity section of representation.rst) as follows:
- The Dimensions column should use "two", not "2".
- The table is missing a Node Node connectivity row. (Or, maybe the Edge Edge connectivity row should be removed? uxarray/conventions/ugrid.py says edge_edge_connectivity is not yet supported.)
- The table mentions "n_max_edge_faces", however no part of uxarray actually uses that dimension.
Grid.edge_face_connectivityactually has dimensions "n_edge", "two", in agreement withEDGE_FACE_CONNECTIVITY_DIMSin uxarray. The table in your PR overview also shows that you use "two" as part of this fix as well, not "n_max_edge_faces".
"n_max_edge_faces" also appears in DIM_NAMES, and I believe it should be removed from there, as part of this PR, because it isn't actually supported anywhere else in uxarray. Using "two" instead of "n_max_edge_faces" contradicts a recent internal discussion, however I think that is okay, because during that discussion nobody brought up what the code is actually doing; I think everyone assumed it was following the docs page (which is incorrect!).
It would make sense to me for these fixes to the docs page and DIM_NAMES to be bundled with this PR. But, I could also understand if you would prefer to push them to another PR later. If you'd prefer to push them, could you open up a new issue report for them before this PR merges, to make sure that they don't get forgotten?
|
Looks good. I'd agree with Sam, let do those also and then merge this. |
|
@Sevans711 @rajeeja Yeah I think a lot of what you're saying is true but I'd prefer it be either part of a seperate PR or after an extensive discussion on what these connectivities should really be. The issue with switching
|
|
@dylannelson I think we might all be on the same page for the most part? I wasn't suggesting to swap "two" to "n_max_edge_faces", just to update the docs to clarify that the code uses "two", not "n_max_edge_faces. There wouldn't be any functionality changes at all, the only change to the code itself would be a tiny update to (26-11-24) EDIT: fixed typo above; it now correctly says "n_max_edge_faces", but originally said "n_max_face_edges" by accident. (See #1766 (comment)) Given that, would you still prefer to push these changes to a different PR? If it makes more sense to you to push them I wouldn't mind, as long as before this PR merges a corresponding issue gets posted to track these points. |
|
@Sevans711 I think we're on the same page now.
Done, though this is technically the opposite what the team said, we can discuss later this week
I didn't change edge edge or node node docs because I'm not familiar with why they are there, and same with
another situation where I don't see an impact to do so, but if the others want it removed too, I'm happy to do it. I feel more hesitant to touch the conventions file than the docs though. |
Sevans711
left a comment
There was a problem hiding this comment.
All looks good now, everything within scope of the original issues has been solved, and all of my extra slightly-out-of-scope comments have either been solved or recorded in #1766 for tracking purposes so they can be solved in a later PR. Thank you - approving!




Closes #1717
Closes #1725
Why two in one? The reason for closing both in one PR is due to them being caused by the same problem. Having 3 dimensions in pre-existing connectivities results in
swap_dimsquietly breaking, causing both the issues seen above. By applying some cleaning both before and afterswap_dimsis called, both issues are solved together. As far as I can see, there is no evidence we would see one of the above errors without the other, and since the solution is in the same location, we may as well solve it once and here. Originally I solved the first one alone, but solving the 2nd would basically require deleting the whole original solution, and replacing it with a more general one. So rather than pushing 1 solution to main, deleting it, and pushing another, I say we just push this single refined solution (assuming it works as intended)Overview
_read_ugridrenamed the trailing dimension offace_node_connectivityton_max_face_nodesand left every other connectivity's equivalent dimension as whatever the source file called it. Readingfesom.mesh.diag.nc, which names those axesn3andn2:face_node_connectivityn3('n_face', 'n_max_face_nodes')face_edge_connectivityn3('n_face', 'n_max_face_nodes')('n_face', 'n_max_face_edges')face_face_connectivityn3('n_face', 'n_max_face_nodes')('n_face', 'n_max_face_faces')edge_node_connectivityn2('n_edge', 'n2')('n_edge', 'two')edge_face_connectivityn2('n_edge', 'n2')('n_edge', 'two')Each connectivity's trailing dimension is now mapped to the name
ugrid.CONNECTIVITYgives it, rather than one being hardcoded and the rest left alone. In this FESOM file (which is read in through the UGRID path) it uses one size-3n3for all three face connectivities.swap_dimscall cannot express all 3, so the first connectivity renames it for the whole dataset and the remainder are renamed per variable.face_node_connectivityis first, so variables that are not connectivity all getn_max_face_nodesExpected Usage
PR Checklist
General
Testing & Benchmarking
Documentation and Examples
docs/api.rst; internal (private) function names start with an underscore (_)AI Disclosure
AI Usage: Claude