From 5abaf48d29b1c185f8c08c485b2496bdccaa9fb1 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Thu, 11 Jan 2024 18:38:40 -0500 Subject: [PATCH] fix an FPE in the shock detection --- Source/hydro/advection_util.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/hydro/advection_util.cpp b/Source/hydro/advection_util.cpp index c75bf51268..3fe363592a 100644 --- a/Source/hydro/advection_util.cpp +++ b/Source/hydro/advection_util.cpp @@ -151,9 +151,12 @@ Castro::shock(const Box& bx, q_arr(i,j,k,QV) * q_arr(i,j,k,QV) + q_arr(i,j,k,QW) * q_arr(i,j,k,QW)); - Real gradPdx_over_P = std::abs(dP_x * q_arr(i,j,k,QU) + - dP_y * q_arr(i,j,k,QV) + - dP_z * q_arr(i,j,k,QW)) / vel; + Real gradPdx_over_P{0.0_rt}; + if (vel != 0.0) { + gradPdx_over_P = std::abs(dP_x * q_arr(i,j,k,QU) + + dP_y * q_arr(i,j,k,QV) + + dP_z * q_arr(i,j,k,QW)) / vel; + } gradPdx_over_P /= (q_arr(i,j,k,QPRES) / std::max(dx[0], std::max(dx[1], dx[2]))); if (gradPdx_over_P > castro::shock_detection_threshold && div_u < 0.0_rt) {