Skip to content

Commit 80b7b2b

Browse files
author
Oscar Smith
authored
fix
1 parent 0e8c353 commit 80b7b2b

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/internal/linear_solve.jl

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ function LinearSolverCache(alg, linsolve, A, b, u; stats, kwargs...)
8080
@bb u_ = copy(u_fixed)
8181
linprob = LinearProblem(A, b; u0 = u_, kwargs...)
8282

83-
weight = __init_ones(u_fixed)
8483
if __hasfield(alg, Val(:precs))
8584
precs = alg.precs
8685
Pl_, Pr_ = precs(A, nothing, u, ntuple(Returns(nothing), 6)...)
8786
else
8887
precs, Pl_, Pr_ = nothing, nothing, nothing
8988
end
90-
Pl, Pr = __wrapprecs(Pl_, Pr_, weight)
89+
Pl, Pr = __wrapprecs(Pl_, Pr_, u)
9190

9291
# Unalias here, we will later use these as caches
9392
lincache = init(linprob, linsolve; alias_A = false, alias_b = false, Pl, Pr)
@@ -128,10 +127,8 @@ function (cache::LinearSolverCache)(;
128127
b !== nothing && (cache.lincache.b = b)
129128
linu !== nothing && __set_lincache_u!(cache, linu)
130129

131-
Plprev = cache.lincache.Pl isa ComposePreconditioner ? cache.lincache.Pl.outer :
132-
cache.lincache.Pl
133-
Prprev = cache.lincache.Pr isa ComposePreconditioner ? cache.lincache.Pr.outer :
134-
cache.lincache.Pr
130+
Plprev = cache.lincache.Pl
131+
Prprev = cache.lincache.Pr
135132

136133
if cache.precs === nothing
137134
_Pl, _Pr = nothing, nothing
@@ -141,10 +138,7 @@ function (cache::LinearSolverCache)(;
141138
end
142139

143140
if (_Pl !== nothing || _Pr !== nothing)
144-
_weight = weight === nothing ?
145-
(cache.lincache.Pr isa Diagonal ? cache.lincache.Pr.diag :
146-
cache.lincache.Pr.inner.diag) : weight
147-
Pl, Pr = __wrapprecs(_Pl, _Pr, _weight)
141+
Pl, Pr = __wrapprecs(_Pl, _Pr, linu)
148142
cache.lincache.Pl = Pl
149143
cache.lincache.Pr = Pr
150144
end
@@ -242,9 +236,9 @@ function __set_lincache_A(lincache, new_A)
242236
end
243237
end
244238

245-
function __wrapprecs(_Pl, _Pr, weight)
246-
Pl = _Pl !== nothing ?= _Pl : IdentityOperator(length(weight))
247-
Pr = _Pr !== nothing ? _Pr : IdentityOperator(length(weight))
239+
function __wrapprecs(_Pl, _Pr, u)
240+
Pl = _Pl !== nothing ?= _Pl : IdentityOperator(length(u))
241+
Pr = _Pr !== nothing ? _Pr : IdentityOperator(length(u))
248242
return Pl, Pr
249243
end
250244

0 commit comments

Comments
 (0)