Skip to content

tridiagonal coefficient inversion lacks singularity guard #2987

Description

@asalmgren

Location

  • Source/TimeIntegration/ERF_MakeFastCoeffs.cpp:243-247
  • Source/TimeIntegration/ERF_MakeFastCoeffs.cpp:293-296

Problem

The Thomas forward elimination computes bet and stores it in coeffB_a(i,j,k), then later inverts it unconditiona
lly:

coeffB_a(i,j,k) = 1.0 / coeffB_a(i,j,k);

No guard is present for near-zero diagonal values.

Why this is a bug

If the fast linear system becomes locally singular/ill-conditioned, this creates infinities/NaNs that then pollute m
omentum and conserved updates.

Suggested patch

Add a safety check before inversion (with abort for now; alternative is clamping with diagnostics).

--- a/Source/TimeIntegration/ERF_MakeFastCoeffs.cpp
+++ b/Source/TimeIntegration/ERF_MakeFastCoeffs.cpp
@@
-            ParallelFor(bx_shrunk_in_k, [=] AMREX_GPU_DEVICE (int i, int j, int k)
-            {
-                coeffB_a(i,j,k) = 1.0 / coeffB_a(i,j,k);
-            });
+            ParallelFor(bx_shrunk_in_k, [=] AMREX_GPU_DEVICE (int i, int j, int k)
+            {
+                Real b = coeffB_a(i,j,k);
+                if (amrex::Math::abs(b) <= 1.e-14_rt) {
+                    amrex::Abort("make_fast_coeffs: singular tridiagonal diagonal entry");
+                }
+                coeffB_a(i,j,k) = 1.0 / b;
+            });

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