@@ -106,7 +106,18 @@ function LinearSolve.init_cacheval(
106106 history = IterativeSolvers. ConvergenceHistory (partial = true )
107107 history[:abstol ] = abstol
108108 history[:reltol ] = reltol
109- filter_kwargs (; idrs_s = 0 , kwargs... ) = kwargs
109+ # `idrs_iterable!` takes the tolerances and the iteration cap
110+ # positionally and accepts only `smoothing`/`verbose` as keywords, so
111+ # every name passed positionally below has to be dropped here. Filtering
112+ # `idrs_s` alone meant `IterativeSolversJL_IDRS(abstol = ...)` forwarded
113+ # `abstol` as a keyword too and failed with a `MethodError`
114+ # (SciML/LinearSolve.jl#24).
115+ function filter_kwargs (;
116+ idrs_s = 0 , abstol = nothing , reltol = nothing ,
117+ maxiter = nothing , kwargs...
118+ )
119+ return kwargs
120+ end
110121 IterativeSolvers. idrs_iterable! (
111122 history, u, A, b, s, Pl, abstol, reltol, maxiters;
112123 filter_kwargs (; alg. kwargs... )...
@@ -167,15 +178,22 @@ function SciMLBase.solve!(cache::LinearCache, alg::IterativeSolversJL; kwargs...
167178 # TODO inject callbacks KSP into solve! cb!(cache.cacheval)
168179 end
169180
170- resid = cache. cacheval isa IterativeSolvers. IDRSIterable ? cache. cacheval. R :
171- cache. cacheval. residual
181+ resid = _iterable_residual (cache. cacheval)
172182 if resid isa IterativeSolvers. Residual
173183 resid = resid. current
174184 end
175185
176186 return SciMLBase. build_linear_solution (alg, cache. u, resid, nothing ; iters = i)
177187end
178188
189+ # IterativeSolvers does not name this field consistently across its iterables.
190+ # Reading `.residual` unconditionally made `IterativeSolversJL_MINRES` throw a
191+ # `FieldError` on every solve, because `MINRESIterable` calls it `resnorm`
192+ # (SciML/LinearSolve.jl#24).
193+ _iterable_residual (iterable) = iterable. residual
194+ _iterable_residual (iterable:: IterativeSolvers.IDRSIterable ) = iterable. R
195+ _iterable_residual (iterable:: IterativeSolvers.MINRESIterable ) = iterable. resnorm
196+
179197purge_history! (iter, x, b) = nothing
180198function purge_history! (iter:: IterativeSolvers.GMRESIterable , x, b)
181199 iter. k = 1
0 commit comments