git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@7851 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -89,6 +89,7 @@ void CreateAtoms::command(int narg, char **arg)
|
|||||||
// process optional keywords
|
// process optional keywords
|
||||||
|
|
||||||
int scaleflag = 1;
|
int scaleflag = 1;
|
||||||
|
remapflag = 0;
|
||||||
|
|
||||||
if (domain->lattice) {
|
if (domain->lattice) {
|
||||||
nbasis = domain->lattice->nbasis;
|
nbasis = domain->lattice->nbasis;
|
||||||
@ -108,6 +109,12 @@ void CreateAtoms::command(int narg, char **arg)
|
|||||||
error->all(FLERR,"Illegal create_atoms command");
|
error->all(FLERR,"Illegal create_atoms command");
|
||||||
basistype[ibasis-1] = itype;
|
basistype[ibasis-1] = itype;
|
||||||
iarg += 3;
|
iarg += 3;
|
||||||
|
} else if (strcmp(arg[iarg],"remap") == 0) {
|
||||||
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_atoms command");
|
||||||
|
if (strcmp(arg[iarg+1],"yes") == 0) remapflag = 1;
|
||||||
|
else if (strcmp(arg[iarg+1],"no") == 0) remapflag = 0;
|
||||||
|
else error->all(FLERR,"Illegal create_atoms command");
|
||||||
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"units") == 0) {
|
} else if (strcmp(arg[iarg],"units") == 0) {
|
||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal create_atoms command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal create_atoms command");
|
||||||
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
|
||||||
@ -214,6 +221,13 @@ void CreateAtoms::add_single()
|
|||||||
{
|
{
|
||||||
double *sublo,*subhi;
|
double *sublo,*subhi;
|
||||||
|
|
||||||
|
// remap atom if requested
|
||||||
|
|
||||||
|
if (remapflag) {
|
||||||
|
int imagetmp = (512 << 20) | (512 << 10) | 512;
|
||||||
|
domain->remap(xone,imagetmp);
|
||||||
|
}
|
||||||
|
|
||||||
// sub-domain bounding box, in lamda units if triclinic
|
// sub-domain bounding box, in lamda units if triclinic
|
||||||
|
|
||||||
if (domain->triclinic == 0) {
|
if (domain->triclinic == 0) {
|
||||||
|
|||||||
@ -33,6 +33,7 @@ class CreateAtoms : protected Pointers {
|
|||||||
int itype,style,nregion,nbasis,nrandom,seed;
|
int itype,style,nregion,nbasis,nrandom,seed;
|
||||||
int *basistype;
|
int *basistype;
|
||||||
double xone[3];
|
double xone[3];
|
||||||
|
int remapflag;
|
||||||
|
|
||||||
void add_single();
|
void add_single();
|
||||||
void add_random();
|
void add_random();
|
||||||
|
|||||||
@ -82,12 +82,14 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
|
|
||||||
// grab optional keywords
|
// grab optional keywords
|
||||||
|
|
||||||
|
int any_flag = 0;
|
||||||
int undo_flag = 0;
|
int undo_flag = 0;
|
||||||
int remove_flag = 0;
|
int remove_flag = 0;
|
||||||
int special_flag = 0;
|
int special_flag = 0;
|
||||||
|
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg],"undo") == 0) undo_flag = 1;
|
if (strcmp(arg[iarg],"any") == 0) any_flag = 1;
|
||||||
|
else if (strcmp(arg[iarg],"undo") == 0) undo_flag = 1;
|
||||||
else if (strcmp(arg[iarg],"remove") == 0) remove_flag = 1;
|
else if (strcmp(arg[iarg],"remove") == 0) remove_flag = 1;
|
||||||
else if (strcmp(arg[iarg],"special") == 0) special_flag = 1;
|
else if (strcmp(arg[iarg],"special") == 0) special_flag = 1;
|
||||||
else error->all(FLERR,"Illegal delete_bonds command");
|
else error->all(FLERR,"Illegal delete_bonds command");
|
||||||
@ -107,7 +109,7 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
|
|
||||||
// set topology interactions either off or on
|
// set topology interactions either off or on
|
||||||
// criteria for an interaction to potentially be changed (set flag = 1)
|
// criteria for an interaction to potentially be changed (set flag = 1)
|
||||||
// all atoms in interaction must be in group
|
// all atoms or one atom in interaction must be in group, based on any_flag
|
||||||
// for style = MULTI, no other criteria
|
// for style = MULTI, no other criteria
|
||||||
// for style = ATOM, at least one atom is specified type
|
// for style = ATOM, at least one atom is specified type
|
||||||
// for style = BOND/ANGLE/DIHEDRAL/IMPROPER, interaction is specified type
|
// for style = BOND/ANGLE/DIHEDRAL/IMPROPER, interaction is specified type
|
||||||
@ -120,7 +122,7 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
int *type = atom->type;
|
int *type = atom->type;
|
||||||
int nlocal = atom->nlocal;
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
int i,m,n,flag;
|
int i,m,n,consider,flag;
|
||||||
int atom1,atom2,atom3,atom4;
|
int atom1,atom2,atom3,atom4;
|
||||||
|
|
||||||
if (atom->avec->bonds_allow) {
|
if (atom->avec->bonds_allow) {
|
||||||
@ -131,7 +133,12 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
for (m = 0; m < num_bond[i]; m++) {
|
for (m = 0; m < num_bond[i]; m++) {
|
||||||
atom1 = atom->map(atom->bond_atom[i][m]);
|
atom1 = atom->map(atom->bond_atom[i][m]);
|
||||||
if (atom1 == -1) error->one(FLERR,"Bond atom missing in delete_bonds");
|
if (atom1 == -1) error->one(FLERR,"Bond atom missing in delete_bonds");
|
||||||
if (mask[i] & groupbit && mask[atom1] & groupbit) {
|
consider = 0;
|
||||||
|
if (!any_flag && mask[i] & groupbit && mask[atom1] & groupbit)
|
||||||
|
consider = 1;
|
||||||
|
if (any_flag && (mask[i] & groupbit || mask[atom1] & groupbit))
|
||||||
|
consider = 1;
|
||||||
|
if (consider) {
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (style == MULTI) flag = 1;
|
if (style == MULTI) flag = 1;
|
||||||
if (style == ATOM &&
|
if (style == ATOM &&
|
||||||
@ -159,8 +166,12 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
atom3 = atom->map(atom->angle_atom3[i][m]);
|
atom3 = atom->map(atom->angle_atom3[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1)
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1)
|
||||||
error->one(FLERR,"Angle atom missing in delete_bonds");
|
error->one(FLERR,"Angle atom missing in delete_bonds");
|
||||||
if (mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
consider = 0;
|
||||||
mask[atom3] & groupbit) {
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
||||||
|
mask[atom3] & groupbit) consider = 1;
|
||||||
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
||||||
|
mask[atom3] & groupbit)) consider = 1;
|
||||||
|
if (consider) {
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (style == MULTI) flag = 1;
|
if (style == MULTI) flag = 1;
|
||||||
if (style == ATOM &&
|
if (style == ATOM &&
|
||||||
@ -190,8 +201,13 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
atom4 = atom->map(atom->dihedral_atom4[i][m]);
|
atom4 = atom->map(atom->dihedral_atom4[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
||||||
error->one(FLERR,"Dihedral atom missing in delete_bonds");
|
error->one(FLERR,"Dihedral atom missing in delete_bonds");
|
||||||
if (mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
consider = 0;
|
||||||
mask[atom3] & groupbit && mask[atom4] & groupbit) {
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
||||||
|
mask[atom3] & groupbit && mask[atom4] & groupbit) consider = 1;
|
||||||
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
||||||
|
mask[atom3] & groupbit || mask[atom4] & groupbit))
|
||||||
|
consider = 1;
|
||||||
|
if (consider) {
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (style == MULTI) flag = 1;
|
if (style == MULTI) flag = 1;
|
||||||
if (style == ATOM &&
|
if (style == ATOM &&
|
||||||
@ -221,8 +237,13 @@ void DeleteBonds::command(int narg, char **arg)
|
|||||||
atom4 = atom->map(atom->improper_atom4[i][m]);
|
atom4 = atom->map(atom->improper_atom4[i][m]);
|
||||||
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
if (atom1 == -1 || atom2 == -1 || atom3 == -1 || atom4 == -1)
|
||||||
error->one(FLERR,"Improper atom missing in delete_bonds");
|
error->one(FLERR,"Improper atom missing in delete_bonds");
|
||||||
if (mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
consider = 0;
|
||||||
mask[atom3] & groupbit && mask[atom4] & groupbit) {
|
if (!any_flag && mask[atom1] & groupbit && mask[atom2] & groupbit &&
|
||||||
|
mask[atom3] & groupbit && mask[atom4] & groupbit) consider = 1;
|
||||||
|
if (any_flag && (mask[atom1] & groupbit || mask[atom2] & groupbit ||
|
||||||
|
mask[atom3] & groupbit || mask[atom4] & groupbit))
|
||||||
|
consider = 1;
|
||||||
|
if (consider) {
|
||||||
flag = 0;
|
flag = 0;
|
||||||
if (style == MULTI) flag = 1;
|
if (style == MULTI) flag = 1;
|
||||||
if (style == ATOM &&
|
if (style == ATOM &&
|
||||||
|
|||||||
@ -284,7 +284,7 @@ void Input::parse()
|
|||||||
|
|
||||||
strcpy(copy,line);
|
strcpy(copy,line);
|
||||||
|
|
||||||
// strip any # comment by resetting string terminator
|
// strip any # comment by replacing it with 0
|
||||||
// do not strip # inside single/double quotes
|
// do not strip # inside single/double quotes
|
||||||
|
|
||||||
char quote = '\0';
|
char quote = '\0';
|
||||||
@ -306,40 +306,59 @@ void Input::parse()
|
|||||||
|
|
||||||
// command = 1st arg
|
// command = 1st arg
|
||||||
|
|
||||||
command = strtok(copy," \t\n\r\f");
|
char *next;
|
||||||
|
command = nextword(copy,&next);
|
||||||
if (command == NULL) return;
|
if (command == NULL) return;
|
||||||
|
|
||||||
// point arg[] at each subsequent arg
|
// point arg[] at each subsequent arg
|
||||||
// treat text between single/double quotes as one arg
|
// nextword() inserts zeroes in copy to delimit args
|
||||||
// insert string terminators in copy to delimit args
|
// nextword() treats text between single/double quotes as one arg
|
||||||
|
|
||||||
quote = '\0';
|
|
||||||
int iarg,argstart;
|
|
||||||
|
|
||||||
narg = 0;
|
narg = 0;
|
||||||
while (1) {
|
ptr = next;
|
||||||
|
while (ptr) {
|
||||||
if (narg == maxarg) {
|
if (narg == maxarg) {
|
||||||
maxarg += DELTA;
|
maxarg += DELTA;
|
||||||
arg = (char **) memory->srealloc(arg,maxarg*sizeof(char *),"input:arg");
|
arg = (char **) memory->srealloc(arg,maxarg*sizeof(char *),"input:arg");
|
||||||
}
|
}
|
||||||
arg[narg] = strtok(NULL," \t\n\r\f");
|
arg[narg] = nextword(ptr,&next);
|
||||||
if (!arg[narg]) break;
|
if (!arg[narg]) break;
|
||||||
if (!quote && (arg[narg][0] == '"' || arg[narg][0] == '\'')) {
|
|
||||||
quote = arg[narg][0];
|
|
||||||
argstart = narg;
|
|
||||||
arg[narg] = &arg[narg][1];
|
|
||||||
}
|
|
||||||
if (quote && arg[narg][strlen(arg[narg])-1] == quote) {
|
|
||||||
for (iarg = argstart; iarg < narg; iarg++)
|
|
||||||
arg[iarg][strlen(arg[iarg])] = ' ';
|
|
||||||
arg[narg][strlen(arg[narg])-1] = '\0';
|
|
||||||
narg = argstart;
|
|
||||||
quote = '\0';
|
|
||||||
}
|
|
||||||
narg++;
|
narg++;
|
||||||
|
ptr = next;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (quote) error->all(FLERR,"Unbalanced quotes in input line");
|
/* ----------------------------------------------------------------------
|
||||||
|
find next word in str
|
||||||
|
insert 0 at end of word
|
||||||
|
ignore leading whitespace
|
||||||
|
treat text between single/double quotes as one arg
|
||||||
|
matching quote must be followed by whitespace char if not end of string
|
||||||
|
strip quotes from returned word
|
||||||
|
return ptr to start of word
|
||||||
|
return next = ptr after word or NULL if word ended with 0
|
||||||
|
return NULL if no word in string
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
char *Input::nextword(char *str, char **next)
|
||||||
|
{
|
||||||
|
char *start,*stop;
|
||||||
|
|
||||||
|
start = &str[strspn(str," \t\n\v\f\r")];
|
||||||
|
if (*start == '\0') return NULL;
|
||||||
|
|
||||||
|
if (*start == '"' || *start == '\'') {
|
||||||
|
stop = strchr(&start[1],*start);
|
||||||
|
if (!stop) error->all(FLERR,"Unbalanced quotes in input line");
|
||||||
|
if (stop[1] && !isspace(stop[1]))
|
||||||
|
error->all(FLERR,"Input line quote not followed by whitespace");
|
||||||
|
start++;
|
||||||
|
} else stop = &start[strcspn(start," \t\n\v\f\r")];
|
||||||
|
|
||||||
|
if (*stop == '\0') *next = NULL;
|
||||||
|
else *next = stop+1;
|
||||||
|
*stop = '\0';
|
||||||
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|||||||
@ -46,8 +46,9 @@ class Input : protected Pointers {
|
|||||||
|
|
||||||
FILE **infiles; // list of open input files
|
FILE **infiles; // list of open input files
|
||||||
|
|
||||||
void parse(); // parse an input text line
|
void parse(); // parse an input text line
|
||||||
int execute_command(); // execute a single command
|
char *nextword(char *, char **); // find next word in string, with quotes
|
||||||
|
int execute_command(); // execute a single command
|
||||||
|
|
||||||
void clear(); // input script commands
|
void clear(); // input script commands
|
||||||
void echo();
|
void echo();
|
||||||
|
|||||||
@ -502,6 +502,8 @@ void Output::create_restart(int narg, char **arg)
|
|||||||
|
|
||||||
restart = new WriteRestart(lmp);
|
restart = new WriteRestart(lmp);
|
||||||
|
|
||||||
|
if (narg != 2 && narg != 3) error->all(FLERR,"Illegal restart command");
|
||||||
|
|
||||||
int n = strlen(arg[1]) + 3;
|
int n = strlen(arg[1]) + 3;
|
||||||
restart1 = new char[n];
|
restart1 = new char[n];
|
||||||
strcpy(restart1,arg[1]);
|
strcpy(restart1,arg[1]);
|
||||||
|
|||||||
Reference in New Issue
Block a user