Fix/2521 curvilinear pic spherical#2598
Merged
fluidnumericsJoe merged 3 commits intomainfrom Apr 28, 2026
Merged
Conversation
…ical" When the mesh type is "spherical" for a curvilinear structured grid, we now use a PIC check that maps the curvilinear cell to x,y,z space on the unit sphere. Within the cell, we construct an orthonormal basis for the cell using vectors that point between edge centers in the xsi and eta directions. Particle positions are converted to x,y,z space and projected onto the cell plane. This approach is identical to what is done for unstructure "spherical" grids; it is robust across the polar caps and across the antimeridians. This change removes the need for consistency checking in the _xinterpolator.py for curvilinear grids for points in the vicinity of the antimeridian
After the curvilinear PIC moved to a tangent-plane bilinear inverse, the old "lat/lon-bilinear blend of corner lons reconstructs query lon" check no longer holds. Replace it with a blend of corner 3D unit-sphere vectors, renormalized onto the sphere, and compare the recovered lat/lon to the query. Tolerance 1e-5 gives ~30x headroom over the worst observed error (~3e-7) on the 1/4 degree NEMO test grid.
erikvansebille
approved these changes
Apr 28, 2026
Member
erikvansebille
left a comment
There was a problem hiding this comment.
Looks good to me! Curious to see whether this new code impacts on performance, but we'll see that in the benchmarks, I guess?
One small comment below
Contributor
Author
|
@VeckoTheGecko - these failures seem unrelated to the changes in this PR; they only came in after merging with main. Looking into it, there's 502 errors showing up on attempts to retrieve data for tests... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR resolves #2521 . When
mesh.type="spherical"for curvilinear grids, the spatial hash search is done on a 3-D cartesian grid where the lat,lon are mapped to x,y,z on the surface of a unit sphere. The previous particle-in-cell (PIC) check was being done still in lat-lon space. This required awkward contortions to handle the antimeridian; @noemieplanat uncovered another issue in the vicinity of the polar caps where lat,lon elements are essentially co-linear (nearly identical latitude) causing a failure in the particle lookup .To more cleanly handle antimeridian and polar caps, this PR changes the PIC check for curvilinear grids with spherical mesh type to match what we do for unstructured grids with spherical mesh type. We map from lat,lon -> x,y,z and perform the search on the unit sphere. For each queried cell, we construct a local tangent plane on the unit sphere and project particle positions onto that plane in order to calculate their computational coordinates.
Checklist
mainfor normal development,v3-supportfor v3 support)AI Disclosure