@@ -37,6 +37,115 @@ NVTX.@annotate function hyperdiffusion_tendency!(Yₜ, Yₜ_lim, Y, p, t)
37
37
apply_hyperdiffusion_tendency! (Yₜ, Y, p, t)
38
38
end
39
39
40
+ using ClimaCore. RecursiveApply: rzero
41
+
42
+ # ####
43
+ # #### Cell center tendencies
44
+ # ####
45
+
46
+ """
47
+ ᶜremaining_tendency(ᶜY, ᶠY, p, t)
48
+
49
+ Returns a Broadcasted object, for evaluating the cell center remaining
50
+ tendency. This method calls `ᶜremaining_tendency(Val(name), ᶜY, ᶠY, p, t)` for
51
+ all `propertynames` of `ᶜY`.
52
+ """
53
+ function ᶜremaining_tendency (ᶜY, ᶠY, p, t)
54
+ names = propertynames (ᶜY)
55
+ tends = construct_tendencies (Val (names), ᶜremaining_tendency, ᶜY, ᶠY, p, t)
56
+ # We cannot broadcast over a NamedTuple, so we need to check that edge case
57
+ # first.
58
+ if all (t -> ! (t isa Base. Broadcast. Broadcasted), tends)
59
+ return make_named_tuple (Val (names), tends... )
60
+ else
61
+ return lazy .(make_named_tuple .(Val (names), tends... ))
62
+ end
63
+ end
64
+
65
+ # ####
66
+ # #### Cell face tendencies
67
+ # ####
68
+
69
+ """
70
+ ᶠremaining_tendency(ᶜY, ᶠY, p, t)
71
+
72
+ Returns a Broadcasted object, for evaluating the cell center remaining
73
+ tendency. This method calls `ᶠremaining_tendency(Val(name), ᶜY, ᶠY, p, t)` for
74
+ all `propertynames` of `ᶠY`.
75
+ """
76
+ function ᶠremaining_tendency (ᶜY, ᶠY, p, t)
77
+ names = propertynames (ᶠY)
78
+ tends = construct_tendencies (Val (names), ᶠremaining_tendency, ᶜY, ᶠY, p, t)
79
+ # We cannot broadcast over a NamedTuple, so we need to check that edge case
80
+ # first.
81
+ if all (t -> ! (t isa Base. Broadcast. Broadcasted), tends)
82
+ return make_named_tuple (Val (names), tends... )
83
+ else
84
+ return lazy .(make_named_tuple .(Val (names), tends... ))
85
+ end
86
+ end
87
+
88
+ # ####
89
+ # #### Individual tendencies
90
+ # ####
91
+
92
+ function ᶜremaining_tendency (:: Val{:ρ} , ᶜY, ᶠY, p, t)
93
+ ∑tendencies = zero (eltype (ᶜY. ρ))
94
+ return ∑tendencies
95
+ end
96
+ function ᶜremaining_tendency (:: Val{:uₕ} , ᶜY, ᶠY, p, t)
97
+ ∑tendencies = zero (eltype (ᶜY. uₕ))
98
+ return ∑tendencies
99
+ end
100
+ function ᶜremaining_tendency (:: Val{:ρe_tot} , ᶜY, ᶠY, p, t)
101
+ ∑tendencies = zero (eltype (ᶜY. ρe_tot))
102
+ return ∑tendencies
103
+ end
104
+ function ᶜremaining_tendency (:: Val{:ρq_tot} , ᶜY, ᶠY, p, t)
105
+ ∑tendencies = zero (eltype (ᶜY. ρq_tot))
106
+ return ∑tendencies
107
+ end
108
+ function ᶜremaining_tendency (:: Val{:ρq_liq} , ᶜY, ᶠY, p, t)
109
+ ∑tendencies = zero (eltype (ᶜY. ρq_liq))
110
+ return ∑tendencies
111
+ end
112
+ function ᶜremaining_tendency (:: Val{:ρq_ice} , ᶜY, ᶠY, p, t)
113
+ ∑tendencies = zero (eltype (ᶜY. ρq_ice))
114
+ return ∑tendencies
115
+ end
116
+ function ᶜremaining_tendency (:: Val{:ρn_liq} , ᶜY, ᶠY, p, t)
117
+ ∑tendencies = zero (eltype (ᶜY. ρn_liq))
118
+ return ∑tendencies
119
+ end
120
+ function ᶜremaining_tendency (:: Val{:ρn_rai} , ᶜY, ᶠY, p, t)
121
+ ∑tendencies = zero (eltype (ᶜY. ρn_rai))
122
+ return ∑tendencies
123
+ end
124
+ function ᶜremaining_tendency (:: Val{:ρq_rai} , ᶜY, ᶠY, p, t)
125
+ ∑tendencies = zero (eltype (ᶜY. ρq_rai))
126
+ return ∑tendencies
127
+ end
128
+ function ᶜremaining_tendency (:: Val{:ρq_sno} , ᶜY, ᶠY, p, t)
129
+ ∑tendencies = zero (eltype (ᶜY. ρq_sno))
130
+ return ∑tendencies
131
+ end
132
+ function ᶜremaining_tendency (:: Val{:sgsʲs} , ᶜY, ᶠY, p, t)
133
+ ∑tendencies = rzero (eltype (ᶜY. sgsʲs))
134
+ return ∑tendencies
135
+ end
136
+ function ᶜremaining_tendency (:: Val{:sgs⁰} , ᶜY, ᶠY, p, t)
137
+ ∑tendencies = rzero (eltype (ᶜY. sgs⁰))
138
+ return ∑tendencies
139
+ end
140
+ function ᶠremaining_tendency (:: Val{:u₃} , ᶜY, ᶠY, p, t)
141
+ ∑tendencies = zero (eltype (ᶠY. u₃))
142
+ return ∑tendencies
143
+ end
144
+ function ᶠremaining_tendency (:: Val{:sgsʲs} , ᶜY, ᶠY, p, t)
145
+ ∑tendencies = rzero (eltype (ᶠY. sgsʲs))
146
+ return ∑tendencies
147
+ end
148
+
40
149
"""
41
150
remaining_tendency!(Yₜ, Yₜ_lim, Y, p, t)
42
151
@@ -64,7 +173,27 @@ Returns:
64
173
"""
65
174
NVTX. @annotate function remaining_tendency! (Yₜ, Yₜ_lim, Y, p, t)
66
175
Yₜ_lim .= zero (eltype (Yₜ_lim))
67
- Yₜ .= zero (eltype (Yₜ))
176
+ device = ClimaComms. device (axes (Y. c))
177
+ p_kernel = (;
178
+ zmax = Spaces. z_max (axes (Y. f)),
179
+ atmos = p. atmos,
180
+ params = p. params,
181
+ dt = p. dt,
182
+ )
183
+ if :sfc in propertynames (Y) # columnwise! does not yet handle .sfc
184
+ parent (Yₜ. sfc) .= zero (Spaces. undertype (axes (Y. c)))
185
+ end
186
+ Operators. columnwise! (
187
+ device,
188
+ ᶜremaining_tendency,
189
+ ᶠremaining_tendency,
190
+ Yₜ. c,
191
+ Yₜ. f,
192
+ Y. c,
193
+ Y. f,
194
+ p_kernel,
195
+ t,
196
+ )
68
197
horizontal_tracer_advection_tendency! (Yₜ_lim, Y, p, t)
69
198
fill_with_nans! (p) # TODO : would be better to limit this to debug mode (e.g., if p.debug_mode...)
70
199
horizontal_dynamics_tendency! (Yₜ, Y, p, t)
0 commit comments