Skip to content

Diffusion ring problems miss MHD guard #181

Description

@BenWibking

Diffusion ring problems miss MHD guard

Summary

The diffusion problem generator rejects Euler runs for magnetic iprob values 0, 1,
2, 10, 20, and 40, but not for iprob=21 or iprob=22.

Why this is a bug

Both iprob=21 and iprob=22 initialize magnetic field components (IB1..IB3).
With hydro/fluid=euler, those components are not allocated. The current guard lets
those inputs through and then writes out of bounds inside the initialization kernel.

Patch

diff --git a/src/pgen/diffusion.cpp b/src/pgen/diffusion.cpp
--- a/src/pgen/diffusion.cpp
+++ b/src/pgen/diffusion.cpp
@@
-  PARTHENON_REQUIRE_THROWS(mhd_enabled || !(iprob == 0 || iprob == 1 || iprob == 2 ||
-                                            iprob == 10 || iprob == 20 || iprob == 40),
+  PARTHENON_REQUIRE_THROWS(mhd_enabled || !(iprob == 0 || iprob == 1 || iprob == 2 ||
+                                            iprob == 10 || iprob == 20 || iprob == 21 ||
+                                            iprob == 22 || iprob == 40),
                            "Selected iprob for diffusion pgen requires MHD enabled.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-code-auditIssues identified by AI-assisted code audit

    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