diff --git a/src/solutions/ode_solutions.jl b/src/solutions/ode_solutions.jl index 7e2f04c418..069a3ca182 100644 --- a/src/solutions/ode_solutions.jl +++ b/src/solutions/ode_solutions.jl @@ -189,16 +189,6 @@ function BVPSolution{T, N}(u, u_analytic, errors, t, k, prob, alg, interp, dense original_nlsolve) end -function BVPSolution(sol::ODESolution{T, N}; resid = nothing, retcode = sol.retcode, - original::Union{Nothing, AbstractNonlinearSolution} = nothing) where {T, N} - if original !== nothing && resid === nothing && hasfield(typeof(original), :resid) - resid = original.resid - end - return BVPSolution{T, N}(sol.u, sol.u_analytic, sol.errors, sol.t, sol.k, sol.prob, - sol.alg, sol.interp, sol.dense, sol.tslocation, sol.stats, sol.alg_choice, - retcode, resid, sol, original) -end - Base.@propagate_inbounds function Base.getproperty(x::AbstractODESolution, s::Symbol) if s === :destats Base.depwarn("`sol.destats` is deprecated. Use `sol.stats` instead.", "sol.destats") @@ -278,6 +268,22 @@ function (sol::AbstractODESolution)(t::AbstractVector{<:Number}, ::Type{deriv}, return DiffEqArray([[interp_sol[idx][i] for idx in idxs] for i in 1:length(t)], t, p, sol) end +function build_solution(prob::BVProblem, ivpsol::AbstractODESolution{T, N}, + nlsol::Union{Nothing, AbstractNonlinearSolution}; retcode = nothing) where {T, N} + if retcode === nothing + if nlsol === nothing + retcode = ivpsol.retcode + else + retcode = ifelse(successful_retcode(nlsol.retcode), ivpsol.retcode, + nlsol.retcode) + end + end + return BVPSolution{T, N}(ivpsol.u, ivpsol.u_analytic, ivpsol.errors, ivpsol.t, + ivpsol.k, prob, ivpsol.alg, ivpsol.interp, ivpsol.dense, ivpsol.tslocation, + ivpsol.stats, ivpsol.alg_choice, retcode, nlsol === nothing ? nothing : nlsol.resid, + ivpsol, nlsol) +end + function build_solution(prob::Union{AbstractODEProblem, AbstractDDEProblem}, alg, t, u; timeseries_errors = length(u) > 2, dense = false, dense_errors = dense,