Skip to content

AMR: tag on vorticity, temperature or a species mass fraction - #2366

Open
sbryngelson wants to merge 4 commits into
MFlowCode:masterfrom
sbryngelson:amr-tag-vars
Open

sbryngelson wants to merge 4 commits into
MFlowCode:masterfrom
sbryngelson:amr-tag-vars

Conversation

@sbryngelson

@sbryngelson sbryngelson commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

AI-assisted (Claude Code). Completes #2310. Part of #2247.

What

Three more values of amr_tag_var:

Value Tagged quantity Notes
5 Vorticity magnitude times the cell size, ` curl u
6 Temperature Needs chemistry = T. Computed with get_temperature, the call s_compute_q_T_sf makes; the common indicator is applied
7 Mass fraction of species amr_tag_species (new parameter, default 1) Needs chemistry = T and amr_tag_abs = T; the common indicator is applied

The vorticity uses the velocity differences between a cell's two neighbours, weighted by dx/dy and dx/dz, so it is the curl on cells that are not square. On a fine block the stencil is clamped to the block and the difference is divided by the index gap, so a block edge gets a one-sided derivative. Everything stays on the host, as the other tag variables are.

Validator: amr_tag_var in 1 to 7; 5 rejected in 1D; 6 and 7 need chemistry; 7 needs amr_tag_abs = T and amr_tag_species >= 1. amr_tag_species <= num_species is a run-time check in m_checker.fpp, since the species count comes from the mechanism (as for inj_species). amr.md, case.md and the parameter descriptions are updated.

The default (amr_tag_var = 1) is unchanged: no existing golden changes.

Design choices to review

  • The vorticity is scaled by dx (the x cell size), not by a mean or minimum cell size, so the threshold has velocity units and halves per level for a resolved vortex.
  • A species tag requires the absolute indicator, as the velocity tag does: the relative one divides by a mass fraction that is zero in most of the domain. Temperature keeps the relative default.
  • The temperature is taken from get_temperature with the energy assembled in place and the default Newton guess, rather than by refactoring s_compute_q_T_sf into a per-cell routine, which would have risked roundoff changes in existing goldens.

How it was checked

Frontier, CPU:

  • New test AMR -> 2D -> tag vorticity (06E1CE23): a Gresho vortex of uniform density on a 64x32 base with dx != dy, two refined levels, amr_tag_eps = 0.05. The golden's D/amr_levels line has 5184 fine cells on level 1 (the initial block has 2048) and 2816 on level 2. A density tag cannot see this flow.
  • Magnitude: in the vortex core the analytic |curl u| * dx is 0.158; level 0 tags the core at a threshold of 0.15 and nothing at 0.165. Without the aspect weighting the value would be 0.118. On level-1 data the core is tagged at 0.07 and not at 0.1 (expected 0.079).
  • New test 1D -> Chemistry -> Reactive Shocktube AMR -> Tag Temperature (08A73A90): the block starts at cells 4 to 11 and regrids onto the diaphragm at cell 24. Same example and mechanism as the existing reactive shocktube AMR tests, so no extra chemistry build.
  • The AMR group passes (117 tests) on a build made after the last edit; test_case_validator.py passes (198), with the new assertions written first and seen to fail.

Not checked

  • Species tagging (amr_tag_var = 7) has validator coverage only: no run, and the run-time amr_tag_species > num_species abort was not exercised.
  • 3D vorticity, more than one rank for the new tests, GPU builds (CI covers the lanes), case-optimized builds.
  • One unexplained observation: with 8x8-cell level-1 tiles and a threshold of 0.085, level-2 blocks still appear although the core value is 0.079. The suspicion is one-sided differences at tile edges across the velocity kink at r = 0.2; it was not confirmed, and does not occur with larger boxes at 0.1.

The tag sweep called the indicator per cell, which evaluated the tagged
variable at the cell and its neighbours through function calls: seven
evaluations per cell in 3D. Evaluate it once per cell into a local array
and difference that. Same tags.
amr_tag_var = 5 tags where the vorticity magnitude times the cell size
exceeds amr_tag_eps (central velocity differences, one-sided at a clamped
block edge); 6 tags on the temperature and 7 on the mass fraction of
species amr_tag_species (chemistry). Tests: a Gresho vortex of uniform
density tracked on two levels, and the reactive shocktube regridded onto
its temperature jump.
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 2d8e3da

Files changed:

  • 11
  • docs/documentation/amr.md
  • docs/documentation/case.md
  • src/simulation/m_amr_nest.fpp
  • src/simulation/m_amr_regrid.fpp
  • src/simulation/m_checker.fpp
  • src/simulation/m_global_parameters.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/params/definitions.py
  • toolchain/mfc/params/descriptions.py
  • toolchain/mfc/test/cases.py

Findings:
No issues found. Checked in step 4: m_amr_nest.fpp, m_amr_regrid.fpp, m_checker.fpp, m_global_parameters.fpp, descriptions.py and amr.md (the validator and tests were read from the diff only).

Low-confidence nit, not a finding: f_amr_tag_val_* divides by r unguarded in the amr_tag_var == 6 branch (Ys(f) = .../r and .../r). The species (7) and velocity (3) branches use max(r, 1.e-30_wp). A cell with zero density is unlikely in practice.

# Conflicts:
#	src/simulation/m_amr_nest.fpp
#	src/simulation/m_amr_regrid.fpp
@sbryngelson
sbryngelson marked this pull request as ready for review November 21, 2026 18:38
@sbryngelson
sbryngelson requested a review from a team as a code owner November 21, 2026 18:38
@sbryngelson
sbryngelson requested review from wilfonba and removed request for a team November 21, 2026 18:38
# Conflicts:
#	toolchain/mfc/test/cases.py
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_amr_nest.fpp 495 +48
src/simulation/m_amr_regrid.fpp 941 +4
src/simulation/m_checker.fpp 77 +1
src/simulation/m_global_parameters.fpp 963 +1
Directory Lines Diff
simulation 41214 +54
total 61284 +54

@sbryngelson

Copy link
Copy Markdown
Member Author

Re-check after resolving the toolchain/mfc/test/cases.py conflict with master (merge e20a91a, both sides' tests kept): Frontier CPU build (-c frontier_amd --no-gpu), AMR group, 120 passed, including the two new tests 06E1CE23 (tag vorticity) and 08A73A90 (Tag Temperature). The other 7 in the run were Convergence tests that cannot launch on Frontier compute nodes through the test runner; the Convergence CI job runs them.

@codecov

codecov Bot commented Nov 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.66667% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.80%. Comparing base (4264341) to head (e20a91a).
⚠️ Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
src/simulation/m_amr_nest.fpp 75.00% 3 Missing and 4 partials ⚠️
src/simulation/m_amr_regrid.fpp 33.33% 0 Missing and 4 partials ⚠️
src/simulation/m_checker.fpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2366      +/-   ##
==========================================
+ Coverage   65.72%   65.80%   +0.08%     
==========================================
  Files         111      111              
  Lines       30549    30712     +163     
  Branches     4673     4699      +26     
==========================================
+ Hits        20079    20211     +132     
+ Misses       6699     6696       -3     
- Partials     3771     3805      +34     

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

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant