Skip to content

Add torus support for interpolation fields#954

Closed
msimberg wants to merge 2 commits intoC2SM:mainfrom
msimberg:better-torus-support-interpolation
Closed

Add torus support for interpolation fields#954
msimberg wants to merge 2 commits intoC2SM:mainfrom
msimberg:better-torus-support-interpolation

Conversation

@msimberg
Copy link
Copy Markdown
Contributor

@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.

)
self.register_provider(cell_average_weight)
case _:
raise ValueError("TODO")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably assert_never is better. Here and elsewhere.

),
"domain_length": self._grid.global_properties.domain_length
if self._grid.global_properties.domain_length
else -1.0,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugly, but have to pass numeric values to factory.

Comment on lines +689 to +699
# TODO(msimberg): Exact result for torus without the following. 1e-16 error
# with the the following. Is it needed?
return _force_mass_conservation_to_c_bln_avg(
c2e2c0,
c_bln_avg,
cell_areas,
cell_owner_mask,
divavg_cntrwgt,
horizontal_start_level_3,
array_ns,
)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't really judge if there are cases for torus where force_mass_conservation is actually required for some grids.

If not, we could leave it out, but the inaccuracy that it introduces is also minimal, so may be safer to leave it in.

Comment on lines +120 to +121
# TODO(msimberg): Rename again. This is arc length on a unit sphere for
# icosahedral grids and real distance for torus grids.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To do: renaming.

This difference is also visible in the rbf scale factor, where for icosahedral grids the factor is in radians and for toruses in meters(?).

I think we probably want to keep compatibility with icon fortran here so that the same scale factors can be used for both icon4py and icon fortran.

@jcanton jcanton closed this Dec 9, 2025
@jcanton jcanton mentioned this pull request Dec 9, 2025
jcanton added a commit that referenced this pull request Jan 5, 2026
Based upon #953 #954 and #957 by @msimberg
Adds torus support to geometry, RBF and interpolation.
Also adds torus grids to all datatests

---------

Co-authored-by: Mikael Simberg <[email protected]>
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