@@ -142,70 +142,65 @@ function partitioned_turbulent_fluxes!(
142
142
csf. F_turb_energy .*= FT (0 )
143
143
csf. F_turb_moisture .*= FT (0 )
144
144
145
- # iterate over all columns (when regridding, this will need to change)
146
- CC. Fields. bycolumn (boundary_space) do colidx
147
- # atmos state of center level 1
148
- z_int = Interfacer. get_field (atmos_sim, Val (:height_int ), colidx)
149
- uₕ_int = Interfacer. get_field (atmos_sim, Val (:uv_int ), colidx)
150
- thermo_state_int = Interfacer. get_field (atmos_sim, Val (:thermo_state_int ), colidx)
151
- z_sfc = Interfacer. get_field (atmos_sim, Val (:height_sfc ), colidx)
152
-
153
- for sim in model_sims
154
- # iterate over all surface models with non-zero area fractions
155
- if sim isa Interfacer. SurfaceModelSimulation
156
- # get area fraction (min = 0, max = 1)
157
- area_fraction = Interfacer. get_field (sim, Val (:area_fraction ), colidx)
158
- # get area mask [0, 1], where area_mask = 1 if area_fraction > 0
159
- area_mask = Regridder. binary_mask .(area_fraction)
160
-
161
- if ! iszero (parent (area_mask))
162
-
163
- thermo_state_sfc = surface_thermo_state (sim, thermo_params, thermo_state_int, colidx)
164
-
165
- # set inputs based on whether the surface_scheme is `MoninObukhovScheme` or `BulkScheme`
166
- surface_params = get_surface_params (atmos_sim)
167
- scheme_properties = get_scheme_properties (surface_scheme, sim, colidx)
168
- input_args = (;
169
- thermo_state_sfc,
170
- thermo_state_int,
171
- uₕ_int,
172
- z_int,
173
- z_sfc,
174
- scheme_properties,
175
- surface_params,
176
- surface_scheme,
177
- colidx,
178
- )
179
- inputs = surface_inputs (surface_scheme, input_args)
180
-
181
- # calculate the surface fluxes
182
- fluxes = get_surface_fluxes_point! (inputs, surface_params)
183
- (; F_turb_ρτxz, F_turb_ρτyz, F_shf, F_lhf, F_turb_moisture) = fluxes
184
-
185
- # perform additional diagnostics if required
186
- differentiate_turbulent_fluxes! (sim, (thermo_params, input_args, fluxes))
187
-
188
- # update fluxes in the coupler
189
- fields = (;
190
- F_turb_ρτxz = F_turb_ρτxz,
191
- F_turb_ρτyz = F_turb_ρτyz,
192
- F_turb_energy = F_shf .+ F_lhf,
193
- F_turb_moisture = F_turb_moisture,
194
- )
195
-
196
- # update the fluxes of this surface model
197
- update_turbulent_fluxes_point! (sim, fields, colidx)
198
-
199
- # add the flux contributing from this surface to the coupler field
200
- @. csf. F_turb_ρτxz[colidx] += F_turb_ρτxz * area_fraction * area_mask
201
- @. csf. F_turb_ρτyz[colidx] += F_turb_ρτyz * area_fraction * area_mask
202
- @. csf. F_turb_energy[colidx] += (F_shf .+ F_lhf) * area_fraction * area_mask
203
- @. csf. F_turb_moisture[colidx] += F_turb_moisture * area_fraction * area_mask
204
-
205
- end
145
+ # atmos state of center level 1
146
+ z_int = Interfacer. get_field (atmos_sim, Val (:height_int ))
147
+ uₕ_int = Interfacer. get_field (atmos_sim, Val (:uv_int ))
148
+ thermo_state_int = Interfacer. get_field (atmos_sim, Val (:thermo_state_int ))
149
+ z_sfc = Interfacer. get_field (atmos_sim, Val (:height_sfc ))
150
+
151
+ for sim in model_sims
152
+ # iterate over all surface models with non-zero area fractions
153
+ if sim isa Interfacer. SurfaceModelSimulation
154
+ # get area fraction (min = 0, max = 1)
155
+ area_fraction = Interfacer. get_field (sim, Val (:area_fraction ))
156
+ # get area mask [0, 1], where area_mask = 1 if area_fraction > 0
157
+ area_mask = Regridder. binary_mask .(area_fraction)
158
+
159
+ if ! iszero (parent (area_mask))
160
+
161
+ thermo_state_sfc = surface_thermo_state (sim, thermo_params, thermo_state_int)
162
+
163
+ # set inputs based on whether the surface_scheme is `MoninObukhovScheme` or `BulkScheme`
164
+ surface_params = get_surface_params (atmos_sim)
165
+ scheme_properties = get_scheme_properties (surface_scheme, sim)
166
+ input_args = (;
167
+ thermo_state_sfc,
168
+ thermo_state_int,
169
+ uₕ_int,
170
+ z_int,
171
+ z_sfc,
172
+ scheme_properties,
173
+ surface_params,
174
+ surface_scheme,
175
+ )
176
+ inputs = surface_inputs (surface_scheme, input_args)
177
+
178
+ # calculate the surface fluxes
179
+ fluxes = get_surface_fluxes_point! (inputs, surface_params)
180
+ (; F_turb_ρτxz, F_turb_ρτyz, F_shf, F_lhf, F_turb_moisture) = fluxes
181
+
182
+ # perform additional diagnostics if required
183
+ differentiate_turbulent_fluxes! (sim, (thermo_params, input_args, fluxes))
184
+
185
+ # update fluxes in the coupler
186
+ fields = (;
187
+ F_turb_ρτxz = F_turb_ρτxz,
188
+ F_turb_ρτyz = F_turb_ρτyz,
189
+ F_turb_energy = F_shf .+ F_lhf,
190
+ F_turb_moisture = F_turb_moisture,
191
+ )
192
+
193
+ # update the fluxes of this surface model
194
+ update_turbulent_fluxes_point! (sim, fields)
195
+
196
+ # add the flux contributing from this surface to the coupler field
197
+ @. csf. F_turb_ρτxz += F_turb_ρτxz * area_fraction * area_mask
198
+ @. csf. F_turb_ρτyz += F_turb_ρτyz * area_fraction * area_mask
199
+ @. csf. F_turb_energy += (F_shf .+ F_lhf) * area_fraction * area_mask
200
+ @. csf. F_turb_moisture += F_turb_moisture * area_fraction * area_mask
201
+
206
202
end
207
203
end
208
-
209
204
end
210
205
211
206
# TODO : add allowable bounds here, check explicitly that all fluxes are equal
@@ -217,25 +212,21 @@ struct BulkScheme <: AbstractSurfaceFluxScheme end
217
212
struct MoninObukhovScheme <: AbstractSurfaceFluxScheme end
218
213
219
214
"""
220
- get_scheme_properties(scheme::AbstractSurfaceFluxScheme, sim::Interfacer.SurfaceModelSimulation, colidx::CC.Fields.ColumnIndex )
215
+ get_scheme_properties(scheme::AbstractSurfaceFluxScheme, sim::Interfacer.SurfaceModelSimulation)
221
216
222
217
Returns the scheme-specific properties for the surface model simulation `sim`.
223
218
"""
224
- function get_scheme_properties (:: BulkScheme , sim:: Interfacer.SurfaceModelSimulation , colidx :: CC.Fields.ColumnIndex )
225
- Ch = Interfacer. get_field (sim, Val (:heat_transfer_coefficient ), colidx )
226
- Cd = Interfacer. get_field (sim, Val (:beta ), colidx )
227
- beta = Interfacer. get_field (sim, Val (:drag_coefficient ), colidx )
219
+ function get_scheme_properties (:: BulkScheme , sim:: Interfacer.SurfaceModelSimulation )
220
+ Ch = Interfacer. get_field (sim, Val (:heat_transfer_coefficient ))
221
+ Cd = Interfacer. get_field (sim, Val (:beta ))
222
+ beta = Interfacer. get_field (sim, Val (:drag_coefficient ))
228
223
FT = eltype (Ch)
229
224
return (; z0b = FT (0 ), z0m = FT (0 ), Ch = Ch, Cd = Cd, beta = beta, gustiness = FT (1 ))
230
225
end
231
- function get_scheme_properties (
232
- :: MoninObukhovScheme ,
233
- sim:: Interfacer.SurfaceModelSimulation ,
234
- colidx:: CC.Fields.ColumnIndex ,
235
- )
236
- z0m = Interfacer. get_field (sim, Val (:roughness_momentum ), colidx)
237
- z0b = Interfacer. get_field (sim, Val (:roughness_buoyancy ), colidx)
238
- beta = Interfacer. get_field (sim, Val (:beta ), colidx)
226
+ function get_scheme_properties (:: MoninObukhovScheme , sim:: Interfacer.SurfaceModelSimulation )
227
+ z0m = Interfacer. get_field (sim, Val (:roughness_momentum ))
228
+ z0b = Interfacer. get_field (sim, Val (:roughness_buoyancy ))
229
+ beta = Interfacer. get_field (sim, Val (:beta ))
239
230
FT = eltype (z0m)
240
231
return (; z0b = z0b, z0m = z0m, Ch = FT (0 ), Cd = FT (0 ), beta = beta, gustiness = FT (1 ))
241
232
end
@@ -287,21 +278,20 @@ function surface_inputs(::MoninObukhovScheme, input_args::NamedTuple)
287
278
end
288
279
289
280
"""
290
- surface_thermo_state(sim::Interfacer.SurfaceModelSimulation, thermo_params::TD.Parameters.ThermodynamicsParameters, thermo_state_int, colidx::CC.Fields.ColumnIndex )
281
+ surface_thermo_state(sim::Interfacer.SurfaceModelSimulation, thermo_params::TD.Parameters.ThermodynamicsParameters, thermo_state_int)
291
282
292
283
Returns the surface parameters for the surface model simulation `sim`. The default is assuming saturated surfaces, unless an extension is defined for the given `SurfaceModelSimulation`.
293
284
"""
294
285
function surface_thermo_state (
295
286
sim:: Interfacer.SurfaceModelSimulation ,
296
287
thermo_params:: TD.Parameters.ThermodynamicsParameters ,
297
- thermo_state_int,
298
- colidx:: CC.Fields.ColumnIndex ;
288
+ thermo_state_int;
299
289
δT_sfc = 0 ,
300
290
)
301
291
FT = eltype (parent (thermo_state_int))
302
292
@warn (" Simulation " * Interfacer. name (sim) * " uses the default thermo (saturated) surface state" , maxlog = 10 )
303
293
# get surface temperature (or perturbed surface temperature for differentiation)
304
- T_sfc = Interfacer. get_field (sim, Val (:surface_temperature ), colidx ) .+ FT (δT_sfc)
294
+ T_sfc = Interfacer. get_field (sim, Val (:surface_temperature )) .+ FT (δT_sfc)
305
295
ρ_sfc = extrapolate_ρ_to_sfc .(thermo_params, thermo_state_int, T_sfc) # ideally the # calculate elsewhere, here just getter...
306
296
q_sfc = TD. q_vap_saturation_generic .(thermo_params, T_sfc, ρ_sfc, TD. Liquid ()) # default: saturated liquid surface
307
297
@. TD. PhaseEquil_ρTq .(thermo_params, ρ_sfc, T_sfc, q_sfc)
@@ -367,15 +357,11 @@ function get_surface_params(atmos_sim::Interfacer.AtmosModelSimulation)
367
357
end
368
358
369
359
"""
370
- update_turbulent_fluxes_point!(sim::Interfacer.SurfaceModelSimulation, fields::NamedTuple, colidx::CC.Fields.ColumnIndex )
360
+ update_turbulent_fluxes_point!(sim::Interfacer.SurfaceModelSimulation, fields::NamedTuple)
371
361
372
362
Updates the fluxes in the surface model simulation `sim` with the fluxes in `fields`.
373
363
"""
374
- function update_turbulent_fluxes_point! (
375
- sim:: Interfacer.SurfaceModelSimulation ,
376
- fields:: NamedTuple ,
377
- colidx:: CC.Fields.ColumnIndex ,
378
- )
364
+ function update_turbulent_fluxes_point! (sim:: Interfacer.SurfaceModelSimulation , fields:: NamedTuple )
379
365
return error (
380
366
" update_turbulent_fluxes_point! is required to be dispatched on" *
381
367
Interfacer. name (sim) *
0 commit comments