Skip to content

vorticity_greater tags on "mag_vort" but derive is registered "magvort"; regrid aborts #90

Closed

Description

@WeiqunZhang

Severity: high/medium · Category: correctness · Fix order: 6 of 25 — fix this 6th.

Filenames are numbered in reverse fix order: 001 = fix last, 025 = fix first. This file is 020.

Location: Source/Utils/CAMR_error.cpp:73

Based on commit 8f87fa8 (line numbers refer to that tree).

F001 and F037 are the same one-line defect found twice; a single edit closes both.

The defect

What is wrong — The vorticity_greater refinement indicator derives field "mag_vort", but the vorticity derive is registered as "magvort" (CAMR_setup.cpp:240), so CAMR::errorEst always aborts with 'unknown variable: mag_vort'. Reported independently at this same line by F037; each reviewer's own wording and evidence is under Verification evidence below.

Why it matters

Any build with inputs 'amr.refinement_indicators = v' and 'amr.v.vorticity_greater = 1.e4': at the first regrid, errorEst calls derive("mag_vort", time, 0), which falls through to AmrLevel::derive and hits amrex::Error("AmrLevel::derive(MultiFab*): unknown variable: mag_vort"), killing the run. The feature is unusable.

How to reach it

  • Any build (2D/3D, EB or not, GPU/CPU). E.g. Exec/Sod/inputs-x with amr.max_level=1, amr.refinement_indicators=v, amr.v.vorticity_greater=1.e4 — aborts at first errorEst during initial grid generation.

Suggested fix

Fix the tag side, not the derive: set field="magvort" at CAMR_error.cpp:73 so it matches derive_lst.add("magvort", ...) in Source/Utils/CAMR_setup.cpp:240. "magvort" is the PeleC-inherited spelling users already put in amr.derive_plot_vars and in post-processing scripts, so renaming the derive instead would break plotfiles. The "mag_vort" spelling is IAMR's: this block was copied from IAMR, and the stale comment at CAMR_error.cpp:91 still refers to "NS_setup.cpp".

Nothing else is needed. AMRErrorTag::SetNGrow() returns 0 for VORT and magvort is registered with grow_box_by_one, so derive(name,time,0) is legal; AmrLevel::derive allocates with the level's m_factory, so the VORT branch's covered-cell skip and CAMR_dermagvort's one-sided cut-cell stencils both work as-is.

Maintainer decisions: no Exec input exercises vorticity_greater — adding a 2D case would have caught this (the derive returns 0 in 1D, so it must not be a 1D test). Consider also validating each errtag's Field() against desc_lst/derive_lst inside error_setup, so typos in the user-supplied field_name for value_greater/value_less/adjacent_difference_greater abort at setup with a clear message rather than at the first regrid.

For Source/Utils/CAMR_error.cpp:73 (F001):

--- a/Source/Utils/CAMR_error.cpp
+++ b/Source/Utils/CAMR_error.cpp
@@ -70,7 +70,7 @@
             int num_val = ppr.countval("vorticity_greater");
             Vector<Real> value(num_val);
             ppr.getarr("vorticity_greater",value,0,num_val);
-            const std::string field="mag_vort";
+            const std::string field="magvort";
             errtags.push_back(AMRErrorTag(value,AMRErrorTag::VORT,field,info));
         }
         else if (ppr.countval("adjacent_difference_greater")) {

Uses the derive name actually registered in CAMR_setup.cpp:240 (derive_lst.add("magvort", ...)); "mag_vort" appears nowhere else in the repo, so errorEst's derive() call no longer falls through to AmrLevel::derive's unknown-variable abort. No input-file compatibility impact: the string is internal, not user-facing.

Diff(s) are against 8f87fa8, written from the current source and verified only with git apply --check — never compiled, never run, never applied to the tree. Treat them as precise intent, not tested patches.

Verification evidence

F001 — confirmed (two independent verifier lenses)

Lens 1 (refutation attempt): CAMR_error.cpp:73: const std::string field="mag_vort"; for VORT tags, but CAMR_setup.cpp:240 registers derive_lst.add("magvort", ...); "mag_vort" appears nowhere else in the repo. CAMR::derive (CAMR.cpp:1083) special-cases only vfrac/volfrac then forwards to AmrLevel::derive, whose fallthrough is amrex::Error("AmrLevel::derive(MultiFab*): unknown variable: ") (AMReX_AmrLevel.cpp:1732). Guaranteed abort at first regrid with vorticity_greater set. Downgraded to medium: loud fail-fast abort of an optional feature, not silent corruption.

Lens 2 (reachability/intent): CAMR_error.cpp:73 hardcodes field="mag_vort" for AMRErrorTag::VORT; CAMR_setup.cpp:240 registers the derive as "magvort". errorEst (CAMR_error.cpp:147) calls derive("mag_vort"); CAMR::derive (CAMR.cpp:1083) special-cases only vfrac/volfrac then falls to AmrLevel::derive, which hits amrex::Error("unknown variable: mag_vort") (AMReX_AmrLevel.cpp:1732). Both strings from initial commit 0656702; block comment cites IAMR's NS_setup.cpp (where derive IS "mag_vort") — copy mismatch, not intent.

F037 — confirmed (one verifier lens)

Reported as: error_setup registers the vorticity_greater refinement indicator with field name "mag_vort", but the derive registered in CAMR_setup.cpp:240 is named "magvort", so errorEst's derive("mag_vort",...) hits AmrLevel::derive's unknown-variable abort.

Failure scenario: Any inputs file using 'amr.refinement_indicators = vort' with 'amr.vort.vorticity_greater = ': on the first regrid, CAMR::errorEst calls derive(errtags[j].Field()="mag_vort", time, 0), which is neither a state variable nor a registered derive, and the run aborts with "AmrLevel::derive(MultiFab*): unknown variable: mag_vort".

Lens 1 (refutation attempt): Duplicate of F001. errorEst (CAMR_error.cpp:147) calls derive(errtags[j].Field(), time, errtags[j].NGrow()) with Field()=="mag_vort"; no state variable or registered derive has that name (state names are density/xmom/.../rho_E/rho_e/Temp; derive is "magvort"), so AmrLevel::derive hits the unknown-variable amrex::Error. git log -S shows the line unchanged since the initial commit — not fixed.


Based on commit 8f87fa8, which is also the tree the audit verified against. From an automated audit of Source/, Tutorials/ and Util/. Audit finding ids: F001, F037. Reviewer unit(s): Derive, Utils-misc, theme:ghost-fillpatch. Nothing here was compiled or run — the failure scenarios are code reasoning, so the reaching configuration above is the cheapest way to confirm or refute it.

Activity

  1. added a commit that references this issue on Nov 17, 2026
    88e2446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions