Skip to content

Conversation

@haakon-e
Copy link
Member

@haakon-e haakon-e commented Oct 23, 2025

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 WVec and UV as a shorthand for Geometry.WVector, and Geometry.UVVector, respectively, to aid code clarity (UV is 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 like vertical_transport, vertical_transport_sedimentation, and all their call sites in advection.jl and implicit_tendency.jl. [1] [2] [3]

  • The explicit and implicit vertical advection tendencies (explicit_vertical_advection_tendency! and implicit_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:

  • EDMFX subdomain routines now use the refactored density fields for all updraft, tracer, and sedimentation advection calculations, reducing code duplication and improving consistency in how area fractions and densities are handled. [1] [2] [3] [4] [5] [6]

Jacobian matrix construction updates:

  • The construction of advection matrices within the manual sparse Jacobian routines has been updated to use face densities, aligning the matrix assembly with the new advection logic and improving consistency between explicit and implicit schemes. [1] [2] [3] [4]

General code cleanup and simplification:

  • Redundant or outdated code patterns (such as repeated manual combinations of Jacobian and density fields) have been removed, and function signatures have been streamlined for clarity and maintainability. [1] [2]

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-weighted face_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(ᶜρ) to face_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.

@haakon-e haakon-e force-pushed the he/face-density branch 4 times, most recently from d9b10d4 to 0db5c3e Compare October 23, 2025 19:17
@haakon-e haakon-e changed the title add face density method rft: add face density method Oct 23, 2025
@haakon-e haakon-e force-pushed the he/face-density branch 2 times, most recently from 6c5903a to c6e9e44 Compare October 24, 2025 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants