git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5528 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2011-01-11 16:52:36 +00:00
parent 9f55cc26d9
commit 81f821578b
2 changed files with 22 additions and 6 deletions

View File

@ -19,8 +19,8 @@
#include "math.h" #include "math.h"
#include "stdlib.h" #include "stdlib.h"
#include "string.h" #include "string.h"
#include "limits.h"
#include "neighbor.h" #include "neighbor.h"
#include "lmptype.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "atom.h" #include "atom.h"
@ -284,6 +284,13 @@ void Neighbor::init()
if (force->kspace) special_flag[1] = special_flag[2] = special_flag[3] = 2; if (force->kspace) special_flag[1] = special_flag[2] = special_flag[3] = 2;
// maxwt = max multiplicative factor on atom indices stored in neigh list
maxwt = 0;
if (special_flag[1] == 2) maxwt = 2;
if (special_flag[2] == 2) maxwt = 3;
if (special_flag[3] == 2) maxwt = 4;
// rRESPA cutoffs // rRESPA cutoffs
int respa = 0; int respa = 0;
@ -1060,6 +1067,14 @@ void Neighbor::build()
bins = (int *) memory->smalloc(maxbin*sizeof(int),"bins"); bins = (int *) memory->smalloc(maxbin*sizeof(int),"bins");
} }
// check that pairwise lists with special bond weighting will not overflow
if (atom->molecular && maxwt && nblist) {
bigint max = maxwt * static_cast<bigint> (atom->nlocal + atom->nghost);
if (max > MAXSMALLINT)
error->one("Weighted neighbor list values are too big");
}
// invoke building of pair and molecular neighbor lists // invoke building of pair and molecular neighbor lists
// only for pairwise lists with buildflag set // only for pairwise lists with buildflag set
@ -1176,8 +1191,8 @@ void Neighbor::setup_bins()
// test for too many global bins in any dimension due to huge global domain // test for too many global bins in any dimension due to huge global domain
if (bbox[0]*binsizeinv > INT_MAX || bbox[1]*binsizeinv > INT_MAX || if (bbox[0]*binsizeinv > MAXSMALLINT || bbox[1]*binsizeinv > MAXSMALLINT ||
bbox[2]*binsizeinv > INT_MAX) bbox[2]*binsizeinv > MAXSMALLINT)
error->all("Domain too large for neighbor bins"); error->all("Domain too large for neighbor bins");
// create actual bins // create actual bins
@ -1259,9 +1274,9 @@ void Neighbor::setup_bins()
// memory for bin ptrs // memory for bin ptrs
if (1.0*mbinx*mbiny*mbinz > INT_MAX) error->one("Too many neighbor bins"); bigint bbin = mbinx*mbiny*mbinz;
if (bbin > MAXSMALLINT) error->one("Too many neighbor bins");
mbins = mbinx*mbiny*mbinz; mbins = bbin;
if (mbins > maxhead) { if (mbins > maxhead) {
maxhead = mbins; maxhead = mbins;
memory->sfree(binhead); memory->sfree(binhead);

View File

@ -77,6 +77,7 @@ class Neighbor : protected Pointers {
int maxlocal; // size of atom-based NeighList arrays int maxlocal; // size of atom-based NeighList arrays
int maxbond,maxangle,maxdihedral,maximproper; // size of bond lists int maxbond,maxangle,maxdihedral,maximproper; // size of bond lists
int maxwt; // max weighting factor applied + 1
int build_once; // 1 if only build lists once per run int build_once; // 1 if only build lists once per run
int must_check; // 1 if must check other classes to reneigh int must_check; // 1 if must check other classes to reneigh