-
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
Set UnstructuredGrid in meshes built by MeshBuilder #150
Comments
Even though I understand the convenience of However your proposed solution (Solution 1) is indeed one of the better ones, also concerning memory if we can keep the grid optional. The mpi communicator should also be an optional configuration parameter where its value is a string key in the eckit::Comm map. If not passed, the default communicator is used. This is in line with the other issue #131 |
Thanks for your comments on this, @wdeconinck. I've been thinking more about our use-case in JEDI, and we should be able to handle the unstructured case separately without constructing the full UnstructuredGrid in the MeshBuilder. I would still want to call How do you recommend we set up the MeshBuilder to allow this? Currently the MeshBuilder creates a Mesh whose Grid is not initialized, so any calls to it will be a memory error. I haven't yet found an easy way to flag the Mesh's Grid as being invalid from within the Mesh itself. I thought of initializing the Grid like ~ Do you have any advice on how we can more gracefully initialize the mesh's grid, or more gracefully check whether it's safe to use |
I've found it: I can use Using this feature to identify if the Grid is initialized + a JEDI workaround for uninitialized (and implicitly unstructured) grids, I think the develop code suites our needs at present. Independently of this, would you like to see the MeshBuilder set the Mesh's Grid, @wdeconinck ? Note that I anticipate most use cases for MeshBuilder would have an UnstructuredGrid, because if the Grid were easily constructible from atlas then there are more elegant interfaces to get to a Mesh. |
Indeed sorry that was not obvious before that you could use
You can do this programmatically with
We could agree that IF the grid type is "unstructured", and IF the "xy" entry is missing, then you have to assemble it via AllGather of owned nodes and global_index yourself within the MeshBuilder. |
This all makes sense, and looks a lot like what I have on a branch. But how do you want to handle the case where a grid is given including its grid points (perhaps unstructured with "xy" list, or some named structured grid)... in a probabilistic sense, most mesh-related input arguments to the MeshBuilder will not be consistent with a particular named atlas grid, and it might be nice to prevent the user from constructing something ill-posed because the grid and mesh are inconsistent. I see three avenues:
What do you think is the way to proceed? I suggest starting with (3) and writing the code for (2) if/when needed... |
I think 2. is a good approach for safety indeed. Each partition, using its global index, could verify the grid coordinates are as expected. |
@wdeconinck I want to verify my understanding of how this can be implemented...
But now I want to check consistency between the Mesh and the Grid, perhaps with code like
My first question is: does the above understanding seem correct? If all the above seems correct, then I need some way to connect these two
Alternatively, I can use a more complex validation algorithm: instead of linearly iterating over the points, do a search to check every point passed to the MeshBuilder is a point in the Grid. A bit computationally demanding perhaps, especially for UnstructuredGrids. My second question is: do you have an opinion, or an alternative suggestion, to the above? |
For nearly all meshes, the nodes.global_index() will indeed follow the grid ordering with 1-base. This is the assumption that should be made, because it is also how the fields are ordered via MPI Gather. So Only for some meshes like HEALPix, or the CubedSphere, the grid-points denote the cell-centres of the mesh. In that case it should be cells.global_index() which follows the grid ordering with 1-base. You should probably disable the validation then, as cells don't have a lonlat field, or at least not a field that is uniquely defined (probably a check if the grid point is contained in the cell could work). Whether to do any validation check at all could be a configuration option passed to the MeshBuilder constructor. |
Thanks @wdeconinck for the info and opinions above. I agree with sticking to a simple validation that is opt-in via config, assumes the |
Is your feature request related to a problem? Please describe.
Some JEDI applications will want to use the MeshBuilder but also to call
mesh.grid()
. Currently the grid is not set.Describe the solution you'd like
Setting the grid requires a global list of point coordinates.
I propose this change: MeshBuilder takes an MPI comm as argument, does an allGather of the (owned) point lons/lats, and constructs an UnstructuredGrid from the global list of points.
But there are some alternative options:
I think the propose change is a more straightforward design and easier to think about. The alternative options put more burden on the user, and are a more complicated design (build a global list but then need to find a subset), but do avoid adding an MPI comm to the argument list.
@wdeconinck do you have a preferred design?
Describe alternatives you've considered
No response
Additional context
No response
Organisation
UCAR/JCSDA
The text was updated successfully, but these errors were encountered: