From fb2cf0c32a7ca4ae73b2097221e8efc1641d37e4 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Thu, 4 Aug 2022 14:05:18 -0600 Subject: [PATCH 01/87] Prototyping new nstencil/npair classes --- src/{npair_full_bin.cpp => npair_bin.cpp} | 76 +++++- src/{npair_full_bin.h => npair_bin.h} | 25 +- src/npair_bin_atomonly.cpp | 148 +++++++++++ ...ll_bin_atomonly.h => npair_bin_atomonly.h} | 15 +- src/npair_copy.cpp | 38 --- src/npair_copy.h | 42 ---- src/npair_full_bin_atomonly.cpp | 94 ------- src/npair_full_bin_ghost.cpp | 156 ------------ src/npair_full_bin_ghost.h | 47 ---- src/npair_full_multi.cpp | 143 ----------- src/npair_full_multi.h | 46 ---- src/npair_full_multi_old.cpp | 133 ---------- src/npair_full_multi_old.h | 46 ---- src/npair_full_nsq.cpp | 125 ---------- src/npair_full_nsq.h | 46 ---- src/npair_full_nsq_ghost.cpp | 138 ----------- src/npair_full_nsq_ghost.h | 47 ---- src/npair_half_bin_atomonly_newton.cpp | 116 --------- src/npair_half_bin_atomonly_newton.h | 46 ---- src/npair_half_bin_newtoff.cpp | 129 ---------- src/npair_half_bin_newtoff.h | 46 ---- src/npair_half_bin_newtoff_ghost.cpp | 162 ------------ src/npair_half_bin_newtoff_ghost.h | 46 ---- src/npair_half_bin_newton.cpp | 161 ------------ src/npair_half_bin_newton.h | 46 ---- src/npair_half_bin_newton_tri.cpp | 134 ---------- src/npair_half_bin_newton_tri.h | 46 ---- src/npair_half_multi_newtoff.cpp | 146 ----------- src/npair_half_multi_newtoff.h | 46 ---- src/npair_half_multi_newton.cpp | 194 --------------- src/npair_half_multi_newton.h | 42 ---- src/npair_half_multi_newton_tri.cpp | 159 ------------ src/npair_half_multi_newton_tri.h | 42 ---- src/npair_half_multi_old_newtoff.cpp | 136 ---------- src/npair_half_multi_old_newtoff.h | 46 ---- src/npair_half_multi_old_newton.cpp | 169 ------------- src/npair_half_multi_old_newton.h | 46 ---- src/npair_half_multi_old_newton_tri.cpp | 144 ----------- src/npair_half_multi_old_newton_tri.h | 46 ---- src/npair_half_nsq_newtoff.cpp | 125 ---------- src/npair_half_nsq_newtoff.h | 46 ---- src/npair_half_nsq_newtoff_ghost.cpp | 150 ----------- src/npair_half_nsq_newtoff_ghost.h | 46 ---- src/npair_half_nsq_newton.cpp | 142 ----------- src/npair_half_nsq_newton.h | 46 ---- src/npair_half_respa_bin_newtoff.cpp | 187 -------------- src/npair_half_respa_bin_newtoff.h | 46 ---- src/npair_half_respa_bin_newton.cpp | 233 ------------------ src/npair_half_respa_bin_newton.h | 46 ---- src/npair_half_respa_bin_newton_tri.cpp | 195 --------------- src/npair_half_respa_bin_newton_tri.h | 46 ---- src/npair_half_respa_nsq_newtoff.cpp | 182 -------------- src/npair_half_respa_nsq_newtoff.h | 46 ---- src/npair_half_respa_nsq_newton.cpp | 202 --------------- src/npair_half_respa_nsq_newton.h | 46 ---- src/npair_half_size_bin_newtoff.cpp | 138 ----------- src/npair_half_size_bin_newtoff.h | 46 ---- src/npair_half_size_bin_newton.cpp | 176 ------------- src/npair_half_size_bin_newton.h | 46 ---- src/npair_half_size_bin_newton_tri.cpp | 147 ----------- src/npair_half_size_bin_newton_tri.h | 46 ---- src/npair_half_size_multi_newtoff.cpp | 160 ------------ src/npair_half_size_multi_newtoff.h | 46 ---- src/npair_half_size_multi_newton.cpp | 213 ---------------- src/npair_half_size_multi_newton.h | 46 ---- src/npair_half_size_multi_newton_tri.cpp | 172 ------------- src/npair_half_size_multi_newton_tri.h | 46 ---- src/npair_half_size_multi_old_newtoff.cpp | 149 ----------- src/npair_half_size_multi_old_newtoff.h | 45 ---- src/npair_half_size_multi_old_newton.cpp | 187 -------------- src/npair_half_size_multi_old_newton.h | 45 ---- src/npair_half_size_multi_old_newton_tri.cpp | 156 ------------ src/npair_half_size_multi_old_newton_tri.h | 45 ---- src/npair_half_size_nsq_newtoff.cpp | 136 ---------- src/npair_half_size_nsq_newtoff.h | 46 ---- src/npair_half_size_nsq_newton.cpp | 154 ------------ src/npair_half_size_nsq_newton.h | 46 ---- src/npair_halffull_newtoff.cpp | 83 ------- src/npair_halffull_newtoff.h | 62 ----- src/npair_halffull_newton.cpp | 97 -------- src/npair_halffull_newton.h | 52 ---- src/npair_skip.cpp | 102 -------- src/npair_skip.h | 54 ---- src/npair_skip_respa.cpp | 163 ------------ src/npair_skip_respa.h | 48 ---- src/npair_skip_size.cpp | 88 ------- src/npair_skip_size.h | 47 ---- src/npair_skip_size_off2on.cpp | 100 -------- src/npair_skip_size_off2on.h | 48 ---- src/npair_skip_size_off2on_oneside.cpp | 163 ------------ src/npair_skip_size_off2on_oneside.h | 48 ---- ...l_half_bin_3d_tri.cpp => nstencil_bin.cpp} | 41 ++- src/nstencil_bin.h | 69 ++++++ src/nstencil_full_bin_2d.cpp | 37 --- src/nstencil_full_bin_2d.h | 42 ---- src/nstencil_full_bin_3d.cpp | 38 --- src/nstencil_full_bin_3d.h | 42 ---- src/nstencil_full_ghost_bin_2d.cpp | 44 ---- src/nstencil_full_ghost_bin_2d.h | 42 ---- src/nstencil_full_ghost_bin_3d.cpp | 45 ---- src/nstencil_full_ghost_bin_3d.h | 42 ---- src/nstencil_full_multi_2d.cpp | 81 ------ src/nstencil_full_multi_2d.h | 44 ---- src/nstencil_full_multi_3d.cpp | 86 ------- src/nstencil_full_multi_3d.h | 44 ---- src/nstencil_full_multi_old_2d.cpp | 51 ---- src/nstencil_full_multi_old_2d.h | 42 ---- src/nstencil_full_multi_old_3d.cpp | 52 ---- src/nstencil_full_multi_old_3d.h | 42 ---- src/nstencil_half_bin_2d.cpp | 38 --- src/nstencil_half_bin_2d.h | 42 ---- src/nstencil_half_bin_2d_tri.cpp | 38 --- src/nstencil_half_bin_2d_tri.h | 42 ---- src/nstencil_half_bin_3d.cpp | 39 --- src/nstencil_half_bin_3d.h | 42 ---- src/nstencil_half_bin_3d_tri.h | 42 ---- src/nstencil_half_multi_2d.cpp | 103 -------- src/nstencil_half_multi_2d.h | 44 ---- src/nstencil_half_multi_2d_tri.cpp | 100 -------- src/nstencil_half_multi_2d_tri.h | 44 ---- src/nstencil_half_multi_3d.cpp | 109 -------- src/nstencil_half_multi_3d.h | 44 ---- src/nstencil_half_multi_3d_tri.cpp | 106 -------- src/nstencil_half_multi_3d_tri.h | 44 ---- src/nstencil_half_multi_old_2d.cpp | 53 ---- src/nstencil_half_multi_old_2d.h | 41 --- src/nstencil_half_multi_old_2d_tri.cpp | 52 ---- src/nstencil_half_multi_old_2d_tri.h | 41 --- src/nstencil_half_multi_old_3d.cpp | 54 ---- src/nstencil_half_multi_old_3d.h | 41 --- src/nstencil_half_multi_old_3d_tri.cpp | 53 ---- src/nstencil_half_multi_old_3d_tri.h | 41 --- 132 files changed, 349 insertions(+), 10531 deletions(-) rename src/{npair_full_bin.cpp => npair_bin.cpp} (58%) rename src/{npair_full_bin.h => npair_bin.h} (60%) create mode 100644 src/npair_bin_atomonly.cpp rename src/{npair_full_bin_atomonly.h => npair_bin_atomonly.h} (71%) delete mode 100644 src/npair_copy.cpp delete mode 100644 src/npair_copy.h delete mode 100644 src/npair_full_bin_atomonly.cpp delete mode 100644 src/npair_full_bin_ghost.cpp delete mode 100644 src/npair_full_bin_ghost.h delete mode 100644 src/npair_full_multi.cpp delete mode 100644 src/npair_full_multi.h delete mode 100644 src/npair_full_multi_old.cpp delete mode 100644 src/npair_full_multi_old.h delete mode 100644 src/npair_full_nsq.cpp delete mode 100644 src/npair_full_nsq.h delete mode 100644 src/npair_full_nsq_ghost.cpp delete mode 100644 src/npair_full_nsq_ghost.h delete mode 100644 src/npair_half_bin_atomonly_newton.cpp delete mode 100644 src/npair_half_bin_atomonly_newton.h delete mode 100644 src/npair_half_bin_newtoff.cpp delete mode 100644 src/npair_half_bin_newtoff.h delete mode 100644 src/npair_half_bin_newtoff_ghost.cpp delete mode 100644 src/npair_half_bin_newtoff_ghost.h delete mode 100644 src/npair_half_bin_newton.cpp delete mode 100644 src/npair_half_bin_newton.h delete mode 100644 src/npair_half_bin_newton_tri.cpp delete mode 100644 src/npair_half_bin_newton_tri.h delete mode 100644 src/npair_half_multi_newtoff.cpp delete mode 100644 src/npair_half_multi_newtoff.h delete mode 100644 src/npair_half_multi_newton.cpp delete mode 100644 src/npair_half_multi_newton.h delete mode 100644 src/npair_half_multi_newton_tri.cpp delete mode 100644 src/npair_half_multi_newton_tri.h delete mode 100644 src/npair_half_multi_old_newtoff.cpp delete mode 100644 src/npair_half_multi_old_newtoff.h delete mode 100644 src/npair_half_multi_old_newton.cpp delete mode 100644 src/npair_half_multi_old_newton.h delete mode 100644 src/npair_half_multi_old_newton_tri.cpp delete mode 100644 src/npair_half_multi_old_newton_tri.h delete mode 100644 src/npair_half_nsq_newtoff.cpp delete mode 100644 src/npair_half_nsq_newtoff.h delete mode 100644 src/npair_half_nsq_newtoff_ghost.cpp delete mode 100644 src/npair_half_nsq_newtoff_ghost.h delete mode 100644 src/npair_half_nsq_newton.cpp delete mode 100644 src/npair_half_nsq_newton.h delete mode 100644 src/npair_half_respa_bin_newtoff.cpp delete mode 100644 src/npair_half_respa_bin_newtoff.h delete mode 100644 src/npair_half_respa_bin_newton.cpp delete mode 100644 src/npair_half_respa_bin_newton.h delete mode 100644 src/npair_half_respa_bin_newton_tri.cpp delete mode 100644 src/npair_half_respa_bin_newton_tri.h delete mode 100644 src/npair_half_respa_nsq_newtoff.cpp delete mode 100644 src/npair_half_respa_nsq_newtoff.h delete mode 100644 src/npair_half_respa_nsq_newton.cpp delete mode 100644 src/npair_half_respa_nsq_newton.h delete mode 100644 src/npair_half_size_bin_newtoff.cpp delete mode 100644 src/npair_half_size_bin_newtoff.h delete mode 100644 src/npair_half_size_bin_newton.cpp delete mode 100644 src/npair_half_size_bin_newton.h delete mode 100644 src/npair_half_size_bin_newton_tri.cpp delete mode 100644 src/npair_half_size_bin_newton_tri.h delete mode 100644 src/npair_half_size_multi_newtoff.cpp delete mode 100644 src/npair_half_size_multi_newtoff.h delete mode 100644 src/npair_half_size_multi_newton.cpp delete mode 100644 src/npair_half_size_multi_newton.h delete mode 100644 src/npair_half_size_multi_newton_tri.cpp delete mode 100644 src/npair_half_size_multi_newton_tri.h delete mode 100644 src/npair_half_size_multi_old_newtoff.cpp delete mode 100644 src/npair_half_size_multi_old_newtoff.h delete mode 100644 src/npair_half_size_multi_old_newton.cpp delete mode 100644 src/npair_half_size_multi_old_newton.h delete mode 100644 src/npair_half_size_multi_old_newton_tri.cpp delete mode 100644 src/npair_half_size_multi_old_newton_tri.h delete mode 100644 src/npair_half_size_nsq_newtoff.cpp delete mode 100644 src/npair_half_size_nsq_newtoff.h delete mode 100644 src/npair_half_size_nsq_newton.cpp delete mode 100644 src/npair_half_size_nsq_newton.h delete mode 100644 src/npair_halffull_newtoff.cpp delete mode 100644 src/npair_halffull_newtoff.h delete mode 100644 src/npair_halffull_newton.cpp delete mode 100644 src/npair_halffull_newton.h delete mode 100644 src/npair_skip.cpp delete mode 100644 src/npair_skip.h delete mode 100644 src/npair_skip_respa.cpp delete mode 100644 src/npair_skip_respa.h delete mode 100644 src/npair_skip_size.cpp delete mode 100644 src/npair_skip_size.h delete mode 100644 src/npair_skip_size_off2on.cpp delete mode 100644 src/npair_skip_size_off2on.h delete mode 100644 src/npair_skip_size_off2on_oneside.cpp delete mode 100644 src/npair_skip_size_off2on_oneside.h rename src/{nstencil_half_bin_3d_tri.cpp => nstencil_bin.cpp} (51%) create mode 100644 src/nstencil_bin.h delete mode 100644 src/nstencil_full_bin_2d.cpp delete mode 100644 src/nstencil_full_bin_2d.h delete mode 100644 src/nstencil_full_bin_3d.cpp delete mode 100644 src/nstencil_full_bin_3d.h delete mode 100644 src/nstencil_full_ghost_bin_2d.cpp delete mode 100644 src/nstencil_full_ghost_bin_2d.h delete mode 100644 src/nstencil_full_ghost_bin_3d.cpp delete mode 100644 src/nstencil_full_ghost_bin_3d.h delete mode 100644 src/nstencil_full_multi_2d.cpp delete mode 100644 src/nstencil_full_multi_2d.h delete mode 100644 src/nstencil_full_multi_3d.cpp delete mode 100644 src/nstencil_full_multi_3d.h delete mode 100644 src/nstencil_full_multi_old_2d.cpp delete mode 100644 src/nstencil_full_multi_old_2d.h delete mode 100644 src/nstencil_full_multi_old_3d.cpp delete mode 100644 src/nstencil_full_multi_old_3d.h delete mode 100644 src/nstencil_half_bin_2d.cpp delete mode 100644 src/nstencil_half_bin_2d.h delete mode 100644 src/nstencil_half_bin_2d_tri.cpp delete mode 100644 src/nstencil_half_bin_2d_tri.h delete mode 100644 src/nstencil_half_bin_3d.cpp delete mode 100644 src/nstencil_half_bin_3d.h delete mode 100644 src/nstencil_half_bin_3d_tri.h delete mode 100644 src/nstencil_half_multi_2d.cpp delete mode 100644 src/nstencil_half_multi_2d.h delete mode 100644 src/nstencil_half_multi_2d_tri.cpp delete mode 100644 src/nstencil_half_multi_2d_tri.h delete mode 100644 src/nstencil_half_multi_3d.cpp delete mode 100644 src/nstencil_half_multi_3d.h delete mode 100644 src/nstencil_half_multi_3d_tri.cpp delete mode 100644 src/nstencil_half_multi_3d_tri.h delete mode 100644 src/nstencil_half_multi_old_2d.cpp delete mode 100644 src/nstencil_half_multi_old_2d.h delete mode 100644 src/nstencil_half_multi_old_2d_tri.cpp delete mode 100644 src/nstencil_half_multi_old_2d_tri.h delete mode 100644 src/nstencil_half_multi_old_3d.cpp delete mode 100644 src/nstencil_half_multi_old_3d.h delete mode 100644 src/nstencil_half_multi_old_3d_tri.cpp delete mode 100644 src/nstencil_half_multi_old_3d_tri.h diff --git a/src/npair_full_bin.cpp b/src/npair_bin.cpp similarity index 58% rename from src/npair_full_bin.cpp rename to src/npair_bin.cpp index 64404ccf8d..294336a03a 100644 --- a/src/npair_full_bin.cpp +++ b/src/npair_bin.cpp @@ -12,29 +12,33 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "npair_full_bin.h" +#include "npair_bin.h" #include "neigh_list.h" #include "atom.h" #include "atom_vec.h" #include "molecule.h" +#include "neighbor.h" #include "domain.h" #include "my_page.h" #include "error.h" using namespace LAMMPS_NS; +using namespace NeighConst; /* ---------------------------------------------------------------------- */ -NPairFullBin::NPairFullBin(LAMMPS *lmp) : NPair(lmp) {} +template +NPairBin::NPairBin(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- binned neighbor list construction for all neighbors every neighbor pair appears in list of both atoms i and j ------------------------------------------------------------------------- */ -void NPairFullBin::build(NeighList *list) +template +void NPairBin::build(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; + int i,j,k,n,itype,jtype,ibin,bin_start,which,imol,iatom,moltemplate; tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -77,14 +81,59 @@ void NPairFullBin::build(NeighList *list) tagprev = tag[i] - iatom - 1; } - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) continue; + 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; @@ -121,5 +170,12 @@ void NPairFullBin::build(NeighList *list) } list->inum = inum; - list->gnum = 0; + if (!HALF) list->gnum = 0; +} + +namespace LAMMPS_NS { +template class NPairBin<0,1,0>; +template class NPairBin<1,0,0>; +template class NPairBin<1,1,0>; +template class NPairBin<1,1,1>; } diff --git a/src/npair_full_bin.h b/src/npair_bin.h similarity index 60% rename from src/npair_full_bin.h rename to src/npair_bin.h index 4d40763271..af23880db7 100644 --- a/src/npair_full_bin.h +++ b/src/npair_bin.h @@ -13,23 +13,40 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairBin<0, 1, 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> NPairHalfBinNewtoff; +NPairStyle(half/bin/newtoff, + NPairHalfBinNewtoff, + NP_HALF | NP_BIN | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBin<1, 1, 0> NPairHalfBinNewton; +NPairStyle(half/bin/newton, + NPairHalfBinNewton, + NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_ORTHO); + +typedef NPairBin<1, 1, 1> NPairHalfBinNewtonTri; +NPairStyle(half/bin/newton/tri, + NPairHalfBinNewtonTri, + NP_HALF | NP_BIN | NP_NEWTON | NP_TRI); // clang-format on #else -#ifndef LMP_NPAIR_FULL_BIN_H -#define LMP_NPAIR_FULL_BIN_H +#ifndef LMP_NPAIR_BIN_H +#define LMP_NPAIR_BIN_H #include "npair.h" namespace LAMMPS_NS { -class NPairFullBin : public NPair { +template +class NPairBin : public NPair { public: - NPairFullBin(class LAMMPS *); + NPairBin(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_bin_atomonly.cpp b/src/npair_bin_atomonly.cpp new file mode 100644 index 0000000000..aa66089fc5 --- /dev/null +++ b/src/npair_bin_atomonly.cpp @@ -0,0 +1,148 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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) {} + +/* ---------------------------------------------------------------------- + binned neighbor list construction for all neighbors + every neighbor pair appears in list of both atoms i and j +------------------------------------------------------------------------- */ + +template +void NPairBinAtomonly::build(NeighList *list) +{ + int i,j,k,n,itype,jtype,ibin,bin_start; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *neighptr; + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + tagint *molecule = atom->molecule; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + 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 (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>; +template class NPairBinAtomonly<1,1,0>; +} diff --git a/src/npair_full_bin_atomonly.h b/src/npair_bin_atomonly.h similarity index 71% rename from src/npair_full_bin_atomonly.h rename to src/npair_bin_atomonly.h index 8e3f96e59b..ae64863138 100644 --- a/src/npair_full_bin_atomonly.h +++ b/src/npair_bin_atomonly.h @@ -13,23 +13,30 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairBinAtomonly<0, 1, 0> NPairFullBinAtomonly; NPairStyle(full/bin/atomonly, NPairFullBinAtomonly, NP_FULL | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBinAtomonly<1, 1, 0> NPairHalfBinAtomonlyNewton; +NPairStyle(half/bin/atomonly/newton, + NPairHalfBinAtomonlyNewton, + NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); // clang-format on #else -#ifndef LMP_NPAIR_FULL_BIN_ATOMONLY_H -#define LMP_NPAIR_FULL_BIN_ATOMONLY_H +#ifndef LMP_NPAIR_BIN_ATOMONLY_H +#define LMP_NPAIR_BIN_ATOMONLY_H #include "npair.h" namespace LAMMPS_NS { -class NPairFullBinAtomonly : public NPair { +template +class NPairBinAtomonly : public NPair { public: - NPairFullBinAtomonly(class LAMMPS *); + NPairBinAtomonly(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_copy.cpp b/src/npair_copy.cpp deleted file mode 100644 index b3cab53e0a..0000000000 --- a/src/npair_copy.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_copy.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairCopy::NPairCopy(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - create list which is simply a copy of parent list -------------------------------------------------------------------------- */ - -void NPairCopy::build(NeighList *list) -{ - NeighList *listcopy = list->listcopy; - - list->inum = listcopy->inum; - list->gnum = listcopy->gnum; - list->ilist = listcopy->ilist; - list->numneigh = listcopy->numneigh; - list->firstneigh = listcopy->firstneigh; - list->ipage = listcopy->ipage; -} diff --git a/src/npair_copy.h b/src/npair_copy.h deleted file mode 100644 index 36b80f83d9..0000000000 --- a/src/npair_copy.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(copy, - NPairCopy, - NP_COPY); -// clang-format on -#else - -#ifndef LMP_NPAIR_COPY_H -#define LMP_NPAIR_COPY_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairCopy : public NPair { - public: - NPairCopy(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/npair_full_bin_atomonly.cpp b/src/npair_full_bin_atomonly.cpp deleted file mode 100644 index b8c4378280..0000000000 --- a/src/npair_full_bin_atomonly.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_full_bin_atomonly.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullBinAtomonly::NPairFullBinAtomonly(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullBinAtomonly::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - 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]; - - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) 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]) 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; - list->gnum = 0; -} diff --git a/src/npair_full_bin_ghost.cpp b/src/npair_full_bin_ghost.cpp deleted file mode 100644 index e051a1d75a..0000000000 --- a/src/npair_full_bin_ghost.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_full_bin_ghost.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullBinGhost::NPairFullBinGhost(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - include neighbors of ghost atoms, but no "special neighbors" for ghosts - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullBinGhost::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int xbin,ybin,zbin,xbin2,ybin2,zbin2; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int inum = 0; - ipage->reset(); - - // loop over owned & ghost atoms, storing neighbors - - for (i = 0; i < nall; i++) { - n = 0; - neighptr = ipage->vget(); - - itype = type[i]; - 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; - } - - // loop over all atoms in surrounding bins in stencil including self - // when i is a ghost atom, must check if stencil bin is out of bounds - // skip i = j - // no molecular test when i = ghost atom - - if (i < nlocal) { - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) 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 != 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 { - ibin = coord2bin(x[i],xbin,ybin,zbin); - for (k = 0; k < nstencil; k++) { - xbin2 = xbin + stencilxyz[k][0]; - ybin2 = ybin + stencilxyz[k][1]; - zbin2 = zbin + stencilxyz[k][2]; - if (xbin2 < 0 || xbin2 >= mbinx || - ybin2 < 0 || ybin2 >= mbiny || - zbin2 < 0 || zbin2 >= mbinz) continue; - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) 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 <= cutneighghostsq[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 = atom->nlocal; - list->gnum = inum - atom->nlocal; -} diff --git a/src/npair_full_bin_ghost.h b/src/npair_full_bin_ghost.h deleted file mode 100644 index 4b7e08a0e1..0000000000 --- a/src/npair_full_bin_ghost.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(full/bin/ghost, - NPairFullBinGhost, - NP_FULL | NP_BIN | NP_GHOST | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_BIN_GHOST_H -#define LMP_NPAIR_FULL_BIN_GHOST_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullBinGhost : public NPair { - public: - NPairFullBinGhost(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_full_multi.cpp b/src/npair_full_multi.cpp deleted file mode 100644 index 34b7a7bfa8..0000000000 --- a/src/npair_full_multi.cpp +++ /dev/null @@ -1,143 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_full_multi.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullMulti::NPairFullMulti(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - multi stencil is icollection-jcollection dependent - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullMulti::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if(icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - // use full stencil for all collection combinations - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - if (i == j) 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 != 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; - } - } - } - } - - 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; - list->gnum = 0; -} diff --git a/src/npair_full_multi.h b/src/npair_full_multi.h deleted file mode 100644 index dcd1b5d8a9..0000000000 --- a/src/npair_full_multi.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(full/multi, - NPairFullMulti, - NP_FULL | NP_MULTI | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_MULTI_H -#define LMP_NPAIR_FULL_MULTI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullMulti : public NPair { - public: - NPairFullMulti(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_full_multi_old.cpp b/src/npair_full_multi_old.cpp deleted file mode 100644 index 7b89f35268..0000000000 --- a/src/npair_full_multi_old.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_full_multi_old.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullMultiOld::NPairFullMultiOld(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - multi-type stencil is itype dependent and is distance checked - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullMultiOld::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil, including self - // skip if i,j neighbor cutoff is less than bin distance - // skip i = j - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - if (i == j) continue; - - 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 != 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; - } - } - } - - 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; - list->gnum = 0; -} diff --git a/src/npair_full_multi_old.h b/src/npair_full_multi_old.h deleted file mode 100644 index 0dd825fcce..0000000000 --- a/src/npair_full_multi_old.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(full/multi/old, - NPairFullMultiOld, - NP_FULL | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_MULTI_OLD_H -#define LMP_NPAIR_FULL_MULTI_OLD_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullMultiOld : public NPair { - public: - NPairFullMultiOld(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_full_nsq.cpp b/src/npair_full_nsq.cpp deleted file mode 100644 index c6427366f4..0000000000 --- a/src/npair_full_nsq.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_full_nsq.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullNsq::NPairFullNsq(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 search for all neighbors - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullNsq::build(NeighList *list) -{ - int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms, owned and ghost - // skip i = j - - for (j = 0; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) continue; - if (i == j) 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 != 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; - } - } - - 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; - list->gnum = 0; -} diff --git a/src/npair_full_nsq.h b/src/npair_full_nsq.h deleted file mode 100644 index 0e65fcd027..0000000000 --- a/src/npair_full_nsq.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(full/nsq, - NPairFullNsq, - NP_FULL | NP_NSQ | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_NSQ_H -#define LMP_NPAIR_FULL_NSQ_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullNsq : public NPair { - public: - NPairFullNsq(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_full_nsq_ghost.cpp b/src/npair_full_nsq_ghost.cpp deleted file mode 100644 index 9550ae54f3..0000000000 --- a/src/npair_full_nsq_ghost.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_full_nsq_ghost.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullNsqGhost::NPairFullNsqGhost(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 search for all neighbors - include neighbors of ghost atoms, but no "special neighbors" for ghosts - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullNsqGhost::build(NeighList *list) -{ - int i,j,n,itype,jtype,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int inum = 0; - ipage->reset(); - - // loop over owned & ghost atoms, storing neighbors - - for (i = 0; i < nall; i++) { - n = 0; - neighptr = ipage->vget(); - - itype = type[i]; - 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; - } - - // loop over all atoms, owned and ghost - // skip i = j - // no molecular test when i = ghost atom - - if (i < nlocal) { - for (j = 0; j < nall; j++) { - if (i == j) 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 != 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 { - for (j = 0; j < nall; j++) { - if (i == j) 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 <= cutneighghostsq[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 = atom->nlocal; - list->gnum = inum - atom->nlocal; -} diff --git a/src/npair_full_nsq_ghost.h b/src/npair_full_nsq_ghost.h deleted file mode 100644 index 6ae517ccf7..0000000000 --- a/src/npair_full_nsq_ghost.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(full/nsq/ghost, - NPairFullNsqGhost, - NP_FULL | NP_NSQ | NP_GHOST | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_NSQ_GHOST_H -#define LMP_NPAIR_FULL_NSQ_GHOST_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullNsqGhost : public NPair { - public: - NPairFullNsqGhost(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_bin_atomonly_newton.cpp b/src/npair_half_bin_atomonly_newton.cpp deleted file mode 100644 index db84d38f6e..0000000000 --- a/src/npair_half_bin_atomonly_newton.cpp +++ /dev/null @@ -1,116 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_bin_atomonly_newton.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinAtomonlyNewton::NPairHalfBinAtomonlyNewton(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - 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 -------------------------------------------------------------------------- */ - -void NPairHalfBinAtomonlyNewton::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - 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]; - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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]) neighptr[n++] = j; - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; 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]) 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; -} diff --git a/src/npair_half_bin_atomonly_newton.h b/src/npair_half_bin_atomonly_newton.h deleted file mode 100644 index 7a3eaf34bc..0000000000 --- a/src/npair_half_bin_atomonly_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/bin/atomonly/newton, - NPairHalfBinAtomonlyNewton, - NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_ATOMONLY_NEWTON_H -#define LMP_NPAIR_HALF_BIN_ATOMONLY_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinAtomonlyNewton : public NPair { - public: - NPairHalfBinAtomonlyNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_bin_newtoff.cpp b/src/npair_half_bin_newtoff.cpp deleted file mode 100644 index 00318b2aa7..0000000000 --- a/src/npair_half_bin_newtoff.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_bin_newtoff.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtoff::NPairHalfBinNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - 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) -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtoff::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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); - // OLD: if (which >= 0) neighptr[n++] = j ^ (which << SBBITS); - } else 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; -} diff --git a/src/npair_half_bin_newtoff.h b/src/npair_half_bin_newtoff.h deleted file mode 100644 index db240f8bd9..0000000000 --- a/src/npair_half_bin_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/bin/newtoff, - NPairHalfBinNewtoff, - NP_HALF | NP_BIN | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTOFF_H -#define LMP_NPAIR_HALF_BIN_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtoff : public NPair { - public: - NPairHalfBinNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_bin_newtoff_ghost.cpp b/src/npair_half_bin_newtoff_ghost.cpp deleted file mode 100644 index b85e3328e1..0000000000 --- a/src/npair_half_bin_newtoff_ghost.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_bin_newtoff_ghost.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtoffGhost::NPairHalfBinNewtoffGhost(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with partial Newton's 3rd law - include neighbors of ghost atoms, but no "special neighbors" for ghosts - owned and ghost atoms check own bin and other bins in stencil - pair stored once if i,j are both owned and i < j - pair stored by me if i owned and j ghost (also stored by proc owning j) - pair stored once if i,j are both ghost and i < j -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtoffGhost::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int xbin,ybin,zbin,xbin2,ybin2,zbin2; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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 < nall; i++) { - n = 0; - neighptr = ipage->vget(); - - itype = type[i]; - 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; - } - - // loop over all atoms in other bins in stencil including self - // when i is a ghost atom, must check if stencil bin is out of bounds - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs with owned atom only, on both procs - // stores ghost/ghost pairs only once - // no molecular test when i = ghost atom - - if (i < nlocal) { - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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 { - ibin = coord2bin(x[i],xbin,ybin,zbin); - for (k = 0; k < nstencil; k++) { - xbin2 = xbin + stencilxyz[k][0]; - ybin2 = ybin + stencilxyz[k][1]; - zbin2 = zbin + stencilxyz[k][2]; - if (xbin2 < 0 || xbin2 >= mbinx || - ybin2 < 0 || ybin2 >= mbiny || - zbin2 < 0 || zbin2 >= mbinz) continue; - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 <= cutneighghostsq[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 = atom->nlocal; - list->gnum = inum - atom->nlocal; -} diff --git a/src/npair_half_bin_newtoff_ghost.h b/src/npair_half_bin_newtoff_ghost.h deleted file mode 100644 index b11e0f4802..0000000000 --- a/src/npair_half_bin_newtoff_ghost.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/bin/newtoff/ghost, - NPairHalfBinNewtoffGhost, - NP_HALF | NP_BIN | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTOFF_GHOST_H -#define LMP_NPAIR_HALF_BIN_NEWTOFF_GHOST_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtoffGhost : public NPair { - public: - NPairHalfBinNewtoffGhost(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_bin_newton.cpp b/src/npair_half_bin_newton.cpp deleted file mode 100644 index d07ebf01f9..0000000000 --- a/src/npair_half_bin_newton.cpp +++ /dev/null @@ -1,161 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_bin_newton.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewton::NPairHalfBinNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - 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 -------------------------------------------------------------------------- */ - -void NPairHalfBinNewton::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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 != 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); - // OLD: if (which >= 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - } - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; 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 != 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); - // OLD: if (which >= 0) neighptr[n++] = j ^ (which << SBBITS); - } else 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; -} diff --git a/src/npair_half_bin_newton.h b/src/npair_half_bin_newton.h deleted file mode 100644 index 19f7b93ae4..0000000000 --- a/src/npair_half_bin_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/bin/newton, - NPairHalfBinNewton, - NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTON_H -#define LMP_NPAIR_HALF_BIN_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewton : public NPair { - public: - NPairHalfBinNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_bin_newton_tri.cpp b/src/npair_half_bin_newton_tri.cpp deleted file mode 100644 index ef2e48a417..0000000000 --- a/src/npair_half_bin_newton_tri.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_bin_newton_tri.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtonTri::NPairHalfBinNewtonTri(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtonTri::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins in stencil - // 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 - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - 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; - } - } - - 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 != 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; - } - } - } - - 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; -} diff --git a/src/npair_half_bin_newton_tri.h b/src/npair_half_bin_newton_tri.h deleted file mode 100644 index ad270ae173..0000000000 --- a/src/npair_half_bin_newton_tri.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/bin/newton/tri, - NPairHalfBinNewtonTri, - NP_HALF | NP_BIN | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTON_TRI_H -#define LMP_NPAIR_HALF_BIN_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtonTri : public NPair { - public: - NPairHalfBinNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_multi_newtoff.cpp b/src/npair_half_multi_newtoff.cpp deleted file mode 100644 index cef28f4cb4..0000000000 --- a/src/npair_half_multi_newtoff.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_multi_newtoff.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiNewtoff::NPairHalfMultiNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with partial Newton's 3rd law - multi stencil is icollection-jcollection dependent - 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) -------------------------------------------------------------------------- */ - -void NPairHalfMultiNewtoff::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - // use full stencil for all collection combinations - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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; - } - } - } - } - - 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; -} diff --git a/src/npair_half_multi_newtoff.h b/src/npair_half_multi_newtoff.h deleted file mode 100644 index 3142587da6..0000000000 --- a/src/npair_half_multi_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/multi/newtoff, - NPairHalfMultiNewtoff, - NP_HALF | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_NEWTOFF_H -#define LMP_NPAIR_HALF_MULTI_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiNewtoff : public NPair { - public: - NPairHalfMultiNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_multi_newton.cpp b/src/npair_half_multi_newton.cpp deleted file mode 100644 index 3ee4ce5fde..0000000000 --- a/src/npair_half_multi_newton.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_multi_newton.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiNewton::NPairHalfMultiNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with full Newton's 3rd law - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in Newton stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiNewton::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == 2) moltemplate = 1; - else moltemplate = 0; - - 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]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if(icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // if same size: uses half stencil so check central bin - if(cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - - if (icollection == jcollection) js = bins[i]; - else js = binhead_multi[jcollection][jbin]; - - // if same collection, - // 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 different collections, - // if j is owned atom, store it if j > i - // if j is ghost, only store if j coords are "above and to the right" of i - - for (j = js; j >= 0; j = bins[j]) { - if((icollection != jcollection) && (j < i)) continue; - - 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; - } - } - } - - // for all collections, loop over all atoms in other bins in stencil, store every pair - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; 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 != 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; - } - } - } - } - - 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; -} diff --git a/src/npair_half_multi_newton.h b/src/npair_half_multi_newton.h deleted file mode 100644 index 55439eacca..0000000000 --- a/src/npair_half_multi_newton.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/multi/newton, - NPairHalfMultiNewton, - NP_HALF | NP_MULTI | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_NEWTON_H -#define LMP_NPAIR_HALF_MULTI_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiNewton : public NPair { - public: - NPairHalfMultiNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/npair_half_multi_newton_tri.cpp b/src/npair_half_multi_newton_tri.cpp deleted file mode 100644 index 4a8bb8e19f..0000000000 --- a/src/npair_half_multi_newton_tri.cpp +++ /dev/null @@ -1,159 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_multi_newton_tri.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiNewtonTri::NPairHalfMultiNewtonTri(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiNewtonTri::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == 2) moltemplate = 1; - else moltemplate = 0; - - 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]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in bins in stencil - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - // if half: 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 - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - - // if same size (same collection), use half stencil - if(cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - 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; - } - } - } - - 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 != 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; - } - } - } - } - - 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; -} diff --git a/src/npair_half_multi_newton_tri.h b/src/npair_half_multi_newton_tri.h deleted file mode 100644 index 2b6d69f332..0000000000 --- a/src/npair_half_multi_newton_tri.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/multi/newton/tri, - NPairHalfMultiNewtonTri, - NP_HALF | NP_MULTI | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_NEWTON_TRI_H -#define LMP_NPAIR_HALF_MULTI_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiNewtonTri : public NPair { - public: - NPairHalfMultiNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/npair_half_multi_old_newtoff.cpp b/src/npair_half_multi_old_newtoff.cpp deleted file mode 100644 index eb6c7d9069..0000000000 --- a/src/npair_half_multi_old_newtoff.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_multi_old_newtoff.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiOldNewtoff::NPairHalfMultiOldNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and other bins in stencil - multi-type stencil is itype dependent and is distance checked - 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) -------------------------------------------------------------------------- */ - -void NPairHalfMultiOldNewtoff::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // skip if i,j neighbor cutoff is less than bin distance - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - if (j <= i) continue; - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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 != 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; - } - } - } - - 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; -} diff --git a/src/npair_half_multi_old_newtoff.h b/src/npair_half_multi_old_newtoff.h deleted file mode 100644 index 9418cf5a4c..0000000000 --- a/src/npair_half_multi_old_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/multi/old/newtoff, - NPairHalfMultiOldNewtoff, - NP_HALF | NP_MULTI_OLD | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_OLD_NEWTOFF_H -#define LMP_NPAIR_HALF_MULTI_OLD_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiOldNewtoff : public NPair { - public: - NPairHalfMultiOldNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_multi_old_newton.cpp b/src/npair_half_multi_old_newton.cpp deleted file mode 100644 index 9708b3e879..0000000000 --- a/src/npair_half_multi_old_newton.cpp +++ /dev/null @@ -1,169 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_multi_old_newton.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiOldNewton::NPairHalfMultiOldNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with full Newton's 3rd law - each owned atom i checks its own bin and other bins in Newton stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiOldNewton::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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 != 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; - } - } - - // loop over all atoms in other bins in stencil, store every pair - // skip if i,j neighbor cutoff is less than bin distance - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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 != 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; - } - } - } - - 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; -} diff --git a/src/npair_half_multi_old_newton.h b/src/npair_half_multi_old_newton.h deleted file mode 100644 index 5c84b8ef98..0000000000 --- a/src/npair_half_multi_old_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/multi/old/newton, - NPairHalfMultiOldNewton, - NP_HALF | NP_MULTI_OLD | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_OLD_NEWTON_H -#define LMP_NPAIR_HALF_MULTI_OLD_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiOldNewton : public NPair { - public: - NPairHalfMultiOldNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_multi_old_newton_tri.cpp b/src/npair_half_multi_old_newton_tri.cpp deleted file mode 100644 index 683cc5f53c..0000000000 --- a/src/npair_half_multi_old_newton_tri.cpp +++ /dev/null @@ -1,144 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_multi_old_newton_tri.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiOldNewtonTri::NPairHalfMultiOldNewtonTri(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiOldNewtonTri::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins, including self, in stencil - // skip if i,j neighbor cutoff is less than bin distance - // bins below self are excluded from stencil - // 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 - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - 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]; - dely = ytmp - x[j][1]; - 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; - } - } - } - - 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; -} diff --git a/src/npair_half_multi_old_newton_tri.h b/src/npair_half_multi_old_newton_tri.h deleted file mode 100644 index 016746cf12..0000000000 --- a/src/npair_half_multi_old_newton_tri.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/multi/old/newton/tri, - NPairHalfMultiOldNewtonTri, - NP_HALF | NP_MULTI_OLD | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_OLD_NEWTON_TRI_H -#define LMP_NPAIR_HALF_MULTI_OLD_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiOldNewtonTri : public NPair { - public: - NPairHalfMultiOldNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_nsq_newtoff.cpp b/src/npair_half_nsq_newtoff.cpp deleted file mode 100644 index affcdcf39f..0000000000 --- a/src/npair_half_nsq_newtoff.cpp +++ /dev/null @@ -1,125 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_nsq_newtoff.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfNsqNewtoff::NPairHalfNsqNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - 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) -------------------------------------------------------------------------- */ - -void NPairHalfNsqNewtoff::build(NeighList *list) -{ - int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - // only store pair if i < j - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 != 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; - } - } - - 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; -} diff --git a/src/npair_half_nsq_newtoff.h b/src/npair_half_nsq_newtoff.h deleted file mode 100644 index 45bef5b0b0..0000000000 --- a/src/npair_half_nsq_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/nsq/newtoff, - NPairHalfNsqNewtoff, - NP_HALF | NP_NSQ | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_NSQ_NEWTOFF_H -#define LMP_NPAIR_HALF_NSQ_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfNsqNewtoff : public NPair { - public: - NPairHalfNsqNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_nsq_newtoff_ghost.cpp b/src/npair_half_nsq_newtoff_ghost.cpp deleted file mode 100644 index eebee1208b..0000000000 --- a/src/npair_half_nsq_newtoff_ghost.cpp +++ /dev/null @@ -1,150 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_nsq_newtoff_ghost.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfNsqNewtoffGhost::NPairHalfNsqNewtoffGhost(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - include neighbors of ghost atoms, but no "special neighbors" for ghosts - pair stored once if i,j are both owned and i < j - pair stored by me if i owned and j ghost (also stored by proc owning j) - pair stored once if i,j are both ghost and i < j -------------------------------------------------------------------------- */ - -void NPairHalfNsqNewtoffGhost::build(NeighList *list) -{ - int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int inum = 0; - ipage->reset(); - - // loop over owned & ghost atoms, storing neighbors - - for (i = 0; i < nall; i++) { - n = 0; - neighptr = ipage->vget(); - - itype = type[i]; - 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; - } - - // loop over remaining atoms, owned and ghost - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs with owned atom only, on both procs - // stores ghost/ghost pairs only once - // no molecular test when i = ghost atom - - if (i < nlocal) { - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 != 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 { - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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]) 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 = atom->nlocal; - list->gnum = inum - atom->nlocal; -} diff --git a/src/npair_half_nsq_newtoff_ghost.h b/src/npair_half_nsq_newtoff_ghost.h deleted file mode 100644 index 5d6cb69450..0000000000 --- a/src/npair_half_nsq_newtoff_ghost.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/nsq/newtoff/ghost, - NPairHalfNsqNewtoffGhost, - NP_HALF | NP_NSQ | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_NSQ_NEWTOFF_GHOST_H -#define LMP_NPAIR_HALF_NSQ_NEWTOFF_GHOST_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfNsqNewtoffGhost : public NPair { - public: - NPairHalfNsqNewtoffGhost(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_nsq_newton.cpp b/src/npair_half_nsq_newton.cpp deleted file mode 100644 index 5263903657..0000000000 --- a/src/npair_half_nsq_newton.cpp +++ /dev/null @@ -1,142 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_nsq_newton.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfNsqNewton::NPairHalfNsqNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 / 2 search for neighbor pairs with full Newton's 3rd law - every pair stored exactly once by some processor - decision on ghost atoms based on itag,jtag tests -------------------------------------------------------------------------- */ - -void NPairHalfNsqNewton::build(NeighList *list) -{ - int i,j,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; - tagint itag,jtag,tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - 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(); - - itag = tag[i]; - itype = type[i]; - 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; - } - - // loop over remaining atoms, owned and ghost - // itag = jtag is possible for long cutoffs that include images of self - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 (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 != 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; - } - } - - 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; -} diff --git a/src/npair_half_nsq_newton.h b/src/npair_half_nsq_newton.h deleted file mode 100644 index 6b7ec89b82..0000000000 --- a/src/npair_half_nsq_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/nsq/newton, - NPairHalfNsqNewton, - NP_HALF | NP_NSQ | NP_NEWTON | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_NSQ_NEWTON_H -#define LMP_NPAIR_HALF_NSQ_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfNsqNewton : public NPair { - public: - NPairHalfNsqNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_respa_bin_newtoff.cpp b/src/npair_half_respa_bin_newtoff.cpp deleted file mode 100644 index b0fb7cb097..0000000000 --- a/src/npair_half_respa_bin_newtoff.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_respa_bin_newtoff.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaBinNewtoff::NPairHalfRespaBinNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and surrounding bins in non-Newton 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) -------------------------------------------------------------------------- */ - -void NPairHalfRespaBinNewtoff::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - } - - int inum = 0; - int which = 0; - int minchange = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - for (i = 0; i < nlocal; i++) { - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itype = type[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - ibin = atom2bin[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in surrounding bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) - neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n_inner); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_half_respa_bin_newtoff.h b/src/npair_half_respa_bin_newtoff.h deleted file mode 100644 index 2782ae239e..0000000000 --- a/src/npair_half_respa_bin_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/respa/bin/newtoff, - NPairHalfRespaBinNewtoff, - NP_HALF | NP_RESPA | NP_BIN | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_BIN_NEWTOFF_H -#define LMP_NPAIR_HALF_RESPA_BIN_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaBinNewtoff : public NPair { - public: - NPairHalfRespaBinNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_respa_bin_newton.cpp b/src/npair_half_respa_bin_newton.cpp deleted file mode 100644 index 0bb6756497..0000000000 --- a/src/npair_half_respa_bin_newton.cpp +++ /dev/null @@ -1,233 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_respa_bin_newton.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaBinNewton::NPairHalfRespaBinNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - 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 -------------------------------------------------------------------------- */ - -void NPairHalfRespaBinNewton::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - } - - int inum = 0; - int which = 0; - int minchange = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - for (i = 0; i < nlocal; i++) { - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itype = type[i]; - 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; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; 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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) - neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n_inner); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_half_respa_bin_newton.h b/src/npair_half_respa_bin_newton.h deleted file mode 100644 index c83ca89891..0000000000 --- a/src/npair_half_respa_bin_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/respa/bin/newton, - NPairHalfRespaBinNewton, - NP_HALF | NP_RESPA | NP_BIN | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_BIN_NEWTON_H -#define LMP_NPAIR_HALF_RESPA_BIN_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaBinNewton : public NPair { - public: - NPairHalfRespaBinNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_respa_bin_newton_tri.cpp b/src/npair_half_respa_bin_newton_tri.cpp deleted file mode 100644 index c6c569d794..0000000000 --- a/src/npair_half_respa_bin_newton_tri.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_respa_bin_newton_tri.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaBinNewtonTri::NPairHalfRespaBinNewtonTri(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfRespaBinNewtonTri::build(NeighList *list) -{ - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - } - - int inum = 0; - int which = 0; - int minchange = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - for (i = 0; i < nlocal; i++) { - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itype = type[i]; - 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; - } - - // loop over all atoms in bins in stencil - // 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 - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - 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; - } - } - - 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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) - neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n_inner); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_half_respa_bin_newton_tri.h b/src/npair_half_respa_bin_newton_tri.h deleted file mode 100644 index a5b573103c..0000000000 --- a/src/npair_half_respa_bin_newton_tri.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/respa/bin/newton/tri, - NPairHalfRespaBinNewtonTri, - NP_HALF | NP_RESPA | NP_BIN | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_BIN_NEWTON_TRI_H -#define LMP_NPAIR_HALF_RESPA_BIN_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaBinNewtonTri : public NPair { - public: - NPairHalfRespaBinNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_respa_nsq_newtoff.cpp b/src/npair_half_respa_nsq_newtoff.cpp deleted file mode 100644 index ff512be7d9..0000000000 --- a/src/npair_half_respa_nsq_newtoff.cpp +++ /dev/null @@ -1,182 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_respa_nsq_newtoff.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaNsqNewtoff::NPairHalfRespaNsqNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - pair added to list if atoms i and j are both owned and i < j - pair added if j is ghost (also stored by proc owning j) -------------------------------------------------------------------------- */ - -void NPairHalfRespaNsqNewtoff::build(NeighList *list) -{ - int i,j,n,itype,jtype,n_inner,n_middle,bitmask,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - } - - int inum = 0; - int which = 0; - int minchange = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - for (i = 0; i < nlocal; i++) { - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itype = type[i]; - 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; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n_inner); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_half_respa_nsq_newtoff.h b/src/npair_half_respa_nsq_newtoff.h deleted file mode 100644 index d13fb810da..0000000000 --- a/src/npair_half_respa_nsq_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/respa/nsq/newtoff, - NPairHalfRespaNsqNewtoff, - NP_HALF | NP_RESPA | NP_NSQ | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_NSQ_NEWTOFF_H -#define LMP_NPAIR_HALF_RESPA_NSQ_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaNsqNewtoff : public NPair { - public: - NPairHalfRespaNsqNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_respa_nsq_newton.cpp b/src/npair_half_respa_nsq_newton.cpp deleted file mode 100644 index 941ce41159..0000000000 --- a/src/npair_half_respa_nsq_newton.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 - Steve Plimpton, sjplimp@sandia.gov - - 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_half_respa_nsq_newton.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaNsqNewton::NPairHalfRespaNsqNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - N^2 / 2 search for neighbor pairs with full Newton's 3rd law - pair added to list if atoms i and j are both owned and i < j - if j is ghost only me or other proc adds pair - decision based on itag,jtag tests -------------------------------------------------------------------------- */ - -void NPairHalfRespaNsqNewton::build(NeighList *list) -{ - int i,j,n,itype,jtype,itag,jtag,n_inner,n_middle,bitmask; - int imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - } - - int inum = 0; - int which = 0; - int minchange = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - for (i = 0; i < nlocal; i++) { - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itag = tag[i]; - itype = type[i]; - 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; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 (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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n_inner); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_half_respa_nsq_newton.h b/src/npair_half_respa_nsq_newton.h deleted file mode 100644 index 9050ca0fde..0000000000 --- a/src/npair_half_respa_nsq_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/respa/nsq/newton, - NPairHalfRespaNsqNewton, - NP_HALF | NP_RESPA | NP_NSQ | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_NSQ_NEWTON_H -#define LMP_NPAIR_HALF_RESPA_NSQ_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaNsqNewton : public NPair { - public: - NPairHalfRespaNsqNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_bin_newtoff.cpp b/src/npair_half_size_bin_newtoff.cpp deleted file mode 100644 index de063c1eb9..0000000000 --- a/src/npair_half_size_bin_newtoff.cpp +++ /dev/null @@ -1,138 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_bin_newtoff.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeBinNewtoff::NPairHalfSizeBinNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and surrounding bins in non-Newton 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) -------------------------------------------------------------------------- */ - -void NPairHalfSizeBinNewtoff::build(NeighList *list) -{ - int i,j,jh,k,n,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,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; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - ibin = atom2bin[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in surrounding bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) continue; - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - } - - 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; -} diff --git a/src/npair_half_size_bin_newtoff.h b/src/npair_half_size_bin_newtoff.h deleted file mode 100644 index f1f9b2a34b..0000000000 --- a/src/npair_half_size_bin_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/bin/newtoff, - NPairHalfSizeBinNewtoff, - NP_HALF | NP_SIZE | NP_BIN | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_BIN_NEWTOFF_H -#define LMP_NPAIR_HALF_SIZE_BIN_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeBinNewtoff : public NPair { - public: - NPairHalfSizeBinNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_bin_newton.cpp b/src/npair_half_size_bin_newton.cpp deleted file mode 100644 index fbf5ce14d4..0000000000 --- a/src/npair_half_size_bin_newton.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_bin_newton.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeBinNewton::NPairHalfSizeBinNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - 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 -------------------------------------------------------------------------- */ - -void NPairHalfSizeBinNewton::build(NeighList *list) -{ - int i,j,jh,k,n,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,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; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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; - } - } - - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - } - - 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; -} diff --git a/src/npair_half_size_bin_newton.h b/src/npair_half_size_bin_newton.h deleted file mode 100644 index a592969c46..0000000000 --- a/src/npair_half_size_bin_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/bin/newton, - NPairHalfSizeBinNewton, - NP_HALF | NP_SIZE | NP_BIN | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_BIN_NEWTON_H -#define LMP_NPAIR_HALF_SIZE_BIN_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeBinNewton : public NPair { - public: - NPairHalfSizeBinNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_bin_newton_tri.cpp b/src/npair_half_size_bin_newton_tri.cpp deleted file mode 100644 index 15728a596a..0000000000 --- a/src/npair_half_size_bin_newton_tri.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_bin_newton_tri.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeBinNewtonTri::NPairHalfSizeBinNewtonTri(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeBinNewtonTri::build(NeighList *list) -{ - int i,j,jh,k,n,ibin,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,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; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins in stencil - // 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 - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - 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,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - } - - 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; -} diff --git a/src/npair_half_size_bin_newton_tri.h b/src/npair_half_size_bin_newton_tri.h deleted file mode 100644 index 50861d560e..0000000000 --- a/src/npair_half_size_bin_newton_tri.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/bin/newton/tri, - NPairHalfSizeBinNewtonTri, - NP_HALF | NP_SIZE | NP_BIN | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_BIN_NEWTON_TRI_H -#define LMP_NPAIR_HALF_SIZE_BIN_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeBinNewtonTri : public NPair { - public: - NPairHalfSizeBinNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp deleted file mode 100644 index ecb70cd6c4..0000000000 --- a/src/npair_half_size_multi_newtoff.cpp +++ /dev/null @@ -1,160 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - Copyright (2003) Sandia Corporation. Under the terms of Contract - DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains -es 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_half_size_multi_newtoff.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiNewtoff::NPairHalfSizeMultiNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with partial Newton's 3rd law - multi stencil is icollection-jcollection dependent - 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) -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiNewtoff::build(NeighList *list) -{ - int i,j,jh,k,n,itype,jtype,icollection,jcollection,ibin,jbin,ns; - int which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - int js; - - int *collection = neighbor->collection; - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - itype = type[i]; - icollection = collection[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - // use full stencil for all collection combinations - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - if (j <= i) 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) { - 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; - } - } - } - } - - 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; -} diff --git a/src/npair_half_size_multi_newtoff.h b/src/npair_half_size_multi_newtoff.h deleted file mode 100644 index b33634e5be..0000000000 --- a/src/npair_half_size_multi_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/multi/newtoff, - NPairHalfSizeMultiNewtoff, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_H -#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiNewtoff : public NPair { - public: - NPairHalfSizeMultiNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_multi_newton.cpp b/src/npair_half_size_multi_newton.cpp deleted file mode 100644 index ee100596bc..0000000000 --- a/src/npair_half_size_multi_newton.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_multi_newton.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiNewton::NPairHalfSizeMultiNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with full Newton's 3rd law - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in Newton stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiNewton::build(NeighList *list) -{ - int i,j,jh,k,n,itype,jtype,icollection,jcollection,ibin,jbin,ns,js; - int which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - - int *collection = neighbor->collection; - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - itype = type[i]; - icollection = collection[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // if same size: uses half stencil so check central bin - if (cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - - if (icollection == jcollection) js = bins[i]; - else js = binhead_multi[jcollection][jbin]; - - // if same collection, - // 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 different collections, - // if j is owned atom, store it if j > i - // if j is ghost, only store if j coords are "above and to the right" of i - - for (j = js; j >= 0; j = bins[j]) { - if ((icollection != jcollection) && (j < i)) continue; - - 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) { - 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; - } - } - } - - // for all collections, loop over all atoms in other bins in stencil, store every pair - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; 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; - radsum = radi + radius[j]; - cutdistsq = (radsum+skin) * (radsum+skin); - - if (rsq <= cutdistsq) { - 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; - } - } - } - } - - 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; -} diff --git a/src/npair_half_size_multi_newton.h b/src/npair_half_size_multi_newton.h deleted file mode 100644 index 32139136e6..0000000000 --- a/src/npair_half_size_multi_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/multi/newton, - NPairHalfSizeMultiNewton, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_H -#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiNewton : public NPair { - public: - NPairHalfSizeMultiNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_multi_newton_tri.cpp b/src/npair_half_size_multi_newton_tri.cpp deleted file mode 100644 index 9a170948b9..0000000000 --- a/src/npair_half_size_multi_newton_tri.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_multi_newton_tri.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiNewtonTri::NPairHalfSizeMultiNewtonTri(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with Newton's 3rd law for triclinic - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiNewtonTri::build(NeighList *list) -{ - int i,j,jh,k,n,itype,jtype,icollection,jcollection,ibin,jbin,ns,js; - int which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - - int *collection = neighbor->collection; - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - itype = type[i]; - icollection = collection[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in bins in stencil - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - // if half: 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 - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - - // if same size (same collection), use half stencil - if (cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - 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; - } - } - } - - 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) { - 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; - } - } - } - } - - 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; -} diff --git a/src/npair_half_size_multi_newton_tri.h b/src/npair_half_size_multi_newton_tri.h deleted file mode 100644 index 10e7a90d16..0000000000 --- a/src/npair_half_size_multi_newton_tri.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/multi/newton/tri, - NPairHalfSizeMultiNewtonTri, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_H -#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiNewtonTri : public NPair { - public: - NPairHalfSizeMultiNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_multi_old_newtoff.cpp b/src/npair_half_size_multi_old_newtoff.cpp deleted file mode 100644 index 4f8e4a8078..0000000000 --- a/src/npair_half_size_multi_old_newtoff.cpp +++ /dev/null @@ -1,149 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_multi_old_newtoff.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiOldNewtoff::NPairHalfSizeMultiOldNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and other bins in stencil - multi-type stencil is itype dependent and is distance checked - 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) -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiOldNewtoff::build(NeighList *list) -{ - int i,j,jh,k,n,itype,jtype,ibin,ns,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - 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]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // skip if i,j neighbor cutoff is less than bin distance - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - if (j <= i) continue; - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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) { - 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; - } - } - } - - 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; -} diff --git a/src/npair_half_size_multi_old_newtoff.h b/src/npair_half_size_multi_old_newtoff.h deleted file mode 100644 index c2ca814129..0000000000 --- a/src/npair_half_size_multi_old_newtoff.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/multi/old/newtoff, - NPairHalfSizeMultiOldNewtoff, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTOFF_H -#define LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiOldNewtoff : public NPair { - public: - NPairHalfSizeMultiOldNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED -*/ diff --git a/src/npair_half_size_multi_old_newton.cpp b/src/npair_half_size_multi_old_newton.cpp deleted file mode 100644 index 753c8c7d44..0000000000 --- a/src/npair_half_size_multi_old_newton.cpp +++ /dev/null @@ -1,187 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_multi_old_newton.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiOldNewton::NPairHalfSizeMultiOldNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with full Newton's 3rd law - each owned atom i checks its own bin and other bins in Newton stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiOldNewton::build(NeighList *list) -{ - int i,j,jh,k,n,itype,jtype,ibin,ns,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - 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]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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) { - 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; - } - } - - // loop over all atoms in other bins in stencil, store every pair - // skip if i,j neighbor cutoff is less than bin distance - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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) - j = j ^ 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++] = 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; - } - } - } - - 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; -} diff --git a/src/npair_half_size_multi_old_newton.h b/src/npair_half_size_multi_old_newton.h deleted file mode 100644 index 2322b5bc42..0000000000 --- a/src/npair_half_size_multi_old_newton.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/multi/old/newton, - NPairHalfSizeMultiOldNewton, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_H -#define LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiOldNewton : public NPair { - public: - NPairHalfSizeMultiOldNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED -*/ diff --git a/src/npair_half_size_multi_old_newton_tri.cpp b/src/npair_half_size_multi_old_newton_tri.cpp deleted file mode 100644 index ee7a11a36e..0000000000 --- a/src/npair_half_size_multi_old_newton_tri.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_multi_old_newton_tri.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiOldNewtonTri::NPairHalfSizeMultiOldNewtonTri(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiOldNewtonTri::build(NeighList *list) -{ - int i,j,jh,k,n,itype,jtype,ibin,ns,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - if (includegroup) nlocal = atom->nfirst; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - 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]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins, including self, in stencil - // skip if i,j neighbor cutoff is less than bin distance - // bins below self are excluded from stencil - // 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 - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - 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]; - 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) { - 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; - } - } - } - - 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; -} diff --git a/src/npair_half_size_multi_old_newton_tri.h b/src/npair_half_size_multi_old_newton_tri.h deleted file mode 100644 index 1658abc717..0000000000 --- a/src/npair_half_size_multi_old_newton_tri.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/multi/old/newton/tri, - NPairHalfSizeMultiOldNewtonTri, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_TRI_H -#define LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_TRI_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiOldNewtonTri : public NPair { - public: - NPairHalfSizeMultiOldNewtonTri(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED -*/ diff --git a/src/npair_half_size_nsq_newtoff.cpp b/src/npair_half_size_nsq_newtoff.cpp deleted file mode 100644 index 9ace347901..0000000000 --- a/src/npair_half_size_nsq_newtoff.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_nsq_newtoff.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "group.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeNsqNewtoff::NPairHalfSizeNsqNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - pair added to list if atoms i and j are both owned and i < j - pair added if j is ghost (also stored by proc owning j) -------------------------------------------------------------------------- */ - -void NPairHalfSizeNsqNewtoff::build(NeighList *list) -{ - int i,j,jh,n,bitmask,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,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; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) continue; - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - - 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; -} diff --git a/src/npair_half_size_nsq_newtoff.h b/src/npair_half_size_nsq_newtoff.h deleted file mode 100644 index b263a907ed..0000000000 --- a/src/npair_half_size_nsq_newtoff.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/nsq/newtoff, - NPairHalfSizeNsqNewtoff, - NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_NSQ_NEWTOFF_H -#define LMP_NPAIR_HALF_SIZE_NSQ_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeNsqNewtoff : public NPair { - public: - NPairHalfSizeNsqNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_half_size_nsq_newton.cpp b/src/npair_half_size_nsq_newton.cpp deleted file mode 100644 index 05409a0bab..0000000000 --- a/src/npair_half_size_nsq_newton.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_half_size_nsq_newton.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "group.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeNsqNewton::NPairHalfSizeNsqNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - N^2 / 2 search for neighbor pairs with full Newton's 3rd law - pair added to list if atoms i and j are both owned and i < j - if j is ghost only me or other proc adds pair - decision based on itag,jtag tests -------------------------------------------------------------------------- */ - -void NPairHalfSizeNsqNewton::build(NeighList *list) -{ - int i,j,jh,n,itag,jtag,bitmask,which,imol,iatom,moltemplate; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutsq; - int *neighptr; - - double **x = atom->x; - double *radius = atom->radius; - tagint *tag = atom->tag; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int nlocal = atom->nlocal; - int nall = nlocal + atom->nghost; - if (includegroup) { - nlocal = atom->nfirst; - bitmask = group->bitmask[includegroup]; - } - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - if (molecular == Atom::TEMPLATE) moltemplate = 1; - else moltemplate = 0; - - int history = list->history; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int mask_history = 1 << HISTBITS; - - int inum = 0; - ipage->reset(); - - for (i = 0; i < nlocal; i++) { - n = 0; - neighptr = ipage->vget(); - - itag = tag[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 (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; - } - } - } - - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - - 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; -} diff --git a/src/npair_half_size_nsq_newton.h b/src/npair_half_size_nsq_newton.h deleted file mode 100644 index 17735ccc45..0000000000 --- a/src/npair_half_size_nsq_newton.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(half/size/nsq/newton, - NPairHalfSizeNsqNewton, - NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTON | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_NSQ_NEWTON_H -#define LMP_NPAIR_HALF_SIZE_NSQ_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeNsqNewton : public NPair { - public: - NPairHalfSizeNsqNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_halffull_newtoff.cpp b/src/npair_halffull_newtoff.cpp deleted file mode 100644 index 475325c2f0..0000000000 --- a/src/npair_halffull_newtoff.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_halffull_newtoff.h" - -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalffullNewtoff::NPairHalffullNewtoff(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build half list from full list - 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) - works if full list is a skip list - works for owned (non-ghost) list, also for ghost list - if ghost, also store neighbors of ghost atoms & set inum,gnum correctly -------------------------------------------------------------------------- */ - -void NPairHalffullNewtoff::build(NeighList *list) -{ - int i,j,ii,jj,n,jnum,joriginal; - int *neighptr,*jlist; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_full = list->listfull->ilist; - int *numneigh_full = list->listfull->numneigh; - int **firstneigh_full = list->listfull->firstneigh; - int inum_full = list->listfull->inum; - if (list->ghost) inum_full += list->listfull->gnum; - - int inum = 0; - ipage->reset(); - - // loop over atoms in full list - - for (ii = 0; ii < inum_full; ii++) { - n = 0; - neighptr = ipage->vget(); - - // loop over parent full list - - i = ilist_full[ii]; - jlist = firstneigh_full[i]; - jnum = numneigh_full[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (j > i) neighptr[n++] = joriginal; - } - - 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 (list->ghost) list->gnum = list->listfull->gnum; -} diff --git a/src/npair_halffull_newtoff.h b/src/npair_halffull_newtoff.h deleted file mode 100644 index 0a00267449..0000000000 --- a/src/npair_halffull_newtoff.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(halffull/newtoff, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI); - -NPairStyle(halffull/newtoff/skip, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP); - -NPairStyle(halffull/newtoff/ghost, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI | NP_GHOST); - -NPairStyle(halffull/newtoff/skip/ghost, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTOFF_H -#define LMP_NPAIR_HALFFULL_NEWTOFF_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalffullNewtoff : public NPair { - public: - NPairHalffullNewtoff(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_halffull_newton.cpp b/src/npair_halffull_newton.cpp deleted file mode 100644 index d9ba02d5b0..0000000000 --- a/src/npair_halffull_newton.cpp +++ /dev/null @@ -1,97 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_halffull_newton.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalffullNewton::NPairHalffullNewton(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build half list from full list - pair stored once if i,j are both owned and i < j - if j is ghost, only store if j coords are "above and to the right" of i - works if full list is a skip list -------------------------------------------------------------------------- */ - -void NPairHalffullNewton::build(NeighList *list) -{ - int i,j,ii,jj,n,jnum,joriginal; - int *neighptr,*jlist; - double xtmp,ytmp,ztmp; - - double **x = atom->x; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_full = list->listfull->ilist; - int *numneigh_full = list->listfull->numneigh; - int **firstneigh_full = list->listfull->firstneigh; - int inum_full = list->listfull->inum; - - int inum = 0; - ipage->reset(); - - // loop over parent full list - - for (ii = 0; ii < inum_full; ii++) { - n = 0; - neighptr = ipage->vget(); - - i = ilist_full[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - // loop over full neighbor list - - jlist = firstneigh_full[i]; - jnum = numneigh_full[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (j < nlocal) { - if (i > j) continue; - } else { - 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; - } - } - neighptr[n++] = joriginal; - } - - 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; -} diff --git a/src/npair_halffull_newton.h b/src/npair_halffull_newton.h deleted file mode 100644 index 95cc09ec0b..0000000000 --- a/src/npair_halffull_newton.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(halffull/newton, - NPairHalffullNewton, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_ORTHO | NP_TRI); - -NPairStyle(halffull/newton/skip, - NPairHalffullNewton, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_ORTHO | NP_TRI | NP_SKIP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTON_H -#define LMP_NPAIR_HALFFULL_NEWTON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalffullNewton : public NPair { - public: - NPairHalffullNewton(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_skip.cpp b/src/npair_skip.cpp deleted file mode 100644 index 4ef0573dbb..0000000000 --- a/src/npair_skip.cpp +++ /dev/null @@ -1,102 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_skip.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkip::NPairSkip(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - works for half and full lists - works for owned (non-ghost) list, also for ghost list - iskip and ijskip flag which atom types and type pairs to skip - if ghost, also store neighbors of ghost atoms & set inum,gnum correctly -------------------------------------------------------------------------- */ - -void NPairSkip::build(NeighList *list) -{ - int i,j,ii,jj,n,itype,jnum,joriginal; - int *neighptr,*jlist; - - int *type = atom->type; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int num_skip = list->listskip->inum; - if (list->ghost) num_skip += list->listskip->gnum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < num_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - neighptr[n++] = joriginal; - } - - 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 (list->ghost) { - int num = 0; - for (i = 0; i < inum; i++) - if (ilist[i] < nlocal) num++; - else break; - list->inum = num; - list->gnum = inum - num; - } -} diff --git a/src/npair_skip.h b/src/npair_skip.h deleted file mode 100644 index aa2b14e12a..0000000000 --- a/src/npair_skip.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(skip, - NPairSkip, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); - -NPairStyle(skip/ghost, - NPairSkip, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_H -#define LMP_NPAIR_SKIP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkip : public NPair { - public: - NPairSkip(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_skip_respa.cpp b/src/npair_skip_respa.cpp deleted file mode 100644 index 373fe3f8db..0000000000 --- a/src/npair_skip_respa.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_skip_respa.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipRespa::NPairSkipRespa(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip - this is for respa lists, copy the inner/middle values from parent -------------------------------------------------------------------------- */ - -void NPairSkipRespa::build(NeighList *list) -{ - int i,j,ii,jj,n,itype,jnum,joriginal,n_inner,n_middle; - int *neighptr,*jlist,*neighptr_inner,*neighptr_middle; - - int *type = atom->type; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - int *numneigh_inner_skip = list->listskip->numneigh_inner; - int **firstneigh_inner_skip = list->listskip->firstneigh_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int *numneigh_middle_skip,**firstneigh_middle_skip; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - numneigh_middle_skip = list->listskip->numneigh_middle; - firstneigh_middle_skip = list->listskip->firstneigh_middle; - } - - int inum = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - // loop over parent outer rRESPA list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - neighptr[n++] = joriginal; - } - - // loop over parent inner rRESPA list - - jlist = firstneigh_inner_skip[i]; - jnum = numneigh_inner_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - neighptr_inner[n_inner++] = joriginal; - } - - // loop over parent middle rRESPA list - - if (respamiddle) { - jlist = firstneigh_middle_skip[i]; - jnum = numneigh_middle_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - neighptr_middle[n_middle++] = joriginal; - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_skip_respa.h b/src/npair_skip_respa.h deleted file mode 100644 index b0938287b5..0000000000 --- a/src/npair_skip_respa.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(skip/half/respa, - NPairSkipRespa, - NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_RESPA_H -#define LMP_NPAIR_SKIP_RESPA_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipRespa : public NPair { - public: - NPairSkipRespa(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_skip_size.cpp b/src/npair_skip_size.cpp deleted file mode 100644 index f4fe760e08..0000000000 --- a/src/npair_skip_size.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_skip_size.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipSize::NPairSkipSize(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip -------------------------------------------------------------------------- */ - -void NPairSkipSize::build(NeighList *list) -{ - int i,j,ii,jj,n,itype,jnum,joriginal; - int *neighptr,*jlist; - - int *type = atom->type; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip size list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - neighptr[n++] = joriginal; - } - - 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; -} diff --git a/src/npair_skip_size.h b/src/npair_skip_size.h deleted file mode 100644 index df8d479185..0000000000 --- a/src/npair_skip_size.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(skip/half/size, - NPairSkipSize, - NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_SIZE_H -#define LMP_NPAIR_SKIP_SIZE_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipSize : public NPair { - public: - NPairSkipSize(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_skip_size_off2on.cpp b/src/npair_skip_size_off2on.cpp deleted file mode 100644 index e48ca345ff..0000000000 --- a/src/npair_skip_size_off2on.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_skip_size_off2on.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipSizeOff2on::NPairSkipSizeOff2on(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip - parent non-skip list used newton off, this skip list is newton on -------------------------------------------------------------------------- */ - -void NPairSkipSizeOff2on::build(NeighList *list) -{ - int i,j,ii,jj,n,itype,jnum,joriginal; - tagint itag,jtag; - int *neighptr,*jlist; - - tagint *tag = atom->tag; - int *type = atom->type; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - itag = tag[i]; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip size list and optionally its history info - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - - // only keep I,J when J = ghost if Itag < Jtag - - jtag = tag[j]; - if (j >= nlocal && jtag < itag) continue; - - neighptr[n++] = joriginal; - } - - 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; -} diff --git a/src/npair_skip_size_off2on.h b/src/npair_skip_size_off2on.h deleted file mode 100644 index 39aee76b09..0000000000 --- a/src/npair_skip_size_off2on.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(skip/size/off2on, - NPairSkipSizeOff2on, - NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_SIZE_OFF2ON_H -#define LMP_NPAIR_SKIP_SIZE_OFF2ON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipSizeOff2on : public NPair { - public: - NPairSkipSizeOff2on(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_skip_size_off2on_oneside.cpp b/src/npair_skip_size_off2on_oneside.cpp deleted file mode 100644 index 1e4b4ac78d..0000000000 --- a/src/npair_skip_size_off2on_oneside.cpp +++ /dev/null @@ -1,163 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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_skip_size_off2on_oneside.h" - -#include "atom.h" -#include "domain.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipSizeOff2onOneside::NPairSkipSizeOff2onOneside(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip - parent non-skip list used newton off and was not onesided, - this skip list is newton on and onesided -------------------------------------------------------------------------- */ - -void NPairSkipSizeOff2onOneside::build(NeighList *list) -{ - int i,j,ii,jj,n,itype,jnum,joriginal,flip,tmp; - int *surf,*jlist; - - int *type = atom->type; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - if (domain->dimension == 2) surf = atom->line; - else surf = atom->tri; - - int inum = 0; - ipage->reset(); - - // two loops over parent list required, one to count, one to store - // because onesided constraint means pair I,J may be stored with I or J - // so don't know in advance how much space to alloc for each atom's neighs - - // first loop over atoms in other list to count neighbors - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (i = 0; i < nlocal; i++) numneigh[i] = 0; - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - n = 0; - - // loop over parent non-skip size list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - - // flip I,J if necessary to satisfy onesided constraint - // do not keep if I is now ghost - - if (surf[i] >= 0) { - if (j >= nlocal) continue; - tmp = i; - i = j; - j = tmp; - flip = 1; - } else flip = 0; - - numneigh[i]++; - if (flip) i = j; - } - } - - // allocate all per-atom neigh list chunks - - for (i = 0; i < nlocal; i++) { - if (numneigh[i] == 0) continue; - n = numneigh[i]; - firstneigh[i] = ipage->get(n); - if (ipage->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - // second loop over atoms in other list to store neighbors - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (i = 0; i < nlocal; i++) numneigh[i] = 0; - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - // loop over parent non-skip size list and optionally its history info - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - - // flip I,J if necessary to satisfy onesided constraint - // do not keep if I is now ghost - - if (surf[i] >= 0) { - if (j >= nlocal) continue; - tmp = i; - i = j; - j = tmp; - flip = 1; - } else flip = 0; - - // store j in neigh list, not joriginal, like other neigh methods - // OK, b/c there is no special list flagging for surfs - - firstneigh[i][numneigh[i]] = j; - numneigh[i]++; - if (flip) i = j; - } - - // only add atom I to ilist if it has neighbors - - if (numneigh[i]) ilist[inum++] = i; - } - - list->inum = inum; -} diff --git a/src/npair_skip_size_off2on_oneside.h b/src/npair_skip_size_off2on_oneside.h deleted file mode 100644 index 3f1cd6ef34..0000000000 --- a/src/npair_skip_size_off2on_oneside.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 -NPairStyle(skip/size/off2on/oneside, - NPairSkipSizeOff2onOneside, - NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_SIZE_OFF2ON_ONESIDE_H -#define LMP_NPAIR_SKIP_SIZE_OFF2ON_ONESIDE_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipSizeOff2onOneside : public NPair { - public: - NPairSkipSizeOff2onOneside(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/nstencil_half_bin_3d_tri.cpp b/src/nstencil_bin.cpp similarity index 51% rename from src/nstencil_half_bin_3d_tri.cpp rename to src/nstencil_bin.cpp index 8d1920ae8c..c5026cb338 100644 --- a/src/nstencil_half_bin_3d_tri.cpp +++ b/src/nstencil_bin.cpp @@ -12,28 +12,55 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "nstencil_half_bin_3d_tri.h" +#include "nstencil_bin.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NStencilHalfBin3dTri::NStencilHalfBin3dTri(LAMMPS *lmp) : - NStencil(lmp) {} +template +NStencilBin::NStencilBin(LAMMPS *lmp) : NStencil(lmp) {} /* ---------------------------------------------------------------------- create stencil based on bin geometry and cutoff ------------------------------------------------------------------------- */ -void NStencilHalfBin3dTri::create() +template +void NStencilBin::create() { int i,j,k; + bool bin_include; + + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF && (!DIM_3D)) sy_min = 0; + if (HALF && DIM_3D) sz_min = 0; nstencil = 0; - for (k = 0; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) + for (k = -sz_min; k <= sz; k++) { + for (j = -sy_min; j <= sy; j++) { + for (i = -sx; i <= sx; i++) { + + // Half and ortho stencils only include own and "upper right" bins + if (HALF && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i >= 0))) continue; + if (HALF && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i >= 0))) continue; + if (bin_distance(i,j,k) < cutneighmaxsq) stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i; + } + } + } +} + +namespace LAMMPS_NS { +template class NStencilBin<0,0,0>; +template class NStencilBin<0,1,0>; +template class NStencilBin<1,0,0>; +template class NStencilBin<1,0,1>; +template class NStencilBin<1,1,0>; +template class NStencilBin<1,1,1>; } diff --git a/src/nstencil_bin.h b/src/nstencil_bin.h new file mode 100644 index 0000000000..a10150fcda --- /dev/null +++ b/src/nstencil_bin.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NSTENCIL_CLASS +// clang-format off +typedef NStencilBin<0, 0, 0> NStencilFullBin2d; +NStencilStyle(full/bin/2d, + NStencilFullBin2d, + NS_FULL | NS_BIN | NS_2D | NS_ORTHO | NS_TRI); + +typedef NStencilBin<0, 1, 0> NStencilFullBin3d; +NStencilStyle(full/bin/3d, + NStencilFullBin3d, + NS_FULL | NS_BIN | NS_3D | NS_ORTHO | NS_TRI); + +typedef NStencilBin<1, 0, 0> NStencilHalfBin2d; +NStencilStyle(half/bin/2d, + NStencilHalfBin2d, + NS_HALF | NS_BIN | NS_2D | NS_ORTHO); + +typedef NStencilBin<1, 0, 1> NStencilHalfBin2dTri; +NStencilStyle(half/bin/2d/tri, + NStencilHalfBin2dTri, + NS_HALF | NS_BIN | NS_2D | NS_TRI); + +typedef NStencilBin<1, 1, 0> NStencilHalfBin3d; +NStencilStyle(half/bin/3d, + NStencilHalfBin3d, + NS_HALF | NS_BIN | NS_3D | NS_ORTHO); + +typedef NStencilBin<1, 1, 1> NStencilHalfBin3dTri; +NStencilStyle(half/bin/3d/tri, + NStencilHalfBin3dTri, + NS_HALF | NS_BIN | NS_3D | NS_TRI); +// clang-format on +#else + +#ifndef LMP_NSTENCIL_BIN_H +#define LMP_NSTENCIL_BIN_H + +#include "nstencil.h" + +namespace LAMMPS_NS { + +template +class NStencilBin : public NStencil { + public: + NStencilBin(class LAMMPS *); + void create() override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/nstencil_full_bin_2d.cpp b/src/nstencil_full_bin_2d.cpp deleted file mode 100644 index ba4ca97ed6..0000000000 --- a/src/nstencil_full_bin_2d.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_bin_2d.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullBin2d::NStencilFullBin2d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullBin2d::create() -{ - int i,j; - - nstencil = 0; - - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance(i,j,0) < cutneighmaxsq) - stencil[nstencil++] = j*mbinx + i; -} diff --git a/src/nstencil_full_bin_2d.h b/src/nstencil_full_bin_2d.h deleted file mode 100644 index f4c630d3c2..0000000000 --- a/src/nstencil_full_bin_2d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/bin/2d, - NStencilFullBin2d, - NS_FULL | NS_BIN | NS_2D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_BIN_2D_H -#define LMP_NSTENCIL_FULL_BIN_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullBin2d : public NStencil { - public: - NStencilFullBin2d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_bin_3d.cpp b/src/nstencil_full_bin_3d.cpp deleted file mode 100644 index 8aa593eb0b..0000000000 --- a/src/nstencil_full_bin_3d.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_bin_3d.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullBin3d::NStencilFullBin3d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullBin3d::create() -{ - int i,j,k; - - nstencil = 0; - - for (k = -sz; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance(i,j,k) < cutneighmaxsq) - stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i; -} diff --git a/src/nstencil_full_bin_3d.h b/src/nstencil_full_bin_3d.h deleted file mode 100644 index 463dda1f62..0000000000 --- a/src/nstencil_full_bin_3d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/bin/3d, - NStencilFullBin3d, - NS_FULL | NS_BIN | NS_3D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_BIN_3D_H -#define LMP_NSTENCIL_FULL_BIN_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullBin3d : public NStencil { - public: - NStencilFullBin3d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_ghost_bin_2d.cpp b/src/nstencil_full_ghost_bin_2d.cpp deleted file mode 100644 index b5a6bac56c..0000000000 --- a/src/nstencil_full_ghost_bin_2d.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_ghost_bin_2d.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullGhostBin2d::NStencilFullGhostBin2d(LAMMPS *lmp) : NStencil(lmp) -{ - xyzflag = 1; -} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullGhostBin2d::create() -{ - int i,j; - - nstencil = 0; - - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance(i,j,0) < cutneighmaxsq) { - stencilxyz[nstencil][0] = i; - stencilxyz[nstencil][1] = j; - stencilxyz[nstencil][2] = 0; - stencil[nstencil++] = j*mbinx + i; - } -} diff --git a/src/nstencil_full_ghost_bin_2d.h b/src/nstencil_full_ghost_bin_2d.h deleted file mode 100644 index 6326aae5ea..0000000000 --- a/src/nstencil_full_ghost_bin_2d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/ghost/bin/2d, - NStencilFullGhostBin2d, - NS_FULL | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_GHOST_BIN_2D_H -#define LMP_NSTENCIL_FULL_GHOST_BIN_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullGhostBin2d : public NStencil { - public: - NStencilFullGhostBin2d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_ghost_bin_3d.cpp b/src/nstencil_full_ghost_bin_3d.cpp deleted file mode 100644 index 2023495c34..0000000000 --- a/src/nstencil_full_ghost_bin_3d.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_ghost_bin_3d.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullGhostBin3d::NStencilFullGhostBin3d(LAMMPS *lmp) : NStencil(lmp) -{ - xyzflag = 1; -} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullGhostBin3d::create() -{ - int i,j,k; - - nstencil = 0; - - for (k = -sz; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance(i,j,k) < cutneighmaxsq) { - stencilxyz[nstencil][0] = i; - stencilxyz[nstencil][1] = j; - stencilxyz[nstencil][2] = k; - stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i; - } -} diff --git a/src/nstencil_full_ghost_bin_3d.h b/src/nstencil_full_ghost_bin_3d.h deleted file mode 100644 index eed98279aa..0000000000 --- a/src/nstencil_full_ghost_bin_3d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/ghost/bin/3d, - NStencilFullGhostBin3d, - NS_FULL | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_GHOST_BIN_3D_H -#define LMP_NSTENCIL_FULL_GHOST_BIN_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullGhostBin3d : public NStencil { - public: - NStencilFullGhostBin3d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_multi_2d.cpp b/src/nstencil_full_multi_2d.cpp deleted file mode 100644 index 52ae88d09e..0000000000 --- a/src/nstencil_full_multi_2d.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_multi_2d.h" - -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullMulti2d::NStencilFullMulti2d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- */ - -void NStencilFullMulti2d::set_stencil_properties() -{ - int n = ncollections; - int i, j; - - // Always look up neighbor using full stencil and neighbor's bin - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - flag_half_multi[i][j] = false; - flag_skip_multi[i][j] = false; - bin_collection_multi[i][j] = j; - } - } -} - -/* ---------------------------------------------------------------------- - create stencils based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullMulti2d::create() -{ - int icollection, jcollection, bin_collection, i, j, ns; - int n = ncollections; - double cutsq; - - - for (icollection = 0; icollection < n; icollection++) { - for (jcollection = 0; jcollection < n; jcollection++) { - if (flag_skip_multi[icollection][jcollection]) { - nstencil_multi[icollection][jcollection] = 0; - continue; - } - - ns = 0; - - sx = stencil_sx_multi[icollection][jcollection]; - sy = stencil_sy_multi[icollection][jcollection]; - - mbinx = stencil_mbinx_multi[icollection][jcollection]; - mbiny = stencil_mbiny_multi[icollection][jcollection]; - - bin_collection = bin_collection_multi[icollection][jcollection]; - - cutsq = cutcollectionsq[icollection][jcollection]; - - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,0,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = j*mbinx + i; - - nstencil_multi[icollection][jcollection] = ns; - } - } -} diff --git a/src/nstencil_full_multi_2d.h b/src/nstencil_full_multi_2d.h deleted file mode 100644 index 2ef43f1999..0000000000 --- a/src/nstencil_full_multi_2d.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/multi/2d, - NStencilFullMulti2d, NS_FULL | NS_MULTI | NS_2D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_MULTI_2D_H -#define LMP_NSTENCIL_FULL_MULTI_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullMulti2d : public NStencil { - public: - NStencilFullMulti2d(class LAMMPS *); - void create() override; - - protected: - void set_stencil_properties() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_multi_3d.cpp b/src/nstencil_full_multi_3d.cpp deleted file mode 100644 index d48cf0c8d7..0000000000 --- a/src/nstencil_full_multi_3d.cpp +++ /dev/null @@ -1,86 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_multi_3d.h" - -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullMulti3d::NStencilFullMulti3d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- */ - -void NStencilFullMulti3d::set_stencil_properties() -{ - int n = ncollections; - int i, j; - - // Always look up neighbor using full stencil and neighbor's bin - // Stencil cutoff set by i-j cutoff - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - flag_half_multi[i][j] = true; - flag_skip_multi[i][j] = false; - bin_collection_multi[i][j] = j; - } - } -} - -/* ---------------------------------------------------------------------- - create stencils based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullMulti3d::create() -{ - int icollection, jcollection, bin_collection, i, j, k, ns; - int n = ncollections; - double cutsq; - - - for (icollection = 0; icollection < n; icollection++) { - for (jcollection = 0; jcollection < n; jcollection++) { - if (flag_skip_multi[icollection][jcollection]) { - nstencil_multi[icollection][jcollection] = 0; - continue; - } - - ns = 0; - - sx = stencil_sx_multi[icollection][jcollection]; - sy = stencil_sy_multi[icollection][jcollection]; - sz = stencil_sz_multi[icollection][jcollection]; - - mbinx = stencil_mbinx_multi[icollection][jcollection]; - mbiny = stencil_mbiny_multi[icollection][jcollection]; - mbinz = stencil_mbinz_multi[icollection][jcollection]; - - bin_collection = bin_collection_multi[icollection][jcollection]; - - cutsq = cutcollectionsq[icollection][jcollection]; - - for (k = -sz; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = - k*mbiny*mbinx + j*mbinx + i; - - nstencil_multi[icollection][jcollection] = ns; - } - } -} diff --git a/src/nstencil_full_multi_3d.h b/src/nstencil_full_multi_3d.h deleted file mode 100644 index 894c688a9f..0000000000 --- a/src/nstencil_full_multi_3d.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/multi/3d, - NStencilFullMulti3d, NS_FULL | NS_MULTI | NS_3D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_MULTI_3D_H -#define LMP_NSTENCIL_FULL_MULTI_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullMulti3d : public NStencil { - public: - NStencilFullMulti3d(class LAMMPS *); - void create() override; - - protected: - void set_stencil_properties() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_multi_old_2d.cpp b/src/nstencil_full_multi_old_2d.cpp deleted file mode 100644 index d653e1080e..0000000000 --- a/src/nstencil_full_multi_old_2d.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_multi_old_2d.h" -#include "atom.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullMultiOld2d::NStencilFullMultiOld2d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullMultiOld2d::create() -{ - int i,j,n; - double rsq,typesq; - int *s; - double *distsq; - - int ntypes = atom->ntypes; - for (int itype = 1; itype <= ntypes; itype++) { - typesq = cuttypesq[itype]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - n = 0; - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) { - rsq = bin_distance(i,j,0); - if (rsq < typesq) { - distsq[n] = rsq; - s[n++] = j*mbinx + i; - } - } - nstencil_multi_old[itype] = n; - } -} diff --git a/src/nstencil_full_multi_old_2d.h b/src/nstencil_full_multi_old_2d.h deleted file mode 100644 index 9b56be0793..0000000000 --- a/src/nstencil_full_multi_old_2d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/multi/old/2d, - NStencilFullMultiOld2d, - NS_FULL | NS_MULTI_OLD | NS_2D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_MULTI_OLD_2D_H -#define LMP_NSTENCIL_FULL_MULTI_OLD_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullMultiOld2d : public NStencil { - public: - NStencilFullMultiOld2d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_full_multi_old_3d.cpp b/src/nstencil_full_multi_old_3d.cpp deleted file mode 100644 index 849ee5a9f9..0000000000 --- a/src/nstencil_full_multi_old_3d.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_full_multi_old_3d.h" -#include "atom.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilFullMultiOld3d::NStencilFullMultiOld3d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilFullMultiOld3d::create() -{ - int i,j,k,n; - double rsq,typesq; - int *s; - double *distsq; - - int ntypes = atom->ntypes; - for (int itype = 1; itype <= ntypes; itype++) { - typesq = cuttypesq[itype]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - n = 0; - for (k = -sz; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) { - rsq = bin_distance(i,j,k); - if (rsq < typesq) { - distsq[n] = rsq; - s[n++] = k*mbiny*mbinx + j*mbinx + i; - } - } - nstencil_multi_old[itype] = n; - } -} diff --git a/src/nstencil_full_multi_old_3d.h b/src/nstencil_full_multi_old_3d.h deleted file mode 100644 index d19da9c95f..0000000000 --- a/src/nstencil_full_multi_old_3d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(full/multi/old/3d, - NStencilFullMultiOld3d, - NS_FULL | NS_MULTI_OLD | NS_3D | NS_ORTHO | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_FULL_MULTI_OLD_3D_H -#define LMP_NSTENCIL_FULL_MULTI_OLD_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilFullMultiOld3d : public NStencil { - public: - NStencilFullMultiOld3d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_bin_2d.cpp b/src/nstencil_half_bin_2d.cpp deleted file mode 100644 index 004d6a8016..0000000000 --- a/src/nstencil_half_bin_2d.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_bin_2d.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfBin2d::NStencilHalfBin2d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfBin2d::create() -{ - int i,j; - - nstencil = 0; - - for (j = 0; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (j > 0 || (j == 0 && i > 0)) - if (bin_distance(i,j,0) < cutneighmaxsq) - stencil[nstencil++] = j*mbinx + i; -} diff --git a/src/nstencil_half_bin_2d.h b/src/nstencil_half_bin_2d.h deleted file mode 100644 index f11138dd54..0000000000 --- a/src/nstencil_half_bin_2d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/bin/2d, - NStencilHalfBin2d, - NS_HALF | NS_BIN | NS_2D | NS_ORTHO); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_BIN_2D_H -#define LMP_NSTENCIL_HALF_BIN_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfBin2d : public NStencil { - public: - NStencilHalfBin2d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_bin_2d_tri.cpp b/src/nstencil_half_bin_2d_tri.cpp deleted file mode 100644 index 9f5ace1ed1..0000000000 --- a/src/nstencil_half_bin_2d_tri.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_bin_2d_tri.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfBin2dTri::NStencilHalfBin2dTri(LAMMPS *lmp) : - NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfBin2dTri::create() -{ - int i,j; - - nstencil = 0; - - for (j = 0; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance(i,j,0) < cutneighmaxsq) - stencil[nstencil++] = j*mbinx + i; -} diff --git a/src/nstencil_half_bin_2d_tri.h b/src/nstencil_half_bin_2d_tri.h deleted file mode 100644 index 5088bc2edc..0000000000 --- a/src/nstencil_half_bin_2d_tri.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/bin/2d/tri, - NStencilHalfBin2dTri, - NS_HALF | NS_BIN | NS_2D | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_BIN_2D_TRI_H -#define LMP_NSTENCIL_HALF_BIN_2D_TRI_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfBin2dTri : public NStencil { - public: - NStencilHalfBin2dTri(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_bin_3d.cpp b/src/nstencil_half_bin_3d.cpp deleted file mode 100644 index a8cacdb601..0000000000 --- a/src/nstencil_half_bin_3d.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_bin_3d.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfBin3d::NStencilHalfBin3d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfBin3d::create() -{ - int i,j,k; - - nstencil = 0; - - for (k = 0; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (k > 0 || j > 0 || (j == 0 && i > 0)) - if (bin_distance(i,j,k) < cutneighmaxsq) - stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i; -} diff --git a/src/nstencil_half_bin_3d.h b/src/nstencil_half_bin_3d.h deleted file mode 100644 index f235d6688b..0000000000 --- a/src/nstencil_half_bin_3d.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/bin/3d, - NStencilHalfBin3d, - NS_HALF | NS_BIN | NS_3D | NS_ORTHO); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_BIN_3D_H -#define LMP_NSTENCIL_HALF_BIN_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfBin3d : public NStencil { - public: - NStencilHalfBin3d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_bin_3d_tri.h b/src/nstencil_half_bin_3d_tri.h deleted file mode 100644 index fa2975ef0a..0000000000 --- a/src/nstencil_half_bin_3d_tri.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/bin/3d/tri, - NStencilHalfBin3dTri, - NS_HALF | NS_BIN | NS_3D | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_BIN_3D_TRI_H -#define LMP_NSTENCIL_HALF_BIN_3D_TRI_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfBin3dTri : public NStencil { - public: - NStencilHalfBin3dTri(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_2d.cpp b/src/nstencil_half_multi_2d.cpp deleted file mode 100644 index 81713e183d..0000000000 --- a/src/nstencil_half_multi_2d.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_2d.h" - -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMulti2d::NStencilHalfMulti2d(LAMMPS *lmp) : - NStencil(lmp) {} - -/* ---------------------------------------------------------------------- */ - -void NStencilHalfMulti2d::set_stencil_properties() -{ - int n = ncollections; - int i, j; - - // Cross collections: use full stencil, looking one way through hierarchy - // smaller -> larger => use full stencil in larger bin - // larger -> smaller => no nstencil required - // If cut offs are same, use half stencil - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - - flag_skip_multi[i][j] = false; - - if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = true; - bin_collection_multi[i][j] = i; - } else { - flag_half_multi[i][j] = false; - bin_collection_multi[i][j] = j; - } - } - } -} - -/* ---------------------------------------------------------------------- - create stencils based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMulti2d::create() -{ - int icollection, jcollection, bin_collection, i, j, ns; - int n = ncollections; - double cutsq; - - - for (icollection = 0; icollection < n; icollection++) { - for (jcollection = 0; jcollection < n; jcollection++) { - if (flag_skip_multi[icollection][jcollection]) { - nstencil_multi[icollection][jcollection] = 0; - continue; - } - - ns = 0; - - sx = stencil_sx_multi[icollection][jcollection]; - sy = stencil_sy_multi[icollection][jcollection]; - - mbinx = stencil_mbinx_multi[icollection][jcollection]; - mbiny = stencil_mbiny_multi[icollection][jcollection]; - - bin_collection = bin_collection_multi[icollection][jcollection]; - - cutsq = cutcollectionsq[icollection][jcollection]; - - if (flag_half_multi[icollection][jcollection]) { - for (j = 0; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (j > 0 || (j == 0 && i > 0)) { - if (bin_distance_multi(i,j,0,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = j*mbinx + i; - } - } else { - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,0,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = j*mbinx + i; - } - - nstencil_multi[icollection][jcollection] = ns; - } - } -} - diff --git a/src/nstencil_half_multi_2d.h b/src/nstencil_half_multi_2d.h deleted file mode 100644 index 043d160b9e..0000000000 --- a/src/nstencil_half_multi_2d.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/2d, - NStencilHalfMulti2d, NS_HALF | NS_MULTI | NS_2D | NS_ORTHO); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_2D_H -#define LMP_NSTENCIL_HALF_MULTI_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMulti2d : public NStencil { - public: - NStencilHalfMulti2d(class LAMMPS *); - void create() override; - - protected: - void set_stencil_properties() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_2d_tri.cpp b/src/nstencil_half_multi_2d_tri.cpp deleted file mode 100644 index d53c503fad..0000000000 --- a/src/nstencil_half_multi_2d_tri.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_2d_tri.h" - -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMulti2dTri::NStencilHalfMulti2dTri(LAMMPS *lmp) : - NStencil(lmp) {} - -/* ---------------------------------------------------------------------- */ - -void NStencilHalfMulti2dTri::set_stencil_properties() -{ - int n = ncollections; - int i, j; - - // Cross collections: use full stencil, looking one way through hierarchy - // smaller -> larger => use full stencil in larger bin - // larger -> smaller => no nstencil required - // If cut offs are same, use half stencil - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - - flag_skip_multi[i][j] = false; - - if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = true; - bin_collection_multi[i][j] = i; - } else { - flag_half_multi[i][j] = false; - bin_collection_multi[i][j] = j; - } - } - } -} - -/* ---------------------------------------------------------------------- - create stencils based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMulti2dTri::create() -{ - int icollection, jcollection, bin_collection, i, j, ns; - int n = ncollections; - double cutsq; - - - for (icollection = 0; icollection < n; icollection++) { - for (jcollection = 0; jcollection < n; jcollection++) { - if (flag_skip_multi[icollection][jcollection]) { - nstencil_multi[icollection][jcollection] = 0; - continue; - } - - ns = 0; - - sx = stencil_sx_multi[icollection][jcollection]; - sy = stencil_sy_multi[icollection][jcollection]; - - mbinx = stencil_mbinx_multi[icollection][jcollection]; - mbiny = stencil_mbiny_multi[icollection][jcollection]; - - bin_collection = bin_collection_multi[icollection][jcollection]; - - cutsq = cutcollectionsq[icollection][jcollection]; - - if (flag_half_multi[icollection][jcollection]) { - for (j = 0; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,0,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = j*mbinx + i; - } else { - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,0,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = j*mbinx + i; - } - - nstencil_multi[icollection][jcollection] = ns; - } - } -} diff --git a/src/nstencil_half_multi_2d_tri.h b/src/nstencil_half_multi_2d_tri.h deleted file mode 100644 index 1d1a469e72..0000000000 --- a/src/nstencil_half_multi_2d_tri.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/2d/tri, - NStencilHalfMulti2dTri, NS_HALF | NS_MULTI | NS_2D | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_2D_TRI_H -#define LMP_NSTENCIL_HALF_MULTI_2D_TRI_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMulti2dTri : public NStencil { - public: - NStencilHalfMulti2dTri(class LAMMPS *); - void create() override; - - protected: - void set_stencil_properties() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_3d.cpp b/src/nstencil_half_multi_3d.cpp deleted file mode 100644 index ca4b4c4111..0000000000 --- a/src/nstencil_half_multi_3d.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_3d.h" - -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMulti3d::NStencilHalfMulti3d(LAMMPS *lmp) : - NStencil(lmp) {} - -/* ---------------------------------------------------------------------- */ - -void NStencilHalfMulti3d::set_stencil_properties() -{ - int n = ncollections; - int i, j; - - // Cross collections: use full stencil, looking one way through hierarchy - // smaller -> larger => use full stencil in larger bin - // larger -> smaller => no nstencil required - // If cut offs are same, use half stencil - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - - flag_skip_multi[i][j] = false; - - if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = true; - bin_collection_multi[i][j] = i; - } else { - flag_half_multi[i][j] = false; - bin_collection_multi[i][j] = j; - } - } - } -} - -/* ---------------------------------------------------------------------- - create stencils based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMulti3d::create() -{ - int icollection, jcollection, bin_collection, i, j, k, ns; - int n = ncollections; - double cutsq; - - - for (icollection = 0; icollection < n; icollection++) { - for (jcollection = 0; jcollection < n; jcollection++) { - if (flag_skip_multi[icollection][jcollection]) { - nstencil_multi[icollection][jcollection] = 0; - continue; - } - - ns = 0; - - sx = stencil_sx_multi[icollection][jcollection]; - sy = stencil_sy_multi[icollection][jcollection]; - sz = stencil_sz_multi[icollection][jcollection]; - - mbinx = stencil_mbinx_multi[icollection][jcollection]; - mbiny = stencil_mbiny_multi[icollection][jcollection]; - mbinz = stencil_mbinz_multi[icollection][jcollection]; - - bin_collection = bin_collection_multi[icollection][jcollection]; - - cutsq = cutcollectionsq[icollection][jcollection]; - - if (flag_half_multi[icollection][jcollection]) { - for (k = 0; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (k > 0 || j > 0 || (j == 0 && i > 0)) { - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = - k*mbiny*mbinx + j*mbinx + i; - } - } else { - for (k = -sz; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = - k*mbiny*mbinx + j*mbinx + i; - } - - nstencil_multi[icollection][jcollection] = ns; - } - } -} - diff --git a/src/nstencil_half_multi_3d.h b/src/nstencil_half_multi_3d.h deleted file mode 100644 index 246d71f3e4..0000000000 --- a/src/nstencil_half_multi_3d.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/3d, - NStencilHalfMulti3d, NS_HALF | NS_MULTI | NS_3D | NS_ORTHO); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_3D_H -#define LMP_NSTENCIL_HALF_MULTI_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMulti3d : public NStencil { - public: - NStencilHalfMulti3d(class LAMMPS *); - void create() override; - - protected: - void set_stencil_properties() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_3d_tri.cpp b/src/nstencil_half_multi_3d_tri.cpp deleted file mode 100644 index 60df9199a2..0000000000 --- a/src/nstencil_half_multi_3d_tri.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_3d_tri.h" - -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMulti3dTri::NStencilHalfMulti3dTri(LAMMPS *lmp) : - NStencil(lmp) {} - -/* ---------------------------------------------------------------------- */ - -void NStencilHalfMulti3dTri::set_stencil_properties() -{ - int n = ncollections; - int i, j; - - // Cross collections: use full stencil, looking one way through hierarchy - // smaller -> larger => use full stencil in larger bin - // larger -> smaller => no nstencil required - // If cut offs are same, use half stencil - - for (i = 0; i < n; i++) { - for (j = 0; j < n; j++) { - if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - - flag_skip_multi[i][j] = false; - - if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = true; - bin_collection_multi[i][j] = i; - } else { - flag_half_multi[i][j] = false; - bin_collection_multi[i][j] = j; - } - } - } -} - -/* ---------------------------------------------------------------------- - create stencils based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMulti3dTri::create() -{ - int icollection, jcollection, bin_collection, i, j, k, ns; - int n = ncollections; - double cutsq; - - - for (icollection = 0; icollection < n; icollection++) { - for (jcollection = 0; jcollection < n; jcollection++) { - if (flag_skip_multi[icollection][jcollection]) { - nstencil_multi[icollection][jcollection] = 0; - continue; - } - - ns = 0; - - sx = stencil_sx_multi[icollection][jcollection]; - sy = stencil_sy_multi[icollection][jcollection]; - sz = stencil_sz_multi[icollection][jcollection]; - - mbinx = stencil_mbinx_multi[icollection][jcollection]; - mbiny = stencil_mbiny_multi[icollection][jcollection]; - mbinz = stencil_mbinz_multi[icollection][jcollection]; - - bin_collection = bin_collection_multi[icollection][jcollection]; - - cutsq = cutcollectionsq[icollection][jcollection]; - - if (flag_half_multi[icollection][jcollection]) { - for (k = 0; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = - k*mbiny*mbinx + j*mbinx + i; - } else { - for (k = -sz; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) - stencil_multi[icollection][jcollection][ns++] = - k*mbiny*mbinx + j*mbinx + i; - } - - nstencil_multi[icollection][jcollection] = ns; - } - } -} diff --git a/src/nstencil_half_multi_3d_tri.h b/src/nstencil_half_multi_3d_tri.h deleted file mode 100644 index 2ced4b0c20..0000000000 --- a/src/nstencil_half_multi_3d_tri.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/3d/tri, - NStencilHalfMulti3dTri, NS_HALF | NS_MULTI | NS_3D | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_3D_TRI_H -#define LMP_NSTENCIL_HALF_MULTI_3D_TRI_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMulti3dTri : public NStencil { - public: - NStencilHalfMulti3dTri(class LAMMPS *); - void create() override; - - protected: - void set_stencil_properties() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_old_2d.cpp b/src/nstencil_half_multi_old_2d.cpp deleted file mode 100644 index 7a2f5a25e2..0000000000 --- a/src/nstencil_half_multi_old_2d.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_old_2d.h" -#include "atom.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMultiOld2d:: -NStencilHalfMultiOld2d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMultiOld2d::create() -{ - int i,j,n; - double rsq,typesq; - int *s; - double *distsq; - - int ntypes = atom->ntypes; - for (int itype = 1; itype <= ntypes; itype++) { - typesq = cuttypesq[itype]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - n = 0; - for (j = 0; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (j > 0 || (j == 0 && i > 0)) { - rsq = bin_distance(i,j,0); - if (rsq < typesq) { - distsq[n] = rsq; - s[n++] = j*mbinx + i; - } - } - nstencil_multi_old[itype] = n; - } -} diff --git a/src/nstencil_half_multi_old_2d.h b/src/nstencil_half_multi_old_2d.h deleted file mode 100644 index 387429d160..0000000000 --- a/src/nstencil_half_multi_old_2d.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/old/2d, - NStencilHalfMultiOld2d, NS_HALF | NS_MULTI_OLD | NS_2D | NS_ORTHO); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_OLD_2D_H -#define LMP_NSTENCIL_HALF_MULTI_OLD_2D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMultiOld2d : public NStencil { - public: - NStencilHalfMultiOld2d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_old_2d_tri.cpp b/src/nstencil_half_multi_old_2d_tri.cpp deleted file mode 100644 index 7e5158cc31..0000000000 --- a/src/nstencil_half_multi_old_2d_tri.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_old_2d_tri.h" -#include "atom.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMultiOld2dTri:: -NStencilHalfMultiOld2dTri(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMultiOld2dTri::create() -{ - int i,j,n; - double rsq,typesq; - int *s; - double *distsq; - - int ntypes = atom->ntypes; - for (int itype = 1; itype <= ntypes; itype++) { - typesq = cuttypesq[itype]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - n = 0; - for (j = 0; j <= sy; j++) - for (i = -sx; i <= sx; i++) { - rsq = bin_distance(i,j,0); - if (rsq < typesq) { - distsq[n] = rsq; - s[n++] = j*mbinx + i; - } - } - nstencil_multi_old[itype] = n; - } -} diff --git a/src/nstencil_half_multi_old_2d_tri.h b/src/nstencil_half_multi_old_2d_tri.h deleted file mode 100644 index a81d37062c..0000000000 --- a/src/nstencil_half_multi_old_2d_tri.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/old/2d/tri, - NStencilHalfMultiOld2dTri, NS_HALF | NS_MULTI_OLD | NS_2D | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_OLD_2D_TRI_H -#define LMP_NSTENCIL_HALF_MULTI_OLD_2D_TRI_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMultiOld2dTri : public NStencil { - public: - NStencilHalfMultiOld2dTri(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_old_3d.cpp b/src/nstencil_half_multi_old_3d.cpp deleted file mode 100644 index cdb22c2d13..0000000000 --- a/src/nstencil_half_multi_old_3d.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_old_3d.h" -#include "atom.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMultiOld3d:: -NStencilHalfMultiOld3d(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMultiOld3d::create() -{ - int i,j,k,n; - double rsq,typesq; - int *s; - double *distsq; - - int ntypes = atom->ntypes; - for (int itype = 1; itype <= ntypes; itype++) { - typesq = cuttypesq[itype]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - n = 0; - for (k = 0; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) - if (k > 0 || j > 0 || (j == 0 && i > 0)) { - rsq = bin_distance(i,j,k); - if (rsq < typesq) { - distsq[n] = rsq; - s[n++] = k*mbiny*mbinx + j*mbinx + i; - } - } - nstencil_multi_old[itype] = n; - } -} diff --git a/src/nstencil_half_multi_old_3d.h b/src/nstencil_half_multi_old_3d.h deleted file mode 100644 index d7d8157afa..0000000000 --- a/src/nstencil_half_multi_old_3d.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi_old/3d, - NStencilHalfMultiOld3d, NS_HALF | NS_MULTI_OLD | NS_3D | NS_ORTHO); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_OLD_3D_H -#define LMP_NSTENCIL_HALF_MULTI_OLD_3D_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMultiOld3d : public NStencil { - public: - NStencilHalfMultiOld3d(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ diff --git a/src/nstencil_half_multi_old_3d_tri.cpp b/src/nstencil_half_multi_old_3d_tri.cpp deleted file mode 100644 index 6fb9b6d3d1..0000000000 --- a/src/nstencil_half_multi_old_3d_tri.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// clang-format off -/* ---------------------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 "nstencil_half_multi_old_3d_tri.h" -#include "atom.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NStencilHalfMultiOld3dTri:: -NStencilHalfMultiOld3dTri(LAMMPS *lmp) : NStencil(lmp) {} - -/* ---------------------------------------------------------------------- - create stencil based on bin geometry and cutoff -------------------------------------------------------------------------- */ - -void NStencilHalfMultiOld3dTri::create() -{ - int i,j,k,n; - double rsq,typesq; - int *s; - double *distsq; - - int ntypes = atom->ntypes; - for (int itype = 1; itype <= ntypes; itype++) { - typesq = cuttypesq[itype]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - n = 0; - for (k = 0; k <= sz; k++) - for (j = -sy; j <= sy; j++) - for (i = -sx; i <= sx; i++) { - rsq = bin_distance(i,j,k); - if (rsq < typesq) { - distsq[n] = rsq; - s[n++] = k*mbiny*mbinx + j*mbinx + i; - } - } - nstencil_multi_old[itype] = n; - } -} diff --git a/src/nstencil_half_multi_old_3d_tri.h b/src/nstencil_half_multi_old_3d_tri.h deleted file mode 100644 index 2a7a5a22bb..0000000000 --- a/src/nstencil_half_multi_old_3d_tri.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- ---------------------------------------------------------- - LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator - https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov - - 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 NSTENCIL_CLASS -// clang-format off -NStencilStyle(half/multi/old/3d/tri, - NStencilHalfMultiOld3dTri, NS_HALF | NS_MULTI_OLD | NS_3D | NS_TRI); -// clang-format on -#else - -#ifndef LMP_NSTENCIL_HALF_MULTI_OLD_3D_TRI_H -#define LMP_NSTENCIL_HALF_MULTI_OLD_3D_TRI_H - -#include "nstencil.h" - -namespace LAMMPS_NS { - -class NStencilHalfMultiOld3dTri : public NStencil { - public: - NStencilHalfMultiOld3dTri(class LAMMPS *); - void create() override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif - -/* ERROR/WARNING messages: - -*/ From 25b89473b203f4cfa80c3066a284a6a2f898f17f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 3 Sep 2022 16:46:55 -0600 Subject: [PATCH 02/87] changing order of central bin --- src/nstencil_bin.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/nstencil_bin.cpp b/src/nstencil_bin.cpp index c5026cb338..45908671fd 100644 --- a/src/nstencil_bin.cpp +++ b/src/nstencil_bin.cpp @@ -39,15 +39,20 @@ void NStencilBin::create() nstencil = 0; + // Half and ortho stencils include central bin first + // This preserves the historical order of the neighbor list + // as the old npair classes used to separately parse the central bin first + if (HALF && (!TRI)) stencil[nstencil++] = 0; + for (k = -sz_min; k <= sz; k++) { for (j = -sy_min; j <= sy; j++) { for (i = -sx; i <= sx; i++) { - // Half and ortho stencils only include own and "upper right" bins + // Now only include "upper right" bins for half and ortho stencils if (HALF && (!DIM_3D) && (!TRI)) - if (! (j > 0 || (j == 0 && i >= 0))) continue; + if (! (j > 0 || (j == 0 && i > 0))) continue; if (HALF && DIM_3D && (!TRI)) - if (! (k > 0 || j > 0 || (j == 0 && i >= 0))) continue; + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; if (bin_distance(i,j,k) < cutneighmaxsq) stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i; From 614fb3cbdd87de7d55d3e5d359dd29fb6b7308c4 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 16 Oct 2022 21:02:02 -0600 Subject: [PATCH 03/87] Adding other nstencil classes --- src/nstencil_bin.cpp | 5 +- src/nstencil_ghost_bin.cpp | 73 ++++++++++++++++++++ src/nstencil_ghost_bin.h | 69 +++++++++++++++++++ src/nstencil_multi.cpp | 133 +++++++++++++++++++++++++++++++++++++ src/nstencil_multi.h | 72 ++++++++++++++++++++ src/nstencil_multi_old.cpp | 85 ++++++++++++++++++++++++ src/nstencil_multi_old.h | 69 +++++++++++++++++++ 7 files changed, 503 insertions(+), 3 deletions(-) create mode 100644 src/nstencil_ghost_bin.cpp create mode 100644 src/nstencil_ghost_bin.h create mode 100644 src/nstencil_multi.cpp create mode 100644 src/nstencil_multi.h create mode 100644 src/nstencil_multi_old.cpp create mode 100644 src/nstencil_multi_old.h diff --git a/src/nstencil_bin.cpp b/src/nstencil_bin.cpp index 45908671fd..22fdc335e4 100644 --- a/src/nstencil_bin.cpp +++ b/src/nstencil_bin.cpp @@ -28,8 +28,7 @@ NStencilBin::NStencilBin(LAMMPS *lmp) : NStencil(lmp) {} template void NStencilBin::create() { - int i,j,k; - bool bin_include; + int i, j, k; // For half stencils, only the upper plane is needed int sy_min = sy; @@ -55,7 +54,7 @@ void NStencilBin::create() if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; if (bin_distance(i,j,k) < cutneighmaxsq) - stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i; + stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; } } } diff --git a/src/nstencil_ghost_bin.cpp b/src/nstencil_ghost_bin.cpp new file mode 100644 index 0000000000..7531a3ff32 --- /dev/null +++ b/src/nstencil_ghost_bin.cpp @@ -0,0 +1,73 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 "nstencil_ghost_bin.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NStencilGhostBin::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp) {} + +/* ---------------------------------------------------------------------- + create stencil based on bin geometry and cutoff +------------------------------------------------------------------------- */ + +template +void NStencilGhostBin::create() +{ + int i, j, k; + + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF && (!DIM_3D)) sy_min = 0; + if (HALF && DIM_3D) sz_min = 0; + + nstencil = 0; + + // Half and ortho stencils include central bin first + // This preserves the historical order of the neighbor list + // as the old npair classes used to separately parse the central bin first + if (HALF && (!TRI)) stencil[nstencil++] = 0; + + for (k = -sz_min; k <= sz; k++) { + for (j = -sy_min; j <= sy; j++) { + for (i = -sx; i <= sx; i++) { + + // Now only include "upper right" bins for half and ortho stencils + if (HALF && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i > 0))) continue; + if (HALF && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + + if (bin_distance(i,j,k) < cutneighmaxsq) + stencilxyz[nstencil][0] = i; + stencilxyz[nstencil][1] = j; + stencilxyz[nstencil][2] = k; + stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; + } + } + } +} + +namespace LAMMPS_NS { +template class NStencilGhostBin<0,0,0>; +template class NStencilGhostBin<0,1,0>; +template class NStencilGhostBin<1,0,0>; +template class NStencilGhostBin<1,0,1>; +template class NStencilGhostBin<1,1,0>; +template class NStencilGhostBin<1,1,1>; +} diff --git a/src/nstencil_ghost_bin.h b/src/nstencil_ghost_bin.h new file mode 100644 index 0000000000..31268cc30d --- /dev/null +++ b/src/nstencil_ghost_bin.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NSTENCIL_CLASS +// clang-format off +typedef NStencilGhostBin<0, 0, 0> NStencilFullGhostBin2d; +NStencilStyle(full/ghost/bin/2d, + NStencilFullGhostBin2d, + NS_FULL | NS_GhostBin | NS_2D | NS_ORTHO | NS_TRI); + +typedef NStencilGhostBin<0, 1, 0> NStencilFullGhostBin3d; +NStencilStyle(full/ghost/bin/3d, + NStencilFullGhostBin3d, + NS_FULL | NS_GhostBin | NS_3D | NS_ORTHO | NS_TRI); + +typedef NStencilGhostBin<1, 0, 0> NStencilHalfGhostBin2d; +NStencilStyle(half/ghost/bin/2d, + NStencilHalfGhostBin2d, + NS_HALF | NS_GhostBin | NS_2D | NS_ORTHO); + +typedef NStencilGhostBin<1, 0, 1> NStencilHalfGhostBin2dTri; +NStencilStyle(half/ghost/bin/2d/tri, + NStencilHalfGhostBin2dTri, + NS_HALF | NS_GhostBin | NS_2D | NS_TRI); + +typedef NStencilGhostBin<1, 1, 0> NStencilHalfGhostBin3d; +NStencilStyle(half/ghost/bin/3d, + NStencilHalfGhostBin3d, + NS_HALF | NS_GhostBin | NS_3D | NS_ORTHO); + +typedef NStencilGhostBin<1, 1, 1> NStencilHalfGhostBin3dTri; +NStencilStyle(half/ghost/bin/3d/tri, + NStencilHalfGhostBin3dTri, + NS_HALF | NS_GhostBin | NS_3D | NS_TRI); +// clang-format on +#else + +#ifndef LMP_NSTENCIL_GHOST_BIN_H +#define LMP_NSTENCIL_GHOST_BIN_H + +#include "nstencil.h" + +namespace LAMMPS_NS { + +template +class NStencilGhostBin : public NStencil { + public: + NStencilGhostBin(class LAMMPS *); + void create() override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/nstencil_multi.cpp b/src/nstencil_multi.cpp new file mode 100644 index 0000000000..6b0688d903 --- /dev/null +++ b/src/nstencil_multi.cpp @@ -0,0 +1,133 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 "nstencil_multi.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NStencilMulti::NStencilMulti(LAMMPS *lmp) : NStencil(lmp) {} + +/* ---------------------------------------------------------------------- */ + +template +void NStencilMulti::set_stencil_properties() +{ + int n = ncollections; + int i, j; + + // FULL + // Always look up neighbor using full stencil and neighbor's bin + // Stencil cutoff set by i-j cutoff + + // HALF + // Cross collections: use full stencil, looking one way through hierarchy + // smaller -> larger => use full stencil in larger bin + // larger -> smaller => no nstencil required + // If cut offs are same, use half stencil + + for (i = 0; i < n; i++) { + for (j = 0; j < n; j++) { + if (HALF) + if (cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; + + flag_skip_multi[i][j] = false; + flag_half_multi[i][j] = false; + bin_collection_multi[i][j] = j; + + if (HALF) { + if (cutcollectionsq[i][i] == cutcollectionsq[j][j]) { + flag_half_multi[i][j] = true; + bin_collection_multi[i][j] = i; + } + } + } + } +} + +/* ---------------------------------------------------------------------- + create stencil based on bin geometry and cutoff +------------------------------------------------------------------------- */ + +template +void NStencilMulti::create() +{ + int icollection, jcollection, bin_collection, i, j, k, ns, half_flag; + int n = ncollections; + double cutsq; + + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF && (!DIM_3D)) sy_min = 0; + if (HALF && DIM_3D) sz_min = 0; + + for (icollection = 0; icollection < n; icollection++) { + for (jcollection = 0; jcollection < n; jcollection++) { + if (flag_skip_multi[icollection][jcollection]) { + nstencil_multi[icollection][jcollection] = 0; + continue; + } + + ns = 0; + + sx = stencil_sx_multi[icollection][jcollection]; + sy = stencil_sy_multi[icollection][jcollection]; + sz = stencil_sz_multi[icollection][jcollection]; + + mbinx = stencil_mbinx_multi[icollection][jcollection]; + mbiny = stencil_mbiny_multi[icollection][jcollection]; + mbinz = stencil_mbinz_multi[icollection][jcollection]; + + bin_collection = bin_collection_multi[icollection][jcollection]; + cutsq = cutcollectionsq[icollection][jcollection]; + + half_flag = flag_half_multi[icollection][jcollection]; + + // Half and ortho stencils include central bin first + // This preserves the historical order of the neighbor list + // as the old npair classes used to separately parse the central bin first + if (half_flag && (!TRI)) stencil[nstencil++] = 0; + + for (k = -sz_min; k <= sz; k++) { + for (j = -sy_min; j <= sy; j++) { + for (i = -sx; i <= sx; i++) { + + // Now only include "upper right" bins for half and ortho stencils + if (half_flag && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i > 0))) continue; + if (half_flag && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + + if (bin_distance_multi(i,j,k,bin_collection) < cutsq) + stencil_multi[icollection][jcollection][ns++] = k * mbiny * mbinx + j * mbinx + i; + } + } + } + + nstencil_multi[icollection][jcollection] = ns; + } + } +} + +namespace LAMMPS_NS { +template class NStencilMulti<0,0,0>; +template class NStencilMulti<0,1,0>; +template class NStencilMulti<1,0,0>; +template class NStencilMulti<1,0,1>; +template class NStencilMulti<1,1,0>; +template class NStencilMulti<1,1,1>; +} diff --git a/src/nstencil_multi.h b/src/nstencil_multi.h new file mode 100644 index 0000000000..4747284f2d --- /dev/null +++ b/src/nstencil_multi.h @@ -0,0 +1,72 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NSTENCIL_CLASS +// clang-format off +typedef NStencilMulti<0, 0, 0> NStencilFullMulti2d; +NStencilStyle(full/multi/2d, + NStencilFullMulti2d, + NS_FULL | NS_MULTI | NS_2D | NS_ORTHO | NS_TRI); + +typedef NStencilMulti<0, 1, 0> NStencilFullMulti3d; +NStencilStyle(full/multi/3d, + NStencilFullMulti3d, + NS_FULL | NS_MULTI | NS_3D | NS_ORTHO | NS_TRI); + +typedef NStencilMulti<1, 0, 0> NStencilHalfMulti2d; +NStencilStyle(half/multi/2d, + NStencilHalfMulti2d, + NS_HALF | NS_MULTI | NS_2D | NS_ORTHO); + +typedef NStencilMulti<1, 0, 1> NStencilHalfMulti2dTri; +NStencilStyle(half/multi/2d/tri, + NStencilHalfMulti2dTri, + NS_HALF | NS_MULTI | NS_2D | NS_TRI); + +typedef NStencilMulti<1, 1, 0> NStencilHalfMulti3d; +NStencilStyle(half/multi/3d, + NStencilHalfMulti3d, + NS_HALF | NS_MULTI | NS_3D | NS_ORTHO); + +typedef NStencilMulti<1, 1, 1> NStencilHalfMulti3dTri; +NStencilStyle(half/multi/3d/tri, + NStencilHalfMulti3dTri, + NS_HALF | NS_MULTI | NS_3D | NS_TRI); +// clang-format on +#else + +#ifndef LMP_NSTENCIL_MULTI_H +#define LMP_NSTENCIL_MULTI_H + +#include "nstencil.h" + +namespace LAMMPS_NS { + +template +class NStencilMulti : public NStencil { + public: + NStencilMulti(class LAMMPS *); + void create() override; + + protected: + void set_stencil_properties() override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ diff --git a/src/nstencil_multi_old.cpp b/src/nstencil_multi_old.cpp new file mode 100644 index 0000000000..b6b99374fa --- /dev/null +++ b/src/nstencil_multi_old.cpp @@ -0,0 +1,85 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 "nstencil_multi_old.h" +#include "atom.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NStencilMultiOld::NStencilMultiOld(LAMMPS *lmp) : NStencil(lmp) {} + +/* ---------------------------------------------------------------------- + create stencil based on bin geometry and cutoff +------------------------------------------------------------------------- */ + +template +void NStencilMultiOld::create() +{ + int i, j, k, n, itype; + double rsq, typesq; + int *s; + double *distsq; + int ntypes = atom->ntypes; + + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF && (!DIM_3D)) sy_min = 0; + if (HALF && DIM_3D) sz_min = 0; + + for (itype = 1; itype <= ntypes; itype++) { + + typesq = cuttypesq[itype]; + s = stencil_multi_old[itype]; + distsq = distsq_multi_old[itype]; + n = 0; + + // Half and ortho stencils include central bin first + // This preserves the historical order of the neighbor list + // as the old npair classes used to separately parse the central bin first + if (HALF && (!TRI)) s[n++] = 0; + + for (k = -sz_min; k <= sz; k++) { + for (j = -sy_min; j <= sy; j++) { + for (i = -sx; i <= sx; i++) { + + // Now only include "upper right" bins for half and ortho stencils + if (HALF && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i > 0))) continue; + if (HALF && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + + rsq = bin_distance(i, j, 0); + if (rsq < typesq) { + distsq[n] = rsq; + s[n++] = k * mbiny * mbinx + j * mbinx + i; + } + } + } + } + nstencil_multi_old[itype] = n; + } +} + +namespace LAMMPS_NS { +template class NStencilMultiOld<0,0,0>; +template class NStencilMultiOld<0,1,0>; +template class NStencilMultiOld<1,0,0>; +template class NStencilMultiOld<1,0,1>; +template class NStencilMultiOld<1,1,0>; +template class NStencilMultiOld<1,1,1>; +} diff --git a/src/nstencil_multi_old.h b/src/nstencil_multi_old.h new file mode 100644 index 0000000000..b5190b6736 --- /dev/null +++ b/src/nstencil_multi_old.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NSTENCIL_CLASS +// clang-format off +typedef NStencilMultiOld<0, 0, 0> NStencilFullMultiOld2d; +NStencilStyle(full/multi/old/2d, + NStencilFullMultiOld2d, + NS_FULL | NS_MULTI_OLD | NS_2D | NS_ORTHO | NS_TRI); + +typedef NStencilMultiOld<0, 1, 0> NStencilFullMultiOld3d; +NStencilStyle(full/multi/old/3d, + NStencilFullMultiOld3d, + NS_FULL | NS_MULTI_OLD | NS_3D | NS_ORTHO | NS_TRI); + +typedef NStencilMultiOld<1, 0, 0> NStencilHalfMultiOld2d; +NStencilStyle(half/multi/old/2d, + NStencilHalfMultiOld2d, + NS_HALF | NS_MULTI_OLD | NS_2D | NS_ORTHO); + +typedef NStencilMultiOld<1, 0, 1> NStencilHalfMultiOld2dTri; +NStencilStyle(half/multi/old/2d/tri, + NStencilHalfMultiOld2dTri, + NS_HALF | NS_MULTI_OLD | NS_2D | NS_TRI); + +typedef NStencilMultiOld<1, 1, 0> NStencilHalfMultiOld3d; +NStencilStyle(half/multi/old/3d, + NStencilHalfMultiOld3d, + NS_HALF | NS_MULTI_OLD | NS_3D | NS_ORTHO); + +typedef NStencilMultiOld<1, 1, 1> NStencilHalfMultiOld3dTri; +NStencilStyle(half/multi/old/3d/tri, + NStencilHalfMultiOld3dTri, + NS_HALF | NS_MULTI_OLD | NS_3D | NS_TRI); +// clang-format on +#else + +#ifndef LMP_NSTENCIL_MULTI_OLD_H +#define LMP_NSTENCIL_MULTI_OLD_H + +#include "nstencil.h" + +namespace LAMMPS_NS { + +template +class NStencilMultiOld : public NStencil { + public: + NStencilMultiOld(class LAMMPS *); + void create() override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +*/ From fcc47158b382440f6ca939f1bcbdfdd610a3e175 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 29 Oct 2022 20:35:04 -0600 Subject: [PATCH 04/87] Adding other npair classes --- src/npair_bin.cpp | 97 +++++++--- src/npair_bin.h | 35 +++- src/npair_bin_atomonly.cpp | 54 ++++-- src/npair_bin_atomonly.h | 37 +++- src/npair_bin_ghost.cpp | 188 +++++++++++++++++++ src/npair_bin_ghost.h | 53 ++++++ src/npair_halffull.cpp | 142 +++++++++++++++ src/npair_halffull.h | 115 ++++++++++++ src/npair_multi.cpp | 205 +++++++++++++++++++++ src/npair_multi.h | 85 +++++++++ src/npair_multi_old.cpp | 236 ++++++++++++++++++++++++ src/npair_multi_old.h | 85 +++++++++ src/npair_nsq.cpp | 205 +++++++++++++++++++++ src/npair_nsq.h | 76 ++++++++ src/npair_nsq_ghost.cpp | 176 ++++++++++++++++++ src/npair_nsq_ghost.h | 53 ++++++ src/npair_respa_bin.cpp | 240 +++++++++++++++++++++++++ src/npair_respa_bin.h | 58 ++++++ src/npair_respa_nsq.cpp | 214 ++++++++++++++++++++++ src/npair_respa_nsq.h | 53 ++++++ src/npair_skip.cpp | 102 +++++++++++ src/npair_skip.h | 59 ++++++ src/npair_skip_respa.cpp | 163 +++++++++++++++++ src/npair_skip_respa.h | 48 +++++ src/npair_skip_size_off2on.cpp | 100 +++++++++++ src/npair_skip_size_off2on.h | 48 +++++ src/npair_skip_size_off2on_oneside.cpp | 163 +++++++++++++++++ src/npair_skip_size_off2on_oneside.h | 48 +++++ src/nstencil_ghost_bin.h | 12 +- 29 files changed, 3098 insertions(+), 52 deletions(-) create mode 100644 src/npair_bin_ghost.cpp create mode 100644 src/npair_bin_ghost.h create mode 100644 src/npair_halffull.cpp create mode 100644 src/npair_halffull.h create mode 100644 src/npair_multi.cpp create mode 100644 src/npair_multi.h create mode 100644 src/npair_multi_old.cpp create mode 100644 src/npair_multi_old.h create mode 100644 src/npair_nsq.cpp create mode 100644 src/npair_nsq.h create mode 100644 src/npair_nsq_ghost.cpp create mode 100644 src/npair_nsq_ghost.h create mode 100644 src/npair_respa_bin.cpp create mode 100644 src/npair_respa_bin.h create mode 100644 src/npair_respa_nsq.cpp create mode 100644 src/npair_respa_nsq.h create mode 100644 src/npair_skip.cpp create mode 100644 src/npair_skip.h create mode 100644 src/npair_skip_respa.cpp create mode 100644 src/npair_skip_respa.h create mode 100644 src/npair_skip_size_off2on.cpp create mode 100644 src/npair_skip_size_off2on.h create mode 100644 src/npair_skip_size_off2on_oneside.cpp create mode 100644 src/npair_skip_size_off2on_oneside.h diff --git a/src/npair_bin.cpp b/src/npair_bin.cpp index 294336a03a..83f8c53ecc 100644 --- a/src/npair_bin.cpp +++ b/src/npair_bin.cpp @@ -27,23 +27,35 @@ using namespace NeighConst; /* ---------------------------------------------------------------------- */ -template -NPairBin::NPairBin(LAMMPS *lmp) : NPair(lmp) {} +template +NPairBin::NPairBin(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j + 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 NPairBin::build(NeighList *list) +template +void NPairBin::build(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,bin_start,which,imol,iatom,moltemplate; + int i,j,jh,k,n,itype,jtype,ibin,bin_start,which,imol,iatom,moltemplate; tagint tagprev; 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 *tag = atom->tag; @@ -59,6 +71,9 @@ void NPairBin::build(NeighList *list) if (molecular == Atom::TEMPLATE) moltemplate = 1; else moltemplate = 0; + int history = list->history; + int mask_history = 1 << HISTBITS; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -141,22 +156,48 @@ void NPairBin::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 (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; + } } } } @@ -174,8 +215,12 @@ void NPairBin::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairBin<0,1,0>; -template class NPairBin<1,0,0>; -template class NPairBin<1,1,0>; -template class NPairBin<1,1,1>; +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>; } diff --git a/src/npair_bin.h b/src/npair_bin.h index af23880db7..92e3243397 100644 --- a/src/npair_bin.h +++ b/src/npair_bin.h @@ -13,26 +13,47 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairBin<0, 1, 0> NPairFullBin; +typedef NPairBin<0, 1, 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> NPairHalfBinNewtoff; +typedef NPairBin<1, 0, 0, 0> NPairHalfBinNewtoff; NPairStyle(half/bin/newtoff, NPairHalfBinNewtoff, - NP_HALF | NP_BIN | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairBin<1, 1, 0> NPairHalfBinNewton; +typedef NPairBin<1, 1, 0, 0> NPairHalfBinNewton; NPairStyle(half/bin/newton, NPairHalfBinNewton, NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_ORTHO); -typedef NPairBin<1, 1, 1> NPairHalfBinNewtonTri; +typedef NPairBin<1, 1, 1, 0> NPairHalfBinNewtonTri; NPairStyle(half/bin/newton/tri, NPairHalfBinNewtonTri, - NP_HALF | NP_BIN | NP_NEWTON | NP_TRI); + NP_HALF | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_TRI); + +typedef NPairBin<0, 1, 0, 1> 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; +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; +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; +NPairStyle(half/size/bin/newton/tri, + NPairHalfSizeBinNewtonTri, + NP_HALF | NP_SIZE | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_TRI); // clang-format on #else @@ -43,7 +64,7 @@ NPairStyle(half/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 index aa66089fc5..3b15580264 100644 --- a/src/npair_bin_atomonly.cpp +++ b/src/npair_bin_atomonly.cpp @@ -25,28 +25,43 @@ using namespace NeighConst; /* ---------------------------------------------------------------------- */ -template -NPairBinAtomonly::NPairBinAtomonly(LAMMPS *lmp) : NPair(lmp) {} +template +NPairBinAtomonly::NPairBinAtomonly(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j + 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) +template +void NPairBinAtomonly::build(NeighList *list) { - int i,j,k,n,itype,jtype,ibin,bin_start; + 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; @@ -126,7 +141,20 @@ void NPairBinAtomonly::build(NeighList *list) delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighsq[itype][jtype]) 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; + neighptr[n++] = jh; + } + } else { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } } } @@ -143,6 +171,12 @@ void NPairBinAtomonly::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairBinAtomonly<0,1,0>; -template class NPairBinAtomonly<1,1,0>; +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 index ae64863138..581700af7d 100644 --- a/src/npair_bin_atomonly.h +++ b/src/npair_bin_atomonly.h @@ -13,16 +13,47 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairBinAtomonly<0, 1, 0> NPairFullBinAtomonly; +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, 1, 0> NPairHalfBinAtomonlyNewton; +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 @@ -33,7 +64,7 @@ NPairStyle(half/bin/atomonly/newton, namespace LAMMPS_NS { -template +template class NPairBinAtomonly : public NPair { public: NPairBinAtomonly(class LAMMPS *); diff --git a/src/npair_bin_ghost.cpp b/src/npair_bin_ghost.cpp new file mode 100644 index 0000000000..5be3352095 --- /dev/null +++ b/src/npair_bin_ghost.cpp @@ -0,0 +1,188 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_ghost.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "molecule.h" +#include "neighbor.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace NeighConst; + +/* ---------------------------------------------------------------------- */ + +template +NPairBinGhost::NPairBinGhost(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + Full: + binned neighbor list construction for all neighbors + include neighbors of ghost atoms, but no "special neighbors" for ghosts + every neighbor pair appears in list of both atoms i and j + Half + Newtoff: + binned neighbor list construction with partial Newton's 3rd law + include neighbors of ghost atoms, but no "special neighbors" for ghosts + owned and ghost atoms check own bin and other bins in stencil + pair stored once if i,j are both owned and i < j + pair stored by me if i owned and j ghost (also stored by proc owning j) + pair stored once if i,j are both ghost and i < j +------------------------------------------------------------------------- */ + + +template +void NPairBinGhost::build(NeighList *list) +{ + int i,j,k,n,itype,jtype,ibin,bin_start,which,imol,iatom,moltemplate; + tagint tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int xbin,ybin,zbin,xbin2,ybin2,zbin2; + int *neighptr; + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int inum = 0; + ipage->reset(); + + // loop over owned & ghost atoms, storing neighbors + for (i = 0; i < nall; i++) { + n = 0; + neighptr = ipage->vget(); + + itype = type[i]; + 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 (i < nlocal) { + ibin = atom2bin[i]; + + // loop over all atoms in surrounding bins in stencil including self + // when i is a ghost atom, must check if stencil bin is out of bounds + // no molecular test when i = ghost atom + 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 { + // 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; + } + + 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 != 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 { + ibin = coord2bin(x[i],xbin,ybin,zbin); + for (k = 0; k < nstencil; k++) { + xbin2 = xbin + stencilxyz[k][0]; + ybin2 = ybin + stencilxyz[k][1]; + zbin2 = zbin + stencilxyz[k][2]; + if (xbin2 < 0 || xbin2 >= mbinx || + 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 (j <= i) 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 <= cutneighghostsq[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 = atom->nlocal; + list->gnum = inum - atom->nlocal; +} + +namespace LAMMPS_NS { +template class NPairBinGhost<0>; +template class NPairBinGhost<1>; +} diff --git a/src/npair_bin_ghost.h b/src/npair_bin_ghost.h new file mode 100644 index 0000000000..602aaf986e --- /dev/null +++ b/src/npair_bin_ghost.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairBinGhost<0> NPairFullBinGhost; +NPairStyle(full/bin/ghost, + NPairFullBinGhost, + NP_FULL | NP_BIN | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); + +typedef NPairBinGhost<1> NPairHalfBinGhostNewtoff; +NPairStyle(half/bin/ghost/newtoff, + NPairHalfBinGhostNewtoff, + NP_HALF | NP_BIN | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_BIN_GHOST_H +#define LMP_NPAIR_BIN_GHOST_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairBinGhost : public NPair { + public: + NPairBinGhost(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_halffull.cpp b/src/npair_halffull.cpp new file mode 100644 index 0000000000..b9652484ce --- /dev/null +++ b/src/npair_halffull.cpp @@ -0,0 +1,142 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_halffull.h" + +#include "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairHalffull::NPairHalffull(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + build half list from full list + pair stored once if i,j are both owned and i < j + works if full list is a skip list + + Newtoff: + pair stored by me if j is ghost (also stored by proc owning j) + works for owned (non-ghost) list, also for ghost list + if ghost, also store neighbors of ghost atoms & set inum,gnum correctly + Newton: + if j is ghost, only store if j coords are "above and to the right" of i +------------------------------------------------------------------------- */ + +template +void NPairHalffull::build(NeighList *list) +{ + int i,j,ii,jj,n,jnum,joriginal; + int *neighptr,*jlist; + double xtmp,ytmp,ztmp; + double delx,dely,delz,rsq; + + double **x = atom->x; + int nlocal = atom->nlocal; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_full = list->listfull->ilist; + int *numneigh_full = list->listfull->numneigh; + int **firstneigh_full = list->listfull->firstneigh; + int inum_full = list->listfull->inum; + if (!NEWTON) + if (list->ghost) inum_full += list->listfull->gnum; + + int inum = 0; + ipage->reset(); + + double cutsq_custom = cutoff_custom * cutoff_custom; + + // loop over atoms in full list + + for (ii = 0; ii < inum_full; ii++) { + n = 0; + neighptr = ipage->vget(); + + // loop over parent full list + + i = ilist_full[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + + jlist = firstneigh_full[i]; + jnum = numneigh_full[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (NEWTON) { + if (j < nlocal) { + if (i > j) continue; + } else { + 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; + } + } + + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; + } else { + if (j > i) { + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; + } + } + } + + 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 (!NEWTON) + if (list->ghost) list->gnum = list->listfull->gnum; +} + +namespace LAMMPS_NS { +template class NPairHalffull<0,0>; +template class NPairHalffull<1,0>; +template class NPairHalffull<0,1>; +template class NPairHalffull<1,1>; +} diff --git a/src/npair_halffull.h b/src/npair_halffull.h new file mode 100644 index 0000000000..519cb0ced1 --- /dev/null +++ b/src/npair_halffull.h @@ -0,0 +1,115 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairHalffull<0, 0> NPairHalffullNewtoff; +NPairStyle(halffull/newtoff, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI); + +typedef NPairHalffull<0, 0> NPairHalffullNewtoff; +NPairStyle(halffull/newtoff/skip, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP); + +typedef NPairHalffull<0, 0> NPairHalffullNewtoff; +NPairStyle(halffull/newtoff/ghost, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_GHOST); + +typedef NPairHalffull<0, 0> NPairHalffullNewtoff; +NPairStyle(halffull/newtoff/skip/ghost, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST); + +typedef NPairHalffull<1, 0> NPairHalffullNewton; +NPairStyle(halffull/newton, + NPairHalffullNewton, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI); + +typedef NPairHalffull<1, 0> NPairHalffullNewton; +NPairStyle(halffull/newton/skip, + NPairHalffullNewton, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_SKIP); + +typedef NPairHalffull<0, 1> NPairHalffullNewtoffTrim; +NPairStyle(halffull/newtoff/trim, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_TRIM); + +typedef NPairHalffull<0, 1> NPairHalffullNewtoffTrim; +NPairStyle(halffull/newtoff/skip/trim, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM); + +typedef NPairHalffull<0, 1> NPairHalffullNewtoffTrim; +NPairStyle(halffull/newtoff/ghost/trim, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM); + +typedef NPairHalffull<0, 1> NPairHalffullNewtoffTrim; +NPairStyle(halffull/newtoff/skip/ghost/trim, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_TRIM); + +typedef NPairHalffull<1, 1> NPairHalffullNewtonTrim; +NPairStyle(halffull/newton/trim, + NPairHalffullNewtonTrim, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_TRIM); + +typedef NPairHalffull<1, 1> NPairHalffullNewtonTrim; +NPairStyle(halffull/newton/skip/trim, + NPairHalffullNewtonTrim, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM); +// clang-format on +#else + +#ifndef LMP_NPAIR_HALFFULL_H +#define LMP_NPAIR_HALFFULL_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairHalffull : public NPair { + public: + NPairHalffull(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp new file mode 100644 index 0000000000..76e90ec674 --- /dev/null +++ b/src/npair_multi.cpp @@ -0,0 +1,205 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_multi.h" +#include "atom.h" +#include "atom_vec.h" +#include "domain.h" +#include "error.h" +#include "molecule.h" +#include "my_page.h" +#include "neighbor.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; +using namespace NeighConst; + +/* ---------------------------------------------------------------------- */ + +template +NPairMulti::NPairMulti(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + multi stencil is icollection-jcollection dependent + 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 NPairMulti::build(NeighList *list) +{ + int i,j,jh,js,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom,moltemplate; + tagint tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radsum,cut,cutsq; + int *neighptr,*s; + + int *collection = neighbor->collection; + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + 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]; + icollection = collection[i]; + 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; + } + + ibin = atom2bin[i]; + + // loop through stencils for all collections + for (jcollection = 0; jcollection < ncollections; jcollection++) { + + // if same collection use own bin + if (icollection == jcollection) jbin = ibin; + else jbin = coord2bin(x[i], jcollection); + + s = stencil_multi[icollection][jcollection]; + ns = nstencil_multi[icollection][jcollection]; + + for (k = 0; k < ns; k++) { + js = binhead_multi[jcollection][jbin + s[k]]; + for (j = js; 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 (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; + } + } + } + } + + 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; + list->gnum = 0; +} + +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>; +} diff --git a/src/npair_multi.h b/src/npair_multi.h new file mode 100644 index 0000000000..288498dc00 --- /dev/null +++ b/src/npair_multi.h @@ -0,0 +1,85 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairMulti<0, 1, 0, 0> NPairFullMulti; +NPairStyle(full/Multi, + NPairFullMulti, + NP_FULL | NP_MULTI | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 0, 0, 0> NPairHalfMultiNewtoff; +NPairStyle(half/multi/newtoff, + NPairHalfMultiNewtoff, + NP_HALF | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 1, 0, 0> NPairHalfMultiNewton; +NPairStyle(half/multi/newton, + NPairHalfMultiNewton, + NP_HALF | NP_MULTI | NP_NEWTON | NP_ORTHO); + +typedef NPairMulti<1, 1, 1, 0> NPairHalfMultiNewtonTri; +NPairStyle(half/multi/newton/tri, + NPairHalfMultiNewtonTri, + NP_HALF | NP_MULTI | NP_NEWTON | NP_TRI); + +typedef NPairMulti<0, 1, 0, 1> NPairFullSizeMulti; +NPairStyle(full/size/Multi, + NPairFullSizeMulti, + NP_FULL | NP_SIZE | NP_MULTI | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 0, 0, 1> NPairHalfSizeMultiNewtoff; +NPairStyle(half/size/multi/newtoff, + NPairHalfSizeMultiNewtoff, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMulti<1, 1, 0, 1> NPairHalfSizeMultiNewton; +NPairStyle(half/size/multi/newton, + NPairHalfSizeMultiNewton, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_ORTHO); + +typedef NPairMulti<1, 1, 1, 1> NPairHalfSizeMultiNewtonTri; +NPairStyle(half/size/multi/newton/tri, + NPairHalfSizeMultiNewtonTri, + NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_MULTI_H +#define LMP_NPAIR_MULTI_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairMulti : public NPair { + public: + NPairMulti(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_multi_old.cpp b/src/npair_multi_old.cpp new file mode 100644 index 0000000000..28efc16797 --- /dev/null +++ b/src/npair_multi_old.cpp @@ -0,0 +1,236 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_multi_old.h" + +#include "atom.h" +#include "atom_vec.h" +#include "domain.h" +#include "error.h" +#include "molecule.h" +#include "my_page.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairMultiOld::NPairMultiOld(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + multi/old-type stencil is itype dependent and is distance checked + Full: + binned neighbor list construction for all neighbors + multi-type stencil is itype dependent and is distance checked + 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 + multi-type stencil is itype dependent and is distance checked + 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 + multi-type stencil is itype dependent and is distance checked + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +template +void NPairMultiOld::build(NeighList *list) +{ + int i,j,jh,k,n,itype,jtype,ibin,bin_start,which,ns,imol,iatom,moltemplate; + tagint tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radsum,cut,cutsq; + int *neighptr,*s; + double *cutsq,*distsq; + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + 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]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } + + ibin = atom2bin[i]; + s = stencil_multi_old[itype]; + distsq = distsq_multi_old[itype]; + cutsq = 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)) { + // 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 (cutsq[jtype] < distsq[k]) continue; + if (i == j) continue; + + 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; + + 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; + } + } + } + } + + 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; + list->gnum = 0; +} + +namespace LAMMPS_NS { +template class NPairMultiOld<0,1,0,0>; +template class NPairMultiOld<1,0,0,0>; +template class NPairMultiOld<1,1,0,0>; +template class NPairMultiOld<1,1,1,0>; +template class NPairMultiOld<0,1,0,1>; +template class NPairMultiOld<1,0,0,1>; +template class NPairMultiOld<1,1,0,1>; +template class NPairMultiOld<1,1,1,1>; +} diff --git a/src/npair_multi_old.h b/src/npair_multi_old.h new file mode 100644 index 0000000000..52b071ebc5 --- /dev/null +++ b/src/npair_multi_old.h @@ -0,0 +1,85 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairMultiOld<0, 1, 0, 0> NPairFullMultiOld; +NPairStyle(full/multi/old, + NPairFullMultiOld, + NP_FULL | NP_MULTI_OLD | NP_MOLONLY | + 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); + +typedef NPairMultiOld<1, 1, 0, 0> NPairHalfMultiOldNewton; +NPairStyle(half/multi/old/newton, + NPairHalfMultiOldNewton, + NP_HALF | NP_MULTI_OLD | NP_MOLONLY | 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); + +typedef NPairMultiOld<0, 1, 0, 1> NPairFullSizeMultiOld; +NPairStyle(full/size/multi/old, + NPairFullSizeMultiOld, + NP_FULL | NP_SIZE | NP_MULTI_OLD | NP_MOLONLY | + 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); + +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); + +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); +// clang-format on +#else + +#ifndef LMP_NPAIR_MULTI_OLD_H +#define LMP_NPAIR_MULTI_OLD_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairMultiOld : public NPair { + public: + NPairMultiOld(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_nsq.cpp b/src/npair_nsq.cpp new file mode 100644 index 0000000000..87a05e8136 --- /dev/null +++ b/src/npair_nsq.cpp @@ -0,0 +1,205 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_nsq.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "molecule.h" +#include "neighbor.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace NeighConst; + +/* ---------------------------------------------------------------------- */ + +template +NPairNsq::NPairNsq(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + Full: + N^2 search for all neighbors + every neighbor pair appears in list of both atoms i and j + Half + Newtoff: + N^2 / 2 search for neighbor pairs with partial Newton's 3rd law + 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: + N^2 / 2 search for neighbor pairs with full Newton's 3rd law + every pair stored exactly once by some processor + decision on ghost atoms based on itag,jtag tests +------------------------------------------------------------------------- */ + +template +void NPairNsq::build(NeighList *list) +{ + int i,j,jh,jstart,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; + tagint itag,jtag,tagprev; + 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 *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + if (includegroup) { + nlocal = atom->nfirst; + bitmask = group->bitmask[includegroup]; + } + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + 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(); + + itag = tag[i]; + itype = type[i]; + 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; + } + + // Full: loop over all atoms, owned and ghost, skip i = j + // Half: loop over remaining atoms, owned and ghost + // Newtoff: only store pair if i < j + // Newton: itag = jtag is possible for long cutoffs that include images of self + + if (!HALF) jstart = 0; + else jstart = i + 1; + + for (j = jstart; j < nall; j++) { + if (includegroup && !(mask[j] & bitmask)) continue; + + if (!HALF) { + // Full neighbor list + if (i == j) continue; + } else if (NEWTON) { + // Half neighbor list, newton on + 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 (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; + + 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; + } + } + } + + 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 NPairNsq<0,1,0>; +template class NPairNsq<1,0,0>; +template class NPairNsq<1,1,0>; +template class NPairNsq<0,1,1>; +template class NPairNsq<1,0,1>; +template class NPairNsq<1,1,1>; +} diff --git a/src/npair_nsq.h b/src/npair_nsq.h new file mode 100644 index 0000000000..4d616d33f2 --- /dev/null +++ b/src/npair_nsq.h @@ -0,0 +1,76 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairNsq<0, 1, 0> NPairFullNsq; +NPairStyle(full/nsq, + NPairFullNsq, + NP_FULL | NP_NSQ | NP_MOLONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsq<1, 0, 0> NPairHalfNsqNewtoff; +NPairStyle(half/nsq/newtoff, + NPairHalfNsqNewtoff, + NP_HALF | NP_NSQ | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsq<1, 1, 0> NPairHalfNsqNewton; +NPairStyle(half/nsq/newton, + NPairHalfNsqNewton, + NP_HALF | NP_NSQ | NP_MOLONLY | NP_NEWTON | NP_ORTHO | NP_TRI); + +typedef NPairNsq<0, 1, 1> NPairFullSizeNsq; +NPairStyle(full/size/nsq, + NPairFullSizeNsq, + NP_FULL | NP_SIZE | NP_NSQ | NP_MOLONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsq<1, 0, 1> NPairHalfSizeNsqNewtoff; +NPairStyle(half/size/nsq/newtoff, + NPairHalfSizeNsqNewtoff, + NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsq<1, 1, 1> NPairHalfSizeNsqNewton; +NPairStyle(half/size/nsq/newton, + NPairHalfSizeNsqNewton, + NP_HALF | NP_SIZE | NP_NSQ | NP_MOLONLY | NP_NEWTON | NP_ORTHO | NP_TRI); + +// clang-format on +#else + +#ifndef LMP_NPAIR_Nsq_H +#define LMP_NPAIR_Nsq_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairNsq : public NPair { + public: + NPairNsq(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_nsq_ghost.cpp b/src/npair_nsq_ghost.cpp new file mode 100644 index 0000000000..4a733047c4 --- /dev/null +++ b/src/npair_nsq_ghost.cpp @@ -0,0 +1,176 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_nsq_ghost.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "molecule.h" +#include "neighbor.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; +using namespace NeighConst; + +/* ---------------------------------------------------------------------- */ + +template +NPairNsqGhost::NPairNsqGhost(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + Full: + N^2 search for all neighbors + include neighbors of ghost atoms, but no "special neighbors" for ghosts + every neighbor pair appears in list of both atoms i and j + Half + Newtoff: + N^2 / 2 search for neighbor pairs with partial Newton's 3rd law + include neighbors of ghost atoms, but no "special neighbors" for ghosts + pair stored once if i,j are both owned and i < j + pair stored by me if i owned and j ghost (also stored by proc owning j) + pair stored once if i,j are both ghost and i < j +------------------------------------------------------------------------- */ + + +template +void NPairNsqGhost::build(NeighList *list) +{ + int i,j,jstart,n,itype,jtype,which,bitmask,imol,iatom,moltemplate; + tagint tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *neighptr; + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + if (includegroup) { + nlocal = atom->nfirst; + bitmask = group->bitmask[includegroup]; + } + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int inum = 0; + ipage->reset(); + + // loop over owned & ghost atoms, storing neighbors + for (i = 0; i < nall; i++) { + n = 0; + neighptr = ipage->vget(); + + itype = type[i]; + 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; + } + + // loop over all atoms, owned and ghost + // Full: + // skip i = j + // Half: + // only store pair if i < j + // stores own/own pairs only once + // stores own/ghost pairs with owned atom only, on both procs + // stores ghost/ghost pairs only once + // no molecular test when i = ghost atom + + if (!HALF) jstart = 0; + else jstart = i + 1; + + if (i < nlocal) { + for (j = jstart; j < nall; j++) { + if (includegroup && !(mask[j] & bitmask)) continue; // JTC: missing in original full version + if (!HALF) { + if (i == j) 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 != 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 { + for (j = jstart; j < nall; j++) { + if (includegroup && !(mask[j] & bitmask)) continue; // JTC: missing in original full version + if (!HALF) { + if (i == j) 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]) 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 = atom->nlocal; + list->gnum = inum - atom->nlocal; +} + +namespace LAMMPS_NS { +template class NPairNsqGhost<0>; +template class NPairNsqGhost<1>; +} diff --git a/src/npair_nsq_ghost.h b/src/npair_nsq_ghost.h new file mode 100644 index 0000000000..d1f34969d5 --- /dev/null +++ b/src/npair_nsq_ghost.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairNsqGhost<0> NPairFullNsqGhost; +NPairStyle(full/nsq/ghost, + NPairFullNsqGhost, + NP_FULL | NP_NSQ | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); + +typedef NPairNsqGhost<1> NPairHalfNsqGhostNewtoff; +NPairStyle(half/nsq/ghost/newtoff, + NPairHalfNsqGhostNewtoff, + NP_HALF | NP_NSQ | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_NSQ_GHOST_H +#define LMP_NPAIR_NSQ_GHOST_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairNsqGhost : public NPair { + public: + NPairNsqGhost(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_respa_bin.cpp b/src/npair_respa_bin.cpp new file mode 100644 index 0000000000..7e8f79df5f --- /dev/null +++ b/src/npair_respa_bin.cpp @@ -0,0 +1,240 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_respa_bin.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "molecule.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairRespaBin::NPairRespaBin(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + multiple respa lists + Newtoff + binned neighbor list construction with partial Newton's 3rd law + each owned atom i checks own bin and surrounding bins in non-Newton 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) + 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 NPairRespaBin::build(NeighList *list) +{ + int i,j,k,n,itype,jtype,ibin,bin_start,n_inner,n_middle,imol,iatom,moltemplate; + tagint tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *neighptr,*neighptr_inner,*neighptr_middle; + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + if (includegroup) nlocal = atom->nfirst; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_inner = list->ilist_inner; + int *numneigh_inner = list->numneigh_inner; + int **firstneigh_inner = list->firstneigh_inner; + MyPage *ipage_inner = list->ipage_inner; + + int *ilist_middle,*numneigh_middle,**firstneigh_middle; + MyPage *ipage_middle; + int respamiddle = list->respamiddle; + if (respamiddle) { + ilist_middle = list->ilist_middle; + numneigh_middle = list->numneigh_middle; + firstneigh_middle = list->firstneigh_middle; + ipage_middle = list->ipage_middle; + } + + int inum = 0; + int which = 0; + int minchange = 0; + ipage->reset(); + ipage_inner->reset(); + if (respamiddle) ipage_middle->reset(); + + for (i = 0; i < nlocal; i++) { + n = n_inner = 0; + neighptr = ipage->vget(); + neighptr_inner = ipage_inner->vget(); + if (respamiddle) { + n_middle = 0; + neighptr_middle = ipage_middle->vget(); + } + + itype = type[i]; + 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; + } + + 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 = binstart; j >= 0; j = bins[j]) { + 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 (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 ((minchange = domain->minimum_image_check(delx,dely,delz))) + neighptr[n++] = j; + else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); + } else neighptr[n++] = j; + + if (rsq < cut_inner_sq) { + if (which == 0) neighptr_inner[n_inner++] = j; + else if (minchange) neighptr_inner[n_inner++] = j; + else if (which > 0) + neighptr_inner[n_inner++] = j ^ (which << SBBITS); + } + + if (respamiddle && + rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { + if (which == 0) neighptr_middle[n_middle++] = j; + else if (minchange) neighptr_middle[n_middle++] = j; + else if (which > 0) + neighptr_middle[n_middle++] = j ^ (which << SBBITS); + } + } + } + } + + 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"); + + ilist_inner[inum] = i; + firstneigh_inner[i] = neighptr_inner; + numneigh_inner[i] = n_inner; + ipage_inner->vgot(n_inner); + if (ipage_inner->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + + if (respamiddle) { + ilist_middle[inum] = i; + firstneigh_middle[i] = neighptr_middle; + numneigh_middle[i] = n_middle; + ipage_middle->vgot(n_middle); + if (ipage_middle->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + inum++; + } + + list->inum = inum; + list->inum_inner = inum; + if (respamiddle) list->inum_middle = inum; +} + +namespace LAMMPS_NS { +template class NPairRespaBin<0,0>; +template class NPairRespaBin<1,0>; +template class NPairRespaBin<1,1>; +} diff --git a/src/npair_respa_bin.h b/src/npair_respa_bin.h new file mode 100644 index 0000000000..bf52ebcadc --- /dev/null +++ b/src/npair_respa_bin.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairRespaBin<0, 0> NPairHalfRespaBinNewtoff; +NPairStyle(half/respa/bin/newtoff, + NPairHalfRespaBinNewtoff, + NP_HALF | NP_RESPA | NP_BIN | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairRespaBin<1, 0> NPairHalfRespaBinNewton; +NPairStyle(half/respa/bin/newton, + NPairHalfRespaBinNewton, + NP_HALF | NP_RESPA | NP_BIN | NP_NEWTON | NP_ORTHO); + +typedef NPairRespaBin<1, 1> NPairHalfRespaBinNewtonTri; +NPairStyle(half/respa/bin/newton/tri, + NPairHalfRespaBinNewtonTri, + NP_HALF | NP_RESPA | NP_BIN | NP_NEWTON | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_RESPA_BIN_H +#define LMP_NPAIR_RESPA_BIN_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairRespaBin : public NPair { + public: + NPairRespaBin(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_respa_nsq.cpp b/src/npair_respa_nsq.cpp new file mode 100644 index 0000000000..5587758cd4 --- /dev/null +++ b/src/npair_respa_nsq.cpp @@ -0,0 +1,214 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_respa_nsq.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "group.h" +#include "molecule.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairRespaNsq::NPairRespaNsq(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + multiple respa lists + Newtoff + N^2 / 2 search for neighbor pairs with partial Newton's 3rd law + pair added to list if atoms i and j are both owned and i < j + pair added if j is ghost (also stored by proc owning j) + Newton + N^2 / 2 search for neighbor pairs with full Newton's 3rd law + pair added to list if atoms i and j are both owned and i < j + if j is ghost only me or other proc adds pair + decision based on itag,jtag tests +------------------------------------------------------------------------- */ + +template +void NPairRespaNsq::build(NeighList *list) +{ + int i,j,n,itype,jtype,n_inner,n_middle,bitmask,imol,iatom,moltemplate; + tagint itag,jtag,tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + int *neighptr,*neighptr_inner,*neighptr_middle; + + double **x = atom->x; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int nlocal = atom->nlocal; + int nall = nlocal + atom->nghost; + if (includegroup) { + nlocal = atom->nfirst; + bitmask = group->bitmask[includegroup]; + } + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + if (molecular == Atom::TEMPLATE) moltemplate = 1; + else moltemplate = 0; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_inner = list->ilist_inner; + int *numneigh_inner = list->numneigh_inner; + int **firstneigh_inner = list->firstneigh_inner; + MyPage *ipage_inner = list->ipage_inner; + + int *ilist_middle,*numneigh_middle,**firstneigh_middle; + MyPage *ipage_middle; + int respamiddle = list->respamiddle; + if (respamiddle) { + ilist_middle = list->ilist_middle; + numneigh_middle = list->numneigh_middle; + firstneigh_middle = list->firstneigh_middle; + ipage_middle = list->ipage_middle; + } + + int inum = 0; + int which = 0; + int minchange = 0; + ipage->reset(); + ipage_inner->reset(); + if (respamiddle) ipage_middle->reset(); + + for (i = 0; i < nlocal; i++) { + n = n_inner = 0; + neighptr = ipage->vget(); + neighptr_inner = ipage_inner->vget(); + if (respamiddle) { + n_middle = 0; + neighptr_middle = ipage_middle->vget(); + } + + itype = type[i]; + itag = tag[i]; + 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; + } + + // loop over remaining atoms, owned and ghost + + for (j = i+1; j < nall; j++) { + if (includegroup && !(mask[j] & bitmask)) continue; + + if (NEWTON) { + 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 (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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) + neighptr[n++] = j; + else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); + } else neighptr[n++] = j; + + if (rsq < cut_inner_sq) { + if (which == 0) neighptr_inner[n_inner++] = j; + else if (minchange) neighptr_inner[n_inner++] = j; + else if (which > 0) neighptr_inner[n_inner++] = j ^ (which << SBBITS); + } + + if (respamiddle && rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { + if (which == 0) neighptr_middle[n_middle++] = j; + else if (minchange) neighptr_middle[n_middle++] = j; + else if (which > 0) + neighptr_middle[n_middle++] = j ^ (which << SBBITS); + } + } + } + + 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"); + + ilist_inner[inum] = i; + firstneigh_inner[i] = neighptr_inner; + numneigh_inner[i] = n_inner; + ipage_inner->vgot(n_inner); + if (ipage_inner->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + + if (respamiddle) { + ilist_middle[inum] = i; + firstneigh_middle[i] = neighptr_middle; + numneigh_middle[i] = n_middle; + ipage_middle->vgot(n_middle); + if (ipage_middle->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + inum++; + } + + list->inum = inum; + list->inum_inner = inum; + if (respamiddle) list->inum_middle = inum; +} + +namespace LAMMPS_NS { +template class NPairRespaNsq<0>; +template class NPairRespaNsq<1>; +} diff --git a/src/npair_respa_nsq.h b/src/npair_respa_nsq.h new file mode 100644 index 0000000000..5d6ea60465 --- /dev/null +++ b/src/npair_respa_nsq.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 NPairRespaNsq<0> NPairHalfRespaNsqNewtoff; +NPairStyle(half/respa/nsq/newtoff, + NPairHalfRespaNsqNewtoff, + NP_HALF | NP_RESPA | NP_NSQ | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairRespaNsq<1> NPairHalfRespaNsqNewton; +NPairStyle(half/respa/nsq/newton, + NPairHalfRespaNsqNewton, + NP_HALF | NP_RESPA | NP_NSQ | NP_NEWTON | NP_ORTHO | NP_TRI); //JTC: Originally didn't have TRI +// clang-format on +#else + +#ifndef LMP_NPAIR_RESPA_NSQ_H +#define LMP_NPAIR_RESPA_NSQ_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairRespaNsq : public NPair { + public: + NPairRespaNsq(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_skip.cpp b/src/npair_skip.cpp new file mode 100644 index 0000000000..4ef0573dbb --- /dev/null +++ b/src/npair_skip.cpp @@ -0,0 +1,102 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_skip.h" + +#include "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairSkip::NPairSkip(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + build skip list for subset of types from parent list + works for half and full lists + works for owned (non-ghost) list, also for ghost list + iskip and ijskip flag which atom types and type pairs to skip + if ghost, also store neighbors of ghost atoms & set inum,gnum correctly +------------------------------------------------------------------------- */ + +void NPairSkip::build(NeighList *list) +{ + int i,j,ii,jj,n,itype,jnum,joriginal; + int *neighptr,*jlist; + + int *type = atom->type; + int nlocal = atom->nlocal; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_skip = list->listskip->ilist; + int *numneigh_skip = list->listskip->numneigh; + int **firstneigh_skip = list->listskip->firstneigh; + int num_skip = list->listskip->inum; + if (list->ghost) num_skip += list->listskip->gnum; + + int *iskip = list->iskip; + int **ijskip = list->ijskip; + + int inum = 0; + ipage->reset(); + + // loop over atoms in other list + // skip I atom entirely if iskip is set for type[I] + // skip I,J pair if ijskip is set for type[I],type[J] + + for (ii = 0; ii < num_skip; ii++) { + i = ilist_skip[ii]; + itype = type[i]; + if (iskip[itype]) continue; + + n = 0; + neighptr = ipage->vget(); + + // loop over parent non-skip list + + jlist = firstneigh_skip[i]; + jnum = numneigh_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + neighptr[n++] = joriginal; + } + + 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 (list->ghost) { + int num = 0; + for (i = 0; i < inum; i++) + if (ilist[i] < nlocal) num++; + else break; + list->inum = num; + list->gnum = inum - num; + } +} diff --git a/src/npair_skip.h b/src/npair_skip.h new file mode 100644 index 0000000000..b2a0752117 --- /dev/null +++ b/src/npair_skip.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 +NPairStyle(skip, + NPairSkip, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +NPairStyle(skip/ghost, + NPairSkip, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST); + +NPairStyle(skip/half/size, + NPairSkip, + NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_SKIP_H +#define LMP_NPAIR_SKIP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairSkip : public NPair { + public: + NPairSkip(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_skip_respa.cpp b/src/npair_skip_respa.cpp new file mode 100644 index 0000000000..373fe3f8db --- /dev/null +++ b/src/npair_skip_respa.cpp @@ -0,0 +1,163 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_skip_respa.h" + +#include "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairSkipRespa::NPairSkipRespa(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + build skip list for subset of types from parent list + iskip and ijskip flag which atom types and type pairs to skip + this is for respa lists, copy the inner/middle values from parent +------------------------------------------------------------------------- */ + +void NPairSkipRespa::build(NeighList *list) +{ + int i,j,ii,jj,n,itype,jnum,joriginal,n_inner,n_middle; + int *neighptr,*jlist,*neighptr_inner,*neighptr_middle; + + int *type = atom->type; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_skip = list->listskip->ilist; + int *numneigh_skip = list->listskip->numneigh; + int **firstneigh_skip = list->listskip->firstneigh; + int inum_skip = list->listskip->inum; + + int *iskip = list->iskip; + int **ijskip = list->ijskip; + + int *ilist_inner = list->ilist_inner; + int *numneigh_inner = list->numneigh_inner; + int **firstneigh_inner = list->firstneigh_inner; + MyPage *ipage_inner = list->ipage_inner; + int *numneigh_inner_skip = list->listskip->numneigh_inner; + int **firstneigh_inner_skip = list->listskip->firstneigh_inner; + + int *ilist_middle,*numneigh_middle,**firstneigh_middle; + MyPage *ipage_middle; + int *numneigh_middle_skip,**firstneigh_middle_skip; + int respamiddle = list->respamiddle; + if (respamiddle) { + ilist_middle = list->ilist_middle; + numneigh_middle = list->numneigh_middle; + firstneigh_middle = list->firstneigh_middle; + ipage_middle = list->ipage_middle; + numneigh_middle_skip = list->listskip->numneigh_middle; + firstneigh_middle_skip = list->listskip->firstneigh_middle; + } + + int inum = 0; + ipage->reset(); + ipage_inner->reset(); + if (respamiddle) ipage_middle->reset(); + + // loop over atoms in other list + // skip I atom entirely if iskip is set for type[I] + // skip I,J pair if ijskip is set for type[I],type[J] + + for (ii = 0; ii < inum_skip; ii++) { + i = ilist_skip[ii]; + itype = type[i]; + if (iskip[itype]) continue; + + n = n_inner = 0; + neighptr = ipage->vget(); + neighptr_inner = ipage_inner->vget(); + if (respamiddle) { + n_middle = 0; + neighptr_middle = ipage_middle->vget(); + } + + // loop over parent outer rRESPA list + + jlist = firstneigh_skip[i]; + jnum = numneigh_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + neighptr[n++] = joriginal; + } + + // loop over parent inner rRESPA list + + jlist = firstneigh_inner_skip[i]; + jnum = numneigh_inner_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + neighptr_inner[n_inner++] = joriginal; + } + + // loop over parent middle rRESPA list + + if (respamiddle) { + jlist = firstneigh_middle_skip[i]; + jnum = numneigh_middle_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + neighptr_middle[n_middle++] = joriginal; + } + } + + 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"); + + ilist_inner[inum] = i; + firstneigh_inner[i] = neighptr_inner; + numneigh_inner[i] = n_inner; + ipage_inner->vgot(n); + if (ipage_inner->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + + if (respamiddle) { + ilist_middle[inum] = i; + firstneigh_middle[i] = neighptr_middle; + numneigh_middle[i] = n_middle; + ipage_middle->vgot(n); + if (ipage_middle->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + inum++; + } + + list->inum = inum; + list->inum_inner = inum; + if (respamiddle) list->inum_middle = inum; +} diff --git a/src/npair_skip_respa.h b/src/npair_skip_respa.h new file mode 100644 index 0000000000..b0938287b5 --- /dev/null +++ b/src/npair_skip_respa.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 +NPairStyle(skip/half/respa, + NPairSkipRespa, + NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_SKIP_RESPA_H +#define LMP_NPAIR_SKIP_RESPA_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairSkipRespa : public NPair { + public: + NPairSkipRespa(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_skip_size_off2on.cpp b/src/npair_skip_size_off2on.cpp new file mode 100644 index 0000000000..e48ca345ff --- /dev/null +++ b/src/npair_skip_size_off2on.cpp @@ -0,0 +1,100 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_skip_size_off2on.h" + +#include "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairSkipSizeOff2on::NPairSkipSizeOff2on(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + build skip list for subset of types from parent list + iskip and ijskip flag which atom types and type pairs to skip + parent non-skip list used newton off, this skip list is newton on +------------------------------------------------------------------------- */ + +void NPairSkipSizeOff2on::build(NeighList *list) +{ + int i,j,ii,jj,n,itype,jnum,joriginal; + tagint itag,jtag; + int *neighptr,*jlist; + + tagint *tag = atom->tag; + int *type = atom->type; + int nlocal = atom->nlocal; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_skip = list->listskip->ilist; + int *numneigh_skip = list->listskip->numneigh; + int **firstneigh_skip = list->listskip->firstneigh; + int inum_skip = list->listskip->inum; + + int *iskip = list->iskip; + int **ijskip = list->ijskip; + + int inum = 0; + ipage->reset(); + + // loop over atoms in other list + // skip I atom entirely if iskip is set for type[I] + // skip I,J pair if ijskip is set for type[I],type[J] + + for (ii = 0; ii < inum_skip; ii++) { + i = ilist_skip[ii]; + itype = type[i]; + if (iskip[itype]) continue; + itag = tag[i]; + + n = 0; + neighptr = ipage->vget(); + + // loop over parent non-skip size list and optionally its history info + + jlist = firstneigh_skip[i]; + jnum = numneigh_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + + // only keep I,J when J = ghost if Itag < Jtag + + jtag = tag[j]; + if (j >= nlocal && jtag < itag) continue; + + neighptr[n++] = joriginal; + } + + 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; +} diff --git a/src/npair_skip_size_off2on.h b/src/npair_skip_size_off2on.h new file mode 100644 index 0000000000..39aee76b09 --- /dev/null +++ b/src/npair_skip_size_off2on.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 +NPairStyle(skip/size/off2on, + NPairSkipSizeOff2on, + NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_SKIP_SIZE_OFF2ON_H +#define LMP_NPAIR_SKIP_SIZE_OFF2ON_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairSkipSizeOff2on : public NPair { + public: + NPairSkipSizeOff2on(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/npair_skip_size_off2on_oneside.cpp b/src/npair_skip_size_off2on_oneside.cpp new file mode 100644 index 0000000000..1e4b4ac78d --- /dev/null +++ b/src/npair_skip_size_off2on_oneside.cpp @@ -0,0 +1,163 @@ +// clang-format off +/* ---------------------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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_skip_size_off2on_oneside.h" + +#include "atom.h" +#include "domain.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +NPairSkipSizeOff2onOneside::NPairSkipSizeOff2onOneside(LAMMPS *lmp) : + NPair(lmp) {} + +/* ---------------------------------------------------------------------- + build skip list for subset of types from parent list + iskip and ijskip flag which atom types and type pairs to skip + parent non-skip list used newton off and was not onesided, + this skip list is newton on and onesided +------------------------------------------------------------------------- */ + +void NPairSkipSizeOff2onOneside::build(NeighList *list) +{ + int i,j,ii,jj,n,itype,jnum,joriginal,flip,tmp; + int *surf,*jlist; + + int *type = atom->type; + int nlocal = atom->nlocal; + + int *ilist = list->ilist; + int *numneigh = list->numneigh; + int **firstneigh = list->firstneigh; + MyPage *ipage = list->ipage; + + int *ilist_skip = list->listskip->ilist; + int *numneigh_skip = list->listskip->numneigh; + int **firstneigh_skip = list->listskip->firstneigh; + int inum_skip = list->listskip->inum; + + int *iskip = list->iskip; + int **ijskip = list->ijskip; + + if (domain->dimension == 2) surf = atom->line; + else surf = atom->tri; + + int inum = 0; + ipage->reset(); + + // two loops over parent list required, one to count, one to store + // because onesided constraint means pair I,J may be stored with I or J + // so don't know in advance how much space to alloc for each atom's neighs + + // first loop over atoms in other list to count neighbors + // skip I atom entirely if iskip is set for type[I] + // skip I,J pair if ijskip is set for type[I],type[J] + + for (i = 0; i < nlocal; i++) numneigh[i] = 0; + + for (ii = 0; ii < inum_skip; ii++) { + i = ilist_skip[ii]; + itype = type[i]; + if (iskip[itype]) continue; + + n = 0; + + // loop over parent non-skip size list + + jlist = firstneigh_skip[i]; + jnum = numneigh_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + + // flip I,J if necessary to satisfy onesided constraint + // do not keep if I is now ghost + + if (surf[i] >= 0) { + if (j >= nlocal) continue; + tmp = i; + i = j; + j = tmp; + flip = 1; + } else flip = 0; + + numneigh[i]++; + if (flip) i = j; + } + } + + // allocate all per-atom neigh list chunks + + for (i = 0; i < nlocal; i++) { + if (numneigh[i] == 0) continue; + n = numneigh[i]; + firstneigh[i] = ipage->get(n); + if (ipage->status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + // second loop over atoms in other list to store neighbors + // skip I atom entirely if iskip is set for type[I] + // skip I,J pair if ijskip is set for type[I],type[J] + + for (i = 0; i < nlocal; i++) numneigh[i] = 0; + + for (ii = 0; ii < inum_skip; ii++) { + i = ilist_skip[ii]; + itype = type[i]; + if (iskip[itype]) continue; + + // loop over parent non-skip size list and optionally its history info + + jlist = firstneigh_skip[i]; + jnum = numneigh_skip[i]; + + for (jj = 0; jj < jnum; jj++) { + joriginal = jlist[jj]; + j = joriginal & NEIGHMASK; + if (ijskip[itype][type[j]]) continue; + + // flip I,J if necessary to satisfy onesided constraint + // do not keep if I is now ghost + + if (surf[i] >= 0) { + if (j >= nlocal) continue; + tmp = i; + i = j; + j = tmp; + flip = 1; + } else flip = 0; + + // store j in neigh list, not joriginal, like other neigh methods + // OK, b/c there is no special list flagging for surfs + + firstneigh[i][numneigh[i]] = j; + numneigh[i]++; + if (flip) i = j; + } + + // only add atom I to ilist if it has neighbors + + if (numneigh[i]) ilist[inum++] = i; + } + + list->inum = inum; +} diff --git a/src/npair_skip_size_off2on_oneside.h b/src/npair_skip_size_off2on_oneside.h new file mode 100644 index 0000000000..3f1cd6ef34 --- /dev/null +++ b/src/npair_skip_size_off2on_oneside.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- ---------------------------------------------------------- + LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator + https://www.lammps.org/, Sandia National Laboratories + Steve Plimpton, sjplimp@sandia.gov + + 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 +NPairStyle(skip/size/off2on/oneside, + NPairSkipSizeOff2onOneside, + NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | + NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_SKIP_SIZE_OFF2ON_ONESIDE_H +#define LMP_NPAIR_SKIP_SIZE_OFF2ON_ONESIDE_H + +#include "npair.h" + +namespace LAMMPS_NS { + +class NPairSkipSizeOff2onOneside : public NPair { + public: + NPairSkipSizeOff2onOneside(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif + +/* ERROR/WARNING messages: + +E: Neighbor list overflow, boost neigh_modify one + +UNDOCUMENTED + +*/ diff --git a/src/nstencil_ghost_bin.h b/src/nstencil_ghost_bin.h index 31268cc30d..cab6e6714c 100644 --- a/src/nstencil_ghost_bin.h +++ b/src/nstencil_ghost_bin.h @@ -16,32 +16,32 @@ typedef NStencilGhostBin<0, 0, 0> NStencilFullGhostBin2d; NStencilStyle(full/ghost/bin/2d, NStencilFullGhostBin2d, - NS_FULL | NS_GhostBin | NS_2D | NS_ORTHO | NS_TRI); + NS_FULL | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_TRI); typedef NStencilGhostBin<0, 1, 0> NStencilFullGhostBin3d; NStencilStyle(full/ghost/bin/3d, NStencilFullGhostBin3d, - NS_FULL | NS_GhostBin | NS_3D | NS_ORTHO | NS_TRI); + NS_FULL | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_TRI); typedef NStencilGhostBin<1, 0, 0> NStencilHalfGhostBin2d; NStencilStyle(half/ghost/bin/2d, NStencilHalfGhostBin2d, - NS_HALF | NS_GhostBin | NS_2D | NS_ORTHO); + NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO); typedef NStencilGhostBin<1, 0, 1> NStencilHalfGhostBin2dTri; NStencilStyle(half/ghost/bin/2d/tri, NStencilHalfGhostBin2dTri, - NS_HALF | NS_GhostBin | NS_2D | NS_TRI); + NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_TRI); typedef NStencilGhostBin<1, 1, 0> NStencilHalfGhostBin3d; NStencilStyle(half/ghost/bin/3d, NStencilHalfGhostBin3d, - NS_HALF | NS_GhostBin | NS_3D | NS_ORTHO); + NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO); typedef NStencilGhostBin<1, 1, 1> NStencilHalfGhostBin3dTri; NStencilStyle(half/ghost/bin/3d/tri, NStencilHalfGhostBin3dTri, - NS_HALF | NS_GhostBin | NS_3D | NS_TRI); + NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_TRI); // clang-format on #else From 6544fbd248e9a8a6486ca01422610f054ddb09c3 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 30 Oct 2022 21:04:31 -0600 Subject: [PATCH 05/87] Fixing compilation mistake, updating dev reference --- src/npair_bin.cpp | 4 ++-- src/npair_bin.h | 10 +--------- src/npair_bin_atomonly.cpp | 4 ++-- src/npair_bin_atomonly.h | 10 +--------- src/npair_multi_old.cpp | 10 +++++----- src/npair_nsq.cpp | 5 +++-- src/npair_nsq_ghost.cpp | 1 + src/npair_respa_bin.cpp | 4 ++-- 8 files changed, 17 insertions(+), 31 deletions(-) diff --git a/src/npair_bin.cpp b/src/npair_bin.cpp index 83f8c53ecc..41f4575444 100644 --- a/src/npair_bin.cpp +++ b/src/npair_bin.cpp @@ -1,8 +1,8 @@ // clang-format off -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 diff --git a/src/npair_bin.h b/src/npair_bin.h index 92e3243397..e9cd65fa34 100644 --- a/src/npair_bin.h +++ b/src/npair_bin.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -75,11 +75,3 @@ class NPairBin : public NPair { #endif #endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_bin_atomonly.cpp b/src/npair_bin_atomonly.cpp index 3b15580264..f658a44b60 100644 --- a/src/npair_bin_atomonly.cpp +++ b/src/npair_bin_atomonly.cpp @@ -1,8 +1,8 @@ // clang-format off -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 diff --git a/src/npair_bin_atomonly.h b/src/npair_bin_atomonly.h index 581700af7d..febe7c2f0e 100644 --- a/src/npair_bin_atomonly.h +++ b/src/npair_bin_atomonly.h @@ -1,7 +1,7 @@ /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -75,11 +75,3 @@ class NPairBinAtomonly : public NPair { #endif #endif - -/* ERROR/WARNING messages: - -E: Neighbor list overflow, boost neigh_modify one - -UNDOCUMENTED - -*/ diff --git a/src/npair_multi_old.cpp b/src/npair_multi_old.cpp index 28efc16797..3c61d4ba29 100644 --- a/src/npair_multi_old.cpp +++ b/src/npair_multi_old.cpp @@ -1,8 +1,8 @@ // clang-format off -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -56,7 +56,7 @@ void NPairMultiOld::build(NeighList *list) double xtmp,ytmp,ztmp,delx,dely,delz,rsq; double radsum,cut,cutsq; int *neighptr,*s; - double *cutsq,*distsq; + double *cutnsq,*distsq; double **x = atom->x; double *radius = atom->radius; @@ -103,7 +103,7 @@ void NPairMultiOld::build(NeighList *list) ibin = atom2bin[i]; s = stencil_multi_old[itype]; distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; + cutnsq = cutneighsq[itype]; ns = nstencil_multi_old[itype]; for (k = 0; k < ns; k++) { bin_start = binhead[ibin+stencil[k]]; @@ -158,7 +158,7 @@ void NPairMultiOld::build(NeighList *list) } jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; + if (cutnsq[jtype] < distsq[k]) continue; if (i == j) continue; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; diff --git a/src/npair_nsq.cpp b/src/npair_nsq.cpp index 87a05e8136..77dafe6191 100644 --- a/src/npair_nsq.cpp +++ b/src/npair_nsq.cpp @@ -1,8 +1,8 @@ // clang-format off -/* ---------------------------------------------------------------------- +/* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories - Steve Plimpton, sjplimp@sandia.gov + 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 @@ -16,6 +16,7 @@ #include "neigh_list.h" #include "atom.h" #include "atom_vec.h" +#include "group.h" #include "molecule.h" #include "neighbor.h" #include "domain.h" diff --git a/src/npair_nsq_ghost.cpp b/src/npair_nsq_ghost.cpp index 8ff34accf8..e9cc732e7d 100644 --- a/src/npair_nsq_ghost.cpp +++ b/src/npair_nsq_ghost.cpp @@ -16,6 +16,7 @@ #include "neigh_list.h" #include "atom.h" #include "atom_vec.h" +#include "group.h" #include "molecule.h" #include "neighbor.h" #include "domain.h" diff --git a/src/npair_respa_bin.cpp b/src/npair_respa_bin.cpp index 2f39ad547c..a3bcbf5124 100644 --- a/src/npair_respa_bin.cpp +++ b/src/npair_respa_bin.cpp @@ -116,14 +116,14 @@ void NPairRespaBin::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin+stencil[k]]; if (stencil[k] == 0) { - if (HALF && NEWTON && (!TRI)) { + if (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 = binstart; j >= 0; j = bins[j]) { + for (j = bin_start; j >= 0; j = bins[j]) { if (!NEWTON) { // Half neighbor list, newton off // only store pair if i < j From c5181bb7c80ee3c28d2aec63e602d7745e384ef5 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 11 Nov 2022 16:56:21 -0700 Subject: [PATCH 06/87] 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 From 11f3195b0c5a582d933d01f44d5a7e32145401eb Mon Sep 17 00:00:00 2001 From: jtclemm Date: Fri, 11 Nov 2022 20:35:52 -0700 Subject: [PATCH 07/87] Fixing more oversights in npair classes --- src/npair_nsq.h | 14 ++++++-------- src/npair_nsq_ghost.cpp | 9 ++++++--- src/npair_nsq_ghost.h | 6 +++--- src/npair_respa_nsq.cpp | 4 ++-- src/npair_skip.h | 5 ----- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/npair_nsq.h b/src/npair_nsq.h index 505a72ea03..749ea3a78c 100644 --- a/src/npair_nsq.h +++ b/src/npair_nsq.h @@ -16,8 +16,7 @@ typedef NPairNsq<0, 1, 0> NPairFullNsq; NPairStyle(full/nsq, NPairFullNsq, - NP_FULL | NP_NSQ | NP_MOLONLY | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_FULL | NP_NSQ | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); typedef NPairNsq<1, 0, 0> NPairHalfNsqNewtoff; NPairStyle(half/nsq/newtoff, @@ -27,13 +26,12 @@ NPairStyle(half/nsq/newtoff, typedef NPairNsq<1, 1, 0> NPairHalfNsqNewton; NPairStyle(half/nsq/newton, NPairHalfNsqNewton, - NP_HALF | NP_NSQ | NP_MOLONLY | NP_NEWTON | NP_ORTHO | NP_TRI); + NP_HALF | NP_NSQ | NP_NEWTON | NP_ORTHO | NP_TRI); typedef NPairNsq<0, 1, 1> NPairFullSizeNsq; NPairStyle(full/size/nsq, NPairFullSizeNsq, - NP_FULL | NP_SIZE | NP_NSQ | NP_MOLONLY | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + NP_FULL | NP_SIZE | NP_NSQ | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); typedef NPairNsq<1, 0, 1> NPairHalfSizeNsqNewtoff; NPairStyle(half/size/nsq/newtoff, @@ -43,13 +41,13 @@ NPairStyle(half/size/nsq/newtoff, typedef NPairNsq<1, 1, 1> NPairHalfSizeNsqNewton; NPairStyle(half/size/nsq/newton, NPairHalfSizeNsqNewton, - NP_HALF | NP_SIZE | NP_NSQ | NP_MOLONLY | NP_NEWTON | NP_ORTHO | NP_TRI); + NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTON | NP_ORTHO | NP_TRI); // clang-format on #else -#ifndef LMP_NPAIR_Nsq_H -#define LMP_NPAIR_Nsq_H +#ifndef LMP_NPAIR_NSQ_H +#define LMP_NPAIR_NSQ_H #include "npair.h" diff --git a/src/npair_nsq_ghost.cpp b/src/npair_nsq_ghost.cpp index e9cc732e7d..5e4185f9d6 100644 --- a/src/npair_nsq_ghost.cpp +++ b/src/npair_nsq_ghost.cpp @@ -106,8 +106,8 @@ void NPairNsqGhost::build(NeighList *list) // stores ghost/ghost pairs only once // no molecular test when i = ghost atom - if (!HALF) jstart = 0; - else jstart = i + 1; + if (HALF) jstart = i + 1; + else jstart = 0; if (i < nlocal) { for (j = jstart; j < nall; j++) { @@ -155,7 +155,10 @@ void NPairNsqGhost::build(NeighList *list) delz = ztmp - x[j][2]; rsq = delx * delx + dely * dely + delz * delz; - if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + if (HALF) { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } else { + if (rsq <= cutneighghostsq[itype][jtype]) neighptr[n++] = j; } } diff --git a/src/npair_nsq_ghost.h b/src/npair_nsq_ghost.h index 79dfce0c9c..516f0bd929 100644 --- a/src/npair_nsq_ghost.h +++ b/src/npair_nsq_ghost.h @@ -18,9 +18,9 @@ NPairStyle(full/nsq/ghost, NPairFullNsqGhost, NP_FULL | NP_NSQ | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); -typedef NPairNsqGhost<1> NPairHalfNsqGhostNewtoff; -NPairStyle(half/nsq/ghost/newtoff, - NPairHalfNsqGhostNewtoff, +typedef NPairNsqGhost<1> NPairHalfNsqNewtoffGhost; +NPairStyle(half/nsq/newtoff/ghost, + NPairHalfNsqNewtoffGhost, NP_HALF | NP_NSQ | NP_NEWTOFF | NP_GHOST | NP_ORTHO | NP_TRI); // clang-format on #else diff --git a/src/npair_respa_nsq.cpp b/src/npair_respa_nsq.cpp index ce73d534c8..7c816f305b 100644 --- a/src/npair_respa_nsq.cpp +++ b/src/npair_respa_nsq.cpp @@ -119,14 +119,14 @@ void NPairRespaNsq::build(NeighList *list) // loop over remaining atoms, owned and ghost - for (j = i+1; j < nall; j++) { + for (j = i + 1; j < nall; j++) { if (includegroup && !(mask[j] & bitmask)) continue; if (NEWTON) { if (j >= nlocal) { jtag = tag[j]; if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; + if ((itag + jtag) % 2 == 0) continue; } else if (itag < jtag) { if ((itag+jtag) % 2 == 1) continue; } else { diff --git a/src/npair_skip.h b/src/npair_skip.h index 6eaf03e1c5..4e85174730 100644 --- a/src/npair_skip.h +++ b/src/npair_skip.h @@ -24,11 +24,6 @@ NPairStyle(skip/ghost, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST); - -NPairStyle(skip/half/size, - NPairSkip, - NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); // clang-format on #else From b0dcaa38231ed1188f89a04ac7e20ea5f01e4bab Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 12 Nov 2022 16:18:11 -0700 Subject: [PATCH 08/87] Updating OPENMP package --- src/OPENMP/npair_bin_atomonly_omp.cpp | 195 ++++++++++++++ src/OPENMP/npair_bin_atomonly_omp.h | 78 ++++++ ..._ghost_omp.cpp => npair_bin_ghost_omp.cpp} | 49 +++- ..._bin_ghost_omp.h => npair_bin_ghost_omp.h} | 18 +- src/OPENMP/npair_bin_omp.cpp | 237 +++++++++++++++++ src/OPENMP/npair_bin_omp.h | 77 ++++++ src/OPENMP/npair_full_bin_atomonly_omp.cpp | 106 -------- src/OPENMP/npair_full_bin_atomonly_omp.h | 39 --- src/OPENMP/npair_full_bin_omp.cpp | 135 ---------- src/OPENMP/npair_full_bin_omp.h | 39 --- src/OPENMP/npair_full_multi_old_omp.cpp | 144 ---------- src/OPENMP/npair_full_multi_old_omp.h | 39 --- src/OPENMP/npair_full_multi_omp.cpp | 154 ----------- src/OPENMP/npair_full_multi_omp.h | 39 --- src/OPENMP/npair_full_nsq_ghost_omp.h | 39 --- src/OPENMP/npair_full_nsq_omp.cpp | 134 ---------- src/OPENMP/npair_full_nsq_omp.h | 39 --- .../npair_half_bin_atomonly_newton_omp.cpp | 126 --------- .../npair_half_bin_atomonly_newton_omp.h | 38 --- .../npair_half_bin_newtoff_ghost_omp.cpp | 174 ------------ src/OPENMP/npair_half_bin_newtoff_ghost_omp.h | 39 --- src/OPENMP/npair_half_bin_newtoff_omp.cpp | 139 ---------- src/OPENMP/npair_half_bin_newtoff_omp.h | 38 --- src/OPENMP/npair_half_bin_newton_omp.cpp | 172 ------------ src/OPENMP/npair_half_bin_newton_omp.h | 38 --- src/OPENMP/npair_half_bin_newton_tri_omp.cpp | 145 ---------- src/OPENMP/npair_half_bin_newton_tri_omp.h | 38 --- src/OPENMP/npair_half_multi_newtoff_omp.cpp | 157 ----------- src/OPENMP/npair_half_multi_newtoff_omp.h | 38 --- src/OPENMP/npair_half_multi_newton_omp.cpp | 205 --------------- src/OPENMP/npair_half_multi_newton_omp.h | 38 --- .../npair_half_multi_newton_tri_omp.cpp | 171 ------------ src/OPENMP/npair_half_multi_newton_tri_omp.h | 38 --- .../npair_half_multi_old_newtoff_omp.cpp | 146 ----------- src/OPENMP/npair_half_multi_old_newtoff_omp.h | 38 --- .../npair_half_multi_old_newton_omp.cpp | 179 ------------- src/OPENMP/npair_half_multi_old_newton_omp.h | 38 --- .../npair_half_multi_old_newton_tri_omp.cpp | 155 ----------- .../npair_half_multi_old_newton_tri_omp.h | 38 --- .../npair_half_nsq_newtoff_ghost_omp.cpp | 158 ----------- src/OPENMP/npair_half_nsq_newtoff_omp.cpp | 134 ---------- src/OPENMP/npair_half_nsq_newtoff_omp.h | 38 --- src/OPENMP/npair_half_nsq_newton_omp.cpp | 152 ----------- src/OPENMP/npair_half_nsq_newton_omp.h | 38 --- .../npair_half_respa_bin_newtoff_omp.cpp | 203 -------------- src/OPENMP/npair_half_respa_bin_newtoff_omp.h | 39 --- .../npair_half_respa_bin_newton_tri_omp.cpp | 210 --------------- .../npair_half_respa_bin_newton_tri_omp.h | 38 --- src/OPENMP/npair_half_respa_nsq_newtoff_omp.h | 39 --- .../npair_half_respa_nsq_newton_omp.cpp | 216 --------------- .../npair_half_size_bin_newtoff_omp.cpp | 151 ----------- src/OPENMP/npair_half_size_bin_newtoff_omp.h | 39 --- src/OPENMP/npair_half_size_bin_newton_omp.cpp | 187 ------------- src/OPENMP/npair_half_size_bin_newton_omp.h | 38 --- .../npair_half_size_bin_newton_tri_omp.cpp | 158 ----------- .../npair_half_size_bin_newton_tri_omp.h | 38 --- .../npair_half_size_multi_newtoff_omp.cpp | 172 ------------ .../npair_half_size_multi_newtoff_omp.h | 38 --- .../npair_half_size_multi_newton_omp.cpp | 225 ---------------- src/OPENMP/npair_half_size_multi_newton_omp.h | 38 --- .../npair_half_size_multi_newton_tri_omp.cpp | 187 ------------- .../npair_half_size_multi_newton_tri_omp.h | 38 --- .../npair_half_size_multi_old_newtoff_omp.cpp | 158 ----------- .../npair_half_size_multi_old_newtoff_omp.h | 39 --- .../npair_half_size_multi_old_newton_omp.h | 38 --- ...air_half_size_multi_old_newton_tri_omp.cpp | 166 ------------ ...npair_half_size_multi_old_newton_tri_omp.h | 38 --- .../npair_half_size_nsq_newtoff_omp.cpp | 147 ----------- src/OPENMP/npair_half_size_nsq_newtoff_omp.h | 39 --- src/OPENMP/npair_half_size_nsq_newton_omp.cpp | 166 ------------ src/OPENMP/npair_half_size_nsq_newton_omp.h | 39 --- src/OPENMP/npair_halffull_newtoff_omp.cpp | 90 ------- src/OPENMP/npair_halffull_newtoff_omp.h | 44 ---- src/OPENMP/npair_halffull_newtoff_trim_omp.h | 44 ---- src/OPENMP/npair_halffull_newton_omp.cpp | 107 -------- src/OPENMP/npair_halffull_newton_omp.h | 44 ---- src/OPENMP/npair_halffull_newton_trim_omp.cpp | 120 --------- src/OPENMP/npair_halffull_newton_trim_omp.h | 44 ---- ...ff_trim_omp.cpp => npair_halffull_omp.cpp} | 67 +++-- src/OPENMP/npair_halffull_omp.h | 107 ++++++++ src/OPENMP/npair_multi_old_omp.cpp | 243 +++++++++++++++++ src/OPENMP/npair_multi_old_omp.h | 77 ++++++ src/OPENMP/npair_multi_omp.cpp | 247 ++++++++++++++++++ src/OPENMP/npair_multi_omp.h | 75 ++++++ ..._ghost_omp.cpp => npair_nsq_ghost_omp.cpp} | 59 ++++- ...toff_ghost_omp.h => npair_nsq_ghost_omp.h} | 18 +- ...i_old_newton_omp.cpp => npair_nsq_omp.cpp} | 176 +++++++------ src/OPENMP/npair_nsq_omp.h | 66 +++++ ...newton_omp.cpp => npair_respa_bin_omp.cpp} | 134 +++++----- ...bin_newton_omp.h => npair_respa_bin_omp.h} | 22 +- ...ewtoff_omp.cpp => npair_respa_nsq_omp.cpp} | 48 +++- ...nsq_newton_omp.h => npair_respa_nsq_omp.h} | 18 +- src/npair_bin_ghost.cpp | 1 - src/npair_multi.cpp | 2 +- src/npair_multi_old.cpp | 1 - src/npair_nsq.h | 1 - src/npair_nsq_ghost.cpp | 2 +- src/npair_respa_bin.cpp | 2 +- 98 files changed, 1801 insertions(+), 7211 deletions(-) create mode 100644 src/OPENMP/npair_bin_atomonly_omp.cpp create mode 100644 src/OPENMP/npair_bin_atomonly_omp.h rename src/OPENMP/{npair_full_bin_ghost_omp.cpp => npair_bin_ghost_omp.cpp} (75%) rename src/OPENMP/{npair_full_bin_ghost_omp.h => npair_bin_ghost_omp.h} (67%) create mode 100644 src/OPENMP/npair_bin_omp.cpp create mode 100644 src/OPENMP/npair_bin_omp.h delete mode 100644 src/OPENMP/npair_full_bin_atomonly_omp.cpp delete mode 100644 src/OPENMP/npair_full_bin_atomonly_omp.h delete mode 100644 src/OPENMP/npair_full_bin_omp.cpp delete mode 100644 src/OPENMP/npair_full_bin_omp.h delete mode 100644 src/OPENMP/npair_full_multi_old_omp.cpp delete mode 100644 src/OPENMP/npair_full_multi_old_omp.h delete mode 100644 src/OPENMP/npair_full_multi_omp.cpp delete mode 100644 src/OPENMP/npair_full_multi_omp.h delete mode 100644 src/OPENMP/npair_full_nsq_ghost_omp.h delete mode 100644 src/OPENMP/npair_full_nsq_omp.cpp delete mode 100644 src/OPENMP/npair_full_nsq_omp.h delete mode 100644 src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_bin_atomonly_newton_omp.h delete mode 100644 src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp delete mode 100644 src/OPENMP/npair_half_bin_newtoff_ghost_omp.h delete mode 100644 src/OPENMP/npair_half_bin_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_bin_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_bin_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_bin_newton_omp.h delete mode 100644 src/OPENMP/npair_half_bin_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_bin_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_multi_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_multi_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_multi_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_multi_newton_omp.h delete mode 100644 src/OPENMP/npair_half_multi_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_multi_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_multi_old_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_multi_old_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_multi_old_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_multi_old_newton_omp.h delete mode 100644 src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_multi_old_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp delete mode 100644 src/OPENMP/npair_half_nsq_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_nsq_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_nsq_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_nsq_newton_omp.h delete mode 100644 src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_respa_bin_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_respa_bin_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_respa_nsq_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_respa_nsq_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_bin_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_bin_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_size_bin_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_bin_newton_omp.h delete mode 100644 src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_bin_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_size_multi_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_multi_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_size_multi_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_multi_newton_omp.h delete mode 100644 src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_multi_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_multi_old_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_size_multi_old_newton_omp.h delete mode 100644 src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_multi_old_newton_tri_omp.h delete mode 100644 src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_nsq_newtoff_omp.h delete mode 100644 src/OPENMP/npair_half_size_nsq_newton_omp.cpp delete mode 100644 src/OPENMP/npair_half_size_nsq_newton_omp.h delete mode 100644 src/OPENMP/npair_halffull_newtoff_omp.cpp delete mode 100644 src/OPENMP/npair_halffull_newtoff_omp.h delete mode 100644 src/OPENMP/npair_halffull_newtoff_trim_omp.h delete mode 100644 src/OPENMP/npair_halffull_newton_omp.cpp delete mode 100644 src/OPENMP/npair_halffull_newton_omp.h delete mode 100644 src/OPENMP/npair_halffull_newton_trim_omp.cpp delete mode 100644 src/OPENMP/npair_halffull_newton_trim_omp.h rename src/OPENMP/{npair_halffull_newtoff_trim_omp.cpp => npair_halffull_omp.cpp} (59%) create mode 100644 src/OPENMP/npair_halffull_omp.h create mode 100644 src/OPENMP/npair_multi_old_omp.cpp create mode 100644 src/OPENMP/npair_multi_old_omp.h create mode 100644 src/OPENMP/npair_multi_omp.cpp create mode 100644 src/OPENMP/npair_multi_omp.h rename src/OPENMP/{npair_full_nsq_ghost_omp.cpp => npair_nsq_ghost_omp.cpp} (71%) rename src/OPENMP/{npair_half_nsq_newtoff_ghost_omp.h => npair_nsq_ghost_omp.h} (64%) rename src/OPENMP/{npair_half_size_multi_old_newton_omp.cpp => npair_nsq_omp.cpp} (51%) create mode 100644 src/OPENMP/npair_nsq_omp.h rename src/OPENMP/{npair_half_respa_bin_newton_omp.cpp => npair_respa_bin_omp.cpp} (67%) rename src/OPENMP/{npair_half_respa_bin_newton_omp.h => npair_respa_bin_omp.h} (55%) rename src/OPENMP/{npair_half_respa_nsq_newtoff_omp.cpp => npair_respa_nsq_omp.cpp} (81%) rename src/OPENMP/{npair_half_respa_nsq_newton_omp.h => npair_respa_nsq_omp.h} (63%) diff --git a/src/OPENMP/npair_bin_atomonly_omp.cpp b/src/OPENMP/npair_bin_atomonly_omp.cpp new file mode 100644 index 0000000000..2fe3baa014 --- /dev/null +++ b/src/OPENMP/npair_bin_atomonly_omp.cpp @@ -0,0 +1,195 @@ +// 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 "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" +#include "npair_omp.h" + +#include "omp_compat.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; + + 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; + 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 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]; + + // loop over all atoms in surrounding bins in stencil including self + // skip i = j + + 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[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 new file mode 100644 index 0000000000..c488486898 --- /dev/null +++ b/src/OPENMP/npair_bin_atomonly_omp.h @@ -0,0 +1,78 @@ +/* -*- 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_full_bin_ghost_omp.cpp b/src/OPENMP/npair_bin_ghost_omp.cpp similarity index 75% rename from src/OPENMP/npair_full_bin_ghost_omp.cpp rename to src/OPENMP/npair_bin_ghost_omp.cpp index 5723a418f5..8f3105dc75 100644 --- a/src/OPENMP/npair_full_bin_ghost_omp.cpp +++ b/src/OPENMP/npair_bin_ghost_omp.cpp @@ -13,7 +13,7 @@ ------------------------------------------------------------------------- */ #include "omp_compat.h" -#include "npair_full_bin_ghost_omp.h" +#include "npair_bin_ghost_omp.h" #include "npair_omp.h" #include "neigh_list.h" #include "atom.h" @@ -27,15 +27,25 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairFullBinGhostOmp::NPairFullBinGhostOmp(LAMMPS *lmp) : NPair(lmp) {} +template +NPairBinGhostOmp::NPairBinGhostOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - include neighbors of ghost atoms, but no "special neighbors" for ghosts - every neighbor pair appears in list of both atoms i and j + Full: + binned neighbor list construction for all neighbors + include neighbors of ghost atoms, but no "special neighbors" for ghosts + every neighbor pair appears in list of both atoms i and j + Half + Newtoff: + binned neighbor list construction with partial Newton's 3rd law + include neighbors of ghost atoms, but no "special neighbors" for ghosts + owned and ghost atoms check own bin and other bins in stencil + pair stored once if i,j are both owned and i < j + pair stored by me if i owned and j ghost (also stored by proc owning j) + pair stored once if i,j are both ghost and i < j ------------------------------------------------------------------------- */ -void NPairFullBinGhostOmp::build(NeighList *list) +template +void NPairBinGhostOmp::build(NeighList *list) { const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; @@ -48,7 +58,7 @@ void NPairFullBinGhostOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nall); - int i,j,k,n,itype,jtype,ibin,which,imol,iatom; + int i,j,k,n,itype,jtype,ibin,bin_start,which,imol,iatom; tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int xbin,ybin,zbin,xbin2,ybin2,zbin2; @@ -93,14 +103,24 @@ void NPairFullBinGhostOmp::build(NeighList *list) // loop over all atoms in surrounding bins in stencil including self // when i is a ghost atom, must check if stencil bin is out of bounds - // skip i = j // no molecular test when i = ghost atom if (i < nlocal) { ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) continue; + 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]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -138,7 +158,11 @@ void NPairFullBinGhostOmp::build(NeighList *list) ybin2 < 0 || ybin2 >= mbiny || zbin2 < 0 || zbin2 >= mbinz) continue; for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) continue; + if (HALF) { + if (j <= i) continue; + } else { + if (i == j) continue; + } jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -164,3 +188,8 @@ void NPairFullBinGhostOmp::build(NeighList *list) list->inum = nlocal; list->gnum = nall - nlocal; } + +namespace LAMMPS_NS { +template class NPairBinGhostOmp<0>; +template class NPairBinGhostOmp<1>; +} diff --git a/src/OPENMP/npair_full_bin_ghost_omp.h b/src/OPENMP/npair_bin_ghost_omp.h similarity index 67% rename from src/OPENMP/npair_full_bin_ghost_omp.h rename to src/OPENMP/npair_bin_ghost_omp.h index 6de134dcf8..df18886e91 100644 --- a/src/OPENMP/npair_full_bin_ghost_omp.h +++ b/src/OPENMP/npair_bin_ghost_omp.h @@ -13,23 +13,29 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairBinGhostOmp<0> NPairFullBinGhostOmp; NPairStyle(full/bin/ghost/omp, NPairFullBinGhostOmp, - NP_FULL | NP_BIN | NP_GHOST | NP_OMP | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); + NP_FULL | NP_BIN | NP_GHOST | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairBinGhostOmp<1> NPairHalfBinNewtoffGhostOmp; +NPairStyle(half/bin/newtoff/ghost/omp, + NPairHalfBinNewtoffGhostOmp, + NP_HALF | NP_BIN | NP_GHOST | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); // clang-format on #else -#ifndef LMP_NPAIR_FULL_BIN_GHOST_OMP_H -#define LMP_NPAIR_FULL_BIN_GHOST_OMP_H +#ifndef LMP_NPAIR_BIN_GHOST_OMP_H +#define LMP_NPAIR_BIN_GHOST_OMP_H #include "npair.h" namespace LAMMPS_NS { -class NPairFullBinGhostOmp : public NPair { +template +class NPairBinGhostOmp : public NPair { public: - NPairFullBinGhostOmp(class LAMMPS *); + NPairBinGhostOmp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/OPENMP/npair_bin_omp.cpp b/src/OPENMP/npair_bin_omp.cpp new file mode 100644 index 0000000000..7029f71df7 --- /dev/null +++ b/src/OPENMP/npair_bin_omp.cpp @@ -0,0 +1,237 @@ +// 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 "omp_compat.h" +#include "npair_bin_omp.h" +#include "npair_omp.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "molecule.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairBinOmp::NPairBinOmp(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 NPairBinOmp::build(NeighList *list) +{ + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int molecular = atom->molecular; + const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; + + 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,which,imol,iatom; + tagint tagprev; + 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 *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + + 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]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } + + // loop over all atoms in surrounding bins in stencil including self + // skip i = j + + 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; + + 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; + } + } + } + } + + 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 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>; +} diff --git a/src/OPENMP/npair_bin_omp.h b/src/OPENMP/npair_bin_omp.h new file mode 100644 index 0000000000..595b789d92 --- /dev/null +++ b/src/OPENMP/npair_bin_omp.h @@ -0,0 +1,77 @@ +/* -*- 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 NPairBinOmp<0, 1, 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; +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; +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; +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; +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; +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; +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; +NPairStyle(half/size/bin/newton/tri/omp, + NPairHalfSizeBinNewtonTriOmp, + NP_HALF | NP_SIZE | NP_BIN | NP_OMP | NP_MOLONLY | NP_NEWTON | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_BIN_OMP_H +#define LMP_NPAIR_BIN_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairBinOmp : public NPair { + public: + NPairBinOmp(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/OPENMP/npair_full_bin_atomonly_omp.cpp b/src/OPENMP/npair_full_bin_atomonly_omp.cpp deleted file mode 100644 index 0a37cca287..0000000000 --- a/src/OPENMP/npair_full_bin_atomonly_omp.cpp +++ /dev/null @@ -1,106 +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_full_bin_atomonly_omp.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullBinAtomonlyOmp::NPairFullBinAtomonlyOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullBinAtomonlyOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - - 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]; - - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) 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]) 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; - list->gnum = 0; -} diff --git a/src/OPENMP/npair_full_bin_atomonly_omp.h b/src/OPENMP/npair_full_bin_atomonly_omp.h deleted file mode 100644 index 50b1aa753c..0000000000 --- a/src/OPENMP/npair_full_bin_atomonly_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(full/bin/atomonly/omp, - NPairFullBinAtomonlyOmp, - NP_FULL | NP_BIN | NP_ATOMONLY | NP_OMP | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_BIN_ATOMONLY_OMP_H -#define LMP_NPAIR_FULL_BIN_ATOMONLY_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullBinAtomonlyOmp : public NPair { - public: - NPairFullBinAtomonlyOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_full_bin_omp.cpp b/src/OPENMP/npair_full_bin_omp.cpp deleted file mode 100644 index 94668002a9..0000000000 --- a/src/OPENMP/npair_full_bin_omp.cpp +++ /dev/null @@ -1,135 +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 "omp_compat.h" -#include "npair_full_bin_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullBinOmp::NPairFullBinOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullBinOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (i == j) 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 != 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; - } - } - } - - 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; - list->gnum = 0; -} diff --git a/src/OPENMP/npair_full_bin_omp.h b/src/OPENMP/npair_full_bin_omp.h deleted file mode 100644 index 333025a1fb..0000000000 --- a/src/OPENMP/npair_full_bin_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(full/bin/omp, - NPairFullBinOmp, - NP_FULL | NP_BIN | NP_OMP | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_BIN_OMP_H -#define LMP_NPAIR_FULL_BIN_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullBinOmp : public NPair { - public: - NPairFullBinOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_full_multi_old_omp.cpp b/src/OPENMP/npair_full_multi_old_omp.cpp deleted file mode 100644 index f0ed6360ab..0000000000 --- a/src/OPENMP/npair_full_multi_old_omp.cpp +++ /dev/null @@ -1,144 +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_full_multi_old_omp.h" -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullMultiOldOmp::NPairFullMultiOldOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - multi-type stencil is itype dependent and is distance checked - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullMultiOldOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i, j, k, n, itype, jtype, ibin, which, ns, imol, iatom; - tagint tagprev; - double xtmp, ytmp, ztmp, delx, dely, delz, rsq; - int *neighptr, *s; - double *cutsq, *distsq; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil, including self - // skip if i,j neighbor cutoff is less than bin distance - // skip i = j - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin + s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - if (i == j) continue; - - 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 != 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; - } - } - } - - 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; - list->gnum = 0; -} diff --git a/src/OPENMP/npair_full_multi_old_omp.h b/src/OPENMP/npair_full_multi_old_omp.h deleted file mode 100644 index 5d9f4c2f88..0000000000 --- a/src/OPENMP/npair_full_multi_old_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(full/multi/old/omp, - NPairFullMultiOldOmp, - NP_FULL | NP_MULTI_OLD | NP_OMP | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_MULTI_OLD_OMP_H -#define LMP_NPAIR_FULL_MULTI_OLD_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullMultiOldOmp : public NPair { - public: - NPairFullMultiOldOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_full_multi_omp.cpp b/src/OPENMP/npair_full_multi_omp.cpp deleted file mode 100644 index 1e39838381..0000000000 --- a/src/OPENMP/npair_full_multi_omp.cpp +++ /dev/null @@ -1,154 +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 "omp_compat.h" -#include "npair_full_multi_omp.h" -#include "npair_omp.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullMultiOmp::NPairFullMultiOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - multi stencil is icollection-jcollection dependent - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullMultiOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - // use full stencil for all collection combinations - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - if (i == j) 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 != 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; - } - } - } - } - - 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; - list->gnum = 0; -} diff --git a/src/OPENMP/npair_full_multi_omp.h b/src/OPENMP/npair_full_multi_omp.h deleted file mode 100644 index 0d71bf7bc6..0000000000 --- a/src/OPENMP/npair_full_multi_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(full/multi/omp, - NPairFullMultiOmp, - NP_FULL | NP_MULTI | NP_OMP | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_MULTI_OMP_H -#define LMP_NPAIR_FULL_MULTI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullMultiOmp : public NPair { - public: - NPairFullMultiOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_full_nsq_ghost_omp.h b/src/OPENMP/npair_full_nsq_ghost_omp.h deleted file mode 100644 index 448354d4ba..0000000000 --- a/src/OPENMP/npair_full_nsq_ghost_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(full/nsq/ghost/omp, - NPairFullNsqGhostOmp, - NP_FULL | NP_NSQ | NP_GHOST | NP_OMP | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_NSQ_GHOST_OMP_H -#define LMP_NPAIR_FULL_NSQ_GHOST_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullNsqGhostOmp : public NPair { - public: - NPairFullNsqGhostOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_full_nsq_omp.cpp b/src/OPENMP/npair_full_nsq_omp.cpp deleted file mode 100644 index 6349906771..0000000000 --- a/src/OPENMP/npair_full_nsq_omp.cpp +++ /dev/null @@ -1,134 +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 "omp_compat.h" -#include "npair_full_nsq_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullNsqOmp::NPairFullNsqOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 search for all neighbors - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullNsqOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,n,itype,jtype,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int nall = atom->nlocal + atom->nghost; - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms, owned and ghost - // skip i = j - - for (j = 0; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) continue; - if (i == j) 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 != 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; - } - } - - 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; - list->gnum = 0; -} diff --git a/src/OPENMP/npair_full_nsq_omp.h b/src/OPENMP/npair_full_nsq_omp.h deleted file mode 100644 index 53e913a18c..0000000000 --- a/src/OPENMP/npair_full_nsq_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(full/nsq/omp, - NPairFullNsqOmp, - NP_FULL | NP_NSQ | NP_OMP | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_NSQ_OMP_H -#define LMP_NPAIR_FULL_NSQ_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairFullNsqOmp : public NPair { - public: - NPairFullNsqOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp b/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp deleted file mode 100644 index 1bc1199628..0000000000 --- a/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp +++ /dev/null @@ -1,126 +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_half_bin_atomonly_newton_omp.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinAtomonlyNewtonOmp::NPairHalfBinAtomonlyNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - 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 -------------------------------------------------------------------------- */ - -void NPairHalfBinAtomonlyNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - - 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(); - - 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]; - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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]) neighptr[n++] = j; - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; 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]) 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; -} diff --git a/src/OPENMP/npair_half_bin_atomonly_newton_omp.h b/src/OPENMP/npair_half_bin_atomonly_newton_omp.h deleted file mode 100644 index dcec3aeee2..0000000000 --- a/src/OPENMP/npair_half_bin_atomonly_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/bin/atomonly/newton/omp, - NPairHalfBinAtomonlyNewtonOmp, - NP_HALF | NP_BIN | NP_ATOMONLY | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_ATOMONLY_NEWTON_OMP_H -#define LMP_NPAIR_HALF_BIN_ATOMONLY_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinAtomonlyNewtonOmp : public NPair { - public: - NPairHalfBinAtomonlyNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp b/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp deleted file mode 100644 index 2255033204..0000000000 --- a/src/OPENMP/npair_half_bin_newtoff_ghost_omp.cpp +++ /dev/null @@ -1,174 +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 "omp_compat.h" -#include "npair_half_bin_newtoff_ghost_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtoffGhostOmp::NPairHalfBinNewtoffGhostOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with partial Newton's 3rd law - include neighbors of ghost atoms, but no "special neighbors" for ghosts - owned and ghost atoms check own bin and other bins in stencil - pair stored once if i,j are both owned and i < j - pair stored by me if i owned and j ghost (also stored by proc owning j) - pair stored once if i,j are both ghost and i < j -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtoffGhostOmp::build(NeighList *list) -{ - const int nlocal = atom->nlocal; - const int nall = nlocal + atom->nghost; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nall); - - int i,j,k,n,itype,jtype,ibin,which,imol,iatom; - tagint tagprev; - int xbin,ybin,zbin,xbin2,ybin2,zbin2; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // when i is a ghost atom, must check if stencil bin is out of bounds - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs with owned atom only, on both procs - // stores ghost/ghost pairs only once - // no molecular test when i = ghost atom - - if (i < nlocal) { - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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 { - ibin = coord2bin(x[i],xbin,ybin,zbin); - for (k = 0; k < nstencil; k++) { - xbin2 = xbin + stencilxyz[k][0]; - ybin2 = ybin + stencilxyz[k][1]; - zbin2 = zbin + stencilxyz[k][2]; - if (xbin2 < 0 || xbin2 >= mbinx || - ybin2 < 0 || ybin2 >= mbiny || - zbin2 < 0 || zbin2 >= mbinz) continue; - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 <= cutneighghostsq[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; - list->gnum = nall - atom->nlocal; -} diff --git a/src/OPENMP/npair_half_bin_newtoff_ghost_omp.h b/src/OPENMP/npair_half_bin_newtoff_ghost_omp.h deleted file mode 100644 index 0258320f88..0000000000 --- a/src/OPENMP/npair_half_bin_newtoff_ghost_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/bin/newtoff/ghost/omp, - NPairHalfBinNewtoffGhostOmp, - NP_HALF | NP_BIN | NP_NEWTOFF | NP_GHOST | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTOFF_GHOST_OMP_H -#define LMP_NPAIR_HALF_BIN_NEWTOFF_GHOST_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtoffGhostOmp : public NPair { - public: - NPairHalfBinNewtoffGhostOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_bin_newtoff_omp.cpp b/src/OPENMP/npair_half_bin_newtoff_omp.cpp deleted file mode 100644 index 36997d9bcb..0000000000 --- a/src/OPENMP/npair_half_bin_newtoff_omp.cpp +++ /dev/null @@ -1,139 +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 "omp_compat.h" -#include "npair_half_bin_newtoff_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtoffOmp::NPairHalfBinNewtoffOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - 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) -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - ibin = atom2bin[i]; - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_bin_newtoff_omp.h b/src/OPENMP/npair_half_bin_newtoff_omp.h deleted file mode 100644 index e5d3034667..0000000000 --- a/src/OPENMP/npair_half_bin_newtoff_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/bin/newtoff/omp, - NPairHalfBinNewtoffOmp, - NP_HALF | NP_BIN | NP_NEWTOFF | NP_OMP | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_BIN_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtoffOmp : public NPair { - public: - NPairHalfBinNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_bin_newton_omp.cpp b/src/OPENMP/npair_half_bin_newton_omp.cpp deleted file mode 100644 index 1663a2f14c..0000000000 --- a/src/OPENMP/npair_half_bin_newton_omp.cpp +++ /dev/null @@ -1,172 +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 "omp_compat.h" -#include "npair_half_bin_newton_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtonOmp::NPairHalfBinNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - 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 -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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 != 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); - // OLD: if (which >= 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - } - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; 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 != 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); - // OLD: if (which >= 0) neighptr[n++] = j ^ (which << SBBITS); - } else 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; -} diff --git a/src/OPENMP/npair_half_bin_newton_omp.h b/src/OPENMP/npair_half_bin_newton_omp.h deleted file mode 100644 index 68064cdf45..0000000000 --- a/src/OPENMP/npair_half_bin_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/bin/newton/omp, - NPairHalfBinNewtonOmp, - NP_HALF | NP_BIN | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTON_OMP_H -#define LMP_NPAIR_HALF_BIN_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtonOmp : public NPair { - public: - NPairHalfBinNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_bin_newton_tri_omp.cpp b/src/OPENMP/npair_half_bin_newton_tri_omp.cpp deleted file mode 100644 index e754456ef1..0000000000 --- a/src/OPENMP/npair_half_bin_newton_tri_omp.cpp +++ /dev/null @@ -1,145 +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 "omp_compat.h" -#include "npair_half_bin_newton_tri_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtonTriOmp::NPairHalfBinNewtonTriOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins in stencil - // 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 - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - 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; - } - } - - 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 != 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_bin_newton_tri_omp.h b/src/OPENMP/npair_half_bin_newton_tri_omp.h deleted file mode 100644 index 90d5af5db1..0000000000 --- a/src/OPENMP/npair_half_bin_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/bin/newton/tri/omp, - NPairHalfBinNewtonTriOmp, - NP_HALF | NP_BIN | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_BIN_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtonTriOmp : public NPair { - public: - NPairHalfBinNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_multi_newtoff_omp.cpp b/src/OPENMP/npair_half_multi_newtoff_omp.cpp deleted file mode 100644 index 1b65653f76..0000000000 --- a/src/OPENMP/npair_half_multi_newtoff_omp.cpp +++ /dev/null @@ -1,157 +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 "omp_compat.h" -#include "npair_half_multi_newtoff_omp.h" -#include "npair_omp.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiNewtoffOmp::NPairHalfMultiNewtoffOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with partial Newton's 3rd law - multi stencil is icollection-jcollection dependent - 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) -------------------------------------------------------------------------- */ - -void NPairHalfMultiNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - // use full stencil for all collection combinations - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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; - } - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_multi_newtoff_omp.h b/src/OPENMP/npair_half_multi_newtoff_omp.h deleted file mode 100644 index 658f41f926..0000000000 --- a/src/OPENMP/npair_half_multi_newtoff_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/multi/newtoff/omp, - NPairHalfMultiNewtoffOmp, - NP_HALF | NP_MULTI | NP_NEWTOFF | NP_OMP | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_MULTI_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiNewtoffOmp : public NPair { - public: - NPairHalfMultiNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_multi_newton_omp.cpp b/src/OPENMP/npair_half_multi_newton_omp.cpp deleted file mode 100644 index 8add1d3703..0000000000 --- a/src/OPENMP/npair_half_multi_newton_omp.cpp +++ /dev/null @@ -1,205 +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 "omp_compat.h" -#include "npair_half_multi_newton_omp.h" -#include "npair_omp.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiNewtonOmp::NPairHalfMultiNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with full Newton's 3rd law - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in Newton stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // if same size: uses half stencil so check central bin - if (cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - - if (icollection == jcollection) js = bins[i]; - else js = binhead_multi[jcollection][jbin]; - - // if same collection, - // 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 different collections, - // if j is owned atom, store it if j > i - // if j is ghost, only store if j coords are "above and to the right" of i - - for (j = js; j >= 0; j = bins[j]) { - if ((icollection != jcollection) && (j < i)) continue; - - 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; - } - } - } - - // for all collections, loop over all atoms in other bins in stencil, store every pair - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; 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 != 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; - } - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_multi_newton_omp.h b/src/OPENMP/npair_half_multi_newton_omp.h deleted file mode 100644 index 44bee84653..0000000000 --- a/src/OPENMP/npair_half_multi_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/multi/newton/omp, - NPairHalfMultiNewtonOmp, - NP_HALF | NP_MULTI | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_NEWTON_OMP_H -#define LMP_NPAIR_HALF_MULTI_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiNewtonOmp : public NPair { - public: - NPairHalfMultiNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_multi_newton_tri_omp.cpp b/src/OPENMP/npair_half_multi_newton_tri_omp.cpp deleted file mode 100644 index a152d011a7..0000000000 --- a/src/OPENMP/npair_half_multi_newton_tri_omp.cpp +++ /dev/null @@ -1,171 +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 "omp_compat.h" -#include "npair_half_multi_newton_tri_omp.h" -#include "npair_omp.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiNewtonTriOmp::NPairHalfMultiNewtonTriOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,jbin,icollection,jcollection,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - 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; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in bins in stencil - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - // if half: 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 - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - - // if same size (same collection), use half stencil - if (cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - 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; - } - } - } - - 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 != 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; - } - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_multi_newton_tri_omp.h b/src/OPENMP/npair_half_multi_newton_tri_omp.h deleted file mode 100644 index 21731f4f0b..0000000000 --- a/src/OPENMP/npair_half_multi_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/multi/newton/tri/omp, - NPairHalfMultiNewtonTriOmp, - NP_HALF | NP_MULTI | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_MULTI_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiNewtonTriOmp : public NPair { - public: - NPairHalfMultiNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp b/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp deleted file mode 100644 index ac5e9dae04..0000000000 --- a/src/OPENMP/npair_half_multi_old_newtoff_omp.cpp +++ /dev/null @@ -1,146 +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 "omp_compat.h" -#include "npair_half_multi_old_newtoff_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiOldNewtoffOmp::NPairHalfMultiOldNewtoffOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and other bins in stencil - multi-type stencil is itype dependent and is distance checked - 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) -------------------------------------------------------------------------- */ - -void NPairHalfMultiOldNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // skip if i,j neighbor cutoff is less than bin distance - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - if (j <= i) continue; - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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 != 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_multi_old_newtoff_omp.h b/src/OPENMP/npair_half_multi_old_newtoff_omp.h deleted file mode 100644 index 26484d6c5b..0000000000 --- a/src/OPENMP/npair_half_multi_old_newtoff_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/multi/old/newtoff/omp, - NPairHalfMultiOldNewtoffOmp, - NP_HALF | NP_MULTI_OLD | NP_NEWTOFF | NP_OMP | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_OLD_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_MULTI_OLD_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiOldNewtoffOmp : public NPair { - public: - NPairHalfMultiOldNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_multi_old_newton_omp.cpp b/src/OPENMP/npair_half_multi_old_newton_omp.cpp deleted file mode 100644 index baa9dd0724..0000000000 --- a/src/OPENMP/npair_half_multi_old_newton_omp.cpp +++ /dev/null @@ -1,179 +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 "omp_compat.h" -#include "npair_half_multi_old_newton_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiOldNewtonOmp::NPairHalfMultiOldNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with full Newton's 3rd law - each owned atom i checks its own bin and other bins in Newton stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiOldNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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 != 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; - } - } - - // loop over all atoms in other bins in stencil, store every pair - // skip if i,j neighbor cutoff is less than bin distance - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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 != 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_multi_old_newton_omp.h b/src/OPENMP/npair_half_multi_old_newton_omp.h deleted file mode 100644 index 8182b49bd7..0000000000 --- a/src/OPENMP/npair_half_multi_old_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/multi/old/newton/omp, - NPairHalfMultiOldNewtonOmp, - NP_HALF | NP_MULTI_OLD | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_OLD_NEWTON_OMP_H -#define LMP_NPAIR_HALF_MULTI_OLD_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiOldNewtonOmp : public NPair { - public: - NPairHalfMultiOldNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp b/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp deleted file mode 100644 index e4895ff1a9..0000000000 --- a/src/OPENMP/npair_half_multi_old_newton_tri_omp.cpp +++ /dev/null @@ -1,155 +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 "omp_compat.h" -#include "npair_half_multi_old_newton_tri_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfMultiOldNewtonTriOmp::NPairHalfMultiOldNewtonTriOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfMultiOldNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,which,ns,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*s; - double *cutsq,*distsq; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins, including self, in stencil - // skip if i,j neighbor cutoff is less than bin distance - // bins below self are excluded from stencil - // 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 - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - 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]; - dely = ytmp - x[j][1]; - 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_multi_old_newton_tri_omp.h b/src/OPENMP/npair_half_multi_old_newton_tri_omp.h deleted file mode 100644 index 5efb007dc1..0000000000 --- a/src/OPENMP/npair_half_multi_old_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/multi/old/newton/tri/omp, - NPairHalfMultiOldNewtonTriOmp, - NP_HALF | NP_MULTI_OLD | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_MULTI_OLD_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_MULTI_OLD_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfMultiOldNewtonTriOmp : public NPair { - public: - NPairHalfMultiOldNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp b/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp deleted file mode 100644 index 388e51e1af..0000000000 --- a/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.cpp +++ /dev/null @@ -1,158 +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 "omp_compat.h" -#include "npair_half_nsq_newtoff_ghost_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfNsqNewtoffGhostOmp::NPairHalfNsqNewtoffGhostOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - include neighbors of ghost atoms, but no "special neighbors" for ghosts - pair stored once if i,j are both owned and i < j - pair stored by me if i owned and j ghost (also stored by proc owning j) - pair stored once if i,j are both ghost and i < j -------------------------------------------------------------------------- */ - -void NPairHalfNsqNewtoffGhostOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int nall = nlocal + atom->nghost; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nall); - - int i,j,n,itype,jtype,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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 & ghost 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs with owned atom only, on both procs - // stores ghost/ghost pairs only once - // no molecular test when i = ghost atom - - if (i < nlocal) { - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 != 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 { - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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]) 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 = atom->nlocal; - list->gnum = nall - atom->nlocal; -} diff --git a/src/OPENMP/npair_half_nsq_newtoff_omp.cpp b/src/OPENMP/npair_half_nsq_newtoff_omp.cpp deleted file mode 100644 index 002ea37e6b..0000000000 --- a/src/OPENMP/npair_half_nsq_newtoff_omp.cpp +++ /dev/null @@ -1,134 +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 "omp_compat.h" -#include "npair_half_nsq_newtoff_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfNsqNewtoffOmp::NPairHalfNsqNewtoffOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - 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) -------------------------------------------------------------------------- */ - -void NPairHalfNsqNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int nall = atom->nlocal + atom->nghost; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,n,itype,jtype,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - // only store pair if i < j - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 != 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; - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_nsq_newtoff_omp.h b/src/OPENMP/npair_half_nsq_newtoff_omp.h deleted file mode 100644 index 47a03750f7..0000000000 --- a/src/OPENMP/npair_half_nsq_newtoff_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/nsq/newtoff/omp, - NPairHalfNsqNewtoffOmp, - NP_HALF | NP_NSQ | NP_NEWTOFF | NP_OMP | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_NSQ_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_NSQ_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfNsqNewtoffOmp : public NPair { - public: - NPairHalfNsqNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_nsq_newton_omp.cpp b/src/OPENMP/npair_half_nsq_newton_omp.cpp deleted file mode 100644 index cb08cb7f7a..0000000000 --- a/src/OPENMP/npair_half_nsq_newton_omp.cpp +++ /dev/null @@ -1,152 +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 "omp_compat.h" -#include "npair_half_nsq_newton_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfNsqNewtonOmp::NPairHalfNsqNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - N^2 / 2 search for neighbor pairs with full Newton's 3rd law - every pair stored exactly once by some processor - decision on ghost atoms based on itag,jtag tests -------------------------------------------------------------------------- */ - -void NPairHalfNsqNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,n,itype,jtype,itag,jtag,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - int nall = atom->nlocal + atom->nghost; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itag = tag[i]; - itype = type[i]; - 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; - } - - // loop over remaining atoms, owned and ghost - // itag = jtag is possible for long cutoffs that include images of self - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 (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 != 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; - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_nsq_newton_omp.h b/src/OPENMP/npair_half_nsq_newton_omp.h deleted file mode 100644 index 00e975d389..0000000000 --- a/src/OPENMP/npair_half_nsq_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/nsq/newton/omp, - NPairHalfNsqNewtonOmp, - NP_HALF | NP_NSQ | NP_NEWTON | NP_OMP | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_NSQ_NEWTON_OMP_H -#define LMP_NPAIR_HALF_NSQ_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfNsqNewtonOmp : public NPair { - public: - NPairHalfNsqNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp b/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp deleted file mode 100644 index c6be04419d..0000000000 --- a/src/OPENMP/npair_half_respa_bin_newtoff_omp.cpp +++ /dev/null @@ -1,203 +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 "omp_compat.h" -#include "npair_half_respa_bin_newtoff_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaBinNewtoffOmp::NPairHalfRespaBinNewtoffOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and surrounding bins in non-Newton 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) -------------------------------------------------------------------------- */ - -void NPairHalfRespaBinNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; - - const int respamiddle = list->respamiddle; - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - } - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - MyPage &ipage_inner = list->ipage_inner[tid]; - ipage.reset(); - ipage_inner.reset(); - - MyPage *ipage_middle; - if (respamiddle) { - ipage_middle = list->ipage_middle + tid; - ipage_middle->reset(); - } - - int which = 0; - int minchange = 0; - - for (i = ifrom; i < ito; i++) { - - n = n_inner = 0; - neighptr = ipage.vget(); - neighptr_inner = ipage_inner.vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itype = type[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - ibin = atom2bin[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in surrounding bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) 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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) - neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - } - - 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"); - - ilist_inner[i] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage.vgot(n_inner); - if (ipage_inner.status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[i] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - } - NPAIR_OMP_CLOSE; - list->inum = nlocal; - list->inum_inner = nlocal; - if (respamiddle) list->inum_middle = nlocal; -} diff --git a/src/OPENMP/npair_half_respa_bin_newtoff_omp.h b/src/OPENMP/npair_half_respa_bin_newtoff_omp.h deleted file mode 100644 index 8ad6209d21..0000000000 --- a/src/OPENMP/npair_half_respa_bin_newtoff_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/respa/bin/newtoff/omp, - NPairHalfRespaBinNewtoffOmp, - NP_HALF | NP_RESPA | NP_BIN | NP_NEWTOFF | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_BIN_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_RESPA_BIN_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaBinNewtoffOmp : public NPair { - public: - NPairHalfRespaBinNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp b/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp deleted file mode 100644 index c998f71290..0000000000 --- a/src/OPENMP/npair_half_respa_bin_newton_tri_omp.cpp +++ /dev/null @@ -1,210 +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 "omp_compat.h" -#include "npair_half_respa_bin_newton_tri_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaBinNewtonTriOmp::NPairHalfRespaBinNewtonTriOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfRespaBinNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; - - const int respamiddle = list->respamiddle; - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - } - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - MyPage &ipage_inner = list->ipage_inner[tid]; - ipage.reset(); - ipage_inner.reset(); - - MyPage *ipage_middle; - if (respamiddle) { - ipage_middle = list->ipage_middle + tid; - ipage_middle->reset(); - } - - int which = 0; - int minchange = 0; - - for (i = ifrom; i < ito; i++) { - - n = n_inner = 0; - neighptr = ipage.vget(); - neighptr_inner = ipage_inner.vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itype = type[i]; - 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; - } - - // loop over all atoms in bins in stencil - // 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 - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - 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; - } - } - - 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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) - neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - } - - 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"); - - ilist_inner[i] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner.vgot(n_inner); - if (ipage_inner.status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[i] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - } - NPAIR_OMP_CLOSE; - list->inum = nlocal; - list->inum_inner = nlocal; - if (respamiddle) list->inum_middle = nlocal; -} diff --git a/src/OPENMP/npair_half_respa_bin_newton_tri_omp.h b/src/OPENMP/npair_half_respa_bin_newton_tri_omp.h deleted file mode 100644 index df45372960..0000000000 --- a/src/OPENMP/npair_half_respa_bin_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/respa/bin/newton/tri/omp, - NPairHalfRespaBinNewtonTriOmp, - NP_HALF | NP_RESPA | NP_BIN | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_BIN_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_RESPA_BIN_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaBinNewtonTriOmp : public NPair { - public: - NPairHalfRespaBinNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_respa_nsq_newtoff_omp.h b/src/OPENMP/npair_half_respa_nsq_newtoff_omp.h deleted file mode 100644 index abd28fd51b..0000000000 --- a/src/OPENMP/npair_half_respa_nsq_newtoff_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/respa/nsq/newtoff/omp, - NPairHalfRespaNsqNewtoffOmp, - NP_HALF | NP_RESPA | NP_NSQ | NP_NEWTOFF | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_RESPA_NSQ_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_RESPA_NSQ_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfRespaNsqNewtoffOmp : public NPair { - public: - NPairHalfRespaNsqNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp b/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp deleted file mode 100644 index 6604861f74..0000000000 --- a/src/OPENMP/npair_half_respa_nsq_newton_omp.cpp +++ /dev/null @@ -1,216 +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 "omp_compat.h" -#include "npair_half_respa_nsq_newton_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "group.h" -#include "molecule.h" -#include "domain.h" -#include "my_page.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfRespaNsqNewtonOmp::NPairHalfRespaNsqNewtonOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - multiple respa lists - N^2 / 2 search for neighbor pairs with full Newton's 3rd law - pair added to list if atoms i and j are both owned and i < j - if j is ghost only me or other proc adds pair - decision based on itag,jtag tests -------------------------------------------------------------------------- */ - -void NPairHalfRespaNsqNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - - NPAIR_OMP_INIT; - - const int respamiddle = list->respamiddle; - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,n,itype,jtype,itag,jtag,n_inner,n_middle,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - int *neighptr,*neighptr_inner,*neighptr_middle; - - // loop over each atom, storing neighbors - - double **x = atom->x; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - int nall = atom->nlocal + atom->nghost; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - } - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - MyPage &ipage_inner = list->ipage_inner[tid]; - ipage.reset(); - ipage_inner.reset(); - - MyPage *ipage_middle; - if (respamiddle) { - ipage_middle = list->ipage_middle + tid; - ipage_middle->reset(); - } - - int which = 0; - int minchange = 0; - - for (i = ifrom; i < ito; i++) { - - n = n_inner = 0; - neighptr = ipage.vget(); - neighptr_inner = ipage_inner.vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - itag = tag[i]; - itype = type[i]; - 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; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 (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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - - 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"); - - ilist_inner[i] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage.vgot(n_inner); - if (ipage_inner.status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[i] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n_middle); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - } - NPAIR_OMP_CLOSE; - list->inum = nlocal; - list->inum_inner = nlocal; - if (respamiddle) list->inum_middle = nlocal; -} diff --git a/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp b/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp deleted file mode 100644 index c205b67539..0000000000 --- a/src/OPENMP/npair_half_size_bin_newtoff_omp.cpp +++ /dev/null @@ -1,151 +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_half_size_bin_newtoff_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeBinNewtoffOmp::NPairHalfSizeBinNewtoffOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and surrounding bins in non-Newton 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) -------------------------------------------------------------------------- */ - -void NPairHalfSizeBinNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - ibin = atom2bin[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in surrounding bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (j <= i) continue; - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_bin_newtoff_omp.h b/src/OPENMP/npair_half_size_bin_newtoff_omp.h deleted file mode 100644 index a91836b152..0000000000 --- a/src/OPENMP/npair_half_size_bin_newtoff_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/size/bin/newtoff/omp, - NPairHalfSizeBinNewtoffOmp, - NP_HALF | NP_SIZE | NP_BIN | NP_NEWTOFF | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_BIN_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_SIZE_BIN_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeBinNewtoffOmp : public NPair { - public: - NPairHalfSizeBinNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_bin_newton_omp.cpp b/src/OPENMP/npair_half_size_bin_newton_omp.cpp deleted file mode 100644 index 628057d41d..0000000000 --- a/src/OPENMP/npair_half_size_bin_newton_omp.cpp +++ /dev/null @@ -1,187 +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_half_size_bin_newton_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeBinNewtonOmp::NPairHalfSizeBinNewtonOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - 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 -------------------------------------------------------------------------- */ - -void NPairHalfSizeBinNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,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; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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; - } - } - - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_bin_newton_omp.h b/src/OPENMP/npair_half_size_bin_newton_omp.h deleted file mode 100644 index efc554bb3c..0000000000 --- a/src/OPENMP/npair_half_size_bin_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/bin/newton/omp, - NPairHalfSizeBinNewtonOmp, - NP_HALF | NP_SIZE | NP_BIN | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_BIN_NEWTON_OMP_H -#define LMP_NPAIR_HALF_SIZE_BIN_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeBinNewtonOmp : public NPair { - public: - NPairHalfSizeBinNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp deleted file mode 100644 index c320296442..0000000000 --- a/src/OPENMP/npair_half_size_bin_newton_tri_omp.cpp +++ /dev/null @@ -1,158 +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_half_size_bin_newton_tri_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeBinNewtonTriOmp::NPairHalfSizeBinNewtonTriOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeBinNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,ibin,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutsq; - int *neighptr; - - // loop over each atom, storing neighbors - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins in stencil - // 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 - - ibin = atom2bin[i]; - for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { - 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,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_bin_newton_tri_omp.h b/src/OPENMP/npair_half_size_bin_newton_tri_omp.h deleted file mode 100644 index 65b46395ca..0000000000 --- a/src/OPENMP/npair_half_size_bin_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/bin/newton/tri/omp, - NPairHalfSizeBinNewtonTriOmp, - NP_HALF | NP_SIZE | NP_BIN | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_BIN_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_SIZE_BIN_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeBinNewtonTriOmp : public NPair { - public: - NPairHalfSizeBinNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp b/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp deleted file mode 100644 index 73564a150c..0000000000 --- a/src/OPENMP/npair_half_size_multi_newtoff_omp.cpp +++ /dev/null @@ -1,172 +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_half_size_multi_newtoff_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiNewtoffOmp::NPairHalfSizeMultiNewtoffOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with partial Newton's 3rd law - multi stencil is icollection-jcollection dependent - 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) -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,icollection,jcollection,ibin,jbin,ns; - int which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if(icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // stores own/own pairs only once - // stores own/ghost pairs on both procs - // use full stencil for all collection combinations - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >=0; j = bins[j]) { - if (j <= i) 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) { - 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; - } - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_multi_newtoff_omp.h b/src/OPENMP/npair_half_size_multi_newtoff_omp.h deleted file mode 100644 index 2e58d9ea38..0000000000 --- a/src/OPENMP/npair_half_size_multi_newtoff_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/multi/newtoff/omp, - NPairHalfSizeMultiNewtoffOmp, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTOFF | NP_OMP | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiNewtoffOmp : public NPair { - public: - NPairHalfSizeMultiNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_multi_newton_omp.cpp b/src/OPENMP/npair_half_size_multi_newton_omp.cpp deleted file mode 100644 index 0ed843ea0b..0000000000 --- a/src/OPENMP/npair_half_size_multi_newton_omp.cpp +++ /dev/null @@ -1,225 +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_half_size_multi_newton_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiNewtonOmp::NPairHalfSizeMultiNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with full Newton's 3rd law - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in Newton stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,icollection,jcollection,ibin,jbin,ns; - int which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if(icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - // if same size: uses half stencil so check central bin - if(cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - - if(icollection == jcollection) js = bins[i]; - else js = binhead_multi[jcollection][jbin]; - - // if same collection, - // 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 different collections, - // if j is owned atom, store it if j > i - // if j is ghost, only store if j coords are "above and to the right" of i - - for (j = js; j >= 0; j = bins[j]) { - if(icollection != jcollection && j < i) continue; - - 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) { - 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; - } - } - } - - // for all collections, loop over all atoms in other bins in stencil, store every pair - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; 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; - radsum = radi + radius[j]; - cutdistsq = (radsum+skin) * (radsum+skin); - - if (rsq <= cutdistsq) { - if (history && rsq < radsum*radsum) - j = j ^ 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++] = 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; - } - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_multi_newton_omp.h b/src/OPENMP/npair_half_size_multi_newton_omp.h deleted file mode 100644 index 99f9174913..0000000000 --- a/src/OPENMP/npair_half_size_multi_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/multi/newton/omp, - NPairHalfSizeMultiNewtonOmp, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_OMP_H -#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiNewtonOmp : public NPair { - public: - NPairHalfSizeMultiNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp deleted file mode 100644 index 9a0ead482b..0000000000 --- a/src/OPENMP/npair_half_size_multi_newton_tri_omp.cpp +++ /dev/null @@ -1,187 +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_half_size_multi_newton_tri_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiNewtonTriOmp::NPairHalfSizeMultiNewtonTriOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with Newton's 3rd law for triclinic - multi stencil is icollection-jcollection dependent - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,icollection,jcollection,ibin,jbin,ns; - int which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - int js; - - // loop over each atom, storing neighbors - - int *collection = neighbor->collection; - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itype = type[i]; - icollection = collection[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - ibin = atom2bin[i]; - - // loop through stencils for all collections - for (jcollection = 0; jcollection < ncollections; jcollection++) { - - // if same collection use own bin - if(icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); - - - // loop over all atoms in bins in stencil - // stencil is empty if i larger than j - // stencil is half if i same size as j - // stencil is full if i smaller than j - // if half: 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 - - s = stencil_multi[icollection][jcollection]; - ns = nstencil_multi[icollection][jcollection]; - - for (k = 0; k < ns; k++) { - js = binhead_multi[jcollection][jbin + s[k]]; - for (j = js; j >= 0; j = bins[j]) { - - // if same size (same collection), use half stencil - if(cutcollectionsq[icollection][icollection] == cutcollectionsq[jcollection][jcollection]){ - 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; - } - } - } - - 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) { - 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; - } - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_multi_newton_tri_omp.h b/src/OPENMP/npair_half_size_multi_newton_tri_omp.h deleted file mode 100644 index d4f6eacc27..0000000000 --- a/src/OPENMP/npair_half_size_multi_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/multi/newton/tri/omp, - NPairHalfSizeMultiNewtonTriOmp, - NP_HALF | NP_SIZE | NP_MULTI | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_SIZE_MULTI_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiNewtonTriOmp : public NPair { - public: - NPairHalfSizeMultiNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp deleted file mode 100644 index c368e71095..0000000000 --- a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp +++ /dev/null @@ -1,158 +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_half_size_multi_old_newtoff_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiOldNewtoffOmp::NPairHalfSizeMultiOldNewtoffOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with partial Newton's 3rd law - each owned atom i checks own bin and other bins in stencil - multi-type stencil is itype dependent and is distance checked - 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) -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiOldNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,ns,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in other bins in stencil including self - // only store pair if i < j - // skip if i,j neighbor cutoff is less than bin distance - // stores own/own pairs only once - // stores own/ghost pairs on both procs - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - if (j <= i) continue; - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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) { - 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.h b/src/OPENMP/npair_half_size_multi_old_newtoff_omp.h deleted file mode 100644 index 05eb0a5269..0000000000 --- a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/size/multi/old/newtoff/omp, - NPairHalfSizeMultiOldNewtoffOmp, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTOFF | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiOldNewtoffOmp : public NPair { - public: - NPairHalfSizeMultiOldNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_multi_old_newton_omp.h b/src/OPENMP/npair_half_size_multi_old_newton_omp.h deleted file mode 100644 index 70ae082dbb..0000000000 --- a/src/OPENMP/npair_half_size_multi_old_newton_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/multi/old/newton/omp, - NPairHalfSizeMultiOldNewtonOmp, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_OMP | NP_ORTHO); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_OMP_H -#define LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiOldNewtonOmp : public NPair { - public: - NPairHalfSizeMultiOldNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp deleted file mode 100644 index c74b191f66..0000000000 --- a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp +++ /dev/null @@ -1,166 +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_half_size_multi_old_newton_tri_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeMultiOldNewtonTriOmp::NPairHalfSizeMultiOldNewtonTriOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfSizeMultiOldNewtonTriOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - 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,ns,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - double *cutsq,*distsq; - - double **x = atom->x; - double *radius = atom->radius; - int *type = atom->type; - int *mask = atom->mask; - tagint *tag = atom->tag; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - 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]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over all atoms in bins, including self, in stencil - // skip if i,j neighbor cutoff is less than bin distance - // bins below self are excluded from stencil - // 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 - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - 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]; - 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) { - 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; - } - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.h b/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.h deleted file mode 100644 index 3c1765b668..0000000000 --- a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.h +++ /dev/null @@ -1,38 +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 -NPairStyle(half/size/multi/old/newton/tri/omp, - NPairHalfSizeMultiOldNewtonTriOmp, - NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_NEWTON | NP_TRI | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_TRI_OMP_H -#define LMP_NPAIR_HALF_SIZE_MULTI_OLD_NEWTON_TRI_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeMultiOldNewtonTriOmp : public NPair { - public: - NPairHalfSizeMultiOldNewtonTriOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp b/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp deleted file mode 100644 index 020551bd8e..0000000000 --- a/src/OPENMP/npair_half_size_nsq_newtoff_omp.cpp +++ /dev/null @@ -1,147 +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_half_size_nsq_newtoff_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "group.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeNsqNewtoffOmp::NPairHalfSizeNsqNewtoffOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - shear history must be accounted for when a neighbor pair is added - pair added to list if atoms i and j are both owned and i < j - pair added if j is ghost (also stored by proc owning j) -------------------------------------------------------------------------- */ - -void NPairHalfSizeNsqNewtoffOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - NPAIR_OMP_INIT; - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,jh,n,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,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; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int nall = atom->nlocal + atom->nghost; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) continue; - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_nsq_newtoff_omp.h b/src/OPENMP/npair_half_size_nsq_newtoff_omp.h deleted file mode 100644 index 93f038eed4..0000000000 --- a/src/OPENMP/npair_half_size_nsq_newtoff_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/size/nsq/newtoff/omp, - NPairHalfSizeNsqNewtoffOmp, - NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTOFF | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_NSQ_NEWTOFF_OMP_H -#define LMP_NPAIR_HALF_SIZE_NSQ_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeNsqNewtoffOmp : public NPair { - public: - NPairHalfSizeNsqNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_half_size_nsq_newton_omp.cpp b/src/OPENMP/npair_half_size_nsq_newton_omp.cpp deleted file mode 100644 index 35dc42ec5b..0000000000 --- a/src/OPENMP/npair_half_size_nsq_newton_omp.cpp +++ /dev/null @@ -1,166 +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_half_size_nsq_newton_omp.h" - -#include "atom.h" -#include "atom_vec.h" -#include "domain.h" -#include "error.h" -#include "molecule.h" -#include "group.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfSizeNsqNewtonOmp::NPairHalfSizeNsqNewtonOmp(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - size particles - N^2 / 2 search for neighbor pairs with full Newton's 3rd law - shear history must be accounted for when a neighbor pair is added - pair added to list if atoms i and j are both owned and i < j - if j is ghost only me or other proc adds pair - decision based on itag,jtag tests -------------------------------------------------------------------------- */ - -void NPairHalfSizeNsqNewtonOmp::build(NeighList *list) -{ - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; - const int molecular = atom->molecular; - const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; - - NPAIR_OMP_INIT; - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(nlocal); - - int i,j,jh,n,itag,jtag,which,imol,iatom; - tagint tagprev; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutsq; - int *neighptr; - - double **x = atom->x; - double *radius = atom->radius; - tagint *tag = atom->tag; - int *type = atom->type; - int *mask = atom->mask; - tagint *molecule = atom->molecule; - tagint **special = atom->special; - int **nspecial = atom->nspecial; - - int *molindex = atom->molindex; - int *molatom = atom->molatom; - Molecule **onemols = atom->avec->onemols; - - int nall = atom->nlocal + atom->nghost; - - 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(); - - for (i = ifrom; i < ito; i++) { - - n = 0; - neighptr = ipage.vget(); - - itag = tag[i]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - radi = radius[i]; - if (moltemplate) { - imol = molindex[i]; - iatom = molatom[i]; - tagprev = tag[i] - iatom - 1; - } - - // loop over remaining atoms, owned and ghost - - for (j = i+1; j < nall; j++) { - if (includegroup && !(mask[j] & bitmask)) 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 (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; - } - } - } - - if (exclude && exclusion(i,j,type[i],type[j],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]; - cutsq = (radsum+skin) * (radsum+skin); - - 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; - } - } - - 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; -} diff --git a/src/OPENMP/npair_half_size_nsq_newton_omp.h b/src/OPENMP/npair_half_size_nsq_newton_omp.h deleted file mode 100644 index 9a7e912007..0000000000 --- a/src/OPENMP/npair_half_size_nsq_newton_omp.h +++ /dev/null @@ -1,39 +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 -NPairStyle(half/size/nsq/newton/omp, - NPairHalfSizeNsqNewtonOmp, - NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTON | NP_OMP | - NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_SIZE_NSQ_NEWTON_OMP_H -#define LMP_NPAIR_HALF_SIZE_NSQ_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalfSizeNsqNewtonOmp : public NPair { - public: - NPairHalfSizeNsqNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_halffull_newtoff_omp.cpp b/src/OPENMP/npair_halffull_newtoff_omp.cpp deleted file mode 100644 index 379ae149f8..0000000000 --- a/src/OPENMP/npair_halffull_newtoff_omp.cpp +++ /dev/null @@ -1,90 +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_halffull_newtoff_omp.h" - -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalffullNewtoffOmp::NPairHalffullNewtoffOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build half list from full list - 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) - works if full list is a skip list -------------------------------------------------------------------------- */ - -void NPairHalffullNewtoffOmp::build(NeighList *list) -{ - const int inum_full = list->listfull->inum; - - NPAIR_OMP_INIT; - -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(inum_full); - - int i,j,ii,jj,n,jnum,joriginal; - int *neighptr,*jlist; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - int *ilist_full = list->listfull->ilist; - int *numneigh_full = list->listfull->numneigh; - int **firstneigh_full = list->listfull->firstneigh; - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - // loop over atoms in full list - - for (ii = ifrom; ii < ito; ii++) { - - n = 0; - neighptr = ipage.vget(); - - // loop over parent full list - - i = ilist_full[ii]; - jlist = firstneigh_full[i]; - jnum = numneigh_full[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (j > i) neighptr[n++] = joriginal; - } - - ilist[ii] = 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 = inum_full; -} diff --git a/src/OPENMP/npair_halffull_newtoff_omp.h b/src/OPENMP/npair_halffull_newtoff_omp.h deleted file mode 100644 index f0ff24dcf9..0000000000 --- a/src/OPENMP/npair_halffull_newtoff_omp.h +++ /dev/null @@ -1,44 +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 -NPairStyle(halffull/newtoff/omp, - NPairHalffullNewtoffOmp, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI |NP_OMP); - -NPairStyle(halffull/newtoff/skip/omp, - NPairHalffullNewtoffOmp, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTOFF_OMP_H -#define LMP_NPAIR_HALFFULL_NEWTOFF_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalffullNewtoffOmp : public NPair { - public: - NPairHalffullNewtoffOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_halffull_newtoff_trim_omp.h b/src/OPENMP/npair_halffull_newtoff_trim_omp.h deleted file mode 100644 index 19e1c55eeb..0000000000 --- a/src/OPENMP/npair_halffull_newtoff_trim_omp.h +++ /dev/null @@ -1,44 +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 -NPairStyle(halffull/newtoff/trim/omp, - NPairHalffullNewtoffTrimOmp, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); - -NPairStyle(halffull/newtoff/skip/trim/omp, - NPairHalffullNewtoffTrimOmp, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTOFF_TRIM_OMP_H -#define LMP_NPAIR_HALFFULL_NEWTOFF_TRIM_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalffullNewtoffTrimOmp : public NPair { - public: - NPairHalffullNewtoffTrimOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_halffull_newton_omp.cpp b/src/OPENMP/npair_halffull_newton_omp.cpp deleted file mode 100644 index abd5f7eacb..0000000000 --- a/src/OPENMP/npair_halffull_newton_omp.cpp +++ /dev/null @@ -1,107 +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_halffull_newton_omp.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalffullNewtonOmp::NPairHalffullNewtonOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build half list from full list - pair stored once if i,j are both owned and i < j - if j is ghost, only store if j coords are "above and to the right" of i - works if full list is a skip list -------------------------------------------------------------------------- */ - -void NPairHalffullNewtonOmp::build(NeighList *list) -{ - const int inum_full = list->listfull->inum; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(inum_full); - - int i,j,ii,jj,n,jnum,joriginal; - int *neighptr,*jlist; - double xtmp,ytmp,ztmp; - - double **x = atom->x; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - int *ilist_full = list->listfull->ilist; - int *numneigh_full = list->listfull->numneigh; - int **firstneigh_full = list->listfull->firstneigh; - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - // loop over parent full list - - for (ii = ifrom; ii < ito; ii++) { - - n = 0; - neighptr = ipage.vget(); - - i = ilist_full[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - // loop over full neighbor list - - jlist = firstneigh_full[i]; - jnum = numneigh_full[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (j < nlocal) { - if (i > j) continue; - } else { - 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; - } - } - neighptr[n++] = joriginal; - } - - ilist[ii] = 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 = inum_full; -} diff --git a/src/OPENMP/npair_halffull_newton_omp.h b/src/OPENMP/npair_halffull_newton_omp.h deleted file mode 100644 index 3ce9fd9ebe..0000000000 --- a/src/OPENMP/npair_halffull_newton_omp.h +++ /dev/null @@ -1,44 +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 -NPairStyle(halffull/newton/omp, - NPairHalffullNewtonOmp, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_ORTHO | NP_TRI| NP_OMP); - -NPairStyle(halffull/newton/skip/omp, - NPairHalffullNewtonOmp, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_ORTHO | NP_TRI | NP_SKIP | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTON_OMP_H -#define LMP_NPAIR_HALFFULL_NEWTON_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalffullNewtonOmp : public NPair { - public: - NPairHalffullNewtonOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_halffull_newton_trim_omp.cpp b/src/OPENMP/npair_halffull_newton_trim_omp.cpp deleted file mode 100644 index 1446175013..0000000000 --- a/src/OPENMP/npair_halffull_newton_trim_omp.cpp +++ /dev/null @@ -1,120 +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_halffull_newton_trim_omp.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" - -#include "omp_compat.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalffullNewtonTrimOmp::NPairHalffullNewtonTrimOmp(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build half list from full list and trim to shorter cutoff - pair stored once if i,j are both owned and i < j - if j is ghost, only store if j coords are "above and to the right" of i - works if full list is a skip list -------------------------------------------------------------------------- */ - -void NPairHalffullNewtonTrimOmp::build(NeighList *list) -{ - const int inum_full = list->listfull->inum; - - NPAIR_OMP_INIT; -#if defined(_OPENMP) -#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) -#endif - NPAIR_OMP_SETUP(inum_full); - - int i,j,ii,jj,n,jnum,joriginal; - int *neighptr,*jlist; - double xtmp,ytmp,ztmp; - double delx,dely,delz,rsq; - - double **x = atom->x; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - int *ilist_full = list->listfull->ilist; - int *numneigh_full = list->listfull->numneigh; - int **firstneigh_full = list->listfull->firstneigh; - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - double cutsq_custom = cutoff_custom * cutoff_custom; - - // loop over parent full list - - for (ii = ifrom; ii < ito; ii++) { - - n = 0; - neighptr = ipage.vget(); - - i = ilist_full[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - // loop over full neighbor list - - jlist = firstneigh_full[i]; - jnum = numneigh_full[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (j < nlocal) { - if (i > j) continue; - } else { - 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; - } - } - - // trim to shorter cutoff - - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx * delx + dely * dely + delz * delz; - - if (rsq > cutsq_custom) continue; - - neighptr[n++] = joriginal; - } - - ilist[ii] = 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 = inum_full; -} diff --git a/src/OPENMP/npair_halffull_newton_trim_omp.h b/src/OPENMP/npair_halffull_newton_trim_omp.h deleted file mode 100644 index 4cb84f1b3a..0000000000 --- a/src/OPENMP/npair_halffull_newton_trim_omp.h +++ /dev/null @@ -1,44 +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 -NPairStyle(halffull/newton/trim/omp, - NPairHalffullNewtonTrimOmp, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_ORTHO | NP_TRI| NP_TRIM | NP_OMP); - -NPairStyle(halffull/newton/skip/trim/omp, - NPairHalffullNewtonTrimOmp, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_OMP); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTON_TRIM_OMP_H -#define LMP_NPAIR_HALFFULL_NEWTON_TRIM_OMP_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairHalffullNewtonTrimOmp : public NPair { - public: - NPairHalffullNewtonTrimOmp(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/OPENMP/npair_halffull_newtoff_trim_omp.cpp b/src/OPENMP/npair_halffull_omp.cpp similarity index 59% rename from src/OPENMP/npair_halffull_newtoff_trim_omp.cpp rename to src/OPENMP/npair_halffull_omp.cpp index d35b3b2ee8..559d8910b1 100644 --- a/src/OPENMP/npair_halffull_newtoff_trim_omp.cpp +++ b/src/OPENMP/npair_halffull_omp.cpp @@ -12,7 +12,7 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "npair_halffull_newtoff_trim_omp.h" +#include "npair_halffull_omp.h" #include "atom.h" #include "error.h" @@ -26,16 +26,24 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairHalffullNewtoffTrimOmp::NPairHalffullNewtoffTrimOmp(LAMMPS *lmp) : NPair(lmp) {} +template +NPairHalffullOmp::NPairHalffullOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- - build half list from full list and trim to shorter cutoff + build half list from full list 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) works if full list is a skip list + + Newtoff: + pair stored by me if j is ghost (also stored by proc owning j) + works for owned (non-ghost) list, also for ghost list + if ghost, also store neighbors of ghost atoms & set inum,gnum correctly + Newton: + if j is ghost, only store if j coords are "above and to the right" of i ------------------------------------------------------------------------- */ -void NPairHalffullNewtoffTrimOmp::build(NeighList *list) +template +void NPairHalffullOmp::build(NeighList *list) { const int inum_full = list->listfull->inum; @@ -52,6 +60,7 @@ void NPairHalffullNewtoffTrimOmp::build(NeighList *list) double delx,dely,delz,rsq; double **x = atom->x; + int nlocal = atom->nlocal; int *ilist = list->ilist; int *numneigh = list->numneigh; @@ -76,10 +85,6 @@ void NPairHalffullNewtoffTrimOmp::build(NeighList *list) // loop over parent full list i = ilist_full[ii]; - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - jlist = firstneigh_full[i]; jnum = numneigh_full[i]; @@ -87,16 +92,39 @@ void NPairHalffullNewtoffTrimOmp::build(NeighList *list) joriginal = jlist[jj]; j = joriginal & NEIGHMASK; - // trim to shorter cutoff + if (NEWTON) { + if (j < nlocal) { + if (i > j) continue; + } else { + 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; + } + } - delx = xtmp - x[j][0]; - dely = ytmp - x[j][1]; - delz = ztmp - x[j][2]; - rsq = delx * delx + dely * dely + delz * delz; + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; - if (rsq > cutsq_custom) continue; + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; + } else { + if (j > i) { + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; - if (j > i) neighptr[n++] = joriginal; + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; + } + } } ilist[ii] = i; @@ -109,3 +137,10 @@ void NPairHalffullNewtoffTrimOmp::build(NeighList *list) NPAIR_OMP_CLOSE; list->inum = inum_full; } + +namespace LAMMPS_NS { +template class NPairHalffullOmp<0,0>; +template class NPairHalffullOmp<1,0>; +template class NPairHalffullOmp<0,1>; +template class NPairHalffullOmp<1,1>; +} diff --git a/src/OPENMP/npair_halffull_omp.h b/src/OPENMP/npair_halffull_omp.h new file mode 100644 index 0000000000..fca7fe37e8 --- /dev/null +++ b/src/OPENMP/npair_halffull_omp.h @@ -0,0 +1,107 @@ +/* -*- 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 NPairHalffullOmp<0, 0> NPairHalffullOmpNewtoffOmp; +NPairStyle(halffull/newtoff/omp, + NPairHalffullOmpNewtoffOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_OMP); + +typedef NPairHalffullOmp<0, 0> NPairHalffullOmpNewtoffOmp; +NPairStyle(halffull/newtoff/skip/omp, + NPairHalffullOmpNewtoffOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_OMP); + +typedef NPairHalffullOmp<0, 0> NPairHalffullOmpNewtoffOmp; +NPairStyle(halffull/newtoff/ghost/omp, + NPairHalffullOmpNewtoffOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_GHOST | NP_OMP); + +typedef NPairHalffullOmp<0, 0> NPairHalffullOmpNewtoffOmp; +NPairStyle(halffull/newtoff/skip/ghost/omp, + NPairHalffullOmpNewtoffOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_OMP); + +typedef NPairHalffullOmp<1, 0> NPairHalffullOmpNewtonOmp; +NPairStyle(halffull/newton/omp, + NPairHalffullOmpNewtonOmp, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_OMP); + +typedef NPairHalffullOmp<1, 0> NPairHalffullOmpNewtonOmp; +NPairStyle(halffull/newton/skip/omp, + NPairHalffullOmpNewtonOmp, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_SKIP | NP_OMP); + +typedef NPairHalffullOmp<0, 1> NPairHalffullOmpNewtoffTrimOmp; +NPairStyle(halffull/newtoff/trim/omp, + NPairHalffullOmpNewtoffTrimOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +typedef NPairHalffullOmp<0, 1> NPairHalffullOmpNewtoffTrimOmp; +NPairStyle(halffull/newtoff/skip/trim/omp, + NPairHalffullOmpNewtoffTrimOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_OMP); + +typedef NPairHalffullOmp<0, 1> NPairHalffullOmpNewtoffTrimOmp; +NPairStyle(halffull/newtoff/ghost/trim/omp, + NPairHalffullOmpNewtoffTrimOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM | NP_OMP); + +typedef NPairHalffullOmp<0, 1> NPairHalffullOmpNewtoffTrimOmp; +NPairStyle(halffull/newtoff/skip/ghost/trim/omp, + NPairHalffullOmpNewtoffTrimOmp, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_TRIM | NP_OMP); + +typedef NPairHalffullOmp<1, 1> NPairHalffullOmpNewtonTrimOmp; +NPairStyle(halffull/newton/trim/omp, + NPairHalffullOmpNewtonTrimOmp, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +typedef NPairHalffullOmp<1, 1> NPairHalffullOmpNewtonTrimOmp; +NPairStyle(halffull/newton/skip/trim/omp, + NPairHalffullOmpNewtonTrimOmp, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_OMP); +// clang-format on +#else + +#ifndef LMP_NPAIR_HALFFULL_OMP_H +#define LMP_NPAIR_HALFFULL_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairHalffullOmp : public NPair { + public: + NPairHalffullOmp(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/OPENMP/npair_multi_old_omp.cpp b/src/OPENMP/npair_multi_old_omp.cpp new file mode 100644 index 0000000000..1c2e86df80 --- /dev/null +++ b/src/OPENMP/npair_multi_old_omp.cpp @@ -0,0 +1,243 @@ +/* ---------------------------------------------------------------------- + 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_multi_old_omp.h" +#include "atom.h" +#include "atom_vec.h" +#include "domain.h" +#include "error.h" +#include "molecule.h" +#include "my_page.h" +#include "neigh_list.h" +#include "npair_omp.h" +#include "omp_compat.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairMultiOldOmp::NPairMultiOldOmp(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + multi/old-type stencil is itype dependent and is distance checked + Full: + binned neighbor list construction for all neighbors + multi-type stencil is itype dependent and is distance checked + 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 + multi-type stencil is itype dependent and is distance checked + 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 + multi-type stencil is itype dependent and is distance checked + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +template +void NPairMultiOldOmp::build(NeighList *list) +{ + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int molecular = atom->molecular; + const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; + + 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, which, ns, imol, iatom; + tagint tagprev; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + double radsum,cut,cutsq; + int *neighptr, *s; + double *cutnsq, *distsq; + + // loop over each atom, storing neighbors + + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + + 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(); + + 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]; + if (moltemplate) { + imol = molindex[i]; + iatom = molatom[i]; + tagprev = tag[i] - iatom - 1; + } + + ibin = atom2bin[i]; + s = stencil_multi_old[itype]; + distsq = distsq_multi_old[itype]; + 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)) { + // 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 (cutnsq[jtype] < distsq[k]) continue; + + 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; + + 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; + } + } + } + } + + 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; + list->gnum = 0; +} + +namespace LAMMPS_NS { +template class NPairMultiOldOmp<0,1,0,0>; +template class NPairMultiOldOmp<1,0,0,0>; +template class NPairMultiOldOmp<1,1,0,0>; +template class NPairMultiOldOmp<1,1,1,0>; +template class NPairMultiOldOmp<0,1,0,1>; +template class NPairMultiOldOmp<1,0,0,1>; +template class NPairMultiOldOmp<1,1,0,1>; +template class NPairMultiOldOmp<1,1,1,1>; +} diff --git a/src/OPENMP/npair_multi_old_omp.h b/src/OPENMP/npair_multi_old_omp.h new file mode 100644 index 0000000000..4251c6ed48 --- /dev/null +++ b/src/OPENMP/npair_multi_old_omp.h @@ -0,0 +1,77 @@ +/* -*- 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 NPairMultiOldOmp<0, 1, 0, 0> NPairFullMultiOldOmp; +NPairStyle(full/multi/old/omp, + NPairFullMultiOldOmp, + NP_FULL | NP_MULTI_OLD | NP_OMP | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOldOmp<1, 0, 0, 0> NPairHalfMultiOldNewtoffOmp; +NPairStyle(half/multi/old/newtoff/omp, + NPairHalfMultiOldNewtoffOmp, + NP_HALF | NP_MULTI_OLD | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOldOmp<1, 1, 0, 0> NPairHalfMultiOldNewtonOmp; +NPairStyle(half/multi/old/newton/omp, + NPairHalfMultiOldNewtonOmp, + NP_HALF | NP_MULTI_OLD | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairMultiOldOmp<1, 1, 1, 0> NPairHalfMultiOldNewtonTriOmp; +NPairStyle(half/multi/old/newton/tri/omp, + NPairHalfMultiOldNewtonTriOmp, + NP_HALF | NP_MULTI_OLD | NP_OMP | NP_NEWTON | NP_TRI); + +typedef NPairMultiOldOmp<0, 1, 0, 1> NPairFullSizeMultiOldOmp; +NPairStyle(full/size/multi/old/omp, + NPairFullSizeMultiOldOmp, + NP_FULL | NP_SIZE | NP_MULTI_OLD | NP_OMP | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOldOmp<1, 0, 0, 1> NPairHalfSizeMultiOldNewtoffOmp; +NPairStyle(half/size/multi/old/newtoff/omp, + NPairHalfSizeMultiOldNewtoffOmp, + NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOldOmp<1, 1, 0, 1> NPairHalfSizeMultiOldNewtonOmp; +NPairStyle(half/size/multi/old/newton/omp, + NPairHalfSizeMultiOldNewtonOmp, + NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairMultiOldOmp<1, 1, 1, 1> NPairHalfSizeMultiOldNewtonTriOmp; +NPairStyle(half/size/multi/old/newton/tri/omp, + NPairHalfSizeMultiOldNewtonTriOmp, + NP_HALF | NP_SIZE | NP_MULTI_OLD | NP_OMP | NP_NEWTON | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_MULTI_OLD_OMP_H +#define LMP_NPAIR_MULTI_OLD_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairMultiOldOmp : public NPair { + public: + NPairMultiOldOmp(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp new file mode 100644 index 0000000000..bbdce96ffc --- /dev/null +++ b/src/OPENMP/npair_multi_omp.cpp @@ -0,0 +1,247 @@ +// 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 "omp_compat.h" +#include "npair_multi_omp.h" +#include "npair_omp.h" +#include "neighbor.h" +#include "neigh_list.h" +#include "atom.h" +#include "atom_vec.h" +#include "molecule.h" +#include "domain.h" +#include "my_page.h" +#include "error.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NPairMultiOmp::NPairMultiOmp(LAMMPS *lmp) : NPair(lmp) {} + +/* ---------------------------------------------------------------------- + multi stencil is icollection-jcollection dependent + 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 NPairMultiOmp::build(NeighList *list) +{ + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int molecular = atom->molecular; + const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; + + NPAIR_OMP_INIT; +#if defined(_OPENMP) +#pragma omp parallel LMP_DEFAULT_NONE LMP_SHARED(list) +#endif + NPAIR_OMP_SETUP(nlocal); + + int i,j,jh,js,k,n,itype,jtype,icollection,jcollection,ibin,jbin,which,ns,imol,iatom; + tagint tagprev; + double xtmp,ytmp,ztmp,delx,dely,delz,rsq; + double radsum,cut,cutsq; + int *neighptr,*s; + + // loop over each atom, storing neighbors + + int *collection = neighbor->collection; + double **x = atom->x; + double *radius = atom->radius; + int *type = atom->type; + int *mask = atom->mask; + tagint *tag = atom->tag; + tagint *molecule = atom->molecule; + tagint **special = atom->special; + int **nspecial = atom->nspecial; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + + 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(); + + for (i = ifrom; i < ito; i++) { + + n = 0; + neighptr = ipage.vget(); + + itype = type[i]; + icollection = collection[i]; + 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; + } + + ibin = atom2bin[i]; + + // loop through stencils for all collections + for (jcollection = 0; jcollection < ncollections; jcollection++) { + + // if same collection use own bin + if (icollection == jcollection) jbin = ibin; + else jbin = coord2bin(x[i], jcollection); + + // loop over all atoms in surrounding bins in stencil including self + // skip i = j + // use full stencil for all collection combinations + + s = stencil_multi[icollection][jcollection]; + ns = nstencil_multi[icollection][jcollection]; + + for (k = 0; k < ns; k++) { + js = binhead_multi[jcollection][jbin + s[k]]; + for (j = js; 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; + + 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; + } + } + } + } + } + + 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; + list->gnum = 0; +} + +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>; +} diff --git a/src/OPENMP/npair_multi_omp.h b/src/OPENMP/npair_multi_omp.h new file mode 100644 index 0000000000..dd85ca8a8e --- /dev/null +++ b/src/OPENMP/npair_multi_omp.h @@ -0,0 +1,75 @@ +/* -*- 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 NPairMultiOmp<0, 1, 0, 0> NPairFullMultiOmp; +NPairStyle(full/multi/omp, + NPairFullMultiOmp, + NP_FULL | NP_MULTI | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 0, 0, 0> NPairHalfMultiNewtoffOmp; +NPairStyle(half/multi/newtoff/omp, + NPairHalfMultiNewtoffOmp, + NP_HALF | NP_MULTI | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 1, 0, 0> NPairHalfMultiNewtonOmp; +NPairStyle(half/multi/newton/omp, + NPairHalfMultiNewtonOmp, + NP_HALF | NP_MULTI | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairMultiOmp<1, 1, 1, 0> NPairHalfMultiNewtonTriOmp; +NPairStyle(half/multi/newton/tri/omp, + NPairHalfMultiNewtonTriOmp, + NP_HALF | NP_MULTI | NP_OMP | NP_NEWTON | NP_TRI); + +typedef NPairMultiOmp<0, 1, 0, 1> NPairFullSizeMultiOmp; +NPairStyle(full/size/multi/omp, + NPairFullSizeMultiOmp, + NP_FULL | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 0, 0, 1> NPairHalfSizeMultiNewtoffOmp; +NPairStyle(half/size/multi/newtoff/omp, + NPairHalfSizeMultiNewtoffOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairMultiOmp<1, 1, 0, 1> NPairHalfSizeMultiNewtonOmp; +NPairStyle(half/size/multi/newton/omp, + NPairHalfSizeMultiNewtonOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairMultiOmp<1, 1, 1, 1> NPairHalfSizeMultiNewtonTriOmp; +NPairStyle(half/size/multi/newton/tri/omp, + NPairHalfSizeMultiNewtonTriOmp, + NP_HALF | NP_SIZE | NP_MULTI | NP_OMP | NP_NEWTON | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_MULTI_OMP_H +#define LMP_NPAIR_MULTI_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairMultiOmp : public NPair { + public: + NPairMultiOmp(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/OPENMP/npair_full_nsq_ghost_omp.cpp b/src/OPENMP/npair_nsq_ghost_omp.cpp similarity index 71% rename from src/OPENMP/npair_full_nsq_ghost_omp.cpp rename to src/OPENMP/npair_nsq_ghost_omp.cpp index 05f402a99d..e1e82fb3ff 100644 --- a/src/OPENMP/npair_full_nsq_ghost_omp.cpp +++ b/src/OPENMP/npair_nsq_ghost_omp.cpp @@ -13,7 +13,7 @@ ------------------------------------------------------------------------- */ #include "omp_compat.h" -#include "npair_full_nsq_ghost_omp.h" +#include "npair_nsq_ghost_omp.h" #include "npair_omp.h" #include "neigh_list.h" #include "atom.h" @@ -27,15 +27,24 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairFullNsqGhostOmp::NPairFullNsqGhostOmp(LAMMPS *lmp) : NPair(lmp) {} +template +NPairNsqGhostOmp::NPairNsqGhostOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- - N^2 search for all neighbors - include neighbors of ghost atoms, but no "special neighbors" for ghosts - every neighbor pair appears in list of both atoms i and j + Full: + N^2 search for all neighbors + include neighbors of ghost atoms, but no "special neighbors" for ghosts + every neighbor pair appears in list of both atoms i and j + Half + Newtoff: + N^2 / 2 search for neighbor pairs with partial Newton's 3rd law + include neighbors of ghost atoms, but no "special neighbors" for ghosts + pair stored once if i,j are both owned and i < j + pair stored by me if i owned and j ghost (also stored by proc owning j) + pair stored once if i,j are both ghost and i < j ------------------------------------------------------------------------- */ -void NPairFullNsqGhostOmp::build(NeighList *list) +template +void NPairNsqGhostOmp::build(NeighList *list) { const int nlocal = atom->nlocal; const int nall = nlocal + atom->nghost; @@ -48,7 +57,7 @@ void NPairFullNsqGhostOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nall); - int i,j,n,itype,jtype,which,imol,iatom; + int i,j,jstart,n,itype,jtype,which,imol,iatom; tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr; @@ -91,12 +100,24 @@ void NPairFullNsqGhostOmp::build(NeighList *list) } // loop over all atoms, owned and ghost - // skip i = j + // Full: + // skip i = j + // Half: + // only store pair if i < j + // stores own/own pairs only once + // stores own/ghost pairs with owned atom only, on both procs + // stores ghost/ghost pairs only once // no molecular test when i = ghost atom + if (HALF) jstart = i + 1; + else jstart = 0; + if (i < nlocal) { - for (j = 0; j < nall; j++) { - if (i == j) continue; + for (j = jstart; j < nall; j++) { + if (!HALF) { + if (i == j) continue; + } + jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -121,8 +142,11 @@ void NPairFullNsqGhostOmp::build(NeighList *list) } } } else { - for (j = 0; j < nall; j++) { - if (i == j) continue; + for (j = jstart; j < nall; j++) { + if (!HALF) { + if (i == j) continue; + } + jtype = type[j]; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; @@ -131,7 +155,11 @@ void NPairFullNsqGhostOmp::build(NeighList *list) delz = ztmp - x[j][2]; rsq = delx*delx + dely*dely + delz*delz; - if (rsq <= cutneighghostsq[itype][jtype]) neighptr[n++] = j; + if (HALF) { + if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; + } else { + if (rsq <= cutneighghostsq[itype][jtype]) neighptr[n++] = j; + } } } @@ -146,3 +174,8 @@ void NPairFullNsqGhostOmp::build(NeighList *list) list->inum = nlocal; list->gnum = nall - nlocal; } + +namespace LAMMPS_NS { +template class NPairNsqGhostOmp<0>; +template class NPairNsqGhostOmp<1>; +} diff --git a/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.h b/src/OPENMP/npair_nsq_ghost_omp.h similarity index 64% rename from src/OPENMP/npair_half_nsq_newtoff_ghost_omp.h rename to src/OPENMP/npair_nsq_ghost_omp.h index 4df15104c3..1d33758bac 100644 --- a/src/OPENMP/npair_half_nsq_newtoff_ghost_omp.h +++ b/src/OPENMP/npair_nsq_ghost_omp.h @@ -13,23 +13,29 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairNsqGhostOmp<0> NPairFullNsqGhostOmp; +NPairStyle(full/nsq/ghost/omp, + NPairFullNsqGhostOmp, + NP_FULL | NP_NSQ | NP_NEWTON | NP_NEWTOFF | NP_GHOST | NP_OMP | NP_ORTHO | NP_TRI); + +typedef NPairNsqGhostOmp<1> NPairHalfNsqNewtoffGhostOmp; NPairStyle(half/nsq/newtoff/ghost/omp, NPairHalfNsqNewtoffGhostOmp, - NP_HALF | NP_NSQ | NP_NEWTOFF | NP_GHOST | NP_OMP | - NP_ORTHO | NP_TRI); + NP_HALF | NP_NSQ | NP_NEWTOFF | NP_GHOST | NP_OMP | NP_ORTHO | NP_TRI); // clang-format on #else -#ifndef LMP_NPAIR_HALF_NSQ_NEWTOFF_GHOST_OMP_H -#define LMP_NPAIR_HALF_NSQ_NEWTOFF_GHOST_OMP_H +#ifndef LMP_NPAIR_NSQ_GHOST_OMP_H +#define LMP_NPAIR_NSQ_GHOST_OMP_H #include "npair.h" namespace LAMMPS_NS { -class NPairHalfNsqNewtoffGhostOmp : public NPair { +template +class NPairNsqGhostOmp : public NPair { public: - NPairHalfNsqNewtoffGhostOmp(class LAMMPS *); + NPairNsqGhostOmp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp b/src/OPENMP/npair_nsq_omp.cpp similarity index 51% rename from src/OPENMP/npair_half_size_multi_old_newton_omp.cpp rename to src/OPENMP/npair_nsq_omp.cpp index 187efe04d1..232fee2d42 100644 --- a/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp +++ b/src/OPENMP/npair_nsq_omp.cpp @@ -12,40 +12,48 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "npair_half_size_multi_old_newton_omp.h" - +#include "omp_compat.h" +#include "npair_nsq_omp.h" +#include "npair_omp.h" +#include "neigh_list.h" +#include "neighbor.h" #include "atom.h" #include "atom_vec.h" -#include "domain.h" -#include "error.h" +#include "group.h" #include "molecule.h" +#include "domain.h" #include "my_page.h" -#include "neigh_list.h" -#include "npair_omp.h" +#include "error.h" -#include "omp_compat.h" using namespace LAMMPS_NS; +using namespace NeighConst; /* ---------------------------------------------------------------------- */ -NPairHalfSizeMultiOldNewtonOmp::NPairHalfSizeMultiOldNewtonOmp(LAMMPS *lmp) : - NPair(lmp) {} +template +NPairNsqOmp::NPairNsqOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- - size particles - binned neighbor list construction with full Newton's 3rd law - each owned atom i checks its own bin and other bins in Newton stencil - multi-type stencil is itype dependent and is distance checked - every pair stored exactly once by some processor + Full: + N^2 search for all neighbors + every neighbor pair appears in list of both atoms i and j + Half + Newtoff: + N^2 / 2 search for neighbor pairs with partial Newton's 3rd law + 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: + N^2 / 2 search for neighbor pairs with full Newton's 3rd law + every pair stored exactly once by some processor + decision on ghost atoms based on itag,jtag tests ------------------------------------------------------------------------- */ -void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) +template +void NPairNsqOmp::build(NeighList *list) { const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; const int molecular = atom->molecular; const int moltemplate = (molecular == Atom::TEMPLATE) ? 1 : 0; - const int history = list->history; - const int mask_history = 1 << HISTBITS; NPAIR_OMP_INIT; #if defined(_OPENMP) @@ -53,12 +61,11 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,jh,k,n,itype,jtype,ibin,ns,which,imol,iatom; - tagint tagprev; + int i,j,jh,jstart,n,itype,jtype,which,imol,iatom; + tagint itag,jtag,tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,cutdistsq; - int *neighptr,*s; - double *cutsq,*distsq; + double radsum,cut,cutsq; + int *neighptr; double **x = atom->x; double *radius = atom->radius; @@ -69,10 +76,14 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) tagint **special = atom->special; int **nspecial = atom->nspecial; + int nall = atom->nlocal + atom->nghost; int *molindex = atom->molindex; int *molatom = atom->molatom; Molecule **onemols = atom->avec->onemols; + int history = list->history; + int mask_history = 1 << HISTBITS; + int *ilist = list->ilist; int *numneigh = list->numneigh; int **firstneigh = list->firstneigh; @@ -81,6 +92,8 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) MyPage &ipage = list->ipage[tid]; ipage.reset(); + // loop over owned atoms, storing neighbors + for (i = ifrom; i < ito; i++) { n = 0; @@ -90,87 +103,66 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; - radi = radius[i]; if (moltemplate) { imol = molindex[i]; iatom = molatom[i]; tagprev = tag[i] - iatom - 1; } - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 + // Full: loop over all atoms, owned and ghost, skip i = j + // Half: loop over remaining atoms, owned and ghost + // Newtoff: only store pair if i < j + // Newton: itag = jtag is possible for long cutoffs that include images of self - for (j = bins[i]; j >= 0; j = bins[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; + if (!HALF) jstart = 0; + else jstart = i + 1; + + for (j = jstart; j < nall; j++) { + if (includegroup && !(mask[j] & bitmask)) continue; + + if (!HALF) { + // Full neighbor list + if (i == j) continue; + } else if (NEWTON) { + // Half neighbor list, newton on + 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 (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) { - jh = j; - if (history && rsq < radsum*radsum) - jh = jh ^ mask_history; + if (SIZE) { + radsum = radius[i] + radius[j]; + cut = radsum + skin; + cutsq = cut * cut; - 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; - } - } - - // loop over all atoms in other bins in stencil, store every pair - // skip if i,j neighbor cutoff is less than bin distance - - ibin = atom2bin[i]; - s = stencil_multi_old[itype]; - distsq = distsq_multi_old[itype]; - cutsq = cutneighsq[itype]; - ns = nstencil_multi_old[itype]; - for (k = 0; k < ns; k++) { - for (j = binhead[ibin+s[k]]; j >= 0; j = bins[j]) { - jtype = type[j]; - if (cutsq[jtype] < distsq[k]) continue; - - 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 (rsq <= cutsq) { jh = j; - if (history && rsq < radsum*radsum) + 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) + else if (imol >= 0) which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j]-tagprev); @@ -181,6 +173,22 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) 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; + } } } @@ -193,4 +201,14 @@ void NPairHalfSizeMultiOldNewtonOmp::build(NeighList *list) } NPAIR_OMP_CLOSE; list->inum = nlocal; + list->gnum = 0; +} + +namespace LAMMPS_NS { +template class NPairNsqOmp<0,1,0>; +template class NPairNsqOmp<1,0,0>; +template class NPairNsqOmp<1,1,0>; +template class NPairNsqOmp<0,1,1>; +template class NPairNsqOmp<1,0,1>; +template class NPairNsqOmp<1,1,1>; } diff --git a/src/OPENMP/npair_nsq_omp.h b/src/OPENMP/npair_nsq_omp.h new file mode 100644 index 0000000000..150ac143ad --- /dev/null +++ b/src/OPENMP/npair_nsq_omp.h @@ -0,0 +1,66 @@ +/* -*- 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 NPairNsqOmp<0, 1, 0> NPairFullNsqOmp; +NPairStyle(full/nsq/omp, + NPairFullNsqOmp, + NP_FULL | NP_NSQ | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsqOmp<1, 0, 0> NPairHalfNsqNewtoffOmp; +NPairStyle(half/nsq/newtoff/omp, + NPairHalfNsqNewtoffOmp, + NP_HALF | NP_NSQ | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsqOmp<1, 1, 0> NPairHalfNsqNewtonOmp; +NPairStyle(half/nsq/newton/omp, + NPairHalfNsqNewtonOmp, + NP_HALF | NP_NSQ | NP_OMP | NP_NEWTON | NP_ORTHO | NP_TRI); + +typedef NPairNsqOmp<0, 1, 1> NPairFullSizeNsqOmp; +NPairStyle(full/size/nsq/omp, + NPairFullSizeNsqOmp, + NP_FULL | NP_SIZE | NP_NSQ | NP_OMP | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsqOmp<1, 0, 1> NPairHalfSizeNsqNewtoffOmp; +NPairStyle(half/size/nsq/newtoff/omp, + NPairHalfSizeNsqNewtoffOmp, + NP_HALF | NP_SIZE | NP_NSQ | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairNsqOmp<1, 1, 1> NPairHalfSizeNsqNewtonOmp; +NPairStyle(half/size/nsq/newton/omp, + NPairHalfSizeNsqNewtonOmp, + NP_HALF | NP_SIZE | NP_NSQ | NP_OMP | NP_NEWTON | NP_ORTHO | NP_TRI); +// clang-format on +#else + +#ifndef LMP_NPAIR_NSQ_OMP_H +#define LMP_NPAIR_NSQ_OMP_H + +#include "npair.h" + +namespace LAMMPS_NS { + +template +class NPairNsqOmp : public NPair { + public: + NPairNsqOmp(class LAMMPS *); + void build(class NeighList *) override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/OPENMP/npair_half_respa_bin_newton_omp.cpp b/src/OPENMP/npair_respa_bin_omp.cpp similarity index 67% rename from src/OPENMP/npair_half_respa_bin_newton_omp.cpp rename to src/OPENMP/npair_respa_bin_omp.cpp index 51fc7a2ed8..877f368083 100644 --- a/src/OPENMP/npair_half_respa_bin_newton_omp.cpp +++ b/src/OPENMP/npair_respa_bin_omp.cpp @@ -13,7 +13,7 @@ ------------------------------------------------------------------------- */ #include "omp_compat.h" -#include "npair_half_respa_bin_newton_omp.h" +#include "npair_respa_bin_omp.h" #include "npair_omp.h" #include "neigh_list.h" #include "atom.h" @@ -27,17 +27,25 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairHalfRespaBinNewtonOmp::NPairHalfRespaBinNewtonOmp(LAMMPS *lmp) : +template +NPairRespaBinOmp::NPairRespaBinOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- multiple respa lists - 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 + Newtoff + binned neighbor list construction with partial Newton's 3rd law + each owned atom i checks own bin and surrounding bins in non-Newton 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) + 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 ------------------------------------------------------------------------- */ -void NPairHalfRespaBinNewtonOmp::build(NeighList *list) +template +void NPairRespaBinOmp::build(NeighList *list) { const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; const int molecular = atom->molecular; @@ -52,7 +60,7 @@ void NPairHalfRespaBinNewtonOmp::build(NeighList *list) #endif NPAIR_OMP_SETUP(nlocal); - int i,j,k,n,itype,jtype,ibin,n_inner,n_middle,imol,iatom; + int i,j,k,n,itype,jtype,ibin,bin_start,n_inner,n_middle,imol,iatom; tagint tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -115,76 +123,68 @@ void NPairHalfRespaBinNewtonOmp::build(NeighList *list) xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; + ibin = atom2bin[i]; if (moltemplate) { imol = molindex[i]; iatom = molatom[i]; tagprev = tag[i] - iatom - 1; } - // loop over rest of atoms in i's bin, ghosts are at end of linked list - // 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 - - for (j = bins[i]; j >= 0; j = bins[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 != 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 ((minchange = domain->minimum_image_check(delx,dely,delz))) - neighptr[n++] = j; - else if (which > 0) neighptr[n++] = j ^ (which << SBBITS); - } else neighptr[n++] = j; - - if (rsq < cut_inner_sq) { - if (which == 0) neighptr_inner[n_inner++] = j; - else if (minchange) neighptr_inner[n_inner++] = j; - else if (which > 0) neighptr_inner[n_inner++] = j ^ (which << SBBITS); - } - - if (respamiddle && - rsq < cut_middle_sq && rsq > cut_middle_inside_sq) { - if (which == 0) neighptr_middle[n_middle++] = j; - else if (minchange) neighptr_middle[n_middle++] = j; - else if (which > 0) - neighptr_middle[n_middle++] = j ^ (which << SBBITS); - } - } - } - - // loop over all atoms in other bins in stencil, store every pair - - ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { + bin_start = binhead[ibin+stencil[k]]; + if (stencil[k] == 0) { + if (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 (!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; + rsq = delx * delx + dely * dely + delz * delz; if (rsq <= cutneighsq[itype][jtype]) { if (molecular != Atom::ATOMIC) { @@ -247,3 +247,9 @@ void NPairHalfRespaBinNewtonOmp::build(NeighList *list) list->inum_inner = nlocal; if (respamiddle) list->inum_middle = nlocal; } + +namespace LAMMPS_NS { +template class NPairRespaBinOmp<0,0>; +template class NPairRespaBinOmp<1,0>; +template class NPairRespaBinOmp<1,1>; +} diff --git a/src/OPENMP/npair_half_respa_bin_newton_omp.h b/src/OPENMP/npair_respa_bin_omp.h similarity index 55% rename from src/OPENMP/npair_half_respa_bin_newton_omp.h rename to src/OPENMP/npair_respa_bin_omp.h index 695d0ce627..23daacbb8f 100644 --- a/src/OPENMP/npair_half_respa_bin_newton_omp.h +++ b/src/OPENMP/npair_respa_bin_omp.h @@ -13,22 +13,34 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairRespaBinOmp<0, 0> NPairHalfRespaBinNewtoffOmp; +NPairStyle(half/respa/bin/newtoff, + NPairHalfRespaBinNewtoffOmp, + NP_HALF | NP_RESPA | NP_BIN | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairRespaBinOmp<1, 0> NPairHalfRespaBinNewtonOmp; NPairStyle(half/respa/bin/newton/omp, NPairHalfRespaBinNewtonOmp, - NP_HALF | NP_RESPA | NP_BIN | NP_NEWTON | NP_OMP | NP_ORTHO); + NP_HALF | NP_RESPA | NP_BIN | NP_OMP | NP_NEWTON | NP_ORTHO); + +typedef NPairRespaBinOmp<1, 1> NPairHalfRespaBinNewtonTriOmp; +NPairStyle(half/respa/bin/newton/tri/omp, + NPairHalfRespaBinNewtonTriOmp, + NP_HALF | NP_RESPA | NP_BIN | NP_OMP | NP_NEWTON | NP_TRI); // clang-format on #else -#ifndef LMP_NPAIR_HALF_RESPA_BIN_NEWTON_OMP_H -#define LMP_NPAIR_HALF_RESPA_BIN_NEWTON_OMP_H +#ifndef LMP_NPAIR_RESPA_BIN_OMP_H +#define LMP_NPAIR_RESPA_BIN_OMP_H #include "npair.h" namespace LAMMPS_NS { -class NPairHalfRespaBinNewtonOmp : public NPair { +template +class NPairRespaBinOmp : public NPair { public: - NPairHalfRespaBinNewtonOmp(class LAMMPS *); + NPairRespaBinOmp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp b/src/OPENMP/npair_respa_nsq_omp.cpp similarity index 81% rename from src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp rename to src/OPENMP/npair_respa_nsq_omp.cpp index 1167a7601b..7464f70570 100644 --- a/src/OPENMP/npair_half_respa_nsq_newtoff_omp.cpp +++ b/src/OPENMP/npair_respa_nsq_omp.cpp @@ -13,7 +13,7 @@ ------------------------------------------------------------------------- */ #include "omp_compat.h" -#include "npair_half_respa_nsq_newtoff_omp.h" +#include "npair_respa_nsq_omp.h" #include "npair_omp.h" #include "neigh_list.h" #include "atom.h" @@ -28,17 +28,25 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairHalfRespaNsqNewtoffOmp::NPairHalfRespaNsqNewtoffOmp(LAMMPS *lmp) : +template +NPairRespaNsqOmp::NPairRespaNsqOmp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- multiple respa lists - N^2 / 2 search for neighbor pairs with partial Newton's 3rd law - pair added to list if atoms i and j are both owned and i < j - pair added if j is ghost (also stored by proc owning j) + Newtoff + N^2 / 2 search for neighbor pairs with partial Newton's 3rd law + pair added to list if atoms i and j are both owned and i < j + pair added if j is ghost (also stored by proc owning j) + Newton + N^2 / 2 search for neighbor pairs with full Newton's 3rd law + pair added to list if atoms i and j are both owned and i < j + if j is ghost only me or other proc adds pair + decision based on itag,jtag tests ------------------------------------------------------------------------- */ -void NPairHalfRespaNsqNewtoffOmp::build(NeighList *list) +template +void NPairRespaNsqOmp::build(NeighList *list) { const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; const int bitmask = (includegroup) ? group->bitmask[includegroup] : 0; @@ -55,7 +63,7 @@ void NPairHalfRespaNsqNewtoffOmp::build(NeighList *list) NPAIR_OMP_SETUP(nlocal); int i,j,n,itype,jtype,n_inner,n_middle,imol,iatom; - tagint tagprev; + tagint itag, jtag, tagprev; double xtmp,ytmp,ztmp,delx,dely,delz,rsq; int *neighptr,*neighptr_inner,*neighptr_middle; @@ -116,6 +124,7 @@ void NPairHalfRespaNsqNewtoffOmp::build(NeighList *list) } itype = type[i]; + itag = tag[i]; xtmp = x[i][0]; ytmp = x[i][1]; ztmp = x[i][2]; @@ -127,8 +136,26 @@ void NPairHalfRespaNsqNewtoffOmp::build(NeighList *list) // loop over remaining atoms, owned and ghost - for (j = i+1; j < nall; j++) { + for (j = i + 1; j < nall; j++) { if (includegroup && !(mask[j] & bitmask)) continue; + + if (NEWTON) { + 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 (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; @@ -195,3 +222,8 @@ void NPairHalfRespaNsqNewtoffOmp::build(NeighList *list) list->inum_inner = nlocal; if (respamiddle) list->inum_middle = nlocal; } + +namespace LAMMPS_NS { +template class NPairRespaNsqOmp<0>; +template class NPairRespaNsqOmp<1>; +} diff --git a/src/OPENMP/npair_half_respa_nsq_newton_omp.h b/src/OPENMP/npair_respa_nsq_omp.h similarity index 63% rename from src/OPENMP/npair_half_respa_nsq_newton_omp.h rename to src/OPENMP/npair_respa_nsq_omp.h index d949ef7e93..66b0f634cd 100644 --- a/src/OPENMP/npair_half_respa_nsq_newton_omp.h +++ b/src/OPENMP/npair_respa_nsq_omp.h @@ -13,23 +13,29 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairRespaNsqOmp<0> NPairHalfRespaNsqNewtoffOmp; +NPairStyle(half/respa/nsq/newtoff/omp, + NPairHalfRespaNsqNewtoff, + NP_HALF | NP_RESPA | NP_NSQ | NP_OMP | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairRespaNsqOmp<1> NPairHalfRespaNsqNewtonOmp; NPairStyle(half/respa/nsq/newton/omp, NPairHalfRespaNsqNewtonOmp, - NP_HALF | NP_RESPA | NP_NSQ | NP_NEWTON | NP_OMP | - NP_ORTHO | NP_TRI); + NP_HALF | NP_RESPA | NP_NSQ | NP_OMP | NP_NEWTON | NP_ORTHO | NP_TRI); // clang-format on #else -#ifndef LMP_NPAIR_HALF_RESPA_NSQ_NEWTON_OMP_H -#define LMP_NPAIR_HALF_RESPA_NSQ_NEWTON_OMP_H +#ifndef LMP_NPAIR_RESPA_NSQ_OMP_H +#define LMP_NPAIR_RESPA_NSQ_OMP_H #include "npair.h" namespace LAMMPS_NS { -class NPairHalfRespaNsqNewtonOmp : public NPair { +template +class NPairRespaNsqOmp : public NPair { public: - NPairHalfRespaNsqNewtonOmp(class LAMMPS *); + NPairRespaNsqOmp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_bin_ghost.cpp b/src/npair_bin_ghost.cpp index 4cf30f10f9..45e2cd0358 100644 --- a/src/npair_bin_ghost.cpp +++ b/src/npair_bin_ghost.cpp @@ -44,7 +44,6 @@ NPairBinGhost::NPairBinGhost(LAMMPS *lmp) : NPair(lmp) {} pair stored once if i,j are both ghost and i < j ------------------------------------------------------------------------- */ - template void NPairBinGhost::build(NeighList *list) { diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index ab182f39c4..ba703691cd 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -105,7 +105,7 @@ void NPairMulti::build(NeighList *list) // if same collection use own bin if (icollection == jcollection) jbin = ibin; - else jbin = coord2bin(x[i], jcollection); + else jbin = coord2bin(x[i], jcollection); s = stencil_multi[icollection][jcollection]; ns = nstencil_multi[icollection][jcollection]; diff --git a/src/npair_multi_old.cpp b/src/npair_multi_old.cpp index 3c61d4ba29..967a366cf4 100644 --- a/src/npair_multi_old.cpp +++ b/src/npair_multi_old.cpp @@ -159,7 +159,6 @@ void NPairMultiOld::build(NeighList *list) jtype = type[j]; if (cutnsq[jtype] < distsq[k]) continue; - if (i == j) continue; if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue; diff --git a/src/npair_nsq.h b/src/npair_nsq.h index 749ea3a78c..df6e332865 100644 --- a/src/npair_nsq.h +++ b/src/npair_nsq.h @@ -42,7 +42,6 @@ typedef NPairNsq<1, 1, 1> NPairHalfSizeNsqNewton; NPairStyle(half/size/nsq/newton, NPairHalfSizeNsqNewton, NP_HALF | NP_SIZE | NP_NSQ | NP_NEWTON | NP_ORTHO | NP_TRI); - // clang-format on #else diff --git a/src/npair_nsq_ghost.cpp b/src/npair_nsq_ghost.cpp index 5e4185f9d6..47009deff7 100644 --- a/src/npair_nsq_ghost.cpp +++ b/src/npair_nsq_ghost.cpp @@ -44,7 +44,6 @@ NPairNsqGhost::NPairNsqGhost(LAMMPS *lmp) : NPair(lmp) {} pair stored once if i,j are both ghost and i < j ------------------------------------------------------------------------- */ - template void NPairNsqGhost::build(NeighList *list) { @@ -159,6 +158,7 @@ void NPairNsqGhost::build(NeighList *list) if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j; } else { if (rsq <= cutneighghostsq[itype][jtype]) neighptr[n++] = j; + } } } diff --git a/src/npair_respa_bin.cpp b/src/npair_respa_bin.cpp index a3bcbf5124..7710a9d8ab 100644 --- a/src/npair_respa_bin.cpp +++ b/src/npair_respa_bin.cpp @@ -167,7 +167,7 @@ void NPairRespaBin::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 (rsq <= cutneighsq[itype][jtype]) { if (molecular != Atom::ATOMIC) { From b3e6a0bfa3c471e93bb4e047a5678a9c793e21ee Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 12 Nov 2022 20:44:45 -0700 Subject: [PATCH 09/87] Fixing mistake in multi stencil --- src/npair_multi.cpp | 2 +- src/nstencil_multi.cpp | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index ba703691cd..9f719f403a 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -160,7 +160,7 @@ void NPairMulti::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/nstencil_multi.cpp b/src/nstencil_multi.cpp index 76329db12d..6e9fefea1e 100644 --- a/src/nstencil_multi.cpp +++ b/src/nstencil_multi.cpp @@ -68,12 +68,6 @@ void NStencilMulti::create() int n = ncollections; double cutsq; - // For half stencils, only the upper plane is needed - int sy_min = sy; - int sz_min = sz; - if (HALF && (!DIM_3D)) sy_min = 0; - if (HALF && DIM_3D) sz_min = 0; - for (icollection = 0; icollection < n; icollection++) { for (jcollection = 0; jcollection < n; jcollection++) { if (flag_skip_multi[icollection][jcollection]) { @@ -101,15 +95,25 @@ void NStencilMulti::create() // as the old npair classes used to separately parse the central bin first if (half_flag && (!TRI)) stencil[nstencil++] = 0; + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF) { + if (half_flag && (!DIM_3D)) sy_min = 0; + if (half_flag && DIM_3D) sz_min = 0; + } + for (k = -sz_min; k <= sz; k++) { for (j = -sy_min; j <= sy; j++) { for (i = -sx; i <= sx; i++) { // Now only include "upper right" bins for half and ortho stencils - if (half_flag && (!DIM_3D) && (!TRI)) - if (! (j > 0 || (j == 0 && i > 0))) continue; - if (half_flag && DIM_3D && (!TRI)) - if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + if (HALF) { + if (half_flag && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i > 0))) continue; + if (half_flag && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + } if (bin_distance_multi(i,j,k,bin_collection) < cutsq) stencil_multi[icollection][jcollection][ns++] = k * mbiny * mbinx + j * mbinx + i; From f3d5941301a4b5db55b04fbd263194147f854fc6 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 14 Nov 2022 20:48:02 -0700 Subject: [PATCH 10/87] Updating logic for multi --- src/OPENMP/npair_multi_omp.cpp | 55 +++++++++++++++++++++------------- src/npair.cpp | 2 ++ src/npair.h | 1 + src/npair_multi.cpp | 48 +++++++++++++++++++---------- src/nstencil_multi.cpp | 19 ++++++------ 5 files changed, 80 insertions(+), 45 deletions(-) diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp index bbdce96ffc..e5db08e157 100644 --- a/src/OPENMP/npair_multi_omp.cpp +++ b/src/OPENMP/npair_multi_omp.cpp @@ -118,15 +118,16 @@ void NPairMultiOmp::build(NeighList *list) if (icollection == jcollection) jbin = ibin; else jbin = coord2bin(x[i], jcollection); - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - // use full stencil for all collection combinations - s = stencil_multi[icollection][jcollection]; ns = nstencil_multi[icollection][jcollection]; for (k = 0; k < ns; k++) { js = binhead_multi[jcollection][jbin + s[k]]; + + // own-bin for half stencil + if (HALF) + if (flag_half_multi[icollection][jcollection] && s[k] == 0) js = bins[i]; + for (j = js; j >= 0; j = bins[j]) { if (!HALF) { // Full neighbor list @@ -144,40 +145,52 @@ void NPairMultiOmp::build(NeighList *list) // 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; + + // if same size (same collection), use half stencil + if (flag_half_multi[icollection][jcollection]) { + 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 same size: uses half stencil so includes a check of the central bin + if (flag_half_multi[icollection][jcollection]){ + if (s[k] == 0) { + // if same collection, + // 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 (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; + // if different collections, + // if j is owned atom, store it if j > i + // if j is ghost, only store if j coords are "above and to the right" of i + + if ((icollection != jcollection) && (j < i)) continue; + + 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; + 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; diff --git a/src/npair.cpp b/src/npair.cpp index c1615411c0..6fddcfef54 100644 --- a/src/npair.cpp +++ b/src/npair.cpp @@ -174,6 +174,8 @@ void NPair::copy_stencil_info() nstencil_multi = ns->nstencil_multi; stencil_multi = ns->stencil_multi; + + flag_half_multi = ns->flag_half_multi; } /* ---------------------------------------------------------------------- diff --git a/src/npair.h b/src/npair.h index 3eeb1d48f4..661196e586 100644 --- a/src/npair.h +++ b/src/npair.h @@ -96,6 +96,7 @@ class NPair : protected Pointers { int *nstencil_multi_old; int **stencil_multi_old; double **distsq_multi_old; + bool **flag_half_multi; int **nstencil_multi; int ***stencil_multi; diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index 9f719f403a..76f6d90f6e 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -112,6 +112,11 @@ void NPairMulti::build(NeighList *list) for (k = 0; k < ns; k++) { js = binhead_multi[jcollection][jbin + s[k]]; + + // own-bin for half stencil + if (HALF) + if (flag_half_multi[icollection][jcollection] && s[k] == 0) js = bins[i]; + for (j = js; j >= 0; j = bins[j]) { if (!HALF) { // Full neighbor list @@ -129,26 +134,39 @@ void NPairMulti::build(NeighList *list) // 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; + + // if same size (same collection), use half stencil + if (flag_half_multi[icollection][jcollection]) { + 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 same size: uses half stencil so includes a check of the central bin + if (flag_half_multi[icollection][jcollection]) { + if (s[k] == 0) { + // if same collection, + // 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 (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; + // if different collections, + // if j is owned atom, store it if j > i + // if j is ghost, only store if j coords are "above and to the right" of i + + if ((icollection != jcollection) && (j < i)) continue; + + 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; + } } } } diff --git a/src/nstencil_multi.cpp b/src/nstencil_multi.cpp index 6e9fefea1e..202dace29d 100644 --- a/src/nstencil_multi.cpp +++ b/src/nstencil_multi.cpp @@ -87,13 +87,13 @@ void NStencilMulti::create() bin_collection = bin_collection_multi[icollection][jcollection]; cutsq = cutcollectionsq[icollection][jcollection]; - half_flag = flag_half_multi[icollection][jcollection]; // Half and ortho stencils include central bin first // This preserves the historical order of the neighbor list // as the old npair classes used to separately parse the central bin first - if (half_flag && (!TRI)) stencil[nstencil++] = 0; + if (HALF && (!TRI)) + if (half_flag) stencil_multi[icollection][jcollection][ns++] = 0; // For half stencils, only the upper plane is needed int sy_min = sy; @@ -106,15 +106,16 @@ void NStencilMulti::create() for (k = -sz_min; k <= sz; k++) { for (j = -sy_min; j <= sy; j++) { for (i = -sx; i <= sx; i++) { - // Now only include "upper right" bins for half and ortho stencils - if (HALF) { - if (half_flag && (!DIM_3D) && (!TRI)) - if (! (j > 0 || (j == 0 && i > 0))) continue; - if (half_flag && DIM_3D && (!TRI)) - if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + if (HALF && (!TRI)) { + if (half_flag) { + if (DIM_3D) { + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + } else { + if (! (j > 0 || (j == 0 && i > 0))) continue; + } + } } - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) stencil_multi[icollection][jcollection][ns++] = k * mbiny * mbinx + j * mbinx + i; } From 8f81cd80b65ff594e0bfaf7fecd1c687b05a650a Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 22 Nov 2022 21:31:31 -0700 Subject: [PATCH 11/87] Fixing a few errors in npair/stencil classes --- src/npair_bin_ghost.cpp | 2 +- src/npair_multi.cpp | 2 +- src/nstencil_ghost_bin.cpp | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/npair_bin_ghost.cpp b/src/npair_bin_ghost.cpp index 45e2cd0358..f3b96492dc 100644 --- a/src/npair_bin_ghost.cpp +++ b/src/npair_bin_ghost.cpp @@ -149,7 +149,7 @@ void NPairBinGhost::build(NeighList *list) if (xbin2 < 0 || xbin2 >= mbinx || ybin2 < 0 || ybin2 >= mbiny || zbin2 < 0 || zbin2 >= mbinz) continue; - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { + for (j = binhead[ibin + stencil[k]]; j >= 0; j = bins[j]) { if (HALF) { if (j <= i) continue; } else { diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index 76f6d90f6e..c05aa7fc5c 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -114,7 +114,7 @@ void NPairMulti::build(NeighList *list) js = binhead_multi[jcollection][jbin + s[k]]; // own-bin for half stencil - if (HALF) + if (HALF && !TRI) if (flag_half_multi[icollection][jcollection] && s[k] == 0) js = bins[i]; for (j = js; j >= 0; j = bins[j]) { diff --git a/src/nstencil_ghost_bin.cpp b/src/nstencil_ghost_bin.cpp index d5c7c1a463..b83a0ffd46 100644 --- a/src/nstencil_ghost_bin.cpp +++ b/src/nstencil_ghost_bin.cpp @@ -18,7 +18,10 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ template -NStencilGhostBin::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp) {} +NStencilGhostBin::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp) +{ + xyzflag = 1; +} /* ---------------------------------------------------------------------- create stencil based on bin geometry and cutoff @@ -52,11 +55,12 @@ void NStencilGhostBin::create() if (HALF && DIM_3D && (!TRI)) if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; - if (bin_distance(i,j,k) < cutneighmaxsq) + if (bin_distance(i,j,k) < cutneighmaxsq) { stencilxyz[nstencil][0] = i; stencilxyz[nstencil][1] = j; stencilxyz[nstencil][2] = k; stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; + } } } } From 58f9553bf10520f3641d6e2a196e1aa92c6889a5 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 23 Nov 2022 08:52:21 -0700 Subject: [PATCH 12/87] Copying fixes to omp --- src/OPENMP/npair_bin_ghost_omp.cpp | 2 +- src/OPENMP/npair_multi_omp.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OPENMP/npair_bin_ghost_omp.cpp b/src/OPENMP/npair_bin_ghost_omp.cpp index 8f3105dc75..dbdabbe869 100644 --- a/src/OPENMP/npair_bin_ghost_omp.cpp +++ b/src/OPENMP/npair_bin_ghost_omp.cpp @@ -108,7 +108,7 @@ void NPairBinGhostOmp::build(NeighList *list) if (i < nlocal) { ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { - for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) { + for (j = binhead[ibin + stencil[k]]; j >= 0; j = bins[j]) { if (HALF) { // Half neighbor list, newton off // only store pair if i < j diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp index e5db08e157..5e29b174f9 100644 --- a/src/OPENMP/npair_multi_omp.cpp +++ b/src/OPENMP/npair_multi_omp.cpp @@ -125,7 +125,7 @@ void NPairMultiOmp::build(NeighList *list) js = binhead_multi[jcollection][jbin + s[k]]; // own-bin for half stencil - if (HALF) + if (HALF && !TRI) if (flag_half_multi[icollection][jcollection] && s[k] == 0) js = bins[i]; for (j = js; j >= 0; j = bins[j]) { From c4676aabfdda3781ec8b246866327a39ed9a7527 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 23 Nov 2022 09:58:46 -0700 Subject: [PATCH 13/87] Adding missing variables from omp npair halffull --- src/OPENMP/npair_bin_atomonly_omp.cpp | 8 ++------ src/OPENMP/npair_halffull_omp.cpp | 4 ++++ src/npair_bin_atomonly.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/OPENMP/npair_bin_atomonly_omp.cpp b/src/OPENMP/npair_bin_atomonly_omp.cpp index 2fe3baa014..2e948bf2b9 100644 --- a/src/OPENMP/npair_bin_atomonly_omp.cpp +++ b/src/OPENMP/npair_bin_atomonly_omp.cpp @@ -80,7 +80,6 @@ void NPairBinAtomonlyOmp::build(NeighList *list) // loop over owned atoms, storing neighbors for (i = ifrom; i < ito; i++) { - n = 0; neighptr = ipage.vget(); @@ -89,13 +88,10 @@ void NPairBinAtomonlyOmp::build(NeighList *list) ytmp = x[i][1]; ztmp = x[i][2]; - // loop over all atoms in surrounding bins in stencil including self - // skip i = j - ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { - bin_start = binhead[ibin+stencil[k]]; + bin_start = binhead[ibin + stencil[k]]; if (stencil[k] == 0) { if (HALF && NEWTON && (!TRI)) { // Half neighbor list, newton on, orthonormal @@ -131,7 +127,7 @@ void NPairBinAtomonlyOmp::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 diff --git a/src/OPENMP/npair_halffull_omp.cpp b/src/OPENMP/npair_halffull_omp.cpp index 559d8910b1..d23325630a 100644 --- a/src/OPENMP/npair_halffull_omp.cpp +++ b/src/OPENMP/npair_halffull_omp.cpp @@ -85,6 +85,10 @@ void NPairHalffullOmp::build(NeighList *list) // loop over parent full list i = ilist_full[ii]; + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + jlist = firstneigh_full[i]; jnum = numneigh_full[i]; diff --git a/src/npair_bin_atomonly.cpp b/src/npair_bin_atomonly.cpp index 100b521b92..5e3be0e8b0 100644 --- a/src/npair_bin_atomonly.cpp +++ b/src/npair_bin_atomonly.cpp @@ -82,7 +82,7 @@ void NPairBinAtomonly::build(NeighList *list) ibin = atom2bin[i]; for (k = 0; k < nstencil; k++) { - bin_start = binhead[ibin+stencil[k]]; + bin_start = binhead[ibin + stencil[k]]; if (stencil[k] == 0) { if (HALF && NEWTON && (!TRI)) { // Half neighbor list, newton on, orthonormal @@ -118,7 +118,7 @@ void NPairBinAtomonly::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 From 781eb934c17935af8e381418bdcaa30612b7290b Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 27 Mar 2023 16:37:11 -0600 Subject: [PATCH 14/87] Adding mass to python numpy unittest of KE --- unittest/python/python-numpy.py | 1 + 1 file changed, 1 insertion(+) diff --git a/unittest/python/python-numpy.py b/unittest/python/python-numpy.py index f8e65bcd85..839e5d03af 100644 --- a/unittest/python/python-numpy.py +++ b/unittest/python/python-numpy.py @@ -108,6 +108,7 @@ class PythonNumpy(unittest.TestCase): self.lmp.command("create_box 1 box") self.lmp.command("create_atoms 1 single 1.0 1.0 1.0") self.lmp.command("create_atoms 1 single 1.0 1.0 1.5") + self.lmp.command("mass 1 1.0") self.lmp.command("compute ke all ke/atom") natoms = self.lmp.get_natoms() self.assertEqual(natoms,2) From b456beb62fdda6cd70f1886523835cf80c5c9a01 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 28 Mar 2023 13:55:12 -0600 Subject: [PATCH 15/87] Reorganizing intel npair to work with cmake, adding intel stencil --- ...st_intel.cpp => npair_bin_ghost_intel.cpp} | 2 +- ..._ghost_intel.h => npair_bin_ghost_intel.h} | 4 +- src/INTEL/npair_bin_intel.cpp | 298 ++++++++++++++++++ ...n_newton_tri_intel.h => npair_bin_intel.h} | 31 +- src/INTEL/npair_full_bin_intel.cpp | 134 -------- src/INTEL/npair_full_bin_intel.h | 44 --- src/INTEL/npair_half_bin_newton_intel.cpp | 108 ------- src/INTEL/npair_half_bin_newton_intel.h | 43 --- src/INTEL/npair_half_bin_newton_tri_intel.cpp | 108 ------- ...rim_intel.cpp => npair_halffull_intel.cpp} | 202 +++++++++++- src/INTEL/npair_halffull_intel.h | 128 ++++++++ src/INTEL/npair_halffull_newtoff_intel.h | 44 --- src/INTEL/npair_halffull_newtoff_trim_intel.h | 44 --- src/INTEL/npair_halffull_newton_intel.cpp | 226 ------------- src/INTEL/npair_halffull_newton_intel.h | 61 ---- src/INTEL/npair_halffull_newton_trim_intel.h | 61 ---- src/INTEL/nstencil_bin_intel.cpp | 70 ++++ src/INTEL/nstencil_bin_intel.h | 65 ++++ src/neighbor.cpp | 1 + src/neighbor.h | 5 +- 20 files changed, 797 insertions(+), 882 deletions(-) rename src/INTEL/{npair_full_bin_ghost_intel.cpp => npair_bin_ghost_intel.cpp} (99%) rename src/INTEL/{npair_full_bin_ghost_intel.h => npair_bin_ghost_intel.h} (95%) create mode 100644 src/INTEL/npair_bin_intel.cpp rename src/INTEL/{npair_half_bin_newton_tri_intel.h => npair_bin_intel.h} (59%) delete mode 100644 src/INTEL/npair_full_bin_intel.cpp delete mode 100644 src/INTEL/npair_full_bin_intel.h delete mode 100644 src/INTEL/npair_half_bin_newton_intel.cpp delete mode 100644 src/INTEL/npair_half_bin_newton_intel.h delete mode 100644 src/INTEL/npair_half_bin_newton_tri_intel.cpp rename src/INTEL/{npair_halffull_newton_trim_intel.cpp => npair_halffull_intel.cpp} (56%) create mode 100644 src/INTEL/npair_halffull_intel.h delete mode 100644 src/INTEL/npair_halffull_newtoff_intel.h delete mode 100644 src/INTEL/npair_halffull_newtoff_trim_intel.h delete mode 100644 src/INTEL/npair_halffull_newton_intel.cpp delete mode 100644 src/INTEL/npair_halffull_newton_intel.h delete mode 100644 src/INTEL/npair_halffull_newton_trim_intel.h create mode 100644 src/INTEL/nstencil_bin_intel.cpp create mode 100644 src/INTEL/nstencil_bin_intel.h diff --git a/src/INTEL/npair_full_bin_ghost_intel.cpp b/src/INTEL/npair_bin_ghost_intel.cpp similarity index 99% rename from src/INTEL/npair_full_bin_ghost_intel.cpp rename to src/INTEL/npair_bin_ghost_intel.cpp index b7b9ee4aea..47c3b5bd20 100644 --- a/src/INTEL/npair_full_bin_ghost_intel.cpp +++ b/src/INTEL/npair_bin_ghost_intel.cpp @@ -16,7 +16,7 @@ Contributing authors: W. Michael Brown (Intel) ------------------------------------------------------------------------- */ -#include "npair_full_bin_ghost_intel.h" +#include "npair_bin_ghost_intel.h" #include "atom.h" #include "comm.h" diff --git a/src/INTEL/npair_full_bin_ghost_intel.h b/src/INTEL/npair_bin_ghost_intel.h similarity index 95% rename from src/INTEL/npair_full_bin_ghost_intel.h rename to src/INTEL/npair_bin_ghost_intel.h index 4ae5ddad5f..eada3237bc 100644 --- a/src/INTEL/npair_full_bin_ghost_intel.h +++ b/src/INTEL/npair_bin_ghost_intel.h @@ -25,8 +25,8 @@ NPairStyle(full/bin/ghost/intel, // clang-format on #else -#ifndef LMP_NPAIR_FULL_BIN_GHOST_INTEL_H -#define LMP_NPAIR_FULL_BIN_GHOST_INTEL_H +#ifndef LMP_NPAIR_BIN_GHOST_INTEL_H +#define LMP_NPAIR_BIN_GHOST_INTEL_H #include "npair_intel.h" diff --git a/src/INTEL/npair_bin_intel.cpp b/src/INTEL/npair_bin_intel.cpp new file mode 100644 index 0000000000..f4942022ec --- /dev/null +++ b/src/INTEL/npair_bin_intel.cpp @@ -0,0 +1,298 @@ +// 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: W. Michael Brown (Intel) +------------------------------------------------------------------------- */ + +#include "npair_bin_intel.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "neigh_list.h" +#include "neighbor.h" + +using namespace LAMMPS_NS; + + +/* ---------------------------------------------------------------------- */ + +NPairHalfBinNewtonIntel::NPairHalfBinNewtonIntel(LAMMPS *lmp) : + NPairIntel(lmp) {} + +/* ---------------------------------------------------------------------- + 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 +------------------------------------------------------------------------- */ + +void NPairHalfBinNewtonIntel::build(NeighList *list) +{ + if (nstencil / 2 > INTEL_MAX_STENCIL_CHECK) + error->all(FLERR, "Too many neighbor bins for INTEL package."); + + #ifdef _LMP_INTEL_OFFLOAD + if (exclude) + error->all(FLERR, "Exclusion lists not yet supported for Intel offload"); + #endif + + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) + hbni(list, _fix->get_mixed_buffers()); + else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) + hbni(list, _fix->get_double_buffers()); + else + hbni(list, _fix->get_single_buffers()); + + _fix->stop_watch(TIME_HOST_NEIGHBOR); +} + +template +void NPairHalfBinNewtonIntel:: +hbni(NeighList *list, IntelBuffers *buffers) { + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + list->inum = nlocal; + + int host_start = _fix->host_start_neighbor(); + const int off_end = _fix->offload_end_neighbor(); + + #ifdef _LMP_INTEL_OFFLOAD + if (off_end) grow_stencil(); + if (_fix->full_host_list()) host_start = 0; + int offload_noghost = _fix->offload_noghost(); + #endif + + buffers->grow_list(list, atom->nlocal, comm->nthreads, 0, off_end); + + int need_ic = 0; + if (atom->molecular != Atom::ATOMIC) + dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, + neighbor->cutneighmax); + + #ifdef _LMP_INTEL_OFFLOAD + if (need_ic) { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, + off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } else { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, + off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } + #else + if (need_ic) + bin_newton(0, list, buffers, host_start, nlocal); + else + bin_newton(0, list, buffers, host_start, nlocal); + #endif +} + + +/* ---------------------------------------------------------------------- */ + +NPairHalfBinNewtonTriIntel::NPairHalfBinNewtonTriIntel(LAMMPS *lmp) : + NPairIntel(lmp) {} + +/* ---------------------------------------------------------------------- + binned neighbor list construction with Newton's 3rd law for triclinic + each owned atom i checks its own bin and other bins in triclinic stencil + every pair stored exactly once by some processor +------------------------------------------------------------------------- */ + +void NPairHalfBinNewtonTriIntel::build(NeighList *list) +{ + if (nstencil > INTEL_MAX_STENCIL) + error->all(FLERR, "Too many neighbor bins for INTEL package."); + + #ifdef _LMP_INTEL_OFFLOAD + if (exclude) + error->all(FLERR, "Exclusion lists not yet supported for Intel offload"); + #endif + + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) + hbnti(list, _fix->get_mixed_buffers()); + else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) + hbnti(list, _fix->get_double_buffers()); + else + hbnti(list, _fix->get_single_buffers()); + + _fix->stop_watch(TIME_HOST_NEIGHBOR); +} + +template +void NPairHalfBinNewtonTriIntel:: +hbnti(NeighList *list, IntelBuffers *buffers) { + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + list->inum = nlocal; + + int host_start = _fix->host_start_neighbor(); + const int off_end = _fix->offload_end_neighbor(); + + #ifdef _LMP_INTEL_OFFLOAD + if (off_end) grow_stencil(); + if (_fix->full_host_list()) host_start = 0; + int offload_noghost = _fix->offload_noghost(); + #endif + + buffers->grow_list(list, atom->nlocal, comm->nthreads, 0, off_end); + + int need_ic = 0; + if (atom->molecular != Atom::ATOMIC) + dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, + neighbor->cutneighmax); + + #ifdef _LMP_INTEL_OFFLOAD + if (need_ic) { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, + off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } else { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, + off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } + #else + if (need_ic) + bin_newton(0, list, buffers, host_start, nlocal); + else + bin_newton(0, list, buffers, host_start, nlocal); + #endif +} + +/* ---------------------------------------------------------------------- */ + +NPairFullBinIntel::NPairFullBinIntel(LAMMPS *lmp) : NPairIntel(lmp) {} + +/* ---------------------------------------------------------------------- + binned neighbor list construction for all neighbors + every neighbor pair appears in list of both atoms i and j +------------------------------------------------------------------------- */ + +void NPairFullBinIntel::build(NeighList *list) +{ + if (nstencil > INTEL_MAX_STENCIL_CHECK) + error->all(FLERR, "Too many neighbor bins for INTEL package."); + + #ifdef _LMP_INTEL_OFFLOAD + if (exclude) + error->all(FLERR, "Exclusion lists not yet supported for Intel offload"); + #endif + + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) + fbi(list, _fix->get_mixed_buffers()); + else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) + fbi(list, _fix->get_double_buffers()); + else + fbi(list, _fix->get_single_buffers()); + + _fix->stop_watch(TIME_HOST_NEIGHBOR); +} + +template +void NPairFullBinIntel:: +fbi(NeighList *list, IntelBuffers *buffers) { + const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; + list->inum = nlocal; + list->gnum = 0; + + int host_start = _fix->host_start_neighbor();; + const int off_end = _fix->offload_end_neighbor(); + + #ifdef _LMP_INTEL_OFFLOAD + if (off_end) grow_stencil(); + if (_fix->full_host_list()) host_start = 0; + int offload_noghost = _fix->offload_noghost(); + #endif + + buffers->grow_list(list, atom->nlocal, comm->nthreads, + _fix->three_body_neighbor(), off_end, + _fix->nbor_pack_width()); + + int need_ic = 0; + if (atom->molecular != Atom::ATOMIC) + dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, + neighbor->cutneighmax); + + #ifdef _LMP_INTEL_OFFLOAD + if (_fix->three_body_neighbor()) { + if (need_ic) { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } else { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } + } else { + if (need_ic) { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } else { + if (offload_noghost) { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal, off_end); + } else { + bin_newton(1, list, buffers, 0, off_end); + bin_newton(0, list, buffers, host_start, nlocal); + } + } + } + #else + if (_fix->three_body_neighbor()) { + if (need_ic) + bin_newton(0, list, buffers, host_start, nlocal); + else + bin_newton(0, list, buffers, host_start, nlocal); + } else { + if (need_ic) + bin_newton(0, list, buffers, host_start, nlocal); + else + bin_newton(0, list, buffers, host_start, nlocal); + } + #endif +} diff --git a/src/INTEL/npair_half_bin_newton_tri_intel.h b/src/INTEL/npair_bin_intel.h similarity index 59% rename from src/INTEL/npair_half_bin_newton_tri_intel.h rename to src/INTEL/npair_bin_intel.h index 8ef65c12e5..fd18f20be5 100644 --- a/src/INTEL/npair_half_bin_newton_tri_intel.h +++ b/src/INTEL/npair_bin_intel.h @@ -14,20 +14,38 @@ #ifdef NPAIR_CLASS // clang-format off +NPairStyle(half/bin/newton/intel, + NPairHalfBinNewtonIntel, + NP_HALF | NP_BIN | NP_NEWTON | NP_ORTHO | NP_INTEL); + NPairStyle(half/bin/newton/tri/intel, NPairHalfBinNewtonTriIntel, NP_HALF | NP_BIN | NP_NEWTON | NP_TRI | NP_INTEL); + +NPairStyle(full/bin/intel, + NPairFullBinIntel, + NP_FULL | NP_BIN | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | + NP_INTEL); // clang-format on #else -#ifndef LMP_NPAIR_HALF_BIN_NEWTON_INTEL_TRI_H -#define LMP_NPAIR_HALF_BIN_NEWTON_INTEL_TRI_H +#ifndef LMP_NPAIR_BIN_INTEL_H +#define LMP_NPAIR_BIN_INTEL_H #include "fix_intel.h" #include "npair_intel.h" namespace LAMMPS_NS { +class NPairHalfBinNewtonIntel : public NPairIntel { + public: + NPairHalfBinNewtonIntel(class LAMMPS *); + void build(class NeighList *) override; + + private: + template void hbni(NeighList *, IntelBuffers *); +}; + class NPairHalfBinNewtonTriIntel : public NPairIntel { public: NPairHalfBinNewtonTriIntel(class LAMMPS *); @@ -37,6 +55,15 @@ class NPairHalfBinNewtonTriIntel : public NPairIntel { template void hbnti(NeighList *, IntelBuffers *); }; +class NPairFullBinIntel : public NPairIntel { + public: + NPairFullBinIntel(class LAMMPS *); + void build(class NeighList *) override; + + private: + template void fbi(NeighList *, IntelBuffers *); +}; + } // namespace LAMMPS_NS #endif diff --git a/src/INTEL/npair_full_bin_intel.cpp b/src/INTEL/npair_full_bin_intel.cpp deleted file mode 100644 index 2f8af4c8af..0000000000 --- a/src/INTEL/npair_full_bin_intel.cpp +++ /dev/null @@ -1,134 +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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) -------------------------------------------------------------------------- */ - -#include "npair_full_bin_intel.h" - -#include "atom.h" -#include "comm.h" -#include "error.h" -#include "neigh_list.h" -#include "neighbor.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairFullBinIntel::NPairFullBinIntel(LAMMPS *lmp) : NPairIntel(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction for all neighbors - every neighbor pair appears in list of both atoms i and j -------------------------------------------------------------------------- */ - -void NPairFullBinIntel::build(NeighList *list) -{ - if (nstencil > INTEL_MAX_STENCIL_CHECK) - error->all(FLERR, "Too many neighbor bins for INTEL package."); - - #ifdef _LMP_INTEL_OFFLOAD - if (exclude) - error->all(FLERR, "Exclusion lists not yet supported for Intel offload"); - #endif - - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) - fbi(list, _fix->get_mixed_buffers()); - else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) - fbi(list, _fix->get_double_buffers()); - else - fbi(list, _fix->get_single_buffers()); - - _fix->stop_watch(TIME_HOST_NEIGHBOR); -} - -template -void NPairFullBinIntel:: -fbi(NeighList *list, IntelBuffers *buffers) { - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - list->inum = nlocal; - list->gnum = 0; - - int host_start = _fix->host_start_neighbor();; - const int off_end = _fix->offload_end_neighbor(); - - #ifdef _LMP_INTEL_OFFLOAD - if (off_end) grow_stencil(); - if (_fix->full_host_list()) host_start = 0; - int offload_noghost = _fix->offload_noghost(); - #endif - - buffers->grow_list(list, atom->nlocal, comm->nthreads, - _fix->three_body_neighbor(), off_end, - _fix->nbor_pack_width()); - - int need_ic = 0; - if (atom->molecular != Atom::ATOMIC) - dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, - neighbor->cutneighmax); - - #ifdef _LMP_INTEL_OFFLOAD - if (_fix->three_body_neighbor()) { - if (need_ic) { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } else { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } - } else { - if (need_ic) { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } else { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } - } - #else - if (_fix->three_body_neighbor()) { - if (need_ic) - bin_newton(0, list, buffers, host_start, nlocal); - else - bin_newton(0, list, buffers, host_start, nlocal); - } else { - if (need_ic) - bin_newton(0, list, buffers, host_start, nlocal); - else - bin_newton(0, list, buffers, host_start, nlocal); - } - #endif -} diff --git a/src/INTEL/npair_full_bin_intel.h b/src/INTEL/npair_full_bin_intel.h deleted file mode 100644 index 58ff21d22c..0000000000 --- a/src/INTEL/npair_full_bin_intel.h +++ /dev/null @@ -1,44 +0,0 @@ -// clang-format off -/* -*- 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 -NPairStyle(full/bin/intel, - NPairFullBinIntel, - NP_FULL | NP_BIN | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | - NP_INTEL); -// clang-format on -#else - -#ifndef LMP_NPAIR_FULL_BIN_INTEL_H -#define LMP_NPAIR_FULL_BIN_INTEL_H - -#include "fix_intel.h" -#include "npair_intel.h" - -namespace LAMMPS_NS { - -class NPairFullBinIntel : public NPairIntel { - public: - NPairFullBinIntel(class LAMMPS *); - void build(class NeighList *) override; - - private: - template void fbi(NeighList *, IntelBuffers *); -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/INTEL/npair_half_bin_newton_intel.cpp b/src/INTEL/npair_half_bin_newton_intel.cpp deleted file mode 100644 index 24e8b01572..0000000000 --- a/src/INTEL/npair_half_bin_newton_intel.cpp +++ /dev/null @@ -1,108 +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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) -------------------------------------------------------------------------- */ - -#include "npair_half_bin_newton_intel.h" - -#include "atom.h" -#include "comm.h" -#include "error.h" -#include "neigh_list.h" -#include "neighbor.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtonIntel::NPairHalfBinNewtonIntel(LAMMPS *lmp) : - NPairIntel(lmp) {} - -/* ---------------------------------------------------------------------- - 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 -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtonIntel::build(NeighList *list) -{ - if (nstencil / 2 > INTEL_MAX_STENCIL_CHECK) - error->all(FLERR, "Too many neighbor bins for INTEL package."); - - #ifdef _LMP_INTEL_OFFLOAD - if (exclude) - error->all(FLERR, "Exclusion lists not yet supported for Intel offload"); - #endif - - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) - hbni(list, _fix->get_mixed_buffers()); - else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) - hbni(list, _fix->get_double_buffers()); - else - hbni(list, _fix->get_single_buffers()); - - _fix->stop_watch(TIME_HOST_NEIGHBOR); -} - -template -void NPairHalfBinNewtonIntel:: -hbni(NeighList *list, IntelBuffers *buffers) { - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - list->inum = nlocal; - - int host_start = _fix->host_start_neighbor(); - const int off_end = _fix->offload_end_neighbor(); - - #ifdef _LMP_INTEL_OFFLOAD - if (off_end) grow_stencil(); - if (_fix->full_host_list()) host_start = 0; - int offload_noghost = _fix->offload_noghost(); - #endif - - buffers->grow_list(list, atom->nlocal, comm->nthreads, 0, off_end); - - int need_ic = 0; - if (atom->molecular != Atom::ATOMIC) - dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, - neighbor->cutneighmax); - - #ifdef _LMP_INTEL_OFFLOAD - if (need_ic) { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, - off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } else { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, - off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } - #else - if (need_ic) - bin_newton(0, list, buffers, host_start, nlocal); - else - bin_newton(0, list, buffers, host_start, nlocal); - #endif -} diff --git a/src/INTEL/npair_half_bin_newton_intel.h b/src/INTEL/npair_half_bin_newton_intel.h deleted file mode 100644 index 092d4f2101..0000000000 --- a/src/INTEL/npair_half_bin_newton_intel.h +++ /dev/null @@ -1,43 +0,0 @@ -// clang-format off -/* -*- 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 -NPairStyle(half/bin/newton/intel, - NPairHalfBinNewtonIntel, - NP_HALF | NP_BIN | NP_NEWTON | NP_ORTHO | NP_INTEL); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALF_BIN_NEWTON_INTEL_H -#define LMP_NPAIR_HALF_BIN_NEWTON_INTEL_H - -#include "fix_intel.h" -#include "npair_intel.h" - -namespace LAMMPS_NS { - -class NPairHalfBinNewtonIntel : public NPairIntel { - public: - NPairHalfBinNewtonIntel(class LAMMPS *); - void build(class NeighList *) override; - - private: - template void hbni(NeighList *, IntelBuffers *); -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/INTEL/npair_half_bin_newton_tri_intel.cpp b/src/INTEL/npair_half_bin_newton_tri_intel.cpp deleted file mode 100644 index a903ef8e9a..0000000000 --- a/src/INTEL/npair_half_bin_newton_tri_intel.cpp +++ /dev/null @@ -1,108 +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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) -------------------------------------------------------------------------- */ - -#include "npair_half_bin_newton_tri_intel.h" - -#include "atom.h" -#include "comm.h" -#include "error.h" -#include "neigh_list.h" -#include "neighbor.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalfBinNewtonTriIntel::NPairHalfBinNewtonTriIntel(LAMMPS *lmp) : - NPairIntel(lmp) {} - -/* ---------------------------------------------------------------------- - binned neighbor list construction with Newton's 3rd law for triclinic - each owned atom i checks its own bin and other bins in triclinic stencil - every pair stored exactly once by some processor -------------------------------------------------------------------------- */ - -void NPairHalfBinNewtonTriIntel::build(NeighList *list) -{ - if (nstencil > INTEL_MAX_STENCIL) - error->all(FLERR, "Too many neighbor bins for INTEL package."); - - #ifdef _LMP_INTEL_OFFLOAD - if (exclude) - error->all(FLERR, "Exclusion lists not yet supported for Intel offload"); - #endif - - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) - hbnti(list, _fix->get_mixed_buffers()); - else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) - hbnti(list, _fix->get_double_buffers()); - else - hbnti(list, _fix->get_single_buffers()); - - _fix->stop_watch(TIME_HOST_NEIGHBOR); -} - -template -void NPairHalfBinNewtonTriIntel:: -hbnti(NeighList *list, IntelBuffers *buffers) { - const int nlocal = (includegroup) ? atom->nfirst : atom->nlocal; - list->inum = nlocal; - - int host_start = _fix->host_start_neighbor(); - const int off_end = _fix->offload_end_neighbor(); - - #ifdef _LMP_INTEL_OFFLOAD - if (off_end) grow_stencil(); - if (_fix->full_host_list()) host_start = 0; - int offload_noghost = _fix->offload_noghost(); - #endif - - buffers->grow_list(list, atom->nlocal, comm->nthreads, 0, off_end); - - int need_ic = 0; - if (atom->molecular != Atom::ATOMIC) - dminimum_image_check(need_ic, neighbor->cutneighmax, neighbor->cutneighmax, - neighbor->cutneighmax); - - #ifdef _LMP_INTEL_OFFLOAD - if (need_ic) { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, - off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } else { - if (offload_noghost) { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal, - off_end); - } else { - bin_newton(1, list, buffers, 0, off_end); - bin_newton(0, list, buffers, host_start, nlocal); - } - } - #else - if (need_ic) - bin_newton(0, list, buffers, host_start, nlocal); - else - bin_newton(0, list, buffers, host_start, nlocal); - #endif -} diff --git a/src/INTEL/npair_halffull_newton_trim_intel.cpp b/src/INTEL/npair_halffull_intel.cpp similarity index 56% rename from src/INTEL/npair_halffull_newton_trim_intel.cpp rename to src/INTEL/npair_halffull_intel.cpp index e38375f750..42ecb716f5 100644 --- a/src/INTEL/npair_halffull_newton_trim_intel.cpp +++ b/src/INTEL/npair_halffull_intel.cpp @@ -13,10 +13,10 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL) + Contributing author: W. Michael Brown (Intel) ------------------------------------------------------------------------- */ -#include "npair_halffull_newton_trim_intel.h" +#include "npair_halffull_intel.h" #include "atom.h" #include "comm.h" @@ -29,6 +29,204 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ +NPairHalffullNewtonIntel::NPairHalffullNewtonIntel(LAMMPS *lmp) : NPair(lmp) { + _fix = static_cast(modify->get_fix_by_id("package_intel")); + if (!_fix) error->all(FLERR, "The 'package intel' command is required for /intel styles"); +} + +/* ---------------------------------------------------------------------- + build half list from full list + pair stored once if i,j are both owned and i < j + if j is ghost, only store if j coords are "above and to the right" of i + works if full list is a skip list +------------------------------------------------------------------------- */ + +template +void NPairHalffullNewtonIntel::build_t(NeighList *list, + IntelBuffers *buffers) +{ + const int inum_full = list->listfull->inum; + const int nlocal = atom->nlocal; + const int e_nall = nlocal + atom->nghost; + const ATOM_T * _noalias const x = buffers->get_x(); + int * _noalias const ilist = list->ilist; + int * _noalias const numneigh = list->numneigh; + int ** _noalias const firstneigh = list->firstneigh; + const int * _noalias const ilist_full = list->listfull->ilist; + const int * _noalias const numneigh_full = list->listfull->numneigh; + const int ** _noalias const firstneigh_full = (const int ** const)list->listfull->firstneigh; // NOLINT + + #if defined(_OPENMP) + #pragma omp parallel + #endif + { + int tid, ifrom, ito; + IP_PRE_omp_range_id(ifrom, ito, tid, inum_full, comm->nthreads); + + // each thread has its own page allocator + MyPage &ipage = list->ipage[tid]; + ipage.reset(); + + // loop over parent full list + for (int ii = ifrom; ii < ito; ii++) { + int n = 0; + int *neighptr = ipage.vget(); + + const int i = ilist_full[ii]; + const flt_t xtmp = x[i].x; + const flt_t ytmp = x[i].y; + const flt_t ztmp = x[i].z; + + // loop over full neighbor list + + const int * _noalias const jlist = firstneigh_full[i]; + const int jnum = numneigh_full[i]; + + #if defined(LMP_SIMD_COMPILER) + #pragma vector aligned + #pragma ivdep + #endif + for (int jj = 0; jj < jnum; jj++) { + const int joriginal = jlist[jj]; + const int j = joriginal & NEIGHMASK; + int addme = 1; + if (j < nlocal) { + if (i > j) addme = 0; + } else { + if (x[j].z < ztmp) addme = 0; + if (x[j].z == ztmp) { + if (x[j].y < ytmp) addme = 0; + if (x[j].y == ytmp && x[j].x < xtmp) addme = 0; + } + } + if (addme) + neighptr[n++] = joriginal; + } + + ilist[ii] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + + int pad_end = n; + IP_PRE_neighbor_pad(pad_end, 0); + #if defined(LMP_SIMD_COMPILER) + #pragma vector aligned + #pragma loop_count min=1, max=INTEL_COMPILE_WIDTH-1, \ + avg=INTEL_COMPILE_WIDTH/2 + #endif + for ( ; n < pad_end; n++) + neighptr[n] = e_nall; + + ipage.vgot(n); + if (ipage.status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + } + list->inum = inum_full; +} + +/* ---------------------------------------------------------------------- + build half list from full 3-body list + half list is already stored as first part of 3-body list +------------------------------------------------------------------------- */ + +template +void NPairHalffullNewtonIntel::build_t3(NeighList *list, int *numhalf) +{ + const int inum_full = list->listfull->inum; + const int e_nall = atom->nlocal + atom->nghost; + int * _noalias const ilist = list->ilist; + int * _noalias const numneigh = list->numneigh; + int ** _noalias const firstneigh = list->firstneigh; + const int * _noalias const ilist_full = list->listfull->ilist; + const int * _noalias const numneigh_full = numhalf; + const int ** _noalias const firstneigh_full = (const int ** const)list->listfull->firstneigh; // NOLINT + + int packthreads = 1; + if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; + + #if defined(_OPENMP) + #pragma omp parallel if (packthreads > 1) + #endif + { + int tid, ifrom, ito; + IP_PRE_omp_range_id(ifrom, ito, tid, inum_full, packthreads); + + // each thread has its own page allocator + MyPage &ipage = list->ipage[tid]; + ipage.reset(); + + // loop over parent full list + for (int ii = ifrom; ii < ito; ii++) { + int n = 0; + int *neighptr = ipage.vget(); + + const int i = ilist_full[ii]; + + // loop over full neighbor list + + const int * _noalias const jlist = firstneigh_full[i]; + const int jnum = numneigh_full[ii]; + + #if defined(LMP_SIMD_COMPILER) + #pragma vector aligned + #pragma ivdep + #endif + for (int jj = 0; jj < jnum; jj++) { + const int joriginal = jlist[jj]; + neighptr[n++] = joriginal; + } + + ilist[ii] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + + int pad_end = n; + IP_PRE_neighbor_pad(pad_end, 0); + #if defined(LMP_SIMD_COMPILER) + #pragma vector aligned + #pragma loop_count min=1, max=INTEL_COMPILE_WIDTH-1, \ + avg=INTEL_COMPILE_WIDTH/2 + #endif + for ( ; n < pad_end; n++) + neighptr[n] = e_nall; + + ipage.vgot(n); + if (ipage.status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + } + list->inum = inum_full; +} + +/* ---------------------------------------------------------------------- */ + +void NPairHalffullNewtonIntel::build(NeighList *list) +{ + if (_fix->three_body_neighbor() == 0) { + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) + build_t(list, _fix->get_mixed_buffers()); + else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) + build_t(list, _fix->get_double_buffers()); + else + build_t(list, _fix->get_single_buffers()); + } else { + int *nhalf, *cnum; + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) { + _fix->get_mixed_buffers()->get_list_data3(list->listfull, nhalf, cnum); + build_t3(list, nhalf); + } else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) { + _fix->get_double_buffers()->get_list_data3(list->listfull, nhalf, cnum); + build_t3(list, nhalf); + } else { + _fix->get_single_buffers()->get_list_data3(list->listfull, nhalf, cnum); + build_t3(list, nhalf); + } + } +} + +/* ---------------------------------------------------------------------- */ + NPairHalffullNewtonTrimIntel::NPairHalffullNewtonTrimIntel(LAMMPS *lmp) : NPair(lmp) { _fix = static_cast(modify->get_fix_by_id("package_intel")); if (!_fix) error->all(FLERR, "The 'package intel' command is required for /intel styles"); diff --git a/src/INTEL/npair_halffull_intel.h b/src/INTEL/npair_halffull_intel.h new file mode 100644 index 0000000000..08c9312fff --- /dev/null +++ b/src/INTEL/npair_halffull_intel.h @@ -0,0 +1,128 @@ +// clang-format off +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: W. Michael Brown (Intel) +------------------------------------------------------------------------- */ + +// For Newton off, only used for hybrid to generate list for non-intel style. +// Use standard routines. + +#ifdef NPAIR_CLASS +// clang-format off +NPairStyle(halffull/newton/intel, + NPairHalffullNewtonIntel, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | + NP_ORTHO | NP_TRI| NP_INTEL); + +NPairStyle(halffull/newton/skip/intel, + NPairHalffullNewtonIntel, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | + NP_ORTHO | NP_TRI | NP_SKIP | NP_INTEL); + +NPairStyle(halffull/newtoff/intel, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_INTEL); + +NPairStyle(halffull/newtoff/skip/intel, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_INTEL); + +NPairStyle(halffull/newtoff/ghost/intel, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_GHOST | NP_INTEL); + +NPairStyle(halffull/newtoff/skip/ghost/intel, + NPairHalffullNewtoff, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_INTEL); + + +NPairStyle(halffull/newton/trim/intel, + NPairHalffullNewtonTrimIntel, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | + NP_ORTHO | NP_TRI| NP_TRIM | NP_INTEL); + +NPairStyle(halffull/newton/skip/trim/intel, + NPairHalffullNewtonTrimIntel, + NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | + NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_INTEL); + +NPairStyle(halffull/newtoff/trim/intel, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_TRIM | NP_INTEL); + +NPairStyle(halffull/newtoff/skip/trim/intel, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_INTEL); + +NPairStyle(halffull/newtoff/ghost/trim/intel, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM | NP_INTEL); + +NPairStyle(halffull/newtoff/skip/ghost/trim/intel, + NPairHalffullNewtoffTrim, + NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | + NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_TRIM | NP_INTEL); +// clang-format on +#else + +#ifndef LMP_NPAIR_HALFFULL_INTEL_H +#define LMP_NPAIR_HALFFULL_INTEL_H + +#include "fix_intel.h" +#include "npair.h" + +#if defined(_OPENMP) +#include +#endif + +namespace LAMMPS_NS { + +class NPairHalffullNewtonIntel : public NPair { + public: + NPairHalffullNewtonIntel(class LAMMPS *); + void build(class NeighList *) override; + + protected: + FixIntel *_fix; + + template void build_t(NeighList *, IntelBuffers *); + + template void build_t3(NeighList *, int *); +}; + +class NPairHalffullNewtonTrimIntel : public NPair { + public: + NPairHalffullNewtonTrimIntel(class LAMMPS *); + void build(class NeighList *) override; + + protected: + FixIntel *_fix; + + template void build_t(NeighList *, IntelBuffers *); + + template void build_t3(NeighList *, int *, IntelBuffers *); +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/INTEL/npair_halffull_newtoff_intel.h b/src/INTEL/npair_halffull_newtoff_intel.h deleted file mode 100644 index f77ddb74d6..0000000000 --- a/src/INTEL/npair_halffull_newtoff_intel.h +++ /dev/null @@ -1,44 +0,0 @@ -// clang-format off -/* -*- 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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) -------------------------------------------------------------------------- */ - -// Only used for hybrid to generate list for non-intel style. Use -// standard routines. - -#ifdef NPAIR_CLASS -// clang-format off -NPairStyle(halffull/newtoff/intel, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_INTEL); - -NPairStyle(halffull/newtoff/skip/intel, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_INTEL); - -NPairStyle(halffull/newtoff/ghost/intel, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_GHOST | NP_INTEL); - -NPairStyle(halffull/newtoff/skip/ghost/intel, - NPairHalffullNewtoff, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_INTEL); -// clang-format on -#endif diff --git a/src/INTEL/npair_halffull_newtoff_trim_intel.h b/src/INTEL/npair_halffull_newtoff_trim_intel.h deleted file mode 100644 index d8594ce3b8..0000000000 --- a/src/INTEL/npair_halffull_newtoff_trim_intel.h +++ /dev/null @@ -1,44 +0,0 @@ -// clang-format off -/* -*- 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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL) -------------------------------------------------------------------------- */ - -// Only used for hybrid to generate list for non-intel style. Use -// standard routines. - -#ifdef NPAIR_CLASS -// clang-format off -NPairStyle(halffull/newtoff/trim/intel, - NPairHalffullNewtoffTrim, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_TRIM | NP_INTEL); - -NPairStyle(halffull/newtoff/skip/trim/intel, - NPairHalffullNewtoffTrim, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_INTEL); - -NPairStyle(halffull/newtoff/ghost/trim/intel, - NPairHalffullNewtoffTrim, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM | NP_INTEL); - -NPairStyle(halffull/newtoff/skip/ghost/trim/intel, - NPairHalffullNewtoffTrim, - NP_HALF_FULL | NP_NEWTOFF | NP_NSQ | NP_BIN | NP_MULTI | NP_HALF | - NP_ORTHO | NP_TRI | NP_SKIP | NP_GHOST | NP_TRIM | NP_INTEL); -// clang-format on -#endif diff --git a/src/INTEL/npair_halffull_newton_intel.cpp b/src/INTEL/npair_halffull_newton_intel.cpp deleted file mode 100644 index cd05d5f97a..0000000000 --- a/src/INTEL/npair_halffull_newton_intel.cpp +++ /dev/null @@ -1,226 +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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) -------------------------------------------------------------------------- */ - -#include "npair_halffull_newton_intel.h" - -#include "atom.h" -#include "comm.h" -#include "error.h" -#include "modify.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairHalffullNewtonIntel::NPairHalffullNewtonIntel(LAMMPS *lmp) : NPair(lmp) { - _fix = static_cast(modify->get_fix_by_id("package_intel")); - if (!_fix) error->all(FLERR, "The 'package intel' command is required for /intel styles"); -} - -/* ---------------------------------------------------------------------- - build half list from full list - pair stored once if i,j are both owned and i < j - if j is ghost, only store if j coords are "above and to the right" of i - works if full list is a skip list -------------------------------------------------------------------------- */ - -template -void NPairHalffullNewtonIntel::build_t(NeighList *list, - IntelBuffers *buffers) -{ - const int inum_full = list->listfull->inum; - const int nlocal = atom->nlocal; - const int e_nall = nlocal + atom->nghost; - const ATOM_T * _noalias const x = buffers->get_x(); - int * _noalias const ilist = list->ilist; - int * _noalias const numneigh = list->numneigh; - int ** _noalias const firstneigh = list->firstneigh; - const int * _noalias const ilist_full = list->listfull->ilist; - const int * _noalias const numneigh_full = list->listfull->numneigh; - const int ** _noalias const firstneigh_full = (const int ** const)list->listfull->firstneigh; // NOLINT - - #if defined(_OPENMP) - #pragma omp parallel - #endif - { - int tid, ifrom, ito; - IP_PRE_omp_range_id(ifrom, ito, tid, inum_full, comm->nthreads); - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - // loop over parent full list - for (int ii = ifrom; ii < ito; ii++) { - int n = 0; - int *neighptr = ipage.vget(); - - const int i = ilist_full[ii]; - const flt_t xtmp = x[i].x; - const flt_t ytmp = x[i].y; - const flt_t ztmp = x[i].z; - - // loop over full neighbor list - - const int * _noalias const jlist = firstneigh_full[i]; - const int jnum = numneigh_full[i]; - - #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma ivdep - #endif - for (int jj = 0; jj < jnum; jj++) { - const int joriginal = jlist[jj]; - const int j = joriginal & NEIGHMASK; - int addme = 1; - if (j < nlocal) { - if (i > j) addme = 0; - } else { - if (x[j].z < ztmp) addme = 0; - if (x[j].z == ztmp) { - if (x[j].y < ytmp) addme = 0; - if (x[j].y == ytmp && x[j].x < xtmp) addme = 0; - } - } - if (addme) - neighptr[n++] = joriginal; - } - - ilist[ii] = i; - firstneigh[i] = neighptr; - numneigh[i] = n; - - int pad_end = n; - IP_PRE_neighbor_pad(pad_end, 0); - #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma loop_count min=1, max=INTEL_COMPILE_WIDTH-1, \ - avg=INTEL_COMPILE_WIDTH/2 - #endif - for ( ; n < pad_end; n++) - neighptr[n] = e_nall; - - ipage.vgot(n); - if (ipage.status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - } - list->inum = inum_full; -} - -/* ---------------------------------------------------------------------- - build half list from full 3-body list - half list is already stored as first part of 3-body list -------------------------------------------------------------------------- */ - -template -void NPairHalffullNewtonIntel::build_t3(NeighList *list, int *numhalf) -{ - const int inum_full = list->listfull->inum; - const int e_nall = atom->nlocal + atom->nghost; - int * _noalias const ilist = list->ilist; - int * _noalias const numneigh = list->numneigh; - int ** _noalias const firstneigh = list->firstneigh; - const int * _noalias const ilist_full = list->listfull->ilist; - const int * _noalias const numneigh_full = numhalf; - const int ** _noalias const firstneigh_full = (const int ** const)list->listfull->firstneigh; // NOLINT - - int packthreads = 1; - if (comm->nthreads > INTEL_HTHREADS) packthreads = comm->nthreads; - - #if defined(_OPENMP) - #pragma omp parallel if (packthreads > 1) - #endif - { - int tid, ifrom, ito; - IP_PRE_omp_range_id(ifrom, ito, tid, inum_full, packthreads); - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - // loop over parent full list - for (int ii = ifrom; ii < ito; ii++) { - int n = 0; - int *neighptr = ipage.vget(); - - const int i = ilist_full[ii]; - - // loop over full neighbor list - - const int * _noalias const jlist = firstneigh_full[i]; - const int jnum = numneigh_full[ii]; - - #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma ivdep - #endif - for (int jj = 0; jj < jnum; jj++) { - const int joriginal = jlist[jj]; - neighptr[n++] = joriginal; - } - - ilist[ii] = i; - firstneigh[i] = neighptr; - numneigh[i] = n; - - int pad_end = n; - IP_PRE_neighbor_pad(pad_end, 0); - #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma loop_count min=1, max=INTEL_COMPILE_WIDTH-1, \ - avg=INTEL_COMPILE_WIDTH/2 - #endif - for ( ; n < pad_end; n++) - neighptr[n] = e_nall; - - ipage.vgot(n); - if (ipage.status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - } - list->inum = inum_full; -} - -/* ---------------------------------------------------------------------- */ - -void NPairHalffullNewtonIntel::build(NeighList *list) -{ - if (_fix->three_body_neighbor() == 0) { - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) - build_t(list, _fix->get_mixed_buffers()); - else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) - build_t(list, _fix->get_double_buffers()); - else - build_t(list, _fix->get_single_buffers()); - } else { - int *nhalf, *cnum; - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) { - _fix->get_mixed_buffers()->get_list_data3(list->listfull, nhalf, cnum); - build_t3(list, nhalf); - } else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - _fix->get_double_buffers()->get_list_data3(list->listfull, nhalf, cnum); - build_t3(list, nhalf); - } else { - _fix->get_single_buffers()->get_list_data3(list->listfull, nhalf, cnum); - build_t3(list, nhalf); - } - } -} diff --git a/src/INTEL/npair_halffull_newton_intel.h b/src/INTEL/npair_halffull_newton_intel.h deleted file mode 100644 index 149983d08e..0000000000 --- a/src/INTEL/npair_halffull_newton_intel.h +++ /dev/null @@ -1,61 +0,0 @@ -// clang-format off -/* -*- 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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) -------------------------------------------------------------------------- */ - -#ifdef NPAIR_CLASS -// clang-format off -NPairStyle(halffull/newton/intel, - NPairHalffullNewtonIntel, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | - NP_ORTHO | NP_TRI| NP_INTEL); - -NPairStyle(halffull/newton/skip/intel, - NPairHalffullNewtonIntel, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | - NP_ORTHO | NP_TRI | NP_SKIP | NP_INTEL); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTON_INTEL_H -#define LMP_NPAIR_HALFFULL_NEWTON_INTEL_H - -#include "fix_intel.h" -#include "npair.h" - -#if defined(_OPENMP) -#include -#endif - -namespace LAMMPS_NS { - -class NPairHalffullNewtonIntel : public NPair { - public: - NPairHalffullNewtonIntel(class LAMMPS *); - void build(class NeighList *) override; - - protected: - FixIntel *_fix; - - template void build_t(NeighList *, IntelBuffers *); - - template void build_t3(NeighList *, int *); -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/INTEL/npair_halffull_newton_trim_intel.h b/src/INTEL/npair_halffull_newton_trim_intel.h deleted file mode 100644 index 0ca551d682..0000000000 --- a/src/INTEL/npair_halffull_newton_trim_intel.h +++ /dev/null @@ -1,61 +0,0 @@ -// clang-format off -/* -*- 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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL) -------------------------------------------------------------------------- */ - -#ifdef NPAIR_CLASS -// clang-format off -NPairStyle(halffull/newton/trim/intel, - NPairHalffullNewtonTrimIntel, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | - NP_ORTHO | NP_TRI| NP_TRIM | NP_INTEL); - -NPairStyle(halffull/newton/skip/trim/intel, - NPairHalffullNewtonTrimIntel, - NP_HALF_FULL | NP_NEWTON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | - NP_ORTHO | NP_TRI | NP_SKIP | NP_TRIM | NP_INTEL); -// clang-format on -#else - -#ifndef LMP_NPAIR_HALFFULL_NEWTON_TRIM_INTEL_H -#define LMP_NPAIR_HALFFULL_NEWTON_TRIM_INTEL_H - -#include "fix_intel.h" -#include "npair.h" - -#if defined(_OPENMP) -#include -#endif - -namespace LAMMPS_NS { - -class NPairHalffullNewtonTrimIntel : public NPair { - public: - NPairHalffullNewtonTrimIntel(class LAMMPS *); - void build(class NeighList *) override; - - protected: - FixIntel *_fix; - - template void build_t(NeighList *, IntelBuffers *); - - template void build_t3(NeighList *, int *, IntelBuffers *); -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/INTEL/nstencil_bin_intel.cpp b/src/INTEL/nstencil_bin_intel.cpp new file mode 100644 index 0000000000..36a79e2997 --- /dev/null +++ b/src/INTEL/nstencil_bin_intel.cpp @@ -0,0 +1,70 @@ +/* ---------------------------------------------------------------------- + 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 "nstencil_bin_intel.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NStencilBinIntel::NStencilBinIntel(LAMMPS *lmp) : NStencil(lmp) {} + +/* ---------------------------------------------------------------------- + create stencil based on bin geometry and cutoff +------------------------------------------------------------------------- */ + +template +void NStencilBinIntel::create() +{ + int i, j, k; + + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF && (!DIM_3D)) sy_min = 0; + if (HALF && DIM_3D) sz_min = 0; + + nstencil = 0; + + // For Intel, half and ortho stencils do not include central bin + // as, historically, this was never included in a stencil. + // Non-Intel npair classes were updated to account for this change, + // but the Intel npair classes have not yet been updated + // if (HALF && (!TRI)) stencil[nstencil++] = 0; + + for (k = -sz_min; k <= sz; k++) { + for (j = -sy_min; j <= sy; j++) { + for (i = -sx; i <= sx; i++) { + + // Now only include "upper right" bins for half and ortho stencils + if (HALF && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i > 0))) continue; + if (HALF && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + + if (bin_distance(i,j,k) < cutneighmaxsq) + stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; + } + } + } +} + +namespace LAMMPS_NS { +template class NStencilBinIntel<0,0,0>; +template class NStencilBinIntel<0,1,0>; +template class NStencilBinIntel<1,0,0>; +template class NStencilBinIntel<1,0,1>; +template class NStencilBinIntel<1,1,0>; +template class NStencilBinIntel<1,1,1>; +} diff --git a/src/INTEL/nstencil_bin_intel.h b/src/INTEL/nstencil_bin_intel.h new file mode 100644 index 0000000000..e377db5fe5 --- /dev/null +++ b/src/INTEL/nstencil_bin_intel.h @@ -0,0 +1,65 @@ +/* -*- 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 NSTENCIL_CLASS +// clang-format off +typedef NStencilBinIntel<0, 0, 0> NStencilFullBin2dIntel; +NStencilStyle(full/bin/2d/intel, + NStencilFullBin2dIntel, + NS_FULL | NS_BIN | NS_2D | NS_ORTHO | NS_TRI | NS_INTEL); + +typedef NStencilBinIntel<0, 1, 0> NStencilFullBin3dIntel; +NStencilStyle(full/bin/3d/intel, + NStencilFullBin3dIntel, + NS_FULL | NS_BIN | NS_3D | NS_ORTHO | NS_TRI | NS_INTEL); + +typedef NStencilBinIntel<1, 0, 0> NStencilHalfBin2dIntel; +NStencilStyle(half/bin/2d/intel, + NStencilHalfBin2dIntel, + NS_HALF | NS_BIN | NS_2D | NS_ORTHO | NS_INTEL); + +typedef NStencilBinIntel<1, 0, 1> NStencilHalfBin2dTriIntel; +NStencilStyle(half/bin/2d/tri/intel, + NStencilHalfBin2dTriIntel, + NS_HALF | NS_BIN | NS_2D | NS_TRI | NS_INTEL); + +typedef NStencilBinIntel<1, 1, 0> NStencilHalfBin3dIntel; +NStencilStyle(half/bin/3d/intel, + NStencilHalfBin3dIntel, + NS_HALF | NS_BIN | NS_3D | NS_ORTHO | NS_INTEL); + +typedef NStencilBinIntel<1, 1, 1> NStencilHalfBin3dTriIntel; +NStencilStyle(half/bin/3d/tri/intel, + NStencilHalfBin3dTriIntel, + NS_HALF | NS_BIN | NS_3D | NS_TRI | NS_INTEL); +// clang-format on +#else + +#ifndef LMP_NSTENCIL_BIN_INTEL_H +#define LMP_NSTENCIL_BIN_INTEL_H + +#include "nstencil.h" + +namespace LAMMPS_NS { + +template +class NStencilBinIntel : public NStencil { + public: + NStencilBinIntel(class LAMMPS *); + void create() override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 006101da64..52979ed83e 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -1991,6 +1991,7 @@ int Neighbor::choose_stencil(NeighRequest *rq) // require match of these request flags and mask bits // (!A != !B) is effectively a logical xor + if (!rq->intel != !(mask & NS_INTEL)) continue; if (!rq->ghost != !(mask & NS_GHOST)) continue; if (!rq->ssa != !(mask & NS_SSA)) continue; diff --git a/src/neighbor.h b/src/neighbor.h index 9c51361aa8..fe2aea0779 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -302,8 +302,9 @@ namespace NeighConst { NS_ORTHO = 1 << 6, NS_TRI = 1 << 7, NS_GHOST = 1 << 8, - NS_SSA = 1 << 9, - NS_MULTI_OLD = 1 << 10 + NS_INTEL = 1 << 9, + NS_SSA = 1 << 10, + NS_MULTI_OLD = 1 << 11 }; enum { From 85765a2bf3242a2f6deb14a2d8c7084ec13076b4 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 12 Jun 2023 12:45:52 +0300 Subject: [PATCH 16/87] Include born_matrix() definition in bond_gaussian.h --- src/EXTRA-MOLECULE/bond_gaussian.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/bond_gaussian.h b/src/EXTRA-MOLECULE/bond_gaussian.h index 7af6f1f4d9..e466df47d4 100644 --- a/src/EXTRA-MOLECULE/bond_gaussian.h +++ b/src/EXTRA-MOLECULE/bond_gaussian.h @@ -35,6 +35,7 @@ class BondGaussian : public Bond { void read_restart(FILE *) override; void write_data(FILE *) override; double single(int, double, int, int, double &) override; + void born_matrix(int, double, int, int, double &, double &) override; protected: int *nterms; From a05fcc326efd1f7ebef08516ddf15b262c155215 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 12 Jun 2023 12:47:21 +0300 Subject: [PATCH 17/87] Implement born_matrix() in bond_gaussian.cpp --- src/EXTRA-MOLECULE/bond_gaussian.cpp | 45 +++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-MOLECULE/bond_gaussian.cpp b/src/EXTRA-MOLECULE/bond_gaussian.cpp index baca0b6e1a..816ab51516 100644 --- a/src/EXTRA-MOLECULE/bond_gaussian.cpp +++ b/src/EXTRA-MOLECULE/bond_gaussian.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ #include "bond_gaussian.h" - +#include #include "atom.h" #include "comm.h" #include "error.h" @@ -35,6 +35,7 @@ BondGaussian::BondGaussian(LAMMPS *lmp) : Bond(lmp), nterms(nullptr), bond_temperature(nullptr), alpha(nullptr), width(nullptr), r0(nullptr) { + born_matrix_enable = 1; } /* ---------------------------------------------------------------------- */ @@ -294,3 +295,45 @@ double BondGaussian::single(int type, double rsq, int /*i*/, int /*j*/, double & return -(force->boltz * bond_temperature[type]) * log(sum_g_i); } + +/* ---------------------------------------------------------------------- */ + +void BondGaussian::born_matrix(int type, double rsq, int /*i*/, int /*j*/, double &du, double &du2) +{ + double r = sqrt(rsq); + + // first derivative of energy with respect to distance + double sum_g_i = 0.0; + double sum_numerator = 0.0; + for (int i = 0; i < nterms[type]; i++) { + double dr = r - r0[type][i]; + double prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + double exponent = -2 * dr * dr / (width[type][i] * width[type][i]); + double g_i = prefactor * exp(exponent); + sum_g_i += g_i; + sum_numerator += g_i * dr / (width[type][i] * width[type][i]); + } + + if (sum_g_i < SMALL) sum_g_i = SMALL; + du = 4.0 * (force->boltz * bond_temperature[type]) * (sum_numerator / sum_g_i); + + // second derivative of energy with respect to distance + sum_g_i = 0.0; + double sum_dg_i = 0.0; + double sum_d2g_i = 0.0; + for (int i = 0; i < nterms[type]; i++) { + double dr = r - r0[type][i]; + double prefactor = (alpha[type][i] / (width[type][i] * sqrt(MY_PI2))); + double exponent = -2 * dr * dr / (width[type][i] * width[type][i]); + double g_i = prefactor * exp(exponent); + sum_g_i += g_i; + sum_dg_i -= 4.0 * g_i * dr / pow(width[type][i], 2); + sum_d2g_i += 4.0 * g_i * (4.0 * pow(r0[type][i], 2) - 8.0 * r0[type][i] * r - pow(width[type][i], 2) + 4.0 * r * r) / pow(width[type][i], 4) ; + } + + if (sum_g_i < SMALL) sum_g_i = SMALL; + double numerator = sum_d2g_i*sum_g_i - sum_dg_i*sum_dg_i; + double denominator = sum_g_i * sum_g_i; + + du2 = - (force->boltz * bond_temperature[type]) * numerator / denominator; +} From 42c843ff4f783069d409404be42fa89c43f60ccc Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Sun, 18 Jun 2023 18:24:24 +0300 Subject: [PATCH 18/87] remove iostream from bond_gaussian.cpp --- src/EXTRA-MOLECULE/bond_gaussian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-MOLECULE/bond_gaussian.cpp b/src/EXTRA-MOLECULE/bond_gaussian.cpp index 816ab51516..9a8546e278 100644 --- a/src/EXTRA-MOLECULE/bond_gaussian.cpp +++ b/src/EXTRA-MOLECULE/bond_gaussian.cpp @@ -12,7 +12,7 @@ ------------------------------------------------------------------------- */ #include "bond_gaussian.h" -#include + #include "atom.h" #include "comm.h" #include "error.h" From 4e17cc551e93faf1433bb002bfbde9838684c2eb Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Sun, 18 Jun 2023 18:25:35 +0300 Subject: [PATCH 19/87] inlcude born_matrix() definition in in angle_quartic.h --- src/EXTRA-MOLECULE/angle_quartic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/angle_quartic.h b/src/EXTRA-MOLECULE/angle_quartic.h index 3f0396f27b..7de51b24d1 100644 --- a/src/EXTRA-MOLECULE/angle_quartic.h +++ b/src/EXTRA-MOLECULE/angle_quartic.h @@ -35,6 +35,7 @@ class AngleQuartic : public Angle { void read_restart(FILE *) override; void write_data(FILE *) override; double single(int, int, int, int) override; + void born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) override; protected: double *k2, *k3, *k4, *theta0; From eb8512ba2a988b9baea384fe96aa935c28e6005a Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Sun, 18 Jun 2023 18:26:48 +0300 Subject: [PATCH 20/87] implementation of born_matrix() for angle_quartic.cpp --- src/EXTRA-MOLECULE/angle_quartic.cpp | 41 +++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-MOLECULE/angle_quartic.cpp b/src/EXTRA-MOLECULE/angle_quartic.cpp index f28e209a77..eaccdbe608 100644 --- a/src/EXTRA-MOLECULE/angle_quartic.cpp +++ b/src/EXTRA-MOLECULE/angle_quartic.cpp @@ -37,7 +37,10 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -AngleQuartic::AngleQuartic(LAMMPS *lmp) : Angle(lmp) {} +AngleQuartic::AngleQuartic(LAMMPS *lmp) : Angle(lmp) +{ + born_matrix_enable = 1; +} /* ---------------------------------------------------------------------- */ @@ -286,3 +289,39 @@ double AngleQuartic::single(int type, int i1, int i2, int i3) double dtheta4 = dtheta3 * dtheta; return k2[type] * dtheta2 + k3[type] * dtheta3 + k4[type] * dtheta4; } + +/* ---------------------------------------------------------------------- */ + +void AngleQuartic::born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) +{ + double **x = atom->x; + + double delx1 = x[i1][0] - x[i2][0]; + double dely1 = x[i1][1] - x[i2][1]; + double delz1 = x[i1][2] - x[i2][2]; + domain->minimum_image(delx1,dely1,delz1); + double r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1); + + double delx2 = x[i3][0] - x[i2][0]; + double dely2 = x[i3][1] - x[i2][1]; + double delz2 = x[i3][2] - x[i2][2]; + domain->minimum_image(delx2,dely2,delz2); + double r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2); + + double c = delx1*delx2 + dely1*dely2 + delz1*delz2; + c /= r1*r2; + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + double theta = acos(c); + + double s = sqrt(1.0 - c*c); + if (s < SMALL) s = SMALL; + + double dtheta = theta - theta0[type]; + double dtheta2 = dtheta * dtheta; + double dtheta3 = dtheta2 * dtheta; + + du = -(2.0 * k2[type] * dtheta + 3.0 * k3[type] * dtheta2 + 4.0 * k4[type] * dtheta3) / s; + du2 = (2.0 * k2[type] + 6.0 * k3[type] * dtheta + 12.0 * k4[type] * dtheta2) / (s*s) - + (2.0 * k2[type] * dtheta + 3.0 * k3[type] * dtheta2 + 4.0 * k4[type] * dtheta3) * c / (s*s*s); +} From 365f4bc55945506de57e44dc0c6ec7102fa2d000 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Sun, 18 Jun 2023 18:44:28 +0300 Subject: [PATCH 21/87] non-zero born_matrix_enable flag in angle_fourier.cpp --- src/EXTRA-MOLECULE/angle_fourier.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/angle_fourier.cpp b/src/EXTRA-MOLECULE/angle_fourier.cpp index 549da0c196..c7eb3d4fe4 100644 --- a/src/EXTRA-MOLECULE/angle_fourier.cpp +++ b/src/EXTRA-MOLECULE/angle_fourier.cpp @@ -39,6 +39,7 @@ using namespace MathConst; AngleFourier::AngleFourier(LAMMPS *lmp) : Angle(lmp) { + born_matrix_enable = 1; k = nullptr; C0 = nullptr; C1 = nullptr; From 2f227614615219d13538481646563c2a8111f251 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 19 Jun 2023 16:38:34 +0300 Subject: [PATCH 22/87] born_matrix() method in bond_mm3.h --- src/YAFF/bond_mm3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/YAFF/bond_mm3.h b/src/YAFF/bond_mm3.h index 302c4052d0..ea89ac826d 100644 --- a/src/YAFF/bond_mm3.h +++ b/src/YAFF/bond_mm3.h @@ -35,6 +35,7 @@ class BondMM3 : public Bond { void read_restart(FILE *) override; void write_data(FILE *) override; double single(int, double, int, int, double &) override; + void born_matrix(int, double, int, int, double &, double &) override; protected: double *r0, *k2; From bfc969d5c5ee4da4e9062bffe7f96d55ffb318ab Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 19 Jun 2023 16:39:49 +0300 Subject: [PATCH 23/87] implementation of born_matrix in bond_mm3.cpp --- src/YAFF/bond_mm3.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/YAFF/bond_mm3.cpp b/src/YAFF/bond_mm3.cpp index a5ef6fb8bc..31ce2dad3e 100644 --- a/src/YAFF/bond_mm3.cpp +++ b/src/YAFF/bond_mm3.cpp @@ -31,7 +31,10 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -BondMM3::BondMM3(LAMMPS *lmp) : Bond(lmp) {} +BondMM3::BondMM3(LAMMPS *lmp) : Bond(lmp) +{ + born_matrix_enable = 1; +} /* ---------------------------------------------------------------------- */ @@ -219,3 +222,19 @@ double BondMM3::single(int type, double rsq, else fforce = 0.0; return k2[type]*dr2*(1.0+K3*dr+K4*dr2); } + +/* ---------------------------------------------------------------------- */ + +void BondMM3::born_matrix(int type, double rsq, int /*i*/, int /*j*/, double &du, double &du2) +{ + double r = sqrt(rsq); + double dr = r - r0[type]; + double dr2 = dr * dr; + double dr3 = dr2 * dr; + + double K3 = -2.55 * k2[type] /force->angstrom; + double K4 = 7.0 * k2[type] * 2.55 * 2.55 / (12.0 * force->angstrom * force->angstrom); + + du = 2.0 * k2[type] * dr + 3.0 * K3 * dr2 + 4.0 * K4 * dr3; + du2 = 2.0 * k2[type] + 6.0 * K3 * dr + 12.0 * K4 * dr2; +} From 6c9d42b7c363a66fa56739f7d3ba3dbc5a1952c2 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 19 Jun 2023 19:38:50 +0300 Subject: [PATCH 24/87] Include born_matrix() definition in bond_harmonic_shift_cut.h --- src/EXTRA-MOLECULE/bond_harmonic_shift_cut.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.h b/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.h index 752ac010d9..09d6ab5330 100644 --- a/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.h +++ b/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.h @@ -35,6 +35,7 @@ class BondHarmonicShiftCut : public Bond { void read_restart(FILE *) override; void write_data(FILE *) override; double single(int, double, int, int, double &) override; + void born_matrix(int, double, int, int, double &, double &) override; protected: double *k, *r0, *r1; From f6b259b1866d9d5316d6464eae7d551fea9fc760 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 19 Jun 2023 19:40:11 +0300 Subject: [PATCH 25/87] Implementing born_matrix in bond_harmonic_shift_cut.cpp --- .../bond_harmonic_shift_cut.cpp | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.cpp b/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.cpp index fedcb95ee8..ebcfdb0258 100644 --- a/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.cpp +++ b/src/EXTRA-MOLECULE/bond_harmonic_shift_cut.cpp @@ -31,7 +31,10 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -BondHarmonicShiftCut::BondHarmonicShiftCut(LAMMPS *lmp) : Bond(lmp) {} +BondHarmonicShiftCut::BondHarmonicShiftCut(LAMMPS *lmp) : Bond(lmp) +{ + born_matrix_enable = 1; +} /* ---------------------------------------------------------------------- */ @@ -219,3 +222,19 @@ double BondHarmonicShiftCut::single(int type, double rsq, int /*i*/, int /*j*/, fforce = -2.0*k[type]*dr/r; return k[type]*(dr*dr - dr2*dr2); } + +/* ---------------------------------------------------------------------- */ + +void BondHarmonicShiftCut::born_matrix(int type, double rsq, int /*i*/, int /*j*/, double &du, double &du2) +{ + du = 0.0; + du2 = 0.0; + + double r = sqrt(rsq); + if (r>r1[type]) return; + + double dr = r - r0[type]; + + du2 = 2 * k[type]; + if (r > 0.0) du = du2 * dr; +} From ad3752431fe9711ef40f2d53cd28d7ab83153b73 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 19 Jun 2023 19:42:01 +0300 Subject: [PATCH 26/87] Regular pointer for coord and coordp in compute_stress_mop_profile.h --- src/EXTRA-COMPUTE/compute_stress_mop_profile.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h index 2b0ffef0f8..1b5b3a911f 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h @@ -49,7 +49,7 @@ class ComputeStressMopProfile : public Compute { int originflag; double origin, delta, offset, invdelta; int nbins; - double **coord, **coordp; + double *coord, *coordp; double **values_local, **values_global; double **bond_local, **bond_global; double **local_contribution; From dc1eb43cf2f15c61c0b44bb872407c4b5091e135 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Mon, 19 Jun 2023 19:47:34 +0300 Subject: [PATCH 27/87] Cleaning coord and coordp vectors in compute_stress_mop_profile.cpp --- .../compute_stress_mop_profile.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 1f1dc30733..3a85869f3c 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -258,7 +258,7 @@ void ComputeStressMopProfile::compute_array() MPI_Allreduce(&bond_local[0][0],&bond_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); for (int ibin=0; ibin ((hi-lo) * invdelta + 1.5); //allocate bin arrays - memory->create(coord,nbins,1,"stress/mop/profile:coord"); - memory->create(coordp,nbins,1,"stress/mop/profile:coordp"); + memory->create(coord,nbins,"stress/mop/profile:coord"); + memory->create(coordp,nbins,"stress/mop/profile:coordp"); memory->create(values_local,nbins,nvalues,"stress/mop/profile:values_local"); memory->create(values_global,nbins,nvalues,"stress/mop/profile:values_global"); memory->create(bond_local,nbins,nvalues,"stress/mop/profile:bond_local"); @@ -652,11 +652,11 @@ void ComputeStressMopProfile::setup_bins() // set bin coordinates for (i = 0; i < nbins; i++) { - coord[i][0] = offset + i*delta; - if (coord[i][0] < (domain->boxlo[dir]+domain->prd_half[dir])) { - coordp[i][0] = coord[i][0] + domain->prd[dir]; + coord[i] = offset + i*delta; + if (coord[i] < (domain->boxlo[dir]+domain->prd_half[dir])) { + coordp[i] = coord[i] + domain->prd[dir]; } else { - coordp[i][0] = coord[i][0] - domain->prd[dir]; + coordp[i] = coord[i] - domain->prd[dir]; } } } From 2631a159affeedef3dd2eeaaa1c3ca0529396b97 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 20 Jun 2023 15:41:09 +0300 Subject: [PATCH 28/87] define born_matrix in angle_mm3.h --- src/YAFF/angle_mm3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/YAFF/angle_mm3.h b/src/YAFF/angle_mm3.h index 95009a9cf6..22f5bd746c 100644 --- a/src/YAFF/angle_mm3.h +++ b/src/YAFF/angle_mm3.h @@ -35,6 +35,7 @@ class AngleMM3 : public Angle { void read_restart(FILE *) override; void write_data(FILE *) override; double single(int, int, int, int) override; + void born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) override; protected: double *theta0, *k2; From bb2d691e7863e5b4746da6fd8f6a951581cbde51 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 20 Jun 2023 15:42:47 +0300 Subject: [PATCH 29/87] implement born_matrix in angle_mm3.cpp --- src/YAFF/angle_mm3.cpp | 45 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/YAFF/angle_mm3.cpp b/src/YAFF/angle_mm3.cpp index c75a0d8308..af199f6fe9 100644 --- a/src/YAFF/angle_mm3.cpp +++ b/src/YAFF/angle_mm3.cpp @@ -36,7 +36,10 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ -AngleMM3::AngleMM3(LAMMPS *lmp) : Angle(lmp) {} +AngleMM3::AngleMM3(LAMMPS *lmp) : Angle(lmp) +{ + born_matrix_enable = 1; +} /* ---------------------------------------------------------------------- */ @@ -284,3 +287,43 @@ double AngleMM3::single(int type, int i1, int i2, int i3) return energy; } + +/* ---------------------------------------------------------------------- */ + +void AngleMM3::born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) +{ + double **x = atom->x; + + double delx1 = x[i1][0] - x[i2][0]; + double dely1 = x[i1][1] - x[i2][1]; + double delz1 = x[i1][2] - x[i2][2]; + domain->minimum_image(delx1,dely1,delz1); + double r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1); + + double delx2 = x[i3][0] - x[i2][0]; + double dely2 = x[i3][1] - x[i2][1]; + double delz2 = x[i3][2] - x[i2][2]; + domain->minimum_image(delx2,dely2,delz2); + double r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2); + + double c = delx1*delx2 + dely1*dely2 + delz1*delz2; + c /= r1*r2; + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + double theta = acos(c); + + double s = sqrt(1.0 - c*c); + if (s < SMALL) s = SMALL; + s = 1.0/s; + + double dtheta = theta - theta0[type]; + double dtheta2 = dtheta*dtheta; + double dtheta3 = dtheta2*dtheta; + double dtheta4 = dtheta3*dtheta; + double dtheta5 = dtheta4*dtheta; + double df = 2.0 * dtheta - 2.406423 * dtheta2 + 0.735348 * dtheta3 - 0.65832 * dtheta4 + 1.42254 * dtheta5; + double d2f = 2.0 - 4.812846 * dtheta + 2.206044 * dtheta2 - 2.63328 * dtheta3 + 7.1127 * dtheta4; + + du = -k2[type] * df / s; + du2 = k2[type] * (d2f - df * c / s) / (s * s) ; +} From 345a834c7e0693770e37a13005118ad29e19ff7b Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 20 Jun 2023 16:20:57 +0300 Subject: [PATCH 30/87] Include definition of born_matrix() in angle_cosine_periodic.h --- src/EXTRA-MOLECULE/angle_cosine_periodic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/angle_cosine_periodic.h b/src/EXTRA-MOLECULE/angle_cosine_periodic.h index 4e584b4543..f04ed04784 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_periodic.h +++ b/src/EXTRA-MOLECULE/angle_cosine_periodic.h @@ -35,6 +35,7 @@ class AngleCosinePeriodic : public Angle { void read_restart(FILE *) override; void write_data(FILE *) override; double single(int, int, int, int) override; + void born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) override; protected: double *k; From 7f3a930d8923a13fb14c02e85d56edb703b1c2cd Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 20 Jun 2023 16:21:57 +0300 Subject: [PATCH 31/87] Implement born_matrix() in angle_cosine_periodic.cpp --- src/EXTRA-MOLECULE/angle_cosine_periodic.cpp | 40 +++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp b/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp index 15d0575f6d..34a8e9d8e5 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp @@ -38,7 +38,10 @@ using namespace MathSpecial; /* ---------------------------------------------------------------------- */ -AngleCosinePeriodic::AngleCosinePeriodic(LAMMPS *lmp) : Angle(lmp) {} +AngleCosinePeriodic::AngleCosinePeriodic(LAMMPS *lmp) : Angle(lmp) +{ + born_matrix_enable = 1; +} /* ---------------------------------------------------------------------- */ @@ -298,3 +301,38 @@ double AngleCosinePeriodic::single(int type, int i1, int i2, int i3) c = cos(acos(c)*multiplicity[type]); return 2.0*k[type]*(1.0-b[type]*powsign(multiplicity[type])*c); } + +/* ---------------------------------------------------------------------- */ + +void AngleCosinePeriodic::born_matrix(int type, int i1, int i2, int i3, double &du, double &du2) +{ + double **x = atom->x; + + double delx1 = x[i1][0] - x[i2][0]; + double dely1 = x[i1][1] - x[i2][1]; + double delz1 = x[i1][2] - x[i2][2]; + domain->minimum_image(delx1,dely1,delz1); + double r1 = sqrt(delx1*delx1 + dely1*dely1 + delz1*delz1); + + double delx2 = x[i3][0] - x[i2][0]; + double dely2 = x[i3][1] - x[i2][1]; + double delz2 = x[i3][2] - x[i2][2]; + domain->minimum_image(delx2,dely2,delz2); + double r2 = sqrt(delx2*delx2 + dely2*dely2 + delz2*delz2); + + double c = delx1*delx2 + dely1*dely2 + delz1*delz2; + c /= r1*r2; + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + double theta = acos(c); + + double s = sqrt(1.0 - c*c); + if (s < SMALL) s = SMALL; + s = 1.0/s; + + double m_angle = multiplicity[type] * theta; + double prefactor = -2.0 * k[type] * b[type] * powsign(multiplicity[type]) * multiplicity[type]; + + du = prefactor * sin(m_angle) / s; + du2 = prefactor * (c * sin(m_angle) - s * cos(m_angle) * multiplicity[type]) / (s * s * s); +} From fb31ffe17cbff6854bc60870a8be54258df7ed07 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 21 Jun 2023 10:56:53 +0300 Subject: [PATCH 32/87] Definition of born_matrix() in dihedral_helix.h --- src/EXTRA-MOLECULE/dihedral_helix.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/dihedral_helix.h b/src/EXTRA-MOLECULE/dihedral_helix.h index 436895c5c3..172a8c3469 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.h +++ b/src/EXTRA-MOLECULE/dihedral_helix.h @@ -33,6 +33,7 @@ class DihedralHelix : public Dihedral { void write_restart(FILE *) override; void read_restart(FILE *) override; void write_data(FILE *) override; + void born_matrix(int, int, int, int, int, double &, double &) override; protected: double *aphi, *bphi, *cphi; From 7ab9da0212f1f3601f7238fe2997f9313d8cc923 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 21 Jun 2023 10:59:13 +0300 Subject: [PATCH 33/87] Implementation of born_matrix in dihedral_helix.cpp --- src/EXTRA-MOLECULE/dihedral_helix.cpp | 106 ++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/src/EXTRA-MOLECULE/dihedral_helix.cpp b/src/EXTRA-MOLECULE/dihedral_helix.cpp index 059bef74a4..1d99de6ba9 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.cpp +++ b/src/EXTRA-MOLECULE/dihedral_helix.cpp @@ -41,6 +41,7 @@ using namespace MathConst; DihedralHelix::DihedralHelix(LAMMPS *lmp) : Dihedral(lmp) { writedata = 1; + born_matrix_enable = 1; } /* ---------------------------------------------------------------------- */ @@ -324,3 +325,108 @@ void DihedralHelix::write_data(FILE *fp) for (int i = 1; i <= atom->ndihedraltypes; i++) fprintf(fp,"%d %g %g %g\n",i,aphi[i],bphi[i],cphi[i]); } + +/* ----------------------------------------------------------------------*/ + +void DihedralHelix::born_matrix(int nd, int i1, int i2, int i3, int i4, + double &du, double &du2) +{ + double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm; + double sb1,sb3,rb1,rb3,c0,b1mag2,b1mag,b2mag2; + double b2mag,b3mag2,b3mag,ctmp,r12c1,c1mag,r12c2; + double c2mag,sc1,sc2,s12,c; + double cx,cy,cz,cmag,dx,phi,si,siinv,sin2; + + int **dihedrallist = neighbor->dihedrallist; + double **x = atom->x; + + int type = dihedrallist[nd][4]; + + // 1st bond + + vb1x = x[i1][0] - x[i2][0]; + vb1y = x[i1][1] - x[i2][1]; + vb1z = x[i1][2] - x[i2][2]; + + // 2nd bond + + vb2x = x[i3][0] - x[i2][0]; + vb2y = x[i3][1] - x[i2][1]; + vb2z = x[i3][2] - x[i2][2]; + + vb2xm = -vb2x; + vb2ym = -vb2y; + vb2zm = -vb2z; + + // 3rd bond + + vb3x = x[i4][0] - x[i3][0]; + vb3y = x[i4][1] - x[i3][1]; + vb3z = x[i4][2] - x[i3][2]; + + // c0 calculation + + sb1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + sb3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + + rb1 = sqrt(sb1); + rb3 = sqrt(sb3); + + c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; + + // 1st and 2nd angle + + b1mag2 = vb1x*vb1x + vb1y*vb1y + vb1z*vb1z; + b1mag = sqrt(b1mag2); + b2mag2 = vb2x*vb2x + vb2y*vb2y + vb2z*vb2z; + b2mag = sqrt(b2mag2); + b3mag2 = vb3x*vb3x + vb3y*vb3y + vb3z*vb3z; + b3mag = sqrt(b3mag2); + + ctmp = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; + r12c1 = 1.0 / (b1mag*b2mag); + c1mag = ctmp * r12c1; + + ctmp = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; + r12c2 = 1.0 / (b2mag*b3mag); + c2mag = ctmp * r12c2; + + // cos and sin of 2 angles and final c + + sin2 = MAX(1.0 - c1mag*c1mag,0.0); + sc1 = sqrt(sin2); + if (sc1 < SMALL) sc1 = SMALL; + sc1 = 1.0/sc1; + + sin2 = MAX(1.0 - c2mag*c2mag,0.0); + sc2 = sqrt(sin2); + if (sc2 < SMALL) sc2 = SMALL; + sc2 = 1.0/sc2; + + s12 = sc1 * sc2; + c = (c0 + c1mag*c2mag) * s12; + + cx = vb1y*vb2z - vb1z*vb2y; + cy = vb1z*vb2x - vb1x*vb2z; + cz = vb1x*vb2y - vb1y*vb2x; + cmag = sqrt(cx*cx + cy*cy + cz*cz); + dx = (cx*vb3x + cy*vb3y + cz*vb3z)/cmag/b3mag; + + // error check + + if (c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) problem(FLERR, i1, i2, i3, i4); + + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + + phi = acos(c); + if (dx > 0.0) phi *= -1.0; + si = sin(phi); + if (fabs(si) < SMALLER) si = SMALLER; + siinv = 1.0/si; + + du = -aphi[type] + 3.0*bphi[type]*sin(3.0*phi)*siinv + + cphi[type]*sin(phi + MY_PI4)*siinv; + du2 = -(9.0*bphi[type]*cos(3.0*phi) + cphi[type]*cos(phi + MY_PI4))*siinv*siinv + + (3.0*bphi[type]*sin(3.0*phi) + cphi[type]*sin(phi + MY_PI4))*c*siinv*siinv*siinv; +} From ae96c9bd47e52d3c3066b40914b8e27ab6b042eb Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 22 Jun 2023 16:58:00 +0300 Subject: [PATCH 34/87] Define born_matrix() in dihedral_quadratic.h --- src/EXTRA-MOLECULE/dihedral_quadratic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.h b/src/EXTRA-MOLECULE/dihedral_quadratic.h index 90d8c3be6e..89f6fa3b25 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.h +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.h @@ -33,6 +33,7 @@ class DihedralQuadratic : public Dihedral { void write_restart(FILE *) override; void read_restart(FILE *) override; void write_data(FILE *) override; + void born_matrix(int, int, int, int, int, double &, double &) override; protected: double *k, *phi0; From 8e1711c8031699756ba3b5d84fa4582ad161a357 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 22 Jun 2023 17:00:10 +0300 Subject: [PATCH 35/87] Implement born_matrix in dihedral_quadratic.cpp --- src/EXTRA-MOLECULE/dihedral_quadratic.cpp | 110 ++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp index cbe9e3e3a2..f576e6efdd 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp @@ -41,6 +41,7 @@ using namespace MathConst; DihedralQuadratic::DihedralQuadratic(LAMMPS *lmp) : Dihedral(lmp) { writedata = 1; + born_matrix_enable = 1; } /* ---------------------------------------------------------------------- */ @@ -327,3 +328,112 @@ void DihedralQuadratic::write_data(FILE *fp) for (int i = 1; i <= atom->ndihedraltypes; i++) fprintf(fp,"%d %g %g \n",i,k[i],phi0[i]*180.0/MY_PI); } + +/* ----------------------------------------------------------------------*/ + +void DihedralQuadratic::born_matrix(int nd, int i1, int i2, int i3, int i4, + double &du, double &du2) +{ + double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm; + double sb1,sb3,rb1,rb3,c0,b1mag2,b1mag,b2mag2; + double b2mag,b3mag2,b3mag,ctmp,r12c1,c1mag,r12c2; + double c2mag,sc1,sc2,s12,c; + double s1,s2,cx,cy,cz,cmag,dx,phi,si,siinv,sin2; + + int **dihedrallist = neighbor->dihedrallist; + double **x = atom->x; + + int type = dihedrallist[nd][4]; + + // 1st bond + + vb1x = x[i1][0] - x[i2][0]; + vb1y = x[i1][1] - x[i2][1]; + vb1z = x[i1][2] - x[i2][2]; + + // 2nd bond + + vb2x = x[i3][0] - x[i2][0]; + vb2y = x[i3][1] - x[i2][1]; + vb2z = x[i3][2] - x[i2][2]; + + vb2xm = -vb2x; + vb2ym = -vb2y; + vb2zm = -vb2z; + + // 3rd bond + vb3x = x[i4][0] - x[i3][0]; + vb3y = x[i4][1] - x[i3][1]; + vb3z = x[i4][2] - x[i3][2]; + + // c0 calculation + + sb1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + sb3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + + rb1 = sqrt(sb1); + rb3 = sqrt(sb3); + + c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; + + // 1st and 2nd angle + + b1mag2 = vb1x*vb1x + vb1y*vb1y + vb1z*vb1z; + b1mag = sqrt(b1mag2); + b2mag2 = vb2x*vb2x + vb2y*vb2y + vb2z*vb2z; + b2mag = sqrt(b2mag2); + b3mag2 = vb3x*vb3x + vb3y*vb3y + vb3z*vb3z; + b3mag = sqrt(b3mag2); + + ctmp = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; + r12c1 = 1.0 / (b1mag*b2mag); + c1mag = ctmp * r12c1; + + ctmp = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; + r12c2 = 1.0 / (b2mag*b3mag); + c2mag = ctmp * r12c2; + + // cos and sin of 2 angles and final c + + sin2 = MAX(1.0 - c1mag*c1mag,0.0); + sc1 = sqrt(sin2); + if (sc1 < SMALL) sc1 = SMALL; + sc1 = 1.0/sc1; + + sin2 = MAX(1.0 - c2mag*c2mag,0.0); + sc2 = sqrt(sin2); + if (sc2 < SMALL) sc2 = SMALL; + sc2 = 1.0/sc2; + + s1 = sc1 * sc1; + s2 = sc2 * sc2; + s12 = sc1 * sc2; + c = (c0 + c1mag*c2mag) * s12; + + cx = vb1y*vb2z - vb1z*vb2y; + cy = vb1z*vb2x - vb1x*vb2z; + cz = vb1x*vb2y - vb1y*vb2x; + cmag = sqrt(cx*cx + cy*cy + cz*cz); + dx = (cx*vb3x + cy*vb3y + cz*vb3z)/cmag/b3mag; + + // error check + + if (c > 1.0 + TOLERANCE || c < (-1.0 - TOLERANCE)) + problem(FLERR, i1, i2, i3, i4); + + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + + phi = acos(c); + if (dx > 0.0) phi *= -1.0; + si = sin(phi); + if (fabs(si) < SMALLER) si = SMALLER; + siinv = 1.0/si; + + double dphi = phi-phi0[type]; + if (dphi > MY_PI) dphi -= 2*MY_PI; + else if (dphi < -MY_PI) dphi += 2*MY_PI; + + du = - 2.0 * k[type] * dphi * siinv; + du2 = 2.0 * k[type] * siinv * siinv * ( 1.0 - dphi * c * siinv) ; +} From 6e32d2932275271ced51152b3c849318c8956601 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 29 Jun 2023 08:53:50 +0300 Subject: [PATCH 36/87] clean up of originflag variable in compute_stress_mop_profile.cpp --- .../compute_stress_mop_profile.cpp | 38 ++++++++----------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 3a85869f3c..d37a941fde 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -38,7 +38,6 @@ using namespace LAMMPS_NS; enum { X, Y, Z }; -enum { LOWER, CENTER, UPPER, COORD }; enum { TOTAL, CONF, KIN, PAIR, BOND }; // clang-format off @@ -63,11 +62,15 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a // bin parameters - if (strcmp(arg[4],"lower") == 0) originflag = LOWER; - else if (strcmp(arg[4],"center") == 0) originflag = CENTER; - else if (strcmp(arg[4],"upper") == 0) originflag = UPPER; - else originflag = COORD; - if (originflag == COORD) origin = utils::numeric(FLERR,arg[4],false,lmp); + if (strcmp(arg[4],"lower") == 0) { + origin = domain->boxlo[dir]; + } else if (strcmp(arg[4],"center") == 0) { + origin = 0.5 * (domain->boxlo[dir] + domain->boxhi[dir]); + } else if (strcmp(arg[4],"upper") == 0) { + origin = domain->boxhi[dir]; + } else { + origin = utils::numeric(FLERR,arg[4],false,lmp); + } delta = utils::numeric(FLERR,arg[5],false,lmp); invdelta = 1.0/delta; @@ -620,23 +623,14 @@ void ComputeStressMopProfile::setup_bins() boxlo = domain->boxlo; boxhi = domain->boxhi; - if (originflag == LOWER) origin = boxlo[dir]; - else if (originflag == UPPER) origin = boxhi[dir]; - else if (originflag == CENTER) - origin = 0.5 * (boxlo[dir] + boxhi[dir]); + if ((origin > domain->boxhi[dir]) || (origin < domain->boxlo[dir])) + error->all(FLERR,"Origin of bins for compute stress/mop/profile is out of bounds" ); - if (origin < boxlo[dir]) { - error->all(FLERR,"Origin of bins for compute stress/mop/profile is out of bounds" ); - } else { - n = static_cast ((origin - boxlo[dir]) * invdelta); - lo = origin - n*delta; - } - if (origin < boxhi[dir]) { - n = static_cast ((boxhi[dir] - origin) * invdelta); - hi = origin + n*delta; - } else { - error->all(FLERR,"Origin of bins for compute stress/mop/profile is out of bounds" ); - } + n = static_cast ((origin - boxlo[dir]) * invdelta); + lo = origin - n*delta; + + n = static_cast ((boxhi[dir] - origin) * invdelta); + hi = origin + n*delta; offset = lo; nbins = static_cast ((hi-lo) * invdelta + 1.5); From 484e7ad0e3c295514f063e1e7933f3683e93f383 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 29 Jun 2023 08:54:30 +0300 Subject: [PATCH 37/87] clean up of originflag from compute_stress_mop_profile.h --- src/EXTRA-COMPUTE/compute_stress_mop_profile.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h index 1b5b3a911f..5890505d71 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h @@ -46,7 +46,6 @@ class ComputeStressMopProfile : public Compute { int bondflag; - int originflag; double origin, delta, offset, invdelta; int nbins; double *coord, *coordp; From 005c15c07b3d4dd445ba276e8f3615852fdb7e71 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 5 Jul 2023 13:26:47 +0300 Subject: [PATCH 38/87] compute kinetic contribution without assuming orthogonal geometry --- src/EXTRA-COMPUTE/compute_stress_mop.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index 98e3bf7043..18e6ec6115 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -422,6 +422,11 @@ void ComputeStressMop::compute_pairs() xi[1] = atom->x[i][1]; xi[2] = atom->x[i][2]; + // minimum image of xi with respect to the plane + xi[dir] -= pos; + domain->minimum_image(xi[0], xi[1], xi[2]); + xi[dir] += pos; + //velocities at t vi[0] = atom->v[i][0]; vi[1] = atom->v[i][1]; @@ -447,10 +452,8 @@ void ComputeStressMop::compute_pairs() // at each timestep, must check atoms going through the // image of the plane that is closest to the box - double pos_temp = pos+copysign(1.0,domain->prd_half[dir]-pos)*domain->prd[dir]; - if (fabs(xi[dir]-pos)= 0)) { // sgn = copysign(1.0,vi[dir]-vcm[dir]); sgn = copysign(1.0,vi[dir]); From 94fa2f51c9189874ab84661519f0047cd1f0c9db Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 5 Jul 2023 13:38:56 +0300 Subject: [PATCH 39/87] compute kinetic contribution without assuming orthogonal geometry --- .../compute_stress_mop_profile.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index d37a941fde..c8793586ea 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -453,7 +453,22 @@ void ComputeStressMopProfile::compute_pairs() pos = coord[ibin]; pos1 = coordp[ibin]; - if (((xi[dir]-pos)*(xj[dir]-pos)*(xi[dir]-pos1)*(xj[dir]-pos1)<0)) { + // minimum image of xi with respect to the plane + xi[dir] -= pos; + domain->minimum_image(xi[0], xi[1], xi[2]); + xi[dir] += pos; + + // minimum image of xj with respect to xi + xj[0] -= xi[0]; + xj[1] -= xi[1]; + xj[2] -= xi[2]; + domain->minimum_image(xi[0], xi[1], xi[2]); + xj[0] += xi[0]; + xj[1] += xi[1]; + xj[2] += xi[2]; + + double tau = (xi[dir] - pos) / (xi[dir] - xj[dir]); + if ((tau <= 1) && (tau >= 0)) { sgn = copysign(1.0,vi[dir]); From 79ed2d9e8bb1bd5fefbf6fcd24eff5fd2d452381 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 5 Jul 2023 16:35:25 +0300 Subject: [PATCH 40/87] Definition of compute_angle and related variables in compute_stress_mop_profile.h --- src/EXTRA-COMPUTE/compute_stress_mop_profile.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h index 5890505d71..c7214c055c 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h @@ -39,18 +39,20 @@ class ComputeStressMopProfile : public Compute { private: void compute_pairs(); void compute_bonds(); + void compute_angles(); void setup_bins(); int nvalues, dir; int *which; - int bondflag; + int bondflag, angleflag; double origin, delta, offset, invdelta; int nbins; double *coord, *coordp; double **values_local, **values_global; double **bond_local, **bond_global; + double **angle_local, **angle_global; double **local_contribution; double dt, nktv2p, ftm2v; From 9aa9bdd3ba4bd6f59cbe2723bedc46936cf77b62 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 5 Jul 2023 16:45:53 +0300 Subject: [PATCH 41/87] Implementation of compute_angles in compute_stress_mop_profile.cpp and related adjustments to flags/memory allocations --- .../compute_stress_mop_profile.cpp | 227 +++++++++++++++++- 1 file changed, 221 insertions(+), 6 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index c8793586ea..dabbbc4781 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -13,7 +13,7 @@ /*------------------------------------------------------------------------ Contributing Authors : Romain Vermorel (LFCR), Laurent Joly (ULyon) - Support for bonds added by : Evangelos Voyiatzis (NovaMechanics) + Support for bonds and angles added by : Evangelos Voyiatzis (NovaMechanics) --------------------------------------------------------------------------*/ #include "compute_stress_mop_profile.h" @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; enum { X, Y, Z }; -enum { TOTAL, CONF, KIN, PAIR, BOND }; +enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE }; // clang-format off /* ---------------------------------------------------------------------- */ @@ -107,6 +107,11 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a which[nvalues] = BOND; nvalues++; } + } else if (strcmp(arg[iarg],"angle") == 0) { + for (i=0; i<3; i++) { + which[nvalues] = ANGLE; + nvalues++; + } } else error->all(FLERR, "Illegal compute stress/mop/profile command"); //break; iarg++; @@ -131,6 +136,8 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a values_local = values_global = array = nullptr; bond_local = nullptr; bond_global = nullptr; + angle_local = nullptr; + angle_global = nullptr; local_contribution = nullptr; // bin setup @@ -159,6 +166,8 @@ ComputeStressMopProfile::~ComputeStressMopProfile() memory->destroy(values_global); memory->destroy(bond_local); memory->destroy(bond_global); + memory->destroy(angle_local); + memory->destroy(angle_global); memory->destroy(local_contribution); memory->destroy(array); } @@ -206,9 +215,14 @@ void ComputeStressMopProfile::init() if (force->bond) bondflag = 1; - if (force->angle) - if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0)) - error->all(FLERR,"compute stress/mop/profile does not account for angle potentials"); + if (force->angle) { + if (force->angle->born_matrix_enable == 0) { + if ((strcmp(force->angle_style, "zero") != 0) && (strcmp(force->angle_style, "none") != 0)) + error->all(FLERR,"compute stress/mop/profile does not account for angle potentials"); + } else { + angleflag = 1; + } + } if (force->dihedral) if ((strcmp(force->dihedral_style, "zero") != 0) && (strcmp(force->dihedral_style, "none") != 0)) error->all(FLERR,"compute stress/mop/profile does not account for dihedral potentials"); @@ -260,13 +274,27 @@ void ComputeStressMopProfile::compute_array() // sum bond contribution over all procs MPI_Allreduce(&bond_local[0][0],&bond_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); + if (angleflag) { + //Compute angle contribution on separate procs + compute_angles(); + } else { + for (int m = 0; m < nbins; m++) { + for (int i = 0; i < nvalues; i++) { + angle_local[m][i] = 0.0; + } + } + } + + // sum angle contribution over all procs + MPI_Allreduce(&angle_local[0][0],&angle_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); + for (int ibin=0; ibinx; + tagint *tag = atom->tag; + int *num_angle = atom->num_angle; + tagint **angle_atom1 = atom->angle_atom1; + tagint **angle_atom2 = atom->angle_atom2; + tagint **angle_atom3 = atom->angle_atom3; + int **angle_type = atom->angle_type; + int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + + int nlocal = atom->nlocal; + int molecular = atom->molecular; + + // loop over all atoms and their angles + Angle *angle = force->angle; + + double duang, du2ang; + double dx[3] = {0.0, 0.0, 0.0}; + double dx_left[3] = {0.0, 0.0, 0.0}; + double dx_right[3] = {0.0, 0.0, 0.0}; + double x_angle_left[3] = {0.0, 0.0, 0.0}; + double x_angle_middle[3] = {0.0, 0.0, 0.0}; + double x_angle_right[3] = {0.0, 0.0, 0.0}; + double dcos_theta[3] = {0.0, 0.0, 0.0}; + + // initialization + for (int m = 0; m < nbins; m++) { + for (int i = 0; i < nvalues; i++) { + angle_local[m][i] = 0.0; + } + local_contribution[m][0] = 0.0; + local_contribution[m][1] = 0.0; + local_contribution[m][2] = 0.0; + } + + + for (atom2 = 0; atom2 < nlocal; atom2++) { + if (!(mask[atom2] & groupbit)) continue; + + if (molecular == 1) + na = num_angle[atom2]; + else { + if (molindex[atom2] < 0) continue; + imol = molindex[atom2]; + iatom = molatom[atom2]; + na = onemols[imol]->num_angle[iatom]; + } + + for (int i = 0; i < na; i++) { + if (molecular == 1) { + if (tag[atom2] != angle_atom2[atom2][i]) continue; + atype = angle_type[atom2][i]; + atom1 = atom->map(angle_atom1[atom2][i]); + atom3 = atom->map(angle_atom3[atom2][i]); + } else { + if (tag[atom2] != onemols[imol]->angle_atom2[atom2][i]) continue; + atype = onemols[imol]->angle_type[atom2][i]; + tagprev = tag[atom2] - iatom - 1; + atom1 = atom->map(onemols[imol]->angle_atom1[atom2][i] + tagprev); + atom3 = atom->map(onemols[imol]->angle_atom3[atom2][i] + tagprev); + } + + if (atom1 < 0 || !(mask[atom1] & groupbit)) continue; + if (atom3 < 0 || !(mask[atom3] & groupbit)) continue; + if (atype <= 0) continue; + + for (int ibin = 0; ibinminimum_image(dx[0], dx[1], dx[2]); + x_angle_left[0] = dx[0]; + x_angle_left[1] = dx[1]; + x_angle_left[2] = dx[2]; + x_angle_left[dir] += pos; + + // minimum image of atom2 with respect to atom1 + dx_left[0] = x[atom2][0] - x_angle_left[0]; + dx_left[1] = x[atom2][1] - x_angle_left[1]; + dx_left[2] = x[atom2][2] - x_angle_left[2]; + domain->minimum_image(dx_left[0], dx_left[1], dx_left[2]); + x_angle_middle[0] = x_angle_left[0] + dx_left[0]; + x_angle_middle[1] = x_angle_left[1] + dx_left[1]; + x_angle_middle[2] = x_angle_left[2] + dx_left[2]; + + // minimum image of atom3 with respect to atom2 + dx_right[0] = x[atom3][0] - x_angle_middle[0]; + dx_right[1] = x[atom3][1] - x_angle_middle[1]; + dx_right[2] = x[atom3][2] - x_angle_middle[2]; + domain->minimum_image(dx_right[0], dx_right[1], dx_right[2]); + x_angle_right[0] = x_angle_middle[0] + dx_right[0]; + x_angle_right[1] = x_angle_middle[1] + dx_right[1]; + x_angle_right[2] = x_angle_middle[2] + dx_right[2]; + + // check if any bond vector crosses the plane of interest + double tau_right = (x_angle_right[dir] - pos) / (x_angle_right[dir] - x_angle_middle[dir]); + double tau_left = (x_angle_middle[dir] - pos) / (x_angle_middle[dir] - x_angle_left[dir]); + bool right_cross = ((tau_right >=0) && (tau_right <= 1)); + bool left_cross = ((tau_left >=0) && (tau_left <= 1)); + + // no bonds crossing the plane + if (!right_cross && !left_cross) continue; + + // compute the cos(theta) of the angle + r1 = sqrt(dx_left[0]*dx_left[0] + dx_left[1]*dx_left[1] + dx_left[2]*dx_left[2]); + r2 = sqrt(dx_right[0]*dx_right[0] + dx_right[1]*dx_right[1] + dx_right[2]*dx_right[2]); + cos_theta = -(dx_right[0]*dx_left[0] + dx_right[1]*dx_left[1] + dx_right[2]*dx_left[2])/(r1*r2); + + if (cos_theta > 1.0) cos_theta = 1.0; + if (cos_theta < -1.0) cos_theta = -1.0; + + // The method returns derivative with regards to cos(theta) + angle->born_matrix(atype, atom1, atom2, atom3, duang, du2ang); + // only right bond crossing the plane + if (right_cross && !left_cross) + { + double sgn = copysign(1.0, x_angle_right[dir] - pos); + dcos_theta[0] = sgn*(dx_right[0]*cos_theta/r2 + dx_left[0]/r1)/r2; + dcos_theta[1] = sgn*(dx_right[1]*cos_theta/r2 + dx_left[1]/r1)/r2; + dcos_theta[2] = sgn*(dx_right[2]*cos_theta/r2 + dx_left[2]/r1)/r2; + } + + // only left bond crossing the plane + if (!right_cross && left_cross) + { + double sgn = copysign(1.0, x_angle_left[dir] - pos); + dcos_theta[0] = -sgn*(dx_left[0]*cos_theta/r1 + dx_right[0]/r2)/r1; + dcos_theta[1] = -sgn*(dx_left[1]*cos_theta/r1 + dx_right[1]/r2)/r1; + dcos_theta[2] = -sgn*(dx_left[2]*cos_theta/r1 + dx_right[2]/r2)/r1; + } + + // both bonds crossing the plane + if (right_cross && left_cross) + { + // due to right bond + double sgn = copysign(1.0, x_angle_middle[dir] - pos); + dcos_theta[0] = -sgn*(dx_right[0]*cos_theta/r2 + dx_left[0]/r1)/r2; + dcos_theta[1] = -sgn*(dx_right[1]*cos_theta/r2 + dx_left[1]/r1)/r2; + dcos_theta[2] = -sgn*(dx_right[2]*cos_theta/r2 + dx_left[2]/r1)/r2; + + // due to left bond + dcos_theta[0] += sgn*(dx_left[0]*cos_theta/r1 + dx_right[0]/r2)/r1; + dcos_theta[1] += sgn*(dx_left[1]*cos_theta/r1 + dx_right[1]/r2)/r1; + dcos_theta[2] += sgn*(dx_left[2]*cos_theta/r1 + dx_right[2]/r2)/r1; + } + + // final contribution of the given angle term + local_contribution[ibin][0] += duang*dcos_theta[0]/area*nktv2p; + local_contribution[ibin][1] += duang*dcos_theta[1]/area*nktv2p; + local_contribution[ibin][2] += duang*dcos_theta[2]/area*nktv2p; + } + } + } + + // loop over the keywords and if necessary add the angle contribution + int m = 0; + while (m < nvalues) { + if (which[m] == CONF || which[m] == TOTAL || which[m] == ANGLE) { + for (int ibin = 0; ibin < nbins; ibin++) { + angle_local[ibin][m] = local_contribution[ibin][0]; + angle_local[ibin][m+1] = local_contribution[ibin][1]; + angle_local[ibin][m+2] = local_contribution[ibin][2]; + } + } + m += 3; + } +} + /* ---------------------------------------------------------------------- setup 1d bins and their extent and coordinates called at init() @@ -657,6 +870,8 @@ void ComputeStressMopProfile::setup_bins() memory->create(values_global,nbins,nvalues,"stress/mop/profile:values_global"); memory->create(bond_local,nbins,nvalues,"stress/mop/profile:bond_local"); memory->create(bond_global,nbins,nvalues,"stress/mop/profile:bond_global"); + memory->create(angle_local,nbins,nvalues,"stress/mop/profile:angle_local"); + memory->create(angle_global,nbins,nvalues,"stress/mop/profile:angle_global"); memory->create(local_contribution,nbins,3,"stress/mop/profile:local_contribution"); // set bin coordinates From 78f4e4f1a15061991a7a0073566df2ed43712715 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 5 Jul 2023 16:51:41 +0300 Subject: [PATCH 42/87] Update compute_stress_mop.rst --- doc/src/compute_stress_mop.rst | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index 21c2963545..70986862fe 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -74,9 +74,7 @@ Between one and six keywords can be used to indicate which contributions to the stress must be computed: total stress (total), kinetic stress (kin), configurational stress (conf), stress due to bond stretching (bond), stress due to angle bending (angle) and/or due to pairwise -non-bonded interactions (pair). The angle keyword is currently -available only for the *stress/mop* command and **not** the -*stress/mop/profile* command. +non-bonded interactions (pair). NOTE 1: The configurational stress is computed considering all pairs of atoms where at least one atom belongs to group group-ID. @@ -136,7 +134,7 @@ requires the class method ``Pair::single()`` to be implemented, which is not possible for manybody potentials. In particular, compute *stress/mop/profile* does not work with more than two-body pair interactions, long range (kspace) interactions and -angle/dihedral/improper intramolecular interactions. Similarly, compute +dihedral/improper intramolecular interactions. Similarly, compute *stress/mop* does not work with more than two-body pair interactions, long range (kspace) interactions and dihedral/improper intramolecular interactions but works with all bond interactions with the class method From 9fde61fc4e358e44854cf73f8d5cb230b3bf7e7c Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Wed, 5 Jul 2023 16:59:02 +0300 Subject: [PATCH 43/87] Update compute_stress_mop_profile.cpp --- src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index dabbbc4781..2dee2bf60f 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -18,6 +18,7 @@ #include "compute_stress_mop_profile.h" +#include "angle.h" #include "atom.h" #include "atom_vec.h" #include "bond.h" From b81df7c21b6be9739f234d4dc9c73272b38cde9c Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:12:09 +0300 Subject: [PATCH 44/87] Include methods and variables for dihedral contribution to compute_stress_mop_profile.h --- src/EXTRA-COMPUTE/compute_stress_mop_profile.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h index c7214c055c..b9b97617c0 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h @@ -40,12 +40,13 @@ class ComputeStressMopProfile : public Compute { void compute_pairs(); void compute_bonds(); void compute_angles(); + void compute_dihedrals(); void setup_bins(); int nvalues, dir; int *which; - int bondflag, angleflag; + int bondflag, angleflag, dihedralflag; double origin, delta, offset, invdelta; int nbins; @@ -53,6 +54,7 @@ class ComputeStressMopProfile : public Compute { double **values_local, **values_global; double **bond_local, **bond_global; double **angle_local, **angle_global; + double **dihedral_local, **dihedral_global; double **local_contribution; double dt, nktv2p, ftm2v; From e819b38a1831a56839cc13be2877099244ca4afe Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:15:12 +0300 Subject: [PATCH 45/87] undo dihedral changes in compute_stress_mop_profile.h --- src/EXTRA-COMPUTE/compute_stress_mop_profile.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h index b9b97617c0..c7214c055c 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h @@ -40,13 +40,12 @@ class ComputeStressMopProfile : public Compute { void compute_pairs(); void compute_bonds(); void compute_angles(); - void compute_dihedrals(); void setup_bins(); int nvalues, dir; int *which; - int bondflag, angleflag, dihedralflag; + int bondflag, angleflag; double origin, delta, offset, invdelta; int nbins; @@ -54,7 +53,6 @@ class ComputeStressMopProfile : public Compute { double **values_local, **values_global; double **bond_local, **bond_global; double **angle_local, **angle_global; - double **dihedral_local, **dihedral_global; double **local_contribution; double dt, nktv2p, ftm2v; From 381d8de017c37794682e77a3825f4e1b9ddd4458 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:22:09 +0300 Subject: [PATCH 46/87] initialization of angleflag in constructor compute_stress_mop_profile.cpp --- src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 2a82cc0f8b..3dfc9326ac 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -49,6 +49,7 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a if (narg < 7) utils::missing_cmd_args(FLERR, "compute stress/mop/profile", error); bondflag = 0; + angleflag = 0; // set compute mode and direction of plane(s) for pressure calculation From ec458e2861b5b4950bfcd9a9dfb67bf1c636c319 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:32:26 +0300 Subject: [PATCH 47/87] method and member variables definition for dihedrals in compute_stress_mop_profile.h --- src/EXTRA-COMPUTE/compute_stress_mop_profile.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h index c7214c055c..b9b97617c0 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.h @@ -40,12 +40,13 @@ class ComputeStressMopProfile : public Compute { void compute_pairs(); void compute_bonds(); void compute_angles(); + void compute_dihedrals(); void setup_bins(); int nvalues, dir; int *which; - int bondflag, angleflag; + int bondflag, angleflag, dihedralflag; double origin, delta, offset, invdelta; int nbins; @@ -53,6 +54,7 @@ class ComputeStressMopProfile : public Compute { double **values_local, **values_global; double **bond_local, **bond_global; double **angle_local, **angle_global; + double **dihedral_local, **dihedral_global; double **local_contribution; double dt, nktv2p, ftm2v; From d40fb4a337c67c2f0c3bc79bf29b87353cd80ceb Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:45:46 +0300 Subject: [PATCH 48/87] method implementation for dihedral contribution to compute_stress_mop_profile.cpp --- .../compute_stress_mop_profile.cpp | 361 +++++++++++++++++- 1 file changed, 354 insertions(+), 7 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 3dfc9326ac..27e420e71d 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -13,7 +13,7 @@ /*------------------------------------------------------------------------ Contributing Authors : Romain Vermorel (LFCR), Laurent Joly (ULyon) - Support for bonds and angles added by : Evangelos Voyiatzis (NovaMechanics) + Support for bonds, angles and dihedrals added by : Evangelos Voyiatzis (NovaMechanics) --------------------------------------------------------------------------*/ #include "compute_stress_mop_profile.h" @@ -23,6 +23,7 @@ #include "atom_vec.h" #include "bond.h" #include "comm.h" +#include "dihedral.h" #include "domain.h" #include "error.h" #include "force.h" @@ -38,8 +39,10 @@ using namespace LAMMPS_NS; +#define SMALL 0.001 + enum { X, Y, Z }; -enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE }; +enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE, DIHEDRAL }; /* ---------------------------------------------------------------------- */ @@ -50,6 +53,7 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a bondflag = 0; angleflag = 0; + dihedralflag = 0; // set compute mode and direction of plane(s) for pressure calculation @@ -114,6 +118,11 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a which[nvalues] = ANGLE; nvalues++; } + } else if (strcmp(arg[iarg],"dihedral") == 0) { + for (i=0; i<3; i++) { + which[nvalues] = DIHEDRAL; + nvalues++; + } } else error->all(FLERR, "Illegal compute stress/mop/profile command"); //break; @@ -141,6 +150,8 @@ ComputeStressMopProfile::ComputeStressMopProfile(LAMMPS *lmp, int narg, char **a bond_global = nullptr; angle_local = nullptr; angle_global = nullptr; + dihedral_local = nullptr; + dihedral_global = nullptr; local_contribution = nullptr; // bin setup @@ -171,6 +182,8 @@ ComputeStressMopProfile::~ComputeStressMopProfile() memory->destroy(bond_global); memory->destroy(angle_local); memory->destroy(angle_global); + memory->destroy(dihedral_local); + memory->destroy(dihedral_global); memory->destroy(local_contribution); memory->destroy(array); } @@ -227,10 +240,16 @@ void ComputeStressMopProfile::init() } } - if (force->dihedral) - if ((strcmp(force->dihedral_style, "zero") != 0) && - (strcmp(force->dihedral_style, "none") != 0)) - error->all(FLERR, "compute stress/mop/profile does not account for dihedral potentials"); + if (force->dihedral) { + if (force->dihedral->born_matrix_enable == 0) { + if ((strcmp(force->dihedral_style, "zero") != 0) && + (strcmp(force->dihedral_style, "none") != 0)) + error->all(FLERR, "compute stress/mop/profile does not account for dihedral potentials"); + } else { + dihedralflag = 1; + } + } + if (force->improper) if ((strcmp(force->improper_style, "zero") != 0) && (strcmp(force->improper_style, "none") != 0)) @@ -294,6 +313,17 @@ void ComputeStressMopProfile::compute_array() // sum angle contribution over all procs MPI_Allreduce(&angle_local[0][0],&angle_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); + + if (dihedralflag) { + //Compute dihedral contribution on separate procs + compute_dihedrals(); + } else { + for (int m = 0; m < nbins; m++) { + for (int i = 0; i < nvalues; i++) { + dihedral_local[m][i] = 0.0; + } + } + } for (int ibin = 0; ibin < nbins; ibin++) { array[ibin][0] = coord[ibin]; @@ -301,7 +331,7 @@ void ComputeStressMopProfile::compute_array() int mo = 1; int m = 0; while (m < nvalues) { - array[ibin][m + mo] = values_global[ibin][m] + bond_global[ibin][m] + angle_global[ibin][m]; + array[ibin][m + mo] = values_global[ibin][m] + bond_global[ibin][m] + angle_global[ibin][m] + dihedral_global[ibin][m]; m++; } } @@ -835,6 +865,321 @@ void ComputeStressMopProfile::compute_angles() } } +/*------------------------------------------------------------------------ + compute dihedral contribution to pressure of local proc + -------------------------------------------------------------------------*/ + +void ComputeStressMopProfile::compute_dihedrals() +{ + int i, nd, atom1, atom2, atom3, atom4, imol, iatom; + tagint tagprev; + double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z; + double vb2xm, vb2ym, vb2zm; + double sb1, sb2, sb3, rb1, rb3, c0, b1mag2, b1mag, b2mag2; + double b2mag, b3mag2, b3mag, c2mag, ctmp, r12c1, c1mag, r12c2; + double s1, s2, s12, sc1, sc2, a11, a22, a33, a12, a13, a23; + double df[3], f1[3], f2[3], f3[3], f4[3]; + double c, sx2, sy2, sz2, sin2; + + double **x = atom->x; + tagint *tag = atom->tag; + int *num_dihedral = atom->num_dihedral; + tagint **dihedral_atom1 = atom->dihedral_atom1; + tagint **dihedral_atom2 = atom->dihedral_atom2; + tagint **dihedral_atom3 = atom->dihedral_atom3; + tagint **dihedral_atom4 = atom->dihedral_atom4; + int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + + int nlocal = atom->nlocal; + int molecular = atom->molecular; + + // loop over all atoms and their dihedrals + + Dihedral *dihedral = force->dihedral; + + double dudih, du2dih; + + double diffx[3] = {0.0, 0.0, 0.0}; + double x_atom_1[3] = {0.0, 0.0, 0.0}; + double x_atom_2[3] = {0.0, 0.0, 0.0}; + double x_atom_3[3] = {0.0, 0.0, 0.0}; + double x_atom_4[3] = {0.0, 0.0, 0.0}; + + // initialization + for (int m = 0; m < nbins; m++) { + for (int i = 0; i < nvalues; i++) { + dihedral_local[m][i] = 0.0; + } + local_contribution[m][0] = 0.0; + local_contribution[m][1] = 0.0; + local_contribution[m][2] = 0.0; + } + + for (atom2 = 0; atom2 < nlocal; atom2++) { + if (!(mask[atom2] & groupbit)) continue; + + if (molecular == Atom::MOLECULAR) + nd = num_dihedral[atom2]; + else { + if (molindex[atom2] < 0) continue; + imol = molindex[atom2]; + iatom = molatom[atom2]; + nd = onemols[imol]->num_dihedral[iatom]; + } + + for (i = 0; i < nd; i++) { + if (molecular == 1) { + if (tag[atom2] != dihedral_atom2[atom2][i]) continue; + atom1 = atom->map(dihedral_atom1[atom2][i]); + atom3 = atom->map(dihedral_atom3[atom2][i]); + atom4 = atom->map(dihedral_atom4[atom2][i]); + } else { + if (tag[atom2] != onemols[imol]->dihedral_atom2[atom2][i]) continue; + tagprev = tag[atom2] - iatom - 1; + atom1 = atom->map(onemols[imol]->dihedral_atom1[atom2][i] + tagprev); + atom3 = atom->map(onemols[imol]->dihedral_atom3[atom2][i] + tagprev); + atom4 = atom->map(onemols[imol]->dihedral_atom4[atom2][i] + tagprev); + } + + if (atom1 < 0 || !(mask[atom1] & groupbit)) continue; + if (atom3 < 0 || !(mask[atom3] & groupbit)) continue; + if (atom4 < 0 || !(mask[atom4] & groupbit)) continue; + + for (int ibin = 0; ibinminimum_image(x_atom_1[0], x_atom_1[1], x_atom_1[2]); + x_atom_1[dir] += pos; + + // minimum image of atom2 with respect to atom1 + diffx[0] = x[atom2][0] - x_atom_1[0]; + diffx[1] = x[atom2][1] - x_atom_1[1]; + diffx[2] = x[atom2][2] - x_atom_1[2]; + domain->minimum_image(diffx[0], diffx[1], diffx[2]); + x_atom_2[0] = x_atom_1[0] + diffx[0]; + x_atom_2[1] = x_atom_1[1] + diffx[1]; + x_atom_2[2] = x_atom_1[2] + diffx[2]; + + // minimum image of atom3 with respect to atom2 + diffx[0] = x[atom3][0] - x_atom_2[0]; + diffx[1] = x[atom3][1] - x_atom_2[1]; + diffx[2] = x[atom3][2] - x_atom_2[2]; + domain->minimum_image(diffx[0], diffx[1], diffx[2]); + x_atom_3[0] = x_atom_2[0] + diffx[0]; + x_atom_3[1] = x_atom_2[1] + diffx[1]; + x_atom_3[2] = x_atom_2[2] + diffx[2]; + + // minimum image of atom3 with respect to atom2 + diffx[0] = x[atom4][0] - x_atom_3[0]; + diffx[1] = x[atom4][1] - x_atom_3[1]; + diffx[2] = x[atom4][2] - x_atom_3[2]; + domain->minimum_image(diffx[0], diffx[1], diffx[2]); + x_atom_4[0] = x_atom_3[0] + diffx[0]; + x_atom_4[1] = x_atom_3[1] + diffx[1]; + x_atom_4[2] = x_atom_3[2] + diffx[2]; + + // check if any bond vector crosses the plane of interest + double tau_right = (x_atom_2[dir] - pos) / (x_atom_2[dir] - x_atom_1[dir]); + double tau_middle = (x_atom_3[dir] - pos) / (x_atom_3[dir] - x_atom_2[dir]); + double tau_left = (x_atom_4[dir] - pos) / (x_atom_4[dir] - x_atom_3[dir]); + bool right_cross = ((tau_right >=0) && (tau_right <= 1)); + bool middle_cross = ((tau_middle >= 0) && (tau_middle <= 1)); + bool left_cross = ((tau_left >=0) && (tau_left <= 1)); + + // no bonds crossing the plane + if (!right_cross && !middle_cross && !left_cross) continue; + + dihedral->born_matrix(i, atom1, atom2, atom3, atom4, dudih, du2dih); + + // first bond + vb1x = x_atom_1[0] - x_atom_2[0]; + vb1y = x_atom_1[1] - x_atom_2[1]; + vb1z = x_atom_1[2] - x_atom_2[2]; + + // second bond + vb2x = x_atom_3[0] - x_atom_2[0]; + vb2y = x_atom_3[1] - x_atom_2[1]; + vb2z = x_atom_3[2] - x_atom_2[2]; + + vb2xm = -vb2x; + vb2ym = -vb2y; + vb2zm = -vb2z; + + // third bond + vb3x = x_atom_4[0] - x_atom_3[0]; + vb3y = x_atom_4[1] - x_atom_3[1]; + vb3z = x_atom_4[2] - x_atom_3[2]; + + // c0 calculation + sb1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + sb2 = 1.0 / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + sb3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + + rb1 = sqrt(sb1); + rb3 = sqrt(sb3); + + c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; + // 1st and 2nd angle + b1mag2 = vb1x*vb1x + vb1y*vb1y + vb1z*vb1z; + b1mag = sqrt(b1mag2); + b2mag2 = vb2x*vb2x + vb2y*vb2y + vb2z*vb2z; + b2mag = sqrt(b2mag2); + b3mag2 = vb3x*vb3x + vb3y*vb3y + vb3z*vb3z; + b3mag = sqrt(b3mag2); + + ctmp = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; + r12c1 = 1.0 / (b1mag*b2mag); + c1mag = ctmp * r12c1; + + ctmp = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; + r12c2 = 1.0 / (b2mag*b3mag); + c2mag = ctmp * r12c2; + + // cos and sin of 2 angles and final c + sin2 = MAX(1.0 - c1mag*c1mag,0.0); + sc1 = sqrt(sin2); + if (sc1 < SMALL) sc1 = SMALL; + sc1 = 1.0/sc1; + + sin2 = MAX(1.0 - c2mag*c2mag,0.0); + sc2 = sqrt(sin2); + if (sc2 < SMALL) sc2 = SMALL; + sc2 = 1.0/sc2; + + s1 = sc1 * sc1; + s2 = sc2 * sc2; + s12 = sc1 * sc2; + c = (c0 + c1mag*c2mag) * s12; + + // error check + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + + // forces on each particle + double a = dudih; + c = c * a; + s12 = s12 * a; + a11 = c*sb1*s1; + a22 = -sb2 * (2.0*c0*s12 - c*(s1+s2)); + a33 = c*sb3*s2; + a12 = -r12c1 * (c1mag*c*s1 + c2mag*s12); + a13 = -rb1*rb3*s12; + a23 = r12c2 * (c2mag*c*s2 + c1mag*s12); + + sx2 = a12*vb1x + a22*vb2x + a23*vb3x; + sy2 = a12*vb1y + a22*vb2y + a23*vb3y; + sz2 = a12*vb1z + a22*vb2z + a23*vb3z; + + f1[0] = a11*vb1x + a12*vb2x + a13*vb3x; + f1[1] = a11*vb1y + a12*vb2y + a13*vb3y; + f1[2] = a11*vb1z + a12*vb2z + a13*vb3z; + + f2[0] = -sx2 - f1[0]; + f2[1] = -sy2 - f1[1]; + f2[2] = -sz2 - f1[2]; + + f4[0] = a13*vb1x + a23*vb2x + a33*vb3x; + f4[1] = a13*vb1y + a23*vb2y + a33*vb3y; + f4[2] = a13*vb1z + a23*vb2z + a33*vb3z; + + f3[0] = sx2 - f4[0]; + f3[1] = sy2 - f4[1]; + f3[2] = sz2 - f4[2]; + + // only right bond crossing the plane + if (right_cross && !middle_cross && !left_cross) + { + double sgn = copysign(1.0, x_atom_1[dir] - pos); + df[0] = sgn * f1[0]; + df[1] = sgn * f1[1]; + df[2] = sgn * f1[2]; + } + + // only middle bond crossing the plane + if (!right_cross && middle_cross && !left_cross) + { + double sgn = copysign(1.0, x_atom_2[dir] - pos); + df[0] = sgn * (f2[0] + f1[0]); + df[1] = sgn * (f2[1] + f1[1]); + df[2] = sgn * (f2[2] + f1[2]); + } + + // only left bond crossing the plane + if (!right_cross && !middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_4[dir] - pos); + df[0] = sgn * f4[0]; + df[1] = sgn * f4[1]; + df[2] = sgn * f4[2]; + } + + // only right & middle bonds crossing the plane + if (right_cross && middle_cross && !left_cross) + { + double sgn = copysign(1.0, x_atom_2[dir] - pos); + df[0] = sgn * f2[0]; + df[1] = sgn * f2[1]; + df[2] = sgn * f2[2]; + } + + // only right & left bonds crossing the plane + if (right_cross && !middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_1[dir] - pos); + df[0] = sgn * (f1[0] + f4[0]); + df[1] = sgn * (f1[1] + f4[1]); + df[2] = sgn * (f1[2] + f4[2]); + } + + // only middle & left bonds crossing the plane + if (!right_cross && middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_3[dir] - pos); + df[0] = sgn * f3[0]; + df[1] = sgn * f3[1]; + df[2] = sgn * f3[2]; + } + + // all three bonds crossing the plane + if (right_cross && middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_1[dir] - pos); + df[0] = sgn * (f1[0] + f3[0]); + df[1] = sgn * (f1[1] + f3[1]); + df[2] = sgn * (f1[2] + f3[2]); + } + + local_contribution[ibin][0] += df[0]/area*nktv2p; + local_contribution[ibin][1] += df[1]/area*nktv2p; + local_contribution[ibin][2] += df[2]/area*nktv2p; + } + } + } + + // loop over the keywords and if necessary add the dihedral contribution + int m = 0; + while (m < nvalues) { + if ((which[m] == CONF) || (which[m] == TOTAL) || (which[m] == DIHEDRAL)) { + for (int ibin = 0; ibin < nbins; ibin++) { + dihedral_local[ibin][m] = local_contribution[ibin][0]; + dihedral_local[ibin][m+1] = local_contribution[ibin][1]; + dihedral_local[ibin][m+2] = local_contribution[ibin][2]; + } + } + m += 3; + } + +} + /* ---------------------------------------------------------------------- setup 1d bins and their extent and coordinates called at init() @@ -870,6 +1215,8 @@ void ComputeStressMopProfile::setup_bins() memory->create(bond_global, nbins, nvalues, "stress/mop/profile:bond_global"); memory->create(angle_local, nbins, nvalues, "stress/mop/profile:angle_local"); memory->create(angle_global, nbins, nvalues, "stress/mop/profile:angle_global"); + memory->create(dihedral_local,nbins,nvalues,"stress/mop/profile:dihedral_local"); + memory->create(dihedral_global,nbins,nvalues,"stress/mop/profile:dihedral_global"); memory->create(local_contribution, nbins, 3, "stress/mop/profile:local_contribution"); // set bin coordinates From b86d1f655381c076a6b378bc8ea8f46aedf5c6de Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:48:45 +0300 Subject: [PATCH 49/87] Update compute_stress_mop.rst for dihedral interactions --- doc/src/compute_stress_mop.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index 70986862fe..3cd7a67c9c 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -18,7 +18,7 @@ Syntax * style = *stress/mop* or *stress/mop/profile* * dir = *x* or *y* or *z* is the direction normal to the plane * args = argument specific to the compute style -* keywords = *kin* or *conf* or *total* or *pair* or *bond* or *angle* (one or more can be specified) +* keywords = *kin* or *conf* or *total* or *pair* or *bond* or *angle* or *dihedral* (one or more can be specified) .. parsed-literal:: @@ -68,13 +68,13 @@ Verlet algorithm. .. versionadded:: 15Jun2023 - contributions from bond and angle potentials + contributions from bond, angle and dihedral potentials -Between one and six keywords can be used to indicate which contributions +Between one and seven keywords can be used to indicate which contributions to the stress must be computed: total stress (total), kinetic stress (kin), configurational stress (conf), stress due to bond stretching -(bond), stress due to angle bending (angle) and/or due to pairwise -non-bonded interactions (pair). +(bond), stress due to angle bending (angle), stress due to dihedral terms (dihedral) +and/or due to pairwise non-bonded interactions (pair). NOTE 1: The configurational stress is computed considering all pairs of atoms where at least one atom belongs to group group-ID. @@ -134,7 +134,7 @@ requires the class method ``Pair::single()`` to be implemented, which is not possible for manybody potentials. In particular, compute *stress/mop/profile* does not work with more than two-body pair interactions, long range (kspace) interactions and -dihedral/improper intramolecular interactions. Similarly, compute +improper intramolecular interactions. Similarly, compute *stress/mop* does not work with more than two-body pair interactions, long range (kspace) interactions and dihedral/improper intramolecular interactions but works with all bond interactions with the class method From 1591b21617a196607306955e7d108f38b330ed1d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Tue, 26 Sep 2023 16:53:16 +0300 Subject: [PATCH 50/87] remove whitespaces from compute_stress_mop_profile.cpp --- src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 27e420e71d..223e4da66a 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -324,7 +324,7 @@ void ComputeStressMopProfile::compute_array() } } } - + for (int ibin = 0; ibin < nbins; ibin++) { array[ibin][0] = coord[ibin]; @@ -540,7 +540,7 @@ void ComputeStressMopProfile::compute_pairs() vcross[0] = vi[0] - fi[0] * iterm; vcross[1] = vi[1] - fi[1] * iterm; vcross[2] = vi[2] - fi[2] * iterm; - + values_local[ibin][m] += imass * vcross[0] * sgn / dt / area * nktv2p / ftm2v; values_local[ibin][m + 1] += imass * vcross[1] * sgn / dt / area * nktv2p / ftm2v; values_local[ibin][m + 2] += imass * vcross[2] * sgn / dt / area * nktv2p / ftm2v; From 3445330cf1679addfdce5ab3e678b54669dc933d Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 28 Sep 2023 16:13:13 +0300 Subject: [PATCH 51/87] remove whitespace from compute_stress_mop.cpp --- src/EXTRA-COMPUTE/compute_stress_mop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index a1077660e5..3f1ae008ea 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -433,7 +433,7 @@ void ComputeStressMop::compute_pairs() xi[dir] -= pos; domain->minimum_image(xi[0], xi[1], xi[2]); xi[dir] += pos; - + //velocities at t vi[0] = atom->v[i][0]; From ac435319fdf8b127ac33cfdf24ea6b8bfcc4649b Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 28 Sep 2023 16:15:03 +0300 Subject: [PATCH 52/87] Definition of compute_dihedral and related variables in compute_stress_mop.h --- src/EXTRA-COMPUTE/compute_stress_mop.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.h b/src/EXTRA-COMPUTE/compute_stress_mop.h index 86140dc278..0a0ea8b55a 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.h +++ b/src/EXTRA-COMPUTE/compute_stress_mop.h @@ -40,15 +40,17 @@ class ComputeStressMop : public Compute { void compute_pairs(); void compute_bonds(); void compute_angles(); + void compute_dihedrals(); int nvalues, dir; int *which; - int bondflag, angleflag; + int bondflag, angleflag, dihedralflag; double *values_local, *values_global; double *bond_local, *bond_global; double *angle_local, *angle_global; + double *dihedral_local, *dihedral_global; double pos, pos1, dt, nktv2p, ftm2v; double area; class NeighList *list; From ca449f1ea859d47e665ae98e5a58cf8aa9781e60 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 28 Sep 2023 16:25:52 +0300 Subject: [PATCH 53/87] Prepare for inclusion of dihedral contribution in compute_stress_mop.cpp --- src/EXTRA-COMPUTE/compute_stress_mop.cpp | 47 +++++++++++++++++++++--- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index 3f1ae008ea..d94ba61d71 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -23,6 +23,7 @@ #include "atom_vec.h" #include "bond.h" #include "comm.h" +#include "dihedral.h" #include "domain.h" #include "error.h" #include "force.h" @@ -38,8 +39,10 @@ using namespace LAMMPS_NS; +#define SMALL 0.001 + enum { X, Y, Z }; -enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE }; +enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE, DIHEDRAL }; /* ---------------------------------------------------------------------- */ @@ -49,6 +52,7 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute( bondflag = 0; angleflag = 0; + dihedralflag = 0; // set compute mode and direction of plane(s) for pressure calculation @@ -129,6 +133,11 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute( which[nvalues] = ANGLE; nvalues++; } + } else if (strcmp(arg[iarg],"dihedral") == 0) { + for (i=0; i<3; i++) { + which[nvalues] = DIHEDRAL; + nvalues++; + } } else error->all(FLERR, "Illegal compute stress/mop command"); //break; @@ -152,6 +161,8 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute( bond_global = nullptr; angle_local = nullptr; angle_global = nullptr; + dihedral_local = nullptr; + dihedral_global = nullptr; // this fix produces a global vector @@ -162,6 +173,8 @@ ComputeStressMop::ComputeStressMop(LAMMPS *lmp, int narg, char **arg) : Compute( memory->create(bond_global, nvalues, "stress/mop:bond_global"); memory->create(angle_local, nvalues, "stress/mop:angle_local"); memory->create(angle_global, nvalues, "stress/mop:angle_global"); + memory->create(dihedral_local,nvalues,"stress/mop:dihedral_local"); + memory->create(dihedral_global,nvalues,"stress/mop:dihedral_global"); size_vector = nvalues; vector_flag = 1; @@ -180,6 +193,8 @@ ComputeStressMop::~ComputeStressMop() memory->destroy(bond_global); memory->destroy(angle_local); memory->destroy(angle_global); + memory->destroy(dihedral_local); + memory->destroy(dihedral_global); memory->destroy(vector); } @@ -233,9 +248,13 @@ void ComputeStressMop::init() } } if (force->dihedral) { - if ((strcmp(force->dihedral_style, "zero") != 0) && - (strcmp(force->dihedral_style, "none") != 0)) - error->all(FLERR, "compute stress/mop does not account for dihedral potentials"); + if (force->dihedral->born_matrix_enable == 0) { + if ((strcmp(force->dihedral_style, "zero") != 0) && + (strcmp(force->dihedral_style, "none") != 0)) + error->all(FLERR, "compute stress/mop does not account for dihedral potentials"); + } else { + dihedralflag = 1; + } } if (force->improper) { if ((strcmp(force->improper_style, "zero") != 0) && @@ -297,8 +316,18 @@ void ComputeStressMop::compute_vector() MPI_Allreduce(angle_local, angle_global, nvalues, MPI_DOUBLE, MPI_SUM, world); + if (dihedralflag) { + //Compute dihedral contribution on separate procs + compute_dihedrals(); + } else { + for (int i=0; i Date: Thu, 28 Sep 2023 16:29:15 +0300 Subject: [PATCH 54/87] remove whitespace from compute_stress_mop.cpp --- src/EXTRA-COMPUTE/compute_stress_mop.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index d94ba61d71..331f4e4841 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -325,7 +325,7 @@ void ComputeStressMop::compute_vector() // sum dihedral contribution over all procs MPI_Allreduce(dihedral_local,dihedral_global,nvalues,MPI_DOUBLE,MPI_SUM,world); - + for (int m = 0; m < nvalues; m++) { vector[m] = values_global[m] + bond_global[m] + angle_global[m] + dihedral_global[m]; } From bbd6b2846f83cef48ed3960fe2496c64ee37f99e Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 28 Sep 2023 16:59:03 +0300 Subject: [PATCH 55/87] implementation of compute_dihedral() in compute_stress_mop.cpp --- src/EXTRA-COMPUTE/compute_stress_mop.cpp | 297 +++++++++++++++++++++++ 1 file changed, 297 insertions(+) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index 331f4e4841..6c35b4ba07 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -825,4 +825,301 @@ void ComputeStressMop::compute_angles() void ComputeStressMop::compute_dihedrals() { + int i, nd, atom1, atom2, atom3, atom4, imol, iatom; + tagint tagprev; + double vb1x, vb1y, vb1z, vb2x, vb2y, vb2z, vb3x, vb3y, vb3z; + double vb2xm, vb2ym, vb2zm; + double sb1, sb2, sb3, rb1, rb3, c0, b1mag2, b1mag, b2mag2; + double b2mag, b3mag2, b3mag, c2mag, ctmp, r12c1, c1mag, r12c2; + double s1, s2, s12, sc1, sc2, a11, a22, a33, a12, a13, a23; + double df[3], f1[3], f2[3], f3[3], f4[3]; + double c, sx2, sy2, sz2, sin2; + + double **x = atom->x; + tagint *tag = atom->tag; + int *num_dihedral = atom->num_dihedral; + tagint **dihedral_atom1 = atom->dihedral_atom1; + tagint **dihedral_atom2 = atom->dihedral_atom2; + tagint **dihedral_atom3 = atom->dihedral_atom3; + tagint **dihedral_atom4 = atom->dihedral_atom4; + int *mask = atom->mask; + + int *molindex = atom->molindex; + int *molatom = atom->molatom; + Molecule **onemols = atom->avec->onemols; + + int nlocal = atom->nlocal; + int molecular = atom->molecular; + + // loop over all atoms and their dihedrals + + Dihedral *dihedral = force->dihedral; + + double dudih, du2dih; + + double diffx[3] = {0.0, 0.0, 0.0}; + double x_atom_1[3] = {0.0, 0.0, 0.0}; + double x_atom_2[3] = {0.0, 0.0, 0.0}; + double x_atom_3[3] = {0.0, 0.0, 0.0}; + double x_atom_4[3] = {0.0, 0.0, 0.0}; + + // initialization + for (int i = 0; i < nvalues; i++) { + dihedral_local[i] = 0.0; + } + double local_contribution[3] = {0.0, 0.0, 0.0}; + + for (atom2 = 0; atom2 < nlocal; atom2++) { + if (!(mask[atom2] & groupbit)) continue; + + if (molecular == Atom::MOLECULAR) + nd = num_dihedral[atom2]; + else { + if (molindex[atom2] < 0) continue; + imol = molindex[atom2]; + iatom = molatom[atom2]; + nd = onemols[imol]->num_dihedral[iatom]; + } + + for (i = 0; i < nd; i++) { + if (molecular == 1) { + if (tag[atom2] != dihedral_atom2[atom2][i]) continue; + atom1 = atom->map(dihedral_atom1[atom2][i]); + atom3 = atom->map(dihedral_atom3[atom2][i]); + atom4 = atom->map(dihedral_atom4[atom2][i]); + } else { + if (tag[atom2] != onemols[imol]->dihedral_atom2[atom2][i]) continue; + tagprev = tag[atom2] - iatom - 1; + atom1 = atom->map(onemols[imol]->dihedral_atom1[atom2][i] + tagprev); + atom3 = atom->map(onemols[imol]->dihedral_atom3[atom2][i] + tagprev); + atom4 = atom->map(onemols[imol]->dihedral_atom4[atom2][i] + tagprev); + } + + if (atom1 < 0 || !(mask[atom1] & groupbit)) continue; + if (atom3 < 0 || !(mask[atom3] & groupbit)) continue; + if (atom4 < 0 || !(mask[atom4] & groupbit)) continue; + + // minimum image of atom1 with respect to the plane of interest + x_atom_1[0] = x[atom1][0]; + x_atom_1[1] = x[atom1][1]; + x_atom_1[2] = x[atom1][2]; + x_atom_1[dir] -= pos; + domain->minimum_image(x_atom_1[0], x_atom_1[1], x_atom_1[2]); + x_atom_1[dir] += pos; + + // minimum image of atom2 with respect to atom1 + diffx[0] = x[atom2][0] - x_atom_1[0]; + diffx[1] = x[atom2][1] - x_atom_1[1]; + diffx[2] = x[atom2][2] - x_atom_1[2]; + domain->minimum_image(diffx[0], diffx[1], diffx[2]); + x_atom_2[0] = x_atom_1[0] + diffx[0]; + x_atom_2[1] = x_atom_1[1] + diffx[1]; + x_atom_2[2] = x_atom_1[2] + diffx[2]; + + // minimum image of atom3 with respect to atom2 + diffx[0] = x[atom3][0] - x_atom_2[0]; + diffx[1] = x[atom3][1] - x_atom_2[1]; + diffx[2] = x[atom3][2] - x_atom_2[2]; + domain->minimum_image(diffx[0], diffx[1], diffx[2]); + x_atom_3[0] = x_atom_2[0] + diffx[0]; + x_atom_3[1] = x_atom_2[1] + diffx[1]; + x_atom_3[2] = x_atom_2[2] + diffx[2]; + + // minimum image of atom3 with respect to atom2 + diffx[0] = x[atom4][0] - x_atom_3[0]; + diffx[1] = x[atom4][1] - x_atom_3[1]; + diffx[2] = x[atom4][2] - x_atom_3[2]; + domain->minimum_image(diffx[0], diffx[1], diffx[2]); + x_atom_4[0] = x_atom_3[0] + diffx[0]; + x_atom_4[1] = x_atom_3[1] + diffx[1]; + x_atom_4[2] = x_atom_3[2] + diffx[2]; + + // check if any bond vector crosses the plane of interest + double tau_right = (x_atom_2[dir] - pos) / (x_atom_2[dir] - x_atom_1[dir]); + double tau_middle = (x_atom_3[dir] - pos) / (x_atom_3[dir] - x_atom_2[dir]); + double tau_left = (x_atom_4[dir] - pos) / (x_atom_4[dir] - x_atom_3[dir]); + bool right_cross = ((tau_right >=0) && (tau_right <= 1)); + bool middle_cross = ((tau_middle >= 0) && (tau_middle <= 1)); + bool left_cross = ((tau_left >=0) && (tau_left <= 1)); + + // no bonds crossing the plane + if (!right_cross && !middle_cross && !left_cross) continue; + + dihedral->born_matrix(i, atom1, atom2, atom3, atom4, dudih, du2dih); + + // first bond + vb1x = x_atom_1[0] - x_atom_2[0]; + vb1y = x_atom_1[1] - x_atom_2[1]; + vb1z = x_atom_1[2] - x_atom_2[2]; + + // second bond + vb2x = x_atom_3[0] - x_atom_2[0]; + vb2y = x_atom_3[1] - x_atom_2[1]; + vb2z = x_atom_3[2] - x_atom_2[2]; + + vb2xm = -vb2x; + vb2ym = -vb2y; + vb2zm = -vb2z; + + // third bond + vb3x = x_atom_4[0] - x_atom_3[0]; + vb3y = x_atom_4[1] - x_atom_3[1]; + vb3z = x_atom_4[2] - x_atom_3[2]; + + // c0 calculation + sb1 = 1.0 / (vb1x*vb1x + vb1y*vb1y + vb1z*vb1z); + sb2 = 1.0 / (vb2x*vb2x + vb2y*vb2y + vb2z*vb2z); + sb3 = 1.0 / (vb3x*vb3x + vb3y*vb3y + vb3z*vb3z); + + rb1 = sqrt(sb1); + rb3 = sqrt(sb3); + + c0 = (vb1x*vb3x + vb1y*vb3y + vb1z*vb3z) * rb1*rb3; + // 1st and 2nd angle + b1mag2 = vb1x*vb1x + vb1y*vb1y + vb1z*vb1z; + b1mag = sqrt(b1mag2); + b2mag2 = vb2x*vb2x + vb2y*vb2y + vb2z*vb2z; + b2mag = sqrt(b2mag2); + b3mag2 = vb3x*vb3x + vb3y*vb3y + vb3z*vb3z; + b3mag = sqrt(b3mag2); + + ctmp = vb1x*vb2x + vb1y*vb2y + vb1z*vb2z; + r12c1 = 1.0 / (b1mag*b2mag); + c1mag = ctmp * r12c1; + + ctmp = vb2xm*vb3x + vb2ym*vb3y + vb2zm*vb3z; + r12c2 = 1.0 / (b2mag*b3mag); + c2mag = ctmp * r12c2; + + // cos and sin of 2 angles and final c + sin2 = MAX(1.0 - c1mag*c1mag,0.0); + sc1 = sqrt(sin2); + if (sc1 < SMALL) sc1 = SMALL; + sc1 = 1.0/sc1; + + sin2 = MAX(1.0 - c2mag*c2mag,0.0); + sc2 = sqrt(sin2); + if (sc2 < SMALL) sc2 = SMALL; + sc2 = 1.0/sc2; + + s1 = sc1 * sc1; + s2 = sc2 * sc2; + s12 = sc1 * sc2; + c = (c0 + c1mag*c2mag) * s12; + + // error check + if (c > 1.0) c = 1.0; + if (c < -1.0) c = -1.0; + + // forces on each particle + double a = dudih; + c = c * a; + s12 = s12 * a; + a11 = c*sb1*s1; + a22 = -sb2 * (2.0*c0*s12 - c*(s1+s2)); + a33 = c*sb3*s2; + a12 = -r12c1 * (c1mag*c*s1 + c2mag*s12); + a13 = -rb1*rb3*s12; + a23 = r12c2 * (c2mag*c*s2 + c1mag*s12); + + sx2 = a12*vb1x + a22*vb2x + a23*vb3x; + sy2 = a12*vb1y + a22*vb2y + a23*vb3y; + sz2 = a12*vb1z + a22*vb2z + a23*vb3z; + + f1[0] = a11*vb1x + a12*vb2x + a13*vb3x; + f1[1] = a11*vb1y + a12*vb2y + a13*vb3y; + f1[2] = a11*vb1z + a12*vb2z + a13*vb3z; + + f2[0] = -sx2 - f1[0]; + f2[1] = -sy2 - f1[1]; + f2[2] = -sz2 - f1[2]; + + f4[0] = a13*vb1x + a23*vb2x + a33*vb3x; + f4[1] = a13*vb1y + a23*vb2y + a33*vb3y; + f4[2] = a13*vb1z + a23*vb2z + a33*vb3z; + + f3[0] = sx2 - f4[0]; + f3[1] = sy2 - f4[1]; + f3[2] = sz2 - f4[2]; + + // only right bond crossing the plane + if (right_cross && !middle_cross && !left_cross) + { + double sgn = copysign(1.0, x_atom_1[dir] - pos); + df[0] = sgn * f1[0]; + df[1] = sgn * f1[1]; + df[2] = sgn * f1[2]; + } + + // only middle bond crossing the plane + if (!right_cross && middle_cross && !left_cross) + { + double sgn = copysign(1.0, x_atom_2[dir] - pos); + df[0] = sgn * (f2[0] + f1[0]); + df[1] = sgn * (f2[1] + f1[1]); + df[2] = sgn * (f2[2] + f1[2]); + } + + // only left bond crossing the plane + if (!right_cross && !middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_4[dir] - pos); + df[0] = sgn * f4[0]; + df[1] = sgn * f4[1]; + df[2] = sgn * f4[2]; + } + + // only right & middle bonds crossing the plane + if (right_cross && middle_cross && !left_cross) + { + double sgn = copysign(1.0, x_atom_2[dir] - pos); + df[0] = sgn * f2[0]; + df[1] = sgn * f2[1]; + df[2] = sgn * f2[2]; + } + + // only right & left bonds crossing the plane + if (right_cross && !middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_1[dir] - pos); + df[0] = sgn * (f1[0] + f4[0]); + df[1] = sgn * (f1[1] + f4[1]); + df[2] = sgn * (f1[2] + f4[2]); + } + + // only middle & left bonds crossing the plane + if (!right_cross && middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_3[dir] - pos); + df[0] = sgn * f3[0]; + df[1] = sgn * f3[1]; + df[2] = sgn * f3[2]; + } + + // all three bonds crossing the plane + if (right_cross && middle_cross && left_cross) + { + double sgn = copysign(1.0, x_atom_1[dir] - pos); + df[0] = sgn * (f1[0] + f3[0]); + df[1] = sgn * (f1[1] + f3[1]); + df[2] = sgn * (f1[2] + f3[2]); + } + + local_contribution[0] += df[0]/area*nktv2p; + local_contribution[1] += df[1]/area*nktv2p; + local_contribution[2] += df[2]/area*nktv2p; + } + } + + // loop over the keywords and if necessary add the dihedral contribution + int m = 0; + while (m < nvalues) { + if ((which[m] == CONF) || (which[m] == TOTAL) || (which[m] == DIHEDRAL)) { + dihedral_local[m] = local_contribution[0]; + dihedral_local[m+1] = local_contribution[1]; + dihedral_local[m+2] = local_contribution[2]; + } + m += 3; + } + } From dc84ab5e5fc826e8095eb7d2c2ec38628dc4c7f7 Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 28 Sep 2023 17:06:11 +0300 Subject: [PATCH 56/87] Update compute_stress_mop.rst --- doc/src/compute_stress_mop.rst | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/src/compute_stress_mop.rst b/doc/src/compute_stress_mop.rst index 3cd7a67c9c..74d4c618e7 100644 --- a/doc/src/compute_stress_mop.rst +++ b/doc/src/compute_stress_mop.rst @@ -132,14 +132,9 @@ size does not change in time, and axis-aligned planes. The method only works with two-body pair interactions, because it requires the class method ``Pair::single()`` to be implemented, which is not possible for manybody potentials. In particular, compute -*stress/mop/profile* does not work with more than two-body pair +*stress/mop/profile* and *stress/mop* do not work with more than two-body pair interactions, long range (kspace) interactions and -improper intramolecular interactions. Similarly, compute -*stress/mop* does not work with more than two-body pair interactions, -long range (kspace) interactions and dihedral/improper intramolecular -interactions but works with all bond interactions with the class method -single() implemented and all angle interactions with the class method -born_matrix() implemented. +improper intramolecular interactions. Related commands """""""""""""""" From d84ee0c4f1f97728d69a55163d8356eba16e290b Mon Sep 17 00:00:00 2001 From: Evangelos Voyiatzis Date: Thu, 28 Sep 2023 17:48:17 +0300 Subject: [PATCH 57/87] Update compute_stress_mop_profile.cpp --- src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 223e4da66a..41b5f64a67 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -325,6 +325,9 @@ void ComputeStressMopProfile::compute_array() } } + // sum dihedral contribution over all procs + MPI_Allreduce(&dihedral_local[0][0],&dihedral_global[0][0],nbins*nvalues,MPI_DOUBLE,MPI_SUM,world); + for (int ibin = 0; ibin < nbins; ibin++) { array[ibin][0] = coord[ibin]; From 14f0045567adfd724cc598b7d7f082b35b6617b6 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 23 Oct 2023 10:27:18 -0600 Subject: [PATCH 58/87] Fixing missing variable in multi --- src/npair_multi.cpp | 2 ++ src/nstencil_multi.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index e74e16470a..7cfb3b836b 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -92,6 +92,8 @@ void NPairMulti::build(NeighList *list) for (i = 0; i < nlocal; i++) { n = 0; neighptr = ipage->vget(); + + itag = tag[i]; itype = type[i]; icollection = collection[i]; xtmp = x[i][0]; diff --git a/src/nstencil_multi.cpp b/src/nstencil_multi.cpp index 8e504cc9b9..a73215a058 100644 --- a/src/nstencil_multi.cpp +++ b/src/nstencil_multi.cpp @@ -95,6 +95,8 @@ void NStencilMulti::create() // Half and ortho stencils include central bin first // This preserves the historical order of the neighbor list // as the old npair classes used to separately parse the central bin first + // This !TRI condition (and the one below) are now unnecessary + // since triclinic only uses full stencils - kept the flags for clarity if (HALF && (!TRI)) if (half_flag) stencil_multi[icollection][jcollection][ns++] = 0; @@ -119,7 +121,7 @@ void NStencilMulti::create() } } } - if (bin_distance_multi(i,j,k,bin_collection) < cutsq) + if (bin_distance_multi(i, j, k, bin_collection) < cutsq) stencil_multi[icollection][jcollection][ns++] = k * mbiny * mbinx + j * mbinx + i; } } From 3536cf9db968a20ad6d7fca9006b2b99f4f4af94 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 23 Oct 2023 12:59:13 -0600 Subject: [PATCH 59/87] Adding triclinic patch to intel stencil --- src/INTEL/nstencil_bin_intel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/INTEL/nstencil_bin_intel.cpp b/src/INTEL/nstencil_bin_intel.cpp index 36a79e2997..4b7dc31f46 100644 --- a/src/INTEL/nstencil_bin_intel.cpp +++ b/src/INTEL/nstencil_bin_intel.cpp @@ -32,8 +32,8 @@ void NStencilBinIntel::create() // For half stencils, only the upper plane is needed int sy_min = sy; int sz_min = sz; - if (HALF && (!DIM_3D)) sy_min = 0; - if (HALF && DIM_3D) sz_min = 0; + if ((!TRI) && HALF && (!DIM_3D)) sy_min = 0; + if ((!TRI) && HALF && DIM_3D) sz_min = 0; nstencil = 0; From 51577eff2ccde5a9bd734ac5f5e73f733adbf521 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 23 Oct 2023 16:14:56 -0600 Subject: [PATCH 60/87] 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; From 8054d2807a3926cd95f1a37d9140f0c75cf84ccd Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 23 Oct 2023 16:54:56 -0600 Subject: [PATCH 61/87] Adding full atomonly bin npair style --- src/OPENMP/npair_multi_old_omp.cpp | 2 +- src/npair_bin.h | 6 ++++++ src/npair_multi_old.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/OPENMP/npair_multi_old_omp.cpp b/src/OPENMP/npair_multi_old_omp.cpp index 894ff9b987..08bc54a72b 100644 --- a/src/OPENMP/npair_multi_old_omp.cpp +++ b/src/OPENMP/npair_multi_old_omp.cpp @@ -166,7 +166,7 @@ void NPairMultiOldOmp::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil,except for i's bin - if (stencil[k] == 0) { + if (s[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) { diff --git a/src/npair_bin.h b/src/npair_bin.h index 2cec108e46..94b7c7077e 100644 --- a/src/npair_bin.h +++ b/src/npair_bin.h @@ -55,6 +55,12 @@ NPairStyle(half/size/bin/newton/tri, NPairHalfSizeBinNewtonTri, NP_HALF | NP_SIZE | NP_BIN | NP_MOLONLY | NP_NEWTON | NP_TRI); +typedef NPairBin<0, 1, 0, 0, 1> NPairFullBinAtomonly; +NPairStyle(full/bin/atomonly, + NPairFullBinAtomonly, + NP_FULL | NP_BIN | NP_ATOMONLY | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + typedef NPairBin<1, 0, 0, 0, 1> NPairHalfBinAtomonlyNewtoff; NPairStyle(half/bin/atomonly/newtoff, NPairHalfBinAtomonlyNewtoff, diff --git a/src/npair_multi_old.cpp b/src/npair_multi_old.cpp index fa39182018..b2d77227cc 100644 --- a/src/npair_multi_old.cpp +++ b/src/npair_multi_old.cpp @@ -159,7 +159,7 @@ void NPairMultiOld::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil,except for i's bin - if (stencil[k] == 0) { + if (s[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) { From 0f94e6030f1f895ebb15cba5faf197edcb63a9d6 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 24 Oct 2023 12:26:37 -0600 Subject: [PATCH 62/87] Adding separate ghost stencil for intel --- src/INTEL/nstencil_ghost_bin_intel.cpp | 76 ++++++++++++++++++++++++++ src/INTEL/nstencil_ghost_bin_intel.h | 65 ++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/INTEL/nstencil_ghost_bin_intel.cpp create mode 100644 src/INTEL/nstencil_ghost_bin_intel.h diff --git a/src/INTEL/nstencil_ghost_bin_intel.cpp b/src/INTEL/nstencil_ghost_bin_intel.cpp new file mode 100644 index 0000000000..cd8203eb64 --- /dev/null +++ b/src/INTEL/nstencil_ghost_bin_intel.cpp @@ -0,0 +1,76 @@ +/* ---------------------------------------------------------------------- + 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 "nstencil_ghost_bin_intel.h" + +using namespace LAMMPS_NS; + +/* ---------------------------------------------------------------------- */ + +template +NStencilGhostBinIntel::NStencilGhostBinIntel(LAMMPS *lmp) : NStencil(lmp) +{ + xyzflag = 1; +} + +/* ---------------------------------------------------------------------- + create stencil based on bin geometry and cutoff +------------------------------------------------------------------------- */ + +template +void NStencilGhostBinIntel::create() +{ + int i, j, k; + + // For half stencils, only the upper plane is needed + int sy_min = sy; + int sz_min = sz; + if (HALF && (!DIM_3D)) sy_min = 0; + if (HALF && DIM_3D) sz_min = 0; + + nstencil = 0; + + // For Intel, half and ortho stencils do not include central bin + // as, historically, this was never included in a stencil. + // Non-Intel npair classes were updated to account for this change, + // but the Intel npair classes have not yet been updated + // if (HALF && (!TRI)) stencil[nstencil++] = 0; + + for (k = -sz_min; k <= sz; k++) { + for (j = -sy_min; j <= sy; j++) { + for (i = -sx; i <= sx; i++) { + + // Now only include "upper right" bins for half and ortho stencils + if (HALF && (!DIM_3D) && (!TRI)) + if (! (j > 0 || (j == 0 && i > 0))) continue; + if (HALF && DIM_3D && (!TRI)) + if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; + + if (bin_distance(i,j,k) < cutneighmaxsq) { + stencilxyz[nstencil][0] = i; + stencilxyz[nstencil][1] = j; + stencilxyz[nstencil][2] = k; + } + } + } + } +} + +namespace LAMMPS_NS { +template class NStencilGhostBinIntel<0,0,0>; +template class NStencilGhostBinIntel<0,1,0>; +template class NStencilGhostBinIntel<1,0,0>; +template class NStencilGhostBinIntel<1,0,1>; +template class NStencilGhostBinIntel<1,1,0>; +template class NStencilGhostBinIntel<1,1,1>; +} diff --git a/src/INTEL/nstencil_ghost_bin_intel.h b/src/INTEL/nstencil_ghost_bin_intel.h new file mode 100644 index 0000000000..c76303309f --- /dev/null +++ b/src/INTEL/nstencil_ghost_bin_intel.h @@ -0,0 +1,65 @@ +/* -*- 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 NSTENCIL_CLASS +// clang-format off +typedef NStencilGhostBinIntel<0, 0, 0> NStencilFullGhostBin2dIntel; +NStencilStyle(full/ghost/bin/2d/intel, + NStencilFullGhostBin2dIntel, + NS_FULL | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_TRI | NS_INTEL); + +typedef NStencilGhostBinIntel<0, 1, 0> NStencilFullGhostBin3dIntel; +NStencilStyle(full/ghost/bin/3d/intel, + NStencilFullGhostBin3dIntel, + NS_FULL | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_TRI | NS_INTEL); + +typedef NStencilGhostBinIntel<1, 0, 0> NStencilHalfGhostBin2dIntel; +NStencilStyle(half/ghost/bin/2d/intel, + NStencilHalfGhostBin2dIntel, + NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_INTEL); + +typedef NStencilGhostBinIntel<1, 0, 1> NStencilHalfGhostBin2dTriIntel; +NStencilStyle(half/ghost/bin/2d/tri/intel, + NStencilHalfGhostBin2dTriIntel, + NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_TRI | NS_INTEL); + +typedef NStencilGhostBinIntel<1, 1, 0> NStencilHalfGhostBin3dIntel; +NStencilStyle(half/ghost/bin/3d/intel, + NStencilHalfGhostBin3dIntel, + NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_INTEL); + +typedef NStencilGhostBinIntel<1, 1, 1> NStencilHalfGhostBin3dTriIntel; +NStencilStyle(half/ghost/bin/3d/tri/intel, + NStencilHalfGhostBin3dTriIntel, + NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_TRI | NS_INTEL); +// clang-format on +#else + +#ifndef LMP_NSTENCIL_GHOST_BIN_INTEL_H +#define LMP_NSTENCIL_GHOST_BIN_INTEL_H + +#include "nstencil.h" + +namespace LAMMPS_NS { + +template +class NStencilGhostBinIntel : public NStencil { + public: + NStencilGhostBinIntel(class LAMMPS *); + void create() override; +}; + +} // namespace LAMMPS_NS + +#endif +#endif From 8f14cdcb3473b16ed17eb2d2bc0d9ad0d465c9eb Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 24 Oct 2023 13:55:43 -0600 Subject: [PATCH 63/87] Cleaning up ghost stencils --- src/INTEL/nstencil_bin_intel.cpp | 2 +- src/INTEL/nstencil_ghost_bin_intel.cpp | 42 ++++++-------------------- src/INTEL/nstencil_ghost_bin_intel.h | 26 ++-------------- src/nstencil_bin.cpp | 2 +- src/nstencil_ghost_bin.cpp | 40 ++++++------------------ src/nstencil_ghost_bin.h | 26 ++-------------- 6 files changed, 27 insertions(+), 111 deletions(-) diff --git a/src/INTEL/nstencil_bin_intel.cpp b/src/INTEL/nstencil_bin_intel.cpp index 4b7dc31f46..426fcec33c 100644 --- a/src/INTEL/nstencil_bin_intel.cpp +++ b/src/INTEL/nstencil_bin_intel.cpp @@ -53,7 +53,7 @@ void NStencilBinIntel::create() if (HALF && DIM_3D && (!TRI)) if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; - if (bin_distance(i,j,k) < cutneighmaxsq) + if (bin_distance(i, j, k) < cutneighmaxsq) stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; } } diff --git a/src/INTEL/nstencil_ghost_bin_intel.cpp b/src/INTEL/nstencil_ghost_bin_intel.cpp index cd8203eb64..23d4930cc0 100644 --- a/src/INTEL/nstencil_ghost_bin_intel.cpp +++ b/src/INTEL/nstencil_ghost_bin_intel.cpp @@ -17,8 +17,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -template -NStencilGhostBinIntel::NStencilGhostBinIntel(LAMMPS *lmp) : NStencil(lmp) +template +NStencilGhostBinIntel::NStencilGhostBinIntel(LAMMPS *lmp) : NStencil(lmp) { xyzflag = 1; } @@ -27,39 +27,21 @@ NStencilGhostBinIntel::NStencilGhostBinIntel(LAMMPS *lmp) : N create stencil based on bin geometry and cutoff ------------------------------------------------------------------------- */ -template -void NStencilGhostBinIntel::create() +template +void NStencilGhostBinIntel::create() { int i, j, k; - // For half stencils, only the upper plane is needed - int sy_min = sy; - int sz_min = sz; - if (HALF && (!DIM_3D)) sy_min = 0; - if (HALF && DIM_3D) sz_min = 0; - nstencil = 0; - // For Intel, half and ortho stencils do not include central bin - // as, historically, this was never included in a stencil. - // Non-Intel npair classes were updated to account for this change, - // but the Intel npair classes have not yet been updated - // if (HALF && (!TRI)) stencil[nstencil++] = 0; - - for (k = -sz_min; k <= sz; k++) { - for (j = -sy_min; j <= sy; j++) { + for (k = -sz; k <= sz; k++) { + for (j = -sy; j <= sy; j++) { for (i = -sx; i <= sx; i++) { - - // Now only include "upper right" bins for half and ortho stencils - if (HALF && (!DIM_3D) && (!TRI)) - if (! (j > 0 || (j == 0 && i > 0))) continue; - if (HALF && DIM_3D && (!TRI)) - if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; - - if (bin_distance(i,j,k) < cutneighmaxsq) { + if (bin_distance(i, j, k) < cutneighmaxsq) { stencilxyz[nstencil][0] = i; stencilxyz[nstencil][1] = j; stencilxyz[nstencil][2] = k; + stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; } } } @@ -67,10 +49,6 @@ void NStencilGhostBinIntel::create() } namespace LAMMPS_NS { -template class NStencilGhostBinIntel<0,0,0>; -template class NStencilGhostBinIntel<0,1,0>; -template class NStencilGhostBinIntel<1,0,0>; -template class NStencilGhostBinIntel<1,0,1>; -template class NStencilGhostBinIntel<1,1,0>; -template class NStencilGhostBinIntel<1,1,1>; +template class NStencilGhostBinIntel<0>; +template class NStencilGhostBinIntel<1>; } diff --git a/src/INTEL/nstencil_ghost_bin_intel.h b/src/INTEL/nstencil_ghost_bin_intel.h index c76303309f..f4ae9f9804 100644 --- a/src/INTEL/nstencil_ghost_bin_intel.h +++ b/src/INTEL/nstencil_ghost_bin_intel.h @@ -13,35 +13,15 @@ #ifdef NSTENCIL_CLASS // clang-format off -typedef NStencilGhostBinIntel<0, 0, 0> NStencilFullGhostBin2dIntel; +typedef NStencilGhostBinIntel<0> NStencilFullGhostBin2dIntel; NStencilStyle(full/ghost/bin/2d/intel, NStencilFullGhostBin2dIntel, NS_FULL | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_TRI | NS_INTEL); -typedef NStencilGhostBinIntel<0, 1, 0> NStencilFullGhostBin3dIntel; +typedef NStencilGhostBinIntel<1> NStencilFullGhostBin3dIntel; NStencilStyle(full/ghost/bin/3d/intel, NStencilFullGhostBin3dIntel, NS_FULL | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_TRI | NS_INTEL); - -typedef NStencilGhostBinIntel<1, 0, 0> NStencilHalfGhostBin2dIntel; -NStencilStyle(half/ghost/bin/2d/intel, - NStencilHalfGhostBin2dIntel, - NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_INTEL); - -typedef NStencilGhostBinIntel<1, 0, 1> NStencilHalfGhostBin2dTriIntel; -NStencilStyle(half/ghost/bin/2d/tri/intel, - NStencilHalfGhostBin2dTriIntel, - NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_TRI | NS_INTEL); - -typedef NStencilGhostBinIntel<1, 1, 0> NStencilHalfGhostBin3dIntel; -NStencilStyle(half/ghost/bin/3d/intel, - NStencilHalfGhostBin3dIntel, - NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_INTEL); - -typedef NStencilGhostBinIntel<1, 1, 1> NStencilHalfGhostBin3dTriIntel; -NStencilStyle(half/ghost/bin/3d/tri/intel, - NStencilHalfGhostBin3dTriIntel, - NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_TRI | NS_INTEL); // clang-format on #else @@ -52,7 +32,7 @@ NStencilStyle(half/ghost/bin/3d/tri/intel, namespace LAMMPS_NS { -template +template class NStencilGhostBinIntel : public NStencil { public: NStencilGhostBinIntel(class LAMMPS *); diff --git a/src/nstencil_bin.cpp b/src/nstencil_bin.cpp index accce7c395..2b7c15cff6 100644 --- a/src/nstencil_bin.cpp +++ b/src/nstencil_bin.cpp @@ -59,7 +59,7 @@ void NStencilBin::create() if (HALF && DIM_3D && (!TRI)) if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; - if (bin_distance(i,j,k) < cutneighmaxsq) + if (bin_distance(i, j, k) < cutneighmaxsq) stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i; } } diff --git a/src/nstencil_ghost_bin.cpp b/src/nstencil_ghost_bin.cpp index b83a0ffd46..81372bedaf 100644 --- a/src/nstencil_ghost_bin.cpp +++ b/src/nstencil_ghost_bin.cpp @@ -17,8 +17,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -template -NStencilGhostBin::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp) +template +NStencilGhostBin::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp) { xyzflag = 1; } @@ -27,35 +27,17 @@ NStencilGhostBin::NStencilGhostBin(LAMMPS *lmp) : NStencil(lm create stencil based on bin geometry and cutoff ------------------------------------------------------------------------- */ -template -void NStencilGhostBin::create() +template +void NStencilGhostBin::create() { int i, j, k; - // For half stencils, only the upper plane is needed - int sy_min = sy; - int sz_min = sz; - if (HALF && (!DIM_3D)) sy_min = 0; - if (HALF && DIM_3D) sz_min = 0; - nstencil = 0; - // Half and ortho stencils include central bin first - // This preserves the historical order of the neighbor list - // as the old npair classes used to separately parse the central bin first - if (HALF && (!TRI)) stencil[nstencil++] = 0; - - for (k = -sz_min; k <= sz; k++) { - for (j = -sy_min; j <= sy; j++) { + for (k = -sz; k <= sz; k++) { + for (j = -sy; j <= sy; j++) { for (i = -sx; i <= sx; i++) { - - // Now only include "upper right" bins for half and ortho stencils - if (HALF && (!DIM_3D) && (!TRI)) - if (! (j > 0 || (j == 0 && i > 0))) continue; - if (HALF && DIM_3D && (!TRI)) - if (! (k > 0 || j > 0 || (j == 0 && i > 0))) continue; - - if (bin_distance(i,j,k) < cutneighmaxsq) { + if (bin_distance(i, j, k) < cutneighmaxsq) { stencilxyz[nstencil][0] = i; stencilxyz[nstencil][1] = j; stencilxyz[nstencil][2] = k; @@ -67,10 +49,6 @@ void NStencilGhostBin::create() } namespace LAMMPS_NS { -template class NStencilGhostBin<0,0,0>; -template class NStencilGhostBin<0,1,0>; -template class NStencilGhostBin<1,0,0>; -template class NStencilGhostBin<1,0,1>; -template class NStencilGhostBin<1,1,0>; -template class NStencilGhostBin<1,1,1>; +template class NStencilGhostBin<0>; +template class NStencilGhostBin<1>; } diff --git a/src/nstencil_ghost_bin.h b/src/nstencil_ghost_bin.h index ccf45fc502..ed4ae21be9 100644 --- a/src/nstencil_ghost_bin.h +++ b/src/nstencil_ghost_bin.h @@ -13,35 +13,15 @@ #ifdef NSTENCIL_CLASS // clang-format off -typedef NStencilGhostBin<0, 0, 0> NStencilFullGhostBin2d; +typedef NStencilGhostBin<0> NStencilFullGhostBin2d; NStencilStyle(full/ghost/bin/2d, NStencilFullGhostBin2d, NS_FULL | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO | NS_TRI); -typedef NStencilGhostBin<0, 1, 0> NStencilFullGhostBin3d; +typedef NStencilGhostBin<1> NStencilFullGhostBin3d; NStencilStyle(full/ghost/bin/3d, NStencilFullGhostBin3d, NS_FULL | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO | NS_TRI); - -typedef NStencilGhostBin<1, 0, 0> NStencilHalfGhostBin2d; -NStencilStyle(half/ghost/bin/2d, - NStencilHalfGhostBin2d, - NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_ORTHO); - -typedef NStencilGhostBin<1, 0, 1> NStencilHalfGhostBin2dTri; -NStencilStyle(half/ghost/bin/2d/tri, - NStencilHalfGhostBin2dTri, - NS_HALF | NS_GHOST | NS_BIN | NS_2D | NS_TRI); - -typedef NStencilGhostBin<1, 1, 0> NStencilHalfGhostBin3d; -NStencilStyle(half/ghost/bin/3d, - NStencilHalfGhostBin3d, - NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_ORTHO); - -typedef NStencilGhostBin<1, 1, 1> NStencilHalfGhostBin3dTri; -NStencilStyle(half/ghost/bin/3d/tri, - NStencilHalfGhostBin3dTri, - NS_HALF | NS_GHOST | NS_BIN | NS_3D | NS_TRI); // clang-format on #else @@ -52,7 +32,7 @@ NStencilStyle(half/ghost/bin/3d/tri, namespace LAMMPS_NS { -template +template class NStencilGhostBin : public NStencil { public: NStencilGhostBin(class LAMMPS *); From 745f2e6c54c462558f2a31ac71fbefe0326d4484 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Wed, 1 Nov 2023 12:22:30 -0600 Subject: [PATCH 64/87] Changing logic for self-bin check, newton+ortho --- src/OPENMP/npair_bin_ghost_omp.cpp | 2 +- src/OPENMP/npair_bin_omp.cpp | 8 +++--- src/OPENMP/npair_halffull_omp.cpp | 6 ++--- src/OPENMP/npair_multi_old_omp.cpp | 4 +-- src/OPENMP/npair_multi_omp.cpp | 36 ++++++++++++-------------- src/OPENMP/npair_nsq_ghost_omp.cpp | 2 +- src/OPENMP/npair_nsq_omp.cpp | 6 ++--- src/OPENMP/npair_respa_bin_omp.cpp | 14 +++++----- src/OPENMP/npair_respa_nsq_omp.cpp | 8 +++--- src/OPENMP/npair_trim_omp.cpp | 2 +- src/npair_bin.cpp | 10 +++---- src/npair_multi.cpp | 36 ++++++++++++-------------- src/npair_multi_old.cpp | 6 ++--- src/npair_nsq.cpp | 2 +- src/npair_respa_bin.cpp | 12 ++++----- src/npair_respa_nsq.cpp | 8 +++--- src/npair_skip_respa.cpp | 10 +++---- src/npair_skip_size_off2on_oneside.cpp | 2 +- 18 files changed, 85 insertions(+), 89 deletions(-) diff --git a/src/OPENMP/npair_bin_ghost_omp.cpp b/src/OPENMP/npair_bin_ghost_omp.cpp index d842294338..f542cf214a 100644 --- a/src/OPENMP/npair_bin_ghost_omp.cpp +++ b/src/OPENMP/npair_bin_ghost_omp.cpp @@ -185,7 +185,7 @@ void NPairBinGhostOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = nlocal; diff --git a/src/OPENMP/npair_bin_omp.cpp b/src/OPENMP/npair_bin_omp.cpp index 81b5e085d6..5b2189dec2 100644 --- a/src/OPENMP/npair_bin_omp.cpp +++ b/src/OPENMP/npair_bin_omp.cpp @@ -117,7 +117,7 @@ void NPairBinOmp::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin + stencil[k]]; if (HALF && NEWTON && (!TRI)) { - if (stencil[k] == 0) { + if (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]; @@ -163,7 +163,7 @@ void NPairBinOmp::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil, except for i's bin - if (stencil[k] == 0) { + if (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) { @@ -229,7 +229,7 @@ void NPairBinOmp::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; if (which == 0) @@ -250,7 +250,7 @@ void NPairBinOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = nlocal; diff --git a/src/OPENMP/npair_halffull_omp.cpp b/src/OPENMP/npair_halffull_omp.cpp index 78ec11023f..bc646accbc 100644 --- a/src/OPENMP/npair_halffull_omp.cpp +++ b/src/OPENMP/npair_halffull_omp.cpp @@ -106,9 +106,9 @@ void NPairHalffullOmp::build(NeighList *list) if (j < nlocal) { if (i > j) continue; } else if (TRI) { - if (fabs(x[j][2]-ztmp) > delta) { + if (fabs(x[j][2] - ztmp) > delta) { if (x[j][2] < ztmp) continue; - } else if (fabs(x[j][1]-ytmp) > delta) { + } else if (fabs(x[j][1] - ytmp) > delta) { if (x[j][1] < ytmp) continue; } else { if (x[j][0] < xtmp) continue; @@ -149,7 +149,7 @@ void NPairHalffullOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = inum_full; diff --git a/src/OPENMP/npair_multi_old_omp.cpp b/src/OPENMP/npair_multi_old_omp.cpp index 08bc54a72b..d45f2d1f5f 100644 --- a/src/OPENMP/npair_multi_old_omp.cpp +++ b/src/OPENMP/npair_multi_old_omp.cpp @@ -119,7 +119,7 @@ void NPairMultiOldOmp::build(NeighList *list) ns = nstencil_multi_old[itype]; for (k = 0; k < ns; k++) { bin_start = binhead[ibin+s[k]]; - if (s[k] == 0) { + if (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 @@ -166,7 +166,7 @@ void NPairMultiOldOmp::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil,except for i's bin - if (s[k] == 0) { + if (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) { diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp index 7999ff5029..818470254c 100644 --- a/src/OPENMP/npair_multi_omp.cpp +++ b/src/OPENMP/npair_multi_omp.cpp @@ -131,7 +131,7 @@ void NPairMultiOmp::build(NeighList *list) // own-bin for half stencil if (HALF && !TRI) - if (flag_half_multi[icollection][jcollection] && s[k] == 0) js = bins[i]; + if (k == 0 && flag_half_multi[icollection][jcollection]) js = bins[i]; for (j = js; j >= 0; j = bins[j]) { if (!HALF) { @@ -180,24 +180,22 @@ void NPairMultiOmp::build(NeighList *list) } else { // Half neighbor list, newton on, orthonormal // if same size: uses half stencil so includes a check of the central bin - if (flag_half_multi[icollection][jcollection]){ - if (s[k] == 0) { - // if same collection, - // 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 (k == 0 && flag_half_multi[icollection][jcollection]) { + // if same collection, + // 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 different collections, - // if j is owned atom, store it if j > i - // if j is ghost, only store if j coords are "above and to the right" of i + // if different collections, + // if j is owned atom, store it if j > i + // if j is ghost, only store if j coords are "above and to the right" of i - if ((icollection != jcollection) && (j < i)) continue; + if ((icollection != jcollection) && (j < i)) continue; - 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; - } + 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; } } } @@ -233,7 +231,7 @@ void NPairMultiOmp::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; @@ -256,7 +254,7 @@ void NPairMultiOmp::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; @@ -279,7 +277,7 @@ void NPairMultiOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = nlocal; diff --git a/src/OPENMP/npair_nsq_ghost_omp.cpp b/src/OPENMP/npair_nsq_ghost_omp.cpp index 6a10876497..a270fbb84d 100644 --- a/src/OPENMP/npair_nsq_ghost_omp.cpp +++ b/src/OPENMP/npair_nsq_ghost_omp.cpp @@ -172,7 +172,7 @@ void NPairNsqGhostOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = nlocal; diff --git a/src/OPENMP/npair_nsq_omp.cpp b/src/OPENMP/npair_nsq_omp.cpp index 9577964401..c482fc8f2d 100644 --- a/src/OPENMP/npair_nsq_omp.cpp +++ b/src/OPENMP/npair_nsq_omp.cpp @@ -137,9 +137,9 @@ void NPairNsqOmp::build(NeighList *list) if (j >= nlocal) { jtag = tag[j]; if (itag > jtag) { - if ((itag+jtag) % 2 == 0) continue; + if ((itag + jtag) % 2 == 0) continue; } else if (itag < jtag) { - if ((itag+jtag) % 2 == 1) continue; + if ((itag + jtag) % 2 == 1) continue; } else if (TRI) { if (fabs(x[j][2] - ztmp) > delta) { if (x[j][2] < ztmp) continue; @@ -219,7 +219,7 @@ void NPairNsqOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = nlocal; diff --git a/src/OPENMP/npair_respa_bin_omp.cpp b/src/OPENMP/npair_respa_bin_omp.cpp index b904e7136b..c958167ba0 100644 --- a/src/OPENMP/npair_respa_bin_omp.cpp +++ b/src/OPENMP/npair_respa_bin_omp.cpp @@ -88,7 +88,7 @@ void NPairRespaBinOmp::build(NeighList *list) int *numneigh_inner = list->numneigh_inner; int **firstneigh_inner = list->firstneigh_inner; - int *ilist_middle,*numneigh_middle,**firstneigh_middle; + int *ilist_middle, *numneigh_middle, **firstneigh_middle; if (respamiddle) { ilist_middle = list->ilist_middle; numneigh_middle = list->numneigh_middle; @@ -133,9 +133,9 @@ void NPairRespaBinOmp::build(NeighList *list) } for (k = 0; k < nstencil; k++) { - bin_start = binhead[ibin+stencil[k]]; + bin_start = binhead[ibin + stencil[k]]; if (NEWTON && (!TRI)) { - if (stencil[k] == 0) { + if (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]; @@ -177,7 +177,7 @@ void NPairRespaBinOmp::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil,except for i's bin - if (stencil[k] == 0) { + if (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) { @@ -242,20 +242,20 @@ void NPairRespaBinOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); ilist_inner[i] = i; firstneigh_inner[i] = neighptr_inner; numneigh_inner[i] = n_inner; ipage.vgot(n_inner); - if (ipage_inner.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_inner.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); if (respamiddle) { ilist_middle[i] = i; firstneigh_middle[i] = neighptr_middle; numneigh_middle[i] = n_middle; ipage_middle->vgot(n_middle); - if (ipage_middle->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_middle->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } } NPAIR_OMP_CLOSE; diff --git a/src/OPENMP/npair_respa_nsq_omp.cpp b/src/OPENMP/npair_respa_nsq_omp.cpp index 2c4ad5d251..6815b21544 100644 --- a/src/OPENMP/npair_respa_nsq_omp.cpp +++ b/src/OPENMP/npair_respa_nsq_omp.cpp @@ -99,7 +99,7 @@ void NPairRespaNsqOmp::build(NeighList *list) int *numneigh_inner = list->numneigh_inner; int **firstneigh_inner = list->firstneigh_inner; - int *ilist_middle,*numneigh_middle,**firstneigh_middle; + int *ilist_middle, *numneigh_middle, **firstneigh_middle; if (respamiddle) { ilist_middle = list->ilist_middle; numneigh_middle = list->numneigh_middle; @@ -222,20 +222,20 @@ void NPairRespaNsqOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); ilist_inner[i] = i; firstneigh_inner[i] = neighptr_inner; numneigh_inner[i] = n_inner; ipage.vgot(n_inner); - if (ipage_inner.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_inner.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); if (respamiddle) { ilist_middle[i] = i; firstneigh_middle[i] = neighptr_middle; numneigh_middle[i] = n_middle; ipage_middle->vgot(n_middle); - if (ipage_middle->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_middle->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } } NPAIR_OMP_CLOSE; diff --git a/src/OPENMP/npair_trim_omp.cpp b/src/OPENMP/npair_trim_omp.cpp index a4419663ff..0840c1a5f2 100644 --- a/src/OPENMP/npair_trim_omp.cpp +++ b/src/OPENMP/npair_trim_omp.cpp @@ -98,7 +98,7 @@ void NPairTrimOmp::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage.vgot(n); - if (ipage.status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage.status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } NPAIR_OMP_CLOSE; list->inum = inum_copy; diff --git a/src/npair_bin.cpp b/src/npair_bin.cpp index d72a98e471..d3d3415bc0 100644 --- a/src/npair_bin.cpp +++ b/src/npair_bin.cpp @@ -110,7 +110,7 @@ void NPairBin::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin + stencil[k]]; if (HALF && NEWTON && (!TRI)) { - if (stencil[k] == 0) { + if (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]; @@ -155,7 +155,7 @@ void NPairBin::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil, except for i's bin - if (stencil[k] == 0) { + if (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) { @@ -198,7 +198,7 @@ void NPairBin::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; @@ -221,7 +221,7 @@ void NPairBin::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; @@ -243,7 +243,7 @@ void NPairBin::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } list->inum = inum; diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index 37c6482a6a..ec5a67fa82 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -128,7 +128,7 @@ void NPairMulti::build(NeighList *list) // own-bin for half stencil if (HALF && !TRI) - if (flag_half_multi[icollection][jcollection] && s[k] == 0) js = bins[i]; + if (k == 0 && flag_half_multi[icollection][jcollection]) js = bins[i]; for (j = js; j >= 0; j = bins[j]) { if (!HALF) { @@ -177,24 +177,22 @@ void NPairMulti::build(NeighList *list) } else { // Half neighbor list, newton on, orthonormal // if same size: uses half stencil so includes a check of the central bin - if (flag_half_multi[icollection][jcollection]) { - if (s[k] == 0) { - // if same collection, - // 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 (k == 0 && flag_half_multi[icollection][jcollection]) { + // if same collection, + // 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 different collections, - // if j is owned atom, store it if j > i - // if j is ghost, only store if j coords are "above and to the right" of i + // if different collections, + // if j is owned atom, store it if j > i + // if j is ghost, only store if j coords are "above and to the right" of i - if ((icollection != jcollection) && (j < i)) continue; + if ((icollection != jcollection) && (j < i)) continue; - 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; - } + 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; } } } @@ -230,7 +228,7 @@ void NPairMulti::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; @@ -253,7 +251,7 @@ void NPairMulti::build(NeighList *list) 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], + which = find_special(onemols[imol]->special[iatom], onemols[imol]->nspecial[iatom], tag[j] - tagprev); else which = 0; @@ -276,7 +274,7 @@ void NPairMulti::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } list->inum = inum; diff --git a/src/npair_multi_old.cpp b/src/npair_multi_old.cpp index b2d77227cc..a4ca1e7361 100644 --- a/src/npair_multi_old.cpp +++ b/src/npair_multi_old.cpp @@ -113,7 +113,7 @@ void NPairMultiOld::build(NeighList *list) for (k = 0; k < ns; k++) { bin_start = binhead[ibin + s[k]]; if (HALF && NEWTON && (!TRI)) { - if (s[k] == 0) { + if (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 +159,7 @@ void NPairMultiOld::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil,except for i's bin - if (s[k] == 0) { + if (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) { @@ -236,7 +236,7 @@ void NPairMultiOld::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } list->inum = inum; diff --git a/src/npair_nsq.cpp b/src/npair_nsq.cpp index 5a7b1e3227..c2f43d9cb0 100644 --- a/src/npair_nsq.cpp +++ b/src/npair_nsq.cpp @@ -211,7 +211,7 @@ void NPairNsq::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } list->inum = inum; diff --git a/src/npair_respa_bin.cpp b/src/npair_respa_bin.cpp index 085986903d..f2fb9f7486 100644 --- a/src/npair_respa_bin.cpp +++ b/src/npair_respa_bin.cpp @@ -81,7 +81,7 @@ void NPairRespaBin::build(NeighList *list) int **firstneigh_inner = list->firstneigh_inner; MyPage *ipage_inner = list->ipage_inner; - int *ilist_middle,*numneigh_middle,**firstneigh_middle; + int *ilist_middle, *numneigh_middle, **firstneigh_middle; MyPage *ipage_middle; int respamiddle = list->respamiddle; if (respamiddle) { @@ -123,7 +123,7 @@ void NPairRespaBin::build(NeighList *list) for (k = 0; k < nstencil; k++) { bin_start = binhead[ibin+stencil[k]]; if (NEWTON && (!TRI)) { - if (stencil[k] == 0) { + if (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]; @@ -165,7 +165,7 @@ void NPairRespaBin::build(NeighList *list) // Half neighbor list, newton on, orthonormal // store every pair for every bin in stencil,except for i's bin - if (stencil[k] == 0) { + if (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) { @@ -230,20 +230,20 @@ void NPairRespaBin::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); ilist_inner[inum] = i; firstneigh_inner[i] = neighptr_inner; numneigh_inner[i] = n_inner; ipage_inner->vgot(n_inner); - if (ipage_inner->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_inner->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); if (respamiddle) { ilist_middle[inum] = i; firstneigh_middle[i] = neighptr_middle; numneigh_middle[i] = n_middle; ipage_middle->vgot(n_middle); - if (ipage_middle->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_middle->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } inum++; diff --git a/src/npair_respa_nsq.cpp b/src/npair_respa_nsq.cpp index 7f70addbc9..9ca166a491 100644 --- a/src/npair_respa_nsq.cpp +++ b/src/npair_respa_nsq.cpp @@ -92,7 +92,7 @@ void NPairRespaNsq::build(NeighList *list) int **firstneigh_inner = list->firstneigh_inner; MyPage *ipage_inner = list->ipage_inner; - int *ilist_middle,*numneigh_middle,**firstneigh_middle; + int *ilist_middle, *numneigh_middle, **firstneigh_middle; MyPage *ipage_middle; int respamiddle = list->respamiddle; if (respamiddle) { @@ -215,20 +215,20 @@ void NPairRespaNsq::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); ilist_inner[inum] = i; firstneigh_inner[i] = neighptr_inner; numneigh_inner[i] = n_inner; ipage_inner->vgot(n_inner); - if (ipage_inner->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_inner->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); if (respamiddle) { ilist_middle[inum] = i; firstneigh_middle[i] = neighptr_middle; numneigh_middle[i] = n_middle; ipage_middle->vgot(n_middle); - if (ipage_middle->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_middle->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } inum++; diff --git a/src/npair_skip_respa.cpp b/src/npair_skip_respa.cpp index ecd820e892..81cfc8a767 100644 --- a/src/npair_skip_respa.cpp +++ b/src/npair_skip_respa.cpp @@ -58,9 +58,9 @@ void NPairSkipRespa::build(NeighList *list) int *numneigh_inner_skip = list->listskip->numneigh_inner; int **firstneigh_inner_skip = list->listskip->firstneigh_inner; - int *ilist_middle,*numneigh_middle,**firstneigh_middle; + int *ilist_middle, *numneigh_middle, **firstneigh_middle; MyPage *ipage_middle; - int *numneigh_middle_skip,**firstneigh_middle_skip; + int *numneigh_middle_skip, **firstneigh_middle_skip; int respamiddle = list->respamiddle; if (respamiddle) { ilist_middle = list->ilist_middle; @@ -135,20 +135,20 @@ void NPairSkipRespa::build(NeighList *list) firstneigh[i] = neighptr; numneigh[i] = n; ipage->vgot(n); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); ilist_inner[inum] = i; firstneigh_inner[i] = neighptr_inner; numneigh_inner[i] = n_inner; ipage_inner->vgot(n); - if (ipage_inner->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_inner->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); if (respamiddle) { ilist_middle[inum] = i; firstneigh_middle[i] = neighptr_middle; numneigh_middle[i] = n_middle; ipage_middle->vgot(n); - if (ipage_middle->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage_middle->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } inum++; diff --git a/src/npair_skip_size_off2on_oneside.cpp b/src/npair_skip_size_off2on_oneside.cpp index d861a1e745..8974da35b2 100644 --- a/src/npair_skip_size_off2on_oneside.cpp +++ b/src/npair_skip_size_off2on_oneside.cpp @@ -107,7 +107,7 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) for (i = 0; i < nlocal; i++) { if (numneigh[i] == 0) continue; firstneigh[i] = ipage->get(numneigh[i]); - if (ipage->status()) error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one"); } // second loop over atoms in other list to store neighbors From 5830dec742dc5c847a72b4bb1e6c7b5fb2aea756 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 16 Oct 2023 15:09:10 -0600 Subject: [PATCH 65/87] new compute: reaxff/bonds/local --- src/REAXFF/compute_reaxff_bonds_local.cpp | 217 ++++++++++++++++++++++ src/REAXFF/compute_reaxff_bonds_local.h | 60 ++++++ 2 files changed, 277 insertions(+) create mode 100644 src/REAXFF/compute_reaxff_bonds_local.cpp create mode 100644 src/REAXFF/compute_reaxff_bonds_local.h diff --git a/src/REAXFF/compute_reaxff_bonds_local.cpp b/src/REAXFF/compute_reaxff_bonds_local.cpp new file mode 100644 index 0000000000..c32b404e86 --- /dev/null +++ b/src/REAXFF/compute_reaxff_bonds_local.cpp @@ -0,0 +1,217 @@ +// 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (LANL) +------------------------------------------------------------------------- */ + +#include "compute_reaxff_bonds_local.h" +#include "atom.h" +#include "molecule.h" +#include "update.h" +#include "force.h" +#include "memory.h" +#include "error.h" +#include "neigh_list.h" + +#include "pair_reaxff.h" +#include "reaxff_api.h" + +using namespace LAMMPS_NS; +using namespace ReaxFF; + +/* ---------------------------------------------------------------------- */ + +ComputeReaxFFBondsLocal::ComputeReaxFFBondsLocal(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + alocal(nullptr), abo(nullptr), neighid(nullptr), numneigh(nullptr), reaxff(nullptr) +{ + if (atom->tag_consecutive() == 0) + error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds/local"); + + local_flag = 1; + + nvalues = 7 + 2*MAXREAXBOND; + prev_nvalues = 0; + + // initialize output + + nlocal = atom->nlocal; + + size_local_rows = atom->nlocal; + size_local_cols = 7 + 2*MAXREAXBOND; + + allocate(nlocal); +} + + +/* ---------------------------------------------------------------------- */ + +ComputeReaxFFBondsLocal::~ComputeReaxFFBondsLocal() +{ + memory->destroy(alocal); + destroy(); +} + +void ComputeReaxFFBondsLocal::destroy() +{ + memory->destroy(abo); + memory->destroy(neighid); + memory->destroy(numneigh); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeReaxFFBondsLocal::allocate(int n) +{ + memory->create(abo,n,MAXREAXBOND,"reaxff/bonds/local:abo"); + memory->create(neighid,n,MAXREAXBOND,"reaxff/bonds/local:neighid"); + memory->create(numneigh,n,"reaxff/bonds/local:numneigh"); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeReaxFFBondsLocal::init() +{ + reaxff = dynamic_cast(force->pair_match("^reax..",0)); + if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/bonds/local without " + "pair_style reaxff, reaxff/kk, or reaxff/omp"); +} + +/* ---------------------------------------------------------------------- */ + +int ComputeReaxFFBondsLocal::FindBond() +{ + int *ilist, i, ii, inum; + int j, pj, nj; + tagint jtag; + double bo_tmp,bo_cut; + + inum = reaxff->list->inum; + ilist = reaxff->list->ilist; + bond_data *bo_ij; + bo_cut = reaxff->api->control->bg_cut; + + tagint *tag = atom->tag; + int numbonds = 0; + + for (ii = 0; ii < inum; ii++) { + i = ilist[ii]; + nj = 0; + + for (pj = Start_Index(i, reaxff->api->lists); pj < End_Index(i, reaxff->api->lists); ++pj) { + bo_ij = &(reaxff->api->lists->select.bond_list[pj]); + j = bo_ij->nbr; + jtag = tag[j]; + bo_tmp = bo_ij->bo_data.BO; + + if (bo_tmp > bo_cut) { + neighid[i][nj] = jtag; + abo[i][nj] = bo_tmp; + nj ++; + } + } + numneigh[i] = nj; + if (nj > numbonds) numbonds = nj; + } + return numbonds; +} + +/* ---------------------------------------------------------------------- */ + +void ComputeReaxFFBondsLocal::compute_local() +{ + invoked_local = update->ntimestep; + + // count local entries and compute bond info + if (atom->nlocal > nlocal) { + destroy(); + allocate(atom->nlocal); + } + + { + const int nlocal = atom->nlocal; + + for (int i = 0; i < nlocal; i++) { + numneigh[i] = 0; + for (int j = 0; j < MAXREAXBOND; j++) { + neighid[i][j] = 0; + abo[i][j] = 0.0; + } + } + } + + int maxnumbonds = FindBond(); + nvalues = 7+2*maxnumbonds; + + if(atom->nlocal > nlocal || nvalues > prev_nvalues) { + reallocate(); + } + + size_local_rows = nlocal; + size_local_cols = nvalues; + + for (int i = 0; i < nlocal; ++i) { + auto ptr = alocal[i]; + int numbonds = numneigh[i]; + ptr[0] = atom->tag[i]; + ptr[1] = atom->type[i]; + ptr[2] = numbonds; + + int j = 3; + + for (int k = 0; k < numbonds; k++) { + ptr[j++] = neighid[i][k]; + } + + ptr[j++] = (atom->molecule == nullptr) ? 0.0 : atom->molecule[i]; + + for (int k = 0; k < numbonds; k++) { + ptr[j++] = abo[i][k]; + } + + ptr[j++] = reaxff->api->workspace->total_bond_order[i]; + ptr[j++] = reaxff->api->workspace->nlp[i]; + ptr[j++] = atom->q[i]; + + // clear any remaining + for(; j < nvalues; ++j) { + ptr[j] = 0.0; + } + } +} + +void ComputeReaxFFBondsLocal::reallocate() +{ + nlocal = atom->nlocal; + + // grow array_local + memory->destroy(alocal); + memory->create(alocal,nlocal,nvalues,"reaxff/bonds/local:array_local"); + array_local = alocal; + + prev_nvalues = nvalues; +} + +/* ---------------------------------------------------------------------- + memory usage of local data +------------------------------------------------------------------------- */ + +double ComputeReaxFFBondsLocal::memory_usage() +{ + double bytes = (double)nlocal*nvalues * sizeof(double); + bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); + bytes += (double)(nlocal) * sizeof(int); + return bytes; +} diff --git a/src/REAXFF/compute_reaxff_bonds_local.h b/src/REAXFF/compute_reaxff_bonds_local.h new file mode 100644 index 0000000000..2347db3a26 --- /dev/null +++ b/src/REAXFF/compute_reaxff_bonds_local.h @@ -0,0 +1,60 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (LANL) +------------------------------------------------------------------------- */ + +#ifdef COMPUTE_CLASS +// clang-format off +ComputeStyle(reaxff/bonds/local,ComputeReaxFFBondsLocal); +// clang-format on +#else + +#ifndef LMP_COMPUTE_REAXFF_BONDS_LOCAL_H +#define LMP_COMPUTE_REAXFF_BONDS_LOCAL_H + +#include "compute.h" + +namespace LAMMPS_NS { + +class ComputeReaxFFBondsLocal : public Compute { + public: + ComputeReaxFFBondsLocal(class LAMMPS *, int, char **); + ~ComputeReaxFFBondsLocal() override; + void init() override; + void compute_local() override; + double memory_usage() override; + + private: + int nlocal; + int nvalues; + int prev_nvalues; + + double **alocal; + tagint **neighid; + double **abo; + int *numneigh; + class PairReaxFF *reaxff; + + int FindBond(); + + void allocate(int); + void destroy(); + void reallocate(); +}; + +} // namespace LAMMPS_NS + +#endif +#endif From bbc2794df29920bc1673ac0501518669fcfb822d Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 16 Oct 2023 15:09:16 -0600 Subject: [PATCH 66/87] add reaxff/bonds/local/kk --- .../compute_reaxff_bonds_local_kokkos.cpp | 125 ++++++++++++++++++ .../compute_reaxff_bonds_local_kokkos.h | 68 ++++++++++ src/KOKKOS/pair_reaxff_kokkos.cpp | 55 ++++++++ src/KOKKOS/pair_reaxff_kokkos.h | 19 +++ 4 files changed, 267 insertions(+) create mode 100644 src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp create mode 100644 src/KOKKOS/compute_reaxff_bonds_local_kokkos.h diff --git a/src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp b/src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp new file mode 100644 index 0000000000..a56d243ed6 --- /dev/null +++ b/src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp @@ -0,0 +1,125 @@ +// 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (LANL) +------------------------------------------------------------------------- */ + +#include "compute_reaxff_bonds_local_kokkos.h" +#include "atom.h" +#include "molecule.h" +#include "update.h" +#include "force.h" +#include "memory.h" +#include "error.h" +#include "neigh_list.h" + +#include "memory_kokkos.h" +#include "pair_reaxff_kokkos.h" +#include "reaxff_api.h" + +using namespace LAMMPS_NS; +using namespace ReaxFF; + +/* ---------------------------------------------------------------------- */ + +template +ComputeReaxFFBondsLocalKokkos::ComputeReaxFFBondsLocalKokkos(LAMMPS *lmp, int narg, char **arg) : + Compute(lmp, narg, arg), + alocal(nullptr), reaxff(nullptr) +{ + if (atom->tag_consecutive() == 0) + error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds/local"); + + local_flag = 1; + + nvalues = 7 + 2*MAXREAXBOND; + prev_nvalues = 0; + + // initialize output + + nlocal = atom->nlocal; + + size_local_rows = atom->nlocal; + size_local_cols = 7 + 2*MAXREAXBOND; + printf("RUNNING KOKKOS VERSION\n"); +} + + +/* ---------------------------------------------------------------------- */ + +template +ComputeReaxFFBondsLocalKokkos::~ComputeReaxFFBondsLocalKokkos() +{ + memoryKK->destroy_kokkos(k_alocal, alocal); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeReaxFFBondsLocalKokkos::init() +{ + reaxff = dynamic_cast(force->pair_match("^reax../kk",0)); + if (reaxff == nullptr) error->all(FLERR,"Cannot use fix reaxff/bonds without " + "pair_style reaxff/kk"); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeReaxFFBondsLocalKokkos::compute_local() +{ + invoked_local = update->ntimestep; + + int maxnumbonds = 0; + if (reaxff->execution_space == Device) + device_pair()->FindBond(maxnumbonds); + else + host_pair()->FindBond(maxnumbonds); + nvalues = 7+2*maxnumbonds; + + if(atom->nlocal > nlocal || nvalues > prev_nvalues) { + nlocal = atom->nlocal; + memoryKK->destroy_kokkos(k_alocal, alocal); + memoryKK->create_kokkos(k_alocal, alocal, atom->nlocal, nvalues,"reaxff/bonds/local:alocal"); + prev_nvalues = nvalues; + array_local = alocal; + } + + size_local_rows = nlocal; + size_local_cols = nvalues; + + if (reaxff->execution_space == Device) + device_pair()->PackBondInfo(k_alocal); + else + host_pair()->PackBondInfo(k_alocal); +} + +/* ---------------------------------------------------------------------- + memory usage of local data +------------------------------------------------------------------------- */ + +template +double ComputeReaxFFBondsLocalKokkos::memory_usage() +{ + double bytes = (double)nlocal*nvalues * sizeof(double); + return bytes; +} + +namespace LAMMPS_NS { +template class ComputeReaxFFBondsLocalKokkos; +#ifdef LMP_KOKKOS_GPU +template class ComputeReaxFFBondsLocalKokkos; +#endif +} diff --git a/src/KOKKOS/compute_reaxff_bonds_local_kokkos.h b/src/KOKKOS/compute_reaxff_bonds_local_kokkos.h new file mode 100644 index 0000000000..bfb5521199 --- /dev/null +++ b/src/KOKKOS/compute_reaxff_bonds_local_kokkos.h @@ -0,0 +1,68 @@ +/* -*- 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (LANL) +------------------------------------------------------------------------- */ + +#ifdef COMPUTE_CLASS +// clang-format off +ComputeStyle(reaxff/bonds/local/kk,ComputeReaxFFBondsLocalKokkos); +ComputeStyle(reaxff/bonds/local/kk/device,ComputeReaxFFBondsLocalKokkos); +ComputeStyle(reaxff/bonds/local/kk/host,ComputeReaxFFBondsLocalKokkos); +// clang-format on +#else + +#ifndef LMP_COMPUTE_REAXFF_BONDS_LOCAL_KOKKOS_H +#define LMP_COMPUTE_REAXFF_BONDS_LOCAL_KOKKOS_H + +#include "compute_reaxff_bonds_local.h" +#include "pair_reaxff_kokkos.h" +#include "kokkos_type.h" + +namespace LAMMPS_NS { + +template +class ComputeReaxFFBondsLocalKokkos : public Compute { + public: + using device_type = DeviceType; + using AT = ArrayTypes; + + ComputeReaxFFBondsLocalKokkos(class LAMMPS *, int, char **); + ~ComputeReaxFFBondsLocalKokkos() override; + void init() override; + void compute_local() override; + double memory_usage() override; + + private: + int nlocal; + int nvalues; + int prev_nvalues; + + double **alocal; + typename AT::tdual_float_2d k_alocal; + PairReaxFF *reaxff; + + auto device_pair() { + return dynamic_cast*>(reaxff); + } + + auto host_pair() { + return dynamic_cast*>(reaxff); + } +}; + +} // namespace LAMMPS_NS + +#endif +#endif diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index c7d54b80cd..fbf90f140d 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4290,6 +4290,61 @@ void PairReaxFFKokkos::pack_bond_buffer_item(int i, int &j, const bo /* ---------------------------------------------------------------------- */ +template +void PairReaxFFKokkos::PackBondInfo(DAT::tdual_float_2d k_alocal) +{ + d_alocal = k_alocal.view(); + k_params_sing.template sync(); + atomKK->sync(execution_space,TAG_MASK|TYPE_MASK|Q_MASK|MOLECULE_MASK); + + tag = atomKK->k_tag.view(); + type = atomKK->k_type.view(); + q = atomKK->k_q.view(); + if (atom->molecule) + molecule = atomKK->k_molecule.view(); + + copymode = 1; + nlocal = atomKK->nlocal; + PairReaxKokkosPackBondInfoFunctor pack_bond_info_functor(this); + Kokkos::parallel_for(nlocal, pack_bond_info_functor); + copymode = 0; + + k_alocal.modify(); + k_alocal.sync(); +} + +template +KOKKOS_INLINE_FUNCTION +void PairReaxFFKokkos::pack_bond_info_item(const int i) const +{ + const int numbonds = d_numneigh_bonds[i]; + d_alocal(i,0) = tag[i]; + d_alocal(i,1) = type[i]; + d_alocal(i,2) = numbonds; + + int j = 3; + + for (int k = 0; k < numbonds; k++) { + d_alocal(i,j++) = d_neighid(i,k); + } + + d_alocal(i,j++) = molecule.data() ? molecule[i] : 0.0; + + for (int k = 0; k < numbonds; k++) { + d_alocal(i,j++) = d_abo(i,k); + } + + d_alocal(i,j++) = d_total_bo[i]; + d_alocal(i,j++) = paramssing(type[i]).nlp_opt - d_Delta_lp[i]; + d_alocal(i,j++) = q[i]; + + for(; j < d_alocal.extent(1); ++j) { + d_alocal(i,j) = 0.0; + } +} + +/* ---------------------------------------------------------------------- */ + template void PairReaxFFKokkos::FindBondSpecies() { diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 1ad0955a1e..32007e9970 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -135,6 +135,7 @@ class PairReaxFFKokkos : public PairReaxFF { double memory_usage(); void FindBond(int &); void PackBondBuffer(DAT::tdual_ffloat_1d, int &); + void PackBondInfo(DAT::tdual_float_2d); void FindBondSpecies(); template @@ -292,6 +293,9 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void pack_bond_buffer_item(int, int&, const bool&) const; + KOKKOS_INLINE_FUNCTION + void pack_bond_info_item(const int) const; + KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxFindBondSpeciesZero, const int&) const; @@ -506,6 +510,8 @@ class PairReaxFFKokkos : public PairReaxFF { typename AT::t_ffloat_1d d_buf; DAT::tdual_int_scalar k_nbuf_local; + typename AT::t_float_2d d_alocal; + typedef Kokkos::View t_reax_int4_2d; t_reax_int4_2d d_angular_pack, d_torsion_pack; @@ -549,6 +555,19 @@ struct PairReaxKokkosPackBondBufferFunctor { } }; +template +struct PairReaxKokkosPackBondInfoFunctor { + using device_type = DeviceType; + using value_type = int; + PairReaxFFKokkos c; + PairReaxKokkosPackBondInfoFunctor(PairReaxFFKokkos* c_ptr):c(*c_ptr) {}; + + KOKKOS_INLINE_FUNCTION + void operator()(const int i) const { + c.pack_bond_info_item(i); + } +}; + } #endif From fea5f5a2438d5ef1c563e945783f93a9560a18f4 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 16 Oct 2023 16:52:34 -0600 Subject: [PATCH 67/87] First serial version of Steve's suggestion --- examples/reaxff/in.reaxff.tatb | 9 +- ...nds_local.cpp => compute_reaxff_bonds.cpp} | 174 +++++++++--------- ...f_bonds_local.h => compute_reaxff_bonds.h} | 27 ++- 3 files changed, 107 insertions(+), 103 deletions(-) rename src/REAXFF/{compute_reaxff_bonds_local.cpp => compute_reaxff_bonds.cpp} (57%) rename src/REAXFF/{compute_reaxff_bonds_local.h => compute_reaxff_bonds.h} (73%) diff --git a/examples/reaxff/in.reaxff.tatb b/examples/reaxff/in.reaxff.tatb index 6cf7828cf1..fd0d846154 100644 --- a/examples/reaxff/in.reaxff.tatb +++ b/examples/reaxff/in.reaxff.tatb @@ -31,8 +31,15 @@ neigh_modify delay 0 every 5 check no fix 1 all nve fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff fix 4 all reaxff/bonds 5 bonds.reaxff +compute bonds all reaxff/bonds variable nqeq equal f_2 +# dumps out the local bond information +dump 1 all local 5 bonds_compute.reaxff c_bonds[1] c_bonds[2] c_bonds[3] + +# dumps out the peratom bond information +dump 2 all custom 5 bonds_atom.reaxff c_bonds[*] + thermo 5 thermo_style custom step temp epair etotal press & v_eb v_ea v_elp v_emol v_ev v_epen v_ecoa & @@ -50,6 +57,6 @@ timestep 0.0625 # axes yes 0.8 0.02 view 60 -30 #dump_modify 3 pad 3 -fix 3 all reaxff/species 1 5 5 species.tatb +#fix 3 all reaxff/species 1 5 5 species.tatb run 25 diff --git a/src/REAXFF/compute_reaxff_bonds_local.cpp b/src/REAXFF/compute_reaxff_bonds.cpp similarity index 57% rename from src/REAXFF/compute_reaxff_bonds_local.cpp rename to src/REAXFF/compute_reaxff_bonds.cpp index c32b404e86..7f1605263c 100644 --- a/src/REAXFF/compute_reaxff_bonds_local.cpp +++ b/src/REAXFF/compute_reaxff_bonds.cpp @@ -16,7 +16,7 @@ Contributing author: Richard Berger (LANL) ------------------------------------------------------------------------- */ -#include "compute_reaxff_bonds_local.h" +#include "compute_reaxff_bonds.h" #include "atom.h" #include "molecule.h" #include "update.h" @@ -33,39 +33,36 @@ using namespace ReaxFF; /* ---------------------------------------------------------------------- */ -ComputeReaxFFBondsLocal::ComputeReaxFFBondsLocal(LAMMPS *lmp, int narg, char **arg) : +ComputeReaxFFBonds::ComputeReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - alocal(nullptr), abo(nullptr), neighid(nullptr), numneigh(nullptr), reaxff(nullptr) + abo(nullptr), neighid(nullptr), numneigh(nullptr), reaxff(nullptr) { if (atom->tag_consecutive() == 0) - error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds/local"); + error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds"); local_flag = 1; - - nvalues = 7 + 2*MAXREAXBOND; - prev_nvalues = 0; + peratom_flag = 1; // initialize output - nlocal = atom->nlocal; + nlocal = -1; + prev_nbonds = -1; - size_local_rows = atom->nlocal; - size_local_cols = 7 + 2*MAXREAXBOND; + size_peratom_cols = 7; - allocate(nlocal); + size_local_rows = 0; + size_local_cols = 3; + + invoked_bonds = -1; } /* ---------------------------------------------------------------------- */ -ComputeReaxFFBondsLocal::~ComputeReaxFFBondsLocal() -{ - memory->destroy(alocal); - destroy(); -} - -void ComputeReaxFFBondsLocal::destroy() +ComputeReaxFFBonds::~ComputeReaxFFBonds() { + memory->destroy(array_local); + memory->destroy(array_atom); memory->destroy(abo); memory->destroy(neighid); memory->destroy(numneigh); @@ -73,25 +70,16 @@ void ComputeReaxFFBondsLocal::destroy() /* ---------------------------------------------------------------------- */ -void ComputeReaxFFBondsLocal::allocate(int n) -{ - memory->create(abo,n,MAXREAXBOND,"reaxff/bonds/local:abo"); - memory->create(neighid,n,MAXREAXBOND,"reaxff/bonds/local:neighid"); - memory->create(numneigh,n,"reaxff/bonds/local:numneigh"); -} - -/* ---------------------------------------------------------------------- */ - -void ComputeReaxFFBondsLocal::init() +void ComputeReaxFFBonds::init() { reaxff = dynamic_cast(force->pair_match("^reax..",0)); - if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/bonds/local without " - "pair_style reaxff, reaxff/kk, or reaxff/omp"); + if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/bonds without " + "pair_style reaxff, reaxff/kk, or reaxff/omp"); } /* ---------------------------------------------------------------------- */ -int ComputeReaxFFBondsLocal::FindBond() +int ComputeReaxFFBonds::FindBond() { int *ilist, i, ii, inum; int j, pj, nj; @@ -119,98 +107,108 @@ int ComputeReaxFFBondsLocal::FindBond() if (bo_tmp > bo_cut) { neighid[i][nj] = jtag; abo[i][nj] = bo_tmp; - nj ++; + nj++; } } numneigh[i] = nj; - if (nj > numbonds) numbonds = nj; + numbonds += nj; } return numbonds; } + /* ---------------------------------------------------------------------- */ -void ComputeReaxFFBondsLocal::compute_local() +void ComputeReaxFFBonds::compute_bonds() +{ + invoked_bonds = update->ntimestep; + + if (atom->nlocal > nlocal) { + memory->destroy(abo); + memory->destroy(neighid); + memory->destroy(numneigh); + memory->destroy(array_atom); + nlocal = atom->nlocal; + memory->create(abo, nlocal, MAXREAXBOND, "reaxff/bonds:abo"); + memory->create(neighid, nlocal, MAXREAXBOND, "reaxff/bonds:neighid"); + memory->create(numneigh, nlocal, "reaxff/bonds:numneigh"); + memory->create(array_atom, nlocal, 7, "reaxff/bonds:array_atom"); + } + + for (int i = 0; i < nlocal; i++) { + numneigh[i] = 0; + for (int j = 0; j < MAXREAXBOND; j++) { + neighid[i][j] = 0; + abo[i][j] = 0.0; + } + } + + nbonds = FindBond(); +} + +/* ---------------------------------------------------------------------- */ + +void ComputeReaxFFBonds::compute_local() { invoked_local = update->ntimestep; - // count local entries and compute bond info - if (atom->nlocal > nlocal) { - destroy(); - allocate(atom->nlocal); + if(invoked_bonds < update->ntimestep) { + compute_bonds(); } - { - const int nlocal = atom->nlocal; - - for (int i = 0; i < nlocal; i++) { - numneigh[i] = 0; - for (int j = 0; j < MAXREAXBOND; j++) { - neighid[i][j] = 0; - abo[i][j] = 0.0; - } - } + if(nbonds > prev_nbonds) { + // grow array_local + memory->destroy(array_local); + memory->create(array_local, nbonds, 3, "reaxff/bonds:array_local"); + prev_nbonds = nbonds; } - int maxnumbonds = FindBond(); - nvalues = 7+2*maxnumbonds; + size_local_rows = nbonds; - if(atom->nlocal > nlocal || nvalues > prev_nvalues) { - reallocate(); - } - - size_local_rows = nlocal; - size_local_cols = nvalues; + int b = 0; for (int i = 0; i < nlocal; ++i) { - auto ptr = alocal[i]; - int numbonds = numneigh[i]; - ptr[0] = atom->tag[i]; - ptr[1] = atom->type[i]; - ptr[2] = numbonds; - - int j = 3; + const int numbonds = numneigh[i]; for (int k = 0; k < numbonds; k++) { - ptr[j++] = neighid[i][k]; - } - - ptr[j++] = (atom->molecule == nullptr) ? 0.0 : atom->molecule[i]; - - for (int k = 0; k < numbonds; k++) { - ptr[j++] = abo[i][k]; - } - - ptr[j++] = reaxff->api->workspace->total_bond_order[i]; - ptr[j++] = reaxff->api->workspace->nlp[i]; - ptr[j++] = atom->q[i]; - - // clear any remaining - for(; j < nvalues; ++j) { - ptr[j] = 0.0; + auto bond = array_local[b++]; + bond[0] = i; + bond[1] = neighid[i][k]; + bond[2] = abo[i][k]; } } } -void ComputeReaxFFBondsLocal::reallocate() +/* ---------------------------------------------------------------------- */ + +void ComputeReaxFFBonds::compute_peratom() { - nlocal = atom->nlocal; + invoked_peratom = update->ntimestep; - // grow array_local - memory->destroy(alocal); - memory->create(alocal,nlocal,nvalues,"reaxff/bonds/local:array_local"); - array_local = alocal; + if(invoked_bonds < update->ntimestep) { + compute_bonds(); + } - prev_nvalues = nvalues; + for (int i = 0; i < nlocal; ++i) { + auto ptr = array_atom[i]; + ptr[0] = atom->tag[i]; + ptr[1] = atom->type[i]; + ptr[2] = numneigh[i]; + ptr[3] = (atom->molecule == nullptr) ? 0.0 : atom->molecule[i]; + ptr[4] = reaxff->api->workspace->total_bond_order[i]; + ptr[5] = reaxff->api->workspace->nlp[i]; + ptr[6] = atom->q[i]; + } } /* ---------------------------------------------------------------------- memory usage of local data ------------------------------------------------------------------------- */ -double ComputeReaxFFBondsLocal::memory_usage() +double ComputeReaxFFBonds::memory_usage() { - double bytes = (double)nlocal*nvalues * sizeof(double); + double bytes = (double)(nbonds*3) * sizeof(double); + bytes += (double)(nlocal*7) * sizeof(double); bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); bytes += (double)(nlocal) * sizeof(int); return bytes; diff --git a/src/REAXFF/compute_reaxff_bonds_local.h b/src/REAXFF/compute_reaxff_bonds.h similarity index 73% rename from src/REAXFF/compute_reaxff_bonds_local.h rename to src/REAXFF/compute_reaxff_bonds.h index 2347db3a26..6b00cef7ed 100644 --- a/src/REAXFF/compute_reaxff_bonds_local.h +++ b/src/REAXFF/compute_reaxff_bonds.h @@ -17,41 +17,40 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(reaxff/bonds/local,ComputeReaxFFBondsLocal); +ComputeStyle(reaxff/bonds,ComputeReaxFFBonds); // clang-format on #else -#ifndef LMP_COMPUTE_REAXFF_BONDS_LOCAL_H -#define LMP_COMPUTE_REAXFF_BONDS_LOCAL_H +#ifndef LMP_COMPUTE_REAXFF_BONDS_H +#define LMP_COMPUTE_REAXFF_BONDS_H #include "compute.h" namespace LAMMPS_NS { -class ComputeReaxFFBondsLocal : public Compute { +class ComputeReaxFFBonds : public Compute { public: - ComputeReaxFFBondsLocal(class LAMMPS *, int, char **); - ~ComputeReaxFFBondsLocal() override; + ComputeReaxFFBonds(class LAMMPS *, int, char **); + ~ComputeReaxFFBonds() override; void init() override; void compute_local() override; + void compute_peratom() override; + virtual void compute_bonds(); double memory_usage() override; - private: + protected: + bigint invoked_bonds; // last timestep on which compute_bonds() was invoked int nlocal; - int nvalues; - int prev_nvalues; + int nbonds; + int prev_nbonds; - double **alocal; tagint **neighid; double **abo; int *numneigh; class PairReaxFF *reaxff; + private: int FindBond(); - - void allocate(int); - void destroy(); - void reallocate(); }; } // namespace LAMMPS_NS From a72a3ed50d12365ebb41a02001454fe667036b23 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 17 Oct 2023 16:24:14 -0600 Subject: [PATCH 68/87] Kokkos version of compute reaxff/bonds --- src/KOKKOS/compute_reaxff_bonds_kokkos.cpp | 192 ++++++++++++++++++ ...kokkos.h => compute_reaxff_bonds_kokkos.h} | 30 ++- .../compute_reaxff_bonds_local_kokkos.cpp | 125 ------------ src/KOKKOS/pair_reaxff_kokkos.cpp | 55 ----- src/KOKKOS/pair_reaxff_kokkos.h | 19 -- 5 files changed, 206 insertions(+), 215 deletions(-) create mode 100644 src/KOKKOS/compute_reaxff_bonds_kokkos.cpp rename src/KOKKOS/{compute_reaxff_bonds_local_kokkos.h => compute_reaxff_bonds_kokkos.h} (67%) delete mode 100644 src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp diff --git a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp b/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp new file mode 100644 index 0000000000..921acb9193 --- /dev/null +++ b/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp @@ -0,0 +1,192 @@ +// 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. +------------------------------------------------------------------------- */ + +/* ---------------------------------------------------------------------- + Contributing author: Richard Berger (LANL) +------------------------------------------------------------------------- */ + +#include "compute_reaxff_bonds_kokkos.h" +#include "atom.h" +#include "molecule.h" +#include "update.h" +#include "force.h" +#include "memory.h" +#include "error.h" +#include "neigh_list.h" + +#include "memory_kokkos.h" +#include "pair_reaxff_kokkos.h" +#include "reaxff_api.h" + +using namespace LAMMPS_NS; +using namespace ReaxFF; + +/* ---------------------------------------------------------------------- */ + +template +ComputeReaxFFBondsKokkos::ComputeReaxFFBondsKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputeReaxFFBonds(lmp, narg, arg), + nbuf(-1), buf(nullptr) +{ +} + + +/* ---------------------------------------------------------------------- */ + +template +ComputeReaxFFBondsKokkos::~ComputeReaxFFBondsKokkos() +{ + memoryKK->destroy_kokkos(k_buf, buf); +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeReaxFFBondsKokkos::init() +{ + reaxff = dynamic_cast(force->pair_match("^reax../kk",0)); + if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/bonds without " + "pair_style reaxff/kk"); +} + +/* ---------------------------------------------------------------------- */ +template +void ComputeReaxFFBondsKokkos::compute_bonds() +{ + if (atom->nlocal > nlocal) { + memory->destroy(array_atom); + nlocal = atom->nlocal; + memory->create(array_atom, nlocal, 7, "reaxff/bonds:array_atom"); + } + + // retrieve bond information from kokkos pair style. the data potentially + // lives on device. it is copied into buf on the host in a condensed format + // compute_local and compute_atom then expand the data from this buffer into + // appropiate arrays for consumption by others (e.g. dump local, dump custom + // or library interface) + int maxnumbonds = 0; + if (reaxff->execution_space == Device) + device_pair()->FindBond(maxnumbonds); + else + host_pair()->FindBond(maxnumbonds); + + nbuf = 1+(maxnumbonds*2 + 7)*nlocal; + + if(!buf || k_buf.extent(0) < nbuf) { + memoryKK->destroy_kokkos(k_buf, buf); + memoryKK->create_kokkos(k_buf, buf, nbuf, "reaxff/bonds:buf"); + } + + // Pass information to buffer, will sync to host + int nbuf_local; + if (reaxff->execution_space == Device) + device_pair()->PackBondBuffer(k_buf, nbuf_local); + else + host_pair()->PackBondBuffer(k_buf, nbuf_local); + buf[0] = nlocal; + + // Extract number of bonds from buffer + nbonds = 0; + int j = 1; + for (int i = 0; i < nlocal; i++) { + int numbonds = static_cast(buf[j+5]); + nbonds += numbonds; + j += 2*numbonds + 7; + } +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeReaxFFBondsKokkos::compute_local() +{ + invoked_local = update->ntimestep; + + if(invoked_bonds < update->ntimestep) { + compute_bonds(); + } + + if(nbonds > prev_nbonds) { + // grow array_local + memory->destroy(array_local); + memory->create(array_local, nbonds, 3, "reaxff/bonds:array_local"); + prev_nbonds = nbonds; + } + + size_local_rows = nbonds; + + // extract local bond information from buffer + int b = 0; + int j = 1; + + for (int i = 0; i < nlocal; ++i) { + const int numbonds = static_cast(buf[j+5]); + const int neigh_offset = j + 6; + const int bo_offset = neigh_offset + numbonds + 1; + for (int k = 0; k < numbonds; k++) { + auto bond = array_local[b++]; + bond[0] = i; + bond[1] = static_cast (buf[neigh_offset+k]); + bond[2] = buf[bo_offset+k]; + } + j += 2*numbonds + 7; + } +} + +/* ---------------------------------------------------------------------- */ + +template +void ComputeReaxFFBondsKokkos::compute_peratom() +{ + invoked_peratom = update->ntimestep; + + if(invoked_bonds < update->ntimestep) { + compute_bonds(); + } + + // extract peratom bond information from buffer + int j = 1; + for (int i = 0; i < nlocal; ++i) { + auto ptr = array_atom[i]; + int numbonds = static_cast(buf[j+5]); + const int mol_offset = j + 6 + numbonds; + ptr[0] = buf[j]; // jtag + ptr[1] = buf[j+1]; // itype + ptr[2] = numbonds; + ptr[3] = buf[mol_offset]; // mol + ptr[4] = buf[j+2]; // sbo + ptr[5] = buf[j+3]; // nlp + ptr[6] = buf[j+4]; // q + j += 2*numbonds + 7; + } +} + +/* ---------------------------------------------------------------------- + memory usage of local data +------------------------------------------------------------------------- */ + +template +double ComputeReaxFFBondsKokkos::memory_usage() +{ + double bytes = (double)(nbonds*3) * sizeof(double); + bytes += (double)(nlocal*7) * sizeof(double); + return bytes; +} + +namespace LAMMPS_NS { +template class ComputeReaxFFBondsKokkos; +#ifdef LMP_KOKKOS_GPU +template class ComputeReaxFFBondsKokkos; +#endif +} diff --git a/src/KOKKOS/compute_reaxff_bonds_local_kokkos.h b/src/KOKKOS/compute_reaxff_bonds_kokkos.h similarity index 67% rename from src/KOKKOS/compute_reaxff_bonds_local_kokkos.h rename to src/KOKKOS/compute_reaxff_bonds_kokkos.h index bfb5521199..45020ffa81 100644 --- a/src/KOKKOS/compute_reaxff_bonds_local_kokkos.h +++ b/src/KOKKOS/compute_reaxff_bonds_kokkos.h @@ -17,41 +17,39 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(reaxff/bonds/local/kk,ComputeReaxFFBondsLocalKokkos); -ComputeStyle(reaxff/bonds/local/kk/device,ComputeReaxFFBondsLocalKokkos); -ComputeStyle(reaxff/bonds/local/kk/host,ComputeReaxFFBondsLocalKokkos); +ComputeStyle(reaxff/bonds/kk,ComputeReaxFFBondsKokkos); +ComputeStyle(reaxff/bonds/kk/device,ComputeReaxFFBondsKokkos); +ComputeStyle(reaxff/bonds/kk/host,ComputeReaxFFBondsKokkos); // clang-format on #else -#ifndef LMP_COMPUTE_REAXFF_BONDS_LOCAL_KOKKOS_H -#define LMP_COMPUTE_REAXFF_BONDS_LOCAL_KOKKOS_H +#ifndef LMP_COMPUTE_REAXFF_BONDS_KOKKOS_H +#define LMP_COMPUTE_REAXFF_BONDS_KOKKOS_H -#include "compute_reaxff_bonds_local.h" +#include "compute_reaxff_bonds.h" #include "pair_reaxff_kokkos.h" #include "kokkos_type.h" namespace LAMMPS_NS { template -class ComputeReaxFFBondsLocalKokkos : public Compute { +class ComputeReaxFFBondsKokkos : public ComputeReaxFFBonds { public: using device_type = DeviceType; using AT = ArrayTypes; - ComputeReaxFFBondsLocalKokkos(class LAMMPS *, int, char **); - ~ComputeReaxFFBondsLocalKokkos() override; + ComputeReaxFFBondsKokkos(class LAMMPS *, int, char **); + ~ComputeReaxFFBondsKokkos() override; void init() override; void compute_local() override; + void compute_peratom() override; + void compute_bonds() override; double memory_usage() override; private: - int nlocal; - int nvalues; - int prev_nvalues; - - double **alocal; - typename AT::tdual_float_2d k_alocal; - PairReaxFF *reaxff; + int nbuf; + double *buf; + typename AT::tdual_float_1d k_buf; auto device_pair() { return dynamic_cast*>(reaxff); diff --git a/src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp b/src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp deleted file mode 100644 index a56d243ed6..0000000000 --- a/src/KOKKOS/compute_reaxff_bonds_local_kokkos.cpp +++ /dev/null @@ -1,125 +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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Richard Berger (LANL) -------------------------------------------------------------------------- */ - -#include "compute_reaxff_bonds_local_kokkos.h" -#include "atom.h" -#include "molecule.h" -#include "update.h" -#include "force.h" -#include "memory.h" -#include "error.h" -#include "neigh_list.h" - -#include "memory_kokkos.h" -#include "pair_reaxff_kokkos.h" -#include "reaxff_api.h" - -using namespace LAMMPS_NS; -using namespace ReaxFF; - -/* ---------------------------------------------------------------------- */ - -template -ComputeReaxFFBondsLocalKokkos::ComputeReaxFFBondsLocalKokkos(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - alocal(nullptr), reaxff(nullptr) -{ - if (atom->tag_consecutive() == 0) - error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds/local"); - - local_flag = 1; - - nvalues = 7 + 2*MAXREAXBOND; - prev_nvalues = 0; - - // initialize output - - nlocal = atom->nlocal; - - size_local_rows = atom->nlocal; - size_local_cols = 7 + 2*MAXREAXBOND; - printf("RUNNING KOKKOS VERSION\n"); -} - - -/* ---------------------------------------------------------------------- */ - -template -ComputeReaxFFBondsLocalKokkos::~ComputeReaxFFBondsLocalKokkos() -{ - memoryKK->destroy_kokkos(k_alocal, alocal); -} - -/* ---------------------------------------------------------------------- */ - -template -void ComputeReaxFFBondsLocalKokkos::init() -{ - reaxff = dynamic_cast(force->pair_match("^reax../kk",0)); - if (reaxff == nullptr) error->all(FLERR,"Cannot use fix reaxff/bonds without " - "pair_style reaxff/kk"); -} - -/* ---------------------------------------------------------------------- */ - -template -void ComputeReaxFFBondsLocalKokkos::compute_local() -{ - invoked_local = update->ntimestep; - - int maxnumbonds = 0; - if (reaxff->execution_space == Device) - device_pair()->FindBond(maxnumbonds); - else - host_pair()->FindBond(maxnumbonds); - nvalues = 7+2*maxnumbonds; - - if(atom->nlocal > nlocal || nvalues > prev_nvalues) { - nlocal = atom->nlocal; - memoryKK->destroy_kokkos(k_alocal, alocal); - memoryKK->create_kokkos(k_alocal, alocal, atom->nlocal, nvalues,"reaxff/bonds/local:alocal"); - prev_nvalues = nvalues; - array_local = alocal; - } - - size_local_rows = nlocal; - size_local_cols = nvalues; - - if (reaxff->execution_space == Device) - device_pair()->PackBondInfo(k_alocal); - else - host_pair()->PackBondInfo(k_alocal); -} - -/* ---------------------------------------------------------------------- - memory usage of local data -------------------------------------------------------------------------- */ - -template -double ComputeReaxFFBondsLocalKokkos::memory_usage() -{ - double bytes = (double)nlocal*nvalues * sizeof(double); - return bytes; -} - -namespace LAMMPS_NS { -template class ComputeReaxFFBondsLocalKokkos; -#ifdef LMP_KOKKOS_GPU -template class ComputeReaxFFBondsLocalKokkos; -#endif -} diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index fbf90f140d..c7d54b80cd 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4290,61 +4290,6 @@ void PairReaxFFKokkos::pack_bond_buffer_item(int i, int &j, const bo /* ---------------------------------------------------------------------- */ -template -void PairReaxFFKokkos::PackBondInfo(DAT::tdual_float_2d k_alocal) -{ - d_alocal = k_alocal.view(); - k_params_sing.template sync(); - atomKK->sync(execution_space,TAG_MASK|TYPE_MASK|Q_MASK|MOLECULE_MASK); - - tag = atomKK->k_tag.view(); - type = atomKK->k_type.view(); - q = atomKK->k_q.view(); - if (atom->molecule) - molecule = atomKK->k_molecule.view(); - - copymode = 1; - nlocal = atomKK->nlocal; - PairReaxKokkosPackBondInfoFunctor pack_bond_info_functor(this); - Kokkos::parallel_for(nlocal, pack_bond_info_functor); - copymode = 0; - - k_alocal.modify(); - k_alocal.sync(); -} - -template -KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::pack_bond_info_item(const int i) const -{ - const int numbonds = d_numneigh_bonds[i]; - d_alocal(i,0) = tag[i]; - d_alocal(i,1) = type[i]; - d_alocal(i,2) = numbonds; - - int j = 3; - - for (int k = 0; k < numbonds; k++) { - d_alocal(i,j++) = d_neighid(i,k); - } - - d_alocal(i,j++) = molecule.data() ? molecule[i] : 0.0; - - for (int k = 0; k < numbonds; k++) { - d_alocal(i,j++) = d_abo(i,k); - } - - d_alocal(i,j++) = d_total_bo[i]; - d_alocal(i,j++) = paramssing(type[i]).nlp_opt - d_Delta_lp[i]; - d_alocal(i,j++) = q[i]; - - for(; j < d_alocal.extent(1); ++j) { - d_alocal(i,j) = 0.0; - } -} - -/* ---------------------------------------------------------------------- */ - template void PairReaxFFKokkos::FindBondSpecies() { diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 32007e9970..1ad0955a1e 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -135,7 +135,6 @@ class PairReaxFFKokkos : public PairReaxFF { double memory_usage(); void FindBond(int &); void PackBondBuffer(DAT::tdual_ffloat_1d, int &); - void PackBondInfo(DAT::tdual_float_2d); void FindBondSpecies(); template @@ -293,9 +292,6 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void pack_bond_buffer_item(int, int&, const bool&) const; - KOKKOS_INLINE_FUNCTION - void pack_bond_info_item(const int) const; - KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxFindBondSpeciesZero, const int&) const; @@ -510,8 +506,6 @@ class PairReaxFFKokkos : public PairReaxFF { typename AT::t_ffloat_1d d_buf; DAT::tdual_int_scalar k_nbuf_local; - typename AT::t_float_2d d_alocal; - typedef Kokkos::View t_reax_int4_2d; t_reax_int4_2d d_angular_pack, d_torsion_pack; @@ -555,19 +549,6 @@ struct PairReaxKokkosPackBondBufferFunctor { } }; -template -struct PairReaxKokkosPackBondInfoFunctor { - using device_type = DeviceType; - using value_type = int; - PairReaxFFKokkos c; - PairReaxKokkosPackBondInfoFunctor(PairReaxFFKokkos* c_ptr):c(*c_ptr) {}; - - KOKKOS_INLINE_FUNCTION - void operator()(const int i) const { - c.pack_bond_info_item(i); - } -}; - } #endif From ca143e6ba8da5fba4e44e06472a84ec10fd0f4fe Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 17 Oct 2023 16:40:03 -0600 Subject: [PATCH 69/87] undo minor change --- examples/reaxff/in.reaxff.tatb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/reaxff/in.reaxff.tatb b/examples/reaxff/in.reaxff.tatb index fd0d846154..f422943a13 100644 --- a/examples/reaxff/in.reaxff.tatb +++ b/examples/reaxff/in.reaxff.tatb @@ -35,7 +35,7 @@ compute bonds all reaxff/bonds variable nqeq equal f_2 # dumps out the local bond information -dump 1 all local 5 bonds_compute.reaxff c_bonds[1] c_bonds[2] c_bonds[3] +dump 1 all local 5 bonds_local.reaxff c_bonds[1] c_bonds[2] c_bonds[3] # dumps out the peratom bond information dump 2 all custom 5 bonds_atom.reaxff c_bonds[*] @@ -57,6 +57,6 @@ timestep 0.0625 # axes yes 0.8 0.02 view 60 -30 #dump_modify 3 pad 3 -#fix 3 all reaxff/species 1 5 5 species.tatb +fix 3 all reaxff/species 1 5 5 species.tatb run 25 From 717e7b064965ec575eeb25ecbbd2d510d9e22100 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 18 Oct 2023 11:30:16 -0600 Subject: [PATCH 70/87] Address comments --- src/KOKKOS/compute_reaxff_bonds_kokkos.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp b/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp index 921acb9193..5c8885ce7a 100644 --- a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp @@ -39,6 +39,7 @@ ComputeReaxFFBondsKokkos::ComputeReaxFFBondsKokkos(LAMMPS *lmp, int ComputeReaxFFBonds(lmp, narg, arg), nbuf(-1), buf(nullptr) { + kokkosable = 1; } @@ -113,9 +114,8 @@ void ComputeReaxFFBondsKokkos::compute_local() { invoked_local = update->ntimestep; - if(invoked_bonds < update->ntimestep) { + if(invoked_bonds < update->ntimestep) compute_bonds(); - } if(nbonds > prev_nbonds) { // grow array_local @@ -151,9 +151,8 @@ void ComputeReaxFFBondsKokkos::compute_peratom() { invoked_peratom = update->ntimestep; - if(invoked_bonds < update->ntimestep) { + if(invoked_bonds < update->ntimestep) compute_bonds(); - } // extract peratom bond information from buffer int j = 1; From 9bffeb9512b595dd7fd2db4b27c7c46d3e45a034 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 18 Oct 2023 16:21:10 -0600 Subject: [PATCH 71/87] Next iteration --- examples/reaxff/in.reaxff.tatb | 2 +- src/KOKKOS/compute_reaxff_bonds_kokkos.cpp | 47 +++++++++--------- src/KOKKOS/compute_reaxff_bonds_kokkos.h | 4 +- src/KOKKOS/pair_reaxff_kokkos.cpp | 57 ++++++++++++++++++++++ src/KOKKOS/pair_reaxff_kokkos.h | 17 +++++++ src/REAXFF/compute_reaxff_bonds.cpp | 30 +++++------- src/REAXFF/compute_reaxff_bonds.h | 2 +- 7 files changed, 114 insertions(+), 45 deletions(-) diff --git a/examples/reaxff/in.reaxff.tatb b/examples/reaxff/in.reaxff.tatb index f422943a13..50f572a994 100644 --- a/examples/reaxff/in.reaxff.tatb +++ b/examples/reaxff/in.reaxff.tatb @@ -38,7 +38,7 @@ variable nqeq equal f_2 dump 1 all local 5 bonds_local.reaxff c_bonds[1] c_bonds[2] c_bonds[3] # dumps out the peratom bond information -dump 2 all custom 5 bonds_atom.reaxff c_bonds[*] +dump 2 all custom 5 bonds_atom.reaxff id type q c_bonds[*] thermo 5 thermo_style custom step temp epair etotal press & diff --git a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp b/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp index 5c8885ce7a..f36832e6ac 100644 --- a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp @@ -68,7 +68,7 @@ void ComputeReaxFFBondsKokkos::compute_bonds() if (atom->nlocal > nlocal) { memory->destroy(array_atom); nlocal = atom->nlocal; - memory->create(array_atom, nlocal, 7, "reaxff/bonds:array_atom"); + memory->create(array_atom, nlocal, 3, "reaxff/bonds:array_atom"); } // retrieve bond information from kokkos pair style. the data potentially @@ -76,13 +76,14 @@ void ComputeReaxFFBondsKokkos::compute_bonds() // compute_local and compute_atom then expand the data from this buffer into // appropiate arrays for consumption by others (e.g. dump local, dump custom // or library interface) + int maxnumbonds = 0; if (reaxff->execution_space == Device) device_pair()->FindBond(maxnumbonds); else host_pair()->FindBond(maxnumbonds); - nbuf = 1+(maxnumbonds*2 + 7)*nlocal; + nbuf = (maxnumbonds*2 + 3)*nlocal; if(!buf || k_buf.extent(0) < nbuf) { memoryKK->destroy_kokkos(k_buf, buf); @@ -90,20 +91,21 @@ void ComputeReaxFFBondsKokkos::compute_bonds() } // Pass information to buffer, will sync to host + int nbuf_local; if (reaxff->execution_space == Device) - device_pair()->PackBondBuffer(k_buf, nbuf_local); + device_pair()->PackReducedBondBuffer(k_buf, nbuf_local); else - host_pair()->PackBondBuffer(k_buf, nbuf_local); - buf[0] = nlocal; + host_pair()->PackReducedBondBuffer(k_buf, nbuf_local); // Extract number of bonds from buffer + nbonds = 0; - int j = 1; + int j = 0; for (int i = 0; i < nlocal; i++) { - int numbonds = static_cast(buf[j+5]); + int numbonds = static_cast(buf[j+2]); nbonds += numbonds; - j += 2*numbonds + 7; + j += 2*numbonds + 3; } } @@ -127,20 +129,21 @@ void ComputeReaxFFBondsKokkos::compute_local() size_local_rows = nbonds; // extract local bond information from buffer + int b = 0; - int j = 1; + int j = 0; for (int i = 0; i < nlocal; ++i) { - const int numbonds = static_cast(buf[j+5]); - const int neigh_offset = j + 6; - const int bo_offset = neigh_offset + numbonds + 1; + const int numbonds = static_cast(buf[j+2]); + const int neigh_offset = j + 3; + const int bo_offset = neigh_offset + numbonds; for (int k = 0; k < numbonds; k++) { auto bond = array_local[b++]; bond[0] = i; bond[1] = static_cast (buf[neigh_offset+k]); bond[2] = buf[bo_offset+k]; } - j += 2*numbonds + 7; + j += 2*numbonds + 3; } } @@ -155,19 +158,15 @@ void ComputeReaxFFBondsKokkos::compute_peratom() compute_bonds(); // extract peratom bond information from buffer - int j = 1; + + int j = 0; for (int i = 0; i < nlocal; ++i) { auto ptr = array_atom[i]; - int numbonds = static_cast(buf[j+5]); - const int mol_offset = j + 6 + numbonds; - ptr[0] = buf[j]; // jtag - ptr[1] = buf[j+1]; // itype + int numbonds = static_cast(buf[j+2]); + ptr[0] = buf[j]; // sbo + ptr[1] = buf[j+1]; // nlp ptr[2] = numbonds; - ptr[3] = buf[mol_offset]; // mol - ptr[4] = buf[j+2]; // sbo - ptr[5] = buf[j+3]; // nlp - ptr[6] = buf[j+4]; // q - j += 2*numbonds + 7; + j += 2*numbonds + 3; } } @@ -179,7 +178,7 @@ template double ComputeReaxFFBondsKokkos::memory_usage() { double bytes = (double)(nbonds*3) * sizeof(double); - bytes += (double)(nlocal*7) * sizeof(double); + bytes += (double)(nlocal*3) * sizeof(double); return bytes; } diff --git a/src/KOKKOS/compute_reaxff_bonds_kokkos.h b/src/KOKKOS/compute_reaxff_bonds_kokkos.h index 45020ffa81..48f3860283 100644 --- a/src/KOKKOS/compute_reaxff_bonds_kokkos.h +++ b/src/KOKKOS/compute_reaxff_bonds_kokkos.h @@ -52,11 +52,11 @@ class ComputeReaxFFBondsKokkos : public ComputeReaxFFBonds { typename AT::tdual_float_1d k_buf; auto device_pair() { - return dynamic_cast*>(reaxff); + return static_cast*>(reaxff); } auto host_pair() { - return dynamic_cast*>(reaxff); + return static_cast*>(reaxff); } }; diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index c7d54b80cd..e298eca2da 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4247,6 +4247,30 @@ void PairReaxFFKokkos::PackBondBuffer(DAT::tdual_ffloat_1d k_buf, in nbuf_local = k_nbuf_local.h_view(); } +/* ---------------------------------------------------------------------- */ + +template +void PairReaxFFKokkos::PackReducedBondBuffer(DAT::tdual_ffloat_1d k_buf, int &nbuf_local) +{ + d_buf = k_buf.view(); + k_params_sing.template sync(); + + copymode = 1; + nlocal = atomKK->nlocal; + PairReaxKokkosPackReducedBondBufferFunctor pack_bond_buffer_functor(this); + Kokkos::parallel_scan(nlocal,pack_bond_buffer_functor); + copymode = 0; + + k_buf.modify(); + k_nbuf_local.modify(); + + k_buf.sync(); + k_nbuf_local.sync(); + nbuf_local = k_nbuf_local.h_view(); +} + +/* ---------------------------------------------------------------------- */ + template KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::pack_bond_buffer_item(int i, int &j, const bool &final) const @@ -4288,6 +4312,39 @@ void PairReaxFFKokkos::pack_bond_buffer_item(int i, int &j, const bo k_nbuf_local.view()() = j - 1; } +template +KOKKOS_INLINE_FUNCTION +void PairReaxFFKokkos::pack_reduced_bond_buffer_item(int i, int &j, const bool &final) const +{ + const int numbonds = d_numneigh_bonds[i]; + if (final) { + d_buf[j] = d_total_bo[i]; + d_buf[j+1] = paramssing(type[i]).nlp_opt - d_Delta_lp[i]; + d_buf[j+2] = numbonds; + } + + j += 3; + + if (final) { + for (int k = 0; k < numbonds; ++k) { + d_buf[j+k] = d_neighid(i,k); + } + } + + j += numbonds; + + if (final) { + for (int k = 0; k < numbonds; k++) { + d_buf[j+k] = d_abo(i,k); + } + } + + j += numbonds; + + if (final && i == nlocal-1) + k_nbuf_local.view()() = j - 1; +} + /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 1ad0955a1e..571dd63fd1 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -135,6 +135,7 @@ class PairReaxFFKokkos : public PairReaxFF { double memory_usage(); void FindBond(int &); void PackBondBuffer(DAT::tdual_ffloat_1d, int &); + void PackReducedBondBuffer(DAT::tdual_ffloat_1d, int &); void FindBondSpecies(); template @@ -292,6 +293,9 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void pack_bond_buffer_item(int, int&, const bool&) const; + KOKKOS_INLINE_FUNCTION + void pack_reduced_bond_buffer_item(int, int&, const bool&) const; + KOKKOS_INLINE_FUNCTION void operator()(TagPairReaxFindBondSpeciesZero, const int&) const; @@ -549,6 +553,19 @@ struct PairReaxKokkosPackBondBufferFunctor { } }; +template +struct PairReaxKokkosPackReducedBondBufferFunctor { + typedef DeviceType device_type; + typedef int value_type; + PairReaxFFKokkos c; + PairReaxKokkosPackReducedBondBufferFunctor(PairReaxFFKokkos* c_ptr):c(*c_ptr) {}; + + KOKKOS_INLINE_FUNCTION + void operator()(const int ii, int &j, const bool &final) const { + c.pack_reduced_bond_buffer_item(ii,j,final); + } +}; + } #endif diff --git a/src/REAXFF/compute_reaxff_bonds.cpp b/src/REAXFF/compute_reaxff_bonds.cpp index 7f1605263c..3b3520fda3 100644 --- a/src/REAXFF/compute_reaxff_bonds.cpp +++ b/src/REAXFF/compute_reaxff_bonds.cpp @@ -35,7 +35,7 @@ using namespace ReaxFF; ComputeReaxFFBonds::ComputeReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), - abo(nullptr), neighid(nullptr), numneigh(nullptr), reaxff(nullptr) + abo(nullptr), neighid(nullptr), bondcount(nullptr), reaxff(nullptr) { if (atom->tag_consecutive() == 0) error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds"); @@ -48,7 +48,7 @@ ComputeReaxFFBonds::ComputeReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : nlocal = -1; prev_nbonds = -1; - size_peratom_cols = 7; + size_peratom_cols = 3; size_local_rows = 0; size_local_cols = 3; @@ -65,7 +65,7 @@ ComputeReaxFFBonds::~ComputeReaxFFBonds() memory->destroy(array_atom); memory->destroy(abo); memory->destroy(neighid); - memory->destroy(numneigh); + memory->destroy(bondcount); } /* ---------------------------------------------------------------------- */ @@ -110,7 +110,7 @@ int ComputeReaxFFBonds::FindBond() nj++; } } - numneigh[i] = nj; + bondcount[i] = nj; numbonds += nj; } return numbonds; @@ -126,17 +126,17 @@ void ComputeReaxFFBonds::compute_bonds() if (atom->nlocal > nlocal) { memory->destroy(abo); memory->destroy(neighid); - memory->destroy(numneigh); + memory->destroy(bondcount); memory->destroy(array_atom); nlocal = atom->nlocal; memory->create(abo, nlocal, MAXREAXBOND, "reaxff/bonds:abo"); memory->create(neighid, nlocal, MAXREAXBOND, "reaxff/bonds:neighid"); - memory->create(numneigh, nlocal, "reaxff/bonds:numneigh"); - memory->create(array_atom, nlocal, 7, "reaxff/bonds:array_atom"); + memory->create(bondcount, nlocal, "reaxff/bonds:bondcount"); + memory->create(array_atom, nlocal, 3, "reaxff/bonds:array_atom"); } for (int i = 0; i < nlocal; i++) { - numneigh[i] = 0; + bondcount[i] = 0; for (int j = 0; j < MAXREAXBOND; j++) { neighid[i][j] = 0; abo[i][j] = 0.0; @@ -168,7 +168,7 @@ void ComputeReaxFFBonds::compute_local() int b = 0; for (int i = 0; i < nlocal; ++i) { - const int numbonds = numneigh[i]; + const int numbonds = bondcount[i]; for (int k = 0; k < numbonds; k++) { auto bond = array_local[b++]; @@ -191,13 +191,9 @@ void ComputeReaxFFBonds::compute_peratom() for (int i = 0; i < nlocal; ++i) { auto ptr = array_atom[i]; - ptr[0] = atom->tag[i]; - ptr[1] = atom->type[i]; - ptr[2] = numneigh[i]; - ptr[3] = (atom->molecule == nullptr) ? 0.0 : atom->molecule[i]; - ptr[4] = reaxff->api->workspace->total_bond_order[i]; - ptr[5] = reaxff->api->workspace->nlp[i]; - ptr[6] = atom->q[i]; + ptr[0] = reaxff->api->workspace->total_bond_order[i]; + ptr[1] = reaxff->api->workspace->nlp[i]; + ptr[2] = bondcount[i]; } } @@ -208,7 +204,7 @@ void ComputeReaxFFBonds::compute_peratom() double ComputeReaxFFBonds::memory_usage() { double bytes = (double)(nbonds*3) * sizeof(double); - bytes += (double)(nlocal*7) * sizeof(double); + bytes += (double)(nlocal*3) * sizeof(double); bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); bytes += (double)(nlocal) * sizeof(int); return bytes; diff --git a/src/REAXFF/compute_reaxff_bonds.h b/src/REAXFF/compute_reaxff_bonds.h index 6b00cef7ed..b876c9e02d 100644 --- a/src/REAXFF/compute_reaxff_bonds.h +++ b/src/REAXFF/compute_reaxff_bonds.h @@ -46,7 +46,7 @@ class ComputeReaxFFBonds : public Compute { tagint **neighid; double **abo; - int *numneigh; + int *bondcount; class PairReaxFF *reaxff; private: From afd0107f01ff552aba336ccc02af240f3aed33a8 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 8 Nov 2023 14:17:18 -0700 Subject: [PATCH 72/87] Add new files to makefile build system --- src/KOKKOS/Install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 489efc55a0..01db058d5b 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -165,6 +165,8 @@ action fix_qeq_reaxff_kokkos.cpp fix_qeq_reaxff.cpp action fix_qeq_reaxff_kokkos.h fix_qeq_reaxff.h action fix_reaxff_bonds_kokkos.cpp fix_reaxff_bonds.cpp action fix_reaxff_bonds_kokkos.h fix_reaxff_bonds.h +action compute_reaxff_bonds_kokkos.cpp compute_reaxff_bonds.cpp +action compute_reaxff_bonds_kokkos.h compute_reaxff_bonds.h action fix_reaxff_species_kokkos.cpp fix_reaxff_species.cpp action fix_reaxff_species_kokkos.h fix_reaxff_species.h action fix_rx_kokkos.cpp fix_rx.cpp From 16f0806da07289e3aea388b453e03ba24f042120 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 20 Nov 2023 15:36:46 -0700 Subject: [PATCH 73/87] Rename compute to reaxff/atom --- examples/reaxff/in.reaxff.tatb | 2 +- src/KOKKOS/Install.sh | 4 +- ...kos.cpp => compute_reaxff_atom_kokkos.cpp} | 46 ++++++------- ..._kokkos.h => compute_reaxff_atom_kokkos.h} | 14 ++-- src/KOKKOS/pair_reaxff_kokkos.cpp | 35 ++++++---- src/KOKKOS/pair_reaxff_kokkos.h | 7 +- ...axff_bonds.cpp => compute_reaxff_atom.cpp} | 64 ++++++++++++------- ...e_reaxff_bonds.h => compute_reaxff_atom.h} | 13 ++-- 8 files changed, 108 insertions(+), 77 deletions(-) rename src/KOKKOS/{compute_reaxff_bonds_kokkos.cpp => compute_reaxff_atom_kokkos.cpp} (76%) rename src/KOKKOS/{compute_reaxff_bonds_kokkos.h => compute_reaxff_atom_kokkos.h} (79%) rename src/REAXFF/{compute_reaxff_bonds.cpp => compute_reaxff_atom.cpp} (74%) rename src/REAXFF/{compute_reaxff_bonds.h => compute_reaxff_atom.h} (84%) diff --git a/examples/reaxff/in.reaxff.tatb b/examples/reaxff/in.reaxff.tatb index 50f572a994..967ed0a1d6 100644 --- a/examples/reaxff/in.reaxff.tatb +++ b/examples/reaxff/in.reaxff.tatb @@ -31,7 +31,7 @@ neigh_modify delay 0 every 5 check no fix 1 all nve fix 2 all qeq/reaxff 1 0.0 10.0 1.0e-6 reaxff fix 4 all reaxff/bonds 5 bonds.reaxff -compute bonds all reaxff/bonds +compute bonds all reaxff/atom bonds yes variable nqeq equal f_2 # dumps out the local bond information diff --git a/src/KOKKOS/Install.sh b/src/KOKKOS/Install.sh index 01db058d5b..28fe6d5cd6 100755 --- a/src/KOKKOS/Install.sh +++ b/src/KOKKOS/Install.sh @@ -165,8 +165,8 @@ action fix_qeq_reaxff_kokkos.cpp fix_qeq_reaxff.cpp action fix_qeq_reaxff_kokkos.h fix_qeq_reaxff.h action fix_reaxff_bonds_kokkos.cpp fix_reaxff_bonds.cpp action fix_reaxff_bonds_kokkos.h fix_reaxff_bonds.h -action compute_reaxff_bonds_kokkos.cpp compute_reaxff_bonds.cpp -action compute_reaxff_bonds_kokkos.h compute_reaxff_bonds.h +action compute_reaxff_atom_kokkos.cpp compute_reaxff_atom.cpp +action compute_reaxff_atom_kokkos.h compute_reaxff_atom.h action fix_reaxff_species_kokkos.cpp fix_reaxff_species.cpp action fix_reaxff_species_kokkos.h fix_reaxff_species.h action fix_rx_kokkos.cpp fix_rx.cpp diff --git a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp similarity index 76% rename from src/KOKKOS/compute_reaxff_bonds_kokkos.cpp rename to src/KOKKOS/compute_reaxff_atom_kokkos.cpp index f36832e6ac..2485d9ae72 100644 --- a/src/KOKKOS/compute_reaxff_bonds_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp @@ -16,7 +16,7 @@ Contributing author: Richard Berger (LANL) ------------------------------------------------------------------------- */ -#include "compute_reaxff_bonds_kokkos.h" +#include "compute_reaxff_atom_kokkos.h" #include "atom.h" #include "molecule.h" #include "update.h" @@ -35,8 +35,8 @@ using namespace ReaxFF; /* ---------------------------------------------------------------------- */ template -ComputeReaxFFBondsKokkos::ComputeReaxFFBondsKokkos(LAMMPS *lmp, int narg, char **arg) : - ComputeReaxFFBonds(lmp, narg, arg), +ComputeReaxFFAtomKokkos::ComputeReaxFFAtomKokkos(LAMMPS *lmp, int narg, char **arg) : + ComputeReaxFFAtom(lmp, narg, arg), nbuf(-1), buf(nullptr) { kokkosable = 1; @@ -46,7 +46,7 @@ ComputeReaxFFBondsKokkos::ComputeReaxFFBondsKokkos(LAMMPS *lmp, int /* ---------------------------------------------------------------------- */ template -ComputeReaxFFBondsKokkos::~ComputeReaxFFBondsKokkos() +ComputeReaxFFAtomKokkos::~ComputeReaxFFAtomKokkos() { memoryKK->destroy_kokkos(k_buf, buf); } @@ -54,21 +54,21 @@ ComputeReaxFFBondsKokkos::~ComputeReaxFFBondsKokkos() /* ---------------------------------------------------------------------- */ template -void ComputeReaxFFBondsKokkos::init() +void ComputeReaxFFAtomKokkos::init() { reaxff = dynamic_cast(force->pair_match("^reax../kk",0)); - if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/bonds without " + if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/atom without " "pair_style reaxff/kk"); } /* ---------------------------------------------------------------------- */ template -void ComputeReaxFFBondsKokkos::compute_bonds() +void ComputeReaxFFAtomKokkos::compute_bonds() { if (atom->nlocal > nlocal) { memory->destroy(array_atom); nlocal = atom->nlocal; - memory->create(array_atom, nlocal, 3, "reaxff/bonds:array_atom"); + memory->create(array_atom, nlocal, 3, "reaxff/atom:array_atom"); } // retrieve bond information from kokkos pair style. the data potentially @@ -83,20 +83,20 @@ void ComputeReaxFFBondsKokkos::compute_bonds() else host_pair()->FindBond(maxnumbonds); - nbuf = (maxnumbonds*2 + 3)*nlocal; + nbuf = ((store_bonds ? maxnumbonds*2 : 0) + 3)*nlocal; if(!buf || k_buf.extent(0) < nbuf) { memoryKK->destroy_kokkos(k_buf, buf); - memoryKK->create_kokkos(k_buf, buf, nbuf, "reaxff/bonds:buf"); + memoryKK->create_kokkos(k_buf, buf, nbuf, "reaxff/atom:buf"); } // Pass information to buffer, will sync to host int nbuf_local; if (reaxff->execution_space == Device) - device_pair()->PackReducedBondBuffer(k_buf, nbuf_local); + device_pair()->PackReducedBondBuffer(k_buf, nbuf_local, store_bonds); else - host_pair()->PackReducedBondBuffer(k_buf, nbuf_local); + host_pair()->PackReducedBondBuffer(k_buf, nbuf_local, store_bonds); // Extract number of bonds from buffer @@ -105,14 +105,14 @@ void ComputeReaxFFBondsKokkos::compute_bonds() for (int i = 0; i < nlocal; i++) { int numbonds = static_cast(buf[j+2]); nbonds += numbonds; - j += 2*numbonds + 3; + j += (store_bonds ? 2*numbonds : 0) + 3; } } /* ---------------------------------------------------------------------- */ template -void ComputeReaxFFBondsKokkos::compute_local() +void ComputeReaxFFAtomKokkos::compute_local() { invoked_local = update->ntimestep; @@ -122,7 +122,7 @@ void ComputeReaxFFBondsKokkos::compute_local() if(nbonds > prev_nbonds) { // grow array_local memory->destroy(array_local); - memory->create(array_local, nbonds, 3, "reaxff/bonds:array_local"); + memory->create(array_local, nbonds, 3, "reaxff/atom:array_local"); prev_nbonds = nbonds; } @@ -150,7 +150,7 @@ void ComputeReaxFFBondsKokkos::compute_local() /* ---------------------------------------------------------------------- */ template -void ComputeReaxFFBondsKokkos::compute_peratom() +void ComputeReaxFFAtomKokkos::compute_peratom() { invoked_peratom = update->ntimestep; @@ -166,7 +166,7 @@ void ComputeReaxFFBondsKokkos::compute_peratom() ptr[0] = buf[j]; // sbo ptr[1] = buf[j+1]; // nlp ptr[2] = numbonds; - j += 2*numbonds + 3; + j += (store_bonds ? 2*numbonds : 0) + 3; } } @@ -175,16 +175,18 @@ void ComputeReaxFFBondsKokkos::compute_peratom() ------------------------------------------------------------------------- */ template -double ComputeReaxFFBondsKokkos::memory_usage() +double ComputeReaxFFAtomKokkos::memory_usage() { - double bytes = (double)(nbonds*3) * sizeof(double); - bytes += (double)(nlocal*3) * sizeof(double); + double bytes = (double)(nlocal*3) * sizeof(double); + if(store_bonds) + bytes += (double)(nbonds*3) * sizeof(double); + bytes += (double)(nbuf > 0 ? nbuf * sizeof(double) : 0); return bytes; } namespace LAMMPS_NS { -template class ComputeReaxFFBondsKokkos; +template class ComputeReaxFFAtomKokkos; #ifdef LMP_KOKKOS_GPU -template class ComputeReaxFFBondsKokkos; +template class ComputeReaxFFAtomKokkos; #endif } diff --git a/src/KOKKOS/compute_reaxff_bonds_kokkos.h b/src/KOKKOS/compute_reaxff_atom_kokkos.h similarity index 79% rename from src/KOKKOS/compute_reaxff_bonds_kokkos.h rename to src/KOKKOS/compute_reaxff_atom_kokkos.h index 48f3860283..7037c7e308 100644 --- a/src/KOKKOS/compute_reaxff_bonds_kokkos.h +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.h @@ -17,29 +17,29 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(reaxff/bonds/kk,ComputeReaxFFBondsKokkos); -ComputeStyle(reaxff/bonds/kk/device,ComputeReaxFFBondsKokkos); -ComputeStyle(reaxff/bonds/kk/host,ComputeReaxFFBondsKokkos); +ComputeStyle(reaxff/atom/kk,ComputeReaxFFAtomKokkos); +ComputeStyle(reaxff/atom/kk/device,ComputeReaxFFAtomKokkos); +ComputeStyle(reaxff/atom/kk/host,ComputeReaxFFAtomKokkos); // clang-format on #else #ifndef LMP_COMPUTE_REAXFF_BONDS_KOKKOS_H #define LMP_COMPUTE_REAXFF_BONDS_KOKKOS_H -#include "compute_reaxff_bonds.h" +#include "compute_reaxff_atom.h" #include "pair_reaxff_kokkos.h" #include "kokkos_type.h" namespace LAMMPS_NS { template -class ComputeReaxFFBondsKokkos : public ComputeReaxFFBonds { +class ComputeReaxFFAtomKokkos : public ComputeReaxFFAtom { public: using device_type = DeviceType; using AT = ArrayTypes; - ComputeReaxFFBondsKokkos(class LAMMPS *, int, char **); - ~ComputeReaxFFBondsKokkos() override; + ComputeReaxFFAtomKokkos(class LAMMPS *, int, char **); + ~ComputeReaxFFAtomKokkos() override; void init() override; void compute_local() override; void compute_peratom() override; diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index e298eca2da..914962f0e6 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4250,15 +4250,21 @@ void PairReaxFFKokkos::PackBondBuffer(DAT::tdual_ffloat_1d k_buf, in /* ---------------------------------------------------------------------- */ template -void PairReaxFFKokkos::PackReducedBondBuffer(DAT::tdual_ffloat_1d k_buf, int &nbuf_local) +void PairReaxFFKokkos::PackReducedBondBuffer(DAT::tdual_ffloat_1d k_buf, int &nbuf_local, bool store_bonds) { d_buf = k_buf.view(); k_params_sing.template sync(); copymode = 1; nlocal = atomKK->nlocal; - PairReaxKokkosPackReducedBondBufferFunctor pack_bond_buffer_functor(this); - Kokkos::parallel_scan(nlocal,pack_bond_buffer_functor); + if(store_bonds) { + PairReaxKokkosPackReducedBondBufferFunctor pack_bond_buffer_functor(this); + Kokkos::parallel_scan(nlocal,pack_bond_buffer_functor); + } else { + PairReaxKokkosPackReducedBondBufferFunctor pack_bond_buffer_functor(this); + Kokkos::parallel_scan(nlocal,pack_bond_buffer_functor); + } + copymode = 0; k_buf.modify(); @@ -4313,6 +4319,7 @@ void PairReaxFFKokkos::pack_bond_buffer_item(int i, int &j, const bo } template +template KOKKOS_INLINE_FUNCTION void PairReaxFFKokkos::pack_reduced_bond_buffer_item(int i, int &j, const bool &final) const { @@ -4325,21 +4332,23 @@ void PairReaxFFKokkos::pack_reduced_bond_buffer_item(int i, int &j, j += 3; - if (final) { - for (int k = 0; k < numbonds; ++k) { - d_buf[j+k] = d_neighid(i,k); + if constexpr(STORE_BONDS) { + if (final) { + for (int k = 0; k < numbonds; ++k) { + d_buf[j+k] = d_neighid(i,k); + } } - } - j += numbonds; + j += numbonds; - if (final) { - for (int k = 0; k < numbonds; k++) { - d_buf[j+k] = d_abo(i,k); + if (final) { + for (int k = 0; k < numbonds; k++) { + d_buf[j+k] = d_abo(i,k); + } } - } - j += numbonds; + j += numbonds; + } if (final && i == nlocal-1) k_nbuf_local.view()() = j - 1; diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index 571dd63fd1..f246afcc86 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -135,7 +135,7 @@ class PairReaxFFKokkos : public PairReaxFF { double memory_usage(); void FindBond(int &); void PackBondBuffer(DAT::tdual_ffloat_1d, int &); - void PackReducedBondBuffer(DAT::tdual_ffloat_1d, int &); + void PackReducedBondBuffer(DAT::tdual_ffloat_1d, int &, bool); void FindBondSpecies(); template @@ -293,6 +293,7 @@ class PairReaxFFKokkos : public PairReaxFF { KOKKOS_INLINE_FUNCTION void pack_bond_buffer_item(int, int&, const bool&) const; + template KOKKOS_INLINE_FUNCTION void pack_reduced_bond_buffer_item(int, int&, const bool&) const; @@ -553,7 +554,7 @@ struct PairReaxKokkosPackBondBufferFunctor { } }; -template +template struct PairReaxKokkosPackReducedBondBufferFunctor { typedef DeviceType device_type; typedef int value_type; @@ -562,7 +563,7 @@ struct PairReaxKokkosPackReducedBondBufferFunctor { KOKKOS_INLINE_FUNCTION void operator()(const int ii, int &j, const bool &final) const { - c.pack_reduced_bond_buffer_item(ii,j,final); + c.template pack_reduced_bond_buffer_item(ii,j,final); } }; diff --git a/src/REAXFF/compute_reaxff_bonds.cpp b/src/REAXFF/compute_reaxff_atom.cpp similarity index 74% rename from src/REAXFF/compute_reaxff_bonds.cpp rename to src/REAXFF/compute_reaxff_atom.cpp index 3b3520fda3..d975fe42f8 100644 --- a/src/REAXFF/compute_reaxff_bonds.cpp +++ b/src/REAXFF/compute_reaxff_atom.cpp @@ -16,7 +16,7 @@ Contributing author: Richard Berger (LANL) ------------------------------------------------------------------------- */ -#include "compute_reaxff_bonds.h" +#include "compute_reaxff_atom.h" #include "atom.h" #include "molecule.h" #include "update.h" @@ -33,14 +33,13 @@ using namespace ReaxFF; /* ---------------------------------------------------------------------- */ -ComputeReaxFFBonds::ComputeReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : +ComputeReaxFFAtom::ComputeReaxFFAtom(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), abo(nullptr), neighid(nullptr), bondcount(nullptr), reaxff(nullptr) { if (atom->tag_consecutive() == 0) - error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/bonds"); + error->all(FLERR,"Atom IDs must be consecutive for compute reaxff/atom"); - local_flag = 1; peratom_flag = 1; // initialize output @@ -54,12 +53,25 @@ ComputeReaxFFBonds::ComputeReaxFFBonds(LAMMPS *lmp, int narg, char **arg) : size_local_cols = 3; invoked_bonds = -1; + + store_bonds = false; + + int iarg = 3; + while (iarg narg) utils::missing_cmd_args(FLERR, "compute reaxff/atom bonds", error); + store_bonds = utils::logical(FLERR, arg[iarg+1], false, lmp); + iarg += 2; + } else error->all(FLERR,"Illegal compute reaxff/atom command"); + } + + local_flag = store_bonds; } /* ---------------------------------------------------------------------- */ -ComputeReaxFFBonds::~ComputeReaxFFBonds() +ComputeReaxFFAtom::~ComputeReaxFFAtom() { memory->destroy(array_local); memory->destroy(array_atom); @@ -70,16 +82,16 @@ ComputeReaxFFBonds::~ComputeReaxFFBonds() /* ---------------------------------------------------------------------- */ -void ComputeReaxFFBonds::init() +void ComputeReaxFFAtom::init() { reaxff = dynamic_cast(force->pair_match("^reax..",0)); - if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/bonds without " + if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/atom without " "pair_style reaxff, reaxff/kk, or reaxff/omp"); } /* ---------------------------------------------------------------------- */ -int ComputeReaxFFBonds::FindBond() +int ComputeReaxFFAtom::FindBond() { int *ilist, i, ii, inum; int j, pj, nj; @@ -105,8 +117,10 @@ int ComputeReaxFFBonds::FindBond() bo_tmp = bo_ij->bo_data.BO; if (bo_tmp > bo_cut) { - neighid[i][nj] = jtag; - abo[i][nj] = bo_tmp; + if(store_bonds) { + neighid[i][nj] = jtag; + abo[i][nj] = bo_tmp; + } nj++; } } @@ -119,7 +133,7 @@ int ComputeReaxFFBonds::FindBond() /* ---------------------------------------------------------------------- */ -void ComputeReaxFFBonds::compute_bonds() +void ComputeReaxFFAtom::compute_bonds() { invoked_bonds = update->ntimestep; @@ -129,15 +143,17 @@ void ComputeReaxFFBonds::compute_bonds() memory->destroy(bondcount); memory->destroy(array_atom); nlocal = atom->nlocal; - memory->create(abo, nlocal, MAXREAXBOND, "reaxff/bonds:abo"); - memory->create(neighid, nlocal, MAXREAXBOND, "reaxff/bonds:neighid"); - memory->create(bondcount, nlocal, "reaxff/bonds:bondcount"); - memory->create(array_atom, nlocal, 3, "reaxff/bonds:array_atom"); + if(store_bonds) { + memory->create(abo, nlocal, MAXREAXBOND, "reaxff/atom:abo"); + memory->create(neighid, nlocal, MAXREAXBOND, "reaxff/atom:neighid"); + } + memory->create(bondcount, nlocal, "reaxff/atom:bondcount"); + memory->create(array_atom, nlocal, 3, "reaxff/atom:array_atom"); } for (int i = 0; i < nlocal; i++) { bondcount[i] = 0; - for (int j = 0; j < MAXREAXBOND; j++) { + for (int j = 0; store_bonds && j < MAXREAXBOND; j++) { neighid[i][j] = 0; abo[i][j] = 0.0; } @@ -148,7 +164,7 @@ void ComputeReaxFFBonds::compute_bonds() /* ---------------------------------------------------------------------- */ -void ComputeReaxFFBonds::compute_local() +void ComputeReaxFFAtom::compute_local() { invoked_local = update->ntimestep; @@ -159,7 +175,7 @@ void ComputeReaxFFBonds::compute_local() if(nbonds > prev_nbonds) { // grow array_local memory->destroy(array_local); - memory->create(array_local, nbonds, 3, "reaxff/bonds:array_local"); + memory->create(array_local, nbonds, 3, "reaxff/atom:array_local"); prev_nbonds = nbonds; } @@ -181,7 +197,7 @@ void ComputeReaxFFBonds::compute_local() /* ---------------------------------------------------------------------- */ -void ComputeReaxFFBonds::compute_peratom() +void ComputeReaxFFAtom::compute_peratom() { invoked_peratom = update->ntimestep; @@ -201,11 +217,13 @@ void ComputeReaxFFBonds::compute_peratom() memory usage of local data ------------------------------------------------------------------------- */ -double ComputeReaxFFBonds::memory_usage() +double ComputeReaxFFAtom::memory_usage() { - double bytes = (double)(nbonds*3) * sizeof(double); - bytes += (double)(nlocal*3) * sizeof(double); - bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); + double bytes = (double)(nlocal*3) * sizeof(double); bytes += (double)(nlocal) * sizeof(int); + if(store_bonds) { + bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); + bytes += (double)(nbonds*3) * sizeof(double); + } return bytes; } diff --git a/src/REAXFF/compute_reaxff_bonds.h b/src/REAXFF/compute_reaxff_atom.h similarity index 84% rename from src/REAXFF/compute_reaxff_bonds.h rename to src/REAXFF/compute_reaxff_atom.h index b876c9e02d..31b18e7238 100644 --- a/src/REAXFF/compute_reaxff_bonds.h +++ b/src/REAXFF/compute_reaxff_atom.h @@ -17,21 +17,21 @@ #ifdef COMPUTE_CLASS // clang-format off -ComputeStyle(reaxff/bonds,ComputeReaxFFBonds); +ComputeStyle(reaxff/atom,ComputeReaxFFAtom); // clang-format on #else -#ifndef LMP_COMPUTE_REAXFF_BONDS_H -#define LMP_COMPUTE_REAXFF_BONDS_H +#ifndef LMP_COMPUTE_REAXFF_ATOM_H +#define LMP_COMPUTE_REAXFF_ATOM_H #include "compute.h" namespace LAMMPS_NS { -class ComputeReaxFFBonds : public Compute { +class ComputeReaxFFAtom : public Compute { public: - ComputeReaxFFBonds(class LAMMPS *, int, char **); - ~ComputeReaxFFBonds() override; + ComputeReaxFFAtom(class LAMMPS *, int, char **); + ~ComputeReaxFFAtom() override; void init() override; void compute_local() override; void compute_peratom() override; @@ -43,6 +43,7 @@ class ComputeReaxFFBonds : public Compute { int nlocal; int nbonds; int prev_nbonds; + bool store_bonds; tagint **neighid; double **abo; From fd83ed4004a8d26b95f1f69e75b288804361bfd5 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 21 Nov 2023 13:42:51 -0700 Subject: [PATCH 74/87] compute reaxff/atom: add support for pair hybrid --- src/KOKKOS/compute_reaxff_atom_kokkos.cpp | 9 ++++--- src/REAXFF/compute_reaxff_atom.cpp | 30 ++++++++++++++++++++--- src/REAXFF/compute_reaxff_atom.h | 1 + 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp index 2485d9ae72..845e8bc6e7 100644 --- a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp @@ -56,9 +56,12 @@ ComputeReaxFFAtomKokkos::~ComputeReaxFFAtomKokkos() template void ComputeReaxFFAtomKokkos::init() { - reaxff = dynamic_cast(force->pair_match("^reax../kk",0)); - if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/atom without " - "pair_style reaxff/kk"); + ComputeReaxFFAtom::init(); + + if(!reaxff || !reaxff->kokkosable) { + error->all(FLERR,"Cannot use compute reaxff/atom/kk without " + "pair_style reaxff/kk"); + } } /* ---------------------------------------------------------------------- */ diff --git a/src/REAXFF/compute_reaxff_atom.cpp b/src/REAXFF/compute_reaxff_atom.cpp index d975fe42f8..1d7bdf0e7d 100644 --- a/src/REAXFF/compute_reaxff_atom.cpp +++ b/src/REAXFF/compute_reaxff_atom.cpp @@ -55,10 +55,21 @@ ComputeReaxFFAtom::ComputeReaxFFAtom(LAMMPS *lmp, int narg, char **arg) : invoked_bonds = -1; store_bonds = false; + nsub = 0; int iarg = 3; while (iarg narg) utils::missing_cmd_args(FLERR, "compute reaxff/atom pair", error); + ++iarg; + + if (isdigit(arg[iarg][0])) { + nsub = utils::inumeric(FLERR, arg[iarg], false, lmp); + ++iarg; + if (nsub > 0) continue; + } + error->all(FLERR, "Illegal compute reaxff/atom command"); + } else if (strcmp(arg[iarg], "bonds") == 0) { if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "compute reaxff/atom bonds", error); store_bonds = utils::logical(FLERR, arg[iarg+1], false, lmp); iarg += 2; @@ -84,9 +95,20 @@ ComputeReaxFFAtom::~ComputeReaxFFAtom() void ComputeReaxFFAtom::init() { - reaxff = dynamic_cast(force->pair_match("^reax..",0)); - if (reaxff == nullptr) error->all(FLERR,"Cannot use compute reaxff/atom without " - "pair_style reaxff, reaxff/kk, or reaxff/omp"); + if (lmp->suffix_enable) { + if (lmp->suffix) + reaxff = dynamic_cast(force->pair_match(fmt::format("^reax../{}", lmp->suffix), 0, nsub)); + if (!reaxff && lmp->suffix2) + reaxff = dynamic_cast(force->pair_match(fmt::format("^reax../{}", lmp->suffix2), 0, nsub)); + } + + if (!reaxff) reaxff = dynamic_cast(force->pair_match("^reax..", 0, nsub)); + + if (!reaxff) error->all(FLERR,"Cannot use compute reaxff/atom without " + "pair_style reaxff or reaxff/omp"); + + if(reaxff->kokkosable && !kokkosable) + error->all(FLERR,"Cannot use compute reaxff/atom with pair_style reaxff/kk. Use reaxff/atom/kk."); } /* ---------------------------------------------------------------------- */ diff --git a/src/REAXFF/compute_reaxff_atom.h b/src/REAXFF/compute_reaxff_atom.h index 31b18e7238..1f9aaec1ae 100644 --- a/src/REAXFF/compute_reaxff_atom.h +++ b/src/REAXFF/compute_reaxff_atom.h @@ -43,6 +43,7 @@ class ComputeReaxFFAtom : public Compute { int nlocal; int nbonds; int prev_nbonds; + int nsub; bool store_bonds; tagint **neighid; From a5cc181358cab34f2edfa1ab79e04d71723bfa70 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 21 Nov 2023 14:03:10 -0700 Subject: [PATCH 75/87] Start with compute reaxff/atom documentation --- doc/src/Commands_compute.rst | 1 + doc/src/compute_reaxff_atom.rst | 67 +++++++++++++++++++++++++++++++++ doc/src/pair_reaxff.rst | 3 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 doc/src/compute_reaxff_atom.rst diff --git a/doc/src/Commands_compute.rst b/doc/src/Commands_compute.rst index dbd6b58ce7..819a1b10d8 100644 --- a/doc/src/Commands_compute.rst +++ b/doc/src/Commands_compute.rst @@ -115,6 +115,7 @@ KOKKOS, o = OPENMP, t = OPT. * :doc:`property/grid ` * :doc:`property/local ` * :doc:`ptm/atom ` + * :doc:`reaxff/atom (k) ` * :doc:`rdf ` * :doc:`reduce ` * :doc:`reduce/chunk ` diff --git a/doc/src/compute_reaxff_atom.rst b/doc/src/compute_reaxff_atom.rst new file mode 100644 index 0000000000..4906f3fe5c --- /dev/null +++ b/doc/src/compute_reaxff_atom.rst @@ -0,0 +1,67 @@ +.. index:: fix reaxff/atom +.. index:: fix reaxff/atom/kk + +fix reaxff/atom command +======================= + +Accelerator Variants: *reaxff/atom/kk* + +Syntax +"""""" + +.. code-block:: LAMMPS + + compute ID group-ID reaxff/atom attribute args ... keyword value ... + +* ID, group-ID are documented in :doc:`compute ` command +* reaxff/atom = name of this compute command +* attribute = *pair* + + .. parsed-literal:: + + *pair* args = nsub + nsub = *n*-instance of a sub-style, if a pair style is used multiple times in a hybrid style + +* keyword = *bonds* + + .. parsed-literal:: + + *bonds* value = *no* or *yes* + *no* = ignore list of local bonds + *yes* = include list of local bonds + +Examples +"""""""" + +.. code-block:: LAMMPS + + compute 1 all reaxff/atom bonds yes + +Description +""""""""""" + +TODO + +---------- + +.. include:: accel_styles.rst + +---------- + +Restrictions +"""""""""""" + +The compute reaxff/atom command requires that the :doc:`pair_style reaxff +` is invoked. This fix is part of the REAXFF package. It is only +enabled if LAMMPS was built with that package. See the :doc:`Build package +` page for more info. + +Related commands +"""""""""""""""" + +:doc:`pair_style reaxff ` + +Default +""""""" + +The option defaults are *bonds* = *no*. diff --git a/doc/src/pair_reaxff.rst b/doc/src/pair_reaxff.rst index d28e15b0a2..03d53d1ff4 100644 --- a/doc/src/pair_reaxff.rst +++ b/doc/src/pair_reaxff.rst @@ -373,7 +373,8 @@ Related commands :doc:`pair_coeff `, :doc:`fix qeq/reaxff `, :doc:`fix acks2/reaxff `, :doc:`fix reaxff/bonds `, -:doc:`fix reaxff/species ` +:doc:`fix reaxff/species `, +:doc:`compute reaxff/atom ` Default """"""" From b72c34d4979b184adbb4aea83240e7bcb30e040e Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Tue, 21 Nov 2023 14:20:17 -0700 Subject: [PATCH 76/87] compute reaxff/atom: return tag[i] instead of i --- src/KOKKOS/compute_reaxff_atom_kokkos.cpp | 3 ++- src/REAXFF/compute_reaxff_atom.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp index 845e8bc6e7..c703bc3552 100644 --- a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp @@ -135,6 +135,7 @@ void ComputeReaxFFAtomKokkos::compute_local() int b = 0; int j = 0; + auto tag = atom->tag; for (int i = 0; i < nlocal; ++i) { const int numbonds = static_cast(buf[j+2]); @@ -142,7 +143,7 @@ void ComputeReaxFFAtomKokkos::compute_local() const int bo_offset = neigh_offset + numbonds; for (int k = 0; k < numbonds; k++) { auto bond = array_local[b++]; - bond[0] = i; + bond[0] = tag[i]; bond[1] = static_cast (buf[neigh_offset+k]); bond[2] = buf[bo_offset+k]; } diff --git a/src/REAXFF/compute_reaxff_atom.cpp b/src/REAXFF/compute_reaxff_atom.cpp index 1d7bdf0e7d..2e5d4058b8 100644 --- a/src/REAXFF/compute_reaxff_atom.cpp +++ b/src/REAXFF/compute_reaxff_atom.cpp @@ -202,6 +202,7 @@ void ComputeReaxFFAtom::compute_local() } size_local_rows = nbonds; + auto tag = atom->tag; int b = 0; @@ -210,7 +211,7 @@ void ComputeReaxFFAtom::compute_local() for (int k = 0; k < numbonds; k++) { auto bond = array_local[b++]; - bond[0] = i; + bond[0] = tag[i]; bond[1] = neighid[i][k]; bond[2] = abo[i][k]; } From a365cb15b0c340b7f56fcca76f9ded4d495f5c0e Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 9 Dec 2023 14:18:20 -0700 Subject: [PATCH 77/87] Updating class names in Intel --- src/INTEL/npair_halffull_intel.cpp | 8 ++++---- src/INTEL/npair_halffull_intel.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/INTEL/npair_halffull_intel.cpp b/src/INTEL/npair_halffull_intel.cpp index 5a70edae8b..134b768cc5 100644 --- a/src/INTEL/npair_halffull_intel.cpp +++ b/src/INTEL/npair_halffull_intel.cpp @@ -257,7 +257,7 @@ void NPairHalffullNewtonIntel::build(NeighList *list) /* ---------------------------------------------------------------------- */ -NPairHalffullNewtonTrimIntel::NPairHalffullNewtonTrimIntel(LAMMPS *lmp) : NPair(lmp) { +NPairHalffullTrimNewtonIntel::NPairHalffullTrimNewtonIntel(LAMMPS *lmp) : NPair(lmp) { _fix = static_cast(modify->get_fix_by_id("package_intel")); if (!_fix) error->all(FLERR, "The 'package intel' command is required for /intel styles"); } @@ -270,7 +270,7 @@ NPairHalffullNewtonTrimIntel::NPairHalffullNewtonTrimIntel(LAMMPS *lmp) : NPair( ------------------------------------------------------------------------- */ template -void NPairHalffullNewtonTrimIntel::build_t(NeighList *list, +void NPairHalffullTrimNewtonIntel::build_t(NeighList *list, IntelBuffers *buffers) { const int inum_full = list->listfull->inum; @@ -408,7 +408,7 @@ void NPairHalffullNewtonTrimIntel::build_t(NeighList *list, ------------------------------------------------------------------------- */ template -void NPairHalffullNewtonTrimIntel::build_t3(NeighList *list, int *numhalf, +void NPairHalffullTrimNewtonIntel::build_t3(NeighList *list, int *numhalf, IntelBuffers *buffers) { const int inum_full = list->listfull->inum; @@ -498,7 +498,7 @@ void NPairHalffullNewtonTrimIntel::build_t3(NeighList *list, int *numhalf, /* ---------------------------------------------------------------------- */ -void NPairHalffullNewtonTrimIntel::build(NeighList *list) +void NPairHalffullTrimNewtonIntel::build(NeighList *list) { if (_fix->three_body_neighbor() == 0 || domain->triclinic) { if (_fix->precision() == FixIntel::PREC_MODE_MIXED) diff --git a/src/INTEL/npair_halffull_intel.h b/src/INTEL/npair_halffull_intel.h index d8ba031176..a1f9adbbc4 100644 --- a/src/INTEL/npair_halffull_intel.h +++ b/src/INTEL/npair_halffull_intel.h @@ -109,9 +109,9 @@ class NPairHalffullNewtonIntel : public NPair { template void build_t3(NeighList *, int *); }; -class NPairHalffullNewtonTrimIntel : public NPair { +class NPairHalffullTrimNewtonIntel : public NPair { public: - NPairHalffullNewtonTrimIntel(class LAMMPS *); + NPairHalffullTrimNewtonIntel(class LAMMPS *); void build(class NeighList *) override; protected: From bab9fc55335f981e7fe6c41e137d90ef6acc138f Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sat, 9 Dec 2023 22:00:22 -0700 Subject: [PATCH 78/87] Consolidating some skip npair classes --- src/npair_skip.cpp | 33 +++- src/npair_skip.h | 34 +++- src/npair_skip_respa.cpp | 49 ++++- src/npair_skip_respa.h | 14 +- src/npair_skip_size.cpp | 86 --------- src/npair_skip_size.h | 39 ---- src/npair_skip_size_off2on.cpp | 30 ++- src/npair_skip_size_off2on.h | 13 +- src/npair_skip_size_off2on_oneside.cpp | 44 ++++- src/npair_skip_size_off2on_oneside.h | 13 +- src/npair_skip_trim.cpp | 118 ------------ src/npair_skip_trim.h | 46 ----- src/npair_skip_trim_respa.cpp | 193 -------------------- src/npair_skip_trim_respa.h | 40 ---- src/npair_skip_trim_size.cpp | 102 ----------- src/npair_skip_trim_size.h | 39 ---- src/npair_skip_trim_size_off2on.cpp | 112 ------------ src/npair_skip_trim_size_off2on.h | 40 ---- src/npair_skip_trim_size_off2on_oneside.cpp | 185 ------------------- src/npair_skip_trim_size_off2on_oneside.h | 40 ---- 20 files changed, 214 insertions(+), 1056 deletions(-) delete mode 100644 src/npair_skip_size.cpp delete mode 100644 src/npair_skip_size.h delete mode 100644 src/npair_skip_trim.cpp delete mode 100644 src/npair_skip_trim.h delete mode 100644 src/npair_skip_trim_respa.cpp delete mode 100644 src/npair_skip_trim_respa.h delete mode 100644 src/npair_skip_trim_size.cpp delete mode 100644 src/npair_skip_trim_size.h delete mode 100644 src/npair_skip_trim_size_off2on.cpp delete mode 100644 src/npair_skip_trim_size_off2on.h delete mode 100644 src/npair_skip_trim_size_off2on_oneside.cpp delete mode 100644 src/npair_skip_trim_size_off2on_oneside.h diff --git a/src/npair_skip.cpp b/src/npair_skip.cpp index d9d4fa491f..fad06d699c 100644 --- a/src/npair_skip.cpp +++ b/src/npair_skip.cpp @@ -22,7 +22,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairSkip::NPairSkip(LAMMPS *lmp) : NPair(lmp) {} +template +NPairSkipTemp::NPairSkipTemp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- build skip list for subset of types from parent list @@ -32,7 +33,8 @@ NPairSkip::NPairSkip(LAMMPS *lmp) : NPair(lmp) {} if ghost, also store neighbors of ghost atoms & set inum,gnum correctly ------------------------------------------------------------------------- */ -void NPairSkip::build(NeighList *list) +template +void NPairSkipTemp::build(NeighList *list) { int i, j, ii, jj, n, itype, jnum, joriginal; int *neighptr, *jlist; @@ -57,6 +59,11 @@ void NPairSkip::build(NeighList *list) int inum = 0; ipage->reset(); + double **x = atom->x; + double xtmp, ytmp, ztmp; + double delx, dely, delz, rsq; + double cutsq_custom = cutoff_custom * cutoff_custom; + // loop over atoms in other list // skip I atom entirely if iskip is set for type[I] // skip I,J pair if ijskip is set for type[I],type[J] @@ -66,6 +73,12 @@ void NPairSkip::build(NeighList *list) itype = type[i]; if (iskip[itype]) continue; + if (TRIM) { + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + } + n = 0; neighptr = ipage->vget(); @@ -78,6 +91,15 @@ void NPairSkip::build(NeighList *list) joriginal = jlist[jj]; j = joriginal & NEIGHMASK; if (ijskip[itype][type[j]]) continue; + + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; } @@ -100,3 +122,10 @@ void NPairSkip::build(NeighList *list) list->gnum = inum - num; } } + +namespace LAMMPS_NS { +template class NPairSkipTemp<0,0>; +template class NPairSkipTemp<1,0>; +template class NPairSkipTemp<0,1>; +template class NPairSkipTemp<1,1>; +} diff --git a/src/npair_skip.h b/src/npair_skip.h index 4e85174730..06da1be85b 100644 --- a/src/npair_skip.h +++ b/src/npair_skip.h @@ -13,17 +13,46 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairSkipTemp<0, 0> NPairSkip; NPairStyle(skip, NPairSkip, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); +typedef NPairSkipTemp<0, 0> NPairSkip; NPairStyle(skip/ghost, NPairSkip, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST); + +typedef NPairSkipTemp<1, 0> NPairSkipSize; +NPairStyle(skip/half/size, + NPairSkipSize, + NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairSkipTemp<0, 1> NPairSkipTrim; +NPairStyle(skip/trim, + NPairSkipTrim, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); + +typedef NPairSkipTemp<0, 1> NPairSkipTrim; +NPairStyle(skip/ghost/trim, + NPairSkipTrim, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM); + +typedef NPairSkipTemp<1, 1> NPairSkipTrimSize; +NPairStyle(skip/trim/half/size, + NPairSkipTrimSize, + NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); + // clang-format on #else @@ -34,9 +63,10 @@ NPairStyle(skip/ghost, namespace LAMMPS_NS { -class NPairSkip : public NPair { +template +class NPairSkipTemp : public NPair { public: - NPairSkip(class LAMMPS *); + NPairSkipTemp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_skip_respa.cpp b/src/npair_skip_respa.cpp index 81cfc8a767..4c3dda91eb 100644 --- a/src/npair_skip_respa.cpp +++ b/src/npair_skip_respa.cpp @@ -23,7 +23,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairSkipRespa::NPairSkipRespa(LAMMPS *lmp) : NPair(lmp) {} +template +NPairSkipRespaTemp::NPairSkipRespaTemp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- build skip list for subset of types from parent list @@ -31,7 +32,8 @@ NPairSkipRespa::NPairSkipRespa(LAMMPS *lmp) : NPair(lmp) {} this is for respa lists, copy the inner/middle values from parent ------------------------------------------------------------------------- */ -void NPairSkipRespa::build(NeighList *list) +template +void NPairSkipRespaTemp::build(NeighList *list) { int i, j, ii, jj, n, itype, jnum, joriginal, n_inner, n_middle; int *neighptr, *jlist, *neighptr_inner, *neighptr_middle; @@ -76,6 +78,11 @@ void NPairSkipRespa::build(NeighList *list) ipage_inner->reset(); if (respamiddle) ipage_middle->reset(); + double **x = atom->x; + double xtmp, ytmp, ztmp; + double delx, dely, delz, rsq; + double cutsq_custom = cutoff_custom * cutoff_custom; + // loop over atoms in other list // skip I atom entirely if iskip is set for type[I] // skip I,J pair if ijskip is set for type[I],type[J] @@ -85,6 +92,12 @@ void NPairSkipRespa::build(NeighList *list) itype = type[i]; if (iskip[itype]) continue; + if (TRIM) { + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + } + n = n_inner = 0; neighptr = ipage->vget(); neighptr_inner = ipage_inner->vget(); @@ -102,6 +115,15 @@ void NPairSkipRespa::build(NeighList *list) joriginal = jlist[jj]; j = joriginal & NEIGHMASK; if (ijskip[itype][type[j]]) continue; + + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; } @@ -114,6 +136,15 @@ void NPairSkipRespa::build(NeighList *list) joriginal = jlist[jj]; j = joriginal & NEIGHMASK; if (ijskip[itype][type[j]]) continue; + + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + neighptr_inner[n_inner++] = joriginal; } @@ -127,6 +158,15 @@ void NPairSkipRespa::build(NeighList *list) joriginal = jlist[jj]; j = joriginal & NEIGHMASK; if (ijskip[itype][type[j]]) continue; + + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + neighptr_middle[n_middle++] = joriginal; } } @@ -158,3 +198,8 @@ void NPairSkipRespa::build(NeighList *list) list->inum_inner = inum; if (respamiddle) list->inum_middle = inum; } + +namespace LAMMPS_NS { +template class NPairSkipRespaTemp<0>; +template class NPairSkipRespaTemp<1>; +} diff --git a/src/npair_skip_respa.h b/src/npair_skip_respa.h index 822fcc290b..0fa4ece699 100644 --- a/src/npair_skip_respa.h +++ b/src/npair_skip_respa.h @@ -13,11 +13,20 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairSkipRespaTemp<0> NPairSkipRespa; NPairStyle(skip/half/respa, NPairSkipRespa, NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairSkipRespaTemp<0> NPairSkipTrimRespa; +NPairStyle(skip/trim/half/respa, + NPairSkipTrimRespa, + NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); + // clang-format on #else @@ -28,9 +37,10 @@ NPairStyle(skip/half/respa, namespace LAMMPS_NS { -class NPairSkipRespa : public NPair { +template +class NPairSkipRespaTemp : public NPair { public: - NPairSkipRespa(class LAMMPS *); + NPairSkipRespaTemp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_skip_size.cpp b/src/npair_skip_size.cpp deleted file mode 100644 index 22883b4e60..0000000000 --- a/src/npair_skip_size.cpp +++ /dev/null @@ -1,86 +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_skip_size.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipSize::NPairSkipSize(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip -------------------------------------------------------------------------- */ - -void NPairSkipSize::build(NeighList *list) -{ - int i, j, ii, jj, n, itype, jnum, joriginal; - int *neighptr, *jlist; - - int *type = atom->type; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip size list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - neighptr[n++] = joriginal; - } - - 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; -} diff --git a/src/npair_skip_size.h b/src/npair_skip_size.h deleted file mode 100644 index 9c2f23447b..0000000000 --- a/src/npair_skip_size.h +++ /dev/null @@ -1,39 +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 -NPairStyle(skip/half/size, - NPairSkipSize, - NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_SIZE_H -#define LMP_NPAIR_SKIP_SIZE_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipSize : public NPair { - public: - NPairSkipSize(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/npair_skip_size_off2on.cpp b/src/npair_skip_size_off2on.cpp index f1b6d2f4fb..89e633b238 100644 --- a/src/npair_skip_size_off2on.cpp +++ b/src/npair_skip_size_off2on.cpp @@ -22,7 +22,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairSkipSizeOff2on::NPairSkipSizeOff2on(LAMMPS *lmp) : NPair(lmp) {} +template +NPairSkipSizeOff2onTemp::NPairSkipSizeOff2onTemp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- build skip list for subset of types from parent list @@ -30,7 +31,8 @@ NPairSkipSizeOff2on::NPairSkipSizeOff2on(LAMMPS *lmp) : NPair(lmp) {} parent non-skip list used newton off, this skip list is newton on ------------------------------------------------------------------------- */ -void NPairSkipSizeOff2on::build(NeighList *list) +template +void NPairSkipSizeOff2onTemp::build(NeighList *list) { int i, j, ii, jj, n, itype, jnum, joriginal; tagint itag, jtag; @@ -56,6 +58,11 @@ void NPairSkipSizeOff2on::build(NeighList *list) int inum = 0; ipage->reset(); + double **x = atom->x; + double xtmp, ytmp, ztmp; + double delx, dely, delz, rsq; + double cutsq_custom = cutoff_custom * cutoff_custom; + // loop over atoms in other list // skip I atom entirely if iskip is set for type[I] // skip I,J pair if ijskip is set for type[I],type[J] @@ -66,6 +73,12 @@ void NPairSkipSizeOff2on::build(NeighList *list) if (iskip[itype]) continue; itag = tag[i]; + if (TRIM) { + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + } + n = 0; neighptr = ipage->vget(); @@ -84,6 +97,14 @@ void NPairSkipSizeOff2on::build(NeighList *list) jtag = tag[j]; if (j >= nlocal && jtag < itag) continue; + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + neighptr[n++] = joriginal; } @@ -95,3 +116,8 @@ void NPairSkipSizeOff2on::build(NeighList *list) } list->inum = inum; } + +namespace LAMMPS_NS { +template class NPairSkipSizeOff2onTemp<0>; +template class NPairSkipSizeOff2onTemp<1>; +} diff --git a/src/npair_skip_size_off2on.h b/src/npair_skip_size_off2on.h index faed76f6c3..e26d2cdd87 100644 --- a/src/npair_skip_size_off2on.h +++ b/src/npair_skip_size_off2on.h @@ -13,11 +13,19 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairSkipSizeOff2onTemp<0> NPairSkipSizeOff2on; NPairStyle(skip/size/off2on, NPairSkipSizeOff2on, NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairSkipSizeOff2onTemp<0> NPairSkipTrimSizeOff2on; +NPairStyle(skip/trim/size/off2on, + NPairSkipTrimSizeOff2on, + NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); // clang-format on #else @@ -28,9 +36,10 @@ NPairStyle(skip/size/off2on, namespace LAMMPS_NS { -class NPairSkipSizeOff2on : public NPair { +template +class NPairSkipSizeOff2onTemp : public NPair { public: - NPairSkipSizeOff2on(class LAMMPS *); + NPairSkipSizeOff2onTemp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_skip_size_off2on_oneside.cpp b/src/npair_skip_size_off2on_oneside.cpp index 8974da35b2..7682b90d95 100644 --- a/src/npair_skip_size_off2on_oneside.cpp +++ b/src/npair_skip_size_off2on_oneside.cpp @@ -24,7 +24,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -NPairSkipSizeOff2onOneside::NPairSkipSizeOff2onOneside(LAMMPS *lmp) : +template +NPairSkipSizeOff2onOnesideTemp::NPairSkipSizeOff2onOnesideTemp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- @@ -34,7 +35,8 @@ NPairSkipSizeOff2onOneside::NPairSkipSizeOff2onOneside(LAMMPS *lmp) : this skip list is newton on and onesided ------------------------------------------------------------------------- */ -void NPairSkipSizeOff2onOneside::build(NeighList *list) +template +void NPairSkipSizeOff2onOnesideTemp::build(NeighList *list) { int i, j, ii, jj, itype, jnum, joriginal, flip, tmp; int *surf, *jlist; @@ -61,6 +63,11 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) int inum = 0; ipage->reset(); + double **x = atom->x; + double xtmp, ytmp, ztmp; + double delx, dely, delz, rsq; + double cutsq_custom = cutoff_custom * cutoff_custom; + // two loops over parent list required, one to count, one to store // because onesided constraint means pair I,J may be stored with I or J // so don't know in advance how much space to alloc for each atom's neighs @@ -76,6 +83,12 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) itype = type[i]; if (iskip[itype]) continue; + if (TRIM) { + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + } + // loop over parent non-skip size list jlist = firstneigh_skip[i]; @@ -86,6 +99,14 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) j = joriginal & NEIGHMASK; if (ijskip[itype][type[j]]) continue; + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + // flip I,J if necessary to satisfy onesided constraint // do not keep if I is now ghost @@ -121,6 +142,12 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) itype = type[i]; if (iskip[itype]) continue; + if (TRIM) { + xtmp = x[i][0]; + ytmp = x[i][1]; + ztmp = x[i][2]; + } + // loop over parent non-skip size list and optionally its history info jlist = firstneigh_skip[i]; @@ -131,6 +158,14 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) j = joriginal & NEIGHMASK; if (ijskip[itype][type[j]]) continue; + if (TRIM) { + delx = xtmp - x[j][0]; + dely = ytmp - x[j][1]; + delz = ztmp - x[j][2]; + rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) continue; + } + // flip I,J if necessary to satisfy onesided constraint // do not keep if I is now ghost @@ -157,3 +192,8 @@ void NPairSkipSizeOff2onOneside::build(NeighList *list) list->inum = inum; } + +namespace LAMMPS_NS { +template class NPairSkipSizeOff2onOnesideTemp<0>; +template class NPairSkipSizeOff2onOnesideTemp<1>; +} diff --git a/src/npair_skip_size_off2on_oneside.h b/src/npair_skip_size_off2on_oneside.h index 48eccf7faf..a5259ef04b 100644 --- a/src/npair_skip_size_off2on_oneside.h +++ b/src/npair_skip_size_off2on_oneside.h @@ -13,11 +13,19 @@ #ifdef NPAIR_CLASS // clang-format off +typedef NPairSkipSizeOff2onOnesideTemp<0> NPairSkipSizeOff2onOneside; NPairStyle(skip/size/off2on/oneside, NPairSkipSizeOff2onOneside, NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); + +typedef NPairSkipSizeOff2onOnesideTemp<1> NPairSkipTrimSizeOff2onOneside; +NPairStyle(skip/trim/size/off2on/oneside, + NPairSkipTrimSizeOff2onOneside, + NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | + NP_ORTHO | NP_TRI | NP_TRIM); // clang-format on #else @@ -28,9 +36,10 @@ NPairStyle(skip/size/off2on/oneside, namespace LAMMPS_NS { -class NPairSkipSizeOff2onOneside : public NPair { +template +class NPairSkipSizeOff2onOnesideTemp : public NPair { public: - NPairSkipSizeOff2onOneside(class LAMMPS *); + NPairSkipSizeOff2onOnesideTemp(class LAMMPS *); void build(class NeighList *) override; }; diff --git a/src/npair_skip_trim.cpp b/src/npair_skip_trim.cpp deleted file mode 100644 index a286a7e19e..0000000000 --- a/src/npair_skip_trim.cpp +++ /dev/null @@ -1,118 +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_skip_trim.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrim::NPairSkipTrim(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - works for half and full lists - works for owned (non-ghost) list, also for ghost list - iskip and ijskip flag which atom types and type pairs to skip - if ghost, also store neighbors of ghost atoms & set inum,gnum correctly -------------------------------------------------------------------------- */ - -void NPairSkipTrim::build(NeighList *list) -{ - int i, j, ii, jj, n, itype, jnum, joriginal; - int *neighptr, *jlist; - - int *type = atom->type; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int num_skip = list->listskip->inum; - if (list->ghost) num_skip += list->listskip->gnum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - double **x = atom->x; - double xtmp, ytmp, ztmp; - double delx, dely, delz, rsq; - double cutsq_custom = cutoff_custom * cutoff_custom; - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < num_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - neighptr[n++] = joriginal; - } - - 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 (list->ghost) { - int num = 0; - for (i = 0; i < inum; i++) - if (ilist[i] < nlocal) - num++; - else - break; - list->inum = num; - list->gnum = inum - num; - } -} diff --git a/src/npair_skip_trim.h b/src/npair_skip_trim.h deleted file mode 100644 index f2a26d654e..0000000000 --- a/src/npair_skip_trim.h +++ /dev/null @@ -1,46 +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 -NPairStyle(skip/trim, - NPairSkipTrim, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); - -NPairStyle(skip/ghost/trim, - NPairSkipTrim, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_TRIM_H -#define LMP_NPAIR_SKIP_TRIM_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipTrim : public NPair { - public: - NPairSkipTrim(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/npair_skip_trim_respa.cpp b/src/npair_skip_trim_respa.cpp deleted file mode 100644 index 7dd040ca0a..0000000000 --- a/src/npair_skip_trim_respa.cpp +++ /dev/null @@ -1,193 +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_skip_trim_respa.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrimRespa::NPairSkipTrimRespa(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip - this is for respa lists, copy the inner/middle values from parent -------------------------------------------------------------------------- */ - -void NPairSkipTrimRespa::build(NeighList *list) -{ - int i,j,ii,jj,n,itype,jnum,joriginal,n_inner,n_middle; - int *neighptr,*jlist,*neighptr_inner,*neighptr_middle; - - int *type = atom->type; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int *ilist_inner = list->ilist_inner; - int *numneigh_inner = list->numneigh_inner; - int **firstneigh_inner = list->firstneigh_inner; - MyPage *ipage_inner = list->ipage_inner; - int *numneigh_inner_skip = list->listskip->numneigh_inner; - int **firstneigh_inner_skip = list->listskip->firstneigh_inner; - - int *ilist_middle,*numneigh_middle,**firstneigh_middle; - MyPage *ipage_middle; - int *numneigh_middle_skip,**firstneigh_middle_skip; - int respamiddle = list->respamiddle; - if (respamiddle) { - ilist_middle = list->ilist_middle; - numneigh_middle = list->numneigh_middle; - firstneigh_middle = list->firstneigh_middle; - ipage_middle = list->ipage_middle; - numneigh_middle_skip = list->listskip->numneigh_middle; - firstneigh_middle_skip = list->listskip->firstneigh_middle; - } - - int inum = 0; - ipage->reset(); - ipage_inner->reset(); - if (respamiddle) ipage_middle->reset(); - - double **x = atom->x; - double xtmp, ytmp, ztmp; - double delx, dely, delz, rsq; - double cutsq_custom = cutoff_custom * cutoff_custom; - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - n = n_inner = 0; - neighptr = ipage->vget(); - neighptr_inner = ipage_inner->vget(); - if (respamiddle) { - n_middle = 0; - neighptr_middle = ipage_middle->vget(); - } - - // loop over parent outer rRESPA list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - neighptr[n++] = joriginal; - } - - // loop over parent inner rRESPA list - - jlist = firstneigh_inner_skip[i]; - jnum = numneigh_inner_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - neighptr_inner[n_inner++] = joriginal; - } - - // loop over parent middle rRESPA list - - if (respamiddle) { - jlist = firstneigh_middle_skip[i]; - jnum = numneigh_middle_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - neighptr_middle[n_middle++] = joriginal; - } - } - - 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"); - - ilist_inner[inum] = i; - firstneigh_inner[i] = neighptr_inner; - numneigh_inner[i] = n_inner; - ipage_inner->vgot(n); - if (ipage_inner->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - - if (respamiddle) { - ilist_middle[inum] = i; - firstneigh_middle[i] = neighptr_middle; - numneigh_middle[i] = n_middle; - ipage_middle->vgot(n); - if (ipage_middle->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - inum++; - } - - list->inum = inum; - list->inum_inner = inum; - if (respamiddle) list->inum_middle = inum; -} diff --git a/src/npair_skip_trim_respa.h b/src/npair_skip_trim_respa.h deleted file mode 100644 index dcfe71c28d..0000000000 --- a/src/npair_skip_trim_respa.h +++ /dev/null @@ -1,40 +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 -NPairStyle(skip/trim/half/respa, - NPairSkipTrimRespa, - NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_TRIM_RESPA_H -#define LMP_NPAIR_SKIP_TRIM_RESPA_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipTrimRespa : public NPair { - public: - NPairSkipTrimRespa(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/npair_skip_trim_size.cpp b/src/npair_skip_trim_size.cpp deleted file mode 100644 index fab70a78b5..0000000000 --- a/src/npair_skip_trim_size.cpp +++ /dev/null @@ -1,102 +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_skip_trim_size.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrimSize::NPairSkipTrimSize(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip -------------------------------------------------------------------------- */ - -void NPairSkipTrimSize::build(NeighList *list) -{ - int i, j, ii, jj, n, itype, jnum, joriginal; - int *neighptr, *jlist; - - int *type = atom->type; - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - double **x = atom->x; - double xtmp, ytmp, ztmp; - double delx, dely, delz, rsq; - double cutsq_custom = cutoff_custom * cutoff_custom; - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip size list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - neighptr[n++] = joriginal; - } - - 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; -} diff --git a/src/npair_skip_trim_size.h b/src/npair_skip_trim_size.h deleted file mode 100644 index 3b536860ca..0000000000 --- a/src/npair_skip_trim_size.h +++ /dev/null @@ -1,39 +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 -NPairStyle(skip/trim/half/size, - NPairSkipTrimSize, - NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_TRIM_SIZE_H -#define LMP_NPAIR_SKIP_TRIM_SIZE_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipTrimSize : public NPair { - public: - NPairSkipTrimSize(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/npair_skip_trim_size_off2on.cpp b/src/npair_skip_trim_size_off2on.cpp deleted file mode 100644 index 3e9a1e5f63..0000000000 --- a/src/npair_skip_trim_size_off2on.cpp +++ /dev/null @@ -1,112 +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_skip_trim_size_off2on.h" - -#include "atom.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrimSizeOff2on::NPairSkipTrimSizeOff2on(LAMMPS *lmp) : NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip - parent non-skip list used newton off, this skip list is newton on -------------------------------------------------------------------------- */ - -void NPairSkipTrimSizeOff2on::build(NeighList *list) -{ - int i, j, ii, jj, n, itype, jnum, joriginal; - tagint itag, jtag; - int *neighptr, *jlist; - - tagint *tag = atom->tag; - int *type = atom->type; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - int inum = 0; - ipage->reset(); - - double **x = atom->x; - double xtmp, ytmp, ztmp; - double delx, dely, delz, rsq; - double cutsq_custom = cutoff_custom * cutoff_custom; - - // loop over atoms in other list - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - itag = tag[i]; - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - n = 0; - neighptr = ipage->vget(); - - // loop over parent non-skip size list and optionally its history info - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) continue; - - // only keep I,J when J = ghost if Itag < Jtag - - jtag = tag[j]; - if (j >= nlocal && jtag < itag) 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 > cutsq_custom) continue; - - neighptr[n++] = joriginal; - } - - 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; -} diff --git a/src/npair_skip_trim_size_off2on.h b/src/npair_skip_trim_size_off2on.h deleted file mode 100644 index 6e52082329..0000000000 --- a/src/npair_skip_trim_size_off2on.h +++ /dev/null @@ -1,40 +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 -NPairStyle(skip/trim/size/off2on, - NPairSkipTrimSizeOff2on, - NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_TRIM_SIZE_OFF2ON_H -#define LMP_NPAIR_SKIP_TRIM_SIZE_OFF2ON_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipTrimSizeOff2on : public NPair { - public: - NPairSkipTrimSizeOff2on(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif diff --git a/src/npair_skip_trim_size_off2on_oneside.cpp b/src/npair_skip_trim_size_off2on_oneside.cpp deleted file mode 100644 index 9d43ac8087..0000000000 --- a/src/npair_skip_trim_size_off2on_oneside.cpp +++ /dev/null @@ -1,185 +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_skip_trim_size_off2on_oneside.h" - -#include "atom.h" -#include "domain.h" -#include "error.h" -#include "my_page.h" -#include "neigh_list.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrimSizeOff2onOneside::NPairSkipTrimSizeOff2onOneside(LAMMPS *lmp) : - NPair(lmp) {} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - iskip and ijskip flag which atom types and type pairs to skip - parent non-skip list used newton off and was not onesided, - this skip list is newton on and onesided -------------------------------------------------------------------------- */ - -void NPairSkipTrimSizeOff2onOneside::build(NeighList *list) -{ - int i,j,ii,jj,itype,jnum,joriginal,flip,tmp; - int *surf,*jlist; - - int *type = atom->type; - int nlocal = atom->nlocal; - - int *ilist = list->ilist; - int *numneigh = list->numneigh; - int **firstneigh = list->firstneigh; - MyPage *ipage = list->ipage; - - int *ilist_skip = list->listskip->ilist; - int *numneigh_skip = list->listskip->numneigh; - int **firstneigh_skip = list->listskip->firstneigh; - int inum_skip = list->listskip->inum; - - int *iskip = list->iskip; - int **ijskip = list->ijskip; - - if (domain->dimension == 2) surf = atom->line; - else surf = atom->tri; - - int inum = 0; - ipage->reset(); - - double **x = atom->x; - double xtmp, ytmp, ztmp; - double delx, dely, delz, rsq; - double cutsq_custom = cutoff_custom * cutoff_custom; - - // two loops over parent list required, one to count, one to store - // because onesided constraint means pair I,J may be stored with I or J - // so don't know in advance how much space to alloc for each atom's neighs - - // first loop over atoms in other list to count neighbors - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (i = 0; i < nlocal; i++) numneigh[i] = 0; - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - // loop over parent non-skip size list - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - // flip I,J if necessary to satisfy onesided constraint - // do not keep if I is now ghost - - if (surf[i] >= 0) { - if (j >= nlocal) continue; - tmp = i; - i = j; - j = tmp; - flip = 1; - } else flip = 0; - - numneigh[i]++; - if (flip) i = j; - } - } - - // allocate all per-atom neigh list chunks - - for (i = 0; i < nlocal; i++) { - if (numneigh[i] == 0) continue; - firstneigh[i] = ipage->get(numneigh[i]); - if (ipage->status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - // second loop over atoms in other list to store neighbors - // skip I atom entirely if iskip is set for type[I] - // skip I,J pair if ijskip is set for type[I],type[J] - - for (i = 0; i < nlocal; i++) numneigh[i] = 0; - - for (ii = 0; ii < inum_skip; ii++) { - i = ilist_skip[ii]; - itype = type[i]; - if (iskip[itype]) continue; - - xtmp = x[i][0]; - ytmp = x[i][1]; - ztmp = x[i][2]; - - // loop over parent non-skip size list and optionally its history info - - jlist = firstneigh_skip[i]; - jnum = numneigh_skip[i]; - - for (jj = 0; jj < jnum; jj++) { - joriginal = jlist[jj]; - j = joriginal & NEIGHMASK; - if (ijskip[itype][type[j]]) 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 > cutsq_custom) continue; - - // flip I,J if necessary to satisfy onesided constraint - // do not keep if I is now ghost - - if (surf[i] >= 0) { - if (j >= nlocal) continue; - tmp = i; - i = j; - j = tmp; - flip = 1; - } else flip = 0; - - // store j in neigh list, not joriginal, like other neigh methods - // OK, b/c there is no special list flagging for surfs - - firstneigh[i][numneigh[i]] = j; - numneigh[i]++; - if (flip) i = j; - } - - // only add atom I to ilist if it has neighbors - - if (numneigh[i]) ilist[inum++] = i; - } - - list->inum = inum; -} diff --git a/src/npair_skip_trim_size_off2on_oneside.h b/src/npair_skip_trim_size_off2on_oneside.h deleted file mode 100644 index 27861123dd..0000000000 --- a/src/npair_skip_trim_size_off2on_oneside.h +++ /dev/null @@ -1,40 +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 -NPairStyle(skip/trim/size/off2on/oneside, - NPairSkipTrimSizeOff2onOneside, - NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI | NP_TRIM); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_TRIM_SIZE_OFF2ON_ONESIDE_H -#define LMP_NPAIR_SKIP_TRIM_SIZE_OFF2ON_ONESIDE_H - -#include "npair.h" - -namespace LAMMPS_NS { - -class NPairSkipTrimSizeOff2onOneside : public NPair { - public: - NPairSkipTrimSizeOff2onOneside(class LAMMPS *); - void build(class NeighList *) override; -}; - -} // namespace LAMMPS_NS - -#endif -#endif From 7c4017018233fc7f851889656b974651f4f0dc21 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Sun, 10 Dec 2023 21:37:13 -0700 Subject: [PATCH 79/87] Fixing errors in headers --- src/OPENMP/npair_skip_omp.h | 36 +++++++++++++++++++++ src/OPENMP/npair_skip_trim_omp.h | 55 -------------------------------- src/npair_skip_respa.h | 2 +- src/npair_skip_size_off2on.h | 2 +- 4 files changed, 38 insertions(+), 57 deletions(-) delete mode 100644 src/OPENMP/npair_skip_trim_omp.h diff --git a/src/OPENMP/npair_skip_omp.h b/src/OPENMP/npair_skip_omp.h index ce61968c17..937304ad3f 100644 --- a/src/OPENMP/npair_skip_omp.h +++ b/src/OPENMP/npair_skip_omp.h @@ -16,6 +16,7 @@ #ifdef NPAIR_CLASS // clang-format off + NPairStyle(skip/omp, NPairSkip, NP_SKIP | NP_HALF | NP_FULL | @@ -50,6 +51,41 @@ NPairStyle(skip/ghost/omp, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_OMP | NP_GHOST); + +NPairStyle(skip/trim/omp, + NPairSkipTrim, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +NPairStyle(skip/trim/half/respa/omp, + NPairSkipTrimRespa, + NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +NPairStyle(skip/trim/half/size/omp, + NPairSkipTrimSize, + NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +NPairStyle(skip/trim/size/off2on/omp, + NPairSkipTrimSizeOff2on, + NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +NPairStyle(skip/trim/size/off2on/oneside/omp, + NPairSkipTrimSizeOff2onOneside, + NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | + NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); + +NPairStyle(skip/trim/ghost/omp, + NPairSkipTrim, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP | NP_GHOST); // clang-format off #endif diff --git a/src/OPENMP/npair_skip_trim_omp.h b/src/OPENMP/npair_skip_trim_omp.h deleted file mode 100644 index aba6f50e17..0000000000 --- a/src/OPENMP/npair_skip_trim_omp.h +++ /dev/null @@ -1,55 +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. -------------------------------------------------------------------------- */ - -// There is no benefit from multi-threading for skip lists, so we -// just forward the requests to the corresponding non-omp versions. - -#ifdef NPAIR_CLASS -// clang-format off -NPairStyle(skip/trim/omp, - NPairSkipTrim, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); - -NPairStyle(skip/trim/half/respa/omp, - NPairSkipTrimRespa, - NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); - -NPairStyle(skip/trim/half/size/omp, - NPairSkipTrimSize, - NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); - -NPairStyle(skip/trim/size/off2on/omp, - NPairSkipTrimSizeOff2on, - NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); - -NPairStyle(skip/trim/size/off2on/oneside/omp, - NPairSkipTrimSizeOff2onOneside, - NP_SKIP | NP_SIZE | NP_OFF2ON | NP_ONESIDE | NP_HALF | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | - NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP); - -NPairStyle(skip/trim/ghost/omp, - NPairSkipTrim, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_OMP | NP_GHOST); -// clang-format off -#endif - diff --git a/src/npair_skip_respa.h b/src/npair_skip_respa.h index 0fa4ece699..af25e84faf 100644 --- a/src/npair_skip_respa.h +++ b/src/npair_skip_respa.h @@ -20,7 +20,7 @@ NPairStyle(skip/half/respa, NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairSkipRespaTemp<0> NPairSkipTrimRespa; +typedef NPairSkipRespaTemp<1> NPairSkipTrimRespa; NPairStyle(skip/trim/half/respa, NPairSkipTrimRespa, NP_SKIP | NP_RESPA | NP_HALF | NP_FULL | diff --git a/src/npair_skip_size_off2on.h b/src/npair_skip_size_off2on.h index e26d2cdd87..b86100ae20 100644 --- a/src/npair_skip_size_off2on.h +++ b/src/npair_skip_size_off2on.h @@ -20,7 +20,7 @@ NPairStyle(skip/size/off2on, NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairSkipSizeOff2onTemp<0> NPairSkipTrimSizeOff2on; +typedef NPairSkipSizeOff2onTemp<1> NPairSkipTrimSizeOff2on; NPairStyle(skip/trim/size/off2on, NPairSkipTrimSizeOff2on, NP_SKIP | NP_SIZE | NP_OFF2ON | NP_HALF | From af74afdf629a08110f0793e3c0b0e7088a71c508 Mon Sep 17 00:00:00 2001 From: jtclemm Date: Mon, 11 Dec 2023 09:02:55 -0700 Subject: [PATCH 80/87] Editing intel files (to be templated) --- src/INTEL/npair_skip_intel.cpp | 243 ++++++++++++++++++++++++- src/INTEL/npair_skip_intel.h | 28 +++ src/INTEL/npair_skip_trim_intel.cpp | 271 ---------------------------- src/INTEL/npair_skip_trim_intel.h | 62 ------- 4 files changed, 270 insertions(+), 334 deletions(-) delete mode 100644 src/INTEL/npair_skip_trim_intel.cpp delete mode 100644 src/INTEL/npair_skip_trim_intel.h diff --git a/src/INTEL/npair_skip_intel.cpp b/src/INTEL/npair_skip_intel.cpp index b023955dd9..8840f7ee43 100644 --- a/src/INTEL/npair_skip_intel.cpp +++ b/src/INTEL/npair_skip_intel.cpp @@ -13,7 +13,7 @@ ------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- - Contributing author: W. Michael Brown (Intel) + Contributing author: W. Michael Brown (Intel), Stan Moore (SNL) ------------------------------------------------------------------------- */ #include "npair_skip_intel.h" @@ -224,3 +224,244 @@ void NPairSkipIntel::build(NeighList *list) } } } + +/* ---------------------------------------------------------------------- */ + +NPairSkipTrimIntel::NPairSkipTrimIntel(LAMMPS *lmp) : NPair(lmp) { + _fix = static_cast(modify->get_fix_by_id("package_intel")); + if (!_fix) error->all(FLERR, "The 'package intel' command is required for /intel styles"); + _inum_starts = new int[comm->nthreads]; + _inum_counts = new int[comm->nthreads]; + _full_props = nullptr; +} + +/* ---------------------------------------------------------------------- */ + +NPairSkipTrimIntel::~NPairSkipTrimIntel() { + delete []_inum_starts; + delete []_inum_counts; + delete[] _full_props; +} + +/* ---------------------------------------------------------------------- */ + +void NPairSkipTrimIntel::copy_neighbor_info() +{ + NPair::copy_neighbor_info(); + // Only need to set _full_props once; npair object deleted for changes + if (_full_props) return; + _full_props = new int[neighbor->nrequest]; + for (int i = 0; i < neighbor->nrequest; i++) + _full_props[i] = neighbor->requests[i]->full; +} + +/* ---------------------------------------------------------------------- + build skip list for subset of types from parent list + works for half and full lists + works for owned (non-ghost) list, also for ghost list + iskip and ijskip flag which atom types and type pairs to skip + if ghost, also store neighbors of ghost atoms & set inum,gnum correctly +------------------------------------------------------------------------- */ + +template +void NPairSkipTrimIntel::build_t(NeighList *list, int *numhalf, int *cnumneigh, + int *numhalf_skip, IntelBuffers *buffers) +{ + const int nlocal = atom->nlocal; + const int e_nall = nlocal + atom->nghost; + const ATOM_T * _noalias const x = buffers->get_x(); + const int * _noalias const type = atom->type; + int * _noalias const ilist = list->ilist; + int * _noalias const numneigh = list->numneigh; + int ** _noalias const firstneigh = (int ** const)list->firstneigh; // NOLINT + const int * _noalias const ilist_skip = list->listskip->ilist; + const int * _noalias const numneigh_skip = list->listskip->numneigh; + const int ** _noalias const firstneigh_skip = (const int ** const)list->listskip->firstneigh; // NOLINT + const int * _noalias const iskip = list->iskip; + const int ** _noalias const ijskip = (const int ** const)list->ijskip; // NOLINT + + const flt_t cutsq_custom = cutoff_custom * cutoff_custom; + int num_skip = list->listskip->inum; + if (list->ghost) num_skip += list->listskip->gnum; + + int packthreads; + if (comm->nthreads > INTEL_HTHREADS && THREE==0) + packthreads = comm->nthreads; + else + packthreads = 1; + + #if defined(_OPENMP) + #pragma omp parallel if (packthreads > 1) + #endif + { + int tid, ifrom, ito; + IP_PRE_omp_range_id(ifrom, ito, tid, num_skip, packthreads); + + // each thread has its own page allocator + MyPage &ipage = list->ipage[tid]; + ipage.reset(); + + int my_inum = ifrom; + _inum_starts[tid] = ifrom; + + // loop over parent full list + for (int ii = ifrom; ii < ito; ii++) { + const int i = ilist_skip[ii]; + const int itype = type[i]; + if (iskip[itype]) continue; + + const flt_t xtmp = x[i].x; + const flt_t ytmp = x[i].y; + const flt_t ztmp = x[i].z; + + int n = 0; + int *neighptr = ipage.vget(); + + // loop over parent non-skip list + + const int * _noalias const jlist = firstneigh_skip[i]; + const int jnum = numneigh_skip[i]; + + if (THREE) { + const int jnumhalf = numhalf_skip[ii]; + for (int jj = 0; jj < jnumhalf; jj++) { + const int joriginal = jlist[jj]; + const int j = joriginal & NEIGHMASK; + + int addme = 1; + if (ijskip[itype][type[j]]) addme = 0; + + // trim to shorter cutoff + + const flt_t delx = xtmp - x[j].x; + const flt_t dely = ytmp - x[j].y; + const flt_t delz = ztmp - x[j].z; + const flt_t rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) addme = 0; + + if (addme) + neighptr[n++] = joriginal; + } + numhalf[my_inum] = n; + + for (int jj = jnumhalf; jj < jnum; jj++) { + const int joriginal = jlist[jj]; + const int j = joriginal & NEIGHMASK; + + int addme = 1; + if (ijskip[itype][type[j]]) addme = 0; + + // trim to shorter cutoff + + const flt_t delx = xtmp - x[j].x; + const flt_t dely = ytmp - x[j].y; + const flt_t delz = ztmp - x[j].z; + const flt_t rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) addme = 0; + + if (addme) + neighptr[n++] = joriginal; + } + } else { + #if defined(LMP_SIMD_COMPILER) + #pragma vector aligned + #pragma ivdep + #endif + for (int jj = 0; jj < jnum; jj++) { + const int joriginal = jlist[jj]; + const int j = joriginal & NEIGHMASK; + + int addme = 1; + if (ijskip[itype][type[j]]) addme = 0; + + // trim to shorter cutoff + + const flt_t delx = xtmp - x[j].x; + const flt_t dely = ytmp - x[j].y; + const flt_t delz = ztmp - x[j].z; + const flt_t rsq = delx * delx + dely * dely + delz * delz; + if (rsq > cutsq_custom) addme = 0; + + if (addme) + neighptr[n++] = joriginal; + } + } + + ilist[my_inum++] = i; + firstneigh[i] = neighptr; + numneigh[i] = n; + + int pad_end = n; + IP_PRE_neighbor_pad(pad_end, 0); + #if defined(LMP_SIMD_COMPILER) + #pragma vector aligned + #pragma loop_count min=1, max=INTEL_COMPILE_WIDTH-1, \ + avg=INTEL_COMPILE_WIDTH/2 + #endif + for ( ; n < pad_end; n++) + neighptr[n] = e_nall; + + ipage.vgot(n); + if (ipage.status()) + error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); + } + + int last_inum = 0, loop_end; + _inum_counts[tid] = my_inum; + } + int inum = _inum_counts[0]; + for (int tid = 1; tid < packthreads; tid++) { + for (int i = _inum_starts[tid]; i < _inum_counts[tid]; i++) { + if (THREE) numhalf[inum] = numhalf[i]; + ilist[inum++] = ilist[i]; + } + } + list->inum = inum; + + if (THREE && num_skip > 0) { + int * const list_start = firstneigh[ilist[0]]; + for (int ii = 0; ii < inum; ii++) { + int i = ilist[ii]; + cnumneigh[ii] = static_cast(firstneigh[i] - list_start); + } + } + if (list->ghost) { + int num = 0; + int my_inum = list->inum; + for (int i = 0; i < my_inum; i++) + if (ilist[i] < nlocal) num++; + else break; + list->inum = num; + list->gnum = my_inum - num; + } +} + +/* ---------------------------------------------------------------------- */ + +void NPairSkipTrimIntel::build(NeighList *list) +{ + if (_fix->three_body_neighbor()==0 || + _full_props[list->listskip->index] == 0) { + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) + build_t(list, nullptr, nullptr, nullptr, _fix->get_mixed_buffers()); + else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) + build_t(list, nullptr, nullptr, nullptr, _fix->get_double_buffers()); + else + build_t(list, nullptr, nullptr, nullptr, _fix->get_single_buffers()); + } else { + int *nhalf, *cnumneigh, *nhalf_skip, *u; + if (_fix->precision() == FixIntel::PREC_MODE_MIXED) { + _fix->get_mixed_buffers()->get_list_data3(list->listskip,nhalf_skip,u); + _fix->get_mixed_buffers()->grow_data3(list, nhalf, cnumneigh); + build_t(list, nhalf, cnumneigh, nhalf_skip, _fix->get_mixed_buffers()); + } else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) { + _fix->get_double_buffers()->get_list_data3(list->listskip,nhalf_skip,u); + _fix->get_double_buffers()->grow_data3(list, nhalf, cnumneigh); + build_t(list, nhalf, cnumneigh, nhalf_skip, _fix->get_double_buffers()); + } else { + _fix->get_single_buffers()->get_list_data3(list->listskip,nhalf_skip,u); + _fix->get_single_buffers()->grow_data3(list,nhalf,cnumneigh); + build_t(list, nhalf, cnumneigh, nhalf_skip, _fix->get_single_buffers()); + } + } +} diff --git a/src/INTEL/npair_skip_intel.h b/src/INTEL/npair_skip_intel.h index d38173895a..993f64bf96 100644 --- a/src/INTEL/npair_skip_intel.h +++ b/src/INTEL/npair_skip_intel.h @@ -25,6 +25,18 @@ NPairStyle(skip/ghost/intel, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST | NP_INTEL); + +NPairStyle(skip/trim/intel, + NPairSkipTrimIntel, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_INTEL); + +NPairStyle(skip/trim/ghost/intel, + NPairSkipTrimIntel, + NP_SKIP | NP_HALF | NP_FULL | + NP_NSQ | NP_BIN | NP_MULTI | + NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_GHOST | NP_INTEL); // clang-format on #else @@ -55,6 +67,22 @@ class NPairSkipIntel : public NPair { void build_t(NeighList *, int *numhalf, int *cnumneigh, int *numhalf_skip); }; +class NPairSkipTrimIntel : public NPair { + public: + NPairSkipTrimIntel(class LAMMPS *); + ~NPairSkipTrimIntel() override; + void copy_neighbor_info() override; + void build(class NeighList *) override; + + protected: + FixIntel *_fix; + int *_inum_starts, *_inum_counts, *_full_props; + + template + void build_t(NeighList *, int *numhalf, int *cnumneigh, int *numhalf_skip, + IntelBuffers *); +}; + } // namespace LAMMPS_NS #endif diff --git a/src/INTEL/npair_skip_trim_intel.cpp b/src/INTEL/npair_skip_trim_intel.cpp deleted file mode 100644 index e16e1bc413..0000000000 --- a/src/INTEL/npair_skip_trim_intel.cpp +++ /dev/null @@ -1,271 +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. -------------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- - Contributing author: Stan Moore (SNL) -------------------------------------------------------------------------- */ - -#include "npair_skip_trim_intel.h" - -#include "atom.h" -#include "comm.h" -#include "error.h" -#include "modify.h" -#include "my_page.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "neighbor.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrimIntel::NPairSkipTrimIntel(LAMMPS *lmp) : NPair(lmp) { - _fix = static_cast(modify->get_fix_by_id("package_intel")); - if (!_fix) error->all(FLERR, "The 'package intel' command is required for /intel styles"); - _inum_starts = new int[comm->nthreads]; - _inum_counts = new int[comm->nthreads]; - _full_props = nullptr; -} - -/* ---------------------------------------------------------------------- */ - -NPairSkipTrimIntel::~NPairSkipTrimIntel() { - delete []_inum_starts; - delete []_inum_counts; - delete[] _full_props; -} - -/* ---------------------------------------------------------------------- */ - -void NPairSkipTrimIntel::copy_neighbor_info() -{ - NPair::copy_neighbor_info(); - // Only need to set _full_props once; npair object deleted for changes - if (_full_props) return; - _full_props = new int[neighbor->nrequest]; - for (int i = 0; i < neighbor->nrequest; i++) - _full_props[i] = neighbor->requests[i]->full; -} - -/* ---------------------------------------------------------------------- - build skip list for subset of types from parent list - works for half and full lists - works for owned (non-ghost) list, also for ghost list - iskip and ijskip flag which atom types and type pairs to skip - if ghost, also store neighbors of ghost atoms & set inum,gnum correctly -------------------------------------------------------------------------- */ - -template -void NPairSkipTrimIntel::build_t(NeighList *list, int *numhalf, int *cnumneigh, - int *numhalf_skip, IntelBuffers *buffers) -{ - const int nlocal = atom->nlocal; - const int e_nall = nlocal + atom->nghost; - const ATOM_T * _noalias const x = buffers->get_x(); - const int * _noalias const type = atom->type; - int * _noalias const ilist = list->ilist; - int * _noalias const numneigh = list->numneigh; - int ** _noalias const firstneigh = (int ** const)list->firstneigh; // NOLINT - const int * _noalias const ilist_skip = list->listskip->ilist; - const int * _noalias const numneigh_skip = list->listskip->numneigh; - const int ** _noalias const firstneigh_skip = (const int ** const)list->listskip->firstneigh; // NOLINT - const int * _noalias const iskip = list->iskip; - const int ** _noalias const ijskip = (const int ** const)list->ijskip; // NOLINT - - const flt_t cutsq_custom = cutoff_custom * cutoff_custom; - int num_skip = list->listskip->inum; - if (list->ghost) num_skip += list->listskip->gnum; - - int packthreads; - if (comm->nthreads > INTEL_HTHREADS && THREE==0) - packthreads = comm->nthreads; - else - packthreads = 1; - - #if defined(_OPENMP) - #pragma omp parallel if (packthreads > 1) - #endif - { - int tid, ifrom, ito; - IP_PRE_omp_range_id(ifrom, ito, tid, num_skip, packthreads); - - // each thread has its own page allocator - MyPage &ipage = list->ipage[tid]; - ipage.reset(); - - int my_inum = ifrom; - _inum_starts[tid] = ifrom; - - // loop over parent full list - for (int ii = ifrom; ii < ito; ii++) { - const int i = ilist_skip[ii]; - const int itype = type[i]; - if (iskip[itype]) continue; - - const flt_t xtmp = x[i].x; - const flt_t ytmp = x[i].y; - const flt_t ztmp = x[i].z; - - int n = 0; - int *neighptr = ipage.vget(); - - // loop over parent non-skip list - - const int * _noalias const jlist = firstneigh_skip[i]; - const int jnum = numneigh_skip[i]; - - if (THREE) { - const int jnumhalf = numhalf_skip[ii]; - for (int jj = 0; jj < jnumhalf; jj++) { - const int joriginal = jlist[jj]; - const int j = joriginal & NEIGHMASK; - - int addme = 1; - if (ijskip[itype][type[j]]) addme = 0; - - // trim to shorter cutoff - - const flt_t delx = xtmp - x[j].x; - const flt_t dely = ytmp - x[j].y; - const flt_t delz = ztmp - x[j].z; - const flt_t rsq = delx * delx + dely * dely + delz * delz; - if (rsq > cutsq_custom) addme = 0; - - if (addme) - neighptr[n++] = joriginal; - } - numhalf[my_inum] = n; - - for (int jj = jnumhalf; jj < jnum; jj++) { - const int joriginal = jlist[jj]; - const int j = joriginal & NEIGHMASK; - - int addme = 1; - if (ijskip[itype][type[j]]) addme = 0; - - // trim to shorter cutoff - - const flt_t delx = xtmp - x[j].x; - const flt_t dely = ytmp - x[j].y; - const flt_t delz = ztmp - x[j].z; - const flt_t rsq = delx * delx + dely * dely + delz * delz; - if (rsq > cutsq_custom) addme = 0; - - if (addme) - neighptr[n++] = joriginal; - } - } else { - #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma ivdep - #endif - for (int jj = 0; jj < jnum; jj++) { - const int joriginal = jlist[jj]; - const int j = joriginal & NEIGHMASK; - - int addme = 1; - if (ijskip[itype][type[j]]) addme = 0; - - // trim to shorter cutoff - - const flt_t delx = xtmp - x[j].x; - const flt_t dely = ytmp - x[j].y; - const flt_t delz = ztmp - x[j].z; - const flt_t rsq = delx * delx + dely * dely + delz * delz; - if (rsq > cutsq_custom) addme = 0; - - if (addme) - neighptr[n++] = joriginal; - } - } - - ilist[my_inum++] = i; - firstneigh[i] = neighptr; - numneigh[i] = n; - - int pad_end = n; - IP_PRE_neighbor_pad(pad_end, 0); - #if defined(LMP_SIMD_COMPILER) - #pragma vector aligned - #pragma loop_count min=1, max=INTEL_COMPILE_WIDTH-1, \ - avg=INTEL_COMPILE_WIDTH/2 - #endif - for ( ; n < pad_end; n++) - neighptr[n] = e_nall; - - ipage.vgot(n); - if (ipage.status()) - error->one(FLERR,"Neighbor list overflow, boost neigh_modify one"); - } - - int last_inum = 0, loop_end; - _inum_counts[tid] = my_inum; - } - int inum = _inum_counts[0]; - for (int tid = 1; tid < packthreads; tid++) { - for (int i = _inum_starts[tid]; i < _inum_counts[tid]; i++) { - if (THREE) numhalf[inum] = numhalf[i]; - ilist[inum++] = ilist[i]; - } - } - list->inum = inum; - - if (THREE && num_skip > 0) { - int * const list_start = firstneigh[ilist[0]]; - for (int ii = 0; ii < inum; ii++) { - int i = ilist[ii]; - cnumneigh[ii] = static_cast(firstneigh[i] - list_start); - } - } - if (list->ghost) { - int num = 0; - int my_inum = list->inum; - for (int i = 0; i < my_inum; i++) - if (ilist[i] < nlocal) num++; - else break; - list->inum = num; - list->gnum = my_inum - num; - } -} - -/* ---------------------------------------------------------------------- */ - -void NPairSkipTrimIntel::build(NeighList *list) -{ - if (_fix->three_body_neighbor()==0 || - _full_props[list->listskip->index] == 0) { - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) - build_t(list, nullptr, nullptr, nullptr, _fix->get_mixed_buffers()); - else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) - build_t(list, nullptr, nullptr, nullptr, _fix->get_double_buffers()); - else - build_t(list, nullptr, nullptr, nullptr, _fix->get_single_buffers()); - } else { - int *nhalf, *cnumneigh, *nhalf_skip, *u; - if (_fix->precision() == FixIntel::PREC_MODE_MIXED) { - _fix->get_mixed_buffers()->get_list_data3(list->listskip,nhalf_skip,u); - _fix->get_mixed_buffers()->grow_data3(list, nhalf, cnumneigh); - build_t(list, nhalf, cnumneigh, nhalf_skip, _fix->get_mixed_buffers()); - } else if (_fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - _fix->get_double_buffers()->get_list_data3(list->listskip,nhalf_skip,u); - _fix->get_double_buffers()->grow_data3(list, nhalf, cnumneigh); - build_t(list, nhalf, cnumneigh, nhalf_skip, _fix->get_double_buffers()); - } else { - _fix->get_single_buffers()->get_list_data3(list->listskip,nhalf_skip,u); - _fix->get_single_buffers()->grow_data3(list,nhalf,cnumneigh); - build_t(list, nhalf, cnumneigh, nhalf_skip, _fix->get_single_buffers()); - } - } -} diff --git a/src/INTEL/npair_skip_trim_intel.h b/src/INTEL/npair_skip_trim_intel.h deleted file mode 100644 index f0018e5df4..0000000000 --- a/src/INTEL/npair_skip_trim_intel.h +++ /dev/null @@ -1,62 +0,0 @@ -// clang-format off -/* -*- 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 -NPairStyle(skip/trim/intel, - NPairSkipTrimIntel, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_INTEL); - -NPairStyle(skip/trim/ghost/intel, - NPairSkipTrimIntel, - NP_SKIP | NP_HALF | NP_FULL | - NP_NSQ | NP_BIN | NP_MULTI | - NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM | NP_GHOST | NP_INTEL); -// clang-format on -#else - -#ifndef LMP_NPAIR_SKIP_TRIM_INTEL_H -#define LMP_NPAIR_SKIP_TRIM_INTEL_H - -#include "fix_intel.h" -#include "npair.h" - -#if defined(_OPENMP) -#include -#endif - -namespace LAMMPS_NS { - -class NPairSkipTrimIntel : public NPair { - public: - NPairSkipTrimIntel(class LAMMPS *); - ~NPairSkipTrimIntel() override; - void copy_neighbor_info() override; - void build(class NeighList *) override; - - protected: - FixIntel *_fix; - int *_inum_starts, *_inum_counts, *_full_props; - - template - void build_t(NeighList *, int *numhalf, int *cnumneigh, int *numhalf_skip, - IntelBuffers *); -}; - -} // namespace LAMMPS_NS - -#endif -#endif From e241f08cfe3c24a49d46cf9e7515b4db335406e4 Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 11 Dec 2023 14:05:42 -0700 Subject: [PATCH 81/87] Finish first version of compute reaxff/atom docs --- doc/src/compute.rst | 1 + doc/src/compute_reaxff_atom.rst | 38 ++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/doc/src/compute.rst b/doc/src/compute.rst index 6737203618..6ef093c16d 100644 --- a/doc/src/compute.rst +++ b/doc/src/compute.rst @@ -280,6 +280,7 @@ The individual style names on the :doc:`Commands compute ` pag * :doc:`property/local ` - convert local attributes to local vectors/arrays * :doc:`ptm/atom ` - determines the local lattice structure based on the Polyhedral Template Matching method * :doc:`rdf ` - radial distribution function :math:`g(r)` histogram of group of atoms +* :doc:`reaxff/atom ` - extract ReaxFF bond information * :doc:`reduce ` - combine per-atom quantities into a single global value * :doc:`reduce/chunk ` - reduce per-atom quantities within each chunk * :doc:`reduce/region ` - same as compute reduce, within a region diff --git a/doc/src/compute_reaxff_atom.rst b/doc/src/compute_reaxff_atom.rst index 4906f3fe5c..9f690d19c3 100644 --- a/doc/src/compute_reaxff_atom.rst +++ b/doc/src/compute_reaxff_atom.rst @@ -1,8 +1,8 @@ -.. index:: fix reaxff/atom -.. index:: fix reaxff/atom/kk +.. index:: compute reaxff/atom +.. index:: compute reaxff/atom/kk -fix reaxff/atom command -======================= +compute reaxff/atom command +=========================== Accelerator Variants: *reaxff/atom/kk* @@ -40,7 +40,35 @@ Examples Description """"""""""" -TODO +Define a computation that extracts bond information computed by the ReaxFF +potential specified by :doc:`pair_style reaxff `. + +By default, it produces per-atom data that includes the following columns: + +* abo = atom bond order (sum of all bonds) +* nlp = number of lone pairs +* nb = number of bonds + +Bonds will only be included if its atoms are in the group. + +In addition, if ``bonds`` is set to ``yes``, the compute will also produce a +local array of all bonds on the current processor whose atoms are in the group. +The columns of each entry of this local array are: + +* id_i = atom i id of bond +* id_j = atom j id of bond +* bo = bond order of bond + +Output info +""""""""""" + +This compute calculates a per-atom array and local array depending on the +number of keywords. The number of rows in the local array is the number of +bonds as described above. Both per-atom and local array have 3 columns. + +The arrays can be accessed by any command that uses local and per-atom values +from a compute as input. See the :doc:`Howto output ` page for +an overview of LAMMPS output options. ---------- From 930fbe8c5df277cb0aa1195a5a7ad031a2585a5c Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Mon, 11 Dec 2023 14:07:48 -0700 Subject: [PATCH 82/87] reaxff/atom: First attempt of filtering by group --- src/KOKKOS/compute_reaxff_atom_kokkos.cpp | 4 +-- src/KOKKOS/pair_reaxff_kokkos.cpp | 37 +++++++++++++---------- src/KOKKOS/pair_reaxff_kokkos.h | 10 +++--- src/REAXFF/compute_reaxff_atom.cpp | 31 +++++++++++-------- 4 files changed, 47 insertions(+), 35 deletions(-) diff --git a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp index c703bc3552..c3e9367ff4 100644 --- a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp @@ -82,9 +82,9 @@ void ComputeReaxFFAtomKokkos::compute_bonds() int maxnumbonds = 0; if (reaxff->execution_space == Device) - device_pair()->FindBond(maxnumbonds); + device_pair()->FindBond(maxnumbonds, groupbit); else - host_pair()->FindBond(maxnumbonds); + host_pair()->FindBond(maxnumbonds, groupbit); nbuf = ((store_bonds ? maxnumbonds*2 : 0) + 3)*nlocal; diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 914962f0e6..29ac398128 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4162,22 +4162,23 @@ double PairReaxFFKokkos::memory_usage() /* ---------------------------------------------------------------------- */ template -void PairReaxFFKokkos::FindBond(int &numbonds) +void PairReaxFFKokkos::FindBond(int &numbonds, int groupbit) { copymode = 1; Kokkos::parallel_for(Kokkos::RangePolicy(0,nmax),*this); bo_cut_bond = api->control->bg_cut; - atomKK->sync(execution_space,TAG_MASK); + atomKK->sync(execution_space,TAG_MASK|MASK_MASK); tag = atomKK->k_tag.view(); + mask = atomKK->k_mask.view(); const int inum = list->inum; NeighListKokkos* k_list = static_cast*>(list); d_ilist = k_list->d_ilist; numbonds = 0; - PairReaxKokkosFindBondFunctor find_bond_functor(this); + PairReaxKokkosFindBondFunctor find_bond_functor(this, groupbit); Kokkos::parallel_reduce(inum,find_bond_functor,numbonds); copymode = 0; } @@ -4194,24 +4195,28 @@ void PairReaxFFKokkos::operator()(TagPairReaxFindBondZero, const int template KOKKOS_INLINE_FUNCTION -void PairReaxFFKokkos::calculate_find_bond_item(int ii, int &numbonds) const +void PairReaxFFKokkos::calculate_find_bond_item(int ii, int &numbonds, int groupbit) const { const int i = d_ilist[ii]; int nj = 0; - const int j_start = d_bo_first[i]; - const int j_end = j_start + d_bo_num[i]; - for (int jj = j_start; jj < j_end; jj++) { - int j = d_bo_list[jj]; - j &= NEIGHMASK; - const tagint jtag = tag[j]; - const int j_index = jj - j_start; - double bo_tmp = d_BO(i,j_index); + if(mask[i] & groupbit) { + const int j_start = d_bo_first[i]; + const int j_end = j_start + d_bo_num[i]; + for (int jj = j_start; jj < j_end; jj++) { + int j = d_bo_list[jj]; + j &= NEIGHMASK; + if(mask[j] & groupbit) { + const tagint jtag = tag[j]; + const int j_index = jj - j_start; + double bo_tmp = d_BO(i,j_index); - if (bo_tmp > bo_cut_bond) { - d_neighid(i,nj) = jtag; - d_abo(i,nj) = bo_tmp; - nj++; + if (bo_tmp > bo_cut_bond) { + d_neighid(i,nj) = jtag; + d_abo(i,nj) = bo_tmp; + nj++; + } + } } } d_numneigh_bonds[i] = nj; diff --git a/src/KOKKOS/pair_reaxff_kokkos.h b/src/KOKKOS/pair_reaxff_kokkos.h index f246afcc86..f54350b04b 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.h +++ b/src/KOKKOS/pair_reaxff_kokkos.h @@ -133,7 +133,7 @@ class PairReaxFFKokkos : public PairReaxFF { void compute(int, int); void init_style(); double memory_usage(); - void FindBond(int &); + void FindBond(int &, int groupbit = 1); void PackBondBuffer(DAT::tdual_ffloat_1d, int &); void PackReducedBondBuffer(DAT::tdual_ffloat_1d, int &, bool); void FindBondSpecies(); @@ -288,7 +288,7 @@ class PairReaxFFKokkos : public PairReaxFF { void operator()(TagPairReaxFindBondZero, const int&) const; KOKKOS_INLINE_FUNCTION - void calculate_find_bond_item(int, int&) const; + void calculate_find_bond_item(int, int&, int) const; KOKKOS_INLINE_FUNCTION void pack_bond_buffer_item(int, int&, const bool&) const; @@ -417,6 +417,7 @@ class PairReaxFFKokkos : public PairReaxFF { typename AT::t_f_array f; typename AT::t_int_1d_randomread type; typename AT::t_tagint_1d_randomread tag; + typename AT::t_int_1d_randomread mask; typename AT::t_float_1d_randomread q; typename AT::t_tagint_1d_randomread molecule; @@ -526,8 +527,9 @@ template struct PairReaxKokkosFindBondFunctor { typedef DeviceType device_type; typedef int value_type; + int groupbit; PairReaxFFKokkos c; - PairReaxKokkosFindBondFunctor(PairReaxFFKokkos* c_ptr):c(*c_ptr) {}; + PairReaxKokkosFindBondFunctor(PairReaxFFKokkos* c_ptr, int groupbit):c(*c_ptr),groupbit(groupbit) {}; KOKKOS_INLINE_FUNCTION void join(int &dst, @@ -537,7 +539,7 @@ struct PairReaxKokkosFindBondFunctor { KOKKOS_INLINE_FUNCTION void operator()(const int ii, int &numbonds) const { - c.calculate_find_bond_item(ii,numbonds); + c.calculate_find_bond_item(ii,numbonds,groupbit); } }; diff --git a/src/REAXFF/compute_reaxff_atom.cpp b/src/REAXFF/compute_reaxff_atom.cpp index 2e5d4058b8..fba67ecacf 100644 --- a/src/REAXFF/compute_reaxff_atom.cpp +++ b/src/REAXFF/compute_reaxff_atom.cpp @@ -126,28 +126,33 @@ int ComputeReaxFFAtom::FindBond() bo_cut = reaxff->api->control->bg_cut; tagint *tag = atom->tag; + int * mask = atom->mask; int numbonds = 0; for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - nj = 0; + if (mask[i] & groupbit) { + nj = 0; - for (pj = Start_Index(i, reaxff->api->lists); pj < End_Index(i, reaxff->api->lists); ++pj) { - bo_ij = &(reaxff->api->lists->select.bond_list[pj]); - j = bo_ij->nbr; - jtag = tag[j]; - bo_tmp = bo_ij->bo_data.BO; + for (pj = Start_Index(i, reaxff->api->lists); pj < End_Index(i, reaxff->api->lists); ++pj) { + bo_ij = &(reaxff->api->lists->select.bond_list[pj]); + j = bo_ij->nbr; + if (mask[j] & groupbit) { + jtag = tag[j]; + bo_tmp = bo_ij->bo_data.BO; - if (bo_tmp > bo_cut) { - if(store_bonds) { - neighid[i][nj] = jtag; - abo[i][nj] = bo_tmp; + if (bo_tmp > bo_cut) { + if(store_bonds) { + neighid[i][nj] = jtag; + abo[i][nj] = bo_tmp; + } + nj++; + } } - nj++; } + bondcount[i] = nj; + numbonds += nj; } - bondcount[i] = nj; - numbonds += nj; } return numbonds; } From 9100f486cb182651020d142a63cb4b30fbc4fa9d Mon Sep 17 00:00:00 2001 From: jtclemm Date: Tue, 12 Dec 2023 15:51:02 -0700 Subject: [PATCH 83/87] Clarify and fix logic in multi, simplify skip --- src/OPENMP/npair_multi_omp.cpp | 48 +++++++++++++++++----------------- src/npair_multi.cpp | 46 ++++++++++++++++---------------- src/npair_skip.cpp | 14 +++++----- src/npair_skip.h | 14 +++++----- 4 files changed, 60 insertions(+), 62 deletions(-) diff --git a/src/OPENMP/npair_multi_omp.cpp b/src/OPENMP/npair_multi_omp.cpp index 818470254c..3f8604572c 100644 --- a/src/OPENMP/npair_multi_omp.cpp +++ b/src/OPENMP/npair_multi_omp.cpp @@ -118,8 +118,7 @@ void NPairMultiOmp::build(NeighList *list) for (jcollection = 0; jcollection < ncollections; jcollection++) { - // if same collection use own bin - + // Use own bin for same collection if (icollection == jcollection) jbin = ibin; else jbin = coord2bin(x[i], jcollection); @@ -129,34 +128,34 @@ void NPairMultiOmp::build(NeighList *list) for (k = 0; k < ns; k++) { js = binhead_multi[jcollection][jbin + s[k]]; - // own-bin for half stencil - if (HALF && !TRI) - if (k == 0 && flag_half_multi[icollection][jcollection]) js = bins[i]; + // For half-newton-ortho, first check self bin (k == 0, always half) + // if checking its own binlist, skip all before i in linked list + if (HALF && NEWTON && !TRI) + if ((k == 0) && (icollection == jcollection)) js = bins[i]; for (j = js; j >= 0; j = bins[j]) { if (!HALF) { - // Full neighbor list + // Full neighbor list, only uses full stencils // only skip i = j if (i == j) continue; } else if (!NEWTON) { - // Half neighbor list, newton off + // Half neighbor list, newton off, only uses full stencils // 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 - // if same size (same collection), use half stencil - // Always have full stencil - // if same size (same collection), exclude half of interactions - // stencil is empty if i larger than j - // stencil is full if i smaller than j - // stencil is full if i same size as j - // for i smaller than j: - // 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 + // Half neighbor list, newton on, triclinic, only uses full stencils + // If different sizes -> full stencil (accept all, one-way search) + // If same size -> half stencil, exclude half of interactions + // stencil is empty if i larger than j + // stencil is full if i smaller than j + // stencil is full if i same size as j + // for i smaller than j: + // 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 (flag_same_multi[icollection][jcollection]) { if (j <= i) continue; @@ -178,9 +177,10 @@ void NPairMultiOmp::build(NeighList *list) } } } else { - // Half neighbor list, newton on, orthonormal - // if same size: uses half stencil so includes a check of the central bin - if (k == 0 && flag_half_multi[icollection][jcollection]) { + // Half neighbor list, newton on, orthonormal, uses a mix of stencils + // If different sizes -> full stencil (accept all, one-way search) + // If same size -> half stencil (first includes a self bin search) + if (k == 0 && flag_same_multi[icollection][jcollection]) { // if same collection, // 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 @@ -217,14 +217,14 @@ void NPairMultiOmp::build(NeighList *list) if (ATOMONLY) { if (rsq <= cutsq) { jh = j; - if (history && rsq < radsum * radsum) + if (history && rsq < (radsum * radsum)) jh = jh ^ mask_history; neighptr[n++] = jh; } } else { if (rsq <= cutsq) { jh = j; - if (history && rsq < radsum * radsum) + if (history && rsq < (radsum * radsum)) jh = jh ^ mask_history; if (molecular != Atom::ATOMIC) { diff --git a/src/npair_multi.cpp b/src/npair_multi.cpp index ec5a67fa82..b5f813c0a8 100644 --- a/src/npair_multi.cpp +++ b/src/npair_multi.cpp @@ -115,8 +115,7 @@ void NPairMulti::build(NeighList *list) for (jcollection = 0; jcollection < ncollections; jcollection++) { - // if same collection use own bin - + // Use own bin for same collection if (icollection == jcollection) jbin = ibin; else jbin = coord2bin(x[i], jcollection); @@ -126,34 +125,34 @@ void NPairMulti::build(NeighList *list) for (k = 0; k < ns; k++) { js = binhead_multi[jcollection][jbin + s[k]]; - // own-bin for half stencil - if (HALF && !TRI) - if (k == 0 && flag_half_multi[icollection][jcollection]) js = bins[i]; + // For half-newton-ortho, first check self bin (k == 0, always half) + // if checking its own binlist, skip all before i in linked list + if (HALF && NEWTON && !TRI) + if ((k == 0) && (icollection == jcollection)) js = bins[i]; for (j = js; j >= 0; j = bins[j]) { if (!HALF) { - // Full neighbor list + // Full neighbor list, only uses full stencils // only skip i = j if (i == j) continue; } else if (!NEWTON) { - // Half neighbor list, newton off + // Half neighbor list, newton off, only uses full stencils // 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 - // if same size (same collection), use half stencil - // Always have full stencil - // if same size (same collection), exclude half of interactions - // stencil is empty if i larger than j - // stencil is full if i smaller than j - // stencil is full if i same size as j - // for i smaller than j: - // 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 + // Half neighbor list, newton on, triclinic, only uses full stencils + // If different sizes -> full stencil (accept all, one-way search) + // If same size -> half stencil, exclude half of interactions + // stencil is empty if i larger than j + // stencil is full if i smaller than j + // stencil is full if i same size as j + // for i smaller than j: + // 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 (flag_same_multi[icollection][jcollection]) { if (j <= i) continue; @@ -175,9 +174,10 @@ void NPairMulti::build(NeighList *list) } } } else { - // Half neighbor list, newton on, orthonormal - // if same size: uses half stencil so includes a check of the central bin - if (k == 0 && flag_half_multi[icollection][jcollection]) { + // Half neighbor list, newton on, orthonormal, uses a mix of stencils + // If different sizes -> full stencil (accept all, one-way search) + // If same size -> half stencil (first includes a self bin search) + if (k == 0 && flag_same_multi[icollection][jcollection]) { // if same collection, // 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 @@ -221,7 +221,7 @@ void NPairMulti::build(NeighList *list) } else { if (rsq <= cutsq) { jh = j; - if (history && rsq < radsum * radsum) + if (history && rsq < (radsum * radsum)) jh = jh ^ mask_history; if (molecular != Atom::ATOMIC) { diff --git a/src/npair_skip.cpp b/src/npair_skip.cpp index fad06d699c..6afb43bc16 100644 --- a/src/npair_skip.cpp +++ b/src/npair_skip.cpp @@ -22,8 +22,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -template -NPairSkipTemp::NPairSkipTemp(LAMMPS *lmp) : NPair(lmp) {} +template +NPairSkipTemp::NPairSkipTemp(LAMMPS *lmp) : NPair(lmp) {} /* ---------------------------------------------------------------------- build skip list for subset of types from parent list @@ -33,8 +33,8 @@ NPairSkipTemp::NPairSkipTemp(LAMMPS *lmp) : NPair(lmp) {} if ghost, also store neighbors of ghost atoms & set inum,gnum correctly ------------------------------------------------------------------------- */ -template -void NPairSkipTemp::build(NeighList *list) +template +void NPairSkipTemp::build(NeighList *list) { int i, j, ii, jj, n, itype, jnum, joriginal; int *neighptr, *jlist; @@ -124,8 +124,6 @@ void NPairSkipTemp::build(NeighList *list) } namespace LAMMPS_NS { -template class NPairSkipTemp<0,0>; -template class NPairSkipTemp<1,0>; -template class NPairSkipTemp<0,1>; -template class NPairSkipTemp<1,1>; +template class NPairSkipTemp<0>; +template class NPairSkipTemp<1>; } diff --git a/src/npair_skip.h b/src/npair_skip.h index 06da1be85b..cb0d201555 100644 --- a/src/npair_skip.h +++ b/src/npair_skip.h @@ -13,41 +13,41 @@ #ifdef NPAIR_CLASS // clang-format off -typedef NPairSkipTemp<0, 0> NPairSkip; +typedef NPairSkipTemp<0> NPairSkip; NPairStyle(skip, NPairSkip, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairSkipTemp<0, 0> NPairSkip; +typedef NPairSkipTemp<0> NPairSkip; NPairStyle(skip/ghost, NPairSkip, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST); -typedef NPairSkipTemp<1, 0> NPairSkipSize; +typedef NPairSkipTemp<0> NPairSkipSize; NPairStyle(skip/half/size, NPairSkipSize, NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI); -typedef NPairSkipTemp<0, 1> NPairSkipTrim; +typedef NPairSkipTemp<1> NPairSkipTrim; NPairStyle(skip/trim, NPairSkipTrim, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_TRIM); -typedef NPairSkipTemp<0, 1> NPairSkipTrim; +typedef NPairSkipTemp<1> NPairSkipTrim; NPairStyle(skip/ghost/trim, NPairSkipTrim, NP_SKIP | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | NP_NEWTON | NP_NEWTOFF | NP_ORTHO | NP_TRI | NP_GHOST | NP_TRIM); -typedef NPairSkipTemp<1, 1> NPairSkipTrimSize; +typedef NPairSkipTemp<1> NPairSkipTrimSize; NPairStyle(skip/trim/half/size, NPairSkipTrimSize, NP_SKIP | NP_SIZE | NP_HALF | NP_FULL | NP_NSQ | NP_BIN | NP_MULTI | NP_MULTI_OLD | @@ -63,7 +63,7 @@ NPairStyle(skip/trim/half/size, namespace LAMMPS_NS { -template +template class NPairSkipTemp : public NPair { public: NPairSkipTemp(class LAMMPS *); From 0cf4c9e7a32585ca7c78d4fd4df4f50c89d83d9b Mon Sep 17 00:00:00 2001 From: Stan Gerald Moore Date: Wed, 13 Dec 2023 11:07:42 -0700 Subject: [PATCH 84/87] Whitespace --- src/KOKKOS/compute_reaxff_atom_kokkos.cpp | 13 ++++++------- src/KOKKOS/pair_reaxff_kokkos.cpp | 6 +++--- src/REAXFF/compute_reaxff_atom.cpp | 17 +++++++---------- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp index c3e9367ff4..8dbcb9441e 100644 --- a/src/KOKKOS/compute_reaxff_atom_kokkos.cpp +++ b/src/KOKKOS/compute_reaxff_atom_kokkos.cpp @@ -42,7 +42,6 @@ ComputeReaxFFAtomKokkos::ComputeReaxFFAtomKokkos(LAMMPS *lmp, int na kokkosable = 1; } - /* ---------------------------------------------------------------------- */ template @@ -58,7 +57,7 @@ void ComputeReaxFFAtomKokkos::init() { ComputeReaxFFAtom::init(); - if(!reaxff || !reaxff->kokkosable) { + if (!reaxff || !reaxff->kokkosable) { error->all(FLERR,"Cannot use compute reaxff/atom/kk without " "pair_style reaxff/kk"); } @@ -88,7 +87,7 @@ void ComputeReaxFFAtomKokkos::compute_bonds() nbuf = ((store_bonds ? maxnumbonds*2 : 0) + 3)*nlocal; - if(!buf || k_buf.extent(0) < nbuf) { + if (!buf || k_buf.extent(0) < nbuf) { memoryKK->destroy_kokkos(k_buf, buf); memoryKK->create_kokkos(k_buf, buf, nbuf, "reaxff/atom:buf"); } @@ -119,10 +118,10 @@ void ComputeReaxFFAtomKokkos::compute_local() { invoked_local = update->ntimestep; - if(invoked_bonds < update->ntimestep) + if (invoked_bonds < update->ntimestep) compute_bonds(); - if(nbonds > prev_nbonds) { + if (nbonds > prev_nbonds) { // grow array_local memory->destroy(array_local); memory->create(array_local, nbonds, 3, "reaxff/atom:array_local"); @@ -158,7 +157,7 @@ void ComputeReaxFFAtomKokkos::compute_peratom() { invoked_peratom = update->ntimestep; - if(invoked_bonds < update->ntimestep) + if (invoked_bonds < update->ntimestep) compute_bonds(); // extract peratom bond information from buffer @@ -182,7 +181,7 @@ template double ComputeReaxFFAtomKokkos::memory_usage() { double bytes = (double)(nlocal*3) * sizeof(double); - if(store_bonds) + if (store_bonds) bytes += (double)(nbonds*3) * sizeof(double); bytes += (double)(nbuf > 0 ? nbuf * sizeof(double) : 0); return bytes; diff --git a/src/KOKKOS/pair_reaxff_kokkos.cpp b/src/KOKKOS/pair_reaxff_kokkos.cpp index 29ac398128..11a40970c2 100644 --- a/src/KOKKOS/pair_reaxff_kokkos.cpp +++ b/src/KOKKOS/pair_reaxff_kokkos.cpp @@ -4200,13 +4200,13 @@ void PairReaxFFKokkos::calculate_find_bond_item(int ii, int &numbond const int i = d_ilist[ii]; int nj = 0; - if(mask[i] & groupbit) { + if (mask[i] & groupbit) { const int j_start = d_bo_first[i]; const int j_end = j_start + d_bo_num[i]; for (int jj = j_start; jj < j_end; jj++) { int j = d_bo_list[jj]; j &= NEIGHMASK; - if(mask[j] & groupbit) { + if (mask[j] & groupbit) { const tagint jtag = tag[j]; const int j_index = jj - j_start; double bo_tmp = d_BO(i,j_index); @@ -4262,7 +4262,7 @@ void PairReaxFFKokkos::PackReducedBondBuffer(DAT::tdual_ffloat_1d k_ copymode = 1; nlocal = atomKK->nlocal; - if(store_bonds) { + if (store_bonds) { PairReaxKokkosPackReducedBondBufferFunctor pack_bond_buffer_functor(this); Kokkos::parallel_scan(nlocal,pack_bond_buffer_functor); } else { diff --git a/src/REAXFF/compute_reaxff_atom.cpp b/src/REAXFF/compute_reaxff_atom.cpp index fba67ecacf..1b54f3b82a 100644 --- a/src/REAXFF/compute_reaxff_atom.cpp +++ b/src/REAXFF/compute_reaxff_atom.cpp @@ -79,7 +79,6 @@ ComputeReaxFFAtom::ComputeReaxFFAtom(LAMMPS *lmp, int narg, char **arg) : local_flag = store_bonds; } - /* ---------------------------------------------------------------------- */ ComputeReaxFFAtom::~ComputeReaxFFAtom() @@ -107,7 +106,7 @@ void ComputeReaxFFAtom::init() if (!reaxff) error->all(FLERR,"Cannot use compute reaxff/atom without " "pair_style reaxff or reaxff/omp"); - if(reaxff->kokkosable && !kokkosable) + if (reaxff->kokkosable && !kokkosable) error->all(FLERR,"Cannot use compute reaxff/atom with pair_style reaxff/kk. Use reaxff/atom/kk."); } @@ -142,7 +141,7 @@ int ComputeReaxFFAtom::FindBond() bo_tmp = bo_ij->bo_data.BO; if (bo_tmp > bo_cut) { - if(store_bonds) { + if (store_bonds) { neighid[i][nj] = jtag; abo[i][nj] = bo_tmp; } @@ -157,7 +156,6 @@ int ComputeReaxFFAtom::FindBond() return numbonds; } - /* ---------------------------------------------------------------------- */ void ComputeReaxFFAtom::compute_bonds() @@ -170,7 +168,7 @@ void ComputeReaxFFAtom::compute_bonds() memory->destroy(bondcount); memory->destroy(array_atom); nlocal = atom->nlocal; - if(store_bonds) { + if (store_bonds) { memory->create(abo, nlocal, MAXREAXBOND, "reaxff/atom:abo"); memory->create(neighid, nlocal, MAXREAXBOND, "reaxff/atom:neighid"); } @@ -195,11 +193,10 @@ void ComputeReaxFFAtom::compute_local() { invoked_local = update->ntimestep; - if(invoked_bonds < update->ntimestep) { + if (invoked_bonds < update->ntimestep) compute_bonds(); - } - if(nbonds > prev_nbonds) { + if (nbonds > prev_nbonds) { // grow array_local memory->destroy(array_local); memory->create(array_local, nbonds, 3, "reaxff/atom:array_local"); @@ -229,7 +226,7 @@ void ComputeReaxFFAtom::compute_peratom() { invoked_peratom = update->ntimestep; - if(invoked_bonds < update->ntimestep) { + if (invoked_bonds < update->ntimestep) { compute_bonds(); } @@ -249,7 +246,7 @@ double ComputeReaxFFAtom::memory_usage() { double bytes = (double)(nlocal*3) * sizeof(double); bytes += (double)(nlocal) * sizeof(int); - if(store_bonds) { + if (store_bonds) { bytes += (double)(2*nlocal*MAXREAXBOND) * sizeof(double); bytes += (double)(nbonds*3) * sizeof(double); } From 603837c96ca07d84c638b9db1cb1f39b9cddbc0d Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 14 Dec 2023 16:21:04 -0500 Subject: [PATCH 85/87] add versionadded tag --- doc/src/compute_reaxff_atom.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/compute_reaxff_atom.rst b/doc/src/compute_reaxff_atom.rst index 9f690d19c3..997ad02e9f 100644 --- a/doc/src/compute_reaxff_atom.rst +++ b/doc/src/compute_reaxff_atom.rst @@ -40,6 +40,8 @@ Examples Description """"""""""" +.. versionadded:: TBD + Define a computation that extracts bond information computed by the ReaxFF potential specified by :doc:`pair_style reaxff `. From 7dab2b7eee941e28e01416ede9688e661c1cf520 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 14 Dec 2023 16:21:17 -0500 Subject: [PATCH 86/87] add new package files to .gitignore --- src/.gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/.gitignore b/src/.gitignore index 3b7902303d..112a1486f7 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -633,6 +633,8 @@ /compute_ptm_atom.h /compute_rattlers_atom.cpp /compute_rattlers_atom.h +/compute_reaxff_atom.cpp +/compute_reaxff_atom.h /compute_rigid_local.cpp /compute_rigid_local.h /compute_slcsa_atom.cpp From 1df91f21a18d88006e07ec50e56c16ca7036b927 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 14 Dec 2023 17:59:18 -0500 Subject: [PATCH 87/87] workaround hack for macOS --- src/PYTHON/python_impl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PYTHON/python_impl.cpp b/src/PYTHON/python_impl.cpp index c1c26c7bb3..ea4ac63ce7 100644 --- a/src/PYTHON/python_impl.cpp +++ b/src/PYTHON/python_impl.cpp @@ -79,7 +79,7 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // Force the stdout and stderr streams to be unbuffered. bool unbuffered = PYTHONUNBUFFERED != nullptr && strcmp(PYTHONUNBUFFERED, "1") == 0; -#if PY_VERSION_HEX >= 0x030800f0 +#if (PY_VERSION_HEX >= 0x030800f0) && !defined(__APPLE__) PyConfig config; PyConfig_InitPythonConfig(&config); config.buffered_stdio = !unbuffered; @@ -87,6 +87,8 @@ PythonImpl::PythonImpl(LAMMPS *lmp) : Pointers(lmp) // Python Global configuration variable Py_UnbufferedStdioFlag = unbuffered; #endif +#else +#warning Cannot force stdout and stderr to be unbuffered #endif #ifdef MLIAP_PYTHON