Skip to content

Commit 5495081

Browse files
Remove use of matching subfields
1 parent 3443adb commit 5495081

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/parameterized_tendencies/les_sgs_models/smagorinsky_lilly.jl

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function horizontal_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLill
120120

121121
end
122122

123+
import UnrolledUtilities as UU
124+
123125
function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
124126
FT = eltype(Y)
125127
(; sfc_temp_C3, ᶠtemp_scalar, ᶜtemp_scalar) = p.scratch
@@ -155,19 +157,23 @@ function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
155157
@. Yₜ.c.ρe_tot -= ᶜdivᵥ_ρe_tot(-(ᶠρ * ᶠD_smag * ᶠgradᵥ(ᶜh_tot)))
156158

157159
## Tracer diffusion and associated mass changes
158-
for (ᶜρχₜ, ᶜχ, χ_name) in CA.matching_subfields(Yₜ.c, ᶜspecific)
159-
χ_name == :e_tot && continue
160-
161-
ᶜdivᵥ_ρχ = Operators.DivergenceF2C(;
162-
top = Operators.SetValue(C3(FT(0))),
163-
bottom = Operators.SetValue(C3(FT(0))),
164-
)
165-
166-
ᶜ∇ᵥρD∇χₜ = @. ᶜtemp_scalar = ᶜdivᵥ_ρχ(-(ᶠρ * ᶠD_smag * ᶠgradᵥ(ᶜχ)))
167-
@. ᶜρχₜ -= ᶜ∇ᵥρD∇χₜ
168-
# Rain and snow does not affect the mass
169-
if χ_name == :q_tot
170-
@. Yₜ.c.ρ -= ᶜ∇ᵥρD∇χₜ
160+
UU.unrolled_foreach(filter(is_tracer_var, propertynames(Yₜ.c))) do ρχ_name
161+
if ρχ_name != :ρe_tot
162+
ᶜρχ = getproperty(Y.c, ρχ_name)
163+
ᶜρχₜ = getproperty(Yₜ.c, ρχ_name)
164+
ᶜχ = @. lazy(specific(ᶜρχ, Y.c.ρ))
165+
166+
ᶜdivᵥ_ρχ = Operators.DivergenceF2C(;
167+
top = Operators.SetValue(C3(FT(0))),
168+
bottom = Operators.SetValue(C3(FT(0))),
169+
)
170+
171+
ᶜ∇ᵥρD∇χₜ = @. ᶜtemp_scalar = ᶜdivᵥ_ρχ(-(ᶠρ * ᶠD_smag * ᶠgradᵥ(ᶜχ)))
172+
@. ᶜρχₜ -= ᶜ∇ᵥρD∇χₜ
173+
# Rain and snow does not affect the mass
174+
if ρχ_name == :ρq_tot
175+
@. Yₜ.c.ρ -= ᶜ∇ᵥρD∇χₜ
176+
end
171177
end
172178
end
173179
end

0 commit comments

Comments
 (0)