Skip to content

Commit a456104

Browse files
author
oscarddssmith
committed
fix ODEs
1 parent 3563ead commit a456104

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/common.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ end
8585

8686
function Base.setproperty!(cache::LinearCache, name::Symbol, x)
8787
if name === :A
88-
if hasproperty(cache.alg, :precs)
88+
if hasproperty(cache.alg, :precs) && !isnothing(cache.alg.precs)
8989
Pl, Pr = cache.alg.precs(x, cache.p)
9090
setfield!(cache, :Pl, Pl)
9191
setfield!(cache, :Pr, Pr)
9292
end
9393
setfield!(cache, :isfresh, true)
9494
elseif name === :p
95-
if hasproperty(cache.alg, :precs)
95+
if hasproperty(cache.alg, :precs) && !isnothing(cache.alg.precs)
9696
Pl, Pr = cache.alg.precs(cache.A, x)
9797
setfield!(cache, :Pl, Pl)
9898
setfield!(cache, :Pr, Pr)
@@ -180,7 +180,11 @@ function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm,
180180
reltol = real(eltype(prob.b))(reltol)
181181
abstol = real(eltype(prob.b))(abstol)
182182

183-
precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS
183+
precs = if hasproperty(alg, :precs)
184+
isnothing(alg.precs) ? DEFAULT_PRECS : alg.precs
185+
else
186+
DEFAULT_PRECS
187+
end
184188
_Pl, _Pr = precs(A, p)
185189
if isnothing(Pl)
186190
Pl = _Pl
@@ -215,7 +219,7 @@ function SciMLBase.reinit!(cache::LinearCache;
215219
reinit_cache = false,)
216220
(; alg, cacheval, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache
217221

218-
precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS
222+
precs = (hasproperty(alg, :precs) && !isnothing(alg.precs)) ? alg.precs : DEFAULT_PRECS
219223
Pl, Pr = if isnothing(A) || isnothing(p)
220224
if isnothing(A)
221225
A = cache.A

src/iterative_wrappers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ end
2121

2222
function KrylovJL(args...; KrylovAlg = Krylov.gmres!,
2323
gmres_restart = 0, window = 0,
24-
precs = DEFAULT_PRECS,
24+
precs = nothing,
2525
kwargs...)
2626
return KrylovJL(KrylovAlg, gmres_restart, window,
2727
precs, args, kwargs)

0 commit comments

Comments
 (0)