From 3fcbd2ae7bb5826386d8b5ce11e12a8d936221dc Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Thu, 15 Feb 2024 05:00:08 -0500 Subject: [PATCH] Update integrator_utils.jl --- src/integrators/integrator_utils.jl | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/integrators/integrator_utils.jl b/src/integrators/integrator_utils.jl index da24cfd77f..13acd65dcd 100644 --- a/src/integrators/integrator_utils.jl +++ b/src/integrators/integrator_utils.jl @@ -474,21 +474,24 @@ function handle_tstop!(integrator) return nothing end +handle_callback_modifiers!(integrator::ODEIntegrator) = nothing + function reset_fsal!(integrator) # Under these conditions, these algorithms are not FSAL anymore integrator.stats.nf += 1 - if integrator.sol.prob isa DAEProblem - DiffEqBase.initialize_dae!(integrator) + handle_callback_modifiers!(integrator) # Hook for DDEs to add discontinuities + + # Ignore DAEs but they already re-ran initialization + # Mass matrix DAEs do need to reset FSAL if available + if !(integrator.sol.prob isa DAEProblem) && (integrator.cache isa OrdinaryDiffEqMutableCache || + (integrator.cache isa CompositeCache && + integrator.cache.caches[1] isa OrdinaryDiffEqMutableCache) + integrator.f(integrator.fsalfirst, integrator.u, integrator.p, integrator.t)) else - if integrator.cache isa OrdinaryDiffEqMutableCache || - (integrator.cache isa CompositeCache && - integrator.cache.caches[1] isa OrdinaryDiffEqMutableCache) - integrator.f(integrator.fsalfirst, integrator.u, integrator.p, integrator.t) - else - integrator.fsalfirst = integrator.f(integrator.u, integrator.p, integrator.t) - end + integrator.fsalfirst = integrator.f(integrator.u, integrator.p, integrator.t) end + # Do not set false here so it can be checked in the algorithm # integrator.reeval_fsal = false end