3939get_fsalfirstlast (cache:: ExplicitTaylor2Cache , u) = (cache. k1, cache. k1)
4040
4141@cache struct ExplicitTaylorCache{
42- P, uType, taylorType, uNoUnitsType, StageLimiter, StepLimiter,
42+ P, tType, uType, taylorType, uNoUnitsType, StageLimiter, StepLimiter,
4343 Thread} <: OrdinaryDiffEqMutableCache
4444 order:: Val{P}
45- jet:: Function
45+ jet:: FunctionWrapper{Nothing, Tuple{taylorType, uType, tType}}
4646 u:: uType
4747 uprev:: uType
4848 utaylor:: taylorType
@@ -54,45 +54,49 @@ get_fsalfirstlast(cache::ExplicitTaylor2Cache, u) = (cache.k1, cache.k1)
5454 thread:: Thread
5555end
5656
57- function alg_cache (alg:: ExplicitTaylor , u, rate_prototype, :: Type{uEltypeNoUnits} ,
57+ function alg_cache (alg:: ExplicitTaylor{P} , u, rate_prototype, :: Type{uEltypeNoUnits} ,
5858 :: Type{uBottomEltypeNoUnits} , :: Type{tTypeNoUnits} , uprev, uprev2, f, t,
5959 dt, reltol, p, calck,
60- :: Val{true} ) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
61- _, jet_iip = build_jet (f, p, alg . order , length (u))
60+ :: Val{true} ) where {P, uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
61+ _, jet_iip = build_jet (f, p, P , length (u))
6262 utaylor = TaylorDiff. make_seed (u, zero (u), alg. order)
63+ jet_wrapped = FunctionWrapper {Nothing, Tuple{typeof(utaylor), typeof(u), typeof(t)}} (jet_iip)
6364 utilde = zero (u)
6465 atmp = similar (u, uEltypeNoUnits)
6566 recursivefill! (atmp, false )
6667 tmp = zero (u)
67- ExplicitTaylorCache (alg. order, jet_iip , u, uprev, utaylor, utilde, tmp, atmp,
68+ ExplicitTaylorCache (alg. order, jet_wrapped , u, uprev, utaylor, utilde, tmp, atmp,
6869 alg. stage_limiter!, alg. step_limiter!, alg. thread)
6970end
7071
7172get_fsalfirstlast (cache:: ExplicitTaylorCache , u) = (cache. u, cache. u)
7273
73- struct ExplicitTaylorConstantCache{P} <: OrdinaryDiffEqConstantCache
74+ struct ExplicitTaylorConstantCache{P, taylorType, uType, tType} < :
75+ OrdinaryDiffEqConstantCache
7476 order:: Val{P}
75- jet:: Function
77+ jet:: FunctionWrapper{taylorType, Tuple{uType, tType}}
7678end
77- function alg_cache (:: ExplicitTaylor{P} , u, rate_prototype, :: Type{uEltypeNoUnits} ,
79+ function alg_cache (alg :: ExplicitTaylor{P} , u, rate_prototype, :: Type{uEltypeNoUnits} ,
7880 :: Type{uBottomEltypeNoUnits} , :: Type{tTypeNoUnits} , uprev, uprev2, f, t,
7981 dt, reltol, p, calck,
8082 :: Val{false} ) where {P, uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
8183 if u isa AbstractArray
82- jet, _ = build_jet (f, p, Val (P) , length (u))
84+ jet, _ = build_jet (f, p, P , length (u))
8385 else
84- jet = build_jet (f, p, Val (P) )
86+ jet = build_jet (f, p, P )
8587 end
86- ExplicitTaylorConstantCache (Val (P), jet)
88+ utaylor = TaylorDiff. make_seed (u, zero (u), alg. order) # not used, but needed for type
89+ jet_wrapped = FunctionWrapper {typeof(utaylor), Tuple{typeof(u), typeof(t)}} (jet)
90+ ExplicitTaylorConstantCache (alg. order, jet_wrapped)
8791end
8892
89- @cache struct ExplicitTaylorAdaptiveOrderCache{
90- uType, taylorType, uNoUnitsType, StageLimiter, StepLimiter,
93+ @cache struct ExplicitTaylorAdaptiveOrderCache{P, Q,
94+ tType, uType, taylorType, uNoUnitsType, StageLimiter, StepLimiter,
9195 Thread} <: OrdinaryDiffEqMutableCache
92- min_order:: Int
93- max_order:: Int
94- current_order:: Ref {Int}
95- jets:: Vector{Function }
96+ min_order:: Val{P}
97+ max_order:: Val{Q}
98+ current_order:: Base.RefValue {Int}
99+ jets:: Vector{FunctionWrapper{Nothing, Tuple{taylorType, uType, tType}} }
96100 u:: uType
97101 uprev:: uType
98102 utaylor:: taylorType
@@ -108,45 +112,51 @@ function alg_cache(
108112 :: Type{uBottomEltypeNoUnits} , :: Type{tTypeNoUnits} , uprev, uprev2, f, t,
109113 dt, reltol, p, calck,
110114 :: Val{true} ) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
111- jets = Function[]
112- for order in (alg. min_order): (alg. max_order)
113- _, jet_iip = build_jet (f, p, Val (order), length (u))
115+ utaylor = TaylorDiff. make_seed (u, zero (u), alg. max_order)
116+ jets = FunctionWrapper{Nothing, Tuple{typeof (utaylor), typeof (u), typeof (t)}}[]
117+ min_order_value = get_value (alg. min_order)
118+ max_order_value = get_value (alg. max_order)
119+ for order in min_order_value: max_order_value
120+ jet_iip = build_jet (f, p, order, length (u))[2 ]
114121 push! (jets, jet_iip)
115122 end
116- utaylor = TaylorDiff. make_seed (u, zero (u), Val (alg. max_order))
117123 utilde = zero (u)
118124 atmp = similar (u, uEltypeNoUnits)
119125 recursivefill! (atmp, false )
120126 tmp = zero (u)
121- current_order = Ref {Int} (alg . min_order )
127+ current_order = Ref (min_order_value )
122128 ExplicitTaylorAdaptiveOrderCache (alg. min_order, alg. max_order, current_order,
123129 jets, u, uprev, utaylor, utilde, tmp, atmp,
124130 alg. stage_limiter!, alg. step_limiter!, alg. thread)
125131end
126132
127133get_fsalfirstlast (cache:: ExplicitTaylorAdaptiveOrderCache , u) = (cache. u, cache. u)
128134
129- struct ExplicitTaylorAdaptiveOrderConstantCache <: OrdinaryDiffEqConstantCache
130- min_order:: Int
131- max_order:: Int
132- current_order:: Ref{Int}
133- jets:: Vector{Function}
135+ struct ExplicitTaylorAdaptiveOrderConstantCache{P, Q, taylorType, uType, tType} < :
136+ OrdinaryDiffEqConstantCache
137+ min_order:: Val{P}
138+ max_order:: Val{Q}
139+ current_order:: Base.RefValue{Int}
140+ jets:: Vector{FunctionWrapper{taylorType, Tuple{uType, tType}}}
134141end
135142function alg_cache (
136143 alg:: ExplicitTaylorAdaptiveOrder , u, rate_prototype, :: Type{uEltypeNoUnits} ,
137144 :: Type{uBottomEltypeNoUnits} , :: Type{tTypeNoUnits} , uprev, uprev2, f, t,
138145 dt, reltol, p, calck,
139146 :: Val{false} ) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
140- jets = Function[]
141- for order in (alg. min_order): (alg. max_order)
147+ utaylor = TaylorDiff. make_seed (u, zero (u), alg. max_order) # not used, but needed for type
148+ jets = FunctionWrapper{typeof (utaylor), Tuple{typeof (u), typeof (t)}}[]
149+ min_order_value = get_value (alg. min_order)
150+ max_order_value = get_value (alg. max_order)
151+ for order in min_order_value: max_order_value
142152 if u isa AbstractArray
143- jet, _ = build_jet (f, p, Val ( order) , length (u))
153+ jet, _ = build_jet (f, p, order, length (u))
144154 else
145- jet = build_jet (f, p, Val ( order) )
155+ jet = build_jet (f, p, order)
146156 end
147157 push! (jets, jet)
148158 end
149- current_order = Ref {Int} (alg . min_order )
159+ current_order = Ref (min_order_value )
150160 ExplicitTaylorAdaptiveOrderConstantCache (
151161 alg. min_order, alg. max_order, current_order, jets)
152162end
0 commit comments