From 0050115f9c903fe347fbcfcf61c667740d0b0f3a Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <schaller@strw.leidenuniv.nl>
Date: Tue, 14 Nov 2023 11:12:21 +0100
Subject: [PATCH] Fix FPE in some strange MAGMA configuration

---
 src/hydro/MAGMA/hydro_iact.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/hydro/MAGMA/hydro_iact.h b/src/hydro/MAGMA/hydro_iact.h
index b7d979f7d2..d9da3766cc 100644
--- a/src/hydro/MAGMA/hydro_iact.h
+++ b/src/hydro/MAGMA/hydro_iact.h
@@ -327,7 +327,8 @@ __attribute__((always_inline)) INLINE static void runner_iact_nonsym_force(
           : 1.f;
 
   /* Van Leer limiter (eq. 21) */
-  const float fraction = 4.f * A_ij / ((1.f + A_ij) * (1.f + A_ij));
+  const float fraction =
+      (A_ij != -1.f) ? 4.f * A_ij / ((1.f + A_ij) * (1.f + A_ij)) : 1.f;
   const float Phi_ij = fmaxf(0.f, fminf(1.f, fraction)) * exp_term;
 
   /* Mid-point reconstruction, first order (eq. 17) */
-- 
GitLab