Skip to content

FFT: expose OpenBCSolver's spectral Green's function - #5627

Merged
ax3l merged 2 commits into
AMReX-Codes:developmentfrom
ax3l:topic-igf-greens-cache
Aug 28, 2026
Merged

FFT: expose OpenBCSolver's spectral Green's function#5627
ax3l merged 2 commits into
AMReX-Codes:developmentfrom
ax3l:topic-igf-greens-cache

Conversation

@ax3l

@ax3l ax3l commented Aug 19, 2026

Copy link
Copy Markdown
Member

OpenBCSolver rebuilds its spectral Green's function whenever setGreensFunction() is called, and there is no way to hand it one that was built earlier. Add greensFunctionFFT() accessors so a caller can keep its own set and move them into and out of the solver with std::swap rather than recomputing. solve() only reads the spectral Green's function, and prepare_openbc() concerns the R2C plans rather than the Green's function values, so one moved in this way needs no further preparation.

The one caveat, documented at the accessor: in 2D, m_G_fft is an alias of the Green's function R2C's spectral data, which a later setGreensFunction() writes into. Callers may write through the reference there, but must not swap or otherwise re-seat it.

Additive only, so nothing changes for existing users. Exercised downstream in BLAST-WarpX/warpx#7178 & BLAST-ImpactX/impactx#1621, where reusing Green's functions this way reproduces rebuilding them bit for bit, and where it takes an accelerating beam simulation from 100 Green's function builds to 10.

  • 🤖 Generated with Claude Code
  • tested with ABLASTR/WarpX and ImpactX
  • manually self-reviewed

Add greensFunctionFFT() accessors so a caller can keep its own set of
Green's functions and move them into and out of the solver, for instance
with std::swap, instead of recomputing them with setGreensFunction().

solve() only reads the spectral Green's function, and prepare_openbc()
concerns the R2C plans rather than the Green's function values, so one
moved in this way needs no further preparation.

Note that in two-d mode this is an alias of the Green's function R2C's
spectral data: callers may write through it, but must not swap or
otherwise re-seat it, because a later setGreensFunction() writes into
the aliased array.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@ax3l
ax3l force-pushed the topic-igf-greens-cache branch from dc9414f to 489c517 Compare August 27, 2026 22:02
@ax3l ax3l changed the title [WIP] FFT: expose OpenBCSolver's spectral Green's function FFT: expose OpenBCSolver's spectral Green's function Aug 28, 2026
Comment thread Src/FFT/AMReX_FFT_OpenBCSolver.H Outdated
@ax3l
ax3l enabled auto-merge (squash) August 28, 2026 16:53
@ax3l
ax3l merged commit f2cbba4 into AMReX-Codes:development Aug 28, 2026
75 checks passed
@ax3l
ax3l deleted the topic-igf-greens-cache branch August 28, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants