Skip to content

Commit

Permalink
Use dispatch for pressure_work_tendency
Browse files Browse the repository at this point in the history
  • Loading branch information
Sbozzolo committed Oct 18, 2023
1 parent 065e6a5 commit 3209d1a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/prognostic_equations/implicit/implicit_tendency.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ NVTX.@annotate function implicit_tendency!(Yₜ, Y, p, t)
)
end
# NOTE: All ρa tendencies should be applied before calling this function
pressure_work_tendency!(Yₜ, Y, p, t, colidx, p.atmos.turbconv_model)
pressure_work_tendency!(Yₜ, Y, p, t, colidx)

# NOTE: This will zero out all monmentum tendencies in the edmfx advection test
# NOTE: This will zero out all momentum tendencies in the edmfx advection test
# please DO NOT add additional velocity tendencies after this function
zero_velocity_tendency!(Yₜ, Y, p, t, colidx)
end
Expand Down
21 changes: 15 additions & 6 deletions src/prognostic_equations/pressure_work.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,25 @@
##### Pressure work
#####

function pressure_work_tendency!(Yₜ, Y, p, t, colidx, ::EDMFX)
function pressure_work_tendency!(Yₜ, Y, p, t, colidx, ::EDMFX, ::TotalEnergy)
n = n_mass_flux_subdomains(p.atmos.turbconv_model)
(; ᶜp) = p.precomputed
for j in 1:n
if :ρe_tot in propertynames(Y.c)
@. Yₜ.c.sgsʲs.:($$j).ρae_tot[colidx] -=
ᶜp[colidx] / Y.c.ρ[colidx] * Yₜ.c.sgsʲs.:($$j).ρa[colidx]
end
@. Yₜ.c.sgsʲs.:($$j).ρae_tot[colidx] -=
ᶜp[colidx] / Y.c.ρ[colidx] * Yₜ.c.sgsʲs.:($$j).ρa[colidx]
end
return nothing
end

pressure_work_tendency!(Yₜ, Y, p, t, colidx, ::Any) = nothing
pressure_work_tendency!(Yₜ, Y, p, t, colidx) = pressure_work_tendency!(
Yₜ,
Y,
p,
t,
colidx,
p.atmos.turbconv_model,
p.atmos.energy_form,
)

pressure_work_tendency!(Yₜ, Y, p, t, colidx, turbconv_model, energy_form) =
nothing

0 comments on commit 3209d1a

Please sign in to comment.