Skip to content

Commit b035dac

Browse files
Merge pull request #164 from devmotion/sdirk_update
WIP: Update of SDIRK and generic implicit integrators
2 parents 2073b24 + 24584cf commit b035dac

File tree

5 files changed

+2805
-2459
lines changed

5 files changed

+2805
-2459
lines changed

src/caches/generic_implicit_caches.jl

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
mutable struct GenericImplicitEulerCache{uType,uArrayType,vecuType,DiffCacheType,rateType,rhsType,nl_rhsType} <: OrdinaryDiffEqMutableCache
1+
mutable struct GenericImplicitEulerCache{uType,uArrayType,vecuType,DiffCacheType,uNoUnitsType,rateType,rhsType,nl_rhsType} <: OrdinaryDiffEqMutableCache
22
u::uType
33
uprev::uType
44
uprev2::uType
55
uhold::vecuType
66
dual_cache::DiffCacheType
77
C::uArrayType
88
tmp::uType
9+
atmp::uNoUnitsType
910
k::rateType
1011
fsalfirst::rateType
1112
rhs::rhsType
@@ -18,7 +19,7 @@ vecu_cache(c::GenericImplicitEulerCache) = (c.uhold,)
1819
dual_cache(c::GenericImplicitEulerCache) = (c.dual_cache,)
1920

2021
function alg_cache(alg::GenericImplicitEuler,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,dt,reltol,::Type{Val{true}})
21-
tmp = similar(u)
22+
tmp = similar(u); atmp = similar(u,uEltypeNoUnits)
2223
C = vec(tmp); k = zeros(rate_prototype)
2324
dual_cache = DiffCache(u,Val{determine_chunksize(u,get_chunksize(alg.nlsolve))})
2425
uhold = vec(u) # this makes uhold the same values as integrator.u
@@ -27,8 +28,8 @@ function alg_cache(alg::GenericImplicitEuler,u,rate_prototype,uEltypeNoUnits,tTy
2728
nl_rhs = alg.nlsolve(Val{:init},rhs,uhold)
2829

2930
GenericImplicitEulerCache{typeof(u),typeof(C),typeof(uhold),typeof(dual_cache),
30-
typeof(k),typeof(rhs),typeof(nl_rhs)}(
31-
u,uprev,uprev2,uhold,dual_cache,C,tmp,k,fsalfirst,rhs,nl_rhs)
31+
typeof(atmp),typeof(k),typeof(rhs),typeof(nl_rhs)}(
32+
u,uprev,uprev2,uhold,dual_cache,C,tmp,atmp,k,fsalfirst,rhs,nl_rhs)
3233
end
3334

3435
struct GenericImplicitEulerConstantCache{vecuType,rhsType,nl_rhsType} <: OrdinaryDiffEqConstantCache
@@ -47,7 +48,7 @@ function alg_cache(alg::GenericImplicitEuler,u,rate_prototype,uEltypeNoUnits,tTy
4748
GenericImplicitEulerConstantCache{typeof(uhold),typeof(rhs),typeof(nl_rhs)}(uhold,C,rhs,nl_rhs)
4849
end
4950

50-
mutable struct GenericTrapezoidCache{uType,uArrayType,vecuType,DiffCacheType,rateType,rhsType,nl_rhsType,tType} <: OrdinaryDiffEqMutableCache
51+
mutable struct GenericTrapezoidCache{uType,uArrayType,vecuType,DiffCacheType,uNoUnitsType,rateType,rhsType,nl_rhsType,tType} <: OrdinaryDiffEqMutableCache
5152
u::uType
5253
uprev::uType
5354
uprev2::uType
@@ -56,6 +57,7 @@ mutable struct GenericTrapezoidCache{uType,uArrayType,vecuType,DiffCacheType,rat
5657
fsalfirst::rateType
5758
dual_cache::DiffCacheType
5859
tmp::uType
60+
atmp::uNoUnitsType
5961
k::rateType
6062
rhs::rhsType
6163
nl_rhs::nl_rhsType
@@ -69,7 +71,7 @@ vecu_cache(c::GenericTrapezoidCache) = (c.uhold,)
6971
dual_cache(c::GenericTrapezoidCache) = (c.dual_cache,)
7072

7173
function alg_cache(alg::GenericTrapezoid,u,rate_prototype,uEltypeNoUnits,tTypeNoUnits,uprev,uprev2,f,t,dt,reltol,::Type{Val{true}})
72-
tmp = similar(u)
74+
tmp = similar(u); atmp = similar(u,uEltypeNoUnits)
7375
C = vec(tmp); k = zeros(rate_prototype)
7476
uhold = vec(u); fsalfirst = zeros(rate_prototype)
7577
dual_cache = DiffCache(u,Val{determine_chunksize(u,get_chunksize(alg.nlsolve))})
@@ -78,10 +80,10 @@ function alg_cache(alg::GenericTrapezoid,u,rate_prototype,uEltypeNoUnits,tTypeNo
7880
uprev3 = similar(u)
7981
tprev2 = t
8082
GenericTrapezoidCache{typeof(u),typeof(C),typeof(uhold),
81-
typeof(dual_cache),typeof(k),
83+
typeof(dual_cache),typeof(atmp),typeof(k),
8284
typeof(rhs),typeof(nl_rhs),typeof(t)}(
8385
u,uprev,uprev2,uhold,C,fsalfirst,
84-
dual_cache,tmp,k,rhs,nl_rhs,uprev3,tprev2)
86+
dual_cache,tmp,atmp,k,rhs,nl_rhs,uprev3,tprev2)
8587
end
8688

8789

0 commit comments

Comments
 (0)