@@ -135,29 +135,27 @@ function edmfx_sgs_mass_flux_tendency!(
135135 (@name (c. ρn_liq), @name (c. sgsʲs.:(1 ). n_liq), @name (n_liq)),
136136 (@name (c. ρn_rai), @name (c. sgsʲs.:(1 ). n_rai), @name (n_rai)),
137137 )
138- for j in 1 : n
139- # TODO using unrolled_foreach here allocates! (breaks the flame tests
140- # even though they use 0M microphysics)
141- # MatrixFields.unrolled_foreach(
142- # microphysics_tracers,
143- # ) do (ρχ_name, χʲ_name, _)
144- for (ρχ_name, χʲ_name, _) in microphysics_tracers
145- MatrixFields. has_field (Y, ρχ_name) || continue
146-
147- ᶜχʲ = MatrixFields. get_field (Y, χʲ_name)
148- @. ᶜa_scalar =
149- ᶜχʲ *
150- draft_area (Y. c. sgsʲs.:($$ j). ρa, ᶜρʲs.:($$ j))
151- vtt = vertical_transport (
152- ᶜρʲs.:($ j),
153- ᶠu³ʲs.:($ j),
154- ᶜa_scalar,
155- dt,
156- edmfx_tracer_upwinding,
157- )
158- ᶜρχₜ = MatrixFields. get_field (Yₜ, ρχ_name)
159- @. ᶜρχₜ += vtt
160- end
138+ # TODO using unrolled_foreach here allocates! (breaks the flame tests
139+ # even though they use 0M microphysics)
140+ # MatrixFields.unrolled_foreach(
141+ # microphysics_tracers,
142+ # ) do (ρχ_name, χʲ_name, _)
143+ for (ρχ_name, χʲ_name, _) in microphysics_tracers
144+ MatrixFields. has_field (Y, ρχ_name) || continue
145+
146+ ᶜχʲ = MatrixFields. get_field (Y, χʲ_name)
147+ @. ᶜa_scalar =
148+ ᶜχʲ *
149+ draft_area (Y. c. sgsʲs.:(1 ). ρa, ᶜρʲs.:(1 ))
150+ vtt = vertical_transport (
151+ ᶜρʲs.:(1 ),
152+ ᶠu³ʲs.:(1 ),
153+ ᶜa_scalar,
154+ dt,
155+ edmfx_tracer_upwinding,
156+ )
157+ ᶜρχₜ = MatrixFields. get_field (Yₜ, ρχ_name)
158+ @. ᶜρχₜ += vtt
161159 end
162160 # MatrixFields.unrolled_foreach(
163161 # microphysics_tracers,
@@ -276,40 +274,41 @@ function edmfx_sgs_mass_flux_tendency!(
276274 (@name (c. ρn_liq), @name (ᶜn_liqʲs.:(1 ))),
277275 (@name (c. ρn_rai), @name (ᶜn_raiʲs.:(1 ))),
278276 )
279- for j in 1 : n
280- # TODO using unrolled_foreach here allocates! (breaks the flame tests
281- # even though they use 0M microphysics)
282- # MatrixFields.unrolled_foreach(
283- # microphysics_tracers,
284- # ) do (ρχ_name, χʲ_name)
285- for (ρχ_name, χʲ_name) in microphysics_tracers
286- MatrixFields. has_field (Y, ρχ_name) || continue
287-
288- ᶜχʲ = MatrixFields. get_field (p. precomputed, χʲ_name)
289- # @. ᶜa_scalar =
290- # ᶜχʲ *
291- # draft_area(ᶜρaʲs.:($$j), ᶜρʲs.:($$j))
292- # TODO : remove this filter when mass flux is treated implicitly
293- @. ᶜa_scalar =
294- ᶜχʲ * min (
295- min (draft_area (ᶜρaʲs.:($$ j), ᶜρʲs.:($$ j)), a_max),
296- FT (0.02 ) / max (
297- Geometry. WVector (
298- ᶜinterp (ᶠu³_diff),
299- ). components. data.:1 ,
300- eps (FT),
301- ),
302- )
303- vtt = vertical_transport (
304- ᶜρʲs.:($ j),
305- ᶠu³ʲs.:($ j),
306- ᶜa_scalar,
307- dt,
308- edmfx_tracer_upwinding,
277+ # TODO using unrolled_foreach here allocates! (breaks the flame tests
278+ # even though they use 0M microphysics)
279+ # MatrixFields.unrolled_foreach(
280+ # microphysics_tracers,
281+ # ) do (ρχ_name, χʲ_name)
282+ @. ᶠu³_diff = ᶠu³ʲs.:(1 ) - ᶠu³
283+ for (ρχ_name, χʲ_name) in microphysics_tracers
284+ MatrixFields. has_field (Y, ρχ_name) || continue
285+
286+ ᶜχʲ = MatrixFields. get_field (p. precomputed, χʲ_name)
287+ ᶜρχ = MatrixFields. get_field (Y, ρχ_name)
288+ ᶜχ = (@. lazy (specific (ᶜρχ, Y. c. ρ)))
289+ # @. ᶜa_scalar =
290+ # (ᶜχʲ - ᶜχ) *
291+ # draft_area(ᶜρaʲs.:($$j), ᶜρʲs.:($$j))
292+ # TODO : remove this filter when mass flux is treated implicitly
293+ @. ᶜa_scalar =
294+ (ᶜχʲ - ᶜχ) * min (
295+ min (draft_area (ᶜρaʲs.:(1 ), ᶜρʲs.:(1 )), a_max),
296+ FT (0.02 ) / max (
297+ Geometry. WVector (
298+ ᶜinterp (ᶠu³_diff),
299+ ). components. data.:1 ,
300+ eps (FT),
301+ ),
309302 )
310- ᶜρχₜ = MatrixFields. get_field (Yₜ, ρχ_name)
311- @. ᶜρχₜ += vtt
312- end
303+ vtt = vertical_transport (
304+ ᶜρʲs.:(1 ),
305+ ᶠu³_diff,
306+ ᶜa_scalar,
307+ dt,
308+ edmfx_sgsflux_upwinding,
309+ )
310+ ᶜρχₜ = MatrixFields. get_field (Yₜ, ρχ_name)
311+ @. ᶜρχₜ += vtt
313312 end
314313 end
315314 # TODO : the following adds the environment flux to the tendency
0 commit comments