Skip to content

Commit 4c3ed68

Browse files
Put set_velocity_quantities back in, leverage funcs
1 parent 3e807ee commit 4c3ed68

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

src/cache/precomputed_quantities.jl

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,33 @@ function set_velocity_at_top!(Y, turbconv_model)
237237
return nothing
238238
end
239239

240+
"""
241+
compute_ᶜu(ᶜuₕ, ᶠu₃)
242+
243+
Computes the cell-centered velocity, given
244+
245+
- `ᶜuₕ` the cell-centered horizontal velocity
246+
- `ᶠu₃` the cell-face `Covariant3` velocity
247+
"""
248+
compute_ᶜu(ᶜuₕ, ᶠu₃) = @. lazy(C123(ᶜuₕ) + ᶜinterp(C123(ᶠu₃)))
249+
250+
"""
251+
compute_ᶠu³(ᶠuₕ³, ᶠu₃)
252+
253+
Computes the cell-face contravariant velocity, given
254+
255+
- `ᶠuₕ³` the cell-face horizontal `Contravariant3` velocity
256+
- `ᶠu₃` the cell-face `Covariant3` velocity
257+
"""
258+
compute_ᶠu³(ᶠuₕ³, ᶠu₃) = ᶠuₕ³ + CT3(ᶠu₃)
259+
240260
# This is used to set the grid-scale velocity quantities ᶜu, ᶠu³, ᶜK based on
241261
# ᶠu₃, and it is also used to set the SGS quantities based on ᶠu₃⁰ and ᶠu₃ʲ.
242-
compute_ᶜu(ᶜuₕ, ᶠu₃) = @lazy @. C123(ᶜuₕ) + ᶜinterp(C123(ᶠu₃))
243-
function compute_ᶠu³(ᶜuₕ, ᶜρ, ᶠu₃)
244-
ᶠuₕ³ = compute_ᶠuₕ³(ᶜuₕ, ᶜρ)
245-
return @lazy @. ᶠuₕ³ + CT3(ᶠu₃)
262+
function set_velocity_quantities!(ᶜu, ᶠu³, ᶜK, ᶠu₃, ᶜuₕ, ᶜρ)
263+
ᶜu .= compute_ᶜu(ᶜuₕ, ᶠu₃)
264+
ᶠu³ .= compute_ᶠu³.(compute_ᶠuₕ³(ᶜuₕ, ᶜρ), ᶠu₃)
265+
ᶜK .= compute_kinetic(ᶜuₕ, ᶠu₃)
266+
return nothing
246267
end
247268

248269
function set_sgs_ᶠu₃!(w_function, ᶠu₃, Y, turbconv_model)
@@ -390,9 +411,7 @@ NVTX.@annotate function set_precomputed_quantities!(Y, p, t)
390411
set_velocity_at_surface!(Y, ᶠuₕ³, turbconv_model)
391412
set_velocity_at_top!(Y, turbconv_model)
392413

393-
ᶠu³ .= compute_ᶠu³(ᶜuₕ, ᶜρ, ᶠu₃)
394-
ᶜu .= compute_ᶜu(ᶜuₕ, ᶠu₃)
395-
ᶜK .= compute_kinetic(ᶜuₕ, ᶠu₃)
414+
set_velocity_quantities!(ᶜu, ᶠu³, ᶜK, Y.f.u₃, Y.c.uₕ, ᶜρ)
396415

397416
if n > 0
398417
# TODO: In the following increments to ᶜK, we actually need to add

src/cache/prognostic_edmf_precomputed_quantities.jl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_environment!(
4444
turbconv_model,
4545
)
4646
set_sgs_ᶠu₃!(u₃⁰, ᶠu₃⁰, Y, turbconv_model)
47-
ᶠu³⁰ .= compute_ᶠu³(ᶜuₕ, ᶜρ, ᶠu₃)
48-
ᶜu⁰ .= compute_ᶜu(ᶜuₕ, ᶠu₃⁰)
49-
ᶜK⁰ .= compute_kinetic(ᶜuₕ, ᶠu₃⁰)
47+
set_velocity_quantities!(ᶜu⁰, ᶠu³⁰, ᶜK⁰, ᶠu₃⁰, Y.c.uₕ, ᶜρ)
5048

5149
# @. ᶜK⁰ += ᶜtke⁰
5250
@. ᶜts⁰ = TD.PhaseEquil_phq(thermo_params, ᶜp, ᶜmse⁰ - ᶜΦ, ᶜq_tot⁰)
@@ -95,9 +93,7 @@ NVTX.@annotate function set_prognostic_edmf_precomputed_quantities_draft_and_bc!
9593
ᶜmseʲ = Y.c.sgsʲs.:($j).mse
9694
ᶜq_totʲ = Y.c.sgsʲs.:($j).q_tot
9795

98-
ᶠu³ʲ .= compute_ᶠu³(ᶜuₕ, ᶜρ, ᶠu₃)
99-
ᶜuʲ .= compute_ᶜu(ᶜuₕ, ᶠu₃ʲ)
100-
ᶜKʲ .= compute_kinetic(ᶜuₕ, ᶠu₃ʲ)
96+
set_velocity_quantities!(ᶜuʲ, ᶠu³ʲ, ᶜKʲ, ᶠu₃ʲ, Y.c.uₕ, ᶜρ)
10197

10298
@. ᶠKᵥʲ = (adjoint(CT3(ᶠu₃ʲ)) * ᶠu₃ʲ) / 2
10399
@. ᶜtsʲ = TD.PhaseEquil_phq(thermo_params, ᶜp, ᶜmseʲ - ᶜΦ, ᶜq_totʲ)

0 commit comments

Comments
 (0)