Skip to content

Commit

Permalink
fix ODEs
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Aug 7, 2024
1 parent 3563ead commit a456104
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ end

function Base.setproperty!(cache::LinearCache, name::Symbol, x)
if name === :A
if hasproperty(cache.alg, :precs)
if hasproperty(cache.alg, :precs) && !isnothing(cache.alg.precs)
Pl, Pr = cache.alg.precs(x, cache.p)
setfield!(cache, :Pl, Pl)
setfield!(cache, :Pr, Pr)
end
setfield!(cache, :isfresh, true)
elseif name === :p
if hasproperty(cache.alg, :precs)
if hasproperty(cache.alg, :precs) && !isnothing(cache.alg.precs)
Pl, Pr = cache.alg.precs(cache.A, x)
setfield!(cache, :Pl, Pl)
setfield!(cache, :Pr, Pr)
Expand Down Expand Up @@ -180,7 +180,11 @@ function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm,
reltol = real(eltype(prob.b))(reltol)
abstol = real(eltype(prob.b))(abstol)

precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS
precs = if hasproperty(alg, :precs)
isnothing(alg.precs) ? DEFAULT_PRECS : alg.precs
else
DEFAULT_PRECS
end
_Pl, _Pr = precs(A, p)
if isnothing(Pl)
Pl = _Pl
Expand Down Expand Up @@ -215,7 +219,7 @@ function SciMLBase.reinit!(cache::LinearCache;
reinit_cache = false,)
(; alg, cacheval, abstol, reltol, maxiters, verbose, assumptions, sensealg) = cache

precs = hasproperty(alg, :precs) ? alg.precs : DEFAULT_PRECS
precs = (hasproperty(alg, :precs) && !isnothing(alg.precs)) ? alg.precs : DEFAULT_PRECS
Pl, Pr = if isnothing(A) || isnothing(p)
if isnothing(A)
A = cache.A
Expand Down
2 changes: 1 addition & 1 deletion src/iterative_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end

function KrylovJL(args...; KrylovAlg = Krylov.gmres!,
gmres_restart = 0, window = 0,
precs = DEFAULT_PRECS,
precs = nothing,
kwargs...)
return KrylovJL(KrylovAlg, gmres_restart, window,
precs, args, kwargs)
Expand Down

0 comments on commit a456104

Please sign in to comment.