Skip to content
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

Grid getter in FunctionSpace #260

Open
tom-j-h opened this issue Feb 28, 2025 · 3 comments
Open

Grid getter in FunctionSpace #260

tom-j-h opened this issue Feb 28, 2025 · 3 comments

Comments

@tom-j-h
Copy link
Contributor

tom-j-h commented Feb 28, 2025

Is your feature request related to a problem? Please describe.

I'm working on something where it would be helpful for a FunctionSpace to be able to return a Grid.

If I understand correctly, all FunctionSpaces (excluding Spectral) should have a Grid underlying them in some way, whether that's directly ((Block)StructuredColumns), via the Mesh (Cell/Edge/NodeColumns), or implicitly via a list of Points (PointCloud).

Describe the solution you'd like

Could we have a getter in FunctionSpace, with implementations in each of the individual types except Spectral? This should be simple for the xColumns FunctionSpaces. PointCloud is trickier - I think we could generate a Grid on the fly using iterate() and return that, or return a Grid that was copied on construction of the PointCloud if it was constructed with one.

Describe alternatives you've considered

At the moment, I think I'd have to dynamic_cast to get the FunctionSpace of particualr type from the base FunctionSpace, then get Grids in the same way as described above.

Additional context

My use case is that we are implementing a simple parallel NetCDF I/O system for FieldSets in JEDI-OOPS. The first step before writing is to redistribute the data (using Redistribution) to a FunctionSpace on the same Grid as the native Fields (hence the need to obtain the grid) but who's Distribution is simply putting ~equal numbers of points onto each PE in order of Atlas's global index. The data is then written to the file in that order so that the files are agnostic to the number of PEs/domain decomposition of the native Fields. For reading the data back in, we do the reverse.

Organisation

Met Office

@tom-j-h tom-j-h changed the title Pure virtual Grid getter for FunctionSpace Grid getter in FunctionSpace Mar 13, 2025
@tom-j-h
Copy link
Contributor Author

tom-j-h commented Mar 13, 2025

I've just updated the title and description a bit.

@wdeconinck
Copy link
Member

I think this would be a good change and one I had been considering for a while.
The one concern I had, as you pointed out were the FunctionSpaces that have no attached grid.

But also as you pointed out these could be created except for the Spectral.

  • PointCloud
  • Mesh-based such as NodeColumns, CellColumns. It is not guaranteed that these have an attached grid, if they have just been created by a mesh reader or other means. In that case the same suggested procedure as for PointCloud could be done and a unstructured grid would need to be created.

@tom-j-h
Copy link
Contributor Author

tom-j-h commented Mar 19, 2025

Thanks for your comment, I wasn't aware that those types may need to construct a Grid too.

@mo-jonasganderton is also interested in adding this functionality and has some ideas on how to improve the PR. We can let you know when it's ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants