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

This commit is contained in:
sjplimp
2011-01-04 21:08:27 +00:00
parent a7f69eac0c
commit c9495408a1
16 changed files with 69 additions and 61 deletions

View File

@ -119,7 +119,7 @@ void FixQEQComb::init()
nlevels_respa = ((Respa *) update->integrate)->nlevels; nlevels_respa = ((Respa *) update->integrate)->nlevels;
ngroup = group->count(igroup); ngroup = group->count(igroup);
if (ngroup == 0.0) error->all("Fix qeq/comb group has no atoms"); if (ngroup == 0) error->all("Fix qeq/comb group has no atoms");
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -22,6 +22,7 @@ FixStyle(qeq/comb,FixQEQComb)
#include "stdio.h" #include "stdio.h"
#include "fix.h" #include "fix.h"
#include "lmptype.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -40,7 +41,7 @@ class FixQEQComb : public Fix {
int me,firstflag; int me,firstflag;
double precision; double precision;
int nlevels_respa; int nlevels_respa;
double ngroup; bigint ngroup;
FILE *fp; FILE *fp;
class PairComb *comb; class PairComb *comb;

View File

@ -1075,7 +1075,7 @@ void FixSRD::vbin_unpack(double *buf, BinAve *vbin, int n, int *list)
void FixSRD::collisions_single() void FixSRD::collisions_single()
{ {
int i,j,k,m,type,nbig,ibin,ibounce,inside,collide_flag; int i,j,k,m,type,mbig,ibin,ibounce,inside,collide_flag;
double dt,t_remain; double dt,t_remain;
double norm[3],xscoll[3],xbcoll[3],vsnew[3]; double norm[3],xscoll[3],xbcoll[3],vsnew[3];
Big *big; Big *big;
@ -1107,11 +1107,11 @@ void FixSRD::collisions_single()
dt = dt_big; dt = dt_big;
while (collide_flag) { while (collide_flag) {
nbig = nbinbig[ibin]; mbig = nbinbig[ibin];
if (ibounce == 0) ncheck += nbig; if (ibounce == 0) ncheck += mbig;
collide_flag = 0; collide_flag = 0;
for (m = 0; m < nbig; m++) { for (m = 0; m < mbig; m++) {
k = binbig[ibin][m]; k = binbig[ibin][m];
big = &biglist[k]; big = &biglist[k];
j = big->index; j = big->index;
@ -1236,7 +1236,7 @@ void FixSRD::collisions_single()
void FixSRD::collisions_multi() void FixSRD::collisions_multi()
{ {
int i,j,k,m,type,nbig,ibin,ibounce,inside,jfirst,typefirst; int i,j,k,m,type,mbig,ibin,ibounce,inside,jfirst,typefirst;
double dt,t_remain,t_first; double dt,t_remain,t_first;
double norm[3],xscoll[3],xbcoll[3],vsnew[3]; double norm[3],xscoll[3],xbcoll[3],vsnew[3];
double normfirst[3],xscollfirst[3],xbcollfirst[3]; double normfirst[3],xscollfirst[3],xbcollfirst[3];
@ -1268,11 +1268,11 @@ void FixSRD::collisions_multi()
dt = dt_big; dt = dt_big;
while (1) { while (1) {
nbig = nbinbig[ibin]; mbig = nbinbig[ibin];
if (ibounce == 0) ncheck += nbig; if (ibounce == 0) ncheck += mbig;
t_first = 0.0; t_first = 0.0;
for (m = 0; m < nbig; m++) { for (m = 0; m < mbig; m++) {
k = binbig[ibin][m]; k = binbig[ibin][m];
big = &biglist[k]; big = &biglist[k];
j = big->index; j = big->index;
@ -2236,9 +2236,9 @@ void FixSRD::parameterize()
// particle counts // particle counts
double nbig = 0.0; bigint mbig = 0;
if (bigexist) nbig = group->count(biggroup); if (bigexist) mbig = group->count(biggroup);
double nsrd = group->count(igroup); bigint nsrd = group->count(igroup);
// mass_big = total mass of all big particles // mass_big = total mass of all big particles
@ -2293,7 +2293,7 @@ void FixSRD::parameterize()
else else
ncell = volsrd / (binsize3x*binsize3y); ncell = volsrd / (binsize3x*binsize3y);
srd_per_cell = nsrd / ncell; srd_per_cell = (double) nsrd / ncell;
// kinematic viscosity of SRD fluid // kinematic viscosity of SRD fluid
// output in cm^2/sec units, converted by xxt2kmu // output in cm^2/sec units, converted by xxt2kmu
@ -2317,7 +2317,7 @@ void FixSRD::parameterize()
if (me == 0) { if (me == 0) {
if (screen) { if (screen) {
fprintf(screen,"SRD info:\n"); fprintf(screen,"SRD info:\n");
fprintf(screen," SRD/big particles = %g %g\n",nsrd,nbig); fprintf(screen," SRD/big particles = %lu %lu\n",nsrd,mbig);
fprintf(screen," big particle diameter max/min = %g %g\n", fprintf(screen," big particle diameter max/min = %g %g\n",
maxbigdiam,minbigdiam); maxbigdiam,minbigdiam);
fprintf(screen," SRD temperature & lamda = %g %g\n", fprintf(screen," SRD temperature & lamda = %g %g\n",
@ -2332,7 +2332,7 @@ void FixSRD::parameterize()
} }
if (logfile) { if (logfile) {
fprintf(logfile,"SRD info:\n"); fprintf(logfile,"SRD info:\n");
fprintf(logfile," SRD/big particles = %g %g\n",nsrd,nbig); fprintf(logfile," SRD/big particles = %lu %lu\n",nsrd,mbig);
fprintf(logfile," big particle diameter max/min = %g %g\n", fprintf(logfile," big particle diameter max/min = %g %g\n",
maxbigdiam,minbigdiam); maxbigdiam,minbigdiam);
fprintf(logfile," SRD temperature & lamda = %g %g\n", fprintf(logfile," SRD temperature & lamda = %g %g\n",

View File

@ -230,7 +230,7 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) :
imd_port = atoi(arg[3]); imd_port = atoi(arg[3]);
if (imd_port < 1024) if (imd_port < 1024)
error->all("Illegal fix imd parameter. port < 1024."); error->all("Illegal fix imd parameter: port < 1024");
/* default values for optional flags */ /* default values for optional flags */
unwrap_flag = 0; unwrap_flag = 0;
@ -259,7 +259,7 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) :
} else if (0 == strcmp(arg[argsdone], "trate")) { } else if (0 == strcmp(arg[argsdone], "trate")) {
imd_trate = atoi(arg[argsdone+1]); imd_trate = atoi(arg[argsdone+1]);
} else { } else {
error->all("Unknown fix imd parameter."); error->all("Unknown fix imd parameter");
} }
++argsdone; ++argsdone; ++argsdone; ++argsdone;
} }
@ -268,12 +268,11 @@ FixIMD::FixIMD(LAMMPS *lmp, int narg, char **arg) :
if (imd_trate < 1) if (imd_trate < 1)
error->all("Illegal fix imd parameter. trate < 1."); error->all("Illegal fix imd parameter. trate < 1.");
if (igroup == group->find("all")) { bigint n;
num_coords = static_cast<int> (atom->natoms); if (igroup == group->find("all")) n = atom->natoms;
} else { else n = group->count(igroup);
num_coords = static_cast<int> (group->count(igroup)); if (n > MAXINT32) error->all("Too many atoms for fix imd");
if (num_coords <= 0) error->all("Invalid number of group atoms for 'fix imd'"); num_coords = static_cast<int> (n);
}
MPI_Comm_rank(world,&me); MPI_Comm_rank(world,&me);

View File

@ -14,6 +14,7 @@
#include "string.h" #include "string.h"
#include "stdlib.h" #include "stdlib.h"
#include "compute_reduce.h" #include "compute_reduce.h"
#include "lmptype.h"
#include "atom.h" #include "atom.h"
#include "update.h" #include "update.h"
#include "domain.h" #include "domain.h"
@ -589,7 +590,7 @@ double ComputeReduce::compute_one(int m, int flag)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double ComputeReduce::count(int m) bigint ComputeReduce::count(int m)
{ {
int vidx = value2index[m]; int vidx = value2index[m];
int aidx = argindex[m]; int aidx = argindex[m];
@ -601,9 +602,9 @@ double ComputeReduce::count(int m)
if (flavor[m] == PERATOM) { if (flavor[m] == PERATOM) {
return group->count(igroup); return group->count(igroup);
} else if (flavor[m] == LOCAL) { } else if (flavor[m] == LOCAL) {
double ncount = compute->size_local_rows; bigint ncount = compute->size_local_rows;
double ncountall; bigint ncountall;
MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&ncount,&ncountall,1,MPI_UNSIGNED_LONG,MPI_SUM,world);
return ncountall; return ncountall;
} }
} else if (which[m] == FIX) { } else if (which[m] == FIX) {
@ -611,15 +612,16 @@ double ComputeReduce::count(int m)
if (flavor[m] == PERATOM) { if (flavor[m] == PERATOM) {
return group->count(igroup); return group->count(igroup);
} else if (flavor[m] == LOCAL) { } else if (flavor[m] == LOCAL) {
double ncount = fix->size_local_rows; bigint ncount = fix->size_local_rows;
double ncountall; bigint ncountall;
MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&ncount,&ncountall,1,MPI_UNSIGNED_LONG,MPI_SUM,world);
return ncountall; return ncountall;
} }
} else if (which[m] == VARIABLE) } else if (which[m] == VARIABLE)
return group->count(igroup); return group->count(igroup);
return 0.0; bigint dummy = 0;
return dummy;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -21,6 +21,7 @@ ComputeStyle(reduce,ComputeReduce)
#define LMP_COMPUTE_REDUCE_H #define LMP_COMPUTE_REDUCE_H
#include "compute.h" #include "compute.h"
#include "lmptype.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -53,7 +54,7 @@ class ComputeReduce : public Compute {
Pair pairme,pairall; Pair pairme,pairall;
virtual double compute_one(int, int); virtual double compute_one(int, int);
virtual double count(int); virtual bigint count(int);
void combine(double &, double, int); void combine(double &, double, int);
}; };

View File

@ -220,7 +220,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
double ComputeReduceRegion::count(int m) bigint ComputeReduceRegion::count(int m)
{ {
int n = value2index[m]; int n = value2index[m];
int j = argindex[m]; int j = argindex[m];
@ -235,8 +235,8 @@ double ComputeReduceRegion::count(int m)
if (flavor[m] == PERATOM) { if (flavor[m] == PERATOM) {
return group->count(igroup,iregion); return group->count(igroup,iregion);
} else if (flavor[m] == LOCAL) { } else if (flavor[m] == LOCAL) {
double ncount = compute->size_local_rows; bigint ncount = compute->size_local_rows;
double ncountall; bigint ncountall;
MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world);
return ncountall; return ncountall;
} }
@ -245,13 +245,14 @@ double ComputeReduceRegion::count(int m)
if (flavor[m] == PERATOM) { if (flavor[m] == PERATOM) {
return group->count(igroup,iregion); return group->count(igroup,iregion);
} else if (flavor[m] == LOCAL) { } else if (flavor[m] == LOCAL) {
double ncount = fix->size_local_rows; bigint ncount = fix->size_local_rows;
double ncountall; bigint ncountall;
MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&ncount,&ncountall,1,MPI_DOUBLE,MPI_SUM,world);
return ncountall; return ncountall;
} }
} else if (which[m] == VARIABLE) } else if (which[m] == VARIABLE)
return group->count(igroup,iregion); return group->count(igroup,iregion);
return 0.0; bigint dummy = 0;
return dummy;
} }

View File

@ -21,6 +21,7 @@ ComputeStyle(reduce/region,ComputeReduceRegion)
#define LMP_COMPUTE_REDUCE_REGION_H #define LMP_COMPUTE_REDUCE_REGION_H
#include "compute_reduce.h" #include "compute_reduce.h"
#include "lmptype.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -31,7 +32,7 @@ class ComputeReduceRegion : public ComputeReduce {
private: private:
double compute_one(int, int); double compute_one(int, int);
double count(int); bigint count(int);
}; };
} }

View File

@ -173,7 +173,7 @@ void Dump::init()
if (nprocs > 1 && irregular == NULL) if (nprocs > 1 && irregular == NULL)
irregular = new Irregular(lmp); irregular = new Irregular(lmp);
double size = group->count(igroup); bigint size = group->count(igroup);
if (size > MAXINT32) error->all("Too many atoms to dump sort"); if (size > MAXINT32) error->all("Too many atoms to dump sort");
// set reorderflag = 1 if can simply reorder local atoms rather than sort // set reorderflag = 1 if can simply reorder local atoms rather than sort

View File

@ -22,6 +22,7 @@
#include "time.h" #include "time.h"
#include "string.h" #include "string.h"
#include "dump_dcd.h" #include "dump_dcd.h"
#include "lmptype.h"
#include "domain.h" #include "domain.h"
#include "atom.h" #include "atom.h"
#include "update.h" #include "update.h"
@ -67,9 +68,11 @@ DumpDCD::DumpDCD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
// allocate global array for atom coords // allocate global array for atom coords
if (igroup == 0) natoms = static_cast<int> (atom->natoms); bigint n;
else natoms = static_cast<int> (group->count(igroup)); if (igroup == 0) n = static_cast<int> (atom->natoms);
if (natoms <= 0) error->all("Invalid natoms for dump dcd"); else n = static_cast<int> (group->count(igroup));
if (n > MAXINT32) error->all("Too many atoms for dump dcd");
natoms = n;
coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords"); coords = (float *) memory->smalloc(3*natoms*sizeof(float),"dump:coords");
xf = &coords[0*natoms]; xf = &coords[0*natoms];

View File

@ -94,7 +94,7 @@ void FixHeat::init()
// cannot have 0 atoms in group // cannot have 0 atoms in group
if (group->count(igroup) == 0.0) error->all("Fix heat group has no atoms"); if (group->count(igroup) == 0) error->all("Fix heat group has no atoms");
masstotal = group->mass(igroup); masstotal = group->mass(igroup);
} }

View File

@ -60,7 +60,7 @@ FixMomentum::FixMomentum(LAMMPS *lmp, int narg, char **arg) :
// cannot have 0 atoms in group // cannot have 0 atoms in group
if (group->count(igroup) == 0.0) if (group->count(igroup) == 0)
error->all("Fix momentum group has no atoms"); error->all("Fix momentum group has no atoms");
} }

View File

@ -91,7 +91,7 @@ FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) :
// cannot have 0 atoms in group // cannot have 0 atoms in group
if (group->count(igroup) == 0.0) if (group->count(igroup) == 0)
error->all("Fix recenter group has no atoms"); error->all("Fix recenter group has no atoms");
} }

View File

@ -17,6 +17,7 @@
#include "string.h" #include "string.h"
#include "stdlib.h" #include "stdlib.h"
#include "group.h" #include "group.h"
#include "lmptype.h"
#include "domain.h" #include "domain.h"
#include "atom.h" #include "atom.h"
#include "force.h" #include "force.h"
@ -481,10 +482,9 @@ void Group::read_restart(FILE *fp)
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
count atoms in group count atoms in group
compute in double precision in case system is huge
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double Group::count(int igroup) bigint Group::count(int igroup)
{ {
int groupbit = bitmask[igroup]; int groupbit = bitmask[igroup];
@ -495,18 +495,17 @@ double Group::count(int igroup)
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) n++; if (mask[i] & groupbit) n++;
double nsingle = n; bigint nsingle = n;
double nall; bigint nall;
MPI_Allreduce(&nsingle,&nall,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&nsingle,&nall,1,MPI_UNSIGNED_LONG,MPI_SUM,world);
return nall; return nall;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
count atoms in group and region count atoms in group and region
compute in double precision in case system is huge
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
double Group::count(int igroup, int iregion) bigint Group::count(int igroup, int iregion)
{ {
int groupbit = bitmask[igroup]; int groupbit = bitmask[igroup];
Region *region = domain->regions[iregion]; Region *region = domain->regions[iregion];
@ -519,9 +518,9 @@ double Group::count(int igroup, int iregion)
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) n++; if (mask[i] & groupbit && region->match(x[i][0],x[i][1],x[i][2])) n++;
double nsingle = n; bigint nsingle = n;
double nall; bigint nall;
MPI_Allreduce(&nsingle,&nall,1,MPI_DOUBLE,MPI_SUM,world); MPI_Allreduce(&nsingle,&nall,1,MPI_UNSIGNED_LONG,MPI_SUM,world);
return nall; return nall;
} }

View File

@ -16,6 +16,7 @@
#include "stdio.h" #include "stdio.h"
#include "pointers.h" #include "pointers.h"
#include "lmptype.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
@ -34,8 +35,8 @@ class Group : protected Pointers {
void write_restart(FILE *); void write_restart(FILE *);
void read_restart(FILE *); void read_restart(FILE *);
double count(int); // count atoms in group bigint count(int); // count atoms in group
double count(int,int); // count atoms in group & region bigint count(int,int); // count atoms in group & region
double mass(int); // total mass of atoms in group double mass(int); // total mass of atoms in group
double mass(int,int); double mass(int,int);
double charge(int); // total charge of atoms in group double charge(int); // total charge of atoms in group

View File

@ -536,7 +536,7 @@ void Velocity::zero_momentum()
{ {
// cannot have 0 atoms in group // cannot have 0 atoms in group
if (group->count(igroup) == 0.0) if (group->count(igroup) == 0)
error->all("Cannot zero momentum of 0 atoms"); error->all("Cannot zero momentum of 0 atoms");
// compute velocity of center-of-mass of group // compute velocity of center-of-mass of group
@ -569,7 +569,7 @@ void Velocity::zero_rotation()
// cannot have 0 atoms in group // cannot have 0 atoms in group
if (group->count(igroup) == 0.0) if (group->count(igroup) == 0)
error->all("Cannot zero momentum of 0 atoms"); error->all("Cannot zero momentum of 0 atoms");
// compute omega (angular velocity) of group around center-of-mass // compute omega (angular velocity) of group around center-of-mass