@@ -37,6 +37,99 @@ 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
+ function ᶜremaining_tendency (ᶜY, ᶠY, p, t)
46
+ names = propertynames (ᶜY)
47
+ tends = construct_tendencies (Val (names), ᶜremaining_tendency, ᶜY, ᶠY, p, t)
48
+ # We cannot broadcast over a NamedTuple, so we need to check that edge case
49
+ # first.
50
+ if all (t -> ! (t isa Base. Broadcast. Broadcasted), tends)
51
+ return make_named_tuple (Val (names), tends... )
52
+ else
53
+ return lazy .(make_named_tuple .(Val (names), tends... ))
54
+ end
55
+ end
56
+
57
+ # ####
58
+ # #### Cell face tendencies
59
+ # ####
60
+ function ᶠremaining_tendency (ᶜY, ᶠY, p, t)
61
+ names = propertynames (ᶠY)
62
+ tends = construct_tendencies (Val (names), ᶠremaining_tendency, ᶜY, ᶠY, p, t)
63
+ # We cannot broadcast over a NamedTuple, so we need to check that edge case
64
+ # first.
65
+ if all (t -> ! (t isa Base. Broadcast. Broadcasted), tends)
66
+ return make_named_tuple (Val (names), tends... )
67
+ else
68
+ return lazy .(make_named_tuple .(Val (names), tends... ))
69
+ end
70
+ end
71
+
72
+ # ####
73
+ # #### Individual tendencies
74
+ # ####
75
+
76
+ function ᶜremaining_tendency (:: Val{:ρ} , ᶜY, ᶠY, p, t)
77
+ ∑tendencies = zero (eltype (ᶜY. ρ))
78
+ return ∑tendencies
79
+ end
80
+ function ᶜremaining_tendency (:: Val{:uₕ} , ᶜY, ᶠY, p, t)
81
+ ∑tendencies = zero (eltype (ᶜY. uₕ))
82
+ return ∑tendencies
83
+ end
84
+ function ᶜremaining_tendency (:: Val{:ρe_tot} , ᶜY, ᶠY, p, t)
85
+ ∑tendencies = zero (eltype (ᶜY. ρe_tot))
86
+ return ∑tendencies
87
+ end
88
+ function ᶜremaining_tendency (:: Val{:ρq_tot} , ᶜY, ᶠY, p, t)
89
+ ∑tendencies = zero (eltype (ᶜY. ρq_tot))
90
+ return ∑tendencies
91
+ end
92
+ function ᶜremaining_tendency (:: Val{:ρq_liq} , ᶜY, ᶠY, p, t)
93
+ ∑tendencies = zero (eltype (ᶜY. ρq_liq))
94
+ return ∑tendencies
95
+ end
96
+ function ᶜremaining_tendency (:: Val{:ρq_ice} , ᶜY, ᶠY, p, t)
97
+ ∑tendencies = zero (eltype (ᶜY. ρq_ice))
98
+ return ∑tendencies
99
+ end
100
+ function ᶜremaining_tendency (:: Val{:ρn_liq} , ᶜY, ᶠY, p, t)
101
+ ∑tendencies = zero (eltype (ᶜY. ρn_liq))
102
+ return ∑tendencies
103
+ end
104
+ function ᶜremaining_tendency (:: Val{:ρn_rai} , ᶜY, ᶠY, p, t)
105
+ ∑tendencies = zero (eltype (ᶜY. ρn_rai))
106
+ return ∑tendencies
107
+ end
108
+ function ᶜremaining_tendency (:: Val{:ρq_rai} , ᶜY, ᶠY, p, t)
109
+ ∑tendencies = zero (eltype (ᶜY. ρq_rai))
110
+ return ∑tendencies
111
+ end
112
+ function ᶜremaining_tendency (:: Val{:ρq_sno} , ᶜY, ᶠY, p, t)
113
+ ∑tendencies = zero (eltype (ᶜY. ρq_sno))
114
+ return ∑tendencies
115
+ end
116
+ function ᶜremaining_tendency (:: Val{:sgsʲs} , ᶜY, ᶠY, p, t)
117
+ ∑tendencies = rzero (eltype (ᶜY. sgsʲs))
118
+ return ∑tendencies
119
+ end
120
+ function ᶜremaining_tendency (:: Val{:sgs⁰} , ᶜY, ᶠY, p, t)
121
+ ∑tendencies = rzero (eltype (ᶜY. sgs⁰))
122
+ return ∑tendencies
123
+ end
124
+ function ᶠremaining_tendency (:: Val{:u₃} , ᶜY, ᶠY, p, t)
125
+ ∑tendencies = zero (eltype (ᶠY. u₃))
126
+ return ∑tendencies
127
+ end
128
+ function ᶠremaining_tendency (:: Val{:sgsʲs} , ᶜY, ᶠY, p, t)
129
+ ∑tendencies = rzero (eltype (ᶠY. sgsʲs))
130
+ return ∑tendencies
131
+ end
132
+
40
133
"""
41
134
remaining_tendency!(Yₜ, Yₜ_lim, Y, p, t)
42
135
@@ -64,7 +157,27 @@ Returns:
64
157
"""
65
158
NVTX. @annotate function remaining_tendency! (Yₜ, Yₜ_lim, Y, p, t)
66
159
Yₜ_lim .= zero (eltype (Yₜ_lim))
67
- Yₜ .= zero (eltype (Yₜ))
160
+ device = ClimaComms. device (axes (Y. c))
161
+ p_kernel = (;
162
+ zmax = Spaces. z_max (axes (Y. f)),
163
+ atmos = p. atmos,
164
+ params = p. params,
165
+ dt = p. dt,
166
+ )
167
+ if :sfc in propertynames (Y) # columnwise! does not yet handle .sfc
168
+ parent (Yₜ. sfc) .= zero (Spaces. undertype (axes (Y. c)))
169
+ end
170
+ Operators. columnwise! (
171
+ device,
172
+ ᶜremaining_tendency,
173
+ ᶠremaining_tendency,
174
+ Yₜ. c,
175
+ Yₜ. f,
176
+ Y. c,
177
+ Y. f,
178
+ p_kernel,
179
+ t,
180
+ )
68
181
horizontal_tracer_advection_tendency! (Yₜ_lim, Y, p, t)
69
182
fill_with_nans! (p) # TODO : would be better to limit this to debug mode (e.g., if p.debug_mode...)
70
183
horizontal_dynamics_tendency! (Yₜ, Y, p, t)
0 commit comments