Skip to content

R2X silently assumes zero-based domain indexing #5049

@WeiqunZhang

Description

@WeiqunZhang
  • Type: Correctness / Indexing assumptions
  • Severity: High
  • Component: FFT R2X domain setup
  • Location:
    • Src/FFT/AMReX_FFT_R2X.H:259
    • Src/FFT/AMReX_FFT_R2X.H:267
    • Src/FFT/AMReX_FFT_R2X.H:299

Problem

R2X stores m_dom_rx = m_dom_0 (original box), but several derived domains are built with smallEnd = 0 and mixed length(...)/bigEnd(...) expressions. If domain.sm\ allEnd() != 0, later setBig(...) operations can generate invalid or truncated boxes.

Impact

  • Wrong internal layouts for non-zero-origin domains.
  • Potential invalid boxes, copy failures, or incorrect FFT results.

Suggested patch

If non-zero-origin support is not implemented in R2X, fail fast with an explicit invariant check.

--- a/Src/FFT/AMReX_FFT_R2X.H
+++ b/Src/FFT/AMReX_FFT_R2X.H
@@   
     AMREX_ALWAYS_ASSERT((m_dom_0.numPts() > 1) && (m_info.batch_size == 1));
+    AMREX_ALWAYS_ASSERT_WITH_MESSAGE(
+        m_dom_0.smallEnd() == IntVect(AMREX_D_DECL(0,0,0)),
+        "FFT::R2X currently requires domain.smallEnd() == 0");

Prepared by Codex

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