Skip to content

FillPatcher time interpolation divides by m_dt_crse without zero guard #2990

@asalmgren

Description

@asalmgren

Location

  • Source/BoundaryConditions/ERF_FillPatcher.H:130-131
  • Source/BoundaryConditions/ERF_FillPatcher.cpp:226,243

Problem

RegisterCoarseData() allows crse_time[1] == crse_time[0] and sets:

m_dt_crse = crse_time[1] - crse_time[0];

Fill() then computes:

fac_new = (time - m_crse_times[0]) / m_dt_crse;

No guard exists for m_dt_crse == 0.

Why this is a bug

This can produce NaN/Inf interpolation factors and corrupt boundary-filled data when coarse snapshots share the same
timestamp.

Suggested patch

Handle zero-interval coarse data explicitly.

--- a/Source/BoundaryConditions/ERF_FillPatcher.H
+++ b/Source/BoundaryConditions/ERF_FillPatcher.H
@@
-    amrex::Real fac_new = (time - m_crse_times[0]) / m_dt_crse;
-    amrex::Real fac_old = 1.0 - fac_new;
+    amrex::Real fac_new = 0.0;
+    amrex::Real fac_old = 1.0;
+    if (amrex::Math::abs(m_dt_crse) > eps) {
+        fac_new = (time - m_crse_times[0]) / m_dt_crse;
+        fac_old = 1.0 - fac_new;
+    }

Optionally add an assert in RegisterCoarseData() if equal coarse times are unsupported.

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