Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add post stage callback #190

Closed
wants to merge 4 commits into from
Closed

Add post stage callback #190

wants to merge 4 commits into from

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Aug 25, 2023

This PR:

  • Renames dss! to apply_filter!, being that this function will be used to call dss! and (potentially) applying boundary conditions.
  • Adds post_stage_callback!, which is called after apply_filter! and is also called inside solve_newton! to ensure that post_stage_callback! is called between newton iterations.

Closes #193.

@@ -144,6 +146,9 @@ function step_u!(integrator, cache::IMEXSSPRKCache)
T_exp!(T_exp, U, p, t_exp)
end
end
dss!(p, U_imp, t_imp) # mutate state (e.g., dss! + BCs)
Copy link
Member Author

Choose a reason for hiding this comment

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

@dennisYatunin, should we be dss-ing the implicit part in the imex ssprk?

Copy link
Member

Choose a reason for hiding this comment

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

No, we should not add another dss call here. For both IMEX-ARK and IMEX-SSPRK, we only need the two dss calls outlined in the docs: one when computing the residual for the implicit solve on each stage, and another at the end of the timestep.

Copy link
Member

Choose a reason for hiding this comment

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

In both cases, dss! can be replaced with a generic filter!, since the reasoning given here is not specific to dss.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I've called it apply_filter! (to avoid name collisions with Base.filter!), does that sound okay? We could alternatively adopt OrdinaryDiffEq's name affect!

@simonbyrne
Copy link
Member

For the ARK ones, it would probably make sense to have post_explicit_stage! and post_implicit_stage!. Not sure how it would work for the SSPRK ones.

@charleskawczynski
Copy link
Member Author

For the ARK ones, it would probably make sense to have post_explicit_stage! and post_implicit_stage!. Not sure how it would work for the SSPRK ones.

I did that originally, but we also need to call it in solve_newton!(alg::NewtonsMethod, ...), which one should we call there?

Comment on lines +121 to +124
(; post_explicit_stage_callback!) = prob.f
if !isnothing(post_explicit_stage_callback!)
post_explicit_stage_callback!(AlgMeta(:init), u0, p, t0)
end
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
(; post_explicit_stage_callback!) = prob.f
if !isnothing(post_explicit_stage_callback!)
post_explicit_stage_callback!(AlgMeta(:init), u0, p, t0)
end
pscb = prob.f.post_explicit_stage_callback!
isnothing(pscb) || pscb(AlgMeta(:init), u0, p, t0)

@charleskawczynski
Copy link
Member Author

Superseded by #210

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.

Add a callback after each stage
3 participants