Skip to content

Fixes #1656: preserve MHD calculations with case optimization#1658

Open
StevenXue98 wants to merge 1 commit into
MFlowCode:masterfrom
StevenXue98:fix-mhd-case-opt
Open

Fixes #1656: preserve MHD calculations with case optimization#1658
StevenXue98 wants to merge 1 commit into
MFlowCode:masterfrom
StevenXue98:fix-mhd-case-opt

Conversation

@StevenXue98

Copy link
Copy Markdown

Description

Replace case-optimization guards based on num_dims with guards based on num_vels for three-component MHD calculations in the HLL and LF Riemann solvers.

MFC retains three velocity and magnetic-field components in 1D and 2D MHD cases. The previous dimensional guards compiled out required magnetic-pressure, relativistic-state, and energy-flux calculations in case-optimized lower-dimensional builds, causing the standard 2D MHD rotor example to produce NaNs.

The revised guards continue pruning three-component expressions from optimized lower-dimensional non-MHD builds while retaining them when num_vels=3.

Closes #1656.

Type of change

  • Bug fix

Testing

Tested with GNU Fortran 13.3.0 and Open MPI 4.1.6 on CPU with the following case-optimized HLL MHD cases:

  • 2D ideal-MHD rotor:
./mfc.sh run examples/2D_mhd_rotor/case.py \
  -t pre_process simulation -n 1 -j 1 \
  --no-debug --no-gpu --case-optimization
  • 1D ideal-MHD Brio–Wu:
./mfc.sh run examples/1D_brio_wu/case.py \
  -t pre_process simulation -n 1 -j 1 \
  --no-debug --no-gpu --case-optimization
  • 1D ideal-MHD Dai–Woodward:
./mfc.sh run examples/1D_dai_woodward/case.py \
  -t pre_process simulation -n 1 -j 1 \
  --no-debug --no-gpu --case-optimization
  • 2D ideal-MHD Orszag–Tang:
./mfc.sh run examples/2D_orszag_tang/case.py \
  -t pre_process simulation -n 1 -j 1 \
  --no-debug --no-gpu --case-optimization
  • Reduced 1D relativistic-MHD case:
./mfc.sh run tests/E0015186/case.py \
  -t pre_process simulation -n 1 -j 1 \
  --no-debug --no-gpu --case-optimization
  • Reduced 2D relativistic-MHD case:
./mfc.sh run tests/33FA33BE/case.py \
  -t pre_process simulation -n 1 -j 1 \
  --no-debug --no-gpu --case-optimization

All cases completed successfully with exit code 0. These runs cover the corrected HLL paths for ideal and relativistic MHD in both 1D and 2D.

Checklist

Check these like this [x] to indicate which of the below applies.

  • I added or updated tests for new behavior
  • I updated documentation if user-facing behavior changed

See the developer guide for full coding standards.

GPU changes (expand if you modified src/simulation/)
  • GPU results match CPU results
  • Tested on NVIDIA GPU or AMD GPU

AI code reviews

Reviews are not retriggered automatically. To request a review, comment on the PR:

  • @claude full review — Claude full review (also triggers on PR open/reopen/ready)
  • Or add label claude-full-review — Claude full review via label

@StevenXue98
StevenXue98 marked this pull request as ready for review July 18, 2026 07:51
@StevenXue98
StevenXue98 requested a review from sbryngelson as a code owner July 18, 2026 07:51
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.53%. Comparing base (bcd64d0) to head (c47915f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1658   +/-   ##
=======================================
  Coverage   59.53%   59.53%           
=======================================
  Files          83       83           
  Lines       21119    21119           
  Branches     3132     3132           
=======================================
  Hits        12574    12574           
  Misses       6439     6439           
  Partials     2106     2106           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Case optimization compiles out required MHD calculations in 1D/2D HLL cases

1 participant