From 51577eff2ccde5a9bd734ac5f5e73f733adbf521 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 23 Oct 2023 16:14:56 -0600 Subject: [PATCH] Merging atomonly npair styles, minor fixes --- src/OPENMP/npair_bin_atomonly_omp.cpp | 202 -------------------------- src/OPENMP/npair_bin_atomonly_omp.h | 78 ---------- src/OPENMP/npair_bin_omp.cpp | 133 ++++++++++------- src/OPENMP/npair_bin_omp.h | 60 ++++++-- src/OPENMP/npair_multi_old_omp.cpp | 4 +- src/OPENMP/npair_multi_omp.cpp | 127 +++++++++------- src/OPENMP/npair_multi_omp.h | 74 +++++++--- src/OPENMP/npair_respa_bin_omp.cpp | 4 +- src/npair_bin.cpp | 143 ++++++++++-------- src/npair_bin.h | 54 +++++-- src/npair_bin_atomonly.cpp | 180 ----------------------- src/npair_bin_atomonly.h | 77 ---------- src/npair_multi.cpp | 137 ++++++++++------- src/npair_multi.h | 76 +++++++--- src/npair_multi_old.cpp | 6 +- src/npair_respa_bin.cpp | 4 +- src/nstencil_multi_old.cpp | 2 +- 17 files changed, 540 insertions(+), 821 deletions(-) delete mode 100644 src/OPENMP/npair_bin_atomonly_omp.cpp delete mode 100644 src/OPENMP/npair_bin_atomonly_omp.h delete mode 100644 src/npair_bin_atomonly.cpp delete mode 100644 src/npair_bin_atomonly.h diff --git a/src/OPENMP/npair_bin_atomonly_omp.cpp b/src/OPENMP/npair_bin_atomonly_omp.cpp deleted file mode 100644 index 2ddb6a109d..0000000000 --- a/src/OPENMP/npair_bin_atomonly_omp.cpp +++ /dev/null @@ -1,202 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include "npair_bin_atomonly_omp.h" -#include "npair_omp.h" -#include "omp_compat.h" - -#include "atom.h" -#include "error.h" -#include "force.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -template -NPairBinAtomonlyOmp::NPairBinAtomonlyOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - Full: - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j - Half + Newtoff: - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and other bins in stencil - pair stored once if i,j are both owned and i < j - pair stored by me if j is ghost (also stored by proc owning j) - Half + Newton: - binned neighbor list construction with full Newton's 3rd law - each owned atom i checks its own bin and other bins in Newton stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -template -void NPairBinAtomonlyOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const double delta = 0.01 * force->angstrom; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i, j, jh, k, n, itype, jtype, ibin, bin_start; - tagint itag, jtag; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq, radsum, cut, cutsq; - int *neighptr; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - - int history = list->history; - int mask_history = 1 << HISTBITS; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - // loop over owned atoms, storing neighbors - - for (i = ifrom; i < ito; i++) { - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - bin_start = binhead[ibin + stencil[k]]; - if (stencil[k] == 0) { - if (HALF && NEWTON && (!TRI)) { - // Half neighbor list, newton on, orthonormal - // loop over rest of atoms in i's bin, ghosts are at end of linked list - bin_start = bins[i]; - } - } - - for (j = bin_start; j >= 0; j = bins[j]) { - if (!HALF) { - // Full neighbor list - // only skip i = j - if (i == j) continue; - } else if (!NEWTON) { - // Half neighbor list, newton off - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - if (j <= i) continue; - } else if (TRI) { - // Half neighbor list, newton on, triclinic - // for triclinic, bin stencil is full in all 3 dims - // must use itag/jtag to eliminate half the I/J interactions - // cannot use I/J exact coord comparision - // b/c transforming orthog -> lambda -> orthog for ghost atoms - // with an added PBC offset can shift all 3 coords by epsilon - if (j <= i) continue; - if (j >= nlocal) { - jtag = tag[j]; - if (itag > jtag) { - if ((itag + jtag) % 2 == 0) continue; - } else if (itag < jtag) { - if ((itag + jtag) % 2 == 1) continue; - } else { - if (fabs(x[j][2] - ztmp) > delta) { - if (x[j][2] < ztmp) continue; - } else if (fabs(x[j][1] - ytmp) > delta) { - if (x[j][1] < ytmp) continue; - } else { - if (x[j][0] < xtmp) continue; - } - } - } - } else { - // Half neighbor list, newton on, orthonormal - // store every pair for every bin in stencil, except for i's bin - - if (stencil[k] == 0) { - // if j is owned atom, store it, since j is beyond i in linked list - // if j is ghost, only store if j coords are "above and to the "right" of i - 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 (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; - neighptr[n++] = jh; - } - } else { - if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; - } - } - } - - ilist[i] = i; - firstneigh[i] = neighptr; - numneigh[i] = n; - ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - NPAIR_OMP_CLOSE; - list->inum = nlocal; - if (!HALF) list->gnum = 0; -} - -namespace LAMMPS_NS { -template class NPairBinAtomonlyOmp<0,1,0,0>; -template class NPairBinAtomonlyOmp<1,0,0,0>; -template class NPairBinAtomonlyOmp<1,1,0,0>; -template class NPairBinAtomonlyOmp<1,1,1,0>; -template class NPairBinAtomonlyOmp<0,1,0,1>; -template class NPairBinAtomonlyOmp<1,0,0,1>; -template class NPairBinAtomonlyOmp<1,1,0,1>; -template class NPairBinAtomonlyOmp<1,1,1,1>; -} diff --git a/src/OPENMP/npair_bin_atomonly_omp.h b/src/OPENMP/npair_bin_atomonly_omp.h deleted file mode 100644 index c488486898..0000000000 --- a/src/OPENMP/npair_bin_atomonly_omp.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef NPAIR_CLASS -// clang-format off -typedef NPairBinAtomonlyOmp<0, 1, 0, 0> NPairFullBinAtomonlyOmp; -NPairStyle(full/bin/atomonly/omp, - NPairFullBinAtomonlyOmp, - NP_FULL | NP_BIN | NP_OMP | NP_ATOMONLY | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonlyOmp<1, 0, 0, 0> NPairHalfBinNewtoffAtomonlyOmp; -NPairStyle(half/bin/newtoff/atomonly/omp, - NPairHalfBinNewtoffAtomonlyOmp, - NP_HALF | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonlyOmp<1, 1, 0, 0> NPairHalfBinNewtonAtomonlyOmp; -NPairStyle(half/bin/newton/atomonly/omp, - NPairHalfBinNewtonAtomonlyOmp, - NP_HALF | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); - -typedef NPairBinAtomonlyOmp<1, 1, 1, 0> NPairHalfBinNewtonTriAtomonlyOmp; -NPairStyle(half/bin/newton/tri/atomonly/omp, - NPairHalfBinNewtonTriAtomonlyOmp, - NP_HALF | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_TRI); - -typedef NPairBinAtomonlyOmp<0, 1, 0, 1> NPairFullSizeBinAtomonlyOmp; -NPairStyle(full/size/bin/atomonly/omp, - NPairFullSizeBinAtomonlyOmp, - NP_FULL | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonlyOmp<1, 0, 0, 1> NPairHalfSizeBinNewtoffAtomonlyOmp; -NPairStyle(half/size/bin/newtoff/atomonly/omp, - NPairHalfSizeBinNewtoffAtomonlyOmp, - NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonlyOmp<1, 1, 0, 1> NPairHalfSizeBinNewtonAtomonlyOmp; -NPairStyle(half/size/bin/newton/atomonly/omp, - NPairHalfSizeBinNewtonAtomonlyOmp, - NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); - -typedef NPairBinAtomonlyOmp<1, 1, 1, 1> NPairHalfSizeBinNewtonTriAtomonlyOmp; -NPairStyle(half/size/bin/newton/tri/atomonly/omp, - NPairHalfSizeBinNewtonTriAtomonlyOmp, - NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_TRI); -// clang-format on -#else - - -#ifndef LMP_NPAIR_BIN_ATOMONLY_OMP_H -#define LMP_NPAIR_BIN_ATOMONLY_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -template -class NPairBinAtomonlyOmp : public NPair { - public: - NPairBinAtomonlyOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_bin_omp.cpp b/src/OPENMP/npair_bin_omp.cpp index bbfa3323f1..81b5e085d6 100644 --- a/src/OPENMP/npair_bin_omp.cpp +++ b/src/OPENMP/npair_bin_omp.cpp @@ -29,8 +29,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -template -NPairBinOmp::NPairBinOmp(LAMMPS *lmp) : NPair(lmp) {} +template +NPairBinOmp::NPairBinOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- Full: @@ -47,8 +47,8 @@ NPairBinOmp::NPairBinOmp(LAMMPS *lmp) : NPair(lmp) {} every pair stored exactly once by some processor ------------------------------------------------------------------------- */ -template -void NPairBinOmp::build(NeighList *list) +template +void NPairBinOmp::build(NeighList *list) { const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; const int molecular = atom->molecular; @@ -101,10 +101,12 @@ void NPairBinOmp::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; + if (!ATOMONLY) { + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } } // loop over all atoms in surrounding bins in stencil including self @@ -113,9 +115,9 @@ void NPairBinOmp::build(NeighList *list) ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { - bin_start = binhead[ibin+stencil[k]]; - if (stencil[k] == 0) { - if (HALF && NEWTON && (!TRI)) { + bin_start = binhead[ibin + stencil[k]]; + if (HALF && NEWTON && (!TRI)) { + if (stencil[k] == 0) { // Half neighbor list, newton on, orthonormal // loop over rest of atoms in i's bin, ghosts are at end of linked list bin_start = bins[i]; @@ -159,7 +161,7 @@ void NPairBinOmp::build(NeighList *list) } } else { // Half neighbor list, newton on, orthonormal - // store every pair for every bin in stencil,except for i's bin + // store every pair for every bin in stencil, except for i's bin if (stencil[k] == 0) { // if j is owned atom, store it, since j is beyond i in linked list @@ -187,45 +189,58 @@ void NPairBinOmp::build(NeighList *list) 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 + if (ATOMONLY) { + if (rsq <= cutsq) { + jh = j; + if (history && rsq < radsum * radsum) + jh = jh ^ mask_history; neighptr[n++] = jh; + } + } else { + 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) + if (ATOMONLY) { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } 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; - 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; + } } } } @@ -243,12 +258,20 @@ void NPairBinOmp::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairBinOmp<0,1,0,0>; -template class NPairBinOmp<1,0,0,0>; -template class NPairBinOmp<1,1,0,0>; -template class NPairBinOmp<1,1,1,0>; -template class NPairBinOmp<0,1,0,1>; -template class NPairBinOmp<1,0,0,1>; -template class NPairBinOmp<1,1,0,1>; -template class NPairBinOmp<1,1,1,1>; +template class NPairBinOmp<0,1,0,0,0>; +template class NPairBinOmp<1,0,0,0,0>; +template class NPairBinOmp<1,1,0,0,0>; +template class NPairBinOmp<1,1,1,0,0>; +template class NPairBinOmp<0,1,0,1,0>; +template class NPairBinOmp<1,0,0,1,0>; +template class NPairBinOmp<1,1,0,1,0>; +template class NPairBinOmp<1,1,1,1,0>; +template class NPairBinOmp<0,1,0,0,1>; +template class NPairBinOmp<1,0,0,0,1>; +template class NPairBinOmp<1,1,0,0,1>; +template class NPairBinOmp<1,1,1,0,1>; +template class NPairBinOmp<0,1,0,1,1>; +template class NPairBinOmp<1,0,0,1,1>; +template class NPairBinOmp<1,1,0,1,1>; +template class NPairBinOmp<1,1,1,1,1>; } diff --git a/src/OPENMP/npair_bin_omp.h b/src/OPENMP/npair_bin_omp.h index 595b789d92..dfe5429ff4 100644 --- a/src/OPENMP/npair_bin_omp.h +++ b/src/OPENMP/npair_bin_omp.h @@ -13,47 +13,89 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairBinOmp<0, 1, 0, 0> NPairFullBinOmp; +typedef NPairBinOmp<0, 1, 0, 0, 0> NPairFullBinOmp; NPairStyle(full/bin/omp, NPairFullBinOmp, NP_FULL | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBinOmp<1, 0, 0, 0> NPairHalfBinNewtoffOmp; +typedef NPairBinOmp<1, 0, 0, 0, 0> NPairHalfBinNewtoffOmp; NPairStyle(half/bin/newtoff/omp, NPairHalfBinNewtoffOmp, NP_HALF | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBinOmp<1, 1, 0, 0> NPairHalfBinNewtonOmp; +typedef NPairBinOmp<1, 1, 0, 0, 0> NPairHalfBinNewtonOmp; NPairStyle(half/bin/newton/omp, NPairHalfBinNewtonOmp, NP_HALF | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairBinOmp<1, 1, 1, 0> NPairHalfBinNewtonTriOmp; +typedef NPairBinOmp<1, 1, 1, 0, 0> NPairHalfBinNewtonTriOmp; NPairStyle(half/bin/newton/tri/omp, NPairHalfBinNewtonTriOmp, NP_HALF | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_TRI); -typedef NPairBinOmp<0, 1, 0, 1> NPairFullSizeBinOmp; +typedef NPairBinOmp<0, 1, 0, 1, 0> NPairFullSizeBinOmp; NPairStyle(full/size/bin/omp, NPairFullSizeBinOmp, NP_FULL | NP_SIZE | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBinOmp<1, 0, 0, 1> NPairHalfSizeBinNewtoffOmp; +typedef NPairBinOmp<1, 0, 0, 1, 0> NPairHalfSizeBinNewtoffOmp; NPairStyle(half/size/bin/newtoff/omp, NPairHalfSizeBinNewtoffOmp, NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBinOmp<1, 1, 0, 1> NPairHalfSizeBinNewtonOmp; +typedef NPairBinOmp<1, 1, 0, 1, 0> NPairHalfSizeBinNewtonOmp; NPairStyle(half/size/bin/newton/omp, NPairHalfSizeBinNewtonOmp, NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairBinOmp<1, 1, 1, 1> NPairHalfSizeBinNewtonTriOmp; +typedef NPairBinOmp<1, 1, 1, 1, 0> NPairHalfSizeBinNewtonTriOmp; NPairStyle(half/size/bin/newton/tri/omp, NPairHalfSizeBinNewtonTriOmp, NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_TRI); + +typedef NPairBinOmp<0, 1, 0, 0, 1> NPairFullBinAtomonlyOmp; +NPairStyle(full/bin/atomonly/omp, + NPairFullBinAtomonlyOmp, + NP_FULL | NP_BIN | NP_OMP | NP_ATOMONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBinOmp<1, 0, 0, 0, 1> NPairHalfBinNewtoffAtomonlyOmp; +NPairStyle(half/bin/newtoff/atomonly/omp, + NPairHalfBinNewtoffAtomonlyOmp, + NP_HALF | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBinOmp<1, 1, 0, 0, 1> NPairHalfBinNewtonAtomonlyOmp; +NPairStyle(half/bin/newton/atomonly/omp, + NPairHalfBinNewtonAtomonlyOmp, + NP_HALF | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairBinOmp<1, 1, 1, 0, 1> NPairHalfBinNewtonTriAtomonlyOmp; +NPairStyle(half/bin/newton/tri/atomonly/omp, + NPairHalfBinNewtonTriAtomonlyOmp, + NP_HALF | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_TRI); + +typedef NPairBinOmp<0, 1, 0, 1, 1> NPairFullSizeBinAtomonlyOmp; +NPairStyle(full/size/bin/atomonly/omp, + NPairFullSizeBinAtomonlyOmp, + NP_FULL | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBinOmp<1, 0, 0, 1, 1> NPairHalfSizeBinNewtoffAtomonlyOmp; +NPairStyle(half/size/bin/newtoff/atomonly/omp, + NPairHalfSizeBinNewtoffAtomonlyOmp, + NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBinOmp<1, 1, 0, 1, 1> NPairHalfSizeBinNewtonAtomonlyOmp; +NPairStyle(half/size/bin/newton/atomonly/omp, + NPairHalfSizeBinNewtonAtomonlyOmp, + NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairBinOmp<1, 1, 1, 1, 1> NPairHalfSizeBinNewtonTriAtomonlyOmp; +NPairStyle(half/size/bin/newton/tri/atomonly/omp, + NPairHalfSizeBinNewtonTriAtomonlyOmp, + NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_ATOMONLY | NP_NEWTON | NP_TRI); // clang-format on #else @@ -64,7 +106,7 @@ NPairStyle(half/size/bin/newton/tri/omp, namespace LAMMPS_NS { -template +template class NPairBinOmp : public NPair { public: NPairBinOmp(class LAMMPS *); diff --git a/src/OPENMP/npair_multi_old_omp.cpp b/src/OPENMP/npair_multi_old_omp.cpp index 893af5a6b7..894ff9b987 100644 --- a/src/OPENMP/npair_multi_old_omp.cpp +++ b/src/OPENMP/npair_multi_old_omp.cpp @@ -118,8 +118,8 @@ void NPairMultiOldOmp::build(NeighList *list) cutnsq = cutneighsq[itype]; ns = nstencil_multi_old[itype]; for (k = 0; k < ns; k++) { - bin_start = binhead[ibin+stencil[k]]; - if (stencil[k] == 0) { + bin_start = binhead[ibin+s[k]]; + if (s[k] == 0) { if (HALF && NEWTON && (!TRI)) { // Half neighbor list, newton on, orthonormal // loop over rest of atoms in i's bin, ghosts are at end of linked list diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp index 06b26f6066..7999ff5029 100644 --- a/src/OPENMP/npair_multi_omp.cpp +++ b/src/OPENMP/npair_multi_omp.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -template -NPairMultiOmp::NPairMultiOmp(LAMMPS *lmp) : NPair(lmp) {} +template +NPairMultiOmp::NPairMultiOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- multi stencil is icollection-jcollection dependent @@ -49,8 +49,8 @@ NPairMultiOmp::NPairMultiOmp(LAMMPS *lmp) : NPair(lmp) every pair stored exactly once by some processor ------------------------------------------------------------------------- */ -template -void NPairMultiOmp::build(NeighList *list) +template +void NPairMultiOmp::build(NeighList *list) { const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; const int molecular = atom->molecular; @@ -104,10 +104,12 @@ void NPairMultiOmp::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; + if (!ATOMONLY) { + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } } ibin = atom2bin[i]; @@ -214,46 +216,59 @@ void NPairMultiOmp::build(NeighList *list) 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 + if (ATOMONLY) { + if (rsq <= cutsq) { + jh = j; + if (history && rsq < radsum * radsum) + jh = jh ^ mask_history; neighptr[n++] = jh; + } + } else { + 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) + if (ATOMONLY) { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } 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; - 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; + } } } } @@ -272,12 +287,20 @@ void NPairMultiOmp::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairMultiOmp<0,1,0,0>; -template class NPairMultiOmp<1,0,0,0>; -template class NPairMultiOmp<1,1,0,0>; -template class NPairMultiOmp<1,1,1,0>; -template class NPairMultiOmp<0,1,0,1>; -template class NPairMultiOmp<1,0,0,1>; -template class NPairMultiOmp<1,1,0,1>; -template class NPairMultiOmp<1,1,1,1>; +template class NPairMultiOmp<0,1,0,0,0>; +template class NPairMultiOmp<1,0,0,0,0>; +template class NPairMultiOmp<1,1,0,0,0>; +template class NPairMultiOmp<1,1,1,0,0>; +template class NPairMultiOmp<0,1,0,1,0>; +template class NPairMultiOmp<1,0,0,1,0>; +template class NPairMultiOmp<1,1,0,1,0>; +template class NPairMultiOmp<1,1,1,1,0>; +template class NPairMultiOmp<0,1,0,0,1>; +template class NPairMultiOmp<1,0,0,0,1>; +template class NPairMultiOmp<1,1,0,0,1>; +template class NPairMultiOmp<1,1,1,0,1>; +template class NPairMultiOmp<0,1,0,1,1>; +template class NPairMultiOmp<1,0,0,1,1>; +template class NPairMultiOmp<1,1,0,1,1>; +template class NPairMultiOmp<1,1,1,1,1>; } diff --git a/src/OPENMP/npair_multi_omp.h b/src/OPENMP/npair_multi_omp.h index dd85ca8a8e..bcb01c87cf 100644 --- a/src/OPENMP/npair_multi_omp.h +++ b/src/OPENMP/npair_multi_omp.h @@ -13,45 +13,85 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairMultiOmp<0, 1, 0, 0> NPairFullMultiOmp; +typedef NPairMultiOmp<0, 1, 0, 0, 0> NPairFullMultiOmp; NPairStyle(full/multi/omp, NPairFullMultiOmp, - NP_FULL | NP_MULTI | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_FULL | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMultiOmp<1, 0, 0, 0> NPairHalfMultiNewtoffOmp; +typedef NPairMultiOmp<1, 0, 0, 0, 0> NPairHalfMultiNewtoffOmp; NPairStyle(half/multi/newtoff/omp, NPairHalfMultiNewtoffOmp, - NP_HALF | NP_MULTI | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMultiOmp<1, 1, 0, 0> NPairHalfMultiNewtonOmp; +typedef NPairMultiOmp<1, 1, 0, 0, 0> NPairHalfMultiNewtonOmp; NPairStyle(half/multi/newton/omp, NPairHalfMultiNewtonOmp, - NP_HALF | NP_MULTI | NP_OMP | NP_NEWTON | NP_ORTHO); + NP_HALF | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTON | NP_ORTHO); -typedef NPairMultiOmp<1, 1, 1, 0> NPairHalfMultiNewtonTriOmp; +typedef NPairMultiOmp<1, 1, 1, 0, 0> NPairHalfMultiNewtonTriOmp; NPairStyle(half/multi/newton/tri/omp, NPairHalfMultiNewtonTriOmp, - NP_HALF | NP_MULTI | NP_OMP | NP_NEWTON | NP_TRI); + NP_HALF | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTON | NP_TRI); -typedef NPairMultiOmp<0, 1, 0, 1> NPairFullSizeMultiOmp; +typedef NPairMultiOmp<0, 1, 0, 1, 0> NPairFullSizeMultiOmp; NPairStyle(full/size/multi/omp, NPairFullSizeMultiOmp, - NP_FULL | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_FULL | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMultiOmp<1, 0, 0, 1> NPairHalfSizeMultiNewtoffOmp; +typedef NPairMultiOmp<1, 0, 0, 1, 0> NPairHalfSizeMultiNewtoffOmp; NPairStyle(half/size/multi/newtoff/omp, NPairHalfSizeMultiNewtoffOmp, - NP_HALF | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMultiOmp<1, 1, 0, 1> NPairHalfSizeMultiNewtonOmp; +typedef NPairMultiOmp<1, 1, 0, 1, 0> NPairHalfSizeMultiNewtonOmp; NPairStyle(half/size/multi/newton/omp, NPairHalfSizeMultiNewtonOmp, - NP_HALF | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTON | NP_ORTHO); + NP_HALF | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTON | NP_ORTHO); -typedef NPairMultiOmp<1, 1, 1, 1> NPairHalfSizeMultiNewtonTriOmp; +typedef NPairMultiOmp<1, 1, 1, 1, 0> NPairHalfSizeMultiNewtonTriOmp; NPairStyle(half/size/multi/newton/tri/omp, NPairHalfSizeMultiNewtonTriOmp, - NP_HALF | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTON | NP_TRI); + NP_HALF | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_OMP | NP_NEWTON | NP_TRI); + +typedef NPairMultiOmp<0, 1, 0, 0, 1> NPairFullMultiAtomonlyOmp; +NPairStyle(full/multi/atomonly/omp, + NPairFullMultiAtomonlyOmp, + NP_FULL | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 0, 0, 0, 1> NPairHalfMultiAtomonlyNewtoffOmp; +NPairStyle(half/multi/atomonly/newtoff/omp, + NPairHalfMultiAtomonlyNewtoffOmp, + NP_HALF | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 1, 0, 0, 1> NPairHalfMultiAtomonlyNewtonOmp; +NPairStyle(half/multi/atomonly/newton/omp, + NPairHalfMultiAtomonlyNewtonOmp, + NP_HALF | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairMultiOmp<1, 1, 1, 0, 1> NPairHalfMultiAtomonlyNewtonTriOmp; +NPairStyle(half/multi/atomonly/newton/tri/omp, + NPairHalfMultiAtomonlyNewtonTriOmp, + NP_HALF | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTON | NP_TRI); + +typedef NPairMultiOmp<0, 1, 0, 1, 1> NPairFullSizeMultiAtomonlyOmp; +NPairStyle(full/size/multi/atomonly/omp, + NPairFullSizeMultiAtomonlyOmp, + NP_FULL | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 0, 0, 1, 1> NPairHalfSizeMultiAtomonlyNewtoffOmp; +NPairStyle(half/size/multi/atomonly/newtoff/omp, + NPairHalfSizeMultiAtomonlyNewtoffOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 1, 0, 1, 1> NPairHalfSizeMultiAtomonlyNewtonOmp; +NPairStyle(half/size/multi/atomonly/newton/omp, + NPairHalfSizeMultiAtomonlyNewtonOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairMultiOmp<1, 1, 1, 1, 1> NPairHalfSizeMultiAtomonlyNewtonTriOmp; +NPairStyle(half/size/multi/atomonly/newton/tri/omp, + NPairHalfSizeMultiAtomonlyNewtonTriOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_OMP | NP_NEWTON | NP_TRI); // clang-format on #else @@ -62,7 +102,7 @@ NPairStyle(half/size/multi/newton/tri/omp, namespace LAMMPS_NS { -template +template class NPairMultiOmp : public NPair { public: NPairMultiOmp(class LAMMPS *); diff --git a/src/OPENMP/npair_respa_bin_omp.cpp b/src/OPENMP/npair_respa_bin_omp.cpp index e1a273b20a..b904e7136b 100644 --- a/src/OPENMP/npair_respa_bin_omp.cpp +++ b/src/OPENMP/npair_respa_bin_omp.cpp @@ -134,8 +134,8 @@ void NPairRespaBinOmp::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin+stencil[k]]; - if (stencil[k] == 0) { - if (NEWTON && (!TRI)) { + if (NEWTON && (!TRI)) { + if (stencil[k] == 0) { // Half neighbor list, newton on, orthonormal // loop over rest of atoms in i's bin, ghosts are at end of linked list bin_start = bins[i]; diff --git a/src/npair_bin.cpp b/src/npair_bin.cpp index c8c2d23e44..d72a98e471 100644 --- a/src/npair_bin.cpp +++ b/src/npair_bin.cpp @@ -28,8 +28,8 @@ using namespace NeighConst; /* ---------------------------------------------------------------------- */ -template -NPairBin::NPairBin(LAMMPS *lmp) : NPair(lmp) {} +template +NPairBin::NPairBin(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- Full: @@ -46,8 +46,8 @@ NPairBin::NPairBin(LAMMPS *lmp) : NPair(lmp) {} every pair stored exactly once by some processor ------------------------------------------------------------------------- */ -template -void NPairBin::build(NeighList *list) +template +void NPairBin::build(NeighList *list) { int i, j, jh, k, n, itype, jtype, ibin, bin_start, which, imol, iatom, moltemplate; tagint itag, jtag, tagprev; @@ -70,10 +70,12 @@ void NPairBin::build(NeighList *list) int *molindex = atom->molindex; int *molatom = atom->molatom; Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) - moltemplate = 1; - else - moltemplate = 0; + if (!ATOMONLY) { + if (molecular == Atom::TEMPLATE) + moltemplate = 1; + else + moltemplate = 0; + } int history = list->history; int mask_history = 1 << HISTBITS; @@ -95,18 +97,20 @@ void NPairBin::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; + if (!ATOMONLY) { + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } } ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin + stencil[k]]; - if (stencil[k] == 0) { - if (HALF && NEWTON && (!TRI)) { + if (HALF && NEWTON && (!TRI)) { + if (stencil[k] == 0) { // Half neighbor list, newton on, orthonormal // loop over rest of atoms in i's bin, ghosts are at end of linked list bin_start = bins[i]; @@ -149,7 +153,7 @@ void NPairBin::build(NeighList *list) } } else { // Half neighbor list, newton on, orthonormal - // store every pair for every bin in stencil,except for i's bin + // store every pair for every bin in stencil, except for i's bin if (stencil[k] == 0) { // if j is owned atom, store it, since j is beyond i in linked list @@ -177,46 +181,59 @@ void NPairBin::build(NeighList *list) 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 + if (ATOMONLY) { + if (rsq <= cutsq) { + jh = j; + if (history && rsq < (radsum * radsum)) + jh = jh ^ mask_history; neighptr[n++] = jh; + } + } else { + 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) + if (ATOMONLY) { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } 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; - 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; + } } } } @@ -234,12 +251,20 @@ void NPairBin::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairBin<0,1,0,0>; -template class NPairBin<1,0,0,0>; -template class NPairBin<1,1,0,0>; -template class NPairBin<1,1,1,0>; -template class NPairBin<0,1,0,1>; -template class NPairBin<1,0,0,1>; -template class NPairBin<1,1,0,1>; -template class NPairBin<1,1,1,1>; +template class NPairBin<0,1,0,0,0>; +template class NPairBin<1,0,0,0,0>; +template class NPairBin<1,1,0,0,0>; +template class NPairBin<1,1,1,0,0>; +template class NPairBin<0,1,0,1,0>; +template class NPairBin<1,0,0,1,0>; +template class NPairBin<1,1,0,1,0>; +template class NPairBin<1,1,1,1,0>; +template class NPairBin<0,1,0,0,1>; +template class NPairBin<1,0,0,0,1>; +template class NPairBin<1,1,0,0,1>; +template class NPairBin<1,1,1,0,1>; +template class NPairBin<0,1,0,1,1>; +template class NPairBin<1,0,0,1,1>; +template class NPairBin<1,1,0,1,1>; +template class NPairBin<1,1,1,1,1>; } diff --git a/src/npair_bin.h b/src/npair_bin.h index e9cd65fa34..2cec108e46 100644 --- a/src/npair_bin.h +++ b/src/npair_bin.h @@ -13,47 +13,83 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairBin<0, 1, 0, 0> NPairFullBin; +typedef NPairBin<0, 1, 0, 0, 0> NPairFullBin; NPairStyle(full/bin, NPairFullBin, NP_FULL | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBin<1, 0, 0, 0> NPairHalfBinNewtoff; +typedef NPairBin<1, 0, 0, 0, 0> NPairHalfBinNewtoff; NPairStyle(half/bin/newtoff, NPairHalfBinNewtoff, NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBin<1, 1, 0, 0> NPairHalfBinNewton; +typedef NPairBin<1, 1, 0, 0, 0> NPairHalfBinNewton; NPairStyle(half/bin/newton, NPairHalfBinNewton, NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairBin<1, 1, 1, 0> NPairHalfBinNewtonTri; +typedef NPairBin<1, 1, 1, 0, 0> NPairHalfBinNewtonTri; NPairStyle(half/bin/newton/tri, NPairHalfBinNewtonTri, NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_TRI); -typedef NPairBin<0, 1, 0, 1> NPairFullSizeBin; +typedef NPairBin<0, 1, 0, 1, 0> NPairFullSizeBin; NPairStyle(full/size/bin, NPairFullSizeBin, NP_FULL | NP_SIZE | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBin<1, 0, 0, 1> NPairHalfSizeBinNewtoff; +typedef NPairBin<1, 0, 0, 1, 0> NPairHalfSizeBinNewtoff; NPairStyle(half/size/bin/newtoff, NPairHalfSizeBinNewtoff, NP_HALF | NP_SIZE | NP_BIN | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBin<1, 1, 0, 1> NPairHalfSizeBinNewton; +typedef NPairBin<1, 1, 0, 1, 0> NPairHalfSizeBinNewton; NPairStyle(half/size/bin/newton, NPairHalfSizeBinNewton, NP_HALF | NP_SIZE | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairBin<1, 1, 1, 1> NPairHalfSizeBinNewtonTri; +typedef NPairBin<1, 1, 1, 1, 0> NPairHalfSizeBinNewtonTri; NPairStyle(half/size/bin/newton/tri, NPairHalfSizeBinNewtonTri, NP_HALF | NP_SIZE | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_TRI); + +typedef NPairBin<1, 0, 0, 0, 1> NPairHalfBinAtomonlyNewtoff; +NPairStyle(half/bin/atomonly/newtoff, + NPairHalfBinAtomonlyNewtoff, + NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBin<1, 1, 0, 0, 1> NPairHalfBinAtomonlyNewton; +NPairStyle(half/bin/atomonly/newton, + NPairHalfBinAtomonlyNewton, + NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairBin<1, 1, 1, 0, 1> NPairHalfBinAtomonlyNewtonTri; +NPairStyle(half/bin/atomonly/newton/tri, + NPairHalfBinAtomonlyNewtonTri, + NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_TRI); + +typedef NPairBin<0, 1, 0, 1, 1> NPairFullSizeBinAtomonly; +NPairStyle(full/size/bin/atomonly, + NPairFullSizeBinAtomonly, + NP_FULL | NP_SIZE | NP_BIN | NP_ATOMONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBin<1, 0, 0, 1, 1> NPairHalfSizeBinAtomonlyNewtoff; +NPairStyle(half/size/bin/atomonly/newtoff, + NPairHalfSizeBinAtomonlyNewtoff, + NP_HALF | NP_SIZE | NP_BIN | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBin<1, 1, 0, 1, 1> NPairHalfSizeBinAtomonlyNewton; +NPairStyle(half/size/bin/atomonly/newton, + NPairHalfSizeBinAtomonlyNewton, + NP_HALF | NP_SIZE | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairBin<1, 1, 1, 1, 1> NPairHalfSizeBinAtomonlyNewtonTri; +NPairStyle(half/size/bin/atomonly/newton/tri, + NPairHalfSizeBinAtomonlyNewtonTri, + NP_HALF | NP_SIZE | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_TRI); // clang-format on #else @@ -64,7 +100,7 @@ NPairStyle(half/size/bin/newton/tri, namespace LAMMPS_NS { -template +template class NPairBin : public NPair { public: NPairBin(class LAMMPS *); diff --git a/src/npair_bin_atomonly.cpp b/src/npair_bin_atomonly.cpp deleted file mode 100644 index 6cdd2e31ba..0000000000 --- a/src/npair_bin_atomonly.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#include "npair_bin_atomonly.h" - -#include "atom.h" -#include "error.h" -#include "neighbor.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; -using namespace NeighConst; - -/* ---------------------------------------------------------------------- */ - -template -NPairBinAtomonly::NPairBinAtomonly(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - Full: - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j - Half + Newtoff: - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and other bins in stencil - pair stored once if i,j are both owned and i < j - pair stored by me if j is ghost (also stored by proc owning j) - Half + Newton: - binned neighbor list construction with full Newton's 3rd law - each owned atom i checks its own bin and other bins in Newton stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -template -void NPairBinAtomonly::build(NeighList *list) -{ - int i, j, jh, k, n, itype, jtype, ibin, bin_start; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq; - double radsum, cut, cutsq; - int *neighptr; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int history = list->history; - int mask_history = 1 << HISTBITS; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - - itype = type[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - bin_start = binhead[ibin + stencil[k]]; - if (stencil[k] == 0) { - if (HALF && NEWTON && (!TRI)) { - // Half neighbor list, newton on, orthonormal - // loop over rest of atoms in i's bin, ghosts are at end of linked list - bin_start = bins[i]; - } - } - - for (j = bin_start; j >= 0; j = bins[j]) { - if (!HALF) { - // Full neighbor list - // only skip i = j - if (i == j) continue; - } else if (!NEWTON) { - // Half neighbor list, newton off - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - if (j <= i) continue; - } else if (TRI) { - // Half neighbor list, newton on, triclinic - // pairs for atoms j "below" i are excluded - // below = lower z or (equal z and lower y) or (equal zy and lower x) - // (equal zyx and j <= i) - // latter excludes self-self interaction but allows superposed atoms - 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; - } - } - } else { - // Half neighbor list, newton on, orthonormal - // store every pair for every bin in stencil, except for i's bin - - if (stencil[k] == 0) { - // if j is owned atom, store it, since j is beyond i in linked list - // if j is ghost, only store if j coords are "above and to the "right" of i - 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 (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; - neighptr[n++] = jh; - } - } else { - if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; - } - } - } - - ilist[inum++] = i; - firstneigh[i] = neighptr; - numneigh[i] = n; - ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - list->inum = inum; - if (!HALF) list->gnum = 0; -} - -namespace LAMMPS_NS { -template class NPairBinAtomonly<0,1,0,0>; -template class NPairBinAtomonly<1,0,0,0>; -template class NPairBinAtomonly<1,1,0,0>; -template class NPairBinAtomonly<1,1,1,0>; -template class NPairBinAtomonly<0,1,0,1>; -template class NPairBinAtomonly<1,0,0,1>; -template class NPairBinAtomonly<1,1,0,1>; -template class NPairBinAtomonly<1,1,1,1>; -} diff --git a/src/npair_bin_atomonly.h b/src/npair_bin_atomonly.h deleted file mode 100644 index febe7c2f0e..0000000000 --- a/src/npair_bin_atomonly.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - LAMMPS development team: developers@lammps.org - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under - the GNU General Public License. - - See the README file in the top-level LAMMPS directory. -------------------------------------------------------------------------- */ - -#ifdef NPAIR_CLASS -// clang-format off -typedef NPairBinAtomonly<0, 1, 0, 0> NPairFullBinAtomonly; -NPairStyle(full/bin/atomonly, - NPairFullBinAtomonly, - NP_FULL | NP_BIN | NP_ATOMONLY | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonly<1, 0, 0, 0> NPairHalfBinAtomonlyNewtoff; -NPairStyle(half/bin/atomonly/newtoff, - NPairHalfBinAtomonlyNewtoff, - NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonly<1, 1, 0, 0> NPairHalfBinAtomonlyNewton; -NPairStyle(half/bin/atomonly/newton, - NPairHalfBinAtomonlyNewton, - NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); - -typedef NPairBinAtomonly<1, 1, 1, 0> NPairHalfBinAtomonlyNewtonTri; -NPairStyle(half/bin/atomonly/newton/tri, - NPairHalfBinAtomonlyNewtonTri, - NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_TRI); - -typedef NPairBinAtomonly<0, 1, 0, 1> NPairFullSizeBinAtomonly; -NPairStyle(full/size/bin/atomonly, - NPairFullSizeBinAtomonly, - NP_FULL | NP_SIZE | NP_BIN | NP_ATOMONLY | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonly<1, 0, 0, 1> NPairHalfSizeBinAtomonlyNewtoff; -NPairStyle(half/size/bin/atomonly/newtoff, - NPairHalfSizeBinAtomonlyNewtoff, - NP_HALF | NP_SIZE | NP_BIN | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -typedef NPairBinAtomonly<1, 1, 0, 1> NPairHalfSizeBinAtomonlyNewton; -NPairStyle(half/size/bin/atomonly/newton, - NPairHalfSizeBinAtomonlyNewton, - NP_HALF | NP_SIZE | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); - -typedef NPairBinAtomonly<1, 1, 1, 1> NPairHalfSizeBinAtomonlyNewtonTri; -NPairStyle(half/size/bin/atomonly/newton/tri, - NPairHalfSizeBinAtomonlyNewtonTri, - NP_HALF | NP_SIZE | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_BIN_ATOMONLY_H -#define LMP_NPAIR_BIN_ATOMONLY_H - -#include "npair.h" - -namespace LAMMPS_NS { - -template -class NPairBinAtomonly : public NPair { - public: - NPairBinAtomonly(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index 7cfb3b836b..37c6482a6a 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -29,8 +29,8 @@ using namespace NeighConst; /* ---------------------------------------------------------------------- */ -template -NPairMulti::NPairMulti(LAMMPS *lmp) : NPair(lmp) {} +template +NPairMulti::NPairMulti(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- multi stencil is icollection-jcollection dependent @@ -48,8 +48,8 @@ NPairMulti::NPairMulti(LAMMPS *lmp) : NPair(lmp) {} every pair stored exactly once by some processor ------------------------------------------------------------------------- */ -template -void NPairMulti::build(NeighList *list) +template +void NPairMulti::build(NeighList *list) { int i, j, jh, js, k, n, itype, jtype, ibin, jbin, icollection, jcollection, which, ns, imol, iatom, moltemplate; tagint itag, jtag, tagprev; @@ -73,10 +73,12 @@ void NPairMulti::build(NeighList *list) int *molindex = atom->molindex; int *molatom = atom->molatom; Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) - moltemplate = 1; - else - moltemplate = 0; + if (!ATOMONLY) { + if (molecular == Atom::TEMPLATE) + moltemplate = 1; + else + moltemplate = 0; + } int history = list->history; int mask_history = 1 << HISTBITS; @@ -99,10 +101,12 @@ void NPairMulti::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; + if (!ATOMONLY) { + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } } ibin = atom2bin[i]; @@ -209,46 +213,59 @@ void NPairMulti::build(NeighList *list) 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 + if (ATOMONLY) { + if (rsq <= cutsq) { + jh = j; + if (history && rsq < (radsum * radsum)) + jh = jh ^ mask_history; neighptr[n++] = jh; + } + } else { + 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) + if (ATOMONLY) { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } 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; - 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; + } } } } @@ -267,12 +284,20 @@ void NPairMulti::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairMulti<0,1,0,0>; -template class NPairMulti<1,0,0,0>; -template class NPairMulti<1,1,0,0>; -template class NPairMulti<1,1,1,0>; -template class NPairMulti<0,1,0,1>; -template class NPairMulti<1,0,0,1>; -template class NPairMulti<1,1,0,1>; -template class NPairMulti<1,1,1,1>; +template class NPairMulti<0,1,0,0,0>; +template class NPairMulti<1,0,0,0,0>; +template class NPairMulti<1,1,0,0,0>; +template class NPairMulti<1,1,1,0,0>; +template class NPairMulti<0,1,0,1,0>; +template class NPairMulti<1,0,0,1,0>; +template class NPairMulti<1,1,0,1,0>; +template class NPairMulti<1,1,1,1,0>; +template class NPairMulti<0,1,0,0,1>; +template class NPairMulti<1,0,0,0,1>; +template class NPairMulti<1,1,0,0,1>; +template class NPairMulti<1,1,1,0,1>; +template class NPairMulti<0,1,0,1,1>; +template class NPairMulti<1,0,0,1,1>; +template class NPairMulti<1,1,0,1,1>; +template class NPairMulti<1,1,1,1,1>; } diff --git a/src/npair_multi.h b/src/npair_multi.h index f6a68711e2..a82352f840 100644 --- a/src/npair_multi.h +++ b/src/npair_multi.h @@ -13,47 +13,89 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairMulti<0, 1, 0, 0> NPairFullMulti; +typedef NPairMulti<0, 1, 0, 0, 0> NPairFullMulti; NPairStyle(full/multi, NPairFullMulti, - NP_FULL | NP_MULTI | + NP_FULL | NP_MULTI | NP_MOLONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMulti<1, 0, 0, 0> NPairHalfMultiNewtoff; +typedef NPairMulti<1, 0, 0, 0, 0> NPairHalfMultiNewtoff; NPairStyle(half/multi/newtoff, NPairHalfMultiNewtoff, - NP_HALF | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_MULTI | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMulti<1, 1, 0, 0> NPairHalfMultiNewton; +typedef NPairMulti<1, 1, 0, 0, 0> NPairHalfMultiNewton; NPairStyle(half/multi/newton, NPairHalfMultiNewton, - NP_HALF | NP_MULTI | NP_NEWTON | NP_ORTHO); + NP_HALF | NP_MULTI | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairMulti<1, 1, 1, 0> NPairHalfMultiNewtonTri; +typedef NPairMulti<1, 1, 1, 0, 0> NPairHalfMultiNewtonTri; NPairStyle(half/multi/newton/tri, NPairHalfMultiNewtonTri, - NP_HALF | NP_MULTI | NP_NEWTON | NP_TRI); + NP_HALF | NP_MULTI | NP_MOLONLY | NP_NEWTON | NP_TRI); -typedef NPairMulti<0, 1, 0, 1> NPairFullSizeMulti; +typedef NPairMulti<0, 1, 0, 1, 0> NPairFullSizeMulti; NPairStyle(full/size/multi, NPairFullSizeMulti, - NP_FULL | NP_SIZE | NP_MULTI | + NP_FULL | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMulti<1, 0, 0, 1> NPairHalfSizeMultiNewtoff; +typedef NPairMulti<1, 0, 0, 1, 0> NPairHalfSizeMultiNewtoff; NPairStyle(half/size/multi/newtoff, NPairHalfSizeMultiNewtoff, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairMulti<1, 1, 0, 1> NPairHalfSizeMultiNewton; +typedef NPairMulti<1, 1, 0, 1, 0> NPairHalfSizeMultiNewton; NPairStyle(half/size/multi/newton, NPairHalfSizeMultiNewton, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_ORTHO); + NP_HALF | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairMulti<1, 1, 1, 1> NPairHalfSizeMultiNewtonTri; +typedef NPairMulti<1, 1, 1, 1, 0> NPairHalfSizeMultiNewtonTri; NPairStyle(half/size/multi/newton/tri, NPairHalfSizeMultiNewtonTri, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_TRI); + NP_HALF | NP_SIZE | NP_MULTI | NP_MOLONLY | NP_NEWTON | NP_TRI); + +typedef NPairMulti<0, 1, 0, 0, 1> NPairFullMultiAtomonly; +NPairStyle(full/multi/atomonly, + NPairFullMultiAtomonly, + NP_FULL | NP_MULTI | NP_ATOMONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 0, 0, 0, 1> NPairHalfMultiAtomonlyNewtoff; +NPairStyle(half/multi/atomonly/newtoff, + NPairHalfMultiAtomonlyNewtoff, + NP_HALF | NP_MULTI | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 1, 0, 0, 1> NPairHalfMultiAtomonlyNewton; +NPairStyle(half/multi/atomonly/newton, + NPairHalfMultiAtomonlyNewton, + NP_HALF | NP_MULTI | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairMulti<1, 1, 1, 0, 1> NPairHalfMultiAtomonlyNewtonTri; +NPairStyle(half/multi/atomonly/newton/tri, + NPairHalfMultiAtomonlyNewtonTri, + NP_HALF | NP_MULTI | NP_ATOMONLY | NP_NEWTON | NP_TRI); + +typedef NPairMulti<0, 1, 0, 1, 1> NPairFullSizeMultiAtomonly; +NPairStyle(full/size/multi/atomonly, + NPairFullSizeMultiAtomonly, + NP_FULL | NP_SIZE | NP_MULTI | NP_ATOMONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 0, 0, 1, 1> NPairHalfSizeMultiAtomonlyNewtoff; +NPairStyle(half/size/multi/atomonly/newtoff, + NPairHalfSizeMultiAtomonlyNewtoff, + NP_HALF | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 1, 0, 1, 1> NPairHalfSizeMultiAtomonlyNewton; +NPairStyle(half/size/multi/atomonly/newton, + NPairHalfSizeMultiAtomonlyNewton, + NP_HALF | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairMulti<1, 1, 1, 1, 1> NPairHalfSizeMultiAtomonlyNewtonTri; +NPairStyle(half/size/multi/atomonly/newton/tri, + NPairHalfSizeMultiAtomonlyNewtonTri, + NP_HALF | NP_SIZE | NP_MULTI | NP_ATOMONLY | NP_NEWTON | NP_TRI); // clang-format on #else @@ -64,7 +106,7 @@ NPairStyle(half/size/multi/newton/tri, namespace LAMMPS_NS { -template +template class NPairMulti : public NPair { public: NPairMulti(class LAMMPS *); diff --git a/src/npair_multi_old.cpp b/src/npair_multi_old.cpp index 1889061093..fa39182018 100644 --- a/src/npair_multi_old.cpp +++ b/src/npair_multi_old.cpp @@ -111,9 +111,9 @@ void NPairMultiOld::build(NeighList *list) cutnsq = cutneighsq[itype]; ns = nstencil_multi_old[itype]; for (k = 0; k < ns; k++) { - bin_start = binhead[ibin+stencil[k]]; - if (stencil[k] == 0) { - if (HALF && NEWTON && (!TRI)) { + bin_start = binhead[ibin + s[k]]; + if (HALF && NEWTON && (!TRI)) { + if (s[k] == 0) { // Half neighbor list, newton on, orthonormal // loop over rest of atoms in i's bin, ghosts are at end of linked list bin_start = bins[i]; diff --git a/src/npair_respa_bin.cpp b/src/npair_respa_bin.cpp index bcbecc05f1..085986903d 100644 --- a/src/npair_respa_bin.cpp +++ b/src/npair_respa_bin.cpp @@ -122,8 +122,8 @@ void NPairRespaBin::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin+stencil[k]]; - if (stencil[k] == 0) { - if (NEWTON && (!TRI)) { + if (NEWTON && (!TRI)) { + if (stencil[k] == 0) { // Half neighbor list, newton on, orthonormal // loop over rest of atoms in i's bin, ghosts are at end of linked list bin_start = bins[i]; diff --git a/src/nstencil_multi_old.cpp b/src/nstencil_multi_old.cpp index a6b8f14263..6d34d8881f 100644 --- a/src/nstencil_multi_old.cpp +++ b/src/nstencil_multi_old.cpp @@ -69,7 +69,7 @@ void NStencilMultiOld::create() if (HALF && DIM_3D && (!TRI)) if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; - rsq = bin_distance(i, j, 0); + rsq = bin_distance(i, j, k); if (rsq < typesq) { distsq[n] = rsq; s[n++] = k * mbiny * mbinx + j * mbinx + i;