Skip to content

Commit 685d858

Browse files
Use LazyBroadcast in set_velocity_quantities
1 parent 799fb93 commit 685d858

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/cache/precomputed_quantities.jl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,27 @@ function set_velocity_at_top!(Y, turbconv_model)
310310
return nothing
311311
end
312312

313+
"""
314+
compute_ᶜu(ᶜuₕ, ᶠu₃)
315+
Computes the cell-centered velocity, given
316+
- `ᶜuₕ` the cell-centered horizontal velocity
317+
- `ᶠu₃` the cell-face `Covariant3` velocity
318+
"""
319+
compute_ᶜu(ᶜuₕ, ᶠu₃) = @. lazy(C123(ᶜuₕ) + ᶜinterp(C123(ᶠu₃)))
320+
321+
"""
322+
compute_ᶠu³(ᶠuₕ³, ᶠu₃)
323+
Computes the cell-face contravariant velocity, given
324+
- `ᶠuₕ³` the cell-face horizontal `Contravariant3` velocity
325+
- `ᶠu₃` the cell-face `Covariant3` velocity
326+
"""
327+
compute_ᶠu³(ᶠuₕ³, ᶠu₃) = ᶠuₕ³ + CT3(ᶠu₃)
328+
313329
# This is used to set the grid-scale velocity quantities ᶜu, ᶠu³, ᶜK based on
314330
# ᶠu₃, and it is also used to set the SGS quantities based on ᶠu₃⁰ and ᶠu₃ʲ.
315331
function set_velocity_quantities!(ᶜu, ᶠu³, ᶜK, ᶠu₃, ᶜuₕ, ᶠuₕ³)
316-
@. ᶜu = C123(ᶜuₕ) + ᶜinterp(C123(ᶠu₃))
317-
@. ᶠu³ = ᶠuₕ³ + CT3(ᶠu₃)
332+
ᶜu .= compute_ᶜu(ᶜuₕ, ᶠu₃)
333+
ᶠu³ .= compute_ᶠu³.(ᶠuₕ³, ᶠu₃)
318334
ᶜK .= compute_kinetic(ᶜuₕ, ᶠu₃)
319335
return nothing
320336
end
@@ -451,7 +467,7 @@ NVTX.@annotate function set_implicit_precomputed_quantities!(Y, p, t)
451467
thermo_args = (thermo_params, moisture_model, precip_model)
452468

453469
@. ᶜspecific = specific_gs(Y.c)
454-
@. ᶠuₕ³ = $compute_ᶠuₕ³(Y.c.uₕ, Y.c.ρ)
470+
ᶠuₕ³ .= compute_ᶠuₕ³(Y.c.uₕ, Y.c.ρ)
455471

456472
# TODO: We might want to move this to dss! (and rename dss! to something
457473
# like enforce_constraints!).

0 commit comments

Comments
 (0)