git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3674 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
35
src/atom.cpp
35
src/atom.cpp
@ -52,6 +52,10 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
extra_bond_per_atom = 0;
|
||||
|
||||
firstgroupname = NULL;
|
||||
sortfreq = 0;
|
||||
maxbin = maxnext = 0;
|
||||
binhead = NULL;
|
||||
next = permute = NULL;
|
||||
|
||||
// initialize atom arrays
|
||||
// customize by adding new array
|
||||
@ -110,13 +114,6 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
|
||||
nextra_store = 0;
|
||||
extra = NULL;
|
||||
|
||||
// sorting
|
||||
|
||||
sortflag = 0;
|
||||
maxbin = maxnext = 0;
|
||||
binhead = NULL;
|
||||
next = permute = NULL;
|
||||
|
||||
// default mapping values and hash table primes
|
||||
|
||||
tag_enable = 1;
|
||||
@ -146,7 +143,11 @@ Atom::~Atom()
|
||||
{
|
||||
delete [] atom_style;
|
||||
delete avec;
|
||||
|
||||
delete [] firstgroupname;
|
||||
memory->sfree(binhead);
|
||||
memory->sfree(next);
|
||||
memory->sfree(permute);
|
||||
|
||||
// delete atom arrays
|
||||
// customize by adding new array
|
||||
@ -211,12 +212,6 @@ Atom::~Atom()
|
||||
delete [] dipole;
|
||||
delete [] dipole_setflag;
|
||||
|
||||
// delete sorting arrays
|
||||
|
||||
memory->sfree(binhead);
|
||||
memory->sfree(next);
|
||||
memory->sfree(permute);
|
||||
|
||||
// delete extra arrays
|
||||
|
||||
memory->sfree(extra_grow);
|
||||
@ -315,7 +310,7 @@ void Atom::setup()
|
||||
// setup for sorting
|
||||
// binsize = user setting or 1/2 of neighbor cutoff
|
||||
|
||||
if (sortflag) {
|
||||
if (sortfreq > 0) {
|
||||
double binsize;
|
||||
if (userbinsize > 0.0) binsize = userbinsize;
|
||||
else binsize = 0.5 * neighbor->cutneighmax;
|
||||
@ -341,6 +336,8 @@ int Atom::style_match(const char *style)
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
modify parameters of the atom style
|
||||
some options can only be invoked before simulation box is defined
|
||||
first and sort options cannot be used together
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Atom::modify_params(int narg, char **arg)
|
||||
@ -354,6 +351,8 @@ void Atom::modify_params(int narg, char **arg)
|
||||
if (strcmp(arg[iarg+1],"array") == 0) map_style = 1;
|
||||
else if (strcmp(arg[iarg+1],"hash") == 0) map_style = 2;
|
||||
else error->all("Illegal atom_modify command");
|
||||
if (domain->box_exist)
|
||||
error->all("Atom_modify map command after simulation box is defined");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"first") == 0) {
|
||||
if (iarg+2 > narg) error->all("Illegal atom_modify command");
|
||||
@ -363,6 +362,7 @@ void Atom::modify_params(int narg, char **arg)
|
||||
firstgroupname = new char[n];
|
||||
strcpy(firstgroupname,arg[iarg+1]);
|
||||
}
|
||||
sortfreq = 0;
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"sort") == 0) {
|
||||
if (iarg+3 > narg) error->all("Illegal atom_modify command");
|
||||
@ -370,8 +370,9 @@ void Atom::modify_params(int narg, char **arg)
|
||||
userbinsize = atof(arg[iarg+2]);
|
||||
if (sortfreq < 0 || userbinsize < 0.0)
|
||||
error->all("Illegal atom_modify command");
|
||||
if (sortfreq == 0) sortflag = 0;
|
||||
else sortflag = 1;
|
||||
if (sortfreq >= 0 && firstgroupname)
|
||||
error->all("Atom_modify sort and first options "
|
||||
"cannot be used together");
|
||||
iarg += 3;
|
||||
} else error->all("Illegal atom_modify command");
|
||||
}
|
||||
@ -1370,7 +1371,7 @@ void Atom::sort()
|
||||
permute = (int *) memory->smalloc(maxnext*sizeof(int),"atom:permute");
|
||||
}
|
||||
|
||||
// insure one extra location at end of atom arrays
|
||||
// insure there is one extra atom location at end of arrays for swaps
|
||||
|
||||
if (nlocal == nmax) avec->grow(0);
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ class Atom : protected Pointers {
|
||||
|
||||
// spatial sorting of atoms
|
||||
|
||||
int sortflag; // 0 = off, 1 = on
|
||||
int sortfreq; // sort atoms every this many steps, 0 = off
|
||||
int nextsort; // next timestep to sort on
|
||||
|
||||
// functions
|
||||
@ -203,7 +203,6 @@ class Atom : protected Pointers {
|
||||
int *permute; // permutation vector
|
||||
double userbinsize; // sorting bin size
|
||||
double bininv;
|
||||
int sortfreq;
|
||||
|
||||
int memlength; // allocated size of memstr
|
||||
char *memstr; // string of array names already counted
|
||||
|
||||
@ -172,7 +172,7 @@ double ComputePressure::compute_scalar()
|
||||
|
||||
double t;
|
||||
if (keflag) {
|
||||
if (temperature->invoked_scalar == update->ntimestep)
|
||||
if (temperature->invoked_scalar != update->ntimestep)
|
||||
t = temperature->compute_scalar();
|
||||
else t = temperature->scalar;
|
||||
}
|
||||
@ -209,7 +209,7 @@ void ComputePressure::compute_vector()
|
||||
if (update->vflag_global != invoked_vector)
|
||||
error->all("Virial was not tallied on needed timestep");
|
||||
|
||||
// invoke temperature it it hasn't been already
|
||||
// invoke temperature if it hasn't been already
|
||||
|
||||
double *ke_tensor;
|
||||
if (keflag) {
|
||||
|
||||
@ -691,8 +691,6 @@ void Input::angle_style()
|
||||
|
||||
void Input::atom_modify()
|
||||
{
|
||||
if (domain->box_exist)
|
||||
error->all("Atom_modify command after simulation box is defined");
|
||||
atom->modify_params(narg,arg);
|
||||
}
|
||||
|
||||
|
||||
@ -192,12 +192,20 @@ void Modify::init()
|
||||
list_init_compute();
|
||||
|
||||
// init each compute
|
||||
// set invoked_scalar,vector,etc to -1 to force new run to re-compute them
|
||||
// add initial timestep to all computes that store invocation times
|
||||
// since any of them may be invoked by initial thermo
|
||||
// do not clear out invocation times stored within a compute,
|
||||
// b/c some may be holdovers from previous run, like for ave fixes
|
||||
|
||||
for (i = 0; i < ncompute; i++) compute[i]->init();
|
||||
for (i = 0; i < ncompute; i++) {
|
||||
compute[i]->init();
|
||||
compute[i]->invoked_scalar = -1;
|
||||
compute[i]->invoked_vector = -1;
|
||||
compute[i]->invoked_array = -1;
|
||||
compute[i]->invoked_peratom = -1;
|
||||
compute[i]->invoked_local = -1;
|
||||
}
|
||||
addstep_compute_all(update->ntimestep);
|
||||
|
||||
// warn if any particle is time integrated more than once
|
||||
|
||||
@ -222,7 +222,8 @@ void Update::create_minimize(int narg, char **arg)
|
||||
do not allow any timestep-dependent fixes to be defined
|
||||
do not allow any dynamic regions to be defined
|
||||
reset eflag/vflag global so nothing will think eng/virial are current
|
||||
reset invoked flags of computes, so nothing will think they are current
|
||||
reset invoked flags of computes,
|
||||
so nothing will think they are current between runs
|
||||
clear timestep list of computes that store future invocation times
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -249,6 +250,7 @@ void Update::reset_timestep(int narg, char **arg)
|
||||
for (int i = 0; i < modify->ncompute; i++) {
|
||||
modify->compute[i]->invoked_scalar = -1;
|
||||
modify->compute[i]->invoked_vector = -1;
|
||||
modify->compute[i]->invoked_array = -1;
|
||||
modify->compute[i]->invoked_peratom = -1;
|
||||
modify->compute[i]->invoked_local = -1;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ void Verlet::setup()
|
||||
comm->setup();
|
||||
if (neighbor->style) neighbor->setup_bins();
|
||||
comm->exchange();
|
||||
if (atom->sortflag) atom->sort();
|
||||
if (atom->sortfreq > 0) atom->sort();
|
||||
comm->borders();
|
||||
if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost);
|
||||
neighbor->build();
|
||||
@ -178,7 +178,7 @@ void Verlet::setup_minimal(int flag)
|
||||
|
||||
void Verlet::run(int n)
|
||||
{
|
||||
int nflag,ntimestep;
|
||||
int nflag,ntimestep,sortflag;
|
||||
|
||||
int n_post_integrate = modify->n_post_integrate;
|
||||
int n_pre_exchange = modify->n_pre_exchange;
|
||||
@ -186,7 +186,9 @@ void Verlet::run(int n)
|
||||
int n_pre_force = modify->n_pre_force;
|
||||
int n_post_force = modify->n_post_force;
|
||||
int n_end_of_step = modify->n_end_of_step;
|
||||
int sortflag = atom->sortflag;
|
||||
|
||||
if (atom->sortfreq > 0) sortflag = 1;
|
||||
else sortflag = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
||||
@ -217,7 +219,7 @@ void Verlet::run(int n)
|
||||
}
|
||||
timer->stamp();
|
||||
comm->exchange();
|
||||
if (sortflag && ntimestep > atom->nextsort) atom->sort();
|
||||
if (sortflag && ntimestep >= atom->nextsort) atom->sort();
|
||||
comm->borders();
|
||||
if (triclinic) domain->lamda2x(atom->nlocal+atom->nghost);
|
||||
timer->stamp(TIME_COMM);
|
||||
|
||||
Reference in New Issue
Block a user