From c5181bb7c80ee3c28d2aec63e602d7745e384ef5 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 11 Nov 2022 16:56:21 -0700 Subject: [PATCH] Fixing various oversights in npair classes --- src/npair_bin_atomonly.cpp | 2 +- src/npair_bin_ghost.cpp | 16 +++++------ src/npair_multi.cpp | 54 ++++++++++++++++++++++++++++---------- src/npair_multi.h | 4 +-- src/npair_multi_old.h | 16 +++++------ 5 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/npair_bin_atomonly.cpp b/src/npair_bin_atomonly.cpp index f658a44b60..100b521b92 100644 --- a/src/npair_bin_atomonly.cpp +++ b/src/npair_bin_atomonly.cpp @@ -139,7 +139,7 @@ void NPairBinAtomonly::build(NeighList *list) delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; delz = ztmp - x[j][2]; - rsq = delx*delx + dely*dely + delz*delz; + rsq = delx * delx + dely * dely + delz * delz; if (SIZE) { radsum = radius[i] + radius[j]; diff --git a/src/npair_bin_ghost.cpp b/src/npair_bin_ghost.cpp index 615759508d..4cf30f10f9 100644 --- a/src/npair_bin_ghost.cpp +++ b/src/npair_bin_ghost.cpp @@ -103,17 +103,17 @@ void NPairBinGhost::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin+stencil[k]]; for (j = bin_start; j >= 0; j = bins[j]) { - if (!HALF) { - // Full neighbor list - // only skip i = j - if (i == j) continue; - } else { + if (HALF) { // Half neighbor list, newton off // only store pair if i < j // stores own/own pairs only once // stores own/ghost pairs on both procs // stores ghost/ghost pairs only once if (j <= i) continue; + } else { + // Full neighbor list + // only skip i = j + if (i == j) continue; } jtype = type[j]; @@ -151,10 +151,10 @@ void NPairBinGhost::build(NeighList *list) ybin2 < 0 || ybin2 >= mbiny || zbin2 < 0 || zbin2 >= mbinz) continue; for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (!HALF) { - if (i == j) continue; - } else { + if (HALF) { if (j <= i) continue; + } else { + if (i == j) continue; } jtype = type[j]; diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index 103f5a1845..ab182f39c4 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -162,20 +162,46 @@ void NPairMulti::build(NeighList *list) delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq[itype][jtype]) { - if (molecular != Atom::ATOMIC) { - if (!moltemplate) - which = find_special(special[i],nspecial[i],tag[j]); - else if (imol >= 0) - which = find_special(onemols[imol]->special[iatom], - onemols[imol]->nspecial[iatom], - tag[j]-tagprev); - else which = 0; - if (which == 0) neighptr[n++] = j; - else if (domain->minimum_image_check(delx,dely,delz)) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; + if (SIZE) { + radsum = radius[i] + radius[j]; + cut = radsum + skin; + cutsq = cut * cut; + + if (rsq <= cutsq) { + jh = j; + if (history && rsq < radsum * radsum) + jh = jh ^ mask_history; + + if (molecular != Atom::ATOMIC) { + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which = 0; + if (which == 0) neighptr[n++] = jh; + else if (domain->minimum_image_check(delx,dely,delz)) + neighptr[n++] = jh; + else if (which > 0) neighptr[n++] = jh ^ (which << SBBITS); + } else neighptr[n++] = jh; + } + } else { + if (rsq <= cutneighsq[itype][jtype]) { + if (molecular != Atom::ATOMIC) { + if (!moltemplate) + which = find_special(special[i],nspecial[i],tag[j]); + else if (imol >= 0) + which = find_special(onemols[imol]->special[iatom], + onemols[imol]->nspecial[iatom], + tag[j]-tagprev); + else which = 0; + if (which == 0) neighptr[n++] = j; + else if (domain->minimum_image_check(delx,dely,delz)) + neighptr[n++] = j; + else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); + } else neighptr[n++] = j; + } } } } diff --git a/src/npair_multi.h b/src/npair_multi.h index 4bb1315200..f6a68711e2 100644 --- a/src/npair_multi.h +++ b/src/npair_multi.h @@ -14,7 +14,7 @@ #ifdef NPAIR_CLASS // clang-format off typedef NPairMulti<0, 1, 0, 0> NPairFullMulti; -NPairStyle(full/Multi, +NPairStyle(full/multi, NPairFullMulti, NP_FULL | NP_MULTI | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); @@ -35,7 +35,7 @@ NPairStyle(half/multi/newton/tri, NP_HALF | NP_MULTI | NP_NEWTON | NP_TRI); typedef NPairMulti<0, 1, 0, 1> NPairFullSizeMulti; -NPairStyle(full/size/Multi, +NPairStyle(full/size/multi, NPairFullSizeMulti, NP_FULL | NP_SIZE | NP_MULTI | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); diff --git a/src/npair_multi_old.h b/src/npair_multi_old.h index 8eb1cc3b00..f01844ed57 100644 --- a/src/npair_multi_old.h +++ b/src/npair_multi_old.h @@ -16,44 +16,44 @@ typedef NPairMultiOld<0, 1, 0, 0> NPairFullMultiOld; NPairStyle(full/multi/old, NPairFullMultiOld, - NP_FULL | NP_MULTI_OLD | NP_MOLONLY | + NP_FULL | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); typedef NPairMultiOld<1, 0, 0, 0> NPairHalfMultiOldNewtoff; NPairStyle(half/multi/old/newtoff, NPairHalfMultiOldNewtoff, - NP_HALF | NP_MULTI_OLD | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_MULTI_OLD | NP_NEWTOFF | NP_ORTHO | NP_TRI); typedef NPairMultiOld<1, 1, 0, 0> NPairHalfMultiOldNewton; NPairStyle(half/multi/old/newton, NPairHalfMultiOldNewton, - NP_HALF | NP_MULTI_OLD | NP_MOLONLY | NP_NEWTON | NP_ORTHO); + NP_HALF | NP_MULTI_OLD | NP_NEWTON | NP_ORTHO); typedef NPairMultiOld<1, 1, 1, 0> NPairHalfMultiOldNewtonTri; NPairStyle(half/multi/old/newton/tri, NPairHalfMultiOldNewtonTri, - NP_HALF | NP_MULTI_OLD | NP_MOLONLY | NP_NEWTON | NP_TRI); + NP_HALF | NP_MULTI_OLD | NP_NEWTON | NP_TRI); typedef NPairMultiOld<0, 1, 0, 1> NPairFullSizeMultiOld; NPairStyle(full/size/multi/old, NPairFullSizeMultiOld, - NP_FULL | NP_SIZE | NP_MULTI_OLD | NP_MOLONLY | + NP_FULL | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); typedef NPairMultiOld<1, 0, 0, 1> NPairHalfSizeMultiOldNewtoff; NPairStyle(half/size/multi/old/newtoff, NPairHalfSizeMultiOldNewtoff, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTOFF | NP_ORTHO | NP_TRI); typedef NPairMultiOld<1, 1, 0, 1> NPairHalfSizeMultiOldNewton; NPairStyle(half/size/multi/old/newton, NPairHalfSizeMultiOldNewton, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_MOLONLY | NP_NEWTON | NP_ORTHO); + NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_ORTHO); typedef NPairMultiOld<1, 1, 1, 1> NPairHalfSizeMultiOldNewtonTri; NPairStyle(half/size/multi/old/newton/tri, NPairHalfSizeMultiOldNewtonTri, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_MOLONLY | NP_NEWTON | NP_TRI); + NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_TRI); // clang-format on #else