Skip to content

Commit

Permalink
Merge b2fd928 into d5b9534
Browse files Browse the repository at this point in the history
  • Loading branch information
kanav99 committed Jun 5, 2019
2 parents d5b9534 + b2fd928 commit b1f7289
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[compat]
julia = "1"
DiffEqBase = ">= 5.8.1"
DiffEqBase = ">= 5.9.0"
DiffEqOperators = ">= 3.2.0"
Parameters = ">= 0.10.0"
ForwardDiff = ">= 0.10.3"
Expand Down
6 changes: 4 additions & 2 deletions src/integrators/integrator_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ function handle_callbacks!(integrator)
discrete_modified = false
saved_in_cb = false
if !(typeof(continuous_callbacks)<:Tuple{})
time,upcrossing,event_occurred,idx,counter =
time,upcrossing,event_occurred,event_idx,idx,counter =
DiffEqBase.find_first_continuous_callback(integrator,continuous_callbacks...)
if event_occurred
integrator.event_last_time = idx
continuous_modified,saved_in_cb = DiffEqBase.apply_callback!(integrator,continuous_callbacks[idx],time,upcrossing)
integrator.vector_event_last_time = event_idx
continuous_modified,saved_in_cb = DiffEqBase.apply_callback!(integrator,continuous_callbacks[idx],time,upcrossing,event_idx)
else
integrator.event_last_time = 0
integrator.vector_event_last_time = 1
end
end
if !integrator.force_stepfail && !(typeof(discrete_callbacks)<:Tuple{})
Expand Down
18 changes: 10 additions & 8 deletions src/integrators/type.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ integrator.opts.abstol = 1e-9
```
For more info see the linked documentation page.
"""
mutable struct ODEIntegrator{algType<:OrdinaryDiffEqAlgorithm,IIP,uType,tType,pType,eigenType,QT,tdirType,ksEltype,SolType,F,CacheType,O,FSALType,EventErrorType} <: DiffEqBase.AbstractODEIntegrator{algType,IIP,uType,tType}
mutable struct ODEIntegrator{algType<:OrdinaryDiffEqAlgorithm,IIP,uType,tType,pType,eigenType,QT,tdirType,ksEltype,SolType,F,CacheType,O,FSALType,EventErrorType,CallbackCacheType} <: DiffEqBase.AbstractODEIntegrator{algType,IIP,uType,tType}
sol::SolType
u::uType
k::ksEltype
Expand All @@ -101,11 +101,13 @@ mutable struct ODEIntegrator{algType<:OrdinaryDiffEqAlgorithm,IIP,uType,tType,pT
saveiter::Int
saveiter_dense::Int
cache::CacheType
callback_cache::CallbackCacheType
kshortsize::Int
force_stepfail::Bool
last_stepfail::Bool
just_hit_tstop::Bool
event_last_time::Int
vector_event_last_time::Int
last_event_error::EventErrorType
accept_step::Bool
isout::Bool
Expand All @@ -117,24 +119,24 @@ mutable struct ODEIntegrator{algType<:OrdinaryDiffEqAlgorithm,IIP,uType,tType,pT
fsallast::FSALType

function ODEIntegrator{algType,IIP,uType,tType,pType,eigenType,tTypeNoUnits,tdirType,ksEltype,SolType,
F,CacheType,O,FSALType,EventErrorType}(
F,CacheType,O,FSALType,EventErrorType,CallbackCacheType}(
sol,u,k,t,dt,f,p,uprev,uprev2,tprev,
alg,dtcache,dtchangeable,dtpropose,tdir,
eigen_est,EEst,qold,q11,erracc,dtacc,success_iter,
iter,saveiter,saveiter_dense,cache,
iter,saveiter,saveiter_dense,cache,callback_cache,
kshortsize,force_stepfail,last_stepfail,just_hit_tstop,
event_last_time,last_event_error,
event_last_time,vector_event_last_time,last_event_error,
accept_step,isout,reeval_fsal,u_modified,opts,destats) where {algType,IIP,uType,tType,pType,eigenType,tTypeNoUnits,tdirType,ksEltype,SolType,
F,CacheType,O,FSALType,EventErrorType}
F,CacheType,O,FSALType,EventErrorType,CallbackCacheType}

new{algType,IIP,uType,tType,pType,eigenType,tTypeNoUnits,tdirType,ksEltype,SolType,
F,CacheType,O,FSALType,EventErrorType}(
F,CacheType,O,FSALType,EventErrorType,CallbackCacheType}(
sol,u,k,t,dt,f,p,uprev,uprev2,tprev,
alg,dtcache,dtchangeable,dtpropose,tdir,
eigen_est,EEst,qold,q11,erracc,dtacc,success_iter,
iter,saveiter,saveiter_dense,cache,
iter,saveiter,saveiter_dense,cache,callback_cache,
kshortsize,force_stepfail,last_stepfail,just_hit_tstop,
event_last_time,last_event_error,
event_last_time,vector_event_last_time,last_event_error,
accept_step,isout,reeval_fsal,u_modified,opts,destats) # Leave off fsalfirst and last
end
end
Expand Down
14 changes: 11 additions & 3 deletions src/solve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ function DiffEqBase.__init(

callbacks_internal = CallbackSet(callback,prob.callback)

max_len_cb = DiffEqBase.max_vector_callback_length(callbacks_internal)
if max_len_cb isa VectorContinuousCallback
callback_cache = DiffEqBase.CallbackCache(max_len_cb.len,uBottomEltype,uBottomEltype)
else
callback_cache = nothing
end

### Algorithm-specific defaults ###
if save_idxs === nothing
ksEltype = Vector{rateType}
Expand Down Expand Up @@ -302,6 +309,7 @@ function DiffEqBase.__init(
force_stepfail = false
last_stepfail = false
event_last_time = 0
vector_event_last_time = 1
last_event_error = zero(uBottomEltypeNoUnits)
dtchangeable = isdtchangeable(alg)
q11 = tTypeNoUnits(1)
Expand All @@ -313,14 +321,14 @@ function DiffEqBase.__init(
QT,typeof(tdir),typeof(k),SolType,
FType,cacheType,
typeof(opts),fsal_typeof(alg,rate_prototype),
typeof(last_event_error)}(
typeof(last_event_error),typeof(callback_cache)}(
sol,u,k,t,tType(dt),f,p,uprev,uprev2,tprev,
alg,dtcache,dtchangeable,
dtpropose,tdir,eigen_est,EEst,QT(qoldinit),q11,
erracc,dtacc,success_iter,
iter,saveiter,saveiter_dense,cache,
iter,saveiter,saveiter_dense,cache,callback_cache,
kshortsize,force_stepfail,last_stepfail,
just_hit_tstop,event_last_time,last_event_error,
just_hit_tstop,event_last_time,vector_event_last_time,last_event_error,
accept_step,
isout,reeval_fsal,
u_modified,opts,destats)
Expand Down

0 comments on commit b1f7289

Please sign in to comment.