From b3671bab7251623d585655726ab87c04ffc9a61c Mon Sep 17 00:00:00 2001 From: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Date: Wed, 29 May 2024 11:13:05 +0200 Subject: [PATCH] remove unnecessary part in callback condition (#53) --- src/callbacks_step/alive.jl | 3 +-- src/callbacks_step/save_solution.jl | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/callbacks_step/alive.jl b/src/callbacks_step/alive.jl index f963de69..64462b23 100644 --- a/src/callbacks_step/alive.jl +++ b/src/callbacks_step/alive.jl @@ -85,8 +85,7 @@ function (alive_callback::AliveCallback)(u, t, integrator) # (total #steps) (#accepted steps) # We need to check the number of accepted steps since callbacks are not # activated after a rejected step. - return interval_or_dt > 0 && (((integrator.stats.naccept % interval_or_dt == 0) && - !(integrator.stats.naccept == 0 && integrator.iter > 0))) + return interval_or_dt > 0 && (integrator.stats.naccept % interval_or_dt == 0) end # this method is called when the callback is activated diff --git a/src/callbacks_step/save_solution.jl b/src/callbacks_step/save_solution.jl index 51d81194..a0bdba24 100644 --- a/src/callbacks_step/save_solution.jl +++ b/src/callbacks_step/save_solution.jl @@ -116,8 +116,7 @@ function (solution_callback::SaveSolutionCallback)(u, t, integrator) # (total #steps) (#accepted steps) # We need to check the number of accepted steps since callbacks are not # activated after a rejected step. - return interval_or_dt > 0 && (((integrator.stats.naccept % interval_or_dt == 0) && - !(integrator.stats.naccept == 0 && integrator.iter > 0)) || + return interval_or_dt > 0 && (integrator.stats.naccept % interval_or_dt == 0 || (save_final_solution && isfinished(integrator))) end