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

This commit is contained in:
sjplimp
2014-06-14 21:25:49 +00:00
parent 2ec1442e97
commit 75a456247d
2 changed files with 37 additions and 1 deletions

View File

@ -80,6 +80,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
int cudaflag = 0;
int kokkosflag = 0;
int restartflag = 0;
int restartremapflag = 0;
int citeflag = 1;
int helpflag = 0;
@ -188,6 +189,14 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
restartflag = 1;
rfile = arg[iarg+1];
dfile = arg[iarg+2];
// check for restart remap flag
if (strcmp(dfile,"remap") == 0) {
if (iarg+4 > narg)
error->universe_all(FLERR,"Invalid command-line argument");
restartremapflag = 1;
dfile = arg[iarg+3];
iarg++;
}
iarg += 3;
// delimit any extra args for the write_data command
wdfirst = iarg;
@ -481,6 +490,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
if (restartflag) {
char cmd[128];
sprintf(cmd,"read_restart %s\n",rfile);
if (restartremapflag) strcat(cmd," remap\n");
input->one(cmd);
sprintf(cmd,"write_data %s",dfile);
for (iarg = wdfirst; iarg < wdlast; iarg++)

View File

@ -73,7 +73,7 @@ ReadRestart::ReadRestart(LAMMPS *lmp) : Pointers(lmp) {}
void ReadRestart::command(int narg, char **arg)
{
if (narg != 1) error->all(FLERR,"Illegal read_restart command");
if (narg != 1 && narg != 2) error->all(FLERR,"Illegal read_restart command");
if (domain->box_exist)
error->all(FLERR,"Cannot read_restart after simulation box is defined");
@ -81,6 +81,14 @@ void ReadRestart::command(int narg, char **arg)
MPI_Comm_rank(world,&me);
MPI_Comm_size(world,&nprocs);
// check for remap option
int remapflag = 0;
if (narg == 2) {
if (strcmp(arg[1],"remap") == 0) remapflag = 1;
else error->all(FLERR,"Illegal read_restart command");
}
// if filename contains "*", search dir for latest restart file
char *file = new char[strlen(arg[0]) + 16];
@ -204,11 +212,13 @@ void ReadRestart::command(int narg, char **arg)
// nprocs_file = # of chunks in file
// proc 0 reads a chunk and bcasts it to other procs
// each proc unpacks the atoms, saving ones in it's sub-domain
// if remapflag set, remap the atom to box before checking sub-domain
// check for atom in sub-domain differs for orthogonal vs triclinic box
else if (multiproc == 0) {
int triclinic = domain->triclinic;
imageint *iptr;
double *x,lamda[3];
double *coord,*sublo,*subhi;
if (triclinic == 0) {
@ -234,6 +244,11 @@ void ReadRestart::command(int narg, char **arg)
m = 0;
while (m < n) {
x = &buf[m+1];
if (remapflag) {
iptr = (imageint *) &buf[m+7];
domain->remap(x,*iptr);
}
if (triclinic) {
domain->x2lamda(x,lamda);
coord = lamda;
@ -411,6 +426,17 @@ void ReadRestart::command(int narg, char **arg)
if (multiproc || mpiioflag) {
// if remapflag set, remap all atoms I read back to box before migrating
if (remapflag) {
double **x = atom->x;
imageint *image = atom->image;
int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++)
domain->remap(x[i],image[i]);
}
// create a temporary fix to hold and migrate extra atom info
// necessary b/c irregular will migrate atoms