Skip to content

Commit 3478420

Browse files
committed
move buoyancy gradient and strain rate norm to grid-mean cache
1 parent e3d8c1b commit 3478420

File tree

4 files changed

+37
-65
lines changed

4 files changed

+37
-65
lines changed

src/cache/precomputed_quantities.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ function precomputed_quantities(Y, atmos)
5353
ᶜp = similar(Y.c, FT),
5454
ᶜh_tot = similar(Y.c, FT),
5555
ᶜmixing_length = similar(Y.c, FT),
56+
ᶜlinear_buoygrad = similar(Y.c, FT),
57+
ᶜstrain_rate_norm = similar(Y.c, FT),
5658
sfc_conditions = Fields.Field(SCT, Spaces.level(axes(Y.f), half)),
5759
)
5860
cloud_diagnostics = (; ᶜcloud_fraction = similar(Y.c, FT),)
@@ -83,8 +85,6 @@ function precomputed_quantities(Y, atmos)
8385
ᶜq_tot⁰ = similar(Y.c, FT),
8486
ᶜts⁰ = similar(Y.c, TST),
8587
ᶜρ⁰ = similar(Y.c, FT),
86-
ᶜlinear_buoygrad = similar(Y.c, FT),
87-
ᶜstrain_rate_norm = similar(Y.c, FT),
8888
ᶜK_u = similar(Y.c, FT),
8989
ᶜK_h = similar(Y.c, FT),
9090
ρatke_flux = similar(Fields.level(Y.f, half), C3{FT}),
@@ -123,8 +123,6 @@ function precomputed_quantities(Y, atmos)
123123
ᶜu⁰ = similar(Y.c, C123{FT}),
124124
ᶜK⁰ = similar(Y.c, FT),
125125
ᶜtke⁰ = similar(Y.c, FT),
126-
ᶜlinear_buoygrad = similar(Y.c, FT),
127-
ᶜstrain_rate_norm = similar(Y.c, FT),
128126
ᶜK_u = similar(Y.c, FT),
129127
ᶜK_h = similar(Y.c, FT),
130128
ρatke_flux = similar(Fields.level(Y.f, half), C3{FT}),

src/diagnostics/core_diagnostics.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,38 @@ add_diagnostic_variable!(
246246
end,
247247
)
248248

249+
###
250+
# Buoyancy gradient (3d)
251+
###
252+
add_diagnostic_variable!(
253+
short_name = "bgrad",
254+
long_name = "Linearized Buoyancy Gradient",
255+
units = "s^-2",
256+
compute! = (out, state, cache, time) -> begin
257+
if isnothing(out)
258+
return copy(cache.precomputed.ᶜlinear_buoygrad)
259+
else
260+
out .= cache.precomputed.ᶜlinear_buoygrad
261+
end
262+
end,
263+
)
264+
265+
###
266+
# Strain rate magnitude (3d)
267+
###
268+
add_diagnostic_variable!(
269+
short_name = "strain",
270+
long_name = "String Rate Magnitude",
271+
units = "s^-2",
272+
compute! = (out, state, cache, time) -> begin
273+
if isnothing(out)
274+
return copy(cache.precomputed.ᶜstrain_rate_norm)
275+
else
276+
out .= cache.precomputed.ᶜstrain_rate_norm
277+
end
278+
end,
279+
)
280+
249281
###
250282
# Relative humidity (3d)
251283
###

src/diagnostics/edmfx_diagnostics.jl

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -882,64 +882,6 @@ add_diagnostic_variable!(
882882
compute! = compute_tke!,
883883
)
884884

885-
###
886-
# Buoyancy gradient (3d)
887-
###
888-
compute_bgrad!(out, state, cache, time) =
889-
compute_bgrad!(out, state, cache, time, cache.atmos.turbconv_model)
890-
compute_bgrad!(_, _, _, _, turbconv_model::T) where {T} =
891-
error_diagnostic_variable("bgrad", turbconv_model)
892-
893-
function compute_bgrad!(
894-
out,
895-
state,
896-
cache,
897-
time,
898-
turbconv_model::Union{PrognosticEDMFX, DiagnosticEDMFX},
899-
)
900-
if isnothing(out)
901-
return copy(cache.precomputed.ᶜlinear_buoygrad)
902-
else
903-
out .= cache.precomputed.ᶜlinear_buoygrad
904-
end
905-
end
906-
907-
add_diagnostic_variable!(
908-
short_name = "bgrad",
909-
long_name = "Linearized Buoyancy Gradient",
910-
units = "s^-2",
911-
compute! = compute_bgrad!,
912-
)
913-
914-
###
915-
# Strain rate magnitude (3d)
916-
###
917-
compute_strain!(out, state, cache, time) =
918-
compute_strain!(out, state, cache, time, cache.atmos.turbconv_model)
919-
compute_strain!(_, _, _, _, turbconv_model::T) where {T} =
920-
error_diagnostic_variable("strain", turbconv_model)
921-
922-
function compute_strain!(
923-
out,
924-
state,
925-
cache,
926-
time,
927-
turbconv_model::Union{PrognosticEDMFX, DiagnosticEDMFX},
928-
)
929-
if isnothing(out)
930-
return copy(cache.precomputed.ᶜstrain_rate_norm)
931-
else
932-
out .= cache.precomputed.ᶜstrain_rate_norm
933-
end
934-
end
935-
936-
add_diagnostic_variable!(
937-
short_name = "strain",
938-
long_name = "String Rate Magnitude",
939-
units = "s^-2",
940-
compute! = compute_strain!,
941-
)
942-
943885
###
944886
# Diffusivity of heat (3d)
945887
###

src/prognostic_equations/gm_sgs_closures.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ NVTX.@annotate function compute_gm_mixing_length!(ᶜmixing_length, Y, p)
2929

3030
ᶜdz = Fields.Δz_field(axes(Y.c))
3131
ᶜlg = Fields.local_geometry_field(Y.c)
32-
(; ᶜts, ᶜp, ᶠu³) = p.precomputed
32+
(; ᶜts, ᶠu³, ᶜlinear_buoygrad, ᶜstrain_rate_norm) = p.precomputed
3333
(; obukhov_length) = p.precomputed.sfc_conditions
3434

35-
ᶜlinear_buoygrad = p.scratch.ᶜtemp_scalar
3635
@. ᶜlinear_buoygrad = buoyancy_gradients(
3736
BuoyGradMean(),
3837
thermo_params,
@@ -53,13 +52,14 @@ NVTX.@annotate function compute_gm_mixing_length!(ᶜmixing_length, Y, p)
5352
@. ᶠu = C123(ᶠinterp(Y.c.uₕ)) + C123(ᶠu³)
5453
ᶜstrain_rate = p.scratch.ᶜtemp_UVWxUVW
5554
compute_strain_rate_center!(ᶜstrain_rate, ᶠu)
55+
@. ᶜstrain_rate_norm = norm_sqr(ᶜstrain_rate)
5656

5757
ᶜprandtl_nvec = p.scratch.ᶜtemp_scalar_2
5858
@. ᶜprandtl_nvec = turbulent_prandtl_number(
5959
params,
6060
obukhov_length,
6161
ᶜlinear_buoygrad,
62-
norm_sqr(ᶜstrain_rate),
62+
ᶜstrain_rate_norm,
6363
)
6464

6565
@. ᶜmixing_length = smagorinsky_lilly_length(

0 commit comments

Comments
 (0)