From bf02d4b3fc52e658210e97695bfee7b7ba052f3f Mon Sep 17 00:00:00 2001 From: AMLattanzi Date: Thu, 25 Jan 2024 09:59:29 -0800 Subject: [PATCH] Avoid undefined operations; this ran. --- .../BoundaryConditions_xvel.cpp | 26 ++++++++++++------- .../BoundaryConditions_yvel.cpp | 16 +++++++----- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Source/BoundaryConditions/BoundaryConditions_xvel.cpp b/Source/BoundaryConditions/BoundaryConditions_xvel.cpp index f0da72d77..fdedf6ba8 100644 --- a/Source/BoundaryConditions/BoundaryConditions_xvel.cpp +++ b/Source/BoundaryConditions/BoundaryConditions_xvel.cpp @@ -69,16 +69,18 @@ void ERFPhysBCFunct::impose_lateral_xvel_bcs (const Array4& dest_arr, bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) { int iflip = dom_lo.x - i; + int jj = std::max(j , dom_lo.y); + jj = std::min(jj, dom_hi.y); if (bc_ptr[n].lo(0) == ERFBCType::ext_dir) { dest_arr(i,j,k) = l_bc_extdir_vals_d[n][0]; } else if (bc_ptr[n].lo(0) == ERFBCType::foextrap) { - dest_arr(i,j,k) = dest_arr(dom_lo.x,j,k); + dest_arr(i,j,k) = dest_arr(dom_lo.x,jj,k); } else if (bc_ptr[n].lo(0) == ERFBCType::reflect_even) { - dest_arr(i,j,k) = dest_arr(iflip,j,k); + dest_arr(i,j,k) = dest_arr(iflip,jj,k); } else if (bc_ptr[n].lo(0) == ERFBCType::reflect_odd) { - dest_arr(i,j,k) = -dest_arr(iflip,j,k); + dest_arr(i,j,k) = -dest_arr(iflip,jj,k); } else if (bc_ptr[n].lo(0) == ERFBCType::neumann_int) { - dest_arr(i,j,k) = (4.0*dest_arr(dom_lo.x+1,j,k) - dest_arr(dom_lo.x+2,j,k))/3.0; + dest_arr(i,j,k) = (4.0*dest_arr(dom_lo.x+1,jj,k) - dest_arr(dom_lo.x+2,jj,k))/3.0; } }, // We only set the values on the domain faces themselves if EXT_DIR @@ -87,7 +89,7 @@ void ERFPhysBCFunct::impose_lateral_xvel_bcs (const Array4& dest_arr, if (bc_ptr[n].lo(0) == ERFBCType::ext_dir) { dest_arr(i,j,k) = l_bc_extdir_vals_d[n][0]; } else if (bc_ptr[n].lo(0) == ERFBCType::neumann_int) { - dest_arr(i,j,k) = (4.0*dest_arr(dom_lo.x+1,j,k) - dest_arr(dom_lo.x+2,j,k))/3.0; + dest_arr(i,j,k) = (4.0*dest_arr(dom_lo.x+1,jj,k) - dest_arr(dom_lo.x+2,jj,k))/3.0; } } ); @@ -95,25 +97,29 @@ void ERFPhysBCFunct::impose_lateral_xvel_bcs (const Array4& dest_arr, bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) { int iflip = 2*(dom_hi.x + 1) - i; + int jj = std::max(j , dom_lo.y); + jj = std::min(jj, dom_hi.y); if (bc_ptr[n].hi(0) == ERFBCType::ext_dir) { dest_arr(i,j,k) = l_bc_extdir_vals_d[n][3]; } else if (bc_ptr[n].hi(0) == ERFBCType::foextrap) { - dest_arr(i,j,k) = dest_arr(dom_hi.x+1,j,k); + dest_arr(i,j,k) = dest_arr(dom_hi.x+1,jj,k); } else if (bc_ptr[n].hi(0) == ERFBCType::reflect_even) { - dest_arr(i,j,k) = dest_arr(iflip,j,k); + dest_arr(i,j,k) = dest_arr(iflip,jj,k); } else if (bc_ptr[n].hi(0) == ERFBCType::reflect_odd) { - dest_arr(i,j,k) = -dest_arr(iflip,j,k); + dest_arr(i,j,k) = -dest_arr(iflip,jj,k); } else if (bc_ptr[n].hi(0) == ERFBCType::neumann_int) { - dest_arr(i,j,k) = (4.0*dest_arr(dom_hi.x,j,k) - dest_arr(dom_hi.x-1,j,k))/3.0; + dest_arr(i,j,k) = (4.0*dest_arr(dom_hi.x,jj,k) - dest_arr(dom_hi.x-1,jj,k))/3.0; } }, // We only set the values on the domain faces themselves if EXT_DIR bx_xhi_face, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) { + int jj = std::max(j , dom_lo.y); + jj = std::min(jj, dom_hi.y); if (bc_ptr[n].hi(0) == ERFBCType::ext_dir) { dest_arr(i,j,k) = l_bc_extdir_vals_d[n][3]; } else if (bc_ptr[n].hi(0) == ERFBCType::neumann_int) { - dest_arr(i,j,k) = (4.0*dest_arr(dom_hi.x,j,k) - dest_arr(dom_hi.x-1,j,k))/3.0; + dest_arr(i,j,k) = (4.0*dest_arr(dom_hi.x,jj,k) - dest_arr(dom_hi.x-1,jj,k))/3.0; } } ); diff --git a/Source/BoundaryConditions/BoundaryConditions_yvel.cpp b/Source/BoundaryConditions/BoundaryConditions_yvel.cpp index f699a2631..6540da8ad 100644 --- a/Source/BoundaryConditions/BoundaryConditions_yvel.cpp +++ b/Source/BoundaryConditions/BoundaryConditions_yvel.cpp @@ -62,26 +62,30 @@ void ERFPhysBCFunct::impose_lateral_yvel_bcs (const Array4& dest_arr, ParallelFor( bx_xlo, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) { int iflip = dom_lo.x - 1- i; + int jj = std::max(j , dom_lo.y); + jj = std::min(jj, dom_hi.y); if (bc_ptr[n].lo(0) == ERFBCType::ext_dir) { dest_arr(i,j,k) = l_bc_extdir_vals_d[n][0]; } else if (bc_ptr[n].lo(0) == ERFBCType::foextrap) { - dest_arr(i,j,k) = dest_arr(dom_lo.x,j,k); + dest_arr(i,j,k) = dest_arr(dom_lo.x,jj,k); } else if (bc_ptr[n].lo(0) == ERFBCType::reflect_even) { - dest_arr(i,j,k) = dest_arr(iflip,j,k); + dest_arr(i,j,k) = dest_arr(iflip,jj,k); } else if (bc_ptr[n].lo(0) == ERFBCType::reflect_odd) { - dest_arr(i,j,k) = -dest_arr(iflip,j,k); + dest_arr(i,j,k) = -dest_arr(iflip,jj,k); } }, bx_xhi, ncomp, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) { int iflip = 2*dom_hi.x + 1 - i; + int jj = std::max(j , dom_lo.y); + jj = std::min(jj, dom_hi.y); if (bc_ptr[n].hi(0) == ERFBCType::ext_dir) { dest_arr(i,j,k) = l_bc_extdir_vals_d[n][3]; } else if (bc_ptr[n].hi(0) == ERFBCType::foextrap) { - dest_arr(i,j,k) = dest_arr(dom_hi.x,j,k); + dest_arr(i,j,k) = dest_arr(dom_hi.x,jj,k); } else if (bc_ptr[n].hi(0) == ERFBCType::reflect_even) { - dest_arr(i,j,k) = dest_arr(iflip,j,k); + dest_arr(i,j,k) = dest_arr(iflip,jj,k); } else if (bc_ptr[n].hi(0) == ERFBCType::reflect_odd) { - dest_arr(i,j,k) = -dest_arr(iflip,j,k); + dest_arr(i,j,k) = -dest_arr(iflip,jj,k); } } );