@@ -64,7 +64,7 @@ struct RosenbrockCombinedConstantCache{TF, UF, Tab, JType, WType, F, AD} <:
6464 interp_order:: Int
6565end
6666
67- @cache mutable struct Rosenbrock23Cache {uType, rateType, uNoUnitsType, JType, WType,
67+ @cache mutable struct RosenbrockCombinedCache {uType, rateType, uNoUnitsType, JType, WType,
6868 TabType, TFType, UFType, F, JCType, GCType,
6969 RTolType, A, AV, StepLimiter, StageLimiter} <: RosenbrockMutableCache
7070 u:: uType
9797 stage_limiter!:: StageLimiter
9898end
9999
100- @cache mutable struct Rosenbrock32Cache{uType, rateType, uNoUnitsType, JType, WType,
101- TabType, TFType, UFType, F, JCType, GCType,
102- RTolType, A, AV, StepLimiter, StageLimiter} <: RosenbrockMutableCache
103- u:: uType
104- uprev:: uType
105- k₁:: rateType
106- k₂:: rateType
107- k₃:: rateType
108- du1:: rateType
109- du2:: rateType
110- f₁:: rateType
111- fsalfirst:: rateType
112- fsallast:: rateType
113- dT:: rateType
114- J:: JType
115- W:: WType
116- tmp:: rateType
117- atmp:: uNoUnitsType
118- weight:: uNoUnitsType
119- tab:: TabType
120- tf:: TFType
121- uf:: UFType
122- linsolve_tmp:: rateType
123- linsolve:: F
124- jac_config:: JCType
125- grad_config:: GCType
126- reltol:: RTolType
127- alg:: A
128- algebraic_vars:: AV
129- step_limiter!:: StepLimiter
130- stage_limiter!:: StageLimiter
131- end
132-
133- function get_fsalfirstlast (cache:: Union{Rosenbrock23Cache, Rosenbrock32Cache} , u)
134- (cache. fsalfirst, cache. fsallast)
135- end
136-
137- function alg_cache (alg:: Rosenbrock23 , u, rate_prototype, :: Type{uEltypeNoUnits} ,
100+ function alg_cache (alg:: Union{Rosenbrock23, Rosenbrock32} , u, rate_prototype, :: Type{uEltypeNoUnits} ,
138101 :: Type{uBottomEltypeNoUnits} , :: Type{tTypeNoUnits} , uprev, uprev2, f, t,
139102 dt, reltol, p, calck,
140103 :: Val{true} ) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
@@ -153,7 +116,7 @@ function alg_cache(alg::Rosenbrock23, u, rate_prototype, ::Type{uEltypeNoUnits},
153116 recursivefill! (atmp, false )
154117 weight = similar (u, uEltypeNoUnits)
155118 recursivefill! (weight, false )
156- tab = Rosenbrock23Tableau (constvalue (uBottomEltypeNoUnits))
119+ tab = RosenbrockCombinedTableau (constvalue (uBottomEltypeNoUnits))
157120 tf = TimeGradientWrapper (f, uprev, p)
158121 uf = UJacobianWrapper (f, t, p)
159122 linsolve_tmp = zero (rate_prototype)
@@ -176,61 +139,13 @@ function alg_cache(alg::Rosenbrock23, u, rate_prototype, ::Type{uEltypeNoUnits},
176139 algebraic_vars = f. mass_matrix === I ? nothing :
177140 [all (iszero, x) for x in eachcol (f. mass_matrix)]
178141
179- Rosenbrock23Cache (u, uprev, k₁, k₂, k₃, du1, du2, f₁,
142+ RosenbrockCombinedCache (u, uprev, k₁, k₂, k₃, du1, du2, f₁,
180143 fsalfirst, fsallast, dT, J, W, tmp, atmp, weight, tab, tf, uf,
181144 linsolve_tmp,
182145 linsolve, jac_config, grad_config, reltol, alg, algebraic_vars, alg. step_limiter!,
183146 alg. stage_limiter!)
184147end
185148
186- function alg_cache (alg:: Rosenbrock32 , u, rate_prototype, :: Type{uEltypeNoUnits} ,
187- :: Type{uBottomEltypeNoUnits} , :: Type{tTypeNoUnits} , uprev, uprev2, f, t,
188- dt, reltol, p, calck,
189- :: Val{true} ) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
190- k₁ = zero (rate_prototype)
191- k₂ = zero (rate_prototype)
192- k₃ = zero (rate_prototype)
193- du1 = zero (rate_prototype)
194- du2 = zero (rate_prototype)
195- # f₀ = zero(u) fsalfirst
196- f₁ = zero (rate_prototype)
197- fsalfirst = zero (rate_prototype)
198- fsallast = zero (rate_prototype)
199- dT = zero (rate_prototype)
200- tmp = zero (rate_prototype)
201- atmp = similar (u, uEltypeNoUnits)
202- recursivefill! (atmp, false )
203- weight = similar (u, uEltypeNoUnits)
204- recursivefill! (weight, false )
205- tab = Rosenbrock32Tableau (constvalue (uBottomEltypeNoUnits))
206-
207- tf = TimeGradientWrapper (f, uprev, p)
208- uf = UJacobianWrapper (f, t, p)
209- linsolve_tmp = zero (rate_prototype)
210-
211- grad_config = build_grad_config (alg, f, tf, du1, t)
212- jac_config = build_jac_config (alg, f, uf, du1, uprev, u, tmp, du2)
213-
214- J, W = build_J_W (alg, u, uprev, p, t, dt, f, jac_config, uEltypeNoUnits, Val (true ))
215-
216- linprob = LinearProblem (W, _vec (linsolve_tmp); u0 = _vec (tmp))
217-
218- Pl, Pr = wrapprecs (
219- alg. precs (W, nothing , u, p, t, nothing , nothing , nothing ,
220- nothing )... , weight, tmp)
221- linsolve = init (
222- linprob, alg. linsolve, alias = LinearAliasSpecifier (alias_A = true , alias_b = true ),
223- Pl = Pl, Pr = Pr,
224- assumptions = LinearSolve. OperatorAssumptions (true ))
225-
226- algebraic_vars = f. mass_matrix === I ? nothing :
227- [all (iszero, x) for x in eachcol (f. mass_matrix)]
228-
229- Rosenbrock32Cache (u, uprev, k₁, k₂, k₃, du1, du2, f₁, fsalfirst, fsallast, dT, J, W,
230- tmp, atmp, weight, tab, tf, uf, linsolve_tmp, linsolve, jac_config,
231- grad_config, reltol, alg, algebraic_vars, alg. step_limiter!, alg. stage_limiter!)
232- end
233-
234149struct Rosenbrock23ConstantCache{T, TF, UF, JType, WType, F, AD} < :
235150 RosenbrockConstantCache
236151 c₃₂:: T
@@ -244,7 +159,7 @@ struct Rosenbrock23ConstantCache{T, TF, UF, JType, WType, F, AD} <:
244159end
245160
246161function Rosenbrock23ConstantCache (:: Type{T} , tf, uf, J, W, linsolve, autodiff) where {T}
247- tab = Rosenbrock23Tableau (T)
162+ tab = RosenbrockCombinedTableau (T)
248163 Rosenbrock23ConstantCache (tab. c₃₂, tab. d, tf, uf, J, W, linsolve, autodiff)
249164end
250165
@@ -274,7 +189,7 @@ struct Rosenbrock32ConstantCache{T, TF, UF, JType, WType, F, AD} <:
274189end
275190
276191function Rosenbrock32ConstantCache (:: Type{T} , tf, uf, J, W, linsolve, autodiff) where {T}
277- tab = Rosenbrock32Tableau (T)
192+ tab = RosenbrockCombinedTableau (T)
278193 Rosenbrock32ConstantCache (tab. c₃₂, tab. d, tf, uf, J, W, linsolve, autodiff)
279194end
280195
@@ -837,7 +752,8 @@ function alg_cache(
837752end
838753
839754function get_fsalfirstlast (
840- cache:: Union {RosenbrockCache,
755+ cache:: Union {RosenbrockCombinedCache, Rosenbrock33Cache,
756+ Rosenbrock34Cache,
841757 Rosenbrock4Cache},
842758 u)
843759 (cache. fsalfirst, cache. fsallast)
0 commit comments