Skip to content

Commit

Permalink
Avoid undefined operations; this ran.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi committed Jan 25, 2024
1 parent ddc662a commit bf02d4b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
26 changes: 16 additions & 10 deletions Source/BoundaryConditions/BoundaryConditions_xvel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ void ERFPhysBCFunct::impose_lateral_xvel_bcs (const Array4<Real>& 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
Expand All @@ -87,33 +89,37 @@ void ERFPhysBCFunct::impose_lateral_xvel_bcs (const Array4<Real>& 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;
}
}
);
ParallelFor(
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;
}
}
);
Expand Down
16 changes: 10 additions & 6 deletions Source/BoundaryConditions/BoundaryConditions_yvel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,30 @@ void ERFPhysBCFunct::impose_lateral_yvel_bcs (const Array4<Real>& 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);
}
}
);
Expand Down

0 comments on commit bf02d4b

Please sign in to comment.