Skip to content

Commit

Permalink
Fix diagnostic behavior (maximum velocity, MAC velocity) on GPUs (#1064)
Browse files Browse the repository at this point in the history
alters how masking is applied when finding max
  • Loading branch information
mbkuhn authored May 17, 2024
1 parent d7e7b81 commit e131a79
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions amr-wind/utilities/diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ amrex::Real amr_wind::diagnostics::get_vel_max(
amrex::Array4<int const> 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<amrex::Real>::lowest());
});
return max_fab;
});
Expand Down Expand Up @@ -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<amrex::Real>::lowest());
});
return max_fab;
});
Expand Down

0 comments on commit e131a79

Please sign in to comment.