Cleaning up ghost stencils

This commit is contained in:
jtclemm
2023-10-24 13:55:43 -06:00
parent 0f94e6030f
commit 8f14cdcb34
6 changed files with 27 additions and 111 deletions

View File

@ -53,7 +53,7 @@ void NStencilBinIntel<HALF, DIM_3D, TRI>::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;
}
}

View File

@ -17,8 +17,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
template<int HALF, int DIM_3D, int TRI>
NStencilGhostBinIntel<HALF, DIM_3D, TRI>::NStencilGhostBinIntel(LAMMPS *lmp) : NStencil(lmp)
template<int DIM_3D>
NStencilGhostBinIntel<DIM_3D>::NStencilGhostBinIntel(LAMMPS *lmp) : NStencil(lmp)
{
xyzflag = 1;
}
@ -27,39 +27,21 @@ NStencilGhostBinIntel<HALF, DIM_3D, TRI>::NStencilGhostBinIntel(LAMMPS *lmp) : N
create stencil based on bin geometry and cutoff
------------------------------------------------------------------------- */
template<int HALF, int DIM_3D, int TRI>
void NStencilGhostBinIntel<HALF, DIM_3D, TRI>::create()
template<int DIM_3D>
void NStencilGhostBinIntel<DIM_3D>::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<HALF, DIM_3D, TRI>::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>;
}

View File

@ -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<int HALF, int DIM_3D, int TRI>
template<int DIM_3D>
class NStencilGhostBinIntel : public NStencil {
public:
NStencilGhostBinIntel(class LAMMPS *);

View File

@ -59,7 +59,7 @@ void NStencilBin<HALF, DIM_3D, TRI>::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;
}
}

View File

@ -17,8 +17,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
template<int HALF, int DIM_3D, int TRI>
NStencilGhostBin<HALF, DIM_3D, TRI>::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp)
template<int DIM_3D>
NStencilGhostBin<DIM_3D>::NStencilGhostBin(LAMMPS *lmp) : NStencil(lmp)
{
xyzflag = 1;
}
@ -27,35 +27,17 @@ NStencilGhostBin<HALF, DIM_3D, TRI>::NStencilGhostBin(LAMMPS *lmp) : NStencil(lm
create stencil based on bin geometry and cutoff
------------------------------------------------------------------------- */
template<int HALF, int DIM_3D, int TRI>
void NStencilGhostBin<HALF, DIM_3D, TRI>::create()
template<int DIM_3D>
void NStencilGhostBin<DIM_3D>::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<HALF, DIM_3D, TRI>::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>;
}

View File

@ -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<int HALF, int DIM_3D, int TRI>
template<int DIM_3D>
class NStencilGhostBin : public NStencil {
public:
NStencilGhostBin(class LAMMPS *);