Skip to content

Commit 50ead43

Browse files
committed
merge set explicit and implicit precomputed quantities; they don't have to be split after the new update of updraft BCs
1 parent b3696f7 commit 50ead43

File tree

1 file changed

+14
-53
lines changed

1 file changed

+14
-53
lines changed

src/cache/precomputed_quantities.jl

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -442,31 +442,20 @@ end
442442

443443
"""
444444
set_implicit_precomputed_quantities!(Y, p, t)
445-
set_implicit_precomputed_quantities_part1!(Y, p, t)
446-
set_implicit_precomputed_quantities_part2!(Y, p, t)
447445
448-
Update the precomputed quantities that are handled implicitly based on the
449-
current state `Y`. These are called before each evaluation of either
450-
`implicit_tendency!` or `remaining_tendency!`, and they include quantities used
446+
Updates the precomputed quantities that are handled implicitly based on the
447+
current state `Y`. This is called before each evaluation of either
448+
`implicit_tendency!` or `remaining_tendency!`, and it includes quantities used
451449
in both tedencies.
452450
453-
These functions also apply a "filter" to `Y` in order to ensure that `ᶠu³` is 0
451+
This function also applies a "filter" to `Y` in order to ensure that `ᶠu³` is 0
454452
at the surface (i.e., to enforce the impenetrable boundary condition). If the
455453
`turbconv_model` is EDMFX, the filter also ensures that `ᶠu³⁰` and `ᶠu³ʲs` are 0
456454
at the surface. In the future, we will probably want to move this filtering
457455
elsewhere, but doing it here ensures that it occurs whenever the precomputed
458456
quantities are updated.
459-
460-
These functions are split into two parts so that the first stage of the implicit
461-
and explicit calculations can be executed in sequence before completing the
462-
remaining steps. This ordering is required to correctly compute variables at
463-
the environment boundary after applying the boundary conditions.
464457
"""
465458
NVTX.@annotate function set_implicit_precomputed_quantities!(Y, p, t)
466-
set_implicit_precomputed_quantities_part1!(Y, p, t)
467-
set_implicit_precomputed_quantities_part2!(Y, p, t)
468-
end
469-
NVTX.@annotate function set_implicit_precomputed_quantities_part1!(Y, p, t)
470459
(; turbconv_model, moisture_model, microphysics_model) = p.atmos
471460
(; ᶜΦ) = p.core
472461
(; ᶜu, ᶠu³, ᶠu, ᶜK, ᶜts, ᶜp) = p.precomputed
@@ -505,16 +494,6 @@ NVTX.@annotate function set_implicit_precomputed_quantities_part1!(Y, p, t)
505494

506495
if turbconv_model isa PrognosticEDMFX
507496
set_prognostic_edmf_precomputed_quantities_draft!(Y, p, ᶠuₕ³, t)
508-
elseif !(isnothing(turbconv_model))
509-
# Do nothing for other turbconv models for now
510-
end
511-
end
512-
NVTX.@annotate function set_implicit_precomputed_quantities_part2!(Y, p, t)
513-
(; turbconv_model) = p.atmos
514-
ᶠuₕ³ = p.scratch.ᶠtemp_CT3
515-
@. ᶠuₕ³ = $compute_ᶠuₕ³(Y.c.uₕ, Y.c.ρ)
516-
517-
if turbconv_model isa PrognosticEDMFX
518497
set_prognostic_edmf_precomputed_quantities_environment!(Y, p, ᶠuₕ³, t)
519498
set_prognostic_edmf_precomputed_quantities_implicit_closures!(Y, p, t)
520499
elseif !(isnothing(turbconv_model))
@@ -523,21 +502,16 @@ NVTX.@annotate function set_implicit_precomputed_quantities_part2!(Y, p, t)
523502
end
524503

525504
"""
526-
set_explicit_precomputed_quantities_part1!(Y, p, t)
527-
set_explicit_precomputed_quantities_part2!(Y, p, t)
505+
set_explicit_precomputed_quantities!(Y, p, t)
528506
529-
Update the precomputed quantities that are handled explicitly based on the
530-
current state `Y`. These are only called before each evaluation of
531-
`remaining_tendency!`, though they include quantities used in both
507+
Updates the precomputed quantities that are handled explicitly based on the
508+
current state `Y`. This is only called before each evaluation of
509+
`remaining_tendency!`, though it includes quantities used in both
532510
`implicit_tendency!` and `remaining_tendency!`.
533-
534-
These functions are split into two parts so that the first stage of the implicit
535-
and explicit calculations can be executed in sequence before completing the
536-
remaining steps. This ordering is required to correctly compute variables at
537-
the environment boundary after applying the boundary conditions.
538511
"""
539-
NVTX.@annotate function set_explicit_precomputed_quantities_part1!(Y, p, t)
540-
(; turbconv_model) = p.atmos
512+
NVTX.@annotate function set_explicit_precomputed_quantities!(Y, p, t)
513+
(; turbconv_model, moisture_model, cloud_model) = p.atmos
514+
(; call_cloud_diagnostics_per_stage) = p.atmos
541515
(; ᶜts) = p.precomputed
542516
thermo_params = CAP.thermodynamics_params(p.params)
543517
FT = eltype(p.params)
@@ -553,18 +527,6 @@ NVTX.@annotate function set_explicit_precomputed_quantities_part1!(Y, p, t)
553527
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts)))
554528
end
555529

556-
if turbconv_model isa DiagnosticEDMFX
557-
set_diagnostic_edmf_precomputed_quantities_bottom_bc!(Y, p, t)
558-
elseif !(isnothing(turbconv_model))
559-
# Do nothing for other turbconv models for now
560-
end
561-
562-
return nothing
563-
end
564-
NVTX.@annotate function set_explicit_precomputed_quantities_part2!(Y, p, t)
565-
(; turbconv_model, moisture_model, cloud_model) = p.atmos
566-
(; call_cloud_diagnostics_per_stage) = p.atmos
567-
568530
# The buoyancy gradient depends on the cloud fraction, and the cloud fraction
569531
# depends on the mixing length, which depends on the buoyancy gradient.
570532
# We break this circular dependency by using cloud fraction from the previous time step in the
@@ -583,6 +545,7 @@ NVTX.@annotate function set_explicit_precomputed_quantities_part2!(Y, p, t)
583545
)
584546
end
585547
if turbconv_model isa DiagnosticEDMFX
548+
set_diagnostic_edmf_precomputed_quantities_bottom_bc!(Y, p, t)
586549
set_diagnostic_edmf_precomputed_quantities_do_integral!(Y, p, t)
587550
set_diagnostic_edmf_precomputed_quantities_top_bc!(Y, p, t)
588551
set_diagnostic_edmf_precomputed_quantities_env_closures!(Y, p, t)
@@ -634,8 +597,6 @@ end
634597
Updates all precomputed quantities based on the current state `Y`.
635598
"""
636599
function set_precomputed_quantities!(Y, p, t)
637-
set_implicit_precomputed_quantities_part1!(Y, p, t)
638-
set_explicit_precomputed_quantities_part1!(Y, p, t)
639-
set_implicit_precomputed_quantities_part2!(Y, p, t)
640-
set_explicit_precomputed_quantities_part2!(Y, p, t)
600+
set_implicit_precomputed_quantities!(Y, p, t)
601+
set_explicit_precomputed_quantities!(Y, p, t)
641602
end

0 commit comments

Comments
 (0)