Skip to content

Commit 498f16e

Browse files
committed
Lazy computations of velocity variables
modified: src/cache/prognostic_edmf_precomputed_quantities.jl modified: src/prognostic_equations/edmfx_tke.jl modified: src/prognostic_equations/edmfx_sgs_flux.jl modified: src/prognostic_equations/edmfx_sgs_flux.jl
1 parent ac4e605 commit 498f16e

19 files changed

+149
-72
lines changed

src/cache/diagnostic_edmf_precomputed_quantities.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_bottom_bc!(
9393
FT = eltype(Y)
9494
n = n_mass_flux_subdomains(turbconv_model)
9595
(; ᶜΦ) = p.core
96-
(; ᶜp, ᶠu³, ᶜh_tot, ᶜK) = p.precomputed
96+
(; ᶜp, ᶜh_tot, ᶜK) = p.precomputed
9797
(; q_tot) = p.precomputed.ᶜspecific
9898
(; ustar, obukhov_length, buoyancy_flux, ρ_flux_h_tot, ρ_flux_q_tot) =
9999
p.precomputed.sfc_conditions
@@ -104,9 +104,11 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_bottom_bc!(
104104
thermo_params = CAP.thermodynamics_params(params)
105105
turbconv_params = CAP.turbconv_params(params)
106106

107+
ᶠu³ = ᶠu³_lazy(Y.c.uₕ, Y.c.ρ, Y.f.u₃)
108+
107109
ρ_int_level = Fields.field_values(Fields.level(Y.c.ρ, 1))
108110
uₕ_int_level = Fields.field_values(Fields.level(Y.c.uₕ, 1))
109-
u³_int_halflevel = Fields.field_values(Fields.level(ᶠu³, half))
111+
u³_int_halflevel = Fields.field_values(Fields.level(Base.materialize(ᶠu³), half))
110112
h_tot_int_level = Fields.field_values(Fields.level(ᶜh_tot, 1))
111113
K_int_level = Fields.field_values(Fields.level(ᶜK, 1))
112114
q_tot_int_level = Fields.field_values(Fields.level(q_tot, 1))
@@ -305,7 +307,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
305307
(; dt) = p
306308
dt = float(dt)
307309
(; ᶜΦ, ᶜgradᵥ_ᶠΦ) = p.core
308-
(; ᶜp, ᶠu³, ᶜts, ᶜh_tot, ᶜK) = p.precomputed
310+
(; ᶜp, ᶜts, ᶜh_tot, ᶜK) = p.precomputed
309311
(; q_tot) = p.precomputed.ᶜspecific
310312
(;
311313
ᶜρaʲs,
@@ -343,14 +345,16 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
343345
ᶜ∇Φ₃ = p.scratch.ᶜtemp_C3
344346
@. ᶜ∇Φ₃ = ᶜgradᵥ(ᶠΦ)
345347

348+
ᶠu³ = ᶠu³_lazy(Y.c.uₕ, Y.c.ρ, Y.f.u₃)
349+
346350
z_sfc_halflevel =
347351
Fields.field_values(Fields.level(Fields.coordinate_field(Y.f).z, half))
348352

349353
# integral
350354
for i in 2:Spaces.nlevels(axes(Y.c))
351355
ρ_level = Fields.field_values(Fields.level(Y.c.ρ, i))
352356
uₕ_level = Fields.field_values(Fields.level(Y.c.uₕ, i))
353-
u³_halflevel = Fields.field_values(Fields.level(ᶠu³, i - half))
357+
u³_halflevel = Fields.field_values(Fields.level(Base.materialize(ᶠu³), i - half))
354358
K_level = Fields.field_values(Fields.level(ᶜK, i))
355359
h_tot_level = Fields.field_values(Fields.level(ᶜh_tot, i))
356360
q_tot_level = Fields.field_values(Fields.level(q_tot, i))
@@ -372,7 +376,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_do_integral!(
372376
∇Φ₃_prev_level = Fields.field_values(Fields.level(ᶜ∇Φ₃, i - 1))
373377
∇Φ₃_data_prev_level = ∇Φ₃_prev_level.components.data.:1
374378
ρ_prev_level = Fields.field_values(Fields.level(Y.c.ρ, i - 1))
375-
u³_prev_halflevel = Fields.field_values(Fields.level(ᶠu³, i - 1 - half))
379+
u³_prev_halflevel = Fields.field_values(Fields.level(Base.materialize(ᶠu³), i - 1 - half))
376380
u³⁰_prev_halflevel =
377381
Fields.field_values(Fields.level(ᶠu³⁰, i - 1 - half))
378382
u³⁰_data_prev_halflevel = u³⁰_prev_halflevel.components.data.:1
@@ -960,7 +964,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
960964
ᶜdz = Fields.Δz_field(axes(Y.c))
961965
(; params) = p
962966
(; dt) = p
963-
(; ᶜp, ᶜu, ᶜts) = p.precomputed
967+
(; ᶜp, ᶜts) = p.precomputed
964968
(; ustar, obukhov_length) = p.precomputed.sfc_conditions
965969
(; ᶜtke⁰) = p.precomputed
966970
(;
@@ -974,13 +978,15 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
974978
thermo_params = CAP.thermodynamics_params(params)
975979
ᶜlg = Fields.local_geometry_field(Y.c)
976980

981+
ᶜu = ᶜu_lazy(Y.c.uₕ, Y.f.u₃)
977982
if p.atmos.turbconv_model isa DiagnosticEDMFX
978983
(; ᶜρaʲs, ᶠu³ʲs, ᶜdetrʲs, ᶠu³⁰, ᶜu⁰) = p.precomputed
979984
elseif p.atmos.turbconv_model isa EDOnlyEDMFX
980-
ᶠu³⁰ = p.precomputed.ᶠu³
985+
ᶠu³⁰ = ᶠu³_lazy(Y.c.uₕ,Y.c.ρ, Y.f.u₃)
981986
ᶜu⁰ = ᶜu
982987
end
983-
@. ᶜu⁰ = C123(Y.c.uₕ) + ᶜinterp(C123(ᶠu³⁰)) # Set here, but used in a different function
988+
989+
ᶜu⁰ = ᶜu_lazy(Y.c.uₕ, ᶠu³⁰) # Set here (lazy), but used elsewhere
984990

985991
@. ᶜlinear_buoygrad = buoyancy_gradients(
986992
BuoyGradMean(),
@@ -1039,7 +1045,7 @@ NVTX.@annotate function set_diagnostic_edmf_precomputed_quantities_env_closures!
10391045

10401046
ρatke_flux_values = Fields.field_values(ρatke_flux)
10411047
ρ_int_values = Fields.field_values(Fields.level(Y.c.ρ, 1))
1042-
u_int_values = Fields.field_values(Fields.level(ᶜu, 1))
1048+
u_int_values = Fields.field_values(Fields.level(Base.materialize(ᶜu), 1))
10431049
ustar_values = Fields.field_values(ustar)
10441050
int_local_geometry_values =
10451051
Fields.field_values(Fields.level(Fields.local_geometry_field(Y.c), 1))

src/cache/precipitation_precomputed_quantities.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ function set_precipitation_velocities!(
4848
moisture_model::NonEquilMoistModel,
4949
precip_model::Microphysics1Moment,
5050
)
51-
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts, ᶜu) = p.precomputed
51+
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts) = p.precomputed
5252
(; ᶜΦ) = p.core
5353
cmc = CAP.microphysics_cloud_params(p.params)
5454
cmp = CAP.microphysics_1m_params(p.params)
5555
thp = CAP.thermodynamics_params(p.params)
5656

57+
ᶜu = ᶜu_lazy(Y.c.uₕ, Y.f.u₃)
58+
5759
# compute the precipitation terminal velocity [m/s]
5860
@. ᶜwᵣ = CM1.terminal_velocity(
5961
cmp.pr,
@@ -104,14 +106,15 @@ function set_precipitation_velocities!(
104106
moisture_model::NonEquilMoistModel,
105107
precip_model::Microphysics2Moment,
106108
)
107-
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwnₗ, ᶜwnᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts, ᶜu) = p.precomputed
109+
(; ᶜwₗ, ᶜwᵢ, ᶜwᵣ, ᶜwₛ, ᶜwnₗ, ᶜwnᵣ, ᶜwₜqₜ, ᶜwₕhₜ, ᶜts) = p.precomputed
108110
(; ᶜΦ) = p.core
109111

110112
cm1c = CAP.microphysics_cloud_params(p.params)
111113
cm1p = CAP.microphysics_1m_params(p.params)
112114
cm2p = CAP.microphysics_2m_params(p.params)
113115
thp = CAP.thermodynamics_params(p.params)
114116

117+
ᶜu = ᶜu_lazy(Y.c.uₕ, Y.f.u₃)
115118
# compute the precipitation terminal velocity [m/s]
116119
# TODO sedimentation of snow is based on the 1M scheme
117120
@. ᶜwnᵣ = getindex(
@@ -280,7 +283,7 @@ function set_precipitation_cache!(
280283
end
281284
function set_precipitation_cache!(Y, p, ::Microphysics1Moment, _)
282285
(; dt) = p
283-
(; ᶜts, ᶜwᵣ, ᶜwₛ, ᶜu) = p.precomputed
286+
(; ᶜts, ᶜwᵣ, ᶜwₛ) = p.precomputed
284287
(; ᶜSqₗᵖ, ᶜSqᵢᵖ, ᶜSqᵣᵖ, ᶜSqₛᵖ) = p.precomputed
285288

286289
(; q_tot, q_liq, q_ice, q_rai, q_sno) = p.precomputed.ᶜspecific

src/cache/precomputed_quantities.jl

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ function implicit_precomputed_quantities(Y, atmos)
4343
n = n_mass_flux_subdomains(turbconv_model)
4444
gs_quantities = (;
4545
ᶜspecific = Base.materialize(ᶜspecific_gs_tracers(Y)),
46-
ᶜu = similar(Y.c, C123{FT}),
47-
ᶠu³ = similar(Y.f, CT3{FT}),
4846
ᶠu = similar(Y.f, CT123{FT}),
4947
ᶜK = similar(Y.c, FT),
5048
ᶜts = similar(Y.c, TST),
@@ -267,10 +265,13 @@ function precomputed_quantities(Y, atmos)
267265
)
268266
end
269267

270-
# Interpolates the third contravariant component of Y.c.uₕ to cell faces.
271-
function compute_ᶠuₕ³(ᶜuₕ, ᶜρ)
272-
ᶜJ = Fields.local_geometry_field(ᶜρ).J
273-
return @. lazy(ᶠwinterp(ᶜρ * ᶜJ, CT3(ᶜuₕ)))
268+
# This is used to set the grid-scale velocity quantities ᶜu, ᶠu³, ᶜK based on
269+
# ᶠu₃, and it is also used to set the SGS quantities based on ᶠu₃⁰ and ᶠu₃ʲ.
270+
function set_velocity_quantities!(ᶠu³, ᶜK, ᶠu₃, ᶜuₕ, ᶠuₕ³, ρ)
271+
ᶜu = ᶜu_lazy(ᶜuₕ, ᶠu₃)
272+
ᶠu³ = ᶠu³_lazy(ᶜuₕ, ρ, ᶠu₃)
273+
ᶜK .= compute_kinetic(ᶜuₕ, ᶠu₃)
274+
return nothing
274275
end
275276

276277
"""
@@ -323,14 +324,6 @@ function set_velocity_at_top!(Y, turbconv_model)
323324
return nothing
324325
end
325326

326-
# This is used to set the grid-scale velocity quantities ᶜu, ᶠu³, ᶜK based on
327-
# ᶠu₃, and it is also used to set the SGS quantities based on ᶠu₃⁰ and ᶠu₃ʲ.
328-
function set_velocity_quantities!(ᶜu, ᶠu³, ᶜK, ᶠu₃, ᶜuₕ, ᶠuₕ³)
329-
@. ᶜu = C123(ᶜuₕ) + ᶜinterp(C123(ᶠu₃))
330-
@. ᶠu³ = ᶠuₕ³ + CT3(ᶠu₃)
331-
ᶜK .= compute_kinetic(ᶜuₕ, ᶠu₃)
332-
return nothing
333-
end
334327

335328
function set_sgs_ᶠu₃!(w_function, ᶠu₃, Y, turbconv_model)
336329
ρaʲs(sgsʲs) = map(sgsʲ -> sgsʲ.ρa, sgsʲs)
@@ -455,21 +448,24 @@ quantities are updated.
455448
NVTX.@annotate function set_implicit_precomputed_quantities!(Y, p, t)
456449
(; turbconv_model, moisture_model, precip_model) = p.atmos
457450
(; ᶜΦ) = p.core
458-
(; ᶜspecific, ᶜu, ᶠu³, ᶠu, ᶜK, ᶜts, ᶜp, ᶜh_tot) = p.precomputed
451+
(; ᶜspecific, ᶠu, ᶜK, ᶜts, ᶜp, ᶜh_tot) = p.precomputed
459452
ᶠuₕ³ = p.scratch.ᶠtemp_CT3
460453
n = n_mass_flux_subdomains(turbconv_model)
461454
thermo_params = CAP.thermodynamics_params(p.params)
462455
thermo_args = (thermo_params, moisture_model, precip_model)
463456

464457
ᶜspecific .= ᶜspecific_gs_tracers(Y)
465-
@. ᶠuₕ³ = $compute_ᶠuₕ³(Y.c.uₕ, Y.c.ρ)
458+
#@. ᶠuₕ³ = $compute_ᶠuₕ³(Y.c.uₕ, Y.c.ρ)
459+
@. ᶠuₕ³ = $ᶠuₕ³_lazy(Y.c.uₕ, Y.c.ρ)
466460

467461
# TODO: We might want to move this to dss! (and rename dss! to something
468462
# like enforce_constraints!).
469463
set_velocity_at_surface!(Y, ᶠuₕ³, turbconv_model)
470464
set_velocity_at_top!(Y, turbconv_model)
471465

472-
set_velocity_quantities!(ᶜu, ᶠu³, ᶜK, Y.f.u₃, Y.c.uₕ, ᶠuₕ³)
466+
ᶜu = ᶜu_lazy(Y.c.uₕ, Y.f.u₃)
467+
ᶠu³ = ᶠu³_lazy(Y.c.uₕ, Y.c.ρ, Y.f.u₃)
468+
set_velocity_quantities!(ᶠu³, ᶜK, Y.f.u₃, Y.c.uₕ, ᶠuₕ³, Y.c.ρ)
473469
ᶜJ = Fields.local_geometry_field(Y.c).J
474470
@. ᶠu = CT123(ᶠwinterp(Y.c.ρ * ᶜJ, CT12(ᶜu))) + CT123(ᶠu³)
475471
if n > 0
@@ -517,7 +513,7 @@ NVTX.@annotate function set_explicit_precomputed_quantities!(Y, p, t)
517513
(; turbconv_model, moisture_model, precip_model, cloud_model) = p.atmos
518514
(; vert_diff, call_cloud_diagnostics_per_stage) = p.atmos
519515
(; ᶜΦ) = p.core
520-
(; ᶜu, ᶜts, ᶜp) = p.precomputed
516+
(; ᶜts, ᶜp) = p.precomputed
521517
ᶠuₕ³ = p.scratch.ᶠtemp_CT3 # updated in set_implicit_precomputed_quantities!
522518
thermo_params = CAP.thermodynamics_params(p.params)
523519

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_environment!(
2222
(; turbconv_model) = p.atmos
2323
(; ᶜΦ,) = p.core
2424
(; ᶜp, ᶜh_tot, ᶜK) = p.precomputed
25-
(; ᶜtke⁰, ᶜρa⁰, ᶠu₃⁰, ᶜu⁰, ᶠu³⁰, ᶜK⁰, ᶜts⁰, ᶜρ⁰, ᶜmse⁰, ᶜq_tot⁰) =
25+
(; ᶜtke⁰, ᶜρa⁰, ᶠu₃⁰, ᶠu³⁰, ᶜK⁰, ᶜts⁰, ᶜρ⁰, ᶜmse⁰, ᶜq_tot⁰) =
2626
p.precomputed
2727
if p.atmos.moisture_model isa NonEquilMoistModel &&
2828
p.atmos.precip_model isa Microphysics1Moment
@@ -77,7 +77,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_environment!(
7777
)
7878
end
7979
set_sgs_ᶠu₃!(u₃⁰, ᶠu₃⁰, Y, turbconv_model)
80-
set_velocity_quantities!(ᶜu⁰, ᶠu³⁰, ᶜK⁰, ᶠu₃⁰, Y.c.uₕ, ᶠuₕ³)
80+
set_velocity_quantities!(ᶠu³⁰, ᶜK⁰, ᶠu₃⁰, Y.c.uₕ, ᶠuₕ³, Y.c.ρ)
8181
# @. ᶜK⁰ += ᶜtke⁰
8282
if p.atmos.moisture_model isa NonEquilMoistModel &&
8383
p.atmos.precip_model isa Microphysics1Moment
@@ -132,7 +132,8 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft!(
132132
ᶜq_snoʲ = Y.c.sgsʲs.:($j).q_sno
133133
end
134134

135-
set_velocity_quantities!(ᶜuʲ, ᶠu³ʲ, ᶜKʲ, ᶠu₃ʲ, Y.c.uₕ, ᶠuₕ³)
135+
set_velocity_quantities!(ᶜuʲ, ᶜKʲ, ᶠu₃ʲ, Y.c.uₕ, ᶠuₕ³, ᶜρʲ)
136+
136137
@. ᶠKᵥʲ = (adjoint(CT3(ᶠu₃ʲ)) * ᶠu₃ʲ) / 2
137138
if p.atmos.moisture_model isa NonEquilMoistModel &&
138139
p.atmos.precip_model isa Microphysics1Moment
@@ -367,7 +368,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_explicit_clos
367368
FT = eltype(params)
368369
n = n_mass_flux_subdomains(turbconv_model)
369370

370-
(; ᶜtke⁰, ᶜu, ᶜp, ᶜρa⁰, ᶠu³⁰, ᶜts⁰, ᶜq_tot⁰) = p.precomputed
371+
(; ᶜtke⁰, ᶜp, ᶜρa⁰, ᶠu³⁰, ᶜts⁰, ᶜq_tot⁰) = p.precomputed
371372
(;
372373
ᶜmixing_length_tuple,
373374
ᶜmixing_length,
@@ -398,6 +399,9 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_explicit_clos
398399
ᶜvert_div = p.scratch.ᶜtemp_scalar
399400
ᶜmassflux_vert_div = p.scratch.ᶜtemp_scalar_2
400401
ᶜw_vert_div = p.scratch.ᶜtemp_scalar_3
402+
403+
ᶜu = Base.materialize(ᶜu_lazy(Y.c.uₕ, Y.f.u₃))
404+
401405
for j in 1:n
402406
# entrainment/detrainment
403407
@. ᶜentrʲs.:($$j) = entrainment(

src/diagnostics/Diagnostics.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import ..PrognosticSurfaceTemperature
5858
import ..draft_area
5959
import ..compute_gm_mixing_length!
6060
import ..horizontal_integral_at_boundary
61+
import ..ᶜu_lazy
6162

6263
# We need the abbreviations for symbols like curl, grad, and so on
6364
include(joinpath("..", "utils", "abbreviations.jl"))

src/diagnostics/core_diagnostics.jl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ add_diagnostic_variable!(
7474
comments = "Eastward (zonal) wind component",
7575
compute! = (out, state, cache, time) -> begin
7676
if isnothing(out)
77-
return copy(u_component.(Geometry.UVector.(cache.precomputed.ᶜu)))
77+
return copy(u_component.(Geometry.UVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃))))
7878
else
79-
out .= u_component.(Geometry.UVector.(cache.precomputed.ᶜu))
79+
out .= u_component.(Geometry.UVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃)))
8080
end
8181
end,
8282
)
@@ -92,9 +92,9 @@ add_diagnostic_variable!(
9292
comments = "Northward (meridional) wind component",
9393
compute! = (out, state, cache, time) -> begin
9494
if isnothing(out)
95-
return copy(v_component.(Geometry.VVector.(cache.precomputed.ᶜu)))
95+
return copy(v_component.(Geometry.VVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃))))
9696
else
97-
out .= v_component.(Geometry.VVector.(cache.precomputed.ᶜu))
97+
out .= v_component.(Geometry.VVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃)))
9898
end
9999
end,
100100
)
@@ -199,7 +199,8 @@ add_diagnostic_variable!(
199199
units = "s^-1",
200200
comments = "Vertical component of relative vorticity",
201201
compute! = (out, state, cache, time) -> begin
202-
vort = @. w_component.(Geometry.WVector(curlₕ(cache.precomputed.ᶜu)))
202+
ᶜu = Base.materialize(ᶜu_lazy(state.c.uₕ, state.f.u₃))
203+
vort = @. w_component.(Geometry.WVector(curlₕ(ᶜu)))
203204
# We need to ensure smoothness, so we call DSS
204205
Spaces.weighted_dss!(vort)
205206
if isnothing(out)
@@ -552,13 +553,13 @@ add_diagnostic_variable!(
552553
if isnothing(out)
553554
return copy(
554555
u_component.(
555-
Geometry.UVector.(Fields.level(cache.precomputed.ᶜu, 1)),
556+
Geometry.UVector.(Fields.level(Base.materialize(ᶜu_lazy(state.c.uₕ, state.f.u₃)), 1)),
556557
),
557558
)
558559
else
559560
out .=
560561
u_component.(
561-
Geometry.UVector.(Fields.level(cache.precomputed.ᶜu, 1)),
562+
Geometry.UVector.(Fields.level(Base.materialize(ᶜu_lazy(state.c.uₕ, state.f.u₃)), 1)),
562563
)
563564
end
564565
end,
@@ -577,13 +578,13 @@ add_diagnostic_variable!(
577578
if isnothing(out)
578579
return copy(
579580
v_component.(
580-
Geometry.VVector.(Fields.level(cache.precomputed.ᶜu, 1)),
581-
),
581+
Geometry.UVector.(Fields.level(Base.materialize(ᶜu_lazy(state.c.uₕ, state.f.u₃)), 1)),
582+
)
582583
)
583584
else
584585
out .=
585586
v_component.(
586-
Geometry.VVector.(Fields.level(cache.precomputed.ᶜu, 1)),
587+
Geometry.UVector.(Fields.level(Base.materialize(ᶜu_lazy(state.c.uₕ, state.f.u₃)), 1)),
587588
)
588589
end
589590
end,
@@ -1369,11 +1370,11 @@ add_diagnostic_variable!(
13691370
comments = "Error of steady-state eastward (zonal) wind component",
13701371
compute! = (out, state, cache, time) -> begin
13711372
if isnothing(out)
1372-
u_component.(Geometry.UVWVector.(cache.precomputed.ᶜu)) .-
1373-
u_component.(cache.steady_state_velocity.ᶜu)
1373+
u_component.(Geometry.UVWVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃))) .-
1374+
u_component.(cache.steady_state_velocity.ᶜu)
13741375
else
13751376
out .=
1376-
u_component.(Geometry.UVWVector.(cache.precomputed.ᶜu)) .-
1377+
u_component.(Geometry.UVWVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃))) .-
13771378
u_component.(cache.steady_state_velocity.ᶜu)
13781379
end
13791380
end,
@@ -1387,11 +1388,11 @@ add_diagnostic_variable!(
13871388
comments = "Error of steady-state northward (meridional) wind component",
13881389
compute! = (out, state, cache, time) -> begin
13891390
if isnothing(out)
1390-
v_component.(Geometry.UVWVector.(cache.precomputed.ᶜu)) .-
1391-
v_component.(cache.steady_state_velocity.ᶜu)
1391+
v_component.(Geometry.UVWVector.(ᶜu_lazy(state.c.uₕ,state.f.u₃))) .-
1392+
v_component.(cache.steady_state_velocity.ᶜu)
13921393
else
13931394
out .=
1394-
v_component.(Geometry.UVWVector.(cache.precomputed.ᶜu)) .-
1395+
v_component.(Geometry.UVWVector.(ᶜu_lazy(state.c.uₕ, state.f.u₃))) .-
13951396
v_component.(cache.steady_state_velocity.ᶜu)
13961397
end
13971398
end,

src/parameterized_tendencies/les_sgs_models/smagorinsky_lilly.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function set_smagorinsky_lilly_precomputed_quantities!(Y, p)
3030
(; atmos, precomputed, scratch, params) = p
3131
c_smag = CAP.c_smag(params)
3232
Pr_t = CAP.Prandtl_number_0(CAP.turbconv_params(params))
33-
(; ᶜu, ᶠu³, ᶜts, ᶜτ_smag, ᶠτ_smag, ᶜD_smag, ᶠD_smag) = precomputed
33+
(; ᶜts, ᶜτ_smag, ᶠτ_smag, ᶜD_smag, ᶠD_smag) = precomputed
3434
FT = eltype(Y)
3535
grav = CAP.grav(params)
3636
thermo_params = CAP.thermodynamics_params(params)
@@ -46,6 +46,8 @@ function set_smagorinsky_lilly_precomputed_quantities!(Y, p)
4646
axis_uvw = (Geometry.UVWAxis(),)
4747

4848
# Compute UVW velocities
49+
ᶜu = ᶜu_lazy(Y.c.uₕ, Y.f.u₃)
50+
ᶠu³ = ᶠu³_lazy(Y.c.uₕ, Y.c.ρ, Y.f.u₃)
4951
ᶜu_uvw = @. ᶜtemp_UVW = UVW(ᶜu)
5052
ᶠu_uvw = @. ᶠtemp_UVW = UVW(ᶠinterp(Y.c.uₕ)) + UVW(ᶠu³)
5153

0 commit comments

Comments
 (0)