Skip to content

Commit 4119a8e

Browse files
committed
handle build_solution in solve.jl
1 parent 254ce8b commit 4119a8e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/solve.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ function SciMLBase.solve(prob::NonlinearProblem,
33
kwargs...)
44
solver = init(prob, alg, args...; kwargs...)
55
sol = solve!(solver)
6-
if typeof(sol) <: NewtonSolution
7-
SciMLBase.build_solution(prob, alg, getsolution(sol), sol.resid;retcode=Symbol(sol.retcode))
8-
else
9-
SciMLBase.build_solution(prob, alg, get_solution(sol),sol.resid;retcode=Symbol(sol.retcode),left = sol.left,right = sol.right)
10-
end
116
end
127

138
function SciMLBase.init(prob::NonlinearProblem{uType, iip}, alg::AbstractBracketingAlgorithm, args...;
@@ -34,7 +29,7 @@ function SciMLBase.init(prob::NonlinearProblem{uType, iip}, alg::AbstractBracket
3429
fl = f(left, p)
3530
fr = f(right, p)
3631
cache = alg_cache(alg, left, right,p, Val(iip))
37-
return BracketingImmutableSolver(1, f, alg, left, right, fl, fr, p, false, maxiters, DEFAULT, cache, iip)
32+
return BracketingImmutableSolver(1, f, alg, left, right, fl, fr, p, false, maxiters, DEFAULT, cache, iip,prob)
3833
end
3934

4035
function SciMLBase.init(prob::NonlinearProblem{uType, iip}, alg::AbstractNewtonAlgorithm, args...;
@@ -59,7 +54,7 @@ function SciMLBase.init(prob::NonlinearProblem{uType, iip}, alg::AbstractNewtonA
5954
fu = f(u, p)
6055
end
6156
cache = alg_cache(alg, f, u, p, Val(iip))
62-
return NewtonImmutableSolver(1, f, alg, u, fu, p, false, maxiters, internalnorm, DEFAULT, tol, cache, iip)
57+
return NewtonImmutableSolver(1, f, alg, u, fu, p, false, maxiters, internalnorm, DEFAULT, tol, cache, iip, prob)
6358
end
6459

6560
function SciMLBase.solve!(solver::AbstractImmutableNonlinearSolver)
@@ -72,7 +67,11 @@ function SciMLBase.solve!(solver::AbstractImmutableNonlinearSolver)
7267
@set! solver.retcode = MAXITERS_EXCEED
7368
end
7469
sol = get_solution(solver)
75-
return sol
70+
if typeof(sol) <: NewtonSolution
71+
SciMLBase.build_solution(solver.prob, solver.alg, getsolution(sol), sol.resid;retcode=Symbol(sol.retcode))
72+
else
73+
SciMLBase.build_solution(solver.prob, solver.alg, getsolution(sol),sol.resid;retcode=Symbol(sol.retcode),left = sol.left,right = sol.right)
74+
end
7675
end
7776

7877
"""

0 commit comments

Comments
 (0)