From 321238baec7df9c6abce188fd68a9ee86f9819e3 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Mon, 3 Apr 2023 22:10:12 -0400 Subject: [PATCH 1/2] Add subsolutions Ref #901 --- src/ensemble/ensemble_solutions.jl | 4 +++- src/problems/problem_utils.jl | 2 +- src/solutions/ode_solutions.jl | 13 +++++++++---- src/solutions/pde_solutions.jl | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/ensemble/ensemble_solutions.jl b/src/ensemble/ensemble_solutions.jl index c1cd3a647..d65d47921 100644 --- a/src/ensemble/ensemble_solutions.jl +++ b/src/ensemble/ensemble_solutions.jl @@ -44,7 +44,9 @@ function EnsembleSolution(sim::T, elapsedTime, typeof(sim)}(sim, elapsedTime, converged) end -Base.reverse(sim::EnsembleSolution) = EnsembleSolution(reverse(sim.u), sim.elapsedTime, sim.converged) +function Base.reverse(sim::EnsembleSolution) + EnsembleSolution(reverse(sim.u), sim.elapsedTime, sim.converged) +end """ $(TYPEDEF) diff --git a/src/problems/problem_utils.jl b/src/problems/problem_utils.jl index 0af4db388..a4fb47ef5 100644 --- a/src/problems/problem_utils.jl +++ b/src/problems/problem_utils.jl @@ -179,4 +179,4 @@ function Base.summary(io::IO, prob::AbstractPDEProblem) no_color) end -Base.copy(p::SciMLBase.NullParameters) = p \ No newline at end of file +Base.copy(p::SciMLBase.NullParameters) = p diff --git a/src/solutions/ode_solutions.jl b/src/solutions/ode_solutions.jl index aaa243120..994f96d1a 100644 --- a/src/solutions/ode_solutions.jl +++ b/src/solutions/ode_solutions.jl @@ -27,7 +27,7 @@ https://docs.sciml.ai/DiffEqDocs/stable/basics/solution/ [the return code documentation](https://docs.sciml.ai/SciMLBase/stable/interfaces/Solutions/#retcodes). """ struct ODESolution{T, N, uType, uType2, DType, tType, rateType, P, A, IType, S, - AC <: Union{Nothing, Vector{Int}}} <: + AC <: Union{Nothing, Vector{Int}}, SSS} <: AbstractODESolution{T, N, uType} u::uType u_analytic::uType2 @@ -42,6 +42,7 @@ struct ODESolution{T, N, uType, uType2, DType, tType, rateType, P, A, IType, S, stats::S alg_choice::AC retcode::ReturnCode.T + subsolutions::Union{SSS, Nothing} end Base.@propagate_inbounds function Base.getproperty(x::AbstractODESolution, s::Symbol) @@ -53,12 +54,16 @@ Base.@propagate_inbounds function Base.getproperty(x::AbstractODESolution, s::Sy end function ODESolution{T, N}(u, u_analytic, errors, t, k, prob, alg, interp, dense, - tslocation, stats, alg_choice, retcode) where {T, N} + tslocation, stats, alg_choice, retcode, + subsolutions = nothing) where {T, N} return ODESolution{T, N, typeof(u), typeof(u_analytic), typeof(errors), typeof(t), typeof(k), typeof(prob), typeof(alg), typeof(interp), typeof(stats), - typeof(alg_choice)}(u, u_analytic, errors, t, k, prob, alg, interp, - dense, tslocation, stats, alg_choice, retcode) + typeof(alg_choice), typeof(subsolutions)}(u, u_analytic, errors, t, + k, prob, alg, interp, + dense, tslocation, stats, + alg_choice, retcode, + subsolutions) end function (sol::AbstractODESolution)(t, ::Type{deriv} = Val{0}; idxs = nothing, diff --git a/src/solutions/pde_solutions.jl b/src/solutions/pde_solutions.jl index 4f3eb1fb7..cd45e2fc2 100644 --- a/src/solutions/pde_solutions.jl +++ b/src/solutions/pde_solutions.jl @@ -95,7 +95,7 @@ struct PDENoTimeSolution{T, N, uType, Disc, Sol, domType, ivType, dvType, P, A, retcode::ReturnCode.T stats::S end - + TruncatedStacktraces.@truncate_stacktrace PDENoTimeSolution 1 2 const PDESolution{T, N, S, D} = Union{PDETimeSeriesSolution{T, N, S, D}, From 7ba9fc8536f01cf9f76dbea89c9907feb701ffaf Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Fri, 26 May 2023 12:23:46 -0400 Subject: [PATCH 2/2] Update ode_solutions.jl --- src/solutions/ode_solutions.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solutions/ode_solutions.jl b/src/solutions/ode_solutions.jl index 994f96d1a..4d956f9ab 100644 --- a/src/solutions/ode_solutions.jl +++ b/src/solutions/ode_solutions.jl @@ -42,7 +42,7 @@ struct ODESolution{T, N, uType, uType2, DType, tType, rateType, P, A, IType, S, stats::S alg_choice::AC retcode::ReturnCode.T - subsolutions::Union{SSS, Nothing} + subsolutions::SSS end Base.@propagate_inbounds function Base.getproperty(x::AbstractODESolution, s::Symbol)