Skip to content

Commit

Permalink
Merge pull request #12 from Shreyas-Ekanathan/upstream
Browse files Browse the repository at this point in the history
Upstream
  • Loading branch information
Shreyas-Ekanathan authored Aug 22, 2024
2 parents 6df8b72 + b609a4d commit 51d2012
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 2 deletions.
15 changes: 15 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,22 @@ Logging = "1.9"
MacroTools = "0.5"
MuladdMacro = "0.2.1"
NonlinearSolve = "3"
OrdinaryDiffEqAdamsBashforthMoulton = "1"
OrdinaryDiffEqCore = "1"
OrdinaryDiffEqDifferentiation = "1"
OrdinaryDiffEqExtrapolation = "1"
OrdinaryDiffEqFeagin = "1"
OrdinaryDiffEqFunctionMap = "1"
OrdinaryDiffEqLowOrderRK = "1"
OrdinaryDiffEqLowStorageRK = "1"
OrdinaryDiffEqHighOrderRK = "1"
OrdinaryDiffEqNonlinearSolve = "1"
OrdinaryDiffEqPRK = "1"
OrdinaryDiffEqQPRK = "1"
OrdinaryDiffEqRKN = "1"
OrdinaryDiffEqStabilizedRK = "1"
OrdinaryDiffEqTsit5 = "1"
OrdinaryDiffEqVerner = "1"
Polyester = "0.7"
PreallocationTools = "0.4"
PrecompileTools = "1"
Expand Down
2 changes: 1 addition & 1 deletion lib/OrdinaryDiffEqCore/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "OrdinaryDiffEqCore"
uuid = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
authors = ["ParamThakkar123 <[email protected]>"]
version = "1.1.0"
version = "1.2.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
26 changes: 26 additions & 0 deletions lib/OrdinaryDiffEqCore/src/interp_func.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,29 @@ function InterpolationData(id::InterpolationData, f)
id.differential_vars,
id.sensitivitymode)
end

# strip interpolation of function information
function SciMLBase.strip_interpolation(id::InterpolationData)

cache = strip_cache(id.cache)

InterpolationData(nothing, id.timeseries,
id.ts,
id.ks,
id.alg_choice,
id.dense,
cache,
id.differential_vars,
id.sensitivitymode)
end

function strip_cache(cache)
if hasfield(typeof(cache), :jac_config) || hasfield(typeof(cache), :grad_config)
fieldnums = length(fieldnames(typeof(cache)))
noth_list = fill(nothing,fieldnums)
cache_type_name = Base.typename(typeof(cache)).wrapper
cache_type_name(noth_list...)
else
cache
end
end
2 changes: 1 addition & 1 deletion src/OrdinaryDiffEq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import OrdinaryDiffEqCore: trivial_limiter!, CompositeAlgorithm, alg_order,
_change_t_via_interpolation!, ODEIntegrator, _ode_interpolant!,
current_interpolant, resize_nlsolver!, _ode_interpolant,
handle_tstop!, _postamble!, update_uprev!, resize_J_W!,
DAEAlgorithm, get_fsalfirstlast
DAEAlgorithm, get_fsalfirstlast, strip_cache, strip_interpolation

export CompositeAlgorithm, ShampineCollocationInit, BrownFullBasicInit, NoInit
AutoSwitch
Expand Down
17 changes: 17 additions & 0 deletions test/interface/ode_strip_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using OrdinaryDiffEq, Test
import SciMLBase

function lorenz!(du, u, p, t)
du[1] = 10.0 * (u[2] - u[1])
du[2] = u[1] * (28.0 - u[3]) - u[2]
du[3] = u[1] * u[2] - (8 / 3) * u[3]
end

u0 = [1.0; 0.0; 0.0]
tspan = (0.0, 0.5)
prob = ODEProblem(lorenz!, u0, tspan)

sol = solve(prob, Rosenbrock23())

@test isnothing(SciMLBase.strip_interpolation(sol.interp).f)
@test isnothing(SciMLBase.strip_interpolation(sol.interp).cache.jac_config)
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ end
@time @safetestset "Inplace Interpolation Tests" include("interface/inplace_interpolation.jl")
@time @safetestset "Algebraic Interpolation Tests" include("interface/algebraic_interpolation.jl")
@time @safetestset "Default Solver Tests" include("interface/default_solver_tests.jl")
@time @safetestset "Interpolation and Cache Stripping Tests" include("interface/ode_strip_test.jl")
end

if !is_APPVEYOR && (GROUP == "All" || GROUP == "InterfaceII" || GROUP == "Interface")
Expand Down

0 comments on commit 51d2012

Please sign in to comment.