Repository navigation
Transport volume fractions in the LF solver - #2050
aliencaocao wants to merge 3 commits into
Conversation
The Lax-Friedrichs advection flux carries the transport term like the mass flux beside it, and its source exports the shared face-normal interface velocity, which is what the adv_src_mode_vel_iface contract assigns to this solver. The cylindrical geometric source of the volume fractions is zero, as it already is for HLL. Adds an axisymmetric LF suite case; the six existing LF cases with two fluids change. Fixes MFlowCode#1818.
|
Claude Code Review Head SHA: 6f33861 Files changed:
Findings: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2050 +/- ##
==========================================
+ Coverage 61.90% 61.92% +0.02%
==========================================
Files 86 86
Lines 22885 22885
Branches 3369 3369
==========================================
+ Hits 14166 14171 +5
+ Misses 6220 6215 -5
Partials 2499 2499 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Lines of Code
|
|
@sbryngelson, I ran the reproducer for this myself and confirmed the implemented equations reduce to the correct flux. I am confident this change is correct and improves the code. It is ready to merge once the runners finish. It's a ~6-line source-code change + regenerated golden files for affected numerics. It failed a documentation runner for some reason, but I just restarted it. Hopefully that fixes the issue. |
|
@aliencaocao I believed the failed runners just need to be restarted, but I don't think I get that option till the rest of the suite finishes. |
Fixes #1818.
Change
src/simulation/m_riemann_solver_lf.fpphands the right-hand side whatadv_src_mode_vel_iface(the modem_global_parameters.fppassigns toriemann_solver = 5) expects:With the Lax-Friedrichs speeds s_M = −s_P, these are exactly the Method 2 formulas of MFC's HLL_HLLC_non_conservative_terms_derivations.md, Section 3. This is the same code path that HLL already uses with
hll_u_interface = T(m_riemann_solver_hll.fpplines 586 to 608). That path includes the zero radial source for α (lines 683 to 690).Why this is correct
The five-equation model advects each volume fraction, ∂αₖ/∂t + u·∇αₖ = 0 (Coralic and Colonius 2014, Eq. 5). MFC discretises this as ∂αₖ/∂t + ∇·(αₖu) = αₖ∇·u, with one shared interface velocity (Coralic and Colonius 2014, Section 3.1). Both terms are built from the same velocity u*. A sum over the fluids then gives
The fractions therefore still sum to one, and a uniform α stays uniform. This is the requirement that uniform pressure and velocity stay uniform across an interface (Saurel and Abgrall 1999, Section 3). In cylindrical coordinates, the (1/r)∂(r αu_r)/∂r and α(1/r)∂(r u_r)/∂r terms share the same αu_r/r part. The radial geometric source of α therefore cancels exactly. Before this PR, neither term carried u·∇α. A bubble's volume fraction did not move, while its mass did.
Before and after
The figures below show interface advection from the issue: a light gas bubble in air, in a periodic box. The flow has uniform pressure and velocity (1, 0). The time is t = 0.4. The exact answer moves the bubble from x = 0.3 to x = 0.7.
Tests and goldens
The existing Lax-Friedrichs cases with two fluids were generated with the defect and change. The suite had no axisymmetric Lax-Friedrichs case. One is added next to the existing axisymmetric HLL cases (
2D -> Axisymmetric -> LF): the stratified two-fluid problem with radial waves. That problem exercises the radial geometric source that this PR changes. It fails on the original code against the new golden. The goldens were regenerated on CPU with GCC 16.2 in double precision without case optimization:27B24CD91D -> 2 Fluid(s) -> Viscous -> riemann_solver=54AADC8483D -> 2 Fluid(s) -> riemann_solver=5 -> mixture_err4C8126372D -> 2 Fluid(s) -> Viscous -> riemann_solver=596AF00B31D -> 2 Fluid(s) -> riemann_solver=5 -> mixture_err9730B2DF2D -> 2 Fluid(s) -> riemann_solver=5 -> mixture_errAD1A50B73D -> 2 Fluid(s) -> Viscous -> riemann_solver=5B44AF4A12D -> Axisymmetric -> LF(new)Every other test in the suite passes unchanged against its existing golden (from a full suite run with the same compiler and flags).
Contribution Policy
We do not accept pull requests generated primarily by AI without genuine understanding or real-world usage context.
All contributions are expected to demonstrate:
If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.
Acknowledgement
PR template credit: junegunn