-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mesh #38
Mesh #38
Conversation
Hi @xldeltares ! I made some progress on adapting the mesh object to 1D2D. Took a bit longer than what I thought... Do you mind reviewing what I did so far? I updated the tests and they run but fail because the built models are apparently different than the examples ones and I think you're the best person to know if this is expected or not. Happy to discuss details if you need and thanks in advance :) |
Hi @hboisgon, nice work! look forward to review it! Before our discussion, here is a look at the tests (I was able to install the working environment and ran the tests. ): The example and test model differ in the following files:
I checked the fm_net.nc, The differences lie in the following variables (first dataset being the example, second dataset being the test, i.e. new results): When checking nodefile.ini, I noticed that in the tests, i.e. new results, MH_14 did not get an street level sampled correctly from DEM. This is a bit strange because I see nothing changed about this part of the code [line 1415 in delft3dfm.py] (https://github.com/Deltares/hydromt_delft3dfm/pull/38/files#diff-33ac0e158093b8ff9226df60fd435fdbd07769738588ba1cc1400c4385beecd9R1415). |
Hey @xldeltares and @hboisgon, I did not look into the details of this work and these files, but maybe the following remark helps.
D-Flow FM accepts UGRID-compliant files, and supports both 0- and 1-based indexing: both are valid, as long as the file has consistent data. This concerns the mesh topology variables *face_nodes, *edge_nodes, *edge_faces, *links, etc. |
As a follow up, findings about manholes seems to indicate a difference in behavior of function However, it is unexpected, because all manholes are within the domain of dem, and dem does not have missing values. As discussed with @hboisgon , it was found that the manholes reprojection in the How to fix? Make the region slightly larger than the current total mesh bounds. Will work on that during the review. |
Hi @arthurvd, thanks for the quick feedback! Good to know that both are valid and how to make the entirely equivalent. :) |
Hi @hboisgon , I have finished the review and made changes accordingly - the testing of building/updating 1D model, 2D model and 1D2D model are completed. Would you do a quick check with the TODOs at the bottom in mind? Afterwards I think we are done! Checklist
Notebook
TODOs:
|
Hi @xldeltares. I am now looking into your changes :)
That's a good question. Can we actually do anything if we don't read the mesh? Right now for self.crs, we try to read if from mesh. Branches and staticgeoms can also only be derived by reading the mesh file (eg for crosssections or boundaries but I am guessing also the structures). The only thing so far we can change without reading the mesh file is changing the config or dimr file. Do you see other cases? For writting in update mode, if you do not want to re-write the exact same mesh file we could think of adding extra checks functionnality to only write the mesh file if something changed. Note that via the hydromt config file, users can already decide to only write the objects they want (adding any [write_*] to the config like write_config will then tell hydromt it should only write the listed conponents instead of all). What do you think? |
Other question in mesh_utils hydrolib_network_from_mesh:
Can the hydrolib network object store variables like bedlevel ? If so we can decide to include it or not. If we are using hydrolib core writers for mesh than I would say yes. If we only use it for network operations then it's not needed per say and avoids large memory usage |
I reviewed your changes @xldeltares. Very nice and very detailed thanks a lot!! I think we are almost there. The mesh branch of hydromt was merged to main now so we should be able to update the env file temporarily to install from git to get the ci to pass before we merge. Can you have a look at that or shall I? An extra one question: I am not sure if we want to commit the batch files to run delft3d-fm or if we keep them local? |
TODO:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated crs funcs look good!
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Issue addressed
Fixes #30
Explanation
Update self.mesh to include both 1D2D. The main changes is that now we only use self.dfmmodel when reading and writing.
This means that conversion functions from xugrid mesh to hydrolib network were added in a new mesh_utils.py script when we
want to use functions from hydrolib-core (eg add branches or create link1d2d etc).
Hopefully this makes it easier in the future to add new parts or data to the delft3dfm mesh and use mesh functions from xugrid.
For now, this PR was co-developed with hydromt core PR 412
Checklist
main
Additional Notes
I had to put a pin on meshkernel version 2.0.2 as 2.1.0 did some breaking changes on a link1d2d function that hydrolib-core still needs to fix.
As region is now the total bounds of 1D2D mesh, each setup method preparing a 1D or 2D part of the mesh comes with its own region argument so that they can be different from each other. For ease of use, we did not want to set defaults here so region is mandatory for all the setup 1D or 2D mesh methods.
I added two optional tasks to the checklist but they could also be done in another PR.
For the cleanup one, while updating the API docs, I wonder if some of our functions should not be moved into workflows or included in setup_functions ? These are:
I think the rest is okay. @xldeltares what do you think?