Skip to content

Commit b42ea0c

Browse files
authored
Merge pull request #1546 from CliMA/js/maybe-fv
remove FluxCalculator.surface_inputs
2 parents 6f34cd2 + 1f4cdd4 commit b42ea0c

File tree

2 files changed

+20
-60
lines changed

2 files changed

+20
-60
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ ClimaCoupler.jl Release Notes
66

77
### ClimaCoupler features
88

9+
#### Remove `FluxCalculator.surface_inputs` helper function PR[#1543](https://github.com/CliMA/ClimaCoupler.jl/pull/1543)
10+
We can simplify the flux calculation by calling `SF.ValuesOnly` directly.
11+
Since we now remap all quantities onto the boundary space when we compute
12+
fluxes, there's no need to access the underlying data layouts of ClimaCore Fields.
13+
914
#### Provide `SW_d`, `LW_d` to surface models instead of `F_radiative` PR[#1518](https://github.com/CliMA/ClimaCoupler.jl/pull/1518)
1015
This allows us to correctly compute radiative flux over surface models by
1116
computing each contribution individually (`SW_u, SW_d, LW_u, LW_d`).

src/FluxCalculator.jl

Lines changed: 15 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -72,53 +72,6 @@ function turbulent_fluxes!(csf, model_sims, thermo_params)
7272
return nothing
7373
end
7474

75-
76-
function surface_inputs(input_args::NamedTuple)
77-
(;
78-
thermo_state_sfc,
79-
thermo_state_atmos,
80-
uₕ_int,
81-
z_int,
82-
z_sfc,
83-
scheme_properties,
84-
boundary_space,
85-
) = input_args
86-
FT = CC.Spaces.undertype(boundary_space)
87-
(; z0b, z0m, beta, gustiness) = scheme_properties
88-
89-
# Extract the underlying data layouts of each field
90-
# Note: this is a bit "dangerous" because it circumvents ClimaCore, but
91-
# it allows us to broadcast over fields on slightly different spaces
92-
maybe_fv = (x) -> x isa CC.Fields.Field ? CC.Fields.field_values(x) : x
93-
94-
z_int_fv = maybe_fv(z_int)
95-
uₕ_int_fv = maybe_fv(uₕ_int)
96-
thermo_state_atmos_fv = maybe_fv(thermo_state_atmos)
97-
z_sfc_fv = maybe_fv(z_sfc)
98-
thermo_state_sfc_fv = maybe_fv(thermo_state_sfc)
99-
beta_fv = maybe_fv(beta)
100-
z0m_fv = maybe_fv(z0m)
101-
z0b_fv = maybe_fv(z0b)
102-
gustiness_fv = maybe_fv(gustiness)
103-
104-
# Compute state values
105-
result = @. SF.ValuesOnly(
106-
SF.StateValues(z_int_fv, uₕ_int_fv, thermo_state_atmos_fv), # state_in
107-
SF.StateValues( # state_sfc
108-
z_sfc_fv,
109-
StaticArrays.SVector(FT(0), FT(0)),
110-
thermo_state_sfc_fv,
111-
),
112-
z0m_fv,
113-
z0b_fv,
114-
gustiness_fv,
115-
beta_fv,
116-
)
117-
118-
# Put the result data layout back onto the surface space
119-
return CC.Fields.Field(result, boundary_space)
120-
end
121-
12275
# TODO: (an equivalent of) this function also lives in Atmos and Land - should move to general utilities
12376
"""
12477
extrapolate_ρ_to_sfc(thermo_params, ts_int, T_sfc)
@@ -324,20 +277,22 @@ function compute_surface_fluxes!(
324277
Interfacer.get_field!(csf.scalar_temp4, sim, Val(:beta))
325278
beta = csf.scalar_temp4
326279

327-
scheme_properties =
328-
(; z0b = z0b, z0m = z0m, Ch = FT(0), Cd = FT(0), beta = beta, gustiness = FT(1))
329-
330-
input_args = (;
331-
thermo_state_sfc,
332-
thermo_state_atmos,
333-
uₕ_int,
334-
csf.z_int,
335-
csf.z_sfc,
336-
scheme_properties,
337-
boundary_space,
338-
surface_params,
280+
# Set some scalars that we hardcode for now
281+
gustiness = FT(1)
282+
283+
# Construct the SurfaceFluxes.jl container of inputs
284+
inputs = @. SF.ValuesOnly(
285+
SF.StateValues(csf.z_int, uₕ_int, thermo_state_atmos), # state_in
286+
SF.StateValues( # state_sfc
287+
csf.z_sfc,
288+
StaticArrays.SVector(FT(0), FT(0)),
289+
thermo_state_sfc,
290+
),
291+
z0m,
292+
z0b,
293+
gustiness,
294+
beta,
339295
)
340-
inputs = FluxCalculator.surface_inputs(input_args)
341296

342297
# calculate the surface fluxes
343298
fluxes = FluxCalculator.get_surface_fluxes(inputs, surface_params)

0 commit comments

Comments
 (0)