Repository navigation
Give HLL's viscous energy flux a face velocity - #2054
aliencaocao wants to merge 2 commits into
Conversation
The loop that exports the HLL interface velocity for the non-conservative terms also writes it to vel_src_rsx_vf, the face velocity the shared viscous routine reads for the tau*u work term. HLLC already fills it; HLL never did, so the work term was inconsistent with the viscous flux and produced spurious cooling. The export condition is kept in one need_nc_vel flag, and the non-conservative export is unchanged. The viscous_shock_tube example is the only suite case combining HLL with viscosity; its golden is the only one that changes.
|
Claude Code Review Head SHA: 7abeb33 Files changed:
Findings: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2054 +/- ##
==========================================
- Coverage 61.90% 61.89% -0.01%
==========================================
Files 86 86
Lines 22885 22888 +3
Branches 3369 3371 +2
==========================================
+ Hits 14166 14167 +1
- Misses 6220 6221 +1
- Partials 2499 2500 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Lines of Code
|
wilfonba
left a comment
There was a problem hiding this comment.
I ran and visualized the 2D viscous shock tube, and this all looks to be correct. Merge away
|
can you better explain the code changes and side effects please? |
Side effects (not really sure what you mean by this, so I just listed what changes it makes to the results and runtime)
|
Fixes #2046.
Change
In
src/simulation/m_riemann_solver_hll.fpp, the loop that exports the HLL interface velocity for the non-conservative terms also writes it tovel_src_rsx_vfwhenviscous = T. That array is the one the shared viscous routine reads for the τ·u work term. The velocity is the existing HLL trace. It is upwind outside the wave fan and averaged inside it:The formula holds for every velocity component. The condition that selected this loop is kept in one logical,
need_nc_vel. The non-conservative export is therefore unchanged.Why this is correct
MFC's energy equation carries the viscous work in its flux, ∇·[(ρE + p)u − τ·u] (equations.md, Section 2.1). With a consistent face velocity, the internal energy then gains exactly the dissipation Φ = τ:∇u ≥ 0 (Mei, MIT 1.63J lecture notes, Eqs. 4.1.16 and 4.1.18). Ψ_u is the HLL flux of the quantity whose "flux" is u. This is the interface velocity that MFC already uses for HLL's volume fraction and Kapila terms (HLL_HLLC_non_conservative_terms_derivations.md, Section 3). HLLC uses its own star velocity for the same work term. For symmetric wave speeds, it reduces to the arithmetic mean of u_L and u_R. That mean is the face velocity of a central viscous flux (Coralic and Colonius 2014, Section 3.2).
Before and after
The figure below shows the Gaussian vortex from the issue on 64², 128² and 256² cells. Each panel shows the heating rate over the first 0.005 time units against the analytic dissipation Φ = 4μA²(r/R)⁴ exp(−2r²/R²).
Tests and goldens
The suite's
Viscouscases all run the default HLLC solver. The one suite case that combines HLL with viscosity is theviscous_shock_tubeexample. The golden was regenerated on CPU with GCC 16.2 in double precision without case optimization:70EC99CE2D -> Example -> viscous_shock_tubeContribution 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