Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow commscontext input, def compute_T_exp_T_lim #257

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ClimaTimeSteppers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const SPCO = SparseCoeffs

include("solvers/imex_tableaus.jl")
include("solvers/explicit_tableaus.jl")
include("solvers/compute_T_exp_T_lim.jl")
include("solvers/imex_ark.jl")
include("solvers/imex_ssprk.jl")
include("solvers/multirate.jl")
Expand Down
3 changes: 2 additions & 1 deletion src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ export ClimaODEFunction, ForwardEulerODEFunction

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

Base.@kwdef struct ClimaODEFunction{TL, TE, TI, L, D, PE, PI} <: AbstractClimaODEFunction
Base.@kwdef struct ClimaODEFunction{TL, TE, TI, L, D, PE, PI, CC} <: AbstractClimaODEFunction
T_lim!::TL = nothing # nothing or (uₜ, u, p, t) -> ...
T_exp!::TE = nothing # nothing or (uₜ, u, p, t) -> ...
T_imp!::TI = nothing # nothing or (uₜ, u, p, t) -> ...
lim!::L = (u, p, t, u_ref) -> nothing
dss!::D = (u, p, t) -> nothing
post_explicit!::PE = (u, p, t) -> nothing
post_implicit!::PI = (u, p, t) -> nothing
comms_context::CC = nothing
end

# Don't wrap a AbstractClimaODEFunction in an ODEFunction (makes ODEProblem work).
Expand Down
13 changes: 13 additions & 0 deletions src/solvers/compute_T_exp_T_lim.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@inline function compute_T_lim_T_exp!(
T_lim,
T_exp,
U,
p,
t,
T_lim!,
T_exp!,
::Union{Nothing, ClimaComms.AbstractCommsContext},
)
T_lim!(T_lim, U, p, t)
T_exp!(T_exp, U, p, t)
end
9 changes: 7 additions & 2 deletions src/solvers/imex_ark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,13 @@ end
end

if !all(iszero, a_exp[:, i]) || !iszero(b_exp[i])
isnothing(T_lim!) || T_lim!(T_lim[i], U, p, t_exp)
isnothing(T_exp!) || T_exp!(T_exp[i], U, p, t_exp)
if !isnothing(T_lim!) && !isnothing(T_exp!)
(; comms_context) = f
compute_T_lim_T_exp!(T_lim[i], T_exp[i], U, p, t_exp, T_lim!, T_exp!, comms_context)
else
isnothing(T_lim!) || T_lim!(T_lim[i], U, p, t_exp)
isnothing(T_exp!) || T_exp!(T_exp[i], U, p, t_exp)
end
end

return nothing
Expand Down
11 changes: 6 additions & 5 deletions src/solvers/imex_ssprk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,12 @@ function step_u!(integrator, cache::IMEXSSPRKCache)
end

if !iszero(β[i])
if !isnothing(T_lim!)
T_lim!(T_lim, U, p, t_exp)
end
if !isnothing(T_exp!)
T_exp!(T_exp, U, p, t_exp)
if !isnothing(T_lim!) && !isnothing(T_exp!)
(; comms_context) = f
compute_T_lim_T_exp!(T_lim[i], T_exp[i], U, p, t_exp, T_lim!, T_exp!, comms_context)
else
isnothing(T_lim!) || T_lim!(T_lim, U, p, t_exp)
isnothing(T_exp!) || T_exp!(T_exp, U, p, t_exp)
end
end
end
Expand Down
Loading