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 order of bins for neighbor list construction #3195

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions Src/Particle/AMReX_DenseBins.H
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,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;
});
}

Expand Down Expand Up @@ -289,7 +289,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;
});
}

Expand Down Expand Up @@ -428,7 +428,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;
});
}

Expand Down
4 changes: 2 additions & 2 deletions Src/Particle/AMReX_NeighborList.H
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public:
for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx-1); ++ii) {
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) {
atmyers marked this conversation as resolved.
Show resolved Hide resolved
int index = (ii * ny + jj) * nz + kk + off_bins;
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);
Expand Down Expand Up @@ -431,7 +431,7 @@ public:
for (int ii = amrex::max(ix-num_cells, 0); ii <= amrex::min(ix+num_cells, nx-1); ++ii) {
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;
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);
Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_NeighborParticlesI.H
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ selectActualNeighbors (CheckPair&& check_pair, int num_cells)
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) {
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 (call_check_pair(check_pair, ptile_data, ptile_data, i, pperm[p])) {
Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_ParticleLocator.H
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct AssignGrid
for (int ii = ix_lo; ii <= ix_hi; ++ii) {
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;
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)) {
Expand Down
2 changes: 1 addition & 1 deletion Src/Particle/AMReX_ParticleUtil.H
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,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<unsigned int>( (uix * ny + uiy) * nz + uiz + offset );
return static_cast<unsigned int>( (uiz * ny + uiy) * nx + uix + offset );
}

private:
Expand Down