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 Tuple of closures with CATKE #3960

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,26 @@ end

const EmptyNamedTuple = NamedTuple{(),Tuple{}}

hasclosure(closure, ClosureType) = closure isa ClosureType
hasclosure(closure_tuple::Tuple, ClosureType) = any(hasclosure(c, ClosureType) for c in closure_tuple)

ab2_step_tracers!(::EmptyNamedTuple, model, Δt, χ) = nothing

function ab2_step_tracers!(tracers, model, Δt, χ)

closure = model.closure

catke_in_closures = hasclosure(closure, FlavorOfCATKE)
td_in_closures = hasclosure(closure, FlavorOfTD)

# Tracer update kernels
for (tracer_index, tracer_name) in enumerate(propertynames(tracers))

# TODO: do better than this silly criteria, also need to check closure tuples
if closure isa FlavorOfCATKE && tracer_name == :e
if catke_in_closures && tracer_name == :e
@debug "Skipping AB2 step for e"
elseif closure isa FlavorOfTD && tracer_name == :ϵ
elseif td_in_closures && tracer_name == :ϵ
@debug "Skipping AB2 step for ϵ"
elseif closure isa FlavorOfTD && tracer_name == :e
elseif td_in_closures && tracer_name == :e
@debug "Skipping AB2 step for e"
else
Gⁿ = model.timestepper.Gⁿ[tracer_name]
Expand Down