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 bug in atom sorting with triclinic boxes #3756

Merged
merged 4 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/KOKKOS/atom_kokkos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,11 @@ void AtomKokkos::sort()

if (nlocal == nmax) avec->grow(0);

// for triclinic, atoms must be in box coords (not lamda) to match bbox

if (domain->triclinic) domain->lamda2x(nlocal);

sync(Host, ALL_MASK);
modified(Host, ALL_MASK);

// bin atoms in reverse order so linked list will be in forward order

Expand Down Expand Up @@ -233,6 +236,12 @@ void AtomKokkos::sort()
//int flagall;
//MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world);
//if (flagall) errorX->all(FLERR,"Atom sort did not operate correctly");

modified(Host, ALL_MASK);

// convert back to lamda coords

if (domain->triclinic) domain->x2lamda(nlocal);
}

/* ----------------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2271,6 +2271,10 @@ void Atom::sort()

for (i = 0; i < nbins; i++) binhead[i] = -1;

// for triclinic, atoms must be in box coords (not lamda) to match bbox

if (domain->triclinic) domain->lamda2x(nlocal);

for (i = nlocal-1; i >= 0; i--) {
ix = static_cast<int> ((x[i][0]-bboxlo[0])*bininvx);
iy = static_cast<int> ((x[i][1]-bboxlo[1])*bininvy);
Expand All @@ -2286,6 +2290,10 @@ void Atom::sort()
binhead[ibin] = i;
}

// convert back to lamda coords

if (domain->triclinic) domain->x2lamda(nlocal);

// permute = desired permutation of atoms
// permute[I] = J means Ith new atom will be Jth old atom

Expand Down