Skip to content

cj_detonation density grid mismatch and missing Finalize #1944

@BenWibking

Description

@BenWibking

cj_detonation uses inconsistent density-grid spacing and misses amrex::Finalize()

Summary

util/cj_detonation/main.cpp computes dlogrho using npts (100) but iterates over npts_ad (150), so sampled densities overshoot intended rho_max. The same function returns without calling amrex::Finalize().

Severity

High

Affected Code

  • util/cj_detonation/main.cpp
    • grid setup around lines 41-42 and 97
    • sampling loop around lines 134-137
    • process exit around line 159

Why This Is a Bug

  • Density spacing mismatch distorts Hugoniot/adiabat sampling and can produce out-of-range physical states.
  • Missing amrex::Finalize() is inconsistent with other AMReX drivers in this repo and can skip orderly runtime teardown.

Proposed Patch

  1. Compute dlogrho from the same point count used by the loop (npts_ad).
  2. Call amrex::Finalize() before returning from main().
--- a/util/cj_detonation/main.cpp
+++ b/util/cj_detonation/main.cpp
@@
-  Real dlogrho = (std::log10(rho_max) - std::log10(rho_min)) / static_cast<Real>(npts-1);
+  Real dlogrho = (std::log10(rho_max) - std::log10(rho_min)) / static_cast<Real>(npts_ad-1);
@@
-  return 0;
+  amrex::Finalize();
+  return 0;

Validation

  • Verify first/last sampled rho in output match rho_min and rho_max (within floating-point tolerance).
  • Run executable and confirm normal completion with AMReX teardown behavior consistent with other tools.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-code-auditAI-generated code audit findings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions