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

This commit is contained in:
sjplimp
2012-06-18 23:03:41 +00:00
parent ccb9496d22
commit a8af5ea42f
14 changed files with 73 additions and 52 deletions

View File

@ -49,13 +49,8 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
if (!atom->sphere_flag) if (!atom->sphere_flag)
error->all(FLERR,"Fix wall/gran requires atom style sphere"); error->all(FLERR,"Fix wall/gran requires atom style sphere");
// set time_depend so that history will be preserved correctly
// across multiple runs via laststep setting in granular pair styles
// same as fix shear/history
restart_peratom = 1; restart_peratom = 1;
create_attribute = 1; create_attribute = 1;
time_depend = 1;
// wall/particle coefficients // wall/particle coefficients
@ -184,7 +179,6 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
shear[i][0] = shear[i][1] = shear[i][2] = 0.0; shear[i][0] = shear[i][1] = shear[i][2] = 0.0;
time_origin = update->ntimestep; time_origin = update->ntimestep;
laststep = -1;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -289,8 +283,8 @@ void FixWallGran::post_force(int vflag)
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
if (update->ntimestep > laststep) shearupdate = 1; int shearupdate = 1;
else shearupdate = 0; if (update->setupflag) shearupdate = 0;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
@ -348,8 +342,6 @@ void FixWallGran::post_force(int vflag)
} }
} }
} }
laststep = update->ntimestep;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -55,7 +55,6 @@ class FixWallGran : public Fix {
int nlevels_respa; int nlevels_respa;
int time_origin; int time_origin;
bigint laststep;
int *touch; int *touch;
double **shear; double **shear;
int shearupdate; int shearupdate;

View File

@ -53,8 +53,9 @@ void PairGranHertzHistory::compute(int eflag, int vflag)
if (eflag || vflag) ev_setup(eflag,vflag); if (eflag || vflag) ev_setup(eflag,vflag);
else evflag = vflag_fdotr = 0; else evflag = vflag_fdotr = 0;
int shearupdate = 0; computeflag = 1;
if (update->ntimestep > laststep) shearupdate = 1; int shearupdate = 1;
if (update->setupflag) shearupdate = 0;
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
@ -243,8 +244,6 @@ void PairGranHertzHistory::compute(int eflag, int vflag)
} }
} }
} }
laststep = update->ntimestep;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -51,7 +51,7 @@ PairGranHookeHistory::PairGranHookeHistory(LAMMPS *lmp) : Pair(lmp)
single_extra = 4; single_extra = 4;
svector = new double[4]; svector = new double[4];
laststep = -1; computeflag = 0;
neighprev = 0; neighprev = 0;
} }
@ -94,8 +94,9 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
if (eflag || vflag) ev_setup(eflag,vflag); if (eflag || vflag) ev_setup(eflag,vflag);
else evflag = vflag_fdotr = 0; else evflag = vflag_fdotr = 0;
int shearupdate = 0; computeflag = 1;
if (update->ntimestep > laststep) shearupdate = 1; int shearupdate = 1;
if (update->setupflag) shearupdate = 0;
double **x = atom->x; double **x = atom->x;
double **v = atom->v; double **v = atom->v;
@ -283,8 +284,6 @@ void PairGranHookeHistory::compute(int eflag, int vflag)
} }
} }
} }
laststep = update->ntimestep;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
@ -393,7 +392,8 @@ void PairGranHookeHistory::init_style()
// if first init, create Fix needed for storing shear history // if first init, create Fix needed for storing shear history
if (history && force->newton_pair == 1) if (history && force->newton_pair == 1)
error->all(FLERR,"Pair granular with shear history requires newton pair off"); error->all(FLERR,
"Pair granular with shear history requires newton pair off");
if (history && fix_history == NULL) { if (history && fix_history == NULL) {
char **fixarg = new char*[3]; char **fixarg = new char*[3];

View File

@ -26,6 +26,8 @@ namespace LAMMPS_NS {
class PairGranHookeHistory : public Pair { class PairGranHookeHistory : public Pair {
public: public:
int computeflag;
PairGranHookeHistory(class LAMMPS *); PairGranHookeHistory(class LAMMPS *);
virtual ~PairGranHookeHistory(); virtual ~PairGranHookeHistory();
virtual void compute(int, int); virtual void compute(int, int);
@ -48,15 +50,12 @@ class PairGranHookeHistory : public Pair {
int freeze_group_bit; int freeze_group_bit;
int history; int history;
bigint laststep;
class FixShearHistory *fix_history;
char *suffix; char *suffix;
int neighprev;
double *onerad_dynamic,*onerad_frozen; double *onerad_dynamic,*onerad_frozen;
double *maxrad_dynamic,*maxrad_frozen; double *maxrad_dynamic,*maxrad_frozen;
int neighprev; class FixShearHistory *fix_history;
void allocate(); void allocate();
}; };

View File

@ -117,6 +117,7 @@ class Fix : protected Pointers {
virtual void post_force_respa(int, int, int) {} virtual void post_force_respa(int, int, int) {}
virtual void final_integrate_respa(int, int) {} virtual void final_integrate_respa(int, int) {}
virtual void min_setup_pre_exchange() {}
virtual void min_setup_pre_force(int) {} virtual void min_setup_pre_force(int) {}
virtual void min_pre_exchange() {} virtual void min_pre_exchange() {}
virtual void min_pre_force(int) {} virtual void min_pre_force(int) {}

View File

@ -18,7 +18,7 @@
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "force.h" #include "force.h"
#include "pair.h" #include "pair_gran_hooke_history.h"
#include "update.h" #include "update.h"
#include "modify.h" #include "modify.h"
#include "memory.h" #include "memory.h"
@ -34,12 +34,8 @@ using namespace FixConst;
FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) : FixShearHistory::FixShearHistory(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) Fix(lmp, narg, arg)
{ {
// set time_depend so that history will be preserved correctly
// across multiple runs via laststep setting in granular pair styles
restart_peratom = 1; restart_peratom = 1;
create_attribute = 1; create_attribute = 1;
time_depend = 1;
// perform initial allocation of atom-based arrays // perform initial allocation of atom-based arrays
// register with atom class // register with atom class
@ -79,6 +75,7 @@ int FixShearHistory::setmask()
{ {
int mask = 0; int mask = 0;
mask |= PRE_EXCHANGE; mask |= PRE_EXCHANGE;
mask |= MIN_PRE_EXCHANGE;
return mask; return mask;
} }
@ -91,16 +88,30 @@ void FixShearHistory::init()
"Pair style granular with history requires atoms have IDs"); "Pair style granular with history requires atoms have IDs");
} }
/* ---------------------------------------------------------------------- */ /* ----------------------------------------------------------------------
called by setup of run or minimize
called by write_restart as input script command
only invoke pre_exchange() if neigh list stores more current history info
than npartner/partner arrays in this fix
that will only be case if pair->compute() has been invoked since
upate of npartner/npartner
this logic avoids 2 problems:
run 100; write_restart; run 100
setup_pre_exchange is called twice (by write_restart and 2nd run setup)
w/out a neighbor list being created in between
read_restart; run 100
setup_pre_exchange called by run setup whacks restart shear history info
------------------------------------------------------------------------- */
void FixShearHistory::setup_pre_exchange() void FixShearHistory::setup_pre_exchange()
{ {
pre_exchange(); if (pair->computeflag) pre_exchange();
pair->computeflag = 0;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
copy shear partner info from neighbor lists to atom arrays copy shear partner info from neighbor lists to atom arrays
so can be exchanged with atoms so can be migrated or stored with atoms
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void FixShearHistory::pre_exchange() void FixShearHistory::pre_exchange()
@ -111,23 +122,14 @@ void FixShearHistory::pre_exchange()
double *shear,*allshear,**firstshear; double *shear,*allshear,**firstshear;
// zero npartner for all current atoms // zero npartner for all current atoms
// do not do this if inum = 0, since will wipe out npartner counts
// inum is 0 when pre_exchange() is called from integrate->setup()
// before first run when no neighbor lists yet exist
// partner info may have just been read from restart file
// and won't be used until granular neighbor lists are built
// if nothing read from restart file, constructor sets npartner = 0
NeighList *list = pair->list;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (i = 0; i < nlocal; i++) npartner[i] = 0;
if (list->inum)
for (i = 0; i < nlocal; i++)
npartner[i] = 0;
// copy shear info from neighbor list atoms to atom arrays // copy shear info from neighbor list atoms to atom arrays
int *tag = atom->tag; int *tag = atom->tag;
NeighList *list = pair->list;
inum = list->inum; inum = list->inum;
ilist = list->ilist; ilist = list->ilist;
numneigh = list->numneigh; numneigh = list->numneigh;
@ -180,6 +182,21 @@ void FixShearHistory::pre_exchange()
error->all(FLERR,"Too many touching neighbors - boost MAXTOUCH"); error->all(FLERR,"Too many touching neighbors - boost MAXTOUCH");
} }
/* ---------------------------------------------------------------------- */
void FixShearHistory::min_setup_pre_exchange()
{
if (pair->computeflag) pre_exchange();
pair->computeflag = 0;
}
/* ---------------------------------------------------------------------- */
void FixShearHistory::min_pre_exchange()
{
pre_exchange();
}
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
memory usage of local atom-based arrays memory usage of local atom-based arrays
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */

View File

@ -36,6 +36,8 @@ class FixShearHistory : public Fix {
void init(); void init();
void setup_pre_exchange(); void setup_pre_exchange();
virtual void pre_exchange(); virtual void pre_exchange();
void min_setup_pre_exchange();
void min_pre_exchange();
double memory_usage(); double memory_usage();
void grow_arrays(int); void grow_arrays(int);
@ -53,7 +55,7 @@ class FixShearHistory : public Fix {
int **partner; // tags for the partners int **partner; // tags for the partners
double ***shearpartner; // 3 shear values with the partner double ***shearpartner; // 3 shear values with the partner
class Pair *pair; class PairGranHookeHistory *pair;
}; };
} }

View File

@ -189,6 +189,8 @@ void Min::setup()
{ {
if (comm->me == 0 && screen) fprintf(screen,"Setting up minimization ...\n"); if (comm->me == 0 && screen) fprintf(screen,"Setting up minimization ...\n");
update->setupflag = 1;
// setup extra global dof due to fixes // setup extra global dof due to fixes
// cannot be done in init() b/c update init() is before modify init() // cannot be done in init() b/c update init() is before modify init()
@ -222,6 +224,7 @@ void Min::setup()
// build neighbor lists // build neighbor lists
atom->setup(); atom->setup();
modify->setup_pre_exchange();
if (triclinic) domain->x2lamda(atom->nlocal); if (triclinic) domain->x2lamda(atom->nlocal);
domain->pbc(); domain->pbc();
domain->reset_box(); domain->reset_box();
@ -279,6 +282,7 @@ void Min::setup()
modify->setup(vflag); modify->setup(vflag);
output->setup(); output->setup();
update->setupflag = 0;
// stats for Finish to print // stats for Finish to print
@ -299,11 +303,14 @@ void Min::setup()
void Min::setup_minimal(int flag) void Min::setup_minimal(int flag)
{ {
update->setupflag = 1;
// setup domain, communication and neighboring // setup domain, communication and neighboring
// acquire ghosts // acquire ghosts
// build neighbor lists // build neighbor lists
if (flag) { if (flag) {
modify->setup_pre_exchange();
if (triclinic) domain->x2lamda(atom->nlocal); if (triclinic) domain->x2lamda(atom->nlocal);
domain->pbc(); domain->pbc();
domain->reset_box(); domain->reset_box();
@ -351,6 +358,7 @@ void Min::setup_minimal(int flag)
requestor[m]->min_xf_get(m); requestor[m]->min_xf_get(m);
modify->setup(vflag); modify->setup(vflag);
update->setupflag = 0;
// stats for Finish to print // stats for Finish to print

View File

@ -235,8 +235,12 @@ void Modify::setup(int vflag)
void Modify::setup_pre_exchange() void Modify::setup_pre_exchange()
{ {
for (int i = 0; i < n_pre_exchange; i++) if (update->whichflag == 1)
fix[list_pre_exchange[i]]->setup_pre_exchange(); for (int i = 0; i < n_pre_exchange; i++)
fix[list_pre_exchange[i]]->setup_pre_exchange();
else if (update->whichflag == 2)
for (int i = 0; i < n_min_pre_exchange; i++)
fix[list_min_pre_exchange[i]]->min_setup_pre_exchange();
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -64,7 +64,6 @@ class Modify : protected Pointers {
void post_force_respa(int, int, int); void post_force_respa(int, int, int);
void final_integrate_respa(int, int); void final_integrate_respa(int, int);
void setup_min_pre_force(int);
void min_pre_exchange(); void min_pre_exchange();
void min_pre_force(int); void min_pre_force(int);
void min_post_force(int); void min_post_force(int);

View File

@ -418,6 +418,7 @@ void Respa::setup_minimal(int flag)
// build neighbor lists // build neighbor lists
if (flag) { if (flag) {
modify->setup_pre_exchange();
if (triclinic) domain->x2lamda(atom->nlocal); if (triclinic) domain->x2lamda(atom->nlocal);
domain->pbc(); domain->pbc();
domain->reset_box(); domain->reset_box();

View File

@ -158,6 +158,7 @@ void Verlet::setup_minimal(int flag)
// build neighbor lists // build neighbor lists
if (flag) { if (flag) {
modify->setup_pre_exchange();
if (triclinic) domain->x2lamda(atom->nlocal); if (triclinic) domain->x2lamda(atom->nlocal);
domain->pbc(); domain->pbc();
domain->reset_box(); domain->reset_box();

View File

@ -95,12 +95,11 @@ void WriteRestart::command(int narg, char **arg)
lmp->init(); lmp->init();
// move atoms to new processors before writing file // move atoms to new processors before writing file
// do pre_exchange so FixShearHistory will store // do setup_pre_exchange to force update of per-atom info if needed
// current neigh info with atoms
// enforce PBC in case atoms are outside box // enforce PBC in case atoms are outside box
// call borders() to rebuild atom map since exchange() destroys map // call borders() to rebuild atom map since exchange() destroys map
if (modify->n_pre_exchange) modify->pre_exchange(); modify->setup_pre_exchange();
if (domain->triclinic) domain->x2lamda(atom->nlocal); if (domain->triclinic) domain->x2lamda(atom->nlocal);
domain->pbc(); domain->pbc();
domain->reset_box(); domain->reset_box();