@@ -105,6 +105,11 @@ function LinearSolverCache(alg, linsolve, A, b, u; kwargs...)
105105 return LinearSolverCache (lincache, linsolve, nothing , nothing , nothing , precs, 0 , 0 )
106106end
107107
108+ @kwdef @concrete struct LinearSolveResult
109+ u
110+ success:: Bool = true
111+ end
112+
108113# Direct Linear Solve Case without Caching
109114function (cache:: LinearSolverCache{Nothing} )(;
110115 A = nothing , b = nothing , linu = nothing , kwargs... )
@@ -119,7 +124,7 @@ function (cache::LinearSolverCache{Nothing})(;
119124 else
120125 res = cache. A \ cache. b
121126 end
122- return res
127+ return LinearSolveResult (; u = res)
123128end
124129
125130# Use LinearSolve.jl
@@ -154,11 +159,7 @@ function (cache::LinearSolverCache)(;
154159 cache. lincache. Pr = Pr
155160 end
156161
157- # display(A)
158-
159162 linres = solve! (cache. lincache)
160- # @show cache.lincache.cacheval
161- # @show LinearAlgebra.issuccess(cache.lincache.cacheval)
162163 cache. lincache = linres. cache
163164 # Unfortunately LinearSolve.jl doesn't have the most uniform ReturnCode handling
164165 if linres. retcode === ReturnCode. Failure
@@ -185,11 +186,14 @@ function (cache::LinearSolverCache)(;
185186 end
186187 linres = solve! (cache. additional_lincache)
187188 cache. additional_lincache = linres. cache
188- return linres. u
189+ linres. retcode === ReturnCode. Failure &&
190+ return LinearSolveResult (; u = linres. u, success = false )
191+ return LinearSolveResult (; u = linres. u)
189192 end
193+ return LinearSolveResult (; u = linres. u, success = false )
190194 end
191195
192- return linres. u
196+ return LinearSolveResult (; u = linres. u)
193197end
194198
195199@inline __update_A! (cache:: LinearSolverCache , :: Nothing , reuse) = cache
0 commit comments