-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add function to build mesh from imported connectivity data #135
Add function to build mesh from imported connectivity data #135
Conversation
@wdeconinck Here's the mesh-building function I've been working with. Let me know if you think this is the right approach or if the functionality should be repackaged in a different way... |
Hi @fmahebert thanks that looks like a good approach. As a first comment I'm not so keen on Also, how come you provide remote_index for cells but not for nodes? Nodes' |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #135 +/- ##
===========================================
+ Coverage 77.53% 77.57% +0.03%
===========================================
Files 808 807 -1
Lines 58119 51418 -6701
===========================================
- Hits 45065 39888 -5177
+ Misses 13054 11530 -1524
☔ View full report in Codecov by Sentry. |
Sounds good, I will split the structs and pass extra arguments as you suggest.
I don't remember how I got here, most likely ignorance? What do you think of this plan:
Does this match your suggestion or have I misunderstood? Finally, an unrelated question: what is the atlas policy on copyright headers? should I put UCAR's header? |
That matches the suggestions indeed. |
Thanks for the feedback @wdeconinck! I've made some updates here, and will check how the new version integrates with fv3-jedi tomorrow. I'll report back then. |
I've tested importing the fv3-jedi grid into an atlas Mesh via the updated interface, and it works just as well (and is easier). Happy on my end. |
* Some limitations of the current implementation (but not inherent): | ||
* - can only set up triangle and quad cells. | ||
* - cannot import halos, i.e., cells owned by other MPI tasks; halos can still be subsequently | ||
* computed by calling the BuildMesh action. |
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.
@ytremolet the current design of this PR means we'll ask the JEDI models to call the build_halo
action after creating the mesh but before constructing the functionspace. It's one very simple line of code, so not a big deal.
We could streamline a little either by...
- adding a bool option here to call
build_halo
internally to this function - expanding the interface so models can import their halos directly
Personally I like the current design, because it keeps the responsibilities clear and makes the halo-building step easy to spot. I think we could support (2) in the future if the teams are interested in reusing their own halo structure. Do you have a different opinion as to whether either of these options is significantly better than the current state?
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.
It seems fine. The test doesn't cover that part (or I missed it). That's ok because it's not part of the new function, but do you have an example (in fv3 or other?) to get a better idea what it looks like from the user point of view?
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.
@ytremolet I don't have something very clean, but on fv3-jedi branch feature/fmahebert_test_atlas_mesh_builder
you can see (note to others, this is not a public repo) a code block in Geometry.cc that sets up the mesh, builds a halo, and tests some halo exchange; in the fortran you can see how the connectivity is inferred from the grid structure; all the above is mixed in which other small changes I was testing but didn't take the time to clean out (sorry).
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.
I had a look at your example. It looks reasonable given the information we want to get from the models. And for now the halo is not shocking, this is code that is only needed once for each model, it won't be repeated all over the place so I would be happy with the current implementation.
Perfect. Note that we also need to add a "base" argument for remote_indices. Now fine-tuning the API. How about creating a class with operator() in the atlas::mesh namespace. Also let's make the implementation using C-style arrays, and have the previous argument list using std::vector's delegate to it. This way we can possibly support different container types, and create Fortran interfaces using Fortran arrays without incurring extra copies. I mean something like following.
|
Thanks @wdeconinck — these suggestions all make sense; I'll make the changes. One clarifying question though about your suggested interface: in the C++ Edit to clarify: I would expect reinterpreting as a |
Changes made (but changing the reinterpret_cast from |
Indeed, just mistake on my part :) |
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.
Thanks @fmahebert looks great, except I'd like it in the atlas::mesh namespace please.
Done! |
Co-authored-by: Willem Deconinck <[email protected]>
b48c753
to
14dc611
Compare
* develop: (56 commits) Implement field::for_each capabilities (ecmwf#139) Avoid harmless FE_INVALID with nvhpc build Avoid harmless FE_INVALID with nvhpc build Remove ATLAS_FPE=0 environment variable as not needed anymore now Avoid harmless FE_DIVBYZERO with nvhpc build Optimize modules and dependencies for caching Add HPC build options matrix Workaround compiler bug in nvhpc-22.11-release build Update GHA nvidia-21.9 to nvidia-22.11 Avoid and suppress some compiler warnings with nvhpc Fix bug where DelaunayMeshGenerator with 1 partition was not setting the grid in the mesh (ecmwf#143) Use Eigen 3.4 Disable floating point signals for tests on nvidia Add nvidia compiler specific HPC build config Add function to build mesh from imported connectivity data (ecmwf#135) Disable GHA "linux gnu-12" OpenMP for CXX as "omp.h" header is not found :( Add gnu-12 ci to github actions (github-hosted runners) Add gnu-7 ci to github actions with github-hosted runners (ecmwf#136) Setup horizontal_dimensions() for BlockStructuredColumns fields Add function Field::horizontal_dimension() -> std::vector<idx_t> ...
For use in applications like JCSDA's JEDI where a mesh connectivity has been constructed externally to atlas (e.g. by a forecast model that does not use atlas to construct its mesh), and we want to reuse this connectivity to build an atlas NodeColumns FunctionSpace.
This function takes local (per MPI task) data about the nodes and cell-to-node connectivities, and sets up the corresponding fields in a Mesh.