@@ -49,17 +49,23 @@ function ᶜremaining_tendency_ρ(ᶜY, ᶠY, p, t)
49
49
50
50
if ! (p. atmos. moisture_model isa DryModel)
51
51
ᶜwₜqₜ = compute_ᶜwₜqₜ (ᶜY, ᶠY, p, t)
52
- ∑tendencies = lazy . (∑tendencies .- water_adv (ᶜρ, ᶜJ, ᶠJ, ᶜwₜqₜ))
52
+ ∑tendencies = sub_tend (∑tendencies, water_adv (ᶜρ, ᶜJ, ᶠJ, ᶜwₜqₜ))
53
53
end
54
54
return (;ρ= ∑tendencies)
55
55
end
56
+
57
+ add_tend (∑tends, t) = lazy .(∑tends .+ t)
58
+ add_tend (∑tends, :: NullBroadcasted ) = ∑tends
59
+ sub_tend (∑tends, :: NullBroadcasted ) = ∑tends
60
+ sub_tend (∑tends, t) = lazy .(∑tends .- t)
61
+
56
62
function ᶜremaining_tendency_uₕ (ᶜY, ᶠY, p, t)
57
63
:uₕ in propertynames (ᶜY) || return ()
58
64
∑tendencies = zero (eltype (ᶜY. uₕ))
59
65
(; viscous_sponge, rayleigh_sponge) = p. atmos
60
66
ᶜuₕ = ᶜY. uₕ
61
- ∑tendencies = lazy . (∑tendencies .+ viscous_sponge_tendency_uₕ (ᶜuₕ, viscous_sponge))
62
- ∑tendencies = lazy . (∑tendencies .+ rayleigh_sponge_tendency_uₕ (ᶜuₕ, rayleigh_sponge))
67
+ ∑tendencies = add_tend (∑tendencies, viscous_sponge_tendency_uₕ (ᶜuₕ, viscous_sponge))
68
+ ∑tendencies = add_tend (∑tendencies, rayleigh_sponge_tendency_uₕ (ᶜuₕ, rayleigh_sponge))
63
69
64
70
return (;uₕ= ∑tendencies)
65
71
end
@@ -82,19 +88,19 @@ function ᶜremaining_tendency_ρe_tot(ᶜY, ᶠY, p, t)
82
88
83
89
if ! (p. atmos. moisture_model isa DryModel)
84
90
ᶜwₕhₜ = compute_ᶜwₕhₜ (ᶜY, ᶠY, p, t)
85
- ∑tendencies = lazy . (∑tendencies .- water_adv (ᶜρ, ᶜJ, ᶠJ, ᶜwₕhₜ))
91
+ ∑tendencies = sub_tend (∑tendencies, water_adv (ᶜρ, ᶜJ, ᶠJ, ᶜwₕhₜ))
86
92
end
87
93
if energy_upwinding != Val (:none )
88
94
(; dt) = p
89
95
ᶠu³ = compute_ᶠu³ (ᶜY, ᶠY)
90
96
vtt = vertical_transport (ᶜρ, ᶠu³, ᶜh_tot, float (dt), energy_upwinding)
91
- ∑tendencies = lazy . (∑tendencies .+ vtt)
97
+ ∑tendencies = add_tend (∑tendencies, vtt)
92
98
vtt_central = vertical_transport (ᶜρ, ᶠu³, ᶜh_tot, float (dt), Val (:none ))
93
99
# need to improve NullBroadcast support for this.
94
- ∑tendencies = lazy . (∑tendencies .+ ( - 1 ) .* vtt_central)
100
+ ∑tendencies = sub_tend (∑tendencies, vtt_central)
95
101
end
96
102
97
- ∑tendencies = lazy . (∑tendencies .+ viscous_sponge_tendency_ρe_tot (ᶜρ, ᶜh_tot, viscous_sponge))
103
+ ∑tendencies = add_tend (∑tendencies, viscous_sponge_tendency_ρe_tot (ᶜρ, ᶜh_tot, viscous_sponge))
98
104
return (;ρe_tot= ∑tendencies)
99
105
end
100
106
function ᶜremaining_tendency_ρq_tot (ᶜY, ᶠY, p, t)
@@ -108,7 +114,7 @@ function ᶜremaining_tendency_ρq_tot(ᶜY, ᶠY, p, t)
108
114
cmc = CAP. microphysics_cloud_params (p. params)
109
115
cmp = CAP. microphysics_1m_params (p. params)
110
116
thp = CAP. thermodynamics_params (p. params)
111
- ∑tendencies = lazy . (∑tendencies .- water_adv (ᶜρ, ᶜJ, ᶠJ, ᶜwₜqₜ))
117
+ ∑tendencies = sub_tend (∑tendencies, water_adv (ᶜρ, ᶜJ, ᶠJ, ᶜwₜqₜ))
112
118
end
113
119
(; tracer_upwinding) = p. atmos. numerics
114
120
if ! (p. atmos. moisture_model isa DryModel) && tracer_upwinding != Val (:none )
@@ -118,7 +124,8 @@ function ᶜremaining_tendency_ρq_tot(ᶜY, ᶠY, p, t)
118
124
ᶠu³ = compute_ᶠu³ (ᶜY, ᶠY)
119
125
vtt = vertical_transport (ᶜρ, ᶠu³, ᶜq_tot, float (dt), tracer_upwinding)
120
126
vtt_central = vertical_transport (ᶜρ, ᶠu³, ᶜq_tot, float (dt), Val (:none ))
121
- ∑tendencies = lazy .(∑tendencies .+ vtt .- vtt_central)
127
+ ∑tendencies = add_tend (∑tendencies, vtt)
128
+ ∑tendencies = sub_tend (∑tendencies, vtt_central)
122
129
end
123
130
124
131
return (;ρq_tot= ∑tendencies)
@@ -161,7 +168,7 @@ function ᶠremaining_tendency_u₃(ᶜY, ᶠY, p, t)
161
168
ᶜuₕ = ᶜY. uₕ
162
169
ᶠuₕ³ = compute_ᶠuₕ³ (ᶜuₕ, ᶜρ)
163
170
ᶠu₃ = compute_ᶠu₃_with_bcs (ᶠY. u₃, ᶠuₕ³)
164
- ∑tendencies = lazy . (∑tendencies .+ viscous_sponge_tendency_u₃ (ᶠu₃, viscous_sponge))
171
+ ∑tendencies = add_tend (∑tendencies, viscous_sponge_tendency_u₃ (ᶠu₃, viscous_sponge))
165
172
return (;u₃= ∑tendencies)
166
173
end
167
174
function ᶠremaining_tendency_sgsʲs (ᶜY, ᶠY, p, t)
0 commit comments