Add callback/event support for operator splitting integrator (Fixes #36)#46
Open
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:mainfrom
Open
Add callback/event support for operator splitting integrator (Fixes #36)#46ChrisRackauckas-Claude wants to merge 1 commit intoSciML:mainfrom
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:mainfrom
Conversation
This implements callback support for OperatorSplittingIntegrator, addressing issue SciML#36. Key changes: - Add savevalues! function to save solution values during callback execution - Add handle_callbacks! function to process callbacks after each step - Add apply_discrete_callback! for full discrete callback support - Add apply_continuous_callback_simple! for simplified continuous callbacks (endpoint-only checking without full root-finding) - Modify __step! to call handle_callbacks! after advancing the solution - Implement proper u_modified! to track when callbacks modify the solution - Add comprehensive test suite for callback functionality Design decisions: - Callbacks are handled at the outer integrator level only, after all subproblems are solved for a timestep. This ensures callbacks have access to the full solution state. - Continuous callbacks use simplified endpoint checking rather than full root-finding, as root-finding across split subproblems is not well-defined for operator splitting methods. - When u is modified by a callback, it is propagated to uprev so the next step starts correctly. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements callback and event support for
OperatorSplittingIntegrator, addressing issue #36.u_modified!tracking for solution modificationssavevalues!function for callback-triggered savesDesign Decisions
As discussed in issue #36, there are two main challenges for callbacks in operator splitting:
Which integrator triggers which callback: We handle callbacks ONLY at the outer integrator level, AFTER all subproblems are solved for a timestep. This ensures callbacks have access to the full solution state.
Visibility of unknowns: By processing callbacks at the outer integrator level, callbacks can see the full solution
u, not just partial views that individual subintegrators work with.For continuous callbacks, full root-finding across split subproblems is not well-defined, so we use simplified endpoint checking (detect sign changes between
tprevandt). Users requiring precise event timing should use smaller timesteps or ensure their callback conditions align with the timestep boundaries.Test plan
u- modification propagates correctlysave_positions- saves work correctlyu_modified!functionality - flag is properly set/clearedAll tests pass locally.
cc @ChrisRackauckas
🤖 Generated with Claude Code