Skip to content

Fix reset of saveiter_dense in reinit! #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DelayDiffEq"
uuid = "bcd4f6db-9728-5f36-b5f7-82caef46ccdb"
authors = ["Chris Rackauckas <accounts@chrisrackauckas.com>"]
version = "5.29.2"
version = "5.29.3"

[deps]
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Expand Down
4 changes: 4 additions & 0 deletions src/integrators/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ function DiffEqBase.reinit!(integrator::HistoryODEIntegrator, u0 = integrator.so

# reset iteration counter
integrator.saveiter = 1
integrator.saveiter_dense = 1
end

nothing
Expand Down Expand Up @@ -387,6 +388,9 @@ function DiffEqBase.reinit!(integrator::DDEIntegrator, u0 = integrator.sol.prob.

# reset iteration counter
integrator.saveiter = resize_start
if integrator.opts.dense
integrator.saveiter_dense = resize_start
end

# erase array of tracked discontinuities
if order_discontinuity_t0 ≤ OrdinaryDiffEq.alg_maximum_order(integrator.alg)
Expand Down
20 changes: 20 additions & 0 deletions test/integrators/reinit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,24 @@ const alg = MethodOfSteps(BS3(); constrained = false)
@test u == sol.u
@test t == sol.t
end

# https://github.com/SciML/OrdinaryDiffEq.jl/issues/1394
@testset "saveiter_dense" begin
integrator = init(prob, alg)
solve!(integrator)

# ensure that the counters were updated
for i in (integrator, integrator.integrator)
@test i.saveiter > 1
@test i.saveiter_dense > 1
end

reinit!(integrator)

# check that the counters are reset
for i in (integrator, integrator.integrator)
@test i.saveiter == 1
@test i.saveiter_dense == 1
end
end
end