Skip to content

Commit cf775cf

Browse files
nefrathenriciszy21
authored andcommitted
test split divergence
1 parent 8da8417 commit cf775cf

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

.buildkite/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ steps:
2828
- julia --check-bounds=yes -e 'using TOML; @assert TOML.parsefile(".buildkite/Manifest-v1.11.toml")["deps"]["ClimaAtmos"][1]["path"] == ".."'
2929

3030
- echo "--- Instantiate .buildkite"
31+
- julia --project=.buildkite -e 'using Pkg; Pkg.add(PackageSpec(name="ClimaCore", rev="ne-ts/splitform"))'
3132
- "julia --project=.buildkite -e 'using Pkg; Pkg.instantiate(;verbose=true); Pkg.precompile(;strict=true); using CUDA; CUDA.precompile_runtime(); Pkg.status()'"
3233

3334
agents:

src/prognostic_equations/advection.jl

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ NVTX.@annotate function horizontal_dynamics_tendency!(Yₜ, Y, p, t)
3838
(; ᶜΦ) = p.core
3939
(; ᶜu, ᶜK, ᶜp, ᶜts) = p.precomputed
4040
(; params) = p
41+
FT = eltype(params)
4142
thermo_params = CAP.thermodynamics_params(params)
4243
cp_d = thermo_params.cp_d
4344

4445
if p.atmos.turbconv_model isa PrognosticEDMFX
4546
(; ᶜuʲs) = p.precomputed
4647
end
4748

48-
@. Yₜ.c.ρ -= wdivₕ(Y.c.ρ * ᶜu)
49+
@. Yₜ.c.ρ -= split_divₕ(Y.c.ρ * ᶜu, FT(1)) # This one
50+
4951
if p.atmos.turbconv_model isa PrognosticEDMFX
5052
for j in 1:n
5153
@. Yₜ.c.sgsʲs.:($$j).ρa -= wdivₕ(Y.c.sgsʲs.:($$j).ρa * ᶜuʲs.:($$j))
@@ -54,7 +56,7 @@ NVTX.@annotate function horizontal_dynamics_tendency!(Yₜ, Y, p, t)
5456

5557
ᶜe_tot = @. lazy(specific(Y.c.ρe_tot, Y.c.ρ))
5658
ᶜh_tot = @. lazy(TD.total_specific_enthalpy(thermo_params, ᶜts, ᶜe_tot))
57-
@. Yₜ.c.ρe_tot -= wdivₕ(Y.c.ρ * ᶜh_tot * ᶜu)
59+
@. Yₜ.c.ρe_tot -= split_divₕ(Y.c.ρ * ᶜu, ᶜh_tot) # this one
5860

5961
if p.atmos.turbconv_model isa PrognosticEDMFX
6062
for j in 1:n
@@ -73,8 +75,16 @@ NVTX.@annotate function horizontal_dynamics_tendency!(Yₜ, Y, p, t)
7375
ᶜθ_v = @. lazy(theta_v(thermo_params, ᶜts))
7476
ᶜθ_vr = @. lazy(theta_vr(thermo_params, ᶜts))
7577
ᶜΠ = @. lazy(dry_exner_function(thermo_params, ᶜts))
76-
@. Yₜ.c.uₕ -= C12(gradₕ(ᶜK + ᶜΦ - ᶜΦ_r) + cp_d * (ᶜθ_v - ᶜθ_vr) * gradₕ(ᶜΠ))
77-
# Without the C12(), the right-hand side would be a C1 or C2 in 2D space.
78+
ᶜθ_v_diff = @. lazy(ᶜθ_v - ᶜθ_vr)
79+
# PG = 0.5 * cp_d * [θv ∇Π + ∇(θv Π) - Π∇θv]
80+
@. Yₜ.c.uₕ -= C12(
81+
gradₕ(ᶜK + ᶜΦ - ᶜΦ_r) +
82+
FT(0.5) * cp_d * (
83+
ᶜθ_v_diff * gradₕ(ᶜΠ) + # θv ∇Π
84+
gradₕ(ᶜθ_v_diff * ᶜΠ) - # ∇(θv Π)
85+
ᶜΠ * gradₕ(ᶜθ_v_diff) # Π∇θv
86+
),
87+
) # Without the C12(), the right-hand side would be a C1 or C2 in 2D space.
7888
return nothing
7989
end
8090

@@ -109,8 +119,9 @@ NVTX.@annotate function horizontal_tracer_advection_tendency!(Yₜ, Y, p, t)
109119
(; ᶜuʲs) = p.precomputed
110120
end
111121

112-
for ρχ_name in filter(is_tracer_var, propertynames(Y.c))
113-
@. Yₜ.c.:($$ρχ_name) -= wdivₕ(Y.c.:($$ρχ_name) * ᶜu)
122+
for ρχ_name in filter(is_tracer_var, propertynames(Y.c)) # this one
123+
ᶜχ = @. lazy(specific(Y.c.:($$ρχ_name), Y.c.ρ))
124+
@. Yₜ.c.:($$ρχ_name) -= split_divₕ(Y.c.ρ * ᶜu, ᶜχ)
114125
end
115126

116127
if p.atmos.turbconv_model isa PrognosticEDMFX

src/utils/abbreviations.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const UVW = Geometry.UVWVector
1616

1717
const divₕ = Operators.Divergence()
1818
const wdivₕ = Operators.WeakDivergence()
19+
const split_divₕ = Operators.SplitDivergence()
1920
const gradₕ = Operators.Gradient()
2021
const wgradₕ = Operators.WeakGradient()
2122
const curlₕ = Operators.Curl()

0 commit comments

Comments
 (0)