Skip to content

Commit 6424dd0

Browse files
Harsh SinghHarsh Singh
authored andcommitted
Refactor: restrict IMEX implementation to ESDIRK methods and address review feedback
1 parent 5b818c5 commit 6424dd0

6 files changed

Lines changed: 56 additions & 57 deletions

File tree

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
1010
CommonSolve = "38540f10-b2f7-11e9-35d8-d573e4eb0ff2"
1111
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
1212
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
13-
DiffEqDevTools = "f3b72e0c-5b89-59e1-b016-84e28bfd966d"
1413
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1514
EnumX = "4e289a0a-7415-4d19-859d-a7e5c4648b56"
1615
ExponentialUtilities = "d4d017d3-3776-5f7e-afef-a10c40355c18"
@@ -28,7 +27,6 @@ Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
2827
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
2928
MuladdMacro = "46d2c3a1-f734-5fdb-9937-b9b9aeba4221"
3029
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
31-
ODEProblemLibrary = "fdc4e326-1af4-4b90-96e7-779fcce2daa5"
3230
OrdinaryDiffEqAdamsBashforthMoulton = "89bda076-bce5-4f1c-845f-551c83cdda9a"
3331
OrdinaryDiffEqBDF = "6ad6398a-0878-4a85-9266-38940aa047c8"
3432
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"

lib/OrdinaryDiffEqCore/src/algorithms.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ abstract type OrdinaryDiffEqAdaptiveImplicitAlgorithm{CS, AD, FDT, ST, CJ} <:
2020
OrdinaryDiffEqAdaptiveAlgorithm end
2121
abstract type OrdinaryDiffEqNewtonAdaptiveAlgorithm{CS, AD, FDT, ST, CJ} <:
2222
OrdinaryDiffEqAdaptiveImplicitAlgorithm{CS, AD, FDT, ST, CJ} end
23+
abstract type OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ} <:
24+
OrdinaryDiffEqNewtonAdaptiveAlgorithm{CS, AD, FDT, ST, CJ} end
2325
abstract type OrdinaryDiffEqRosenbrockAdaptiveAlgorithm{CS, AD, FDT, ST, CJ} <:
2426
OrdinaryDiffEqAdaptiveImplicitAlgorithm{CS, AD, FDT, ST, CJ} end
2527

lib/OrdinaryDiffEqSDIRK/src/OrdinaryDiffEqSDIRK.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import OrdinaryDiffEqCore: alg_order, calculate_residuals!,
66
OrdinaryDiffEqAlgorithm,
77
OrdinaryDiffEqMutableCache, OrdinaryDiffEqConstantCache,
88
OrdinaryDiffEqNewtonAdaptiveAlgorithm,
9+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm,
910
OrdinaryDiffEqNewtonAlgorithm,
1011
DEFAULT_PRECS,
1112
OrdinaryDiffEqAdaptiveAlgorithm, CompiledFloats, uses_uprev,
@@ -46,7 +47,7 @@ export ImplicitEuler, ImplicitMidpoint, Trapezoid, TRBDF2, SDIRK2, SDIRK22,
4647
SFSDIRK5, CFNLIRK3, SFSDIRK6, SFSDIRK7, SFSDIRK8, Kvaerno5, KenCarp4, KenCarp5,
4748
SFSDIRK4, SFSDIRK5, CFNLIRK3, SFSDIRK6,
4849
SFSDIRK7, SFSDIRK8, ESDIRK436L2SA2, ESDIRK437L2SA, ESDIRK547L2SA2, ESDIRK659L2SA,
49-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm, ARS343
50+
ARS343
5051

5152
import PrecompileTools
5253
import Preferences

lib/OrdinaryDiffEqSDIRK/src/algorithms.jl

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ function SDIRK_docstring(
7979
)
8080
end
8181

82-
abstract type OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ} <:
83-
OrdinaryDiffEqNewtonAdaptiveAlgorithm{CS, AD, FDT, ST, CJ} end
8482

8583
@doc SDIRK_docstring(
8684
"A 1st order implicit solver. A-B-L-stable. Adaptive timestepping through a divided differences estimate. Strong-stability preserving (SSP). Good for highly stiff equations.",
@@ -489,7 +487,7 @@ end
489487
"""
490488
)
491489
struct Kvaerno3{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
492-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
490+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
493491
linsolve::F
494492
nlsolve::F2
495493
precs::P
@@ -541,7 +539,7 @@ end
541539
"""
542540
)
543541
struct KenCarp3{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
544-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
542+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
545543
linsolve::F
546544
nlsolve::F2
547545
precs::P
@@ -1048,7 +1046,7 @@ end
10481046
"""
10491047
)
10501048
struct Kvaerno4{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1051-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1049+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
10521050
linsolve::F
10531051
nlsolve::F2
10541052
precs::P
@@ -1104,7 +1102,7 @@ end
11041102
"""
11051103
)
11061104
struct Kvaerno5{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1107-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1105+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
11081106
linsolve::F
11091107
nlsolve::F2
11101108
precs::P
@@ -1156,7 +1154,7 @@ end
11561154
"""
11571155
)
11581156
struct KenCarp4{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1159-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1157+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
11601158
linsolve::F
11611159
nlsolve::F2
11621160
precs::P
@@ -1211,7 +1209,7 @@ end
12111209
"""
12121210
)
12131211
struct KenCarp47{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1214-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1212+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
12151213
linsolve::F
12161214
nlsolve::F2
12171215
precs::P
@@ -1263,7 +1261,7 @@ end
12631261
"""
12641262
)
12651263
struct KenCarp5{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1266-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1264+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
12671265
linsolve::F
12681266
nlsolve::F2
12691267
precs::P
@@ -1316,7 +1314,7 @@ end
13161314
"""
13171315
)
13181316
struct KenCarp58{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1319-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1317+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
13201318
linsolve::F
13211319
nlsolve::F2
13221320
precs::P
@@ -1625,7 +1623,7 @@ end
16251623
"""
16261624
)
16271625
struct ARS343{CS, AD, F, F2, P, FDT, ST, CJ, StepLimiter} <:
1628-
OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm{CS, AD, FDT, ST, CJ}
1626+
OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm{CS, AD, FDT, ST, CJ}
16291627
linsolve::F
16301628
nlsolve::F2
16311629
precs::P

lib/OrdinaryDiffEqSDIRK/src/generic_imex_perform_step.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
mutable struct IMEXConstantCache{Tab, N} <: OrdinaryDiffEqConstantCache
1+
mutable struct ESDIRKIMEXConstantCache{Tab, N} <: OrdinaryDiffEqConstantCache
22
nlsolver::N
33
tab::Tab
44
end
55

6-
mutable struct IMEXCache{uType, rateType, uNoUnitsType, N, Tab, kType, StepLimiter} <:
6+
mutable struct ESDIRKIMEXCache{uType, rateType, uNoUnitsType, N, Tab, kType, StepLimiter} <:
77
SDIRKMutableCache
88
u::uType
99
uprev::uType
@@ -16,7 +16,7 @@ mutable struct IMEXCache{uType, rateType, uNoUnitsType, N, Tab, kType, StepLimit
1616
step_limiter!::StepLimiter
1717
end
1818

19-
function full_cache(c::IMEXCache)
19+
function full_cache(c::ESDIRKIMEXCache)
2020
base = (c.u, c.uprev, c.fsalfirst, c.zs..., c.atmp)
2121
if eltype(c.ks) !== Nothing
2222
return tuple(base..., c.ks...)
@@ -25,28 +25,28 @@ function full_cache(c::IMEXCache)
2525
end
2626

2727
function alg_cache(
28-
alg::OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm, u, rate_prototype, ::Type{uEltypeNoUnits},
28+
alg::OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm, u, rate_prototype, ::Type{uEltypeNoUnits},
2929
::Type{uBottomEltypeNoUnits}, ::Type{tTypeNoUnits},
3030
uprev, uprev2, f, t, dt, reltol, p, calck,
3131
::Val{false}, verbose
3232
) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
33-
tab = IMEXTableau(alg, constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
33+
tab = ESDIRKIMEXTableau(alg, constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
3434
γ = tab.Ai[2, 2]
3535
c = tab.c[2]
3636
nlsolver = build_nlsolver(
3737
alg, u, uprev, p, t, dt, f, rate_prototype, uEltypeNoUnits,
3838
uBottomEltypeNoUnits, tTypeNoUnits, γ, c, Val(false), verbose
3939
)
40-
return IMEXConstantCache(nlsolver, tab)
40+
return ESDIRKIMEXConstantCache(nlsolver, tab)
4141
end
4242

4343
function alg_cache(
44-
alg::OrdinaryDiffEqNewtonAdaptiveIMEXAlgorithm, u, rate_prototype, ::Type{uEltypeNoUnits},
44+
alg::OrdinaryDiffEqNewtonAdaptiveESDIRKAlgorithm, u, rate_prototype, ::Type{uEltypeNoUnits},
4545
::Type{uBottomEltypeNoUnits},
4646
::Type{tTypeNoUnits}, uprev, uprev2, f, t, dt, reltol, p, calck,
4747
::Val{true}, verbose
4848
) where {uEltypeNoUnits, uBottomEltypeNoUnits, tTypeNoUnits}
49-
tab = IMEXTableau(alg, constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
49+
tab = ESDIRKIMEXTableau(alg, constvalue(uBottomEltypeNoUnits), constvalue(tTypeNoUnits))
5050
γ = tab.Ai[2, 2]
5151
c = tab.c[2]
5252
nlsolver = build_nlsolver(
@@ -67,12 +67,12 @@ function alg_cache(
6767
atmp = similar(u, uEltypeNoUnits)
6868
recursivefill!(atmp, false)
6969

70-
return IMEXCache(
70+
return ESDIRKIMEXCache(
7171
u, uprev, fsalfirst, zs, ks, atmp, nlsolver, tab, alg.step_limiter!
7272
)
7373
end
7474

75-
function initialize!(integrator, cache::IMEXConstantCache)
75+
function initialize!(integrator, cache::ESDIRKIMEXConstantCache)
7676
integrator.kshortsize = 2
7777
integrator.k = typeof(integrator.k)(undef, integrator.kshortsize)
7878
integrator.fsalfirst = integrator.f(integrator.uprev, integrator.p, integrator.t)
@@ -83,7 +83,7 @@ function initialize!(integrator, cache::IMEXConstantCache)
8383
return nothing
8484
end
8585

86-
function initialize!(integrator, cache::IMEXCache)
86+
function initialize!(integrator, cache::ESDIRKIMEXCache)
8787
integrator.kshortsize = 2
8888
resize!(integrator.k, integrator.kshortsize)
8989
integrator.k[1] = integrator.fsalfirst
@@ -94,7 +94,7 @@ function initialize!(integrator, cache::IMEXCache)
9494
end
9595

9696
@muladd function perform_step!(
97-
integrator, cache::IMEXConstantCache, repeat_step = false
97+
integrator, cache::ESDIRKIMEXConstantCache, repeat_step = false
9898
)
9999
(; t, dt, uprev, u, p) = integrator
100100
nlsolver = cache.nlsolver
@@ -208,7 +208,7 @@ end
208208
integrator.u = u
209209
end
210210

211-
@muladd function perform_step!(integrator, cache::IMEXCache, repeat_step = false)
211+
@muladd function perform_step!(integrator, cache::ESDIRKIMEXCache, repeat_step = false)
212212
(; t, dt, uprev, u, p) = integrator
213213
(; zs, ks, atmp, nlsolver, step_limiter!) = cache
214214
(; tmp) = nlsolver

0 commit comments

Comments
 (0)