-
Notifications
You must be signed in to change notification settings - Fork 250
Description
Summary
HandleParticlesAtBoundaries decides whether to use the cheap MultiParticleContainer::RedistributeLocal path with the condition if (max_level == 0) (Evolve/WarpXEvolve.cpp:672). But max_level is the allowed AMR depth, not the number of active levels. As soon as a user sets amr.max_level > 0 to permit future refinement, this check fails even when the hierarchy currently contains only level 0 cells. The code therefore always falls back to the heavy Redistribute() call, ignoring the num_moved bookkeeping that was designed specifically for single-level moving-window runs.
Impact
Moving-window and boosted-frame runs that anticipate adaptive refinement now pay the cost of a global particle redistribution every timestep, even while no fine level exists. This defeats the optimization that limits communication to num_redistribute_ghost cells and adds substantial overhead (and unnecessary particle resorting) precisely in the regime where most users would expect the faster single-level path.
Fix
Key off the current finest level instead: use the local path whenever finest_level == 0, regardless of the configured maximum. Multi-level cases will continue to use the full Redistribute() logic.
Patch
diff --git a/Evolve/WarpXEvolve.cpp b/Evolve/WarpXEvolve.cpp
@@
- if (max_level == 0) {
+ if (finest_level == 0) {Prepared by Codex