diff --git a/src/callbacks_step/save_solution.jl b/src/callbacks_step/save_solution.jl index 31fe0e87c77..0092360cb20 100644 --- a/src/callbacks_step/save_solution.jl +++ b/src/callbacks_step/save_solution.jl @@ -211,11 +211,11 @@ end get_element_variables!(element_variables, u_ode, semi) callbacks = integrator.opts.callback if callbacks isa CallbackSet - for cb in callbacks.continuous_callbacks + foreach(callbacks.continuous_callbacks) do cb get_element_variables!(element_variables, u_ode, semi, cb; t = integrator.t, iter = iter) end - for cb in callbacks.discrete_callbacks + foreach(callbacks.discrete_callbacks) do cb get_element_variables!(element_variables, u_ode, semi, cb; t = integrator.t, iter = iter) end diff --git a/src/callbacks_step/summary.jl b/src/callbacks_step/summary.jl index 26981a58b73..566f2c03418 100644 --- a/src/callbacks_step/summary.jl +++ b/src/callbacks_step/summary.jl @@ -168,16 +168,17 @@ function initialize_summary_callback(cb::DiscreteCallback, u, t, integrator; callbacks = integrator.opts.callback if callbacks isa CallbackSet - for cb in callbacks.continuous_callbacks + foreach(callbacks.continuous_callbacks) do cb show(io_context, MIME"text/plain"(), cb) println(io, "\n") end - for cb in callbacks.discrete_callbacks + foreach(callbacks.discrete_callbacks) do cb # Do not show ourselves - cb.affect! === summary_callback && continue + cb.affect! === summary_callback && return nothing show(io_context, MIME"text/plain"(), cb) println(io, "\n") + return nothing end else show(io_context, MIME"text/plain"(), callbacks) diff --git a/src/time_integration/methods_2N.jl b/src/time_integration/methods_2N.jl index 557e8272128..d2f22679c4f 100644 --- a/src/time_integration/methods_2N.jl +++ b/src/time_integration/methods_2N.jl @@ -119,10 +119,10 @@ function solve(ode::ODEProblem, alg::T; # initialize callbacks if callback isa CallbackSet - for cb in callback.continuous_callbacks + foreach(callback.continuous_callbacks) do cb error("unsupported") end - for cb in callback.discrete_callbacks + foreach(callback.discrete_callbacks) do cb cb.initialize(cb, integrator.u, integrator.t, integrator) end elseif !isnothing(callback) @@ -172,10 +172,11 @@ function solve!(integrator::SimpleIntegrator2N) # handle callbacks if callbacks isa CallbackSet - for cb in callbacks.discrete_callbacks + foreach(callbacks.discrete_callbacks) do cb if cb.condition(integrator.u, integrator.t, integrator) cb.affect!(integrator) end + return nothing end end diff --git a/src/time_integration/methods_3Sstar.jl b/src/time_integration/methods_3Sstar.jl index 03232c04122..b0ce5930514 100644 --- a/src/time_integration/methods_3Sstar.jl +++ b/src/time_integration/methods_3Sstar.jl @@ -189,10 +189,10 @@ function solve(ode::ODEProblem, alg::T; # initialize callbacks if callback isa CallbackSet - for cb in callback.continuous_callbacks + foreach(callback.continuous_callbacks) do cb error("unsupported") end - for cb in callback.discrete_callbacks + foreach(callback.discrete_callbacks) do cb cb.initialize(cb, integrator.u, integrator.t, integrator) end elseif !isnothing(callback) @@ -248,10 +248,11 @@ function solve!(integrator::SimpleIntegrator3Sstar) # handle callbacks if callbacks isa CallbackSet - for cb in callbacks.discrete_callbacks + foreach(callbacks.discrete_callbacks) do cb if cb.condition(integrator.u, integrator.t, integrator) cb.affect!(integrator) end + return nothing end end diff --git a/src/time_integration/methods_SSP.jl b/src/time_integration/methods_SSP.jl index 5b72682d48e..6424dde7d31 100644 --- a/src/time_integration/methods_SSP.jl +++ b/src/time_integration/methods_SSP.jl @@ -124,10 +124,10 @@ function solve(ode::ODEProblem, alg = SimpleSSPRK33()::SimpleAlgorithmSSP; # initialize callbacks if callback isa CallbackSet - for cb in callback.continuous_callbacks + foreach(callback.continuous_callbacks) do cb error("unsupported") end - for cb in callback.discrete_callbacks + foreach(callback.discrete_callbacks) do cb cb.initialize(cb, integrator.u, integrator.t, integrator) end elseif !isnothing(callback) @@ -184,7 +184,7 @@ function solve!(integrator::SimpleIntegratorSSP) # handle callbacks if callbacks isa CallbackSet - for cb in callbacks.discrete_callbacks + foreach(callbacks.discrete_callbacks) do cb if cb.condition(integrator.u, integrator.t, integrator) cb.affect!(integrator) end