Skip to content

Conversation

@fluidnumerics-joe
Copy link
Contributor

@fluidnumerics-joe fluidnumerics-joe commented Dec 5, 2025

This PR builds on #2394 and adds a section for unstructured grid interpolation.

In working on this tutorial, I've found that the waschpress point implementation was not robust; in some cases, particles were erroneously detected inside faces they were not inside of. I've corrected this by implementing strictly barycentric coordinates for 3-sided cells with a much simpler algorithm. With this implementation, I've also enforced a check to ensure that ux.grid objects have at most 3 nodes per face (triangle only meshes). I think this is fine, since the ICON and FESOM2 cases we're currently prioritizing only use triangular meshes. Nonetheless, I'll open a discussion on Zulip to gauge interest in supporting n-gon meshes.

Additionally, when using the "spherical" mesh type, I've found that the spherical coordinate transformation on particle (lat,lon) positions produces cartesian locations that are not in the plane spanned by the element faces. This allows the sum of the barycentric coordinates to be greater than one. To fix this, I've added a step in the point-in-cell check to remove the component of the cartesian location that is normal to the element plane when performing point in cell checks. This resolves issues with false negatives on spherical type meshes.

Still need to clean up the particle color plots. Almost there..
In developing the tutorial, the generalized waschpress point implementation
was found to erroneously detect inside/outside . I've rolled back to a
more simple barycentric coordinate calculation for 3-sided faces and put
in a restriction that ux.grid objects have at most 3 nodes per face.
I'll open an issue for implementing a more robust n-sided waschpress
point implementation
The location that the particle ends up at changes since we've changed
the method in which the barycentric coordinates are calculated.
fluidnumerics-joe and others added 7 commits December 8, 2025 16:07
The spherical coordinate transformation of a point computes a cartesian
location that is outside the element plane. When computing barycentric
coordinates, this makes it possible for the sum of the barycentric
coordinates to exceed 1. To fix this, we remove the component of the
particle's cartesian coordinates that is normal to the element plane
when performing point in cell checks
Note also that changes in test assertions were needed for unstructured
grid pset.execute tests that use spherical mesh types. This arises due
to the fact that we now alter the particle locations by removing the
component of the spherical coordinate transformation that is not in the
element plane; this changes the resulting barycentric coordinates and
thus interpolated values for particle advection.
Copy link
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

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

Suggestions for fixing the last failing test (due to change in interpolation API); looks good otherwise!

@fluidnumerics-joe fluidnumerics-joe merged commit db0f8fe into v4-dev Dec 9, 2025
11 checks passed
@fluidnumerics-joe fluidnumerics-joe deleted the uxinterpolation_tutorial_v4 branch December 9, 2025 18:24
@github-project-automation github-project-automation bot moved this from Backlog to Done in Parcels development Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants