From e131a79f8e68be181390a2656f54268f90a9e78a Mon Sep 17 00:00:00 2001 From: Michael B Kuhn <31661049+mbkuhn@users.noreply.github.com> Date: Fri, 17 May 2024 13:26:22 -0600 Subject: [PATCH] Fix diagnostic behavior (maximum velocity, MAC velocity) on GPUs (#1064) alters how masking is applied when finding max --- amr-wind/utilities/diagnostics.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/amr-wind/utilities/diagnostics.cpp b/amr-wind/utilities/diagnostics.cpp index 5e11e41db6..dff1c749ec 100644 --- a/amr-wind/utilities/diagnostics.cpp +++ b/amr-wind/utilities/diagnostics.cpp @@ -17,8 +17,10 @@ amrex::Real amr_wind::diagnostics::get_vel_max( amrex::Array4 const& mask_arr) -> amrex::Real { amrex::Real max_fab = -1e8; amrex::Loop(bx, [=, &max_fab](int i, int j, int k) noexcept { - max_fab = amrex::max(max_fab, factor * vel_arr(i, j, k, vdir)) * - (mask_arr(i, j, k) > 0 ? 1.0 : -1.0); + max_fab = amrex::max( + max_fab, mask_arr(i, j, k) > 0 + ? factor * vel_arr(i, j, k, vdir) + : std::numeric_limits::lowest()); }); return max_fab; }); @@ -89,9 +91,10 @@ amrex::Real amr_wind::diagnostics::get_macvel_max( int ii = i - (vdir == 0 ? 1 : 0); int jj = j - (vdir == 1 ? 1 : 0); int kk = k - (vdir == 2 ? 1 : 0); - max_fab = - amrex::max(max_fab, factor * mvel_arr(i, j, k)) * - (mask_arr(i, j, k) + mask_arr(ii, jj, kk) > 0 ? 1.0 : -1.0); + max_fab = amrex::max( + max_fab, (mask_arr(i, j, k) + mask_arr(ii, jj, kk)) > 0 + ? factor * mvel_arr(i, j, k) + : std::numeric_limits::lowest()); }); return max_fab; });