Skip to content

Commit

Permalink
Remove do_dss from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbozzolo committed Nov 24, 2023
1 parent 02837da commit f466bf5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
18 changes: 13 additions & 5 deletions src/cache/cache.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function do_dss(space::Spaces.AbstractSpace)
quadrature_style = Spaces.horizontal_space(space).quadrature_style
return quadrature_style isa Spaces.Quadratures.GLL
end

do_dss(Yc::Fields.Field) = do_dss(axes(Yc))
do_dss(Y::Fields.FieldVector) = do_dss(Y.c)

# Functions on which the model depends:
# CAP.R_d(params) # dry specific gas constant
# CAP.kappa_d(params) # dry adiabatic exponent
Expand Down Expand Up @@ -37,11 +45,12 @@ function build_cache(Y, atmos, params, surface_setup, simulation)
end
ᶜf = @. CT3(Geometry.WVector(ᶜf))

quadrature_style = Spaces.horizontal_space(axes(Y.c)).quadrature_style
do_dss = quadrature_style isa Spaces.Quadratures.GLL
ghost_buffer =
!do_dss ? (;) :
(; c = Spaces.create_dss_buffer(Y.c), f = Spaces.create_dss_buffer(Y.f))
do_dss(Y) ?
(;
c = Spaces.create_dss_buffer(Y.c),
f = Spaces.create_dss_buffer(Y.f),
) : (;)

limiter =
isnothing(atmos.numerics.limiter) ? nothing :
Expand Down Expand Up @@ -98,7 +107,6 @@ function build_cache(Y, atmos, params, surface_setup, simulation)
core,
sfc_setup,
params,
do_dss,
precomputed,
scratch,
hyperdiff,
Expand Down
2 changes: 1 addition & 1 deletion src/callbacks/callbacks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ NVTX.@annotate function compute_diagnostics(integrator)

if eltype(Fields.coordinate_field(axes(Y.c))) <: Geometry.Abstract3DPoint
ᶜvort = @. Geometry.WVector(curlₕ(Y.c.uₕ))
if p.do_dss
if do_dss(Y)
Spaces.weighted_dss!(ᶜvort)
end
dycore_diagnostic = (; dycore_diagnostic..., vorticity = ᶜvort)
Expand Down
2 changes: 1 addition & 1 deletion src/prognostic_equations/dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using ClimaCore.Utilities: half
import ClimaCore.Fields: ColumnField

NVTX.@annotate function dss!(Y, p, t)
if p.do_dss
if do_dss(Y)
Spaces.weighted_dss_start2!(Y.c, p.ghost_buffer.c)
Spaces.weighted_dss_start2!(Y.f, p.ghost_buffer.f)
Spaces.weighted_dss_internal2!(Y.c, p.ghost_buffer.c)
Expand Down
15 changes: 5 additions & 10 deletions src/prognostic_equations/hyperdiffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ hyperdiffusion_cache(Y, atmos) =
hyperdiffusion_cache(Y, hyperdiff::Nothing, _) = (;)

function hyperdiffusion_cache(Y, hyperdiff::ClimaHyperdiffusion, turbconv_model)
do_dss =
Spaces.horizontal_space(axes(Y.c)).quadrature_style isa
Spaces.Quadratures.GLL
FT = eltype(Y)
n = n_mass_flux_subdomains(turbconv_model)

Expand Down Expand Up @@ -43,7 +40,7 @@ function hyperdiffusion_cache(Y, hyperdiff::ClimaHyperdiffusion, turbconv_model)
turbconv_model isa DiagnosticEDMFX ? (; ᶜ∇²tke⁰ = similar(Y.c, FT)) :
(;)
quantities = (; gs_quantities..., sgs_quantities...)
if do_dss
if do_dss(Y)
quantities = (;
quantities...,
hyperdiffusion_ghost_buffer = map(
Expand All @@ -64,7 +61,6 @@ NVTX.@annotate function hyperdiffusion_tendency!(Yₜ, Y, p, t)
diffuse_tke = use_prognostic_tke(turbconv_model)
ᶜJ = Fields.local_geometry_field(Y.c).J
point_type = eltype(Fields.coordinate_field(Y.c))
(; do_dss) = p
(; ᶜp, ᶜspecific) = p.precomputed
(; ᶜ∇²u, ᶜ∇²specific_energy) = p.hyperdiff
if turbconv_model isa PrognosticEDMFX
Expand All @@ -75,7 +71,7 @@ NVTX.@annotate function hyperdiffusion_tendency!(Yₜ, Y, p, t)
(; ᶜtke⁰) = p.precomputed
(; ᶜ∇²tke⁰) = p.hyperdiff
end
if do_dss
if do_dss(Y)
buffer = p.hyperdiff.hyperdiffusion_ghost_buffer
end

Expand All @@ -100,7 +96,7 @@ NVTX.@annotate function hyperdiffusion_tendency!(Yₜ, Y, p, t)
end
end

if do_dss
if do_dss(Y)
NVTX.@range "dss_hyperdiffusion_tendency" color = colorant"green" begin
for dss_op! in (
Spaces.weighted_dss_start!,
Expand Down Expand Up @@ -173,12 +169,11 @@ NVTX.@annotate function tracer_hyperdiffusion_tendency!(Yₜ, Y, p, t)
n = n_mass_flux_subdomains(turbconv_model)

(; ᶜspecific) = p.precomputed
(; do_dss) = p
(; ᶜ∇²specific_tracers) = p.hyperdiff
if turbconv_model isa PrognosticEDMFX
(; ᶜ∇²q_totʲs) = p.hyperdiff
end
if do_dss
if do_dss(Y)
buffer = p.hyperdiff.hyperdiffusion_ghost_buffer
end

Expand All @@ -193,7 +188,7 @@ NVTX.@annotate function tracer_hyperdiffusion_tendency!(Yₜ, Y, p, t)
end
end

if do_dss
if do_dss(Y)
NVTX.@range "dss_hyperdiffusion_tendency" color = colorant"green" begin
for dss_op! in (
Spaces.weighted_dss_start!,
Expand Down

0 comments on commit f466bf5

Please sign in to comment.