@@ -120,6 +120,8 @@ function horizontal_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLill
120120
121121end
122122
123+ import UnrolledUtilities as UU
124+
123125function 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
173179end
0 commit comments