Skip to content

Commit

Permalink
Update compat to be compatible with Spaces.z_max
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Nov 21, 2024
1 parent 918ae61 commit c5ea747
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/ClimaAtmos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module ClimaAtmos
using NVTX
import Thermodynamics as TD

include("compat.jl")
include(joinpath("parameters", "Parameters.jl"))
import .Parameters as CAP

Expand Down
23 changes: 23 additions & 0 deletions src/compat.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ClimaCore
import ClimaCore: Domains, Spaces, Topologies

# To allow for backwards compatibility of ClimaCore:
if pkgversion(ClimaCore) < v"0.14.18"
"""
z_max(::ClimaCore.Spaces.AbstractSpace)
The domain maximum along the z-direction.
"""
function z_max end

z_max(s::Spaces.AbstractSpace) = Spaces.z_max(s)
z_max(domain::ClimaCore.Domains.IntervalDomain) = domain.coord_max.z
function z_max(space::Spaces.AbstractSpace)
mesh = Topologies.mesh(Spaces.vertical_topology(space))
domain = Topologies.domain(mesh)
return Domains.z_max(domain)
end

else
z_max(s::Spaces.AbstractSpace) = Spaces.z_max(s)
end
2 changes: 1 addition & 1 deletion src/parameterized_tendencies/sponge/rayleigh_sponge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ rayleigh_sponge_tendency!(Yₜ, Y, p, t, ::Nothing) = nothing

function rayleigh_sponge_tendency!(Yₜ, Y, p, t, s::RayleighSponge)
ᶜz = Fields.coordinate_field(Y.c).z
zmax = Spaces.z_max(axes(Y.f))
zmax = z_max(axes(Y.f))
@. Yₜ.c.uₕ -= β_rayleigh_uₕ(s, ᶜz, zmax) * Y.c.uₕ
end
2 changes: 1 addition & 1 deletion src/parameterized_tendencies/sponge/viscous_sponge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function viscous_sponge_tendency!(Yₜ, Y, p, t, s::ViscousSponge)
ᶜuₕ = Y.c.uₕ
ᶜz = Fields.coordinate_field(Y.c).z
ᶠz = Fields.coordinate_field(Y.f).z
zmax = Spaces.z_max(axes(ᶠz))
zmax = z_max(axes(ᶠz))
@. Yₜ.c.uₕ +=
β_viscous(s, ᶜz, zmax) * (
wgradₕ(divₕ(ᶜuₕ)) - Geometry.project(
Expand Down
2 changes: 1 addition & 1 deletion src/prognostic_equations/implicit/implicit_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ function update_implicit_equation_jacobian!(A, Y, p, dtγ)
dtγ * ᶠp_grad_matrix DiagonalMatrixRow(-(ᶜkappa_m) * ᶜρ) ∂ᶜK_∂ᶜuₕ
rs = p.atmos.rayleigh_sponge
ᶠz = Fields.coordinate_field(Y.f).z
zmax = Spaces.z_max(axes(Y.f))
zmax = z_max(axes(Y.f))
if rs isa RayleighSponge
@. ∂ᶠu₃_err_∂ᶠu₃ =
dtγ * (
Expand Down
2 changes: 1 addition & 1 deletion src/prognostic_equations/implicit/implicit_tendency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function implicit_vertical_advection_tendency!(Yₜ, Y, p, t)

if rayleigh_sponge isa RayleighSponge
ᶠz = Fields.coordinate_field(Y.f).z
zmax = Spaces.z_max(axes(Y.f))
zmax = z_max(axes(Y.f))
rs = rayleigh_sponge
@. Yₜ.f.u₃ -= β_rayleigh_w(rs, ᶠz, zmax) * Y.f.u₃
if turbconv_model isa PrognosticEDMFX
Expand Down

0 comments on commit c5ea747

Please sign in to comment.