|
82 | 82 | DEFAULT_PRECS(W, du, u, p, t, newW, Plprev, Prprev, cachedata) = nothing, nothing
|
83 | 83 |
|
84 | 84 | function dolinsolve(precs::P, linsolve; A = nothing, linu = nothing, b = nothing,
|
85 |
| - du = nothing, u = nothing, p = nothing, t = nothing, weight = nothing, |
86 |
| - cachedata = nothing, reltol = nothing) where {P} |
87 |
| - A !== nothing && (linsolve.A = A) |
| 85 | + du = nothing, p = nothing, weight = nothing, cachedata = nothing, reltol = nothing, |
| 86 | + reuse_A_if_factorization = false) where {P} |
| 87 | + # Some Algorithms would reuse factorization but it causes the cache to not reset in |
| 88 | + # certain cases |
| 89 | + if A !== nothing |
| 90 | + alg = linsolve.alg |
| 91 | + if (alg isa LinearSolve.AbstractFactorization) || |
| 92 | + (alg isa LinearSolve.DefaultLinearSolver && !(alg == |
| 93 | + LinearSolve.DefaultLinearSolver(LinearSolve.DefaultAlgorithmChoice.KrylovJL_GMRES))) |
| 94 | + # Factorization Algorithm |
| 95 | + !reuse_A_if_factorization && (linsolve.A = A) |
| 96 | + else |
| 97 | + linsolve.A = A |
| 98 | + end |
| 99 | + end |
88 | 100 | b !== nothing && (linsolve.b = b)
|
89 | 101 | linu !== nothing && (linsolve.u = linu)
|
90 | 102 |
|
91 | 103 | Plprev = linsolve.Pl isa ComposePreconditioner ? linsolve.Pl.outer : linsolve.Pl
|
92 | 104 | Prprev = linsolve.Pr isa ComposePreconditioner ? linsolve.Pr.outer : linsolve.Pr
|
93 | 105 |
|
94 |
| - _Pl, _Pr = precs(linsolve.A, du, u, p, nothing, A !== nothing, Plprev, Prprev, |
| 106 | + _Pl, _Pr = precs(linsolve.A, du, linu, p, nothing, A !== nothing, Plprev, Prprev, |
95 | 107 | cachedata)
|
96 | 108 | if (_Pl !== nothing || _Pr !== nothing)
|
97 | 109 | _weight = weight === nothing ?
|
|
0 commit comments