@@ -4,7 +4,7 @@ abstract type AbstractLegacyController <: AbstractController end
44abstract type AbstractControllerCache end
55
66"""
7- setup_controller_cache(alg, controller::AbstractController)::AbstractControllerCache
7+ setup_controller_cache(alg, atmp, controller::AbstractController)::AbstractControllerCache
88
99This function takes a controller together with the time stepping algorithm to
1010construct and initialize the respective cache for the controller.
@@ -55,7 +55,7 @@ step_reject_controller!
5555
5656
5757# The legacy controllers do not have this concept.
58- setup_controller_cache (alg, controller:: AbstractLegacyController ) = controller
58+ setup_controller_cache (alg, atmp, controller:: AbstractLegacyController ) = controller
5959
6060# checks whether the controller should accept a step based on the error estimate
6161@inline function accept_step_controller (integrator, controller_or_cache:: Union{<:AbstractLegacyController, <:AbstractControllerCache} )
9999struct DummyController <: AbstractController
100100end
101101
102- setup_controller_cache (alg, controller:: DummyController ) = controller
102+ setup_controller_cache (alg, atmp, controller:: DummyController ) = controller
103103
104104@inline function accept_step_controller (integrator, controller:: DummyController )
105105 return integrator. EEst <= 1
@@ -191,19 +191,21 @@ function NewIController(QT, alg; qmin = nothing, qmax = nothing, gamma = nothing
191191 )
192192end
193193
194- mutable struct IControllerCache{C, T} <: AbstractControllerCache
194+ mutable struct IControllerCache{C, T, UT } <: AbstractControllerCache
195195 controller:: C
196196 q:: T
197197 dtreject:: T
198198 # I believe this should go here or in the algorithm cache, but not in the integrator itself.
199199 # EEst::T
200+ atmp:: UT
200201end
201202
202- function setup_controller_cache (alg, controller:: NewIController{T} ) where T
203+ function setup_controller_cache (alg, atmp, controller:: NewIController{T} ) where T
203204 IControllerCache (
204205 controller,
205206 T (1 ),
206207 T (1 // 10 ^ 4 ), # TODO which value?
208+ atmp,
207209 )
208210end
209211
@@ -356,23 +358,24 @@ function NewPIController(QT, alg; beta1 = nothing, beta2 = nothing, qmin = nothi
356358 )
357359end
358360
359- mutable struct PIControllerCache{T} <: AbstractControllerCache
361+ mutable struct PIControllerCache{T, UT } <: AbstractControllerCache
360362 controller:: NewPIController{T}
361363 # Propsoed scaling factor for the time step length
362364 q:: T
363365 # Cached εₙ₊₁^β₁
364366 q11:: T
365367 # Previous EEst
366368 errold:: T
369+ atmp:: UT
367370end
368371
369-
370- function setup_controller_cache (alg, controller:: NewPIController{T} ) where T
372+ function setup_controller_cache (alg, atmp, controller:: NewPIController{T} ) where T
371373 PIControllerCache (
372374 controller,
373375 T (1 ),
374376 T (1 ),
375377 T (1 // 10 ^ 4 ),
378+ atmp,
376379 )
377380end
378381
@@ -612,18 +615,20 @@ function Base.show(io::IO, controller::NewPIDController)
612615 " )" )
613616end
614617
615- mutable struct PIDControllerCache{T, Limiter} <: AbstractControllerCache
618+ mutable struct PIDControllerCache{T, Limiter, UT } <: AbstractControllerCache
616619 controller:: NewPIDController{T, Limiter}
617620 err:: MVector{3, T} # history of the error estimates
618621 dt_factor:: T
622+ atmp:: UT
619623end
620624
621- function setup_controller_cache (alg, controller:: NewPIDController{QT} ) where QT
625+ function setup_controller_cache (alg, atmp, controller:: NewPIDController{QT} ) where QT
622626 err = MVector {3, QT} (true , true , true )
623627 PIDControllerCache (
624628 controller,
625629 err,
626630 QT (1 // 10 ^ 4 ),
631+ atmp,
627632 )
628633end
629634
@@ -829,21 +834,23 @@ function NewPredictiveController(QT, alg; qmin = nothing, qmax = nothing, gamma
829834 )
830835end
831836
832- mutable struct PredictiveControllerCache{T} <: AbstractControllerCache
837+ mutable struct PredictiveControllerCache{T, UT } <: AbstractControllerCache
833838 controller:: NewPredictiveController{T}
834839 dtacc:: T
835840 erracc:: T
836841 qold:: T
837842 q:: T
843+ atmp:: UT
838844end
839845
840- function setup_controller_cache (alg, controller:: NewPredictiveController{T} ) where T
846+ function setup_controller_cache (alg, atmp, controller:: NewPredictiveController{T} ) where T
841847 PredictiveControllerCache {T} (
842848 controller,
843849 T (1 ),
844850 T (1 ),
845851 T (1 ),
846- T (1 )
852+ T (1 ),
853+ atmp,
847854 )
848855end
849856
@@ -909,13 +916,15 @@ struct CompositeController{T} <: AbstractController
909916 controllers:: T
910917end
911918
912- struct CompositeControllerCache{T} <: AbstractControllerCache
919+ struct CompositeControllerCache{T, UT } <: AbstractControllerCache
913920 caches:: T
921+ atmp:: UT # This is just here for easy access
914922end
915923
916- function setup_controller_cache (alg:: CompositeAlgorithm , cc:: CompositeController )
924+ function setup_controller_cache (alg:: CompositeAlgorithm , atmp, cc:: CompositeController )
917925 CompositeControllerCache (
918- map ((alg, controller)-> setup_controller_cache (alg, controller), alg. algs, cc. controllers)
926+ map ((alg, controller)-> setup_controller_cache (alg, atmp, controller), alg. algs, cc. controllers),
927+ atmp,
919928 )
920929end
921930
0 commit comments