diff options
author | 2020-02-05 17:44:57 -0800 | |
---|---|---|
committer | 2020-02-05 17:44:57 -0800 | |
commit | 30124ab2e38bda273d025050a2eb24a5f2c0fc25 (patch) | |
tree | fefb5fb436682e8fa944a6cce4779cc22431686d /Source/WarpX.cpp | |
parent | 13fb97ac903245f7232f8153d467e233fc71a2eb (diff) | |
download | WarpX-30124ab2e38bda273d025050a2eb24a5f2c0fc25.tar.gz WarpX-30124ab2e38bda273d025050a2eb24a5f2c0fc25.tar.zst WarpX-30124ab2e38bda273d025050a2eb24a5f2c0fc25.zip |
Fix bug in previous C++ implementation.
Diffstat (limited to 'Source/WarpX.cpp')
-rw-r--r-- | Source/WarpX.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 907176908..6c98b276d 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -1297,32 +1297,37 @@ WarpX::BuildBufferMasks () void WarpX::BuildBufferMasksInBox ( const Box &tbx, Array4<int> &msk, const Array4<int> gmsk, const int ng ) { + bool setnull; const auto lo = amrex::lbound( tbx ); const auto hi = amrex::ubound( tbx ); #if (AMREX_SPACEDIM == 2) int k = lo.z; for (int j = lo.y; j <= hi.y; ++j) { for (int i = lo.x; i <= hi.x; ++i) { + setnull = false; for (int jj = j-ng; jj <= j+ng; ++jj) { for (int ii = i-ng; ii <= i+ng; ++ii) { - if ( gmsk(ii,jj,k) == 0 ) msk(i,j,k) = 0; - else msk(i,j,k) = 1; + if ( gmsk(ii,jj,k) == 0 ) setnull = true; } } + if ( setnull ) msk(i,j,k) = 0; + else msk(i,j,k) = 1; } } #elif (AMREX_SPACEDIM == 3) for (int k = lo.z; k <= hi.z; ++k) { for (int j = lo.y; j <= hi.y; ++j) { for (int i = lo.x; i <= hi.x; ++i) { + setnull = false; for (int kk = k-ng; kk <= k+ng; ++kk) { for (int jj = j-ng; jj <= j+ng; ++jj) { for (int ii = i-ng; ii <= i+ng; ++ii) { - if ( gmsk(ii,jj,k) == 0 ) msk(i,j,k) = 0; - else msk(i,j,k) = 1; + if ( gmsk(ii,jj,kk) == 0 ) setnull = true; } } } + if ( setnull ) msk(i,j,k) = 0; + else msk(i,j,k) = 1; } } } |