Skip to content

[2/n][Adjoint Module] Fix source deposition across chunk boundaries - #3290

Closed
smartalecH wants to merge 1 commit into
NanoComp:fix/adjoint-adjacent-material-gridsfrom
smartalecH:fix/source-boundary-deposition
Closed

[2/n][Adjoint Module] Fix source deposition across chunk boundaries#3290
smartalecH wants to merge 1 commit into
NanoComp:fix/adjoint-adjacent-material-gridsfrom
smartalecH:fix/source-boundary-deposition

Conversation

@smartalecH

@smartalecH smartalecH commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Stack

Each PR is based on the one above it, so every diff here is just its own delta.

PR
1 #3277 Fix MaterialGrid design-variable attribution (#1984)
2 #3290 Fix source deposition across chunk boundaries ← you are here
3 #3292 Fix adjoint source weighting on a symmetry plane (#3291)
4 #3280 Enable proper JAX support in the adjoint module
5 #3281 Differentiable angular-spectrum propagation
6 #3283 Adjoint gradients w.r.t. source amplitudes
7 #3284 Launch a mode through a stratified stack
8 #3285 Adjoint gradients w.r.t. geometry (centre and size)
9 #3286 Register a material grid's susceptibilities
10 #3287 Evaluate the dispersive adjoint at the discrete lineshape
11 #3293 Subpixel-smooth dispersive materials and their shape derivative
12 #3294 Scalable Pade extrapolation for DFT monitors (#3217)
13 #3295 3D grating coupler example: fiber, grating and mirror

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.

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.
@smartalecH
smartalecH changed the base branch from master to fix/adjoint-adjacent-material-grids September 2, 2026 18:23
@smartalecH
smartalecH force-pushed the fix/source-boundary-deposition branch from 064dd07 to 14e3910 Compare September 2, 2026 18:23
@smartalecH

Copy link
Copy Markdown
Collaborator Author

@lxvm can you try this out?

@lxvm

lxvm commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Sure! Is there an issue I can reference to understand what this should fix?

@smartalecH

Copy link
Copy Markdown
Collaborator Author

@lxvm this should resolve the issue you were referencing in #3264 (i.e. the value of your objective function depends on the chunk layout)

@lxvm

lxvm commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@smartalecH this pr fixes the consistency in my simulations w.r.t. MPI parallelization when I use geometry_center. Many thanks!

@smartalecH
smartalecH marked this pull request as ready for review September 2, 2026 21:53
@smartalecH
smartalecH requested a review from stevengj September 2, 2026 21:53
@smartalecH

Copy link
Copy Markdown
Collaborator Author

@stevengj note that I stacked this on #3277 (to make it easier for Lorenzo to run the full patch suite) so if we approve, we need to merge that one first and rebase here.

@smartalecH

Copy link
Copy Markdown
Collaborator Author

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.

@smartalecH smartalecH closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants