@@ -21,6 +21,10 @@ import ClimaCore:
21
21
Operators,
22
22
Quadratures
23
23
using ClimaCore. MatrixFields
24
+ import ClimaCore. Utilities: half
25
+ import ClimaCore. RecursiveApply: ⊠
26
+ import LinearAlgebra: I, norm, ldiv!, mul!
27
+ import ClimaCore. MatrixFields: @name
24
28
25
29
# Test that an expression is true and that it is also type-stable.
26
30
macro test_all (expression)
@@ -32,7 +36,7 @@ macro test_all(expression)
32
36
end
33
37
end
34
38
35
- # Compute the minimum time (in seconds) required to run an expression after it
39
+ # Compute the minimum time (in seconds) required to run an expression after it
36
40
# has been compiled. This macro is used instead of @benchmark from
37
41
# BenchmarkTools.jl because the latter is extremely slow (it appears to keep
38
42
# triggering recompilations and allocating a lot of memory in the process).
@@ -134,6 +138,85 @@ function test_field_broadcast(;
134
138
end
135
139
end
136
140
141
+ # Create a field matrix for a similar solve to ClimaAtmos's moist dycore + prognostic,
142
+ # EDMF + prognostic surface temperature with implicit acoustic waves and SGS fluxes
143
+ function dycore_prognostic_EDMF_FieldMatrix (;
144
+ ᶜᶜmat1,
145
+ ᶜᶠmat2,
146
+ ᶠᶜmat2,
147
+ ᶜᶜmat3,
148
+ ᶠᶠmat3,
149
+ e¹²,
150
+ e³,
151
+ e₃,
152
+ ρχ_unit,
153
+ ρaχ_unit,
154
+ ᶜᶠmat2_ρχ_u₃,
155
+ ᶠᶠmat3_u₃_u₃,
156
+ ᶜᶠmat2_scalar_u₃,
157
+ ᶠᶜmat2_u₃_scalar,
158
+ )
159
+
160
+ ᶜᶜmat3_uₕ_scalar = ᶜᶜmat3 .* (e¹²,)
161
+ ᶜᶠmat2_uₕ_u₃ = ᶜᶠmat2 .* (e¹² * e₃' ,)
162
+ ᶜᶜmat3_ρχ_scalar = map (Base. Fix1 (map, Base. Fix2 (⊠ , ρχ_unit)), ᶜᶜmat3)
163
+ ᶜᶜmat3_ρaχ_scalar = map (Base. Fix1 (map, Base. Fix2 (⊠ , ρaχ_unit)), ᶜᶜmat3)
164
+ ᶜᶠmat2_ρaχ_u₃ = map (Base. Fix1 (map, Base. Fix2 (⊠ , ρaχ_unit ⊠ e₃' )), ᶜᶠmat2)
165
+ return MatrixFields. FieldMatrix (
166
+ # GS-GS blocks:
167
+ (@name (sfc), @name (sfc)) => I,
168
+ (@name (c. ρ), @name (c. ρ)) => I,
169
+ (@name (c. ρe_tot), @name (c. ρe_tot)) => deepcopy (ᶜᶜmat3),
170
+ (@name (c. ρatke), @name (c. ρatke)) => deepcopy (ᶜᶜmat3),
171
+ (@name (c. ρχ), @name (c. ρχ)) => deepcopy (ᶜᶜmat3),
172
+ (@name (c. uₕ), @name (c. uₕ)) => deepcopy (ᶜᶜmat3),
173
+ (@name (c. ρ), @name (f. u₃)) => deepcopy (ᶜᶠmat2_scalar_u₃),
174
+ (@name (c. ρe_tot), @name (f. u₃)) => deepcopy (ᶜᶠmat2_scalar_u₃),
175
+ (@name (c. ρatke), @name (f. u₃)) => deepcopy (ᶜᶠmat2_scalar_u₃),
176
+ (@name (c. ρχ), @name (f. u₃)) => deepcopy (ᶜᶠmat2_ρχ_u₃),
177
+ (@name (f. u₃), @name (c. ρ)) => deepcopy (ᶠᶜmat2_u₃_scalar),
178
+ (@name (f. u₃), @name (c. ρe_tot)) => deepcopy (ᶠᶜmat2_u₃_scalar),
179
+ (@name (f. u₃), @name (f. u₃)) => deepcopy (ᶠᶠmat3_u₃_u₃),
180
+ # GS-SGS blocks:
181
+ (@name (c. ρe_tot), @name (c. sgsʲs.:(1 ). ρae_tot)) => deepcopy (ᶜᶜmat3),
182
+ (@name (c. ρχ. ρq_tot), @name (c. sgsʲs.:(1 ). ρaχ. ρaq_tot)) =>
183
+ deepcopy (ᶜᶜmat3),
184
+ (@name (c. ρχ. ρq_liq), @name (c. sgsʲs.:(1 ). ρaχ. ρaq_liq)) =>
185
+ deepcopy (ᶜᶜmat3),
186
+ (@name (c. ρχ. ρq_ice), @name (c. sgsʲs.:(1 ). ρaχ. ρaq_ice)) =>
187
+ deepcopy (ᶜᶜmat3),
188
+ (@name (c. ρχ. ρq_rai), @name (c. sgsʲs.:(1 ). ρaχ. ρaq_rai)) =>
189
+ deepcopy (ᶜᶜmat3),
190
+ (@name (c. ρχ. ρq_sno), @name (c. sgsʲs.:(1 ). ρaχ. ρaq_sno)) =>
191
+ deepcopy (ᶜᶜmat3),
192
+ (@name (c. ρe_tot), @name (c. sgsʲs.:(1 ). ρa)) => deepcopy (ᶜᶜmat3),
193
+ (@name (c. ρatke), @name (c. sgsʲs.:(1 ). ρa)) => deepcopy (ᶜᶜmat3),
194
+ (@name (c. ρχ), @name (c. sgsʲs.:(1 ). ρa)) => deepcopy (ᶜᶜmat3_ρχ_scalar),
195
+ (@name (c. uₕ), @name (c. sgsʲs.:(1 ). ρa)) => deepcopy (ᶜᶜmat3_uₕ_scalar),
196
+ (@name (c. ρe_tot), @name (f. sgsʲs.:(1 ). u₃)) => deepcopy (ᶜᶠmat2_scalar_u₃),
197
+ (@name (c. ρatke), @name (f. sgsʲs.:(1 ). u₃)) => deepcopy (ᶜᶠmat2_scalar_u₃),
198
+ (@name (c. ρχ), @name (f. sgsʲs.:(1 ). u₃)) => deepcopy (ᶜᶠmat2_ρχ_u₃),
199
+ (@name (c. uₕ), @name (f. sgsʲs.:(1 ). u₃)) => deepcopy (ᶜᶠmat2_uₕ_u₃),
200
+ (@name (f. u₃), @name (c. sgsʲs.:(1 ). ρa)) => deepcopy (ᶠᶜmat2_u₃_scalar),
201
+ (@name (f. u₃), @name (f. sgsʲs.:(1 ). u₃)) => deepcopy (ᶠᶠmat3_u₃_u₃),
202
+ # SGS-SGS blocks:
203
+ (@name (c. sgsʲs.:(1 ). ρa), @name (c. sgsʲs.:(1 ). ρa)) => I,
204
+ (@name (c. sgsʲs.:(1 ). ρae_tot), @name (c. sgsʲs.:(1 ). ρae_tot)) => I,
205
+ (@name (c. sgsʲs.:(1 ). ρaχ), @name (c. sgsʲs.:(1 ). ρaχ)) => I,
206
+ (@name (c. sgsʲs.:(1 ). ρa), @name (f. sgsʲs.:(1 ). u₃)) =>
207
+ deepcopy (ᶜᶠmat2_scalar_u₃),
208
+ (@name (c. sgsʲs.:(1 ). ρae_tot), @name (f. sgsʲs.:(1 ). u₃)) =>
209
+ deepcopy (ᶜᶠmat2_scalar_u₃),
210
+ (@name (c. sgsʲs.:(1 ). ρaχ), @name (f. sgsʲs.:(1 ). u₃)) =>
211
+ deepcopy (ᶜᶠmat2_ρaχ_u₃),
212
+ (@name (f. sgsʲs.:(1 ). u₃), @name (c. sgsʲs.:(1 ). ρa)) =>
213
+ deepcopy (ᶠᶜmat2_u₃_scalar),
214
+ (@name (f. sgsʲs.:(1 ). u₃), @name (c. sgsʲs.:(1 ). ρae_tot)) =>
215
+ deepcopy (ᶠᶜmat2_u₃_scalar),
216
+ (@name (f. sgsʲs.:(1 ). u₃), @name (f. sgsʲs.:(1 ). u₃)) =>
217
+ deepcopy (ᶠᶠmat3_u₃_u₃),
218
+ )
219
+ end
137
220
# Generate extruded finite difference spaces for testing. Include topography
138
221
# when possible.
139
222
function test_spaces (:: Type{FT} ) where {FT}
0 commit comments