@@ -107,22 +107,23 @@ 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- for (ᶜρχₜ, ᶜχ, χ_name) in CA. matching_subfields (Yₜ. c, ᶜspecific)
111- χ_name == :e_tot && continue
112- ᶜρχₜ_diffusion =
113- @. p. scratch. ᶜtemp_scalar = wdivₕ (Y. c. ρ * ᶜD_smag * gradₕ (ᶜχ))
110+ foreach_gs_tracer (Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
111+ ᶜχ = @. lazy (specific (ᶜρχ, Y. c. ρ))
112+ ᶜρχₜ_diffusion = @. lazy (wdivₕ (Y. c. ρ * ᶜD_smag * gradₕ (ᶜχ)))
114113 @. ᶜρχₜ += ᶜρχₜ_diffusion
115114 # Rain and snow does not affect the mass
116- if χ_name ∉ ( :q_rai , :q_sno )
115+ if ρχ_name == @name (ρq_tot )
117116 @. Yₜ. c. ρ += ᶜρχₜ_diffusion
118117 end
119118 end
120119
121120end
122121
122+ import UnrolledUtilities as UU
123+
123124function vertical_smagorinsky_lilly_tendency! (Yₜ, Y, p, t, :: SmagorinskyLilly )
124125 FT = eltype (Y)
125- (; sfc_temp_C3, ᶠtemp_scalar, ᶜtemp_scalar ) = p. scratch
126+ (; sfc_temp_C3, ᶠtemp_scalar) = p. scratch
126127 (; ᶜτ_smag, ᶠτ_smag, ᶠD_smag, ᶜspecific, ᶜh_tot, sfc_conditions) =
127128 p. precomputed
128129 (; ρ_flux_uₕ, ρ_flux_h_tot) = sfc_conditions
@@ -155,18 +156,17 @@ function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
155156 @. Yₜ. c. ρe_tot -= ᶜdivᵥ_ρe_tot (- (ᶠρ * ᶠD_smag * ᶠgradᵥ (ᶜh_tot)))
156157
157158 # # 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- )
159+ ᶜdivᵥ_ρχ = Operators. DivergenceF2C (;
160+ top = Operators. SetValue (C3 (FT (0 ))),
161+ bottom = Operators. SetValue (C3 (FT (0 ))),
162+ )
165163
166- ᶜ∇ᵥρD∇χₜ = @. ᶜtemp_scalar = ᶜdivᵥ_ρχ (- (ᶠρ * ᶠD_smag * ᶠgradᵥ (ᶜχ)))
164+ foreach_gs_tracer (Yₜ, Y) do ᶜρχₜ, ᶜρχ, ρχ_name
165+ ᶜ∇ᵥρD∇χₜ =
166+ @. lazy (ᶜdivᵥ_ρχ (- (ᶠρ * ᶠD_smag * ᶠgradᵥ (specific (ᶜρχ, Y. c. ρ)))))
167167 @. ᶜρχₜ -= ᶜ∇ᵥρD∇χₜ
168168 # Rain and snow does not affect the mass
169- if χ_name == :q_tot
169+ if ρχ_name == @name (ρq_tot)
170170 @. Yₜ. c. ρ -= ᶜ∇ᵥρD∇χₜ
171171 end
172172 end
0 commit comments