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

This commit is contained in:
sjplimp
2016-08-04 16:39:15 +00:00
parent 677da2ea52
commit 0bffc1711e
4 changed files with 90 additions and 71 deletions

View File

@ -230,7 +230,6 @@ void CreateAtoms::command(int narg, char **arg)
}
// error check and further setup for variable test
// save local copy of each equal variable string so can restore at end
if (!vstr && (xstr || ystr || zstr))
error->all(FLERR,"Incomplete use of variables in create_atoms command");
@ -248,25 +247,22 @@ void CreateAtoms::command(int narg, char **arg)
xvar = input->variable->find(xstr);
if (xvar < 0)
error->all(FLERR,"Variable name for create_atoms does not exist");
if (!input->variable->equalstyle(xvar))
if (!input->variable->internalstyle(xvar))
error->all(FLERR,"Variable for create_atoms is invalid style");
input->variable->equal_save(xvar,xstr_copy);
}
if (ystr) {
yvar = input->variable->find(ystr);
if (yvar < 0)
error->all(FLERR,"Variable name for create_atoms does not exist");
if (!input->variable->equalstyle(yvar))
if (!input->variable->internalstyle(yvar))
error->all(FLERR,"Variable for create_atoms is invalid style");
input->variable->equal_save(yvar,ystr_copy);
}
if (zstr) {
zvar = input->variable->find(zstr);
if (zvar < 0)
error->all(FLERR,"Variable name for create_atoms does not exist");
if (!input->variable->equalstyle(zvar))
if (!input->variable->internalstyle(zvar))
error->all(FLERR,"Variable for create_atoms is invalid style");
input->variable->equal_save(zvar,zstr_copy);
}
}
@ -377,23 +373,17 @@ void CreateAtoms::command(int narg, char **arg)
for (int i = nlocal_previous; i < nlocal; i++)
fix->set_arrays(i);
}
for (int m = 0; m < modify->ncompute; m++) {
Compute *compute = modify->compute[m];
if (compute->create_attribute)
for (int i = nlocal_previous; i < nlocal; i++)
compute->set_arrays(i);
}
for (int i = nlocal_previous; i < nlocal; i++)
input->variable->set_arrays(i);
// restore each equal variable string previously saved
if (varflag) {
if (xstr) input->variable->equal_restore(xvar,xstr_copy);
if (ystr) input->variable->equal_restore(yvar,ystr_copy);
if (zstr) input->variable->equal_restore(zvar,zstr_copy);
}
// set new total # of atoms and error check
bigint nblocal = atom->nlocal;
@ -853,16 +843,17 @@ void CreateAtoms::add_molecule(double *center, double *quat_user)
/* ----------------------------------------------------------------------
test a generated atom position against variable evaluation
first plug in x,y,z values as requested
first set x,y,z values in internal variables
------------------------------------------------------------------------- */
int CreateAtoms::vartest(double *x)
{
if (xstr) input->variable->equal_override(xvar,x[0]);
if (ystr) input->variable->equal_override(yvar,x[1]);
if (zstr) input->variable->equal_override(zvar,x[2]);
if (xstr) input->variable->internal_set(xvar,x[0]);
if (ystr) input->variable->internal_set(yvar,x[1]);
if (zstr) input->variable->internal_set(zvar,x[2]);
double value = input->variable->compute_equal(vvar);
if (value == 0.0) return 0;
return 1;
}