[2/n][Adjoint Module] Fix source deposition across chunk boundaries - #3290
Conversation
Zero-thickness sources can restrict onto multiple Yee points. When a chunk boundary intersects that stencil, source deposition can become dependent on the chunk layout, especially with a nonzero geometry center.\n\nEnumerate the full component-local stencil with global parity, then use the existing boundary-source relocation path to transfer samples to their timestep-owning chunks. Compact relocated source records and avoid collective setup when no relocation is needed.\n\nAdd deterministic 2D and 3D chunk-boundary regressions, including an evolved-field energy comparison.
064dd07 to
14e3910
Compare
|
@lxvm can you try this out? |
|
Sure! Is there an issue I can reference to understand what this should fix? |
|
@smartalecH this pr fixes the consistency in my simulations w.r.t. MPI parallelization when I use |
|
Closing in favour of #3298, which is the same branch and the same content, opened from this repository rather than from a fork. The reason is purely mechanical: this series is a stack of 13 pull requests, each based on the one below it so that every diff is only its own delta. GitHub's native stacked pull requests cannot include a PR opened from a fork, and four of the thirteen — including this one — were. Rather than leave the series half-stacked, all four have been reopened with their branches hosted here so the whole chain can be linked. Nothing about the change itself has been revised, and the description is carried over verbatim. The discussion and reviews on this PR stay readable here; please continue on #3298. |
Stack
Each PR is based on the one above it, so every diff here is just its own delta.
Closes #1051
When users specify a geometry center, it shifts the locations of the sources relative to the chunk pattern (as expected). One bug that was fixed long ago, was when sources were accidentally placed on both chunks after a shift. Another issue (which is resolved here) is when a source shifts, but not all of it is properly shifted due to the way meep handles "ownership."
More specifically, when a zero-thickness source lies on a chunk boundary, Meep must interpolate it onto grid points on both sides. Previously, each chunk clipped that interpolation to its locally owned grid points. With a shifted simulation center, this could omit part of the source or store it on the wrong chunk, making results depend on the chunk layout.
The fix computes the complete source interpolation first, then moves each resulting source sample to the chunk that owns the corresponding field update. This makes source deposition independent of domain decomposition.