rft: add face density method #4071
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the handling of face density in vertical advection and sedimentation routines throughout the codebase. The main goal is to consistently use face densities (
ᶠρ) instead of manually combining cell and face Jacobians and densities at each call site. This improves code clarity, reduces duplication, and ensures more robust and maintainable implementations of advection and sedimentation tendencies.It also introduces
WVecandUVas a shorthand forGeometry.WVector, andGeometry.UVVector, respectively, to aid code clarity (UVis not applied in this PR however, but is available for future code changes).Vertical advection and sedimentation refactor:
All vertical advection and sedimentation routines now consistently use face densities (
ᶠρ = face_density(ᶜρ)) and composite fields (ᶠρJ,ᶜρJ) rather than manually combining cell and face Jacobians and densities at each call site. This affects functions likevertical_transport,vertical_transport_sedimentation, and all their call sites inadvection.jlandimplicit_tendency.jl. [1] [2] [3]The explicit and implicit vertical advection tendencies (
explicit_vertical_advection_tendency!andimplicit_vertical_advection_tendency!) have been updated to use the new composite density fields, simplifying expressions and ensuring correct handling of density across cell and face fields. [1] [2] [3] [4] [5]EDMFX updraft and tracer advection improvements:
Jacobian matrix construction updates:
General code cleanup and simplification:
This refactor should make the code easier to read, less error-prone, and more maintainable.
Notes
There is about two dozen instances of
ᶠinterp(Y.c.ρ)orᶠinterp(ᶜρ)in the code base. Whether that is appropriate, or the Jacobian-weightedface_density(as introduced by this PR) should be used instead, is up for discussion and may require deeper analysis. In particular, any potential changes fromᶠinterp(ᶜρ)toface_density(ᶜρ)must be considered in the tendency and jacobian simultaneously, for consistency. This PR should be a pure refactor, having no impact on actual simulations.