Skip to content

Commit aef46a5

Browse files
Remove is_ρq_tot
1 parent 081b9ad commit aef46a5

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

src/parameterized_tendencies/les_sgs_models/smagorinsky_lilly.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ function horizontal_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLill
107107
@. Yₜ.c.ρe_tot += wdivₕ(Y.c.ρ * ᶜD_smag * gradₕ(ᶜh_tot))
108108

109109
## Tracer diffusion and associated mass changes
110-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
110+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
111111
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
112112
ᶜρχₜ_diffusion = @. lazy(wdivₕ(Y.c.ρ * ᶜD_smag * gradₕ(ᶜχ)))
113113
@. ᶜρχₜ += ᶜρχₜ_diffusion
114114
# Rain and snow does not affect the mass
115-
if is_ρq_tot
115+
if ρχ_name == @name(ρq_tot)
116116
@. Yₜ.c.ρ += ᶜρχₜ_diffusion
117117
end
118118
end
@@ -161,11 +161,11 @@ function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
161161
bottom = Operators.SetValue(C3(FT(0))),
162162
)
163163

164-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
164+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
165165
ᶜ∇ᵥρD∇χₜ = @. lazy(ᶜdivᵥ_ρχ(-(ᶠρ * ᶠD_smag * ᶠgradᵥ(specific(ᶜρχ, Y.c.ρ)))))
166166
@. ᶜρχₜ -= ᶜ∇ᵥρD∇χₜ
167167
# Rain and snow does not affect the mass
168-
if is_ρq_tot
168+
if ρχ_name == @name(ρq_tot)
169169
@. Yₜ.c.ρ -= ᶜ∇ᵥρD∇χₜ
170170
end
171171
end

src/prognostic_equations/advection.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ NVTX.@annotate function explicit_vertical_advection_tendency!(Yₜ, Y, p, t)
213213
ᶜρ = Y.c.ρ
214214

215215
# Full vertical advection of passive tracers (like liq, rai, etc) ...
216-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
217-
if !is_ρq_tot
216+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
217+
if !(ρχ_name in (@name(ρe_tot), @name(ρq_tot)))
218218
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
219219
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜχ, float(dt), tracer_upwinding)
220220
@. ᶜρχₜ += vtt

src/prognostic_equations/remaining_tendency.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ NVTX.@annotate function additional_tendency!(Yₜ, Y, p, t)
166166
@. Yₜ.c.ρe_tot += vst_ρe_tot
167167

168168
# TODO: can we write this out explicitly?
169-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
169+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
170170
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
171171
vst_tracer = viscous_sponge_tendency_tracer(ᶜρ, ᶜχ, viscous_sponge)
172172
@. ᶜρχₜ += vst_tracer

src/prognostic_equations/surface_flux.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ function surface_flux_tendency!(Yₜ, Y, p, t)
115115
btt = boundary_tendency_scalar(ᶜh_tot, sfc_conditions.ρ_flux_h_tot)
116116
@. Yₜ.c.ρe_tot -= btt
117117
ρ_flux_χ = p.scratch.sfc_temp_C3
118-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
118+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
119119
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
120-
if is_ρq_tot
120+
if ρχ_name == @name(ρq_tot)
121121
@. ρ_flux_χ = sfc_conditions.ρ_flux_q_tot
122122
else
123123
@. ρ_flux_χ = C3(FT(0))
124124
end
125125
btt = boundary_tendency_scalar(ᶜχ, ρ_flux_χ)
126126
@. ᶜρχₜ -= btt
127-
if is_ρq_tot
127+
if ρχ_name == @name(ρq_tot)
128128
@. Yₜ.c.ρ -= btt
129129
end
130130
end

src/prognostic_equations/vertical_diffusion_boundary_layer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function vertical_diffusion_boundary_layer_tendency!(
100100
top = Operators.SetValue(C3(0)),
101101
bottom = Operators.SetValue(C3(0)),
102102
)
103-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
103+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
104104
if ρχ_name in (@name(ρq_rai), @name(ρq_sno), @name(ρn_rai))
105105
@. ᶜK_h_scaled = α_vert_diff_tracer * ᶜK_h
106106
else
@@ -111,7 +111,7 @@ function vertical_diffusion_boundary_layer_tendency!(
111111
@. ᶜρχₜ -= ᶜρχₜ_diffusion
112112
# Only add contribution from total water diffusion to mass tendency
113113
# (exclude contributions from diffusion of condensate, precipitation)
114-
if is_ρq_tot
114+
if ρχ_name == @name(ρq_tot)
115115
@. Yₜ.c.ρ -= ᶜρχₜ_diffusion
116116
end
117117
end

src/utils/variable_manipulations.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ the current tracer is `ρq_tot` (to allow for special handling).
8686
Arguments:
8787
8888
- `f`: A function to apply to each scalar. It must have the signature `f
89-
(ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot)`, where `ᶜρχₜ` is the tendency field, `ᶜρχ`
90-
is the state field, and `is_ρq_tot` is a `Bool`.
89+
(ᶜρχₜ, ᶜρχ, ρχ_name)`, where `ᶜρχₜ` is the tendency field, `ᶜρχ`
90+
is the state field, and `ρχ_name` is a `MatrixFields.@name` object.
9191
- `Yₜ`: The tendency state vector.
9292
- `Y`: The current state vector.
9393
9494
# Example
9595
9696
```julia
97-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
97+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
9898
# Apply some operation, e.g., a sponge layer
9999
@. ᶜρχₜ += some_sponge_function(ᶜρχ)
100-
if is_ρq_tot
100+
if ρχ_name == @name(ρq_tot)
101101
# Perform an additional operation only for ρq_tot
102102
end
103103
end
@@ -107,8 +107,7 @@ foreach_tracer(f::F, Yₜ, Y) where {F} =
107107
unrolled_foreach(tracer_names(Y.c)) do scalar_name
108108
ᶜρχₜ = MatrixFields.get_field(Yₜ.c, scalar_name)
109109
ᶜρχ = MatrixFields.get_field(Y.c, scalar_name)
110-
is_ρq_tot = scalar_name == @name(ρq_tot)
111-
f(ᶜρχₜ, ᶜρχ, scalar_name, is_ρq_tot)
110+
f(ᶜρχₜ, ᶜρχ, scalar_name)
112111
end
113112

114113
"""

0 commit comments

Comments
 (0)