Skip to content

eb_compute_div: eb_weights_type = 1 ("total energy" weights) computes rho*(rho*e + |u|^2/2) because CAMR's QREINT is rho*e, not e as in the CNS source it was ported from #119

Closed

Description

@WeiqunZhang

Severity: low · Category: eb
Locations: Source/Hydro/Hydro_utils_eb_K.H:547-553, Source/Hydro/Hydro_ctoprim.H:89
Based on commit 17997db (line numbers refer to that tree).

The defect

The flux-redistribution weight for eb_weights_type == 1 is

redistwgt = q(QRHO) * ( q(QREINT) + 0.5*(u^2 + v^2 [+ w^2]) )

(Hydro_utils_eb_K.H:547-553), copied from AMReX's CNS
(amrex/Tests/EB_CNS/Source/hydro/CNS_divop_K.H:298-302, option documented as "use total energy as
eb weights", CNS.cpp:442-445). In CNS q(QEINT) is the specific internal energy e, so the
product is the total energy density rhoe + rho|u|^2/2. In CAMR q(QREINT) is rho*e
(Hydro_ctoprim.H:89; every EB kernel relies on that: PLM_eb.H:145 enthalpy, compute_hyp_wallflux
passes it as the Riemann re, hydro_transd adds 0.5*rho*|u|^2 to it). The weight is therefore
rho^2 e + rho |u|^2/2: dimensionally inconsistent and not the total energy.

Why it matters

With CAMR.eb_weights_type = 1 the mass/momentum/energy taken out of small cut cells is
distributed to their neighbours with weights that scale like rho^2 e in the interior-energy
dominated limit, i.e. the option does not do what its name (and the CNS origin) says. The
redistribution remains conservative (any positive weight is), so only the local distribution of
the small-cell correction is affected. Default is eb_weights_type = 2 (rho), so no shipped
input is affected.

How to reach it

Any USE_EB build with CAMR.redistribution_type = FluxRedist and CAMR.eb_weights_type = 1
(e.g. Exec/SodPlusSphere, Exec/DoubleRamp), DIM = 2 or 3.

Suggested fix

--- a/Source/Hydro/Hydro_utils_eb_K.H
+++ b/Source/Hydro/Hydro_utils_eb_K.H
@@ -545,11 +545,13 @@ void eb_compute_div (int i, int j, int k, int n,
     if (eb_weights_type == 0) {
         redistwgt(i,j,k) = 1.0;
     } else if (eb_weights_type == 1) {
-        redistwgt(i,j,k) = q(i,j,k,QRHO)*( q(i,j,k,QREINT) +
+        // Total energy density; note QREINT is rho*e in CAMR (CNS's QEINT
+        // is e, which is where the old rho*(...) form came from).
+        redistwgt(i,j,k) = q(i,j,k,QREINT) + 0.5*q(i,j,k,QRHO)*(
 #if (AMREX_SPACEDIM == 2)
-                        0.5*(q(i,j,k,QU)*q(i,j,k,QU) + q(i,j,k,QV)*q(i,j,k,QV)) );
+                        q(i,j,k,QU)*q(i,j,k,QU) + q(i,j,k,QV)*q(i,j,k,QV) );
 #else
-                    0.5*(q(i,j,k,QU)*q(i,j,k,QU) + q(i,j,k,QV)*q(i,j,k,QV) + q(i,j,k,QW)*q(i,j,k,QW)) );
+                        q(i,j,k,QU)*q(i,j,k,QU) + q(i,j,k,QV)*q(i,j,k,QV) + q(i,j,k,QW)*q(i,j,k,QW) );
 #endif
     }
     else if (eb_weights_type == 2) {

(git apply --check OK; scratch copy in audit/notes/T5-scratch/008-eb-weights-energy.diff.)

Activity

  1. added a commit that references this issue on Nov 17, 2026
    e082e76
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