Skip to content

MHD utility transforms do not consistently carry QFX/UFX auxiliary fields #3249

Description

@WeiqunZhang

Summary

The MHD primitive/conserved conversion helpers only treat species (QFS/UFS) and omit auxiliary composition fields (QFX/UFX). In ConsToPrim, QFX is read for EOS input without being initialized from UFX. In PrimToCons/PToC, UFX is never written from primitive data. In qflux, QFX updates are not computed.

Location

  • Source/mhd/mhd_util.H:124
  • Source/mhd/mhd_util.H:136
  • Source/mhd/mhd_util.H:40
  • Source/mhd/mhd_util.H:173
  • Source/mhd/mhd_util.cpp:101

Problem Details

Current patterns:

  • ConsToPrim sets QFS from UFS, then reads q_zone[QFX+n] into eos_state.aux[n] without initializing QFX.
  • PrimToCons and PToC write UFS but do not write UFX.
  • qflux computes primitive flux updates for QFS but not QFX.

When NAUX_NET > 0, this can feed undefined aux data into EOS and leave auxiliary transport state inconsistent.

Impact

  • Undefined aux inputs to EOS in MHD update path.
  • Missing or corrupted auxiliary advection updates.
  • Potential non-deterministic behavior in runs/networks that use auxiliary variables.

Suggested Patch

diff --git a/Source/mhd/mhd_util.H b/Source/mhd/mhd_util.H
--- a/Source/mhd/mhd_util.H
+++ b/Source/mhd/mhd_util.H
@@
   for (int n = 0; n < NumSpec; n++) {
     qflx[QFS+n] = (flx[UFS+n] - flx[URHO] * q_zone[QFS+n]) / q_zone[QRHO];
   }
+#if NAUX_NET > 0
+  for (int n = 0; n < NumAux; n++) {
+    qflx[QFX+n] = (flx[UFX+n] - flx[URHO] * q_zone[QFX+n]) / q_zone[QRHO];
+  }
+#endif
@@
   for (int n = 0; n < NumSpec; n++) {
     q_zone[QFS+n] = U_zone[UFS+n] / U_zone[URHO];
   }
+#if NAUX_NET > 0
+  for (int n = 0; n < NumAux; n++) {
+    q_zone[QFX+n] = U_zone[UFX+n] / U_zone[URHO];
+  }
+#endif
@@
   for (int n = 0; n < NumSpec; n++) {
     U(UFS+n) = U(URHO) * q(QFS+n);
   }
+#if NAUX_NET > 0
+  for (int n = 0; n < NumAux; n++) {
+    U(UFX+n) = U(URHO) * q(QFX+n);
+  }
+#endif

diff --git a/Source/mhd/mhd_util.cpp b/Source/mhd/mhd_util.cpp
--- a/Source/mhd/mhd_util.cpp
+++ b/Source/mhd/mhd_util.cpp
@@
     for (int n = 0; n < NumSpec; n++) {
       u_arr(i,j,k,UFS+n) = q_arr(i,j,k,QRHO) * q_arr(i,j,k,QFS+n);
     }
+#if NAUX_NET > 0
+    for (int n = 0; n < NumAux; n++) {
+      u_arr(i,j,k,UFX+n) = q_arr(i,j,k,QRHO) * q_arr(i,j,k,QFX+n);
+    }
+#endif

Prepared by Codex

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions