diff --git a/src/neigh_list.cpp b/src/neigh_list.cpp index ed58a114e575f925b8bfce3ca21d0ecf1872ad09..93d8289541ba30d804a2ec07f7f8acf0a05c9f16 100644 --- a/src/neigh_list.cpp +++ b/src/neigh_list.cpp @@ -105,7 +105,7 @@ NeighList::~NeighList() void NeighList::grow(int nmax) { - // skip if grow not needed (don't think this should happen) + // skip if grow not needed if (nmax <= maxlocal) return; maxlocal = nmax; diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 6f0d193f5176b9697dd11f2e019e398d39e1f2ac..7ed83152115e45fa68fd3d629e955c2543e4bc57 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -548,6 +548,7 @@ void Neighbor::init() // allocate atom arrays and 1st pages of lists that store them + maxlocal = atom->nmax; for (i = 0; i < nlist; i++) if (lists[i]->growflag) { lists[i]->grow(maxlocal); @@ -962,7 +963,7 @@ void Neighbor::build() } // if necessary, extend atom arrays in pairwise lists - // only done for lists with growflag set which are used every reneighbor + // only for lists with growflag set and which are used every reneighbor if (atom->nlocal > maxlocal) { maxlocal = atom->nmax; @@ -978,7 +979,7 @@ void Neighbor::build() } // invoke building of pair and molecular neighbor lists - // only done for pairwise lists with buildflag set + // only for pairwise lists with buildflag set for (i = 0; i < nblist; i++) (this->*pair_build[blist[i]])(lists[blist[i]]); @@ -998,14 +999,23 @@ void Neighbor::build() void Neighbor::build_one(int i) { - // grow atom arrays and update stencils depending on growflag & stencilflag + // update stencils and grow atom arrays and bins + // only for relevant settings of stencilflag and growflag + // do not reset maxlocal to atom->nmax, since not all lists are being grown - if (lists[i]->growflag) lists[i]->grow(maxlocal); if (lists[i]->stencilflag) { lists[i]->stencil_allocate(smax,style); (this->*stencil_create[i])(lists[i],sx,sy,sz); } + if (lists[i]->growflag) lists[i]->grow(maxlocal); + + if (style != NSQ && atom->nmax > maxbin) { + maxbin = atom->nmax; + memory->sfree(bins); + bins = (int *) memory->smalloc(maxbin*sizeof(int),"bins"); + } + (this->*pair_build[i])(lists[i]); } diff --git a/src/neighbor.h b/src/neighbor.h index 6a3ff2f6fab7d309df3f8eb186254a474e8b717a..e48e3263527abc4d7724f481a04a206b2edd401c 100644 --- a/src/neighbor.h +++ b/src/neighbor.h @@ -72,7 +72,7 @@ class Neighbor : protected Pointers { private: int me,nprocs; - int maxlocal; // size of numneigh, firstneigh arrays + int maxlocal; // size of atom-based NeighList arrays int maxbond,maxangle,maxdihedral,maximproper; // size of bond lists int must_check; // 1 if must check other classes to reneigh