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 *);