Skip to content

Commit 553ac2e

Browse files
reset u0
1 parent 9dbd20e commit 553ac2e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/iterative_wrappers.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function init_cacheval(alg::IterativeSolversJL, A, b, u, Pl, Pr, maxiters, absto
201201
end
202202

203203
function SciMLBase.solve(cache::LinearCache, alg::IterativeSolversJL; kwargs...)
204-
if cache.isfresh
204+
if cache.isfresh || !(alg <: IterativeSolvers.GMRESIterable)
205205
solver = init_cacheval(alg, cache.A, cache.b, cache.u, cache.Pl, cache.Pr, cache.maxiters, cache.abstol, cache.reltol, cache.verbose)
206206
cache = set_cacheval(cache, solver)
207207
end
@@ -217,6 +217,7 @@ function SciMLBase.solve(cache::LinearCache, alg::IterativeSolversJL; kwargs...)
217217
return SciMLBase.build_linear_solution(alg,cache.u,nothing,cache)
218218
end
219219

220+
purge_history!(iter, x, b) = nothing
220221
function purge_history!(iter::IterativeSolvers.GMRESIterable, x, b)
221222
iter.k = 1
222223
iter.x = x

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ function test_interface(alg, prob1, prob2)
1616
A1 = prob1.A; b1 = prob1.b; x1 = prob1.u0
1717
A2 = prob2.A; b2 = prob2.b; x2 = prob2.u0
1818

19+
x1 .= false
1920
y = solve(prob1, alg; cache_kwargs...)
2021
@test A1 * y b1
2122

2223
cache = SciMLBase.init(prob1,alg; cache_kwargs...) # initialize cache
24+
cache.u .= false
2325
y = solve(cache)
2426
@test A1 * y b1
2527

2628
cache = LinearSolve.set_A(cache,copy(A2))
29+
cache.u .= false
2730
y = solve(cache)
2831
@test A2 * y b1
2932

3033
cache = LinearSolve.set_b(cache,b2)
34+
cache.u .= false
3135
y = solve(cache)
3236
@test A2 * y b2
3337

0 commit comments

Comments
 (0)