Skip to content

Adds a warning whenever a _mesh is different for a field when added to a FieldSet, or during Fieldset creation#2761

Merged
wyatt-fluidnumerics merged 6 commits into
mainfrom
mesh-check-on-fieldset-creation
Jul 22, 2026
Merged

Adds a warning whenever a _mesh is different for a field when added to a FieldSet, or during Fieldset creation#2761
wyatt-fluidnumerics merged 6 commits into
mainfrom
mesh-check-on-fieldset-creation

Conversation

@wyatt-fluidnumerics

@wyatt-fluidnumerics wyatt-fluidnumerics commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Description

Currently, mixing "flat" and "spherical" meshes in a FieldSet is allowed without warning. This can happen without intention whenever a field is created with the default mesh, which may not be the same mesh as underlies the rest of the FieldSet. This PR adds a function _warn_if_fields_use_different_meshes(fields: Iterable[Field | VectorField]) in fieldset.py which produces a FieldSetWarning if fields in the input iterable have different _mesh in their underlying grid. A call to the function is also added at the end of FieldSet.__init__ and FieldSet.add_field

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 used Claude Code in plan mode to help understand relevant parts of the code base. All code was written by myself.

@wyatt-fluidnumerics

Copy link
Copy Markdown
Contributor Author

It is unclear to me whether a call to _warn_if_fields_use_different_meshes should also be added at the end of add_constant_field. My understanding is the underlying mesh of a constant field changes the effect on particles by prescribing m/s or deg/s for "flat" and "spherical" respectively. In tests/test_fieldset.py constant fields with different underlying meshes are used a number of times (notably in fieldset_two_models).

@erikvansebille

Copy link
Copy Markdown
Member

Thanks @wyatt-fluidnumerics!

It is unclear to me whether a call to _warn_if_fields_use_different_meshes should also be added at the end of add_constant_field.

Yes, I would also add this test when adding constant fields. And any errors in the test suite should will then have to be patched?

…ly combine/create FieldSets with the same underlying mesh
@wyatt-fluidnumerics

Copy link
Copy Markdown
Contributor Author

I added the check to add_constant_field and revised the tests to use the correct mesh.

@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.

Thanks @wyatt-fluidnumerics. Happy for this to be merged!

@wyatt-fluidnumerics
wyatt-fluidnumerics merged commit be4f5d9 into main Jul 22, 2026
17 checks passed
@wyatt-fluidnumerics
wyatt-fluidnumerics deleted the mesh-check-on-fieldset-creation branch July 22, 2026 14:22
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Jul 22, 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.

Throw warning if _mesh is not the same for all Fields when creating FieldSet

2 participants