Skip to content

Commit c6db181

Browse files
committed
exchange u and v separately
1 parent bb1f2d8 commit c6db181

File tree

7 files changed

+30
-18
lines changed

7 files changed

+30
-18
lines changed

docs/src/interfacer.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ for the following properties:
135135
| `turbulent_energy_flux` | aerodynamic turbulent surface fluxes of energy (sensible and latent heat) | W m⁻² |
136136
| `turbulent_moisture_flux` | aerodynamic turbulent surface fluxes of energy (evaporation) | kg m⁻² s⁻¹ |
137137
| `thermo_state_int` | thermodynamic state at the first internal model level | |
138-
| `uv_int` | horizontal wind velocity vector at the first internal model level | m s⁻¹ |
138+
| `u_int` | zonal wind velocity vector at the first internal model level | m s⁻¹ |
139+
| `v_int` | meridional wind velocity vector at the first internal model level | m s⁻¹ |
139140

140141
- `update_field!(::AtmosModelSimulation. ::Val{property}, field)`:
141142
A function to update the value of property in the component model

experiments/ClimaEarth/components/atmosphere/climaatmos.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,17 @@ Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:height_int}) =
307307
CC.Spaces.level(CC.Fields.coordinate_field(sim.integrator.u.c).z, 1)
308308
Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:height_sfc}) =
309309
CC.Spaces.level(CC.Fields.coordinate_field(sim.integrator.u.f).z, CC.Utilities.half)
310-
function Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:uv_int})
310+
function Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:u_int})
311311
# NOTE: This calculation is copied from ClimaAtmos (and is allocating! Fix me if you can!)
312312
int_local_geometry_values = Fields.level(Fields.local_geometry_field(sim.integrator.u.c), 1)
313313
int_u_values = CC.Spaces.level(sim.integrator.p.precomputed.ᶜu, 1)
314-
u = CA.projected_vector_data.(CA.CT1, int_u_values, int_local_geometry_values)
315-
v = CA.projected_vector_data.(CA.CT2, int_u_values, int_local_geometry_values)
316-
return @. StaticArrays.SVector(u, v)
314+
return CA.projected_vector_data.(CA.CT1, int_u_values, int_local_geometry_values)
315+
end
316+
function Interfacer.get_field(sim::ClimaAtmosSimulation, ::Val{:v_int})
317+
# NOTE: This calculation is copied from ClimaAtmos (and is allocating! Fix me if you can!)
318+
int_local_geometry_values = Fields.level(Fields.local_geometry_field(sim.integrator.u.c), 1)
319+
int_u_values = CC.Spaces.level(sim.integrator.p.precomputed.ᶜu, 1)
320+
return CA.projected_vector_data.(CA.CT2, int_u_values, int_local_geometry_values)
317321
end
318322

319323
# extensions required by the Interfacer

experiments/ClimaEarth/components/land/climaland_integrated.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -536,17 +536,19 @@ function FluxCalculator.compute_surface_fluxes!(
536536

537537
# `_int` refers to atmos state of center level 1
538538
z_int = Interfacer.get_field(atmos_sim, Val(:height_int))
539-
uₕ_int = Interfacer.get_field(atmos_sim, Val(:uv_int))
539+
u_int = Interfacer.get_field(atmos_sim, Val(:u_int))
540+
v_int = Interfacer.get_field(atmos_sim, Val(:v_int))
540541
thermo_state_int = Interfacer.get_field(atmos_sim, Val(:thermo_state_int))
541542

542-
# We use `field_values` here because of the mismatch between the lowest atmos level
543-
# and the boundary space, even though the horizontal grids are the same.
544-
@assert axes(coupled_atmos.u).grid == axes(uₕ_int).grid.full_grid.horizontal_grid
545-
@assert axes(coupled_atmos.thermal_state).grid == axes(thermo_state_int).grid.full_grid.horizontal_grid
546-
@assert axes(coupled_atmos.h).grid == axes(z_int).grid.full_grid.horizontal_grid
547-
Fields.field_values(coupled_atmos.u) .= Fields.field_values(uₕ_int)
548-
Fields.field_values(coupled_atmos.thermal_state) .= Fields.field_values(thermo_state_int)
549-
Fields.field_values(coupled_atmos.h) .= Fields.field_values(z_int)
543+
# remap atmosphere fields to the exchange grid for flux calculation
544+
u_atmos = zeros(axes(csf.F_turb_ρτxz))
545+
v_atmos = zeros(axes(csf.F_turb_ρτxz))
546+
FieldExchanger.dummmy_remap!(u_atmos, u_int)
547+
FieldExchanger.dummmy_remap!(v_atmos, v_int)
548+
@. coupled_atmos.u = StaticArrays.SVector(u_atmos, v_atmos)
549+
550+
FieldExchanger.dummmy_remap!(coupled_atmos.h, z_int)
551+
FieldExchanger.dummmy_remap!(coupled_atmos.thermal_state, thermo_state_int)
550552

551553
# set the same atmosphere state for all sub-components
552554
@assert sim.model.soil.boundary_conditions.top.atmos ===

src/FluxCalculator.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ function compute_surface_fluxes!(
295295
)
296296
# `_int` refers to atmos state of center level 1
297297
z_int = Interfacer.get_field(atmos_sim, Val(:height_int))
298-
uₕ_int = Interfacer.get_field(atmos_sim, Val(:uv_int))
298+
u_int = Interfacer.get_field(atmos_sim, Val(:u_int))
299+
v_int = Interfacer.get_field(atmos_sim, Val(:v_int))
300+
uₕ_int = @. StaticArrays.SVector(u_int, v_int)
299301
thermo_state_int = Interfacer.get_field(atmos_sim, Val(:thermo_state_int))
300302
z_sfc = Interfacer.get_field(atmos_sim, Val(:height_sfc))
301303

src/Interfacer.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ get_field(
194194
Val{:turblent_energy_flux},
195195
Val{:turbulent_moisture_flux},
196196
Val{:thermo_state_int},
197-
Val{:uv_int},
197+
Val{:u_int},
198+
Val{:v_int},
198199
},
199200
) = get_field_error(sim, val)
200201

test/flux_calculator_tests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ Interfacer.name(sim::TestAtmos2) = "TestAtmos2"
3030

3131
Interfacer.get_field(sim::TestAtmos, ::Val{:height_int}) = sim.integrator.p.z
3232
Interfacer.get_field(sim::TestAtmos, ::Val{:height_sfc}) = sim.integrator.p.z_sfc
33-
Interfacer.get_field(sim::TestAtmos, ::Val{:uv_int}) = @. StaticArrays.SVector(sim.integrator.p.u, sim.integrator.p.v)
33+
Interfacer.get_field(sim::TestAtmos, ::Val{:u_int}) = sim.integrator.p.u
34+
Interfacer.get_field(sim::TestAtmos, ::Val{:v_int}) = sim.integrator.p.v
3435
Interfacer.get_field(sim::TestAtmos, ::Val{:thermo_state_int}) =
3536
TD.PhaseEquil_ρTq.(get_thermo_params(sim), sim.integrator.ρ, sim.integrator.T, sim.integrator.q)
3637

test/interfacer_tests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ end
161161
:turbulent_energy_flux,
162162
:turbulent_moisture_flux,
163163
:thermo_state_int,
164-
:uv_int,
164+
:u_int,
165+
:v_int,
165166
)
166167
val = Val(value)
167168
@test_throws ErrorException("undefined field `$value` for " * Interfacer.name(sim)) Interfacer.get_field(

0 commit comments

Comments
 (0)