diff --git a/Src/Particle/AMReX_DenseBins.H b/Src/Particle/AMReX_DenseBins.H index 24c9cc293cb..0481b469718 100644 --- a/Src/Particle/AMReX_DenseBins.H +++ b/Src/Particle/AMReX_DenseBins.H @@ -197,7 +197,7 @@ public: index_type uix = amrex::min(nx-1,amrex::max(0,iv3.x)); index_type uiy = amrex::min(ny-1,amrex::max(0,iv3.y)); index_type uiz = amrex::min(nz-1,amrex::max(0,iv3.z)); - return (uix * ny + uiy) * nz + uiz; + return (uiz * ny + uiy) * nx + uix; }); } @@ -301,7 +301,7 @@ public: index_type uix = amrex::min(nx-1,amrex::max(0,iv3.x)); index_type uiy = amrex::min(ny-1,amrex::max(0,iv3.y)); index_type uiz = amrex::min(nz-1,amrex::max(0,iv3.z)); - return (uix * ny + uiy) * nz + uiz; + return (uiz * ny + uiy) * nx + uix; }); } @@ -440,7 +440,7 @@ public: index_type uix = amrex::min(nx-1,amrex::max(0,iv3.x)); index_type uiy = amrex::min(ny-1,amrex::max(0,iv3.y)); index_type uiz = amrex::min(nz-1,amrex::max(0,iv3.z)); - return (uix * ny + uiy) * nz + uiz; + return (uiz * ny + uiy) * nx + uix; }); } diff --git a/Src/Particle/AMReX_NeighborList.H b/Src/Particle/AMReX_NeighborList.H index 53434ec7c3c..7fb85696418 100644 --- a/Src/Particle/AMReX_NeighborList.H +++ b/Src/Particle/AMReX_NeighborList.H @@ -368,10 +368,10 @@ public: int ny = hi_p[type].y-lo_p[type].y+1; int nz = hi_p[type].z-lo_p[type].z+1; - for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx-1); ++ii) { + for (int kk = amrex::max(iz-num_cells, 0); kk <= amrex::min(iz+num_cells, nz-1); ++kk) { for (int jj = amrex::max(iy-num_cells, 0); jj <= amrex::min(iy+num_cells, ny-1); ++jj) { - for (int kk = amrex::max(iz-num_cells, 0); kk <= amrex::min(iz+num_cells, nz-1); ++kk) { - int index = (ii * ny + jj) * nz + kk + off_bins; + for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx-1); ++ii) { + int index = (kk * ny + jj) * nx + ii + off_bins; for (auto p = poffset[index]; p < poffset[index+1]; ++p) { const auto& pid = pperm[p]; bool ghost_pid = (pid >= np_real); @@ -428,10 +428,10 @@ public: int ny = hi_p[type].y-lo_p[type].y+1; int nz = hi_p[type].z-lo_p[type].z+1; - for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx-1); ++ii) { + for (int kk = amrex::max(iz-num_cells, 0); kk <= amrex::min(iz+num_cells, nz-1); ++kk) { for (int jj = amrex::max(iy-num_cells, 0); jj <= amrex::min(iy+num_cells, ny-1); ++jj) { - for (int kk = amrex::max(iz-num_cells, 0); kk <= amrex::min(iz+num_cells, nz-1); ++kk) { - int index = (ii * ny + jj) * nz + kk + off_bins; + for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx-1); ++ii) { + int index = (kk * ny + jj) * nx + ii + off_bins; for (auto p = poffset[index]; p < poffset[index+1]; ++p) { const auto& pid = pperm[p]; bool ghost_pid = (pid >= np_real); diff --git a/Src/Particle/AMReX_NeighborParticlesI.H b/Src/Particle/AMReX_NeighborParticlesI.H index ca1747b6b8b..3b34f2d967c 100644 --- a/Src/Particle/AMReX_NeighborParticlesI.H +++ b/Src/Particle/AMReX_NeighborParticlesI.H @@ -1059,11 +1059,11 @@ selectActualNeighbors (CheckPair const& check_pair, int num_cells) int nz = hi.z-lo.z+1; bool isActualNeighbor = false; - for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx); ++ii) { + for (int kk = amrex::max(iz-num_cells, 0); kk <= amrex::min(iz+num_cells, nz); ++kk) { for (int jj = amrex::max(iy-num_cells, 0); jj <= amrex::min(iy+num_cells, ny); ++jj) { - for (int kk = amrex::max(iz-num_cells, 0); kk <= amrex::min(iz+num_cells, nz); ++kk) { + for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx); ++ii) { if (isActualNeighbor) { break; } - int nbr_cell_id = (ii * ny + jj) * nz + kk; + int nbr_cell_id = (kk * ny + jj) * nx + ii; for (auto p = poffset[nbr_cell_id]; p < poffset[nbr_cell_id+1]; ++p) { if (pperm[p] == i) { continue; } if (detail::call_check_pair(check_pair, ptile_data, ptile_data, i, pperm[p])) { diff --git a/Src/Particle/AMReX_ParticleLocator.H b/Src/Particle/AMReX_ParticleLocator.H index 9b75f503302..3a783e1dce4 100644 --- a/Src/Particle/AMReX_ParticleLocator.H +++ b/Src/Particle/AMReX_ParticleLocator.H @@ -67,10 +67,10 @@ struct AssignGrid int iy_hi = amrex::min((lo.y + nGrow - m_lo.y) / m_bin_size.y, m_num_bins.y-1); int iz_hi = amrex::min((lo.z + nGrow - m_lo.z) / m_bin_size.z, m_num_bins.z-1); int loc = -1; - for (int ii = ix_lo; ii <= ix_hi; ++ii) { + for (int kk = iz_lo; kk <= iz_hi; ++kk) { for (int jj = iy_lo; jj <= iy_hi; ++jj) { - for (int kk = iz_lo; kk <= iz_hi; ++kk) { - int index = (ii * m_num_bins.y + jj) * m_num_bins.z + kk; + for (int ii = ix_lo; ii <= ix_hi; ++ii) { + int index = (kk * m_num_bins.y + jj) * m_num_bins.x + ii; for (const auto& nbor : m_bif.getBinIterator(index)) { Box bx = nbor.second; if (bx.contains(iv)) { diff --git a/Src/Particle/AMReX_ParticleUtil.H b/Src/Particle/AMReX_ParticleUtil.H index 6b31db7e995..cbe401389be 100644 --- a/Src/Particle/AMReX_ParticleUtil.H +++ b/Src/Particle/AMReX_ParticleUtil.H @@ -325,7 +325,7 @@ struct BinMapper int uix = amrex::min(nx-1,amrex::max(0,iv3.x)); int uiy = amrex::min(ny-1,amrex::max(0,iv3.y)); int uiz = amrex::min(nz-1,amrex::max(0,iv3.z)); - return static_cast( (uix * ny + uiy) * nz + uiz + offset ); + return static_cast( (uiz * ny + uiy) * nx + uix + offset ); } private: