Skip to content

Replace XESMF with ConservativeRegridding#160

Open
simone-silvestri wants to merge 18 commits intomainfrom
ss/conservative-regridding
Open

Replace XESMF with ConservativeRegridding#160
simone-silvestri wants to merge 18 commits intomainfrom
ss/conservative-regridding

Conversation

@simone-silvestri
Copy link
Copy Markdown
Member

@simone-silvestri simone-silvestri commented Apr 14, 2026

Summary

  • Remove XESMF as a weak dependency and replace with ConservativeRegridding as a hard dependency
  • Rewrite the SpeedyWeather extension to use ConservativeRegridding.Regridder and regrid! instead of XESMF.Regridder
  • Use transpose(regridder) for the reverse direction instead of constructing a separate regridder

TODO

  • Test coupled SpeedyWeather simulation with the new regridding infrastructure
  • Ensure ConservativeRegridding compat bounds are correct for release

🤖 Generated with Claude Code

Remove XESMF entirely and use ConservativeRegridding for regridding
between SpeedyWeather and Oceananigans grids. ConservativeRegridding
is now a direct dependency rather than an extension.

The SpeedyWeather extension now implements treeify for RingGrids,
building GeoInterface polygons from cell vertices. This enables
the default OctahedralGaussianGrid instead of requiring FullClenshawGrid.

Note: treeify for SpeedyWeather grids needs testing to confirm
it works end-to-end with the conservative regridding pipeline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@simone-silvestri
Copy link
Copy Markdown
Member Author

Still need to verify some things, so I ll make this into a draft

@simone-silvestri simone-silvestri marked this pull request as draft April 14, 2026 07:09
simone-silvestri and others added 8 commits April 14, 2026 09:10
RingGrids.get_gridcell_polygons returns vertices in clockwise order
(E, S, W, N). Reverse to CCW (E, N, W, S) so that GO.area on the
Spherical manifold returns positive areas.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Build a proper ExplicitPolygonGrid + TopDownQuadtreeCursor for
SpeedyWeather grids instead of using FlatNoTree (brute force).

- Full grids: clean (nlon, nlat) ExplicitPolygonGrid, linear
  indices match RingGrid flat indices directly.
- Reduced grids: (nlon_max, nlat) matrix with degenerate padding
  for shorter rings, ReorderedTopDownQuadtreeCursor maps 2D indices
  to RingGrid flat indices, ghost cells beyond npoints have zero area.

The regrid! overloads handle the size mismatch for reduced grids
by zero-padding into temp arrays.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reduced grids now use one sub-tree per latitude ring combined via
MultiTreeWrapper. Each ring is an ExplicitPolygonGrid(nlon_ring, 1)
with IndexOffsetQuadtreeCursor mapping to flat RingGrid indices.
This gives ncells = npoints exactly — no ghost cells, no size
mismatch, so regrid! stays clean with no padding logic.

The dual DFS prunes entire latitude rings via SphericalCap extents,
and within each ring prunes by longitude via the quadtree.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extensions can only use packages listed in the parent Project.toml.
These are already in the dependency tree via ConservativeRegridding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 0% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...lEarthSpeedyWeatherExt/speedy_weather_exchanger.jl 0.00% 28 Missing ⚠️

📢 Thoughts on this report? Let us know!

Oceananigans uses radius=6.371e6, SpeedyWeather uses 6.3710088e6.
Pass the exchange_grid's manifold explicitly to Regridder to avoid
the "manifolds must be the same" error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@simone-silvestri simone-silvestri marked this pull request as ready for review April 27, 2026 08:44
Comment thread test/test_speedy_coupling.jl Outdated
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.

1 participant