Skip to content

Commit aafb36a

Browse files
Put zmax into cache, for rayleigh sponge
1 parent f67ed0a commit aafb36a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/parameterized_tendencies/sponge/rayleigh_sponge.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ import ClimaCore.Fields as Fields
1414

1515
function rayleigh_sponge_tendency_uₕ(ᶜuₕ, s)
1616
s isa Nothing && return NullBroadcasted()
17-
(; ᶜz, ᶠz) = z_coordinate_fields(axes(ᶜuₕ))
17+
ᶜz = Fields.coordinate_field(Spaces.center_space(axes(ᶜuₕ))).z
18+
ᶠz = Fields.coordinate_field(Spaces.face_space(axes(ᶜuₕ))).z
1819
zmax = z_max(axes(ᶠz))
20+
return rayleigh_sponge_tendency_uₕ(ᶜuₕ, s, ᶜz, ᶠz, zmax)
21+
end
22+
23+
function rayleigh_sponge_tendency_uₕ(ᶜuₕ, s, ᶜz, ᶠz, zmax)
24+
s isa Nothing && return NullBroadcasted()
1925
return @. lazy(-β_rayleigh_uₕ(s, ᶜz, zmax) * ᶜuₕ)
2026
end

src/prognostic_equations/remaining_tendency.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,13 @@ sub_tend(∑tends, t) = lazy.(∑tends .- t)
6969
function ᶜremaining_tendency(::Val{:uₕ}, ᶜY, ᶠY, p, t)
7070
:uₕ in propertynames(ᶜY) || return ()
7171
∑tendencies = zero(eltype(ᶜY.uₕ))
72+
(; zmax) = p
7273
(; viscous_sponge, rayleigh_sponge) = p.atmos
74+
ᶜz = Fields.coordinate_field(ᶜY).z
75+
ᶠz = Fields.coordinate_field(ᶠY).z
7376
ᶜuₕ = ᶜY.uₕ
7477
∑tendencies = add_tend(∑tendencies, viscous_sponge_tendency_uₕ(ᶜuₕ, viscous_sponge))
75-
∑tendencies = add_tend(∑tendencies, rayleigh_sponge_tendency_uₕ(ᶜuₕ, rayleigh_sponge))
78+
∑tendencies = add_tend(∑tendencies, rayleigh_sponge_tendency_uₕ(ᶜuₕ, rayleigh_sponge, ᶜz, ᶠz, zmax))
7679

7780
return ∑tendencies
7881
end
@@ -255,6 +258,7 @@ NVTX.@annotate function remaining_tendency!(Yₜ, Yₜ_lim, Y, p, t)
255258
end
256259
(; moisture_model, viscous_sponge, precip_model) = p.atmos
257260
p_kernel = (;
261+
zmax = Spaces.z_max(axes(Y.f)),
258262
atmos = p.atmos,
259263
params = p.params,
260264
dt = p.dt,

0 commit comments

Comments
 (0)