Skip to content

AMR follow-ups: reflux corrects alt_soundspeed, 6-equation and HLL Method 1 sources; per-level memory table - #2519

Open
sbryngelson wants to merge 9 commits into
MFlowCode:masterfrom
sbryngelson:amr-followups-2
Open

sbryngelson wants to merge 9 commits into
MFlowCode:masterfrom
sbryngelson:amr-followups-2

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Contribution Policy

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.

Summary

The remaining AMR follow-ups, in one PR. More items land here as they are done; the list below is what is in it now.

Closes #2503, #2490 and #2502. Part of #2498 (its remaining item, the rest of #2449).

1. Reflux: the rest of the volume-fraction source correction (#2503, #2490)

#2505 refluxes the volume fractions with their alpha*div(u) correction. The same face velocity enters three more terms, which the reflux now corrects with the flux too. Each correction uses the outside coarse cell's own state, rebuilt from its conserved variables at apply time.

f_amr_usrc_coef returns the coefficient of the face velocity in each equation's rhs, so one update carries both corrections. The level ≥ 2 to parent state reflux now gives each GPU thread one transverse cell and walks the equations: it reads the outside cells' state before writing them. Single-fluid runs are unaffected.

2. Memory table (#2498, the rest of #2449)

  • Per level: each level's row adds the ghost-layer part of its store and its flux registers (one register slot per block).
  • GPU builds: one more line gives the device and host totals.

3. Sedov WENO5 NaN (#2502)

Reproduced on master: on a uniform 256³ octant, WENO5 + mp_weno goes NaN at the collapsing centre (t = 2.4e-3), and face_bound = 1 or 2 runs it to t = 0.02. That is the known missing positivity safeguard (#2469), not an mp_weno defect. The Sedov "Limits" note in validation_amr.md now says so and points at face_bound. Docs only.

Verification

Shear test (#2490's case). A steady shear u = 0.5 sin(2 pi y) of a uniform two-fluid mixture through a static 2:1 block; the exact solution keeps alpha = 0.5. Max |alpha_1 - 0.5| on level 0 (AMD CPU):

Model #2505 alone, N = 64 → 128 (order) this PR, N = 64 → 128 (order)
6-equation 2.19e-5 → 1.15e-5 (0.93) 1.10e-5 → 2.81e-6 (1.97)
5-equation, alt_soundspeed 1.46e-4 → 7.31e-5 (1.00) 1.06e-5 → 2.79e-6 (1.92)

The level-0 seam error goes from first to second order, and is 4× and 26× smaller at N = 128.

New goldens. Each fails on a #2505 build, using the same case files and comparing every output file:

Test difference from #2505
AMR -> 2D -> two-fluid shear layer -> alt_soundspeed (4E535E36) up to 7.4e-2 relative
... -> 6eq (CDD17C4E) up to 1.4e-2 relative
AMR -> 1D -> two-fluid -> stiffened gas at a static block face -> HLL (49E41590) max |p - 1| = 1.0e-14 here, 1.2e-2 on #2505

The shear-layer jump sits inside a coarse cell (y = 0.51), so the fine and coarse face velocities differ at the block's x-faces. With the jump on a coarse face the flow is exactly steady and nothing would be tested.

Suite. Full AMR suite 136/136 on the AMD CPU build and 136/136 on MI250X after rebasing onto master (Slurm 6002966, builds exit 0). No existing golden changes: none of them has a face velocity that varies along a block face. ./mfc.sh precheck: pass.

Memory table. AMR -> 2D -> multi-level static np=2 -> rank_time_wrt on 2 ranks prints, per level, 0.122 MiB store, of which 0.044 MiB ghost layers (36 %), and 0.007 MiB registers; the GPU build adds the device and host totals.

Made with Claude Code.

@sbryngelson sbryngelson added the claude-full-review Trigger Claude Code review label Nov 26, 2026
@sbryngelson

Copy link
Copy Markdown
Member Author

Checks on Frontier for the opening push:

More AMR follow-ups will land in this PR before it goes ready.

(Posted with Claude Code.)

@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 007153a

No review was produced. Claude ran but wrote no review (Claude step: failure). Run and transcript: https://github.com/MFlowCode/MFC/actions/runs/45894627720

@sbryngelson

Copy link
Copy Markdown
Member Author

@claude full review

@sbryngelson
sbryngelson marked this pull request as ready for review November 26, 2026 20:56
@sbryngelson
sbryngelson requested a review from a team as a code owner November 26, 2026 20:56
@sbryngelson
sbryngelson requested review from danieljvickers and removed request for a team November 26, 2026 20:56
@codecov

codecov Bot commented Nov 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.50420% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.57%. Comparing base (c158eee) to head (007153a).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_amr_registers.fpp 58.71% 26 Missing and 19 partials ⚠️
src/simulation/m_amr_distribution.fpp 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2519      +/-   ##
==========================================
- Coverage   66.59%   66.57%   -0.02%     
==========================================
  Files         112      112              
  Lines       31558    31635      +77     
  Branches     4856     4869      +13     
==========================================
+ Hits        21015    21062      +47     
- Misses       6561     6580      +19     
- Partials     3982     3993      +11     

☔ 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.

@sbryngelson

Copy link
Copy Markdown
Member Author

Fix for the four Frontier (CCE) failures, all one internal compiler error ("Subtree parent problem", ftn-7991) in s_amr_reflux_apply_faces:

  • Cause. The crash is in CCE's OpenACC/OpenMP loop lowering (v_mt_util_pdg.c); it persists at -O1 and -hvector0. The trigger is this PR's runtime do side = 1, 2 loop with side-indexed private arrays.
  • Fix. The two faces are now written out with the file's existing #:for, with per-face private scalars, as master's kernel was. The arithmetic is unchanged (the high face is q - w*dt*(c - fb)/m for q + w*dt*(fb - c)/m, identical in IEEE).
  • Checked on Frontier: simulation builds with CCE for --gpu acc and --gpu mp; AMD flang CPU and GPU builds and ./mfc.sh precheck pass. Tests are left to CI.

Also in this push: the #2502 note in validation_amr.md (docs only).

(Posted with Claude Code.)

MFlowCode#2312)

Level 2 joins across the seam and covers y = 13..44 without the unrefined
strip; amr.md notes that the tag buffer usually gives the two sides equal
extents.
@sbryngelson

Copy link
Copy Markdown
Member Author

Merged upstream master (includes #2486), which brings the regenerated goldens of F1BD319C and 872A4241 that failed on the previous head.

#2312 (oblique seam crossings): nothing to fix; a regression test is added.

  • Case. 2D, 128x64, two levels, amr_max_grid_size = 32. A disc (r = 0.15, centre y = 0.45) crosses the level-1 seam y = 28|29 off its centre.

  • Result. Level-2 blocks at step 6, master and this branch:

    level-2 y coverage
    master 13..28 and 29..44, joined across the seam
    union-growing join (tried, dropped) 13..25 and 32..44, a 6-cell unrefined strip
  • Conclusion. The existing seam join (AMR nesting: join level >= 2 blocks across parent seams #2382) already covers oblique crossings. The tag buffer gives both sides the same extents, so the change I tried only made things worse.

  • What is added. New golden 5713DE2B guards it. amr.md now says the join also applies to a disc crossing the seam off its centre.

#2496 item 3 (tile cost model): tried, not kept.

  • Setup. Frontier, 16 nodes, 128 MI250X GCDs, --case-optimization --gpu mp, the AMR benchmark case, 80 steps. Times are step-loop wall.

  • Sweep of pinned amr_max_grid_size.

    tile size step-loop wall
    master's derived rule 9.93 s, 9.87 s
    32 (512 level-1 boxes) 8.15 s
    40 8.50 s
    56 9.93 s

    16 and 24 hit amr_max_blocks and dropped refined area.

  • Rule tested. "Shrink toward 16 until 4 tiles per rank, capped at half the pool."

    run 1 run 2
    master 9.92 s 9.91 s
    rule 14.87 s 14.87 s

    It is 50 % slower. As the refined region shrinks between regrids, the rule keeps shrinking tiles toward the 16-cell floor to reach 4P tiles. A pinned 32 never goes below 32.

  • Status. The derived rule stays as in master. The gain from pinning 32 stays available through amr_max_grid_size. A rule that captures it would need a floor of about 32 cells rather than a tiles-per-rank target. That is left open on AMR tiling after #2461: thin tiles below the seam halo, pool truncation, worse balance on non-cube rank counts, no test #2496.

(Posted with Claude Code.)

@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_amr_registers.fpp 699 +108
src/simulation/m_phase_timing.fpp 166 +11
src/simulation/m_amr_distribution.fpp 617 +1
Directory Lines Diff
simulation 42893 +120
total 62949 +120

This branch has not been deployed

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

Labels

claude-full-review Trigger Claude Code review

1 participant