Skip to content

Commit

Permalink
Merge pull request #334 from SciML/gmres_retcode
Browse files Browse the repository at this point in the history
Setup retcode for Krylov.jl
  • Loading branch information
ChrisRackauckas authored Jun 18, 2023
2 parents 5426cdd + b9c3d2f commit c0bed7b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/iterative_wrappers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,18 @@ function SciMLBase.solve!(cache::LinearCache, alg::KrylovJL; kwargs...)
stats = @get_cacheval(cache, :KrylovJL_GMRES).stats
resid = stats.residuals |> last

retcode = if !stats.solved
if stats.status == "maximum number of iterations exceeded"
ReturnCode.MaxIters
elseif stats.status == "solution good enough given atol and rtol"
ReturnCode.ConvergenceFailure
else
ReturnCode.Failure
end
else
ReturnCode.Success
end

return SciMLBase.build_linear_solution(alg, cache.u, resid, cache;
iters = stats.niter)
end

0 comments on commit c0bed7b

Please sign in to comment.