Skip to content

Advecting a swarm that was never populated fails with 'negative dimensions are not allowed' (DMSwarm local size -1) #702

Description

@lmoresi

A uw.swarm.Swarm that has had no particles added on any rank reports swarm.local_size == -1 (the DMSwarm size before any population), and swarm.advection(V_fn, dt) then dies inside numpy with ValueError: negative dimensions are not allowed. In serial as in parallel. An empty rank of a populated swarm (size 0) is handled since #680; the never-populated swarm is not the same case and deserves a clear error naming the cause. Found while resolving #693 (a driver advected its tracer swarm before the first release).

Reproduction:

mesh = uw.meshing.UnstructuredSimplexBox(minCoords=(0,0), maxCoords=(1,1), cellSize=0.25)
x, y = mesh.X
swarm = uw.swarm.Swarm(mesh)
swarm.local_size            # -1
swarm.advection(sympy.Matrix([[-y, x]]), 0.01)   # ValueError: negative dimensions are not allowed

🤖 Generated with Claude Code

https://claude.ai/code/session_018T2VHUGaZiQVJ95qQ4DiSL

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions