Skip to content

Commit c0bed7b

Browse files
Merge pull request #334 from SciML/gmres_retcode
Setup retcode for Krylov.jl
2 parents 5426cdd + b9c3d2f commit c0bed7b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/iterative_wrappers.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,18 @@ function SciMLBase.solve!(cache::LinearCache, alg::KrylovJL; kwargs...)
270270
stats = @get_cacheval(cache, :KrylovJL_GMRES).stats
271271
resid = stats.residuals |> last
272272

273+
retcode = if !stats.solved
274+
if stats.status == "maximum number of iterations exceeded"
275+
ReturnCode.MaxIters
276+
elseif stats.status == "solution good enough given atol and rtol"
277+
ReturnCode.ConvergenceFailure
278+
else
279+
ReturnCode.Failure
280+
end
281+
else
282+
ReturnCode.Success
283+
end
284+
273285
return SciMLBase.build_linear_solution(alg, cache.u, resid, cache;
274286
iters = stats.niter)
275287
end

0 commit comments

Comments
 (0)