Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try improving buoyancy gradient kernel performance #2544

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/cache/diagnostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -765,17 +765,13 @@ function set_diagnostic_edmf_precomputed_quantities_env_closures!(Y, p, t)
EnvBuoyGradVars(
thermo_params,
ᶜts,
projected_vector_data(
projected_vector_buoy_grad_vars(
C3,
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts))),
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts))), # ∂θv∂z_unsat
ᶜgradᵥ(ᶠinterp(q_tot)), # ∂qt∂z_sat
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts))), # ∂θl∂z_sat
ᶜlg,
), # ∂θv∂z_unsat
projected_vector_data(C3, ᶜgradᵥ(ᶠinterp(q_tot)), ᶜlg), # ∂qt∂z_sat
projected_vector_data(
C3,
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts))),
ᶜlg,
), # ∂θl∂z_sat
),
),
)

Expand Down
14 changes: 5 additions & 9 deletions src/cache/prognostic_edmf_precomputed_quantities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,13 @@ function set_prognostic_edmf_precomputed_quantities_closures!(Y, p, t)
EnvBuoyGradVars(
thermo_params,
ᶜts⁰,
projected_vector_data(
projected_vector_buoy_grad_vars(
C3,
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts⁰))),
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts⁰))), # ∂θv∂z_unsat
ᶜgradᵥ(ᶠinterp(ᶜq_tot⁰)), # ∂qt∂z_sat
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts⁰))), # ∂θl∂z_sat
ᶜlg,
), # ∂θv∂z_unsat
projected_vector_data(C3, ᶜgradᵥ(ᶠinterp(ᶜq_tot⁰)), ᶜlg), # ∂qt∂z_sat
projected_vector_data(
C3,
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts⁰))),
ᶜlg,
), # ∂θl∂z_sat
),
),
)

Expand Down
18 changes: 5 additions & 13 deletions src/prognostic_equations/gm_sgs_closures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,13 @@ function compute_gm_mixing_length!(ᶜmixing_length, Y, p)
EnvBuoyGradVars(
thermo_params,
ᶜts,
projected_vector_data(
projected_vector_buoy_grad_vars(
C3,
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts))),
ᶜgradᵥ(ᶠinterp(TD.virtual_pottemp(thermo_params, ᶜts))), # ∂θv∂z_unsat
ᶜgradᵥ(ᶠinterp(TD.total_specific_humidity(thermo_params, ᶜts))), # ∂qt∂z_sat
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts))), # ∂θl∂z_sat
ᶜlg,
), # ∂θv∂z_unsat
projected_vector_data(
C3,
ᶜgradᵥ(ᶠinterp(TD.total_specific_humidity(thermo_params, ᶜts))),
ᶜlg,
), # ∂qt∂z_sat
projected_vector_data(
C3,
ᶜgradᵥ(ᶠinterp(TD.liquid_ice_pottemp(thermo_params, ᶜts))),
ᶜlg,
), # ∂θl∂z_sat
),
),
)

Expand Down
8 changes: 8 additions & 0 deletions src/solver/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ Base.@kwdef struct EnvBuoyGradVars{FT}
∂θl∂z_sat::FT
end

function EnvBuoyGradVars(
thermo_params,
ts::TD.ThermodynamicState,
∂θv∂z_unsat_∂qt∂z_sat_∂θl∂z_sat,
)
(; ∂θv∂z_unsat, ∂qt∂z_sat, ∂θl∂z_sat) = ∂θv∂z_unsat_∂qt∂z_sat_∂θl∂z_sat
return EnvBuoyGradVars(thermo_params, ts, ∂θv∂z_unsat, ∂qt∂z_sat, ∂θl∂z_sat)
end

function EnvBuoyGradVars(
thermo_params,
Expand Down
9 changes: 9 additions & 0 deletions src/utils/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ The type should correspond to a vector with only one component, i.e., a basis ve
projected_vector_data(::Type{V}, vector, local_geometry) where {V} =
V(vector, local_geometry)[1] / unit_basis_vector_data(V, local_geometry)

function projected_vector_buoy_grad_vars(::Type{V}, v1, v2, v3, lg) where {V}
ubvd = unit_basis_vector_data(V, lg)
return (;
∂θv∂z_unsat = V(v1, lg)[1] / ubvd,
∂qt∂z_sat = V(v2, lg)[1] / ubvd,
∂θl∂z_sat = V(v3, lg)[1] / ubvd,
)
end

"""
get_physical_w(u, local_geometry)

Expand Down
Loading