Skip to content

Commit 94c220d

Browse files
Allow commscontext input, def compute_T_exp_T_lim
1 parent 7a2e03e commit 94c220d

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

src/ClimaTimeSteppers.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const SPCO = SparseCoeffs
118118

119119
include("solvers/imex_tableaus.jl")
120120
include("solvers/explicit_tableaus.jl")
121+
include("solvers/compute_T_exp_T_lim.jl")
121122
include("solvers/imex_ark.jl")
122123
include("solvers/imex_ssprk.jl")
123124
include("solvers/multirate.jl")

src/functions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ export ClimaODEFunction, ForwardEulerODEFunction
44

55
abstract type AbstractClimaODEFunction <: DiffEqBase.AbstractODEFunction{true} end
66

7-
Base.@kwdef struct ClimaODEFunction{TL, TE, TI, L, D, PE, PI} <: AbstractClimaODEFunction
7+
Base.@kwdef struct ClimaODEFunction{TL, TE, TI, L, D, PE, PI, CC} <: AbstractClimaODEFunction
88
T_lim!::TL = nothing # nothing or (uₜ, u, p, t) -> ...
99
T_exp!::TE = nothing # nothing or (uₜ, u, p, t) -> ...
1010
T_imp!::TI = nothing # nothing or (uₜ, u, p, t) -> ...
1111
lim!::L = (u, p, t, u_ref) -> nothing
1212
dss!::D = (u, p, t) -> nothing
1313
post_explicit!::PE = (u, p, t) -> nothing
1414
post_implicit!::PI = (u, p, t) -> nothing
15+
comms_context::CC = nothing
1516
end
1617

1718
# Don't wrap a AbstractClimaODEFunction in an ODEFunction (makes ODEProblem work).

src/solvers/compute_T_exp_T_lim.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@inline function compute_T_lim_T_exp!(
2+
T_lim,
3+
T_exp,
4+
U,
5+
p,
6+
t,
7+
T_lim!,
8+
T_exp!,
9+
::Union{Nothing, ClimaComms.AbstractCommsContext},
10+
)
11+
T_lim!(T_lim, U, p, t)
12+
T_exp!(T_exp, U, p, t)
13+
end

src/solvers/imex_ark.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,13 @@ end
169169
end
170170

171171
if !all(iszero, a_exp[:, i]) || !iszero(b_exp[i])
172-
isnothing(T_lim!) || T_lim!(T_lim[i], U, p, t_exp)
173-
isnothing(T_exp!) || T_exp!(T_exp[i], U, p, t_exp)
172+
if !isnothing(T_lim!) && !isnothing(T_exp!)
173+
(; comms_context) = f
174+
compute_T_lim_T_exp!(T_lim[i], T_exp[i], U, p, t_exp, T_lim!, T_exp!, comms_context)
175+
else
176+
isnothing(T_lim!) || T_lim!(T_lim[i], U, p, t_exp)
177+
isnothing(T_exp!) || T_exp!(T_exp[i], U, p, t_exp)
178+
end
174179
end
175180

176181
return nothing

src/solvers/imex_ssprk.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ function step_u!(integrator, cache::IMEXSSPRKCache)
153153
end
154154

155155
if !iszero(β[i])
156-
if !isnothing(T_lim!)
157-
T_lim!(T_lim, U, p, t_exp)
158-
end
159-
if !isnothing(T_exp!)
160-
T_exp!(T_exp, U, p, t_exp)
156+
if !isnothing(T_lim!) && !isnothing(T_exp!)
157+
(; comms_context) = f
158+
compute_T_lim_T_exp!(T_lim[i], T_exp[i], U, p, t_exp, T_lim!, T_exp!, comms_context)
159+
else
160+
isnothing(T_lim!) || T_lim!(T_lim[i], U, p, t_exp)
161+
isnothing(T_exp!) || T_exp!(T_exp[i], U, p, t_exp)
161162
end
162163
end
163164
end

0 commit comments

Comments
 (0)