Skip to content

Commit f081339

Browse files
committed
Remove local algo solution types
1 parent 973d041 commit f081339

File tree

3 files changed

+5
-36
lines changed

3 files changed

+5
-36
lines changed

src/scalar.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ end
5252
function SciMLBase.solve(prob::NonlinearProblem{<:Number, iip, <:Dual{T,V,P}}, alg::NewtonRaphson, args...; kwargs...) where {iip, T, V, P}
5353
sol, partials = scalar_nlsolve_ad(prob, alg, args...; kwargs...)
5454
return SciMLBase.build_solution(prob, alg, Dual{T,V,P}(sol.u, partials), sol.resid; retcode=sol.retcode)
55-
#return NewtonSolution(Dual{T,V,P}(sol.u, partials), sol.retcode, sol.resid)
55+
5656
end
5757
function SciMLBase.solve(prob::NonlinearProblem{<:Number, iip, <:AbstractArray{<:Dual{T,V,P}}}, alg::NewtonRaphson, args...; kwargs...) where {iip, T, V, P}
5858
sol, partials = scalar_nlsolve_ad(prob, alg, args...; kwargs...)
5959
return SciMLBase.build_solution(prob, alg, Dual{T,V,P}(sol.u, partials), sol.resid; retcode=sol.retcode)
60-
#return NewtonSolution(Dual{T,V,P}(sol.u, partials), sol.retcode, sol.resid)
6160
end
6261

6362
# avoid ambiguities

src/solve.jl

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ function SciMLBase.solve!(solver::AbstractImmutableNonlinearSolver)
6666
if solver.iter == solver.maxiters
6767
@set! solver.retcode = MAXITERS_EXCEED
6868
end
69-
sol = get_solution(solver)
70-
if typeof(sol) <: NewtonSolution
71-
SciMLBase.build_solution(solver.prob, solver.alg, getsolution(sol), sol.resid;retcode=Symbol(sol.retcode))
69+
if typeof(solver) <: NewtonImmutableSolver
70+
SciMLBase.build_solution(solver.prob, solver.alg, solver.u, solver.fu;retcode=Symbol(solver.retcode))
7271
else
73-
SciMLBase.build_solution(solver.prob, solver.alg, getsolution(sol),sol.resid;retcode=Symbol(sol.retcode),left = sol.left,right = sol.right)
72+
SciMLBase.build_solution(solver.prob, solver.alg, solver.left,solver.fl;retcode=Symbol(solver.retcode),left = solver.left,right = solver.right)
7473
end
7574
end
7675

@@ -99,20 +98,6 @@ function mic_check(solver::NewtonImmutableSolver)
9998
solver
10099
end
101100

102-
"""
103-
get_solution(solver::Union{BracketingImmutableSolver, BracketingSolver})
104-
get_solution(solver::Union{NewtonImmutableSolver, NewtonSolver})
105-
106-
Form solution object from solver types
107-
"""
108-
function get_solution(solver::BracketingImmutableSolver)
109-
return BracketingSolution(solver.left, solver.right, solver.retcode, solver.fl)
110-
end
111-
112-
function get_solution(solver::NewtonImmutableSolver)
113-
return NewtonSolution(solver.u, solver.retcode, solver.fu)
114-
end
115-
116101
"""
117102
reinit!(solver, prob)
118103

src/types.jl

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,9 @@ end
5050
# typeof(fu), typeof(p), typeof(internalnorm), typeof(tol), typeof(cache)}(iter, f, alg, u, fu, p, force_stop, maxiters, internalnorm, retcode, tol, cache)
5151
# end
5252

53-
struct BracketingSolution{uType,resType}
54-
left::uType
55-
right::uType
56-
retcode::Retcode
57-
resid::resType
58-
end
59-
60-
struct NewtonSolution{uType,resType}
61-
u::uType
62-
retcode::Retcode
63-
resid::resType
64-
end
6553

6654
function sync_residuals!(solver::BracketingImmutableSolver)
6755
@set! solver.fl = solver.f(solver.left, solver.p)
6856
@set! solver.fr = solver.f(solver.right, solver.p)
6957
solver
70-
end
71-
72-
getsolution(sol::NewtonSolution) = sol.u
73-
getsolution(sol::BracketingSolution) = sol.left
58+
end

0 commit comments

Comments
 (0)