Skip to content

Uxgrid edge data interpolators - #3012

Merged
wyatt-fluidnumerics merged 7 commits into
mainfrom
uxgrid-edge-data-interpolators
Oct 30, 2026
Merged

wyatt-fluidnumerics merged 7 commits into
mainfrom
uxgrid-edge-data-interpolators

Conversation

@wyatt-fluidnumerics

@wyatt-fluidnumerics wyatt-fluidnumerics commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds built in interpolators for edge registered UxGrid data, it also adds testing for the default selection of uxinterpolators during fieldset creation.

The two interpolators match existing built in convention for constant ZC and linear ZF interpolation, while doing piecewise constant lateral interpolation by averaging edge data to face centers.

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
      • Describe how you used it (e.g., by pasting your prompt): I implemented the constant ZC interpolator and then asked opus 5.5 to do the matching case for linear ZF. I reviewed all code produced by the llm.

@erikvansebille erikvansebille mentioned this pull request Oct 26, 2026
2 tasks done

@erikvansebille erikvansebille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR looks good - just one request below

assert np.allclose(fieldset.p.eval(t=tq, z=zq, y=yq, x=xq), zc * (xq + yq))


def test_from_ugrid_conventions_selects_correct_interpolator():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you also add a test for correctness? E.g. with a simple field where you can calculate the answer by hand? So that we can make sure that the interpolator doesn't break in the future?

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.

Added in 82a15bf. I also realized that none of the other UxGrid interpolators have testing for this kind of thing either. I'll open an issue on this tomorrow.

@github-project-automation github-project-automation Bot moved this from Backlog to Ready in Parcels development Oct 26, 2026
edim: xr.DataArray(edge_ids, dims=("points", "edges")),
}
edge_data = field.data.isel(selection_dict, ignore_grid=True)
value = edge_data.mean("edges").data # Face value is the mean of its surrounding edges

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this is essentially piecewise constant ? What if I have an edge that is much shorter than the other 2 ? Is it's value as important as the others in constructing the value for the face ?

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.

My understanding is that the centroid is the mean of the node locations. So this is just averaging to the centroid and then using piecewise constant. The default interpolator for n_face is also piecewise constant so I think this is fine for now.

Long term it would be great to add more complex interpolation methods for unstructured grids, I'll open an issue on this?

@wyatt-fluidnumerics
wyatt-fluidnumerics merged commit 267e8d4 into main Oct 30, 2026
24 checks passed
@wyatt-fluidnumerics
wyatt-fluidnumerics deleted the uxgrid-edge-data-interpolators branch October 30, 2026 13:23
@github-project-automation github-project-automation Bot moved this from Ready to Done in Parcels development Oct 30, 2026
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.

from_ugrid_conventions crashes with opaque TypeError for extra variables with unsupported dimension layouts

3 participants