Skip to content

Conversation

@erikvansebille
Copy link
Member

@erikvansebille erikvansebille commented Dec 23, 2025

This PR fixes #2143 by creating a ParticleSetView class that links a View of the ParticleSet (on the kernel level) to a ParticleSet.

This allows much more intuitive masking in Kernels, see e.g. the change in the Argo and the interaction tutorials.

For example, some of the old code for the Merge Kernel in the interaction tutorial was

masses = particles.mass
states = particles.state

masses[larger_idx] += particles.mass[smaller_idx]
states[smaller_idx] = parcels.StatusCode.Delete

particles.mass = masses
particles.state = states

While the new code is

particles.mass[larger_idx] += particles.mass[smaller_idx]
particles.state[smaller_idx] = parcels.StatusCode.Delete

Note that this PR is blocked by #2444 (fix cherry-picked into this PR as 9aa0f32)

@erikvansebille erikvansebille added the 🚧BLOCKED🚧 An issue that is blocked by another issue. label Dec 23, 2025
@erikvansebille erikvansebille changed the base branch from v4-dev to fix_uxgrid_indexsearch_bug December 23, 2025 07:53
@erikvansebille erikvansebille marked this pull request as ready for review December 23, 2025 09:20
@erikvansebille erikvansebille changed the base branch from fix_uxgrid_indexsearch_bug to v4-dev December 23, 2025 09:21
@erikvansebille erikvansebille changed the title Implementing View for KernelParticle Implementing View for KernelParticle/ParticleSet Dec 24, 2025

class KernelParticle:
"""Simple class to be used in a kernel that links a particle (on the kernel level) to a particle dataset."""
class ParticleSetView:
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this particle.py file the best place for the ParticleSetView and ParticleSetViewArray classes? Or better to move them to particle.py; or its own file?

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

Labels

🚧BLOCKED🚧 An issue that is blocked by another issue.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

Refactor particleset attributes and particle data for vectorized kernels

2 participants