Skip to content

Commit 95e6109

Browse files
Merge pull request #342 from CliMA/tr/fix-prob-remake
Remake problem manually during multirate init
2 parents 0c57a2f + d2540eb commit 95e6109

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/solvers/multirate.jl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,32 @@ struct MultirateCache{OC, II}
2424
innerinteg::II
2525
end
2626

27+
"""
28+
cts_remake(prob::DiffEqBase.AbstractODEProblem; f::DiffEqBase.AbstractODEFunction)
29+
30+
Remake an ODE problem with a new function `f`.
31+
"""
32+
function cts_remake(prob::DiffEqBase.AbstractODEProblem; f::DiffEqBase.AbstractODEFunction)
33+
return DiffEqBase.ODEProblem{DiffEqBase.isinplace(prob)}(
34+
f,
35+
prob.u0,
36+
prob.tspan,
37+
prob.p,
38+
prob.problem_type;
39+
prob.kwargs...,
40+
)
41+
end
42+
2743
function init_cache(prob::DiffEqBase.AbstractODEProblem, alg::Multirate; dt, fast_dt, kwargs...)
2844

2945
@assert prob.f isa DiffEqBase.SplitFunction
3046

3147
# subproblems
32-
outerprob = DiffEqBase.remake(prob; f = prob.f.f2)
48+
outerprob = cts_remake(prob; f = prob.f.f1)
3349
outercache = init_cache(outerprob, alg.slow)
3450

3551
innerfun = init_inner(prob, outercache, dt)
36-
innerprob = DiffEqBase.remake(prob; f = innerfun)
52+
innerprob = cts_remake(prob; f = innerfun)
3753
innerinteg = DiffEqBase.init(innerprob, alg.fast; dt = fast_dt, kwargs...)
3854
return MultirateCache(outercache, innerinteg)
3955
end

0 commit comments

Comments
 (0)