-
Notifications
You must be signed in to change notification settings - Fork 168
Uxinterpolation tutorial v4 #2421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
+486
−87
Conversation
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
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.
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.
erikvansebille
approved these changes
Dec 9, 2025
Member
erikvansebille
left a comment
There was a problem hiding this 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!
Co-authored-by: Erik van Sebille <[email protected]>
Co-authored-by: Erik van Sebille <[email protected]>
for more information, see https://pre-commit.ci
…/Parcels into uxinterpolation_tutorial_v4
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.
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.gridobjects 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.