Skip to content

Commit 2c87e5c

Browse files
committed
handle case where u is nothing
1 parent 13258f5 commit 2c87e5c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/ImplicitDiscreteSolve/src/cache.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mutable struct ImplicitDiscreteState{uType, pType, tType}
2-
u::Vector{uType}
2+
u::uType
33
p::pType
44
t_next::tType
55
end
@@ -16,7 +16,7 @@ function alg_cache(alg::SimpleIDSolve, u, rate_prototype, ::Type{uEltypeNoUnits}
1616
dt, reltol, p, calck,
1717
::Val{true}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
1818

19-
state = ImplicitDiscreteState(similar(u), p, t)
19+
state = ImplicitDiscreteState(isnothing(u) ? nothing : similar(u), p, t)
2020
SimpleIDSolveCache(u, uprev, state, nothing)
2121
end
2222

@@ -31,7 +31,7 @@ function alg_cache(alg::SimpleIDSolve, u, rate_prototype, ::Type{uEltypeNoUnits}
3131
dt, reltol, p, calck,
3232
::Val{false}) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
3333

34-
state = ImplicitDiscreteState(similar(u), p, t)
34+
state = ImplicitDiscreteState(isnothing(u) ? nothing : similar(u), p, t)
3535
SimpleIDSolveCache(u, uprev, state, nothing)
3636
end
3737

lib/ImplicitDiscreteSolve/src/solve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function perform_step!(integrator, cache::SimpleIDSolveCache, repeat_step = fals
1212
end
1313

1414
function initialize!(integrator, cache::SimpleIDSolveCache)
15-
cache.state.u .= integrator.u
15+
integrator.u isa AbstractVector && (cache.state.u .= integrator.u)
1616
cache.state.p = integrator.p
1717
cache.state.t_next = integrator.t
1818
f = integrator.f

0 commit comments

Comments
 (0)