Skip to content

Commit b5e2a0d

Browse files
committed
save du and k for DAEs when dense==true
1 parent 18fc6d1 commit b5e2a0d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

Diff for: src/integrators/integrator_utils.jl

+12-5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ function _savevalues!(integrator, force_save, reduce_size)::Tuple{Bool, Bool}
102102
[k[integrator.opts.save_idxs] for k in integrator.k],
103103
false)
104104
end
105+
if integrator.prob isa DAEProblem
106+
if integrator.opts.save_idxs === nothing
107+
copyat_or_push!(integrator.sol.du, integrator.saveiter, integrator.du)
108+
else
109+
copyat_or_push!(integrator.sol.du, integrator.saveiter,
110+
integrator.du[integrator.opts.save_idxs], false)
111+
end
112+
end
105113
end
106114
end
107115
if integrator.alg isa OrdinaryDiffEqCompositeAlgorithm
@@ -346,6 +354,7 @@ function handle_callbacks!(integrator)
346354
discrete_modified, saved_in_cb = DiffEqBase.apply_discrete_callback!(integrator,
347355
discrete_callbacks...)
348356
end
357+
349358
if !saved_in_cb
350359
savevalues!(integrator)
351360
end
@@ -482,12 +491,10 @@ function handle_tstop!(integrator)
482491
end
483492

484493
function reset_fsal!(integrator)
485-
# Under these conditions, these algorithms are not FSAL anymore
494+
# call this when the conditions for FSAL are no longer true (e.g. u_modified)
486495
integrator.stats.nf += 1
487496

488-
if integrator.sol.prob isa DAEProblem
489-
DiffEqBase.initialize_dae!(integrator)
490-
else
497+
if integrator.sol.prob isa ODEProblem
491498
if integrator.cache isa OrdinaryDiffEqMutableCache ||
492499
(integrator.cache isa CompositeCache &&
493500
integrator.cache.caches[1] isa OrdinaryDiffEqMutableCache)
@@ -496,7 +503,7 @@ function reset_fsal!(integrator)
496503
integrator.fsalfirst = integrator.f(integrator.u, integrator.p, integrator.t)
497504
end
498505
end
499-
# Do not set false here so it can be checked in the algorithm
506+
# Do not set reeval_fsal false here so it can be checked in the algorithm
500507
# integrator.reeval_fsal = false
501508
end
502509

Diff for: src/solve.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function DiffEqBase.__init(prob::Union{DiffEqBase.AbstractODEProblem,
2525
save_end = nothing,
2626
callback = nothing,
2727
dense = save_everystep &&
28-
!(alg isa Union{DAEAlgorithm, FunctionMap}) &&
28+
!(alg isa FunctionMap) &&
2929
isempty(saveat),
3030
calck = (callback !== nothing && callback !== CallbackSet()) ||
3131
(dense) || !isempty(saveat), # and no dense output

0 commit comments

Comments
 (0)