From d7047245f412fb969ef0bd120a9d83a0d37eb1d0 Mon Sep 17 00:00:00 2001 From: Joel Clemmer Date: Sun, 22 Nov 2020 21:22:29 -0700 Subject: [PATCH] Add cross type self bin check for newton --- src/npair_half_multi2_newton.cpp | 39 +++++++++++++++++++++++ src/npair_half_multi2_newton_tri.cpp | 13 ++++++++ src/npair_half_size_multi2_newton.cpp | 33 +++++++++++++++++++ src/npair_half_size_multi2_newton_tri.cpp | 13 ++++++++ 4 files changed, 98 insertions(+) diff --git a/src/npair_half_multi2_newton.cpp b/src/npair_half_multi2_newton.cpp index 58397f645e..413da06284 100755 --- a/src/npair_half_multi2_newton.cpp +++ b/src/npair_half_multi2_newton.cpp @@ -163,6 +163,45 @@ void NPairHalfMulti2Newton::build(NeighList *list) // smaller -> larger: locate i in the ktype bin structure kbin = coord2bin(x[i], ktype); + + // if same size, use half list so check own bin + if(cutneighsq[itype][itype] == cutneighsq[ktype][ktype]){ + js = binhead_multi2[ktype][kbin]; + for (j = js; j >= 0; j = bins_multi2[ktype][j]) { + if (j >= nlocal) { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + } + + jtype = type[j]; + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + + if (rsq <= cutneighsq[itype][jtype]) { + if (molecular) { + 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; + } + } + } + s = stencil_multi2[itype][ktype]; ns = nstencil_multi2[itype][ktype]; diff --git a/src/npair_half_multi2_newton_tri.cpp b/src/npair_half_multi2_newton_tri.cpp index c741a860f1..7970ee94a0 100755 --- a/src/npair_half_multi2_newton_tri.cpp +++ b/src/npair_half_multi2_newton_tri.cpp @@ -143,6 +143,19 @@ void NPairHalfMulti2NewtonTri::build(NeighList *list) for (j = js; j >= 0; j = bins_multi2[ktype][j]) { jtype = type[j]; + + // if same size, use half stencil + if(cutneighsq[itype][itype] == cutneighsq[ktype][ktype]){ + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp) { + if (x[j][0] < xtmp) continue; + if (x[j][0] == xtmp && j <= i) continue; + } + } + } + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; delx = xtmp - x[j][0]; diff --git a/src/npair_half_size_multi2_newton.cpp b/src/npair_half_size_multi2_newton.cpp index a1832f6a49..3b34b1a514 100755 --- a/src/npair_half_size_multi2_newton.cpp +++ b/src/npair_half_size_multi2_newton.cpp @@ -138,6 +138,39 @@ void NPairHalfSizeMulti2Newton::build(NeighList *list) // smaller -> larger: locate i in the ktype bin structure kbin = coord2bin(x[i], ktype); + // if same size, use half list so check own bin + if(cutneighsq[itype][itype] == cutneighsq[ktype][ktype]){ + js = binhead_multi2[ktype][kbin]; + for (j = js; j >= 0; j = bins_multi2[ktype][j]) { + if (j >= nlocal) { + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp && x[j][0] < xtmp) continue; + } + } + + jtype = type[j]; + if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; + + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx*delx + dely*dely + delz*delz; + radsum = radi + radius[j]; + cutdistsq = (radsum+skin) * (radsum+skin); + + if (rsq <= cutdistsq) { + if (history && rsq < radsum*radsum) + neighptr[n++] = j ^ mask_history; + else + neighptr[n++] = j; + } + } + } + + // Check other stencils + s = stencil_multi2[itype][ktype]; ns = nstencil_multi2[itype][ktype]; for (k = 0; k < ns; k++) { diff --git a/src/npair_half_size_multi2_newton_tri.cpp b/src/npair_half_size_multi2_newton_tri.cpp index 1c0c1d514f..3a2065c36e 100755 --- a/src/npair_half_size_multi2_newton_tri.cpp +++ b/src/npair_half_size_multi2_newton_tri.cpp @@ -115,6 +115,7 @@ void NPairHalfSizeMulti2NewtonTri::build(NeighList *list) } } else { // smaller -> larger: locate i in the ktype bin structure + kbin = coord2bin(x[i], ktype); s = stencil_multi2[itype][ktype]; @@ -124,6 +125,18 @@ void NPairHalfSizeMulti2NewtonTri::build(NeighList *list) for (j = js; j >= 0; j = bins_multi2[ktype][j]) { jtype = type[j]; + + // if same size, use half stencil + if(cutneighsq[itype][itype] == cutneighsq[ktype][ktype]){ + if (x[j][2] < ztmp) continue; + if (x[j][2] == ztmp) { + if (x[j][1] < ytmp) continue; + if (x[j][1] == ytmp) { + if (x[j][0] < xtmp) continue; + if (x[j][0] == xtmp && j <= i) continue; + } + } + } if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue;