Skip to content

Commit 6245eb0

Browse files
Merge pull request #56 from tkf/set_ut
Implement set_{u,t,ut}! for SDEIntegrator
2 parents f1bbe68 + 227b041 commit 6245eb0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
julia 0.6.0
22
Parameters 0.5.0
3-
DiffEqBase 3.0.0
3+
DiffEqBase 3.8.0
44
RecursiveArrayTools 0.13.0
55
DataStructures 0.4.6
66
Juno 0.2.5

src/integrators/integrator_interface.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,28 @@ end
332332
@inline function DiffEqBase.get_du!(out,integrator::SDEIntegrator)
333333
@. out = (integrator.u - integrator.uprev) / integrator.dt
334334
end
335+
336+
function DiffEqBase.set_t!(integrator::SDEIntegrator, t::Real)
337+
if integrator.opts.save_everystep
338+
error("Integrator time cannot be reset unless it is initialized",
339+
" with save_everystep=false")
340+
end
341+
if !isdtchangeable(integrator.alg)
342+
reinit!(integrator, integrator.u;
343+
t0 = t,
344+
reset_dt = false,
345+
reinit_callbacks = false,
346+
reinit_cache = false)
347+
else
348+
integrator.t = t
349+
end
350+
end
351+
352+
function DiffEqBase.set_u!(integrator::SDEIntegrator, u)
353+
if integrator.opts.save_everystep
354+
error("Integrator state cannot be reset unless it is initialized",
355+
" with save_everystep=false")
356+
end
357+
integrator.u = u
358+
u_modified!(integrator, true)
359+
end

0 commit comments

Comments
 (0)