Skip to content

Evolve: use finest_level instead of max_level to gate RedistributeLocal#6727

Merged
ax3l merged 1 commit intoBLAST-WarpX:developmentfrom
RemiLehe:fix/6653-redistribute-local-finest-level
Mar 31, 2026
Merged

Evolve: use finest_level instead of max_level to gate RedistributeLocal#6727
ax3l merged 1 commit intoBLAST-WarpX:developmentfrom
RemiLehe:fix/6653-redistribute-local-finest-level

Conversation

@RemiLehe
Copy link
Copy Markdown
Member

@RemiLehe RemiLehe commented Mar 31, 2026

Summary

HandleParticlesAtBoundaries was using max_level == 0 to decide whether to use the cheap RedistributeLocal path. But max_level is the configured maximum AMR depth, while finest_level is the number of currently active levels. Whenever a user sets amr.max_level > 0 to allow future refinement, the local redistribute was bypassed unconditionally — even when the hierarchy currently had only one level and the optimization would have been valid and faster.

Fix

Replace max_level == 0 with finest_level == 0.

Fixes #6653

🤖 Generated with Claude Code

RedistributeLocal is safe when all particles fit within a single
AMR level. The guard was checking `max_level == 0` (the configured
maximum depth), but the relevant quantity is `finest_level` (the
number of currently active levels). When a user enables AMR with
`amr.max_level > 0` but the hierarchy has not yet refined, the
cheap local redistribute was always bypassed even though it would
have been correct and faster.

Fixes BLAST-WarpX#6653

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@RemiLehe RemiLehe changed the title Evolve: use finest_level instead of max_level to gate RedistributeLocal [WIP] Evolve: use finest_level instead of max_level to gate RedistributeLocal Mar 31, 2026
@RemiLehe RemiLehe changed the title [WIP] Evolve: use finest_level instead of max_level to gate RedistributeLocal Evolve: use finest_level instead of max_level to gate RedistributeLocal Mar 31, 2026
@RemiLehe RemiLehe requested a review from ax3l March 31, 2026 16:19
Copy link
Copy Markdown
Member

@ax3l ax3l left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! :)

@ax3l ax3l added bug Something isn't working component: mesh refinement (A)MR bug: affects latest release Bug also exists in latest release version labels Mar 31, 2026
@ax3l ax3l merged commit 843bd17 into BLAST-WarpX:development Mar 31, 2026
48 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug: affects latest release Bug also exists in latest release version bug Something isn't working component: mesh refinement (A)MR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local particle redistribute is disabled whenever max_level>0

2 participants