Commit 37810bdc authored by Tim Mattox's avatar Tim Mattox
Browse files

USER-DPD: move centroid bin of stencil_ssa to the first slot.

Eliminates a special case version of a loop just for Subphase 0.
NOTE: pair evaluation order changes, causing numerical differences!
This changed the order that close neighbors of ghosts are processed.
parent 7feb6c28
Loading
Loading
Loading
Loading
+5 −27
Original line number Diff line number Diff line
@@ -180,35 +180,13 @@ void NPairHalfBinNewtonSSA::build(NeighList *list)
          iatom = molatom[i];
          tagprev = tag[i] - iatom - 1;
        }
        // loop over rest of local atoms in i's bin if this is subphase 0
        // just store them, since j is beyond i in linked list
        if (subphase == 0) for (j = bins[i]; j >= 0; j = bins[j]) {
          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;
          }
        }

        // loop over all local atoms in other bins in "subphase" of stencil
        // loop over all local atoms in the current stencil "subphase"
        for (k = nstencil_ssa[subphase]; k < nstencil_ssa[subphase+1]; k++) {
          for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) {
          const int jbin = ibin+stencil[k];
          if (jbin != ibin) j = binhead[jbin];
          else j = bins[i]; // same bin as i, so start just past i in the bin
          for (; j >= 0; j = bins[j]) {
            jtype = type[j];
            if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue;
            delx = xtmp - x[j][0];
+8 −6
Original line number Diff line number Diff line
@@ -43,6 +43,14 @@ void NStencilHalfBin2dNewtonSSA::create()
{
  int i,j,pos = 0;
  nstencil_ssa[0] = 0; // redundant info, but saves a conditional

  // Include the centroid at the start.
  // It will be handled as part of Subphase 0.
  stencilxyz[pos][0] = 0;
  stencilxyz[pos][1] = 0;
  stencilxyz[pos][2] = 0;
  stencil[pos++] = 0;

  // Subphase 0: upper right front bins (red)
  for (j = 0; j <= sy; j++)
    for (i = 0; i <= sx; i++)
@@ -101,11 +109,5 @@ void NStencilHalfBin2dNewtonSSA::create()
      }
  // nstencil_ssa[8] = pos;

  // Also, include the centroid for the AIR ghosts.
  stencilxyz[pos][0] = 0;
  stencilxyz[pos][1] = 0;
  stencilxyz[pos][2] = 0;
  stencil[pos++] = 0;

  nstencil = pos; // record where full stencil ends
}
+8 −6
Original line number Diff line number Diff line
@@ -43,6 +43,14 @@ void NStencilHalfBin3dNewtonSSA::create()
{
  int i,j,k,pos = 0;
  nstencil_ssa[0] = 0; // redundant info, but saves a conditional

  // Include the centroid at the start.
  // It will be handled as part of Subphase 0.
  stencilxyz[pos][0] = 0;
  stencilxyz[pos][1] = 0;
  stencilxyz[pos][2] = 0;
  stencil[pos++] = 0;

  // Subphase 0: upper right front bins (red)
  for (k = 0; k <= sz; k++)
    for (j = 0; j <= sy; j++)
@@ -141,11 +149,5 @@ void NStencilHalfBin3dNewtonSSA::create()
        }
  //nstencil_ssa[8] = pos;

  // Also, include the centroid for the AIR ghosts.
  stencilxyz[pos][0] = 0;
  stencilxyz[pos][1] = 0;
  stencilxyz[pos][2] = 0;
  stencil[pos++] = 0;

  nstencil = pos; // record where full stencil ends
}