Skip to content

Better torus support for mean cell area etc.#848

Merged
msimberg merged 73 commits intoC2SM:mainfrom
msimberg:better-torus-support-3
Sep 22, 2025
Merged

Better torus support for mean cell area etc.#848
msimberg merged 73 commits intoC2SM:mainfrom
msimberg:better-torus-support-3

Conversation

@msimberg
Copy link
Copy Markdown
Contributor

@msimberg msimberg commented Aug 27, 2025

Part 3 of N for better torus support.

Adds:

  • mean_cell_area
  • mean_dual_cell_area
  • mean_edge_length
  • mean_dual_edge_length

and their computation to GlobalGridParams. These are read from the grid file, if available. If they're not available, they're computed from the corresponding fields. As a fallback of the fallback, the mean_cell_area is computed from the global number of cells and the area of the sphere. However, I'm considering removing this fallback as it should always be possible to compute it from the fields.

As far as I can tell, mean_dual_cell_area and mean_edge_length are currently not used for anything but I'm adding them for completeness because:

  • mean_cell_area is required to compute characteristic_length which is used for RBF interpolation on spheres, and
  • mean_dual_edge_length is used for RBF interpolation on toruses (this will be used in Initialize geometry fields for torus grids #853).

msimberg added 23 commits August 7, 2025 15:46
Add a few torus tests, as well as tests that are expected to fail.
Avoid conflict with gt4py GridType.
Make accessing geometry_type easier from GlobalGridParams, when
grid_params is None (user does not have to check if the nested
grid_params is None to access grid_params.geometry_type).
@msimberg msimberg force-pushed the better-torus-support-3 branch from 938f62d to febb2b3 Compare August 28, 2025 09:32
Will be refactored later.
It provides little value over the regular constructor. The regular
constructor now takes keywords, so passing just the mean_cell_area by
keyword is simpler and clearer.
@msimberg
Copy link
Copy Markdown
Contributor Author

cscs-ci run default

@msimberg
Copy link
Copy Markdown
Contributor Author

cscs-ci run default

@msimberg
Copy link
Copy Markdown
Contributor Author

cscs-ci run default

@halungge
Copy link
Copy Markdown
Contributor

CSCS test run failed because of missing grid files. @halungge if I understand correctly you have access to add grid files to be accessible by the CSCS CI runs on capstor. When you have some extra time, would you mind adding grid files for the tests that failed here: https://gitlab.com/cscs-ci/ci-testing/webhook-ci/mirrors/5125340235196978/2255149825504669/-/jobs/11355053444#L2560?

Does this work now, or you still need other Grids?

@msimberg
Copy link
Copy Markdown
Contributor Author

cscs-ci run default

@msimberg
Copy link
Copy Markdown
Contributor Author

CSCS test run failed because of missing grid files. @halungge if I understand correctly you have access to add grid files to be accessible by the CSCS CI runs on capstor. When you have some extra time, would you mind adding grid files for the tests that failed here: https://gitlab.com/cscs-ci/ci-testing/webhook-ci/mirrors/5125340235196978/2255149825504669/-/jobs/11355053444#L2560?

Does this work now, or you still need other Grids?

Grids work, thank you!

@msimberg
Copy link
Copy Markdown
Contributor Author

cscs-ci run default

halungge pushed a commit that referenced this pull request Sep 19, 2025
Adds the ability to produce scalar values from the factories. 
We need this in the metrics factory for the computation of `nflat_gradp`
for the dynamical core and will need it as well for the computation of
some mean properties for the grid (`mean_cell_area`...) as discussed in
[PR-848](#848)

(Additional fixes): fixes a lot of typing issues in all three factory
implementations.

---------

Co-authored-by: yiluchen1066 <67939569+yiluchen1066@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

Mandatory Tests

Please make sure you run these tests via comment before you merge!

  • cscs-ci run default

Optional Tests

To run benchmarks you can use:

  • cscs-ci run benchmark-bencher

To run tests and benchmarks with the DaCe backend you can use:

  • cscs-ci run dace

To run test levels ignored by the default test suite (mostly simple datatest for static fields computations) you can use:

  • cscs-ci run extra

For more detailed information please look at CI in the EXCLAIM universe.

@msimberg
Copy link
Copy Markdown
Contributor Author

cscs-ci run default

@msimberg msimberg merged commit dd21bc4 into C2SM:main Sep 22, 2025
47 checks passed
@msimberg msimberg deleted the better-torus-support-3 branch September 22, 2025 13:46
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

Successfully merging this pull request may close these issues.

2 participants