Skip to content

Commit b641412

Browse files
committed
address code revioew
1 parent f494526 commit b641412

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

Diff for: src/integrators/integrator_utils.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,20 @@ 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.alg isa DAEAlgorithm
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
113105
end
114106
end
115107
if integrator.alg isa OrdinaryDiffEqCompositeAlgorithm
116108
copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter,
117109
integrator.cache.current)
118110
end
111+
if integrator.opts.save_du
112+
if integrator.opts.save_idxs === nothing
113+
copyat_or_push!(integrator.sol.du, integrator.saveiter, integrator(integrator.t, Val{1}))
114+
else
115+
copyat_or_push!(integrator.sol.du, integrator.saveiter,
116+
integrator(integrator.t, Val{1}, idxs=integrator.opts.save_idxs), false)
117+
end
118+
end
119119
end
120120
end
121121
if force_save || (integrator.opts.save_everystep &&
@@ -142,20 +142,20 @@ function _savevalues!(integrator, force_save, reduce_size)::Tuple{Bool, Bool}
142142
[k[integrator.opts.save_idxs] for k in integrator.k],
143143
false)
144144
end
145-
if integrator.alg isa DAEAlgorithm
146-
if integrator.opts.save_idxs === nothing
147-
copyat_or_push!(integrator.sol.du, integrator.saveiter, integrator.du)
148-
else
149-
copyat_or_push!(integrator.sol.du, integrator.saveiter,
150-
integrator.du[integrator.opts.save_idxs], false)
151-
end
152-
end
153145
end
154146
end
155147
if integrator.alg isa OrdinaryDiffEqCompositeAlgorithm
156148
copyat_or_push!(integrator.sol.alg_choice, integrator.saveiter,
157149
integrator.cache.current)
158150
end
151+
if integrator.opts.save_du
152+
if integrator.opts.save_idxs === nothing
153+
copyat_or_push!(integrator.sol.du, integrator.saveiter, integrator(integrator.t, Val{1}))
154+
else
155+
copyat_or_push!(integrator.sol.du, integrator.saveiter,
156+
integrator(integrator.t, Val{1}, idxs=integrator.opts.save_idxs), false)
157+
end
158+
end
159159
end
160160
reduce_size && resize!(integrator.k, integrator.kshortsize)
161161
return saved, savedexactly

Diff for: src/integrators/type.jl

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ mutable struct DEOptions{absType, relType, QT, tType, Controller, F1, F2, F3, F4
4646
force_dtmin::Bool
4747
advance_to_tstop::Bool
4848
stop_at_next_tstop::Bool
49+
save_du::Bool
4950
end
5051

5152
TruncatedStacktraces.@truncate_stacktrace DEOptions

Diff for: src/solve.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function DiffEqBase.__init(prob::Union{DiffEqBase.AbstractODEProblem,
7070
alias_u0 = false,
7171
alias_du0 = false,
7272
initializealg = DefaultInit(),
73+
save_du = false,
7374
kwargs...) where {recompile_flag}
7475
if prob isa DiffEqBase.AbstractDAEProblem && alg isa OrdinaryDiffEqAlgorithm
7576
error("You cannot use an ODE Algorithm with a DAEProblem")
@@ -407,7 +408,8 @@ function DiffEqBase.__init(prob::Union{DiffEqBase.AbstractODEProblem,
407408
unstable_check,
408409
verbose, calck, force_dtmin,
409410
advance_to_tstop,
410-
stop_at_next_tstop)
411+
stop_at_next_tstop,
412+
save_du)
411413

412414
stats = SciMLBase.DEStats(0)
413415
differential_vars = prob isa DAEProblem ? prob.differential_vars : get_differential_vars(f, u)

0 commit comments

Comments
 (0)