@@ -14,8 +14,6 @@ import ..Interfacer, ..Utilities
14
14
15
15
export calculate_surface_air_density,
16
16
extrapolate_ρ_to_sfc,
17
- MoninObukhovScheme,
18
- BulkScheme,
19
17
turbulent_fluxes!,
20
18
get_surface_params,
21
19
update_turbulent_fluxes!,
35
33
turbulent_fluxes!(model_sims::NamedTuple,
36
34
csf::CC.Fields.Field,
37
35
boundary_space::CC.Spaces.AbstractSpace,
38
- surface_scheme,
39
36
thermo_params::TD.Parameters.ThermodynamicsParameters)
40
37
41
38
Compute turbulent fluxes and associated quantities. Store the results in `fields` as
47
44
- `model_sims`: [NamedTuple] containing `ComponentModelSimulation`s.
48
45
- `fields`: [NamedTuple] containing coupler fields.
49
46
- `boundary_space`: [CC.Spaces.AbstractSpace] the space of the coupler surface.
50
- - `surface_scheme`: [AbstractSurfaceFluxScheme] the surface flux scheme.
51
47
- `thermo_params`: [TD.Parameters.ThermodynamicsParameters] the thermodynamic parameters.
52
48
53
49
TODO:
@@ -61,7 +57,6 @@ function turbulent_fluxes!(
61
57
model_sims:: NamedTuple ,
62
58
csf:: CC.Fields.Field ,
63
59
boundary_space:: CC.Spaces.AbstractSpace ,
64
- surface_scheme,
65
60
thermo_params:: TD.Parameters.ThermodynamicsParameters ,
66
61
)
67
62
atmos_sim = model_sims. atmos_sim
@@ -83,77 +78,15 @@ function turbulent_fluxes!(
83
78
84
79
# Compute the surface fluxes for each surface model and add them to `csf`
85
80
for sim in model_sims
86
- compute_surface_fluxes! (csf, sim, atmos_sim, boundary_space, thermo_params, surface_scheme )
81
+ compute_surface_fluxes! (csf, sim, atmos_sim, boundary_space, thermo_params)
87
82
end
88
83
89
84
# TODO : add allowable bounds here, check explicitly that all fluxes are equal
90
85
return nothing
91
86
end
92
87
93
- abstract type AbstractSurfaceFluxScheme end
94
- struct BulkScheme <: AbstractSurfaceFluxScheme end
95
- struct MoninObukhovScheme <: AbstractSurfaceFluxScheme end
96
88
97
- """
98
- get_scheme_properties(scheme::AbstractSurfaceFluxScheme, sim::Interfacer.SurfaceModelSimulation)
99
-
100
- Returns the scheme-specific properties for the surface model simulation `sim`.
101
- """
102
- function get_scheme_properties (:: BulkScheme , sim:: Interfacer.SurfaceModelSimulation )
103
- Ch = Interfacer. get_field (sim, Val (:heat_transfer_coefficient ))
104
- Cd = Interfacer. get_field (sim, Val (:drag_coefficient ))
105
- beta = Interfacer. get_field (sim, Val (:beta ))
106
- FT = eltype (Ch)
107
- return (; z0b = FT (0 ), z0m = FT (0 ), Ch = Ch, Cd = Cd, beta = beta, gustiness = FT (1 ))
108
- end
109
- function get_scheme_properties (:: MoninObukhovScheme , sim:: Interfacer.SurfaceModelSimulation )
110
- z0m = Interfacer. get_field (sim, Val (:roughness_momentum ))
111
- z0b = Interfacer. get_field (sim, Val (:roughness_buoyancy ))
112
- beta = Interfacer. get_field (sim, Val (:beta ))
113
- FT = eltype (z0m)
114
- return (; z0b = z0b, z0m = z0m, Ch = FT (0 ), Cd = FT (0 ), beta = beta, gustiness = FT (1 ))
115
- end
116
-
117
- """
118
- surface_inputs(scheme::AbstractSurfaceFluxScheme, thermo_state_sfc, thermo_state_int, uₕ_int, z_int, z_sfc, z0b, z0m, Ch, Cd, beta, gustiness)
119
-
120
- Returns the inputs for the surface model simulation `sim`.
121
- """
122
- function surface_inputs (:: BulkScheme , input_args:: NamedTuple )
123
-
124
- (; thermo_state_sfc, thermo_state_int, uₕ_int, z_int, z_sfc, scheme_properties, boundary_space) = input_args
125
- FT = CC. Spaces. undertype (axes (z_sfc))
126
- (; Ch, Cd, beta, gustiness) = scheme_properties
127
-
128
- # Extract the underlying data layouts of each field
129
- # Note: this is a bit "dangerous" because it circumvents ClimaCore, but
130
- # it allows us to broadcast over fields on slightly different spaces
131
- fv = CC. Fields. field_values
132
- z_int_fv = fv (z_int)
133
- uₕ_int_fv = fv (uₕ_int)
134
- thermo_state_int_fv = fv (thermo_state_int)
135
- z_sfc_fv = fv (z_sfc)
136
- thermo_state_sfc_fv = fv (thermo_state_sfc)
137
- beta_fv = fv (beta)
138
-
139
- # wrap state values
140
- result = @. SF. Coefficients (
141
- SF. StateValues (z_int_fv, uₕ_int_fv, thermo_state_int_fv), # state_in
142
- SF. StateValues ( # state_sfc
143
- z_sfc_fv,
144
- StaticArrays. SVector (FT (0 ), FT (0 )),
145
- thermo_state_sfc_fv,
146
- ),
147
- Cd, # Cd
148
- Ch, # Ch
149
- gustiness, # gustiness
150
- beta_fv, # beta
151
- )
152
-
153
- # Put the result data layout back onto the surface space
154
- return CC. Fields. Field (result, boundary_space)
155
- end
156
- function surface_inputs (:: MoninObukhovScheme , input_args:: NamedTuple )
89
+ function surface_inputs (input_args:: NamedTuple )
157
90
(; thermo_state_sfc, thermo_state_int, uₕ_int, z_int, z_sfc, scheme_properties, boundary_space) = input_args
158
91
FT = CC. Spaces. undertype (boundary_space)
159
92
(; z0b, z0m, beta, gustiness) = scheme_properties
@@ -333,7 +266,7 @@ function water_albedo_from_atmosphere!(atmos_sim::Interfacer.AtmosModelSimulatio
333
266
end
334
267
335
268
"""
336
- compute_surface_fluxes!(csf, sim, atmos_sim, boundary_space, thermo_params, surface_scheme )
269
+ compute_surface_fluxes!(csf, sim, atmos_sim, boundary_space, thermo_params)
337
270
338
271
This function computes surface fluxes between the input component model
339
272
simulation and the atmosphere.
@@ -351,15 +284,13 @@ function does nothing if called on an atmosphere model simulation.
351
284
- `atmos_sim`: [Interfacer.AtmosModelSimulation] the atmosphere simulation to compute fluxes with.
352
285
- `boundary_space`: [CC.Spaces.AbstractSpace] the space of the coupler surface.
353
286
- `thermo_params`: [TD.Parameters.ThermodynamicsParameters] the thermodynamic parameters.
354
- - `surface_scheme`: [AbstractSurfaceFluxScheme] the surface flux scheme.
355
287
"""
356
288
function compute_surface_fluxes! (
357
289
csf,
358
290
sim:: Interfacer.AtmosModelSimulation ,
359
291
atmos_sim:: Interfacer.AtmosModelSimulation ,
360
292
boundary_space,
361
293
thermo_params,
362
- surface_scheme,
363
294
)
364
295
# do nothing for atmos model
365
296
return nothing
@@ -371,7 +302,6 @@ function compute_surface_fluxes!(
371
302
atmos_sim:: Interfacer.AtmosModelSimulation ,
372
303
boundary_space,
373
304
thermo_params,
374
- surface_scheme,
375
305
)
376
306
# `_int` refers to atmos state of center level 1
377
307
z_int = Interfacer. get_field (atmos_sim, Val (:height_int ))
@@ -384,23 +314,18 @@ function compute_surface_fluxes!(
384
314
385
315
thermo_state_sfc = FluxCalculator. surface_thermo_state (sim, thermo_params, thermo_state_int)
386
316
387
- # set inputs based on whether the surface_scheme is `MoninObukhovScheme` or `BulkScheme`
388
317
surface_params = FluxCalculator. get_surface_params (atmos_sim)
389
- scheme_properties = FluxCalculator. get_scheme_properties (surface_scheme, sim)
318
+
319
+ z0m = Interfacer. get_field (sim, Val (:roughness_momentum ))
320
+ z0b = Interfacer. get_field (sim, Val (:roughness_buoyancy ))
321
+ beta = Interfacer. get_field (sim, Val (:beta ))
322
+ FT = eltype (z0m)
323
+ scheme_properties = (; z0b = z0b, z0m = z0m, Ch = FT (0 ), Cd = FT (0 ), beta = beta, gustiness = FT (1 ))
390
324
391
325
# surface_params, surface_scheme are used by EinsenmanIceSimulation
392
- input_args = (;
393
- thermo_state_sfc,
394
- thermo_state_int,
395
- uₕ_int,
396
- z_int,
397
- z_sfc,
398
- scheme_properties,
399
- boundary_space,
400
- surface_params,
401
- surface_scheme,
402
- )
403
- inputs = FluxCalculator. surface_inputs (surface_scheme, input_args)
326
+ input_args =
327
+ (; thermo_state_sfc, thermo_state_int, uₕ_int, z_int, z_sfc, scheme_properties, boundary_space, surface_params)
328
+ inputs = FluxCalculator. surface_inputs (input_args)
404
329
405
330
# calculate the surface fluxes
406
331
fluxes = FluxCalculator. get_surface_fluxes! (inputs, surface_params)
0 commit comments