Skip to content

FEAT: Add mesh properties, fail on mismatched meshes - #2848

Open
VeckoTheGecko wants to merge 7 commits into
Parcels-code:mainfrom
VeckoTheGecko:meshing
Open

FEAT: Add mesh properties, fail on mismatched meshes#2848
VeckoTheGecko wants to merge 7 commits into
Parcels-code:mainfrom
VeckoTheGecko:meshing

Conversation

@VeckoTheGecko

@VeckoTheGecko VeckoTheGecko commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Description

Changes:

  • Added mesh property to ModelData base class
  • Added mesh property to FieldSet
  • Updated FieldSet init to call assert_models_have_same_mesh (which raises IncompatibleMeshesException)
  • Add test

Checklist

AI Disclosure

None used

@VeckoTheGecko

VeckoTheGecko commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

if you have capacity @wyatt-fluidnumerics , it would be great to have your review

@VeckoTheGecko VeckoTheGecko changed the title Add mesh properties, and fail on mismatched meshes FEAT: Add mesh properties, fail on mismatched meshes Aug 25, 2026

def __init__(self, models: list[ModelData]):
if models == []:
raise ValueError("List of models can't be empty.")

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.

With this change we can't have fieldsets with only constant fields (which is very reasonable), since that would result in an ambigious fieldset mesh.

Hence I also removed test_fieldset_time_interval_constant_fields

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.

I realise now that our docs relied on "empty, constant only" fieldsets.

docs/user_guide/examples/tutorial_interaction.ipynb

I assume that you wrote this @erikvansebille . I'll postpone merging, and leave this open until you're back

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.

Actually, I think there are use cases where we have empty fieldsets - like indeed in the particle-particle interaction tutorial. If users want to use parcels as an Agent-Based-Model engine, they typically don't have/use Fields.

How problematic is it to support empty fieldsets? Perhaps we should change the interaction-tutorial to not have any fields at all (instead of only constant fields)? Or will that be a major endeavour (for another PR)?

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.

If users want to use parcels as an Agent-Based-Model engine, they typically don't have/use Fields.

I'm not quite sure I understand this - I feel that this is scope creep for the project. Why would users want to use Parcels as an engine for agent based modelling? (instead of other libraries in Python for this)

@wyatt-fluidnumerics wyatt-fluidnumerics left a comment

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.

This all looks great to me. I think this would also be a good time to remove the mesh argument from add_constant_field like you mentioned in the original issue.

@VeckoTheGecko

Copy link
Copy Markdown
Contributor Author

remove the mesh argument from add_constant_field

Yeah sure, I can wrap that into here :)

@VeckoTheGecko

VeckoTheGecko commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

remove the mesh argument from add_constant_field

Yeah sure, I can wrap that into here :)

Actually, I remember why I didn't - I wanted to do it after #2845 as that would make things easier (I also wanted to expand testing for add_constant_field since it doesn't work at the moment for SphericalMesh(some_custom_radius)

Separate PR would be better I think

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

Looks good - except that I think we should support empty FieldSets. but that could perhaps be annother PR? See below


def __init__(self, models: list[ModelData]):
if models == []:
raise ValueError("List of models can't be empty.")

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.

Actually, I think there are use cases where we have empty fieldsets - like indeed in the particle-particle interaction tutorial. If users want to use parcels as an Agent-Based-Model engine, they typically don't have/use Fields.

How problematic is it to support empty fieldsets? Perhaps we should change the interaction-tutorial to not have any fields at all (instead of only constant fields)? Or will that be a major endeavour (for another PR)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants