Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Abs for FabArray #1004

Merged
merged 1 commit into from
Jun 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Src/Base/AMReX_FabArrayUtility.H
Original file line number Diff line number Diff line change
Expand Up @@ -1592,29 +1592,28 @@ Divide (FabArray<FAB>& dst, FabArray<FAB> const& src, int srccomp, int dstcomp,
template <class FAB,
class bar = amrex::EnableIf_t<IsBaseFab<FAB>::value> >
void
Abs (FabArray<FAB>& dst, FabArray<FAB> const& src, int srccomp, int dstcomp, int numcomp, int nghost)
Abs (FabArray<FAB>& fa, int icomp, int numcomp, int nghost)
{
Abs(dst,src,srccomp,dstcomp,numcomp,IntVect(nghost));
Abs(fa,icomp,numcomp,IntVect(nghost));
}

template <class FAB,
class bar = amrex::EnableIf_t<IsBaseFab<FAB>::value> >
void
Abs (FabArray<FAB>& dst, FabArray<FAB> const& src, int srccomp, int dstcomp, int numcomp, const IntVect& nghost)
Abs (FabArray<FAB>& fa, int icomp, int numcomp, const IntVect& nghost)
{
#ifdef _OPENMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(dst,TilingIfNotGPU()); mfi.isValid(); ++mfi)
for (MFIter mfi(fa,TilingIfNotGPU()); mfi.isValid(); ++mfi)
{
const Box& bx = mfi.growntilebox(nghost);
if (bx.ok())
{
auto const srcFab = src.array(mfi);
auto dstFab = dst.array(mfi);
auto const& fab = fa.array(mfi);
AMREX_HOST_DEVICE_PARALLEL_FOR_4D ( bx, numcomp, i, j, k, n,
{
dstFab(i,j,k,n+dstcomp) /= srcFab(i,j,k,n+srccomp);
fab(i,j,k,n+icomp) = amrex::Math::abs(fab(i,j,k,n+icomp));
});
}
}
Expand Down