Describe the bug
While running the official example 9-Unsteady_Flow.ipynb, I encountered a ValueError during the advection step. The error occurs when using order=2 (RK2) for swarm advection after adding new particles to the swarm. It seems the internal buffers for the RK2 scheme do not resize to accommodate the updated swarm size.
To Reproduce
Python
import underworld3 as uw
passive_swarm = uw.swarm.Swarm(mesh=mesh)
passive_swarm.populate(
fill_param=0,
)
max_steps = 50
timestep = 0
elapsed_time = 0.0
delta_t = 0.05
for step in range(0, max_steps):
# Keep previous guess for solve
navier_stokes.solve(zero_init_guess=False, timestep=delta_t)
passive_swarm.advection(v_soln.sym, delta_t, order=2, corrector=False)
# Add new tracer particles near the inlet
new_points = 100
new_coords = np.array([0.0, 0.25] + 0.5 * np.random.random((new_points, 2)))
passive_swarm.add_particles_with_coordinates(new_coords)
...
The following snippet is a simplified version of the logic in 9-Unsteady_Flow:
## --- Step 1: Initial advection (works fine) ---
# This likely initializes internal buffers with the current swarm size
passive_swarm.advection(v_soln.sym, delta_t, order=2)
## --- Step 2: Add new particles (as seen in Example 9) ---
new_points = 100
new_coords = np.array([0.0, 0.25] + 0.5 * np.random.random((new_points, 2)))
passive_swarm.add_particles_with_coordinates(new_coords)
## --- Step 3: Second advection (Crashes) ---
# This fails with a shape mismatch error
passive_swarm.advection(v_soln.sym, delta_t, order=2)
## Error Message
ValueError: could not broadcast input array from shape (N_old, 2) into shape (N_new, 2)
(Note: In my case, it was (742, 2) and (842, 2))
Environment:
OS: macOS (Apple Silicon M3)
Underworld3 Version: [0.99.0b]
Example: 9-Unsteady_Flow.ipynb
Describe the bug
While running the official example 9-Unsteady_Flow.ipynb, I encountered a ValueError during the advection step. The error occurs when using order=2 (RK2) for swarm advection after adding new particles to the swarm. It seems the internal buffers for the RK2 scheme do not resize to accommodate the updated swarm size.
To Reproduce
The following snippet is a simplified version of the logic in 9-Unsteady_Flow:
Environment:
OS: macOS (Apple Silicon M3)
Underworld3 Version: [0.99.0b]
Example: 9-Unsteady_Flow.ipynb