Skip to content

plm_slope/plm_pslope: order-2 branch returns 4/3 of the centered slope (dfm=dfp=0) #84

Closed

Description

@WeiqunZhang

Severity: medium · Category: physics-numerics · Fix order: 12 of 25 — fix this 12th.

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

Location: Source/Hydro/Godunov/PLM.H:75

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

The defect

What is wrong — For order==2, plm_slope returns min(dlim, (4/3)|dcen|) because the 4th-order blend dtemp = 4/3*dcen - 1/6*(dfp+dfm) is evaluated with dfm=dfp hardwired to 0, so the slope is 4/3 of the correct centered slope; plm_pslope (line 158) has the same defect.

Why it matters

Any USE_EB=TRUE Godunov run (do_mol=0; MOL never calls plm_slope -- it has its own mol_slope_* kernels): plm_slope_eb falls back to plm_slope(...,2) at every cell within 2 cells of a covered cell (also any run with plm_iorder=2). For exactly linear data q=a+bx the returned slope is (4/3)bdx instead of bdx (order-4 path returns bdx exactly), creating an artificial jump of bdx/3 at every face and spurious Riemann dissipation on smooth flow near the EB.

Suggested fix

Make the fourth-order blend conditional on order == 4 in both plm_slope and plm_pslope, so the order-2 path returns the plain MC-limited centered slope. Since dlim is already 2*min(|dlft|,|drgt|), that reproduces AMReX's own amrex_calc_xslope order-2 branch (AMReX_Slopes_K.H) exactly, and leaves order-4 results bit-for-bit unchanged.

This is a regression from b5e063e (#27), which wrapped the dfm/dfp stencil in if (order == 4) and flipped the plm_iorder default 2 to 4 without adding the matching dtemp branch; before it, every call computed the full blend, so order 2 was unreachable. The vestigial (order == 4) ? qp2 - qp : 0.0 on line 59 is the same leftover and can go.

Your call: EB Godunov and plm_iorder=2 baselines will shift (less dissipation on smooth flow), and plm_slope_eb's order > 1 fallback silently maps any other value to 2, so consider validating plm_iorder in {1,2,4} at parse time. Nothing else must land with this.

--- a/Source/Hydro/Godunov/PLM.H
+++ b/Source/Hydro/Godunov/PLM.H
@@ -72,7 +72,7 @@
       dlim = (dlft * drgt >= 0.0)
                ? 2.0 * std::min(std::abs(dlft), std::abs(drgt)) : 0.0;
 
-      dtemp = 4.0 / 3.0 * dcen - 1.0 / 6.0 * (dfp + dfm);
+      dtemp = (order == 4) ? 4.0 / 3.0 * dcen - 1.0 / 6.0 * (dfp + dfm) : dcen;
 
       return flat * dsgn * std::min(dlim, std::abs(dtemp));
   }
@@ -155,6 +155,6 @@
       dlim = (dlft * drgt >= 0.0)
                ? 2.0 * std::min(std::abs(dlft), std::abs(drgt)) : 0.0;
 
-      dtemp = 4.0 / 3.0 * dcen - 1.0 / 6.0 * (dfp + dfm);
+      dtemp = (order == 4) ? 4.0 / 3.0 * dcen - 1.0 / 6.0 * (dfp + dfm) : dcen;
 
       amrex::Real dp = flat * dsgn * std::min<amrex::Real>(dlim, std::abs(dtemp));

Applies the 4th-order blend only when order==4; otherwise uses the plain centered slope, so order==2 becomes the standard MC-limited slope (exact b*dx on linear data). Same one-line change in plm_slope and plm_pslope. No AMReX API involved. Maintainer may optionally drop the now-vestigial (order == 4) ? on drgt at line 59, which is already inside the order-4 guard.

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

F036 — confirmed (one verifier lens)

Lens 1 (refutation attempt): PLM.H:41 initializes dfm = 0.0, dfp = 0.0; they are assigned only inside if (order == 4) (lines 48-66), yet line 75 unconditionally computes dtemp = 4.0/3.0 * dcen - 1.0/6.0 * (dfp + dfm), so order==2 returns min(dlim, 4/3|dcen|) = (4/3)s on linear data (dlim=2|s| does not bind). plm_pslope line 158 is identical. Vestigial drgt = (order == 4) ? qp2 - qp : 0.0; at line 59 inside the order-4 guard shows the lost else dtemp = dcen branch. Reachable in every EB Godunov run: Godunov_3D_eb.cpp:148 forces PLM with EB, and PLM_eb.H:54/:101 fall back to plm_slope(...,2) near covered cells. Caveat: MOL does not use these functions (own mol_slope_* kernels), so 'Godunov/MOL' is overbroad; affects Godunov only. May relate to open issue #70 only if that comparison ran the Godunov (not do_mol=1) path. git -S shows the expression unchanged since the initial commit.


Based on commit 8f87fa8, which is also the tree the audit verified against. From an automated audit of Source/, Tutorials/ and Util/. Audit finding id: F036. Reviewer unit(s): PPM+PLM. 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 Aug 23, 2026
    6b3a6cd
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