Skip to content

Commit 081b9ad

Browse files
Add tracer name to foreach_tracer
1 parent b06e174 commit 081b9ad

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/parameterized_tendencies/les_sgs_models/smagorinsky_lilly.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ 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 ᶜρχₜ, ᶜρχ, is_ρq_tot
110+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
111111
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
112112
ᶜρχₜ_diffusion = @. lazy(wdivₕ(Y.c.ρ * ᶜD_smag * gradₕ(ᶜχ)))
113113
@. ᶜρχₜ += ᶜρχₜ_diffusion
@@ -161,7 +161,7 @@ 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 ᶜρχₜ, ᶜρχ, is_ρq_tot
164+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
165165
ᶜ∇ᵥρD∇χₜ = @. lazy(ᶜdivᵥ_ρχ(-(ᶠρ * ᶠD_smag * ᶠgradᵥ(specific(ᶜρχ, Y.c.ρ)))))
166166
@. ᶜρχₜ -= ᶜ∇ᵥρD∇χₜ
167167
# Rain and snow does not affect the mass

src/prognostic_equations/advection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ 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 ᶜρχₜ, ᶜρχ, is_ρq_tot
216+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
217217
if !is_ρq_tot
218218
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
219219
vtt = vertical_transport(ᶜρ, ᶠu³, ᶜχ, float(dt), tracer_upwinding)

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 ᶜρχₜ, ᶜρχ, is_ρq_tot
169+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ 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 ᶜρχₜ, ᶜρχ, is_ρq_tot
118+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
119119
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
120120
if is_ρq_tot
121121
@. ρ_flux_χ = sfc_conditions.ρ_flux_q_tot

src/prognostic_equations/vertical_diffusion_boundary_layer.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ 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 ᶜρχₜ, ᶜρχ, is_ρq_tot
104-
if ρχ_name in (:ρq_rai, :ρq_sno, :ρn_rai)
103+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
104+
if ρχ_name in (@name(ρq_rai), @name(ρq_sno), @name(ρn_rai))
105105
@. ᶜK_h_scaled = α_vert_diff_tracer * ᶜK_h
106106
else
107107
@. ᶜK_h_scaled = ᶜK_h

src/utils/variable_manipulations.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ the current tracer is `ρq_tot` (to allow for special handling).
8585
8686
Arguments:
8787
88-
- `f`: A function to apply to each scalar. It must have the signature
89-
`f(ᶜρχₜ, ᶜρχ, is_ρq_tot)`, where `ᶜρχₜ` is the tendency field, `ᶜρχ` is
90-
the state field, and `is_ρq_tot` is a `Bool`.
88+
- `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`.
9191
- `Yₜ`: The tendency state vector.
9292
- `Y`: The current state vector.
9393
9494
# Example
9595
9696
```julia
97-
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, is_ρq_tot
97+
foreach_tracer(Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name, is_ρq_tot
9898
# Apply some operation, e.g., a sponge layer
9999
@. ᶜρχₜ += some_sponge_function(ᶜρχ)
100100
if is_ρq_tot
@@ -108,7 +108,7 @@ foreach_tracer(f::F, Yₜ, Y) where {F} =
108108
ᶜρχₜ = MatrixFields.get_field(Yₜ.c, scalar_name)
109109
ᶜρχ = MatrixFields.get_field(Y.c, scalar_name)
110110
is_ρq_tot = scalar_name == @name(ρq_tot)
111-
f(ᶜρχₜ, ᶜρχ, is_ρq_tot)
111+
f(ᶜρχₜ, ᶜρχ, scalar_name, is_ρq_tot)
112112
end
113113

114114
"""

0 commit comments

Comments
 (0)