Skip to content

Commit

Permalink
Merge #131
Browse files Browse the repository at this point in the history
131: Rename cache method to init_cache r=charleskawczynski a=charleskawczynski

This PR renames the `cache` method to `init_cache`, peeled off from #26.

Co-authored-by: Charles Kawczynski <[email protected]>
  • Loading branch information
bors[bot] and charleskawczynski authored Dec 26, 2022
2 parents 1e0e996 + b6c1593 commit c15e85b
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion perf/benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function main()
for problem in (split_linear_prob_wfact_split(), split_linear_prob_wfact_split_fe())
integrator = DiffEqBase.init(problem, algorithm; dt)

cache = CTS.cache(problem, algorithm)
cache = CTS.init_cache(problem, algorithm)

CTS.step_u!(integrator, cache)

Expand Down
2 changes: 1 addition & 1 deletion perf/flame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
algorithm = CTS.IMEXARKAlgorithm(ARS343(), NewtonsMethod(; max_iters = 2))
dt = 0.01
integrator = DiffEqBase.init(prob, algorithm; dt)
cache = CTS.cache(prob, algorithm)
cache = CTS.init_cache(prob, algorithm)
do_work!(integrator, cache) # compile first
import Profile
Profile.clear_malloc_data()
Expand Down
2 changes: 1 addition & 1 deletion perf/jet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function config_integrators(problem)
algorithm = CTS.IMEXARKAlgorithm(ARS343(), NewtonsMethod(; max_iters = 2))
dt = 0.01
integrator = DiffEqBase.init(problem, algorithm; dt)
integrator.cache = CTS.cache(problem, algorithm)
integrator.cache = CTS.init_cache(problem, algorithm)
return (; integrator)
end
prob = if parsed_args["problem"] == "ode_fun"
Expand Down
2 changes: 1 addition & 1 deletion src/integrators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function DiffEqBase.__init(
callback,
advance_to_tstop,
false,
cache(prob, alg; dt, kwargs...),
init_cache(prob, alg; dt, kwargs...),
sol,
)
DiffEqBase.initialize!(callback, u0, t0, integrator)
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/ark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct AdditiveRungeKuttaFullCache{Nstages, RT, A, O, L}
end


function cache(
function init_cache(
prob::DiffEqBase.AbstractODEProblem{uType, tType, true},
alg::AdditiveRungeKutta;
dt,
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/imex_ark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct IMEXARKCache{SCU, SCE, SCI, T, Γ, NMC}
newtons_method_cache::NMC
end

function cache(prob::DiffEqBase.AbstractODEProblem, alg::IMEXARKAlgorithm; kwargs...)
function init_cache(prob::DiffEqBase.AbstractODEProblem, alg::IMEXARKAlgorithm; kwargs...)
(; u0, f) = prob
(; T_imp!) = f
(; tab, newtons_method) = alg
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/lsrk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct LowStorageRungeKutta2NIncCache{Nstages, RT, A}
du::A
end

function cache(prob::DiffEqBase.ODEProblem, alg::LowStorageRungeKutta2N; kwargs...)
function init_cache(prob::DiffEqBase.ODEProblem, alg::LowStorageRungeKutta2N; kwargs...)
# @assert prob.problem_type isa DiffEqBase.IncrementingODEProblem ||
# prob.f isa DiffEqBase.IncrementingODEFunction
du = zero(prob.u0)
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/mis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ end

nstages(::MultirateInfinitesimalStepCache{Nstages}) where {Nstages} = Nstages

function cache(
function init_cache(
prob::DiffEqBase.AbstractODEProblem{uType, tType, true},
alg::MultirateInfinitesimalStep;
kwargs...,
Expand Down
4 changes: 2 additions & 2 deletions src/solvers/multirate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ struct MultirateCache{OC, II}
innerinteg::II
end

function cache(prob::DiffEqBase.AbstractODEProblem, alg::Multirate; dt, fast_dt, kwargs...)
function init_cache(prob::DiffEqBase.AbstractODEProblem, alg::Multirate; dt, fast_dt, kwargs...)

@assert prob.f isa DiffEqBase.SplitFunction

# subproblems
outerprob = DiffEqBase.remake(prob; f = prob.f.f2)
outercache = cache(outerprob, alg.slow)
outercache = init_cache(outerprob, alg.slow)

innerfun = init_inner(prob, outercache, dt)
innerprob = DiffEqBase.remake(prob; f = innerfun)
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/rosenbrock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct RosenbrockCache{Nstages, RT, N², A}
linsolve!::Any
end

function cache(prob::DiffEqBase.AbstractODEProblem, alg::RosenbrockAlgorithm; kwargs...)
function init_cache(prob::DiffEqBase.AbstractODEProblem, alg::RosenbrockAlgorithm; kwargs...)

tab = tableau(alg, eltype(prob.u0))
Nstages = length(tab.m)
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/ssprk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct StrongStabilityPreservingRungeKuttaCache{Nstages, RT, A}
U::A
end

function cache(prob::DiffEqBase.AbstractODEProblem, alg::StrongStabilityPreservingRungeKutta; kwargs...)
function init_cache(prob::DiffEqBase.AbstractODEProblem, alg::StrongStabilityPreservingRungeKutta; kwargs...)

tab = tableau(alg, eltype(prob.u0))
# can't use Vector{T}(undef) as need to ensure no NaNs
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/wickerskamarock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct WickerSkamarockRungeKuttaCache{Nstages, RT, A}
U::A
F::A
end
function cache(prob::DiffEqBase.ODEProblem, alg::WickerSkamarockRungeKutta; kwargs...)
function init_cache(prob::DiffEqBase.ODEProblem, alg::WickerSkamarockRungeKutta; kwargs...)
U = similar(prob.u0)
F = similar(prob.u0)
return WickerSkamarockRungeKuttaCache(tableau(alg, eltype(F)), U, F)
Expand Down

0 comments on commit c15e85b

Please sign in to comment.