@@ -26,16 +26,17 @@ These quantities are computed for both cell centers and faces, with prefixes `
2626- `p`: The model parameters, e.g. `AtmosCache`.
2727"""
2828function set_smagorinsky_lilly_precomputed_quantities! (Y, p)
29- FT = eltype (Y)
30- (; ᶠu, ᶜts, ᶜL_h, ᶜL_v) = p. precomputed
29+ # FT = eltype(Y)
30+ (; ᶜu, ᶠu, ᶜts, ᶜL_h, ᶜL_v, ᶠS, ᶜS ) = p. precomputed
3131 c_smag = CAP. c_smag (p. params)
3232 # grav = CAP.grav(p.params)
3333 # Pr_t = CAP.Prandtl_number_0(CAP.turbconv_params(p.params))
3434 # thermo_params = CAP.thermodynamics_params(p.params)
3535 # (; ᶜtemp_scalar, ᶜtemp_scalar_2) = p.scratch
3636
37- # Strain rate tensor
38- # ᶜS = compute_strain_rate_center(ᶠu)
37+ # Precompute full strain rate tensor
38+ compute_strain_rate_center_full! (ᶜS, ᶜu, ᶠu)
39+ compute_strain_rate_face_full! (ᶠS, ᶜu, ᶠu)
3940
4041 # Stratification correction
4142 # ᶜθ_v = @. lazy(TD.virtual_pottemp(thermo_params, ᶜts))
@@ -61,14 +62,12 @@ horizontal_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::Nothing) = nothing
6162vertical_smagorinsky_lilly_tendency! (Yₜ, Y, p, t, :: Nothing ) = nothing
6263
6364function horizontal_smagorinsky_lilly_tendency! (Yₜ, Y, p, t, :: SmagorinskyLilly )
64- (; ᶜu, ᶠu, ᶜts, ᶜL_h ) = p. precomputed
65+ (; ᶜts, ᶜL_h, ᶠS, ᶜS ) = p. precomputed
6566 (; ᶜtemp_UVWxUVW, ᶠtemp_UVWxUVW, ᶜtemp_scalar, ᶠtemp_scalar) = p. scratch
6667 thermo_params = CAP. thermodynamics_params (p. params)
6768 Pr_t = CAP. Prandtl_number_0 (CAP. turbconv_params (p. params))
6869
6970 # # Momentum tendencies
70- ᶜS = compute_strain_rate_center (ᶠu)
71- ᶠS = compute_strain_rate_face (ᶜu)
7271 ᶜS_h = @. lazy (Geometry. project ((Geometry. UVAxis (),), ᶜS, (Geometry. UVAxis (),)))
7372 ᶜS_norm = @. lazy (√ (2 * norm_sqr (ᶜS_h)))
7473
@@ -88,9 +87,8 @@ function horizontal_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLill
8887 @. Yₜ. f. u₃ -= C3 (wdivₕ (ᶠρ * ᶠτ_smag) / ᶠρ)
8988
9089 # # Total energy tendency
91- ᶜh_tot = @. lazy (
92- TD. total_specific_enthalpy (thermo_params, ᶜts, specific (Y. c. ρe_tot, Y. c. ρ)),
93- )
90+ ᶜe_tot = @. lazy (specific (Y. c. ρe_tot, Y. c. ρ))
91+ ᶜh_tot = @. lazy (TD. total_specific_enthalpy (thermo_params, ᶜts, ᶜe_tot))
9492 @. Yₜ. c. ρe_tot += wdivₕ (Y. c. ρ * ᶜD_smag * gradₕ (ᶜh_tot))
9593
9694 # # Tracer diffusion and associated mass changes
108106
109107function vertical_smagorinsky_lilly_tendency! (Yₜ, Y, p, t, :: SmagorinskyLilly )
110108 FT = eltype (Y)
111- (; ᶜu, ᶠu, ᶜts, ᶜL_v ) = p. precomputed
109+ (; ᶜts, ᶜL_v, ᶠS, ᶜS ) = p. precomputed
112110 (; ᶜtemp_UVWxUVW, ᶠtemp_UVWxUVW, ᶠtemp_scalar, ᶠtemp_scalar_2) = p. scratch
113111 thermo_params = CAP. thermodynamics_params (p. params)
114112 Pr_t = CAP. Prandtl_number_0 (CAP. turbconv_params (p. params))
@@ -129,8 +127,6 @@ function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
129127 )
130128
131129 # # Momentum tendencies
132- ᶜS = compute_strain_rate_center (ᶠu)
133- ᶠS = compute_strain_rate_face (ᶜu)
134130 ᶜS_v = @. lazy (Geometry. project ((Geometry. WAxis (),), ᶜS, (Geometry. WAxis (),)))
135131 ᶜS_norm = @. lazy (√ (2 * norm_sqr (ᶜS_v)))
136132
@@ -155,9 +151,8 @@ function vertical_smagorinsky_lilly_tendency!(Yₜ, Y, p, t, ::SmagorinskyLilly)
155151 @. Yₜ. f. u₃ -= C3 (ᶠdivᵥ (Y. c. ρ * ᶜτ_smag) / ᶠρ)
156152
157153 # # Total energy tendency
158- ᶜh_tot = @. lazy (
159- TD. total_specific_enthalpy (thermo_params, ᶜts, specific (Y. c. ρe_tot, Y. c. ρ)),
160- )
154+ ᶜe_tot = @. lazy (specific (Y. c. ρe_tot, Y. c. ρ))
155+ ᶜh_tot = @. lazy (TD. total_specific_enthalpy (thermo_params, ᶜts, ᶜe_tot))
161156 @. Yₜ. c. ρe_tot -= ᶜdivᵥ_ρe_tot (- (ᶠρ * ᶠD_smag * ᶠgradᵥ (ᶜh_tot)))
162157
163158 # # Tracer diffusion and associated mass changes
0 commit comments