Skip to content

Commit

Permalink
Avoid dividing by zero in constexpr linear algebra routines (#1603)
Browse files Browse the repository at this point in the history
This fixes the crash in `Detonation-collision-retry-SDC` in the Castro
test suite.
  • Loading branch information
yut23 authored Jul 8, 2024
1 parent 4fc8892 commit 523b4be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions integration/VODE/vode_dvjac.H
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ void dvjac (int& IERPJ, BurnT& state, DvodeT& vstate)
int IER{};

#ifdef NEW_NETWORK_IMPLEMENTATION
RHS::dgefa(vstate.jac);
IER = 0;
IER = RHS::dgefa(vstate.jac);
#else
if (integrator_rp::linalg_do_pivoting == 1) {
constexpr bool allow_pivot{true};
Expand Down
10 changes: 9 additions & 1 deletion networks/rhs.H
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,22 @@ void dgesl (const RArray2D& a, RArray1D& b)
}

AMREX_GPU_HOST_DEVICE AMREX_INLINE
void dgefa (RArray2D& a)
int dgefa (RArray2D& a)
{

// LU factorization in-place without pivoting.

int info = 0;

amrex::constexpr_for<1, INT_NEQS>([&] (auto n1)
{
[[maybe_unused]] constexpr int k = n1;

// compute multipliers
if (a(k, k) == 0.0_rt) {
info = k;
return; // same as continue in a normal loop
}

amrex::Real t = -1.0_rt / a(k,k);
amrex::constexpr_for<k+1, INT_NEQS+1>([&] (auto n2)
Expand All @@ -340,6 +346,8 @@ void dgefa (RArray2D& a)
});
});
});

return info;
}

// Calculate the density dependence term for tabulated rates. The RHS has a term
Expand Down

0 comments on commit 523b4be

Please sign in to comment.