From 949353594dcf4c3409ad4fb63d2f1c0e7ce77722 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Thu, 11 Jun 2020 10:57:57 -0700 Subject: [PATCH] fix Abs for FabArray --- Src/Base/AMReX_FabArrayUtility.H | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Src/Base/AMReX_FabArrayUtility.H b/Src/Base/AMReX_FabArrayUtility.H index 654b41956f7..294705a056a 100644 --- a/Src/Base/AMReX_FabArrayUtility.H +++ b/Src/Base/AMReX_FabArrayUtility.H @@ -1592,29 +1592,28 @@ Divide (FabArray& dst, FabArray const& src, int srccomp, int dstcomp, template ::value> > void -Abs (FabArray& dst, FabArray const& src, int srccomp, int dstcomp, int numcomp, int nghost) +Abs (FabArray& fa, int icomp, int numcomp, int nghost) { - Abs(dst,src,srccomp,dstcomp,numcomp,IntVect(nghost)); + Abs(fa,icomp,numcomp,IntVect(nghost)); } template ::value> > void -Abs (FabArray& dst, FabArray const& src, int srccomp, int dstcomp, int numcomp, const IntVect& nghost) +Abs (FabArray& 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)); }); } }