Skip to content
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
11 changes: 10 additions & 1 deletion src/integrator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function DiffEqBase.reinit!(
u0 = integrator.sol.prob.u0;
t0 = integrator.sol.prob.tspan[1],
tf = integrator.sol.prob.tspan[2],
dt = isadaptive(integrator) ? nothing : integrator.dtcache,
erase_sol = false,
tstops = integrator._tstops,
saveat = integrator._saveat,
Expand All @@ -192,6 +193,9 @@ function DiffEqBase.reinit!(
integrator.uprev .= u0
integrator.t = t0
integrator.tprev = t0
if dt !== nothing
integrator.dt = dt
end
integrator.tstops, integrator.saveat = tstops_and_saveat_heaps(t0, tf, tstops, saveat)
integrator.iter = 0
if erase_sol
Expand All @@ -214,7 +218,7 @@ function DiffEqBase.reinit!(
u0,
1:length(u0),
integrator.subintegrator_tree;
t0, tf,
t0, tf, dt,
erase_sol,
tstops,
saveat,
Expand All @@ -228,8 +232,13 @@ function subreinit!(
u0,
solution_indices,
subintegrator::DiffEqBase.DEIntegrator;
dt,
kwargs...
)
# dt is not reset as expected in reinit!
if dt !== nothing
subintegrator.dt = dt
end
DiffEqBase.reinit!(subintegrator, u0[solution_indices]; kwargs...)
end

Expand Down
21 changes: 9 additions & 12 deletions test/operator_splitting_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ end
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)

DiffEqBase.reinit!(integrator)
DiffEqBase.reinit!(integrator; dt = dt)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Default
for (u, t) in DiffEqBase.TimeChoiceIterator(integrator, tspan[1]:5.0:tspan[2])
end
Expand All @@ -176,7 +176,7 @@ end
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)

DiffEqBase.reinit!(integrator)
DiffEqBase.reinit!(integrator; dt = dt)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Default
for (uprev, tprev, u, t) in DiffEqBase.intervals(integrator)
end
Expand All @@ -187,7 +187,7 @@ end
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)

DiffEqBase.reinit!(integrator)
DiffEqBase.reinit!(integrator; dt = dt)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Default
DiffEqBase.solve!(integrator)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Success
Expand Down Expand Up @@ -218,8 +218,7 @@ end
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)

DiffEqBase.reinit!(integrator)
integrator.dt = dt
DiffEqBase.reinit!(integrator; dt = dt)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Default
for (u, t) in DiffEqBase.TimeChoiceIterator(integrator, tspan[1]:5.0:tspan[2])
end
Expand All @@ -228,10 +227,9 @@ end
@test integrator.subintegrator_tree[1].t ≈ tspan[2]
@test integrator.dtcache ≈ dt
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)+1 # We need one extra step after reinit for some reason...
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)

DiffEqBase.reinit!(integrator)
integrator.dt = dt
DiffEqBase.reinit!(integrator; dt = dt)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Default
for (uprev, tprev, u, t) in DiffEqBase.intervals(integrator)
end
Expand All @@ -240,18 +238,17 @@ end
@test integrator.subintegrator_tree[1].t ≈ tspan[2]
@test integrator.dtcache ≈ dt
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)+1
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)

DiffEqBase.reinit!(integrator)
integrator.dt = dt
DiffEqBase.reinit!(integrator; dt = dt)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Default
DiffEqBase.solve!(integrator)
@test integrator.sol.retcode == DiffEqBase.ReturnCode.Success
@test integrator.t ≈ tspan[2]
@test integrator.subintegrator_tree[1].t ≈ tspan[2]
@test integrator.dtcache ≈ dt
@test integrator.iter == ceil(Int, (tspan[2]-tspan[1])/dt)
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)+1
@test integrator.subintegrator_tree[1].iter == ceil(Int, (tspan[2]-tspan[1])/dt)
end
end

Expand Down
Loading