more changes to merge with current master
This commit is contained in:
@ -380,29 +380,23 @@ ComputePropertyAtom::ComputePropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
"atom property that isn't allocated");
|
"atom property that isn't allocated");
|
||||||
pack_choice[i] = &ComputePropertyAtom::pack_nbonds;
|
pack_choice[i] = &ComputePropertyAtom::pack_nbonds;
|
||||||
|
|
||||||
} else if (strcmp(arg[iarg],"buckling") == 0) {
|
|
||||||
if (!atom->mesont_flag)
|
|
||||||
error->all(FLERR,"Compute property/atom for "
|
|
||||||
"atom property that isn't allocated");
|
|
||||||
pack_choice[i] = &ComputePropertyAtom::pack_buckling;
|
|
||||||
|
|
||||||
// custom per-atom vector
|
// custom per-atom vector
|
||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^i_")) {
|
} else if (utils::strmatch(arg[iarg],"^i_")) {
|
||||||
int flag,icol;
|
int flag,cols;
|
||||||
index[i] = atom->find_custom(&arg[iarg][2],flag,icol);
|
index[i] = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||||
if (index[i] < 0 || flag || icol)
|
if (index[i] < 0 || flag || cols)
|
||||||
error->all(FLERR,"Compute property/atom integer "
|
error->all(FLERR,"Compute property/atom integer "
|
||||||
"vector does not exist");
|
"vector does not exist");
|
||||||
pack_choice[i] = &ComputePropertyAtom::pack_iname;
|
pack_choice[i] = &ComputePropertyAtom::pack_iname;
|
||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^d_")) {
|
} else if (utils::strmatch(arg[iarg],"^d_")) {
|
||||||
int flag;
|
int flag,cols;
|
||||||
index[i] = atom->find_custom(&arg[iarg][2],flag,icol);
|
index[i] = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||||
if (index[i] < 0 || flag || icol1)
|
if (index[i] < 0 || flag || cols)
|
||||||
error->all(FLERR,"Compute property/atom floating point "
|
error->all(FLERR,"Compute property/atom floating point "
|
||||||
"vector does not exist");
|
"vector does not exist");
|
||||||
pack_choice[i] = &ComputePropertyAtom::pack_dname;
|
pack_choice[i] = &ComputePropertyAtom::pack_dname;
|
||||||
}
|
|
||||||
|
|
||||||
// custom per-atom arrays, must include bracketed index
|
// custom per-atom arrays, must include bracketed index
|
||||||
// OLDSTYLE code
|
// OLDSTYLE code
|
||||||
@ -1203,21 +1197,6 @@ void ComputePropertyAtom::pack_fmz(int n)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ComputePropertyAtom::pack_nbonds(int n)
|
|
||||||
{
|
|
||||||
int *num_bond = atom->num_bond;
|
|
||||||
int *mask = atom->mask;
|
|
||||||
int nlocal = atom->nlocal;
|
|
||||||
|
|
||||||
for (int i = 0; i < nlocal; i++) {
|
|
||||||
if (mask[i] & groupbit) buf[n] = num_bond[i];
|
|
||||||
else buf[n] = 0.0;
|
|
||||||
n += nvalues;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
void ComputePropertyAtom::pack_radius(int n)
|
void ComputePropertyAtom::pack_radius(int n)
|
||||||
{
|
{
|
||||||
double *radius = atom->radius;
|
double *radius = atom->radius;
|
||||||
@ -1853,6 +1832,21 @@ void ComputePropertyAtom::pack_corner3z(int n)
|
|||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void ComputePropertyAtom::pack_nbonds(int n)
|
||||||
|
{
|
||||||
|
int *num_bond = atom->num_bond;
|
||||||
|
int *mask = atom->mask;
|
||||||
|
int nlocal = atom->nlocal;
|
||||||
|
|
||||||
|
for (int i = 0; i < nlocal; i++) {
|
||||||
|
if (mask[i] & groupbit) buf[n] = num_bond[i];
|
||||||
|
else buf[n] = 0.0;
|
||||||
|
n += nvalues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
void ComputePropertyAtom::pack_iname(int n)
|
void ComputePropertyAtom::pack_iname(int n)
|
||||||
{
|
{
|
||||||
int *ivector = atom->ivector[index[n]];
|
int *ivector = atom->ivector[index[n]];
|
||||||
|
|||||||
@ -90,8 +90,6 @@ class ComputePropertyAtom : public Compute {
|
|||||||
void pack_fmy(int);
|
void pack_fmy(int);
|
||||||
void pack_fmz(int);
|
void pack_fmz(int);
|
||||||
|
|
||||||
void pack_nbonds(int);
|
|
||||||
|
|
||||||
void pack_radius(int);
|
void pack_radius(int);
|
||||||
void pack_diameter(int);
|
void pack_diameter(int);
|
||||||
void pack_omegax(int);
|
void pack_omegax(int);
|
||||||
@ -129,6 +127,8 @@ class ComputePropertyAtom : public Compute {
|
|||||||
void pack_corner3y(int);
|
void pack_corner3y(int);
|
||||||
void pack_corner3z(int);
|
void pack_corner3z(int);
|
||||||
|
|
||||||
|
void pack_nbonds(int);
|
||||||
|
|
||||||
void pack_iname(int);
|
void pack_iname(int);
|
||||||
void pack_dname(int);
|
void pack_dname(int);
|
||||||
void pack_i2name(int);
|
void pack_i2name(int);
|
||||||
|
|||||||
@ -1444,54 +1444,15 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
} else if (strcmp(arg[iarg],"tqz") == 0) {
|
} else if (strcmp(arg[iarg],"tqz") == 0) {
|
||||||
if (!atom->torque_flag)
|
if (!atom->torque_flag)
|
||||||
error->all(FLERR,"Dumping an atom property that isn't allocated");
|
error->all(FLERR,"Dumping an atom property that isn't allocated");
|
||||||
pack_choice[i] = &DumpCustom::pack_tqz;
|
pack_choice[iarg] = &DumpCustom::pack_tqz;
|
||||||
vtype[i] = Dump::DOUBLE;
|
vtype[iarg] = Dump::DOUBLE;
|
||||||
|
|
||||||
// custom per-atom array = i2_ID or d2_ID, must include bracketed index
|
|
||||||
// OLDSTYLE code - remove this after extend ArgInfo for i2/d2 arrays
|
|
||||||
|
|
||||||
} else if (strncmp(arg[iarg],"i2_",3) == 0 ||
|
|
||||||
strncmp(arg[iarg],"d2_",3) == 0) {
|
|
||||||
int which = 0;
|
|
||||||
if (arg[iarg][0] == 'd') which = 1;
|
|
||||||
|
|
||||||
pack_choice[i] = &DumpCustom::pack_custom;
|
|
||||||
if (!which) vtype[i] = Dump::INT;
|
|
||||||
else vtype[i] = Dump::DOUBLE;
|
|
||||||
|
|
||||||
int n = strlen(arg[iarg]);
|
|
||||||
char *suffix = new char[n];
|
|
||||||
strcpy(suffix,&arg[iarg][3]);
|
|
||||||
|
|
||||||
char *ptr = strchr(suffix,'[');
|
|
||||||
if (ptr) {
|
|
||||||
if (suffix[strlen(suffix)-1] != ']')
|
|
||||||
error->all(FLERR,"Invalid attribute in dump custom command");
|
|
||||||
suffix[strlen(suffix)-1] = '\0';
|
|
||||||
argindex[i] = utils::inumeric(FLERR,ptr+1,true,lmp);
|
|
||||||
*ptr = '\0';
|
|
||||||
} else error->all(FLERR,"Dump custom per-atom custom array is not indexed");
|
|
||||||
|
|
||||||
int flag,cols;
|
|
||||||
n = atom->find_custom(suffix,flag,cols);
|
|
||||||
|
|
||||||
if ((!which && (n < 0 || flag || !cols)) ||
|
|
||||||
(which && (n < 0 || !flag || !cols)))
|
|
||||||
error->all(FLERR,"Dump custom per-atom custom array does not exist");
|
|
||||||
if (argindex[i] <= 0 || argindex[i] > cols)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Dump custom per-atom custom array is accessed out-of-range");
|
|
||||||
|
|
||||||
field2index[i] = add_custom(suffix,which);
|
|
||||||
delete [] suffix;
|
|
||||||
|
|
||||||
// compute or fix or variable or custom vector/array
|
// compute or fix or variable or custom vector/array
|
||||||
// NEWSTYLE code - add ArgInfo returns for IVEC, DVEC, IARRAY, DARRAY
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int n,tmp;
|
int n,flag,cols;
|
||||||
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||||
|ArgInfo::DVEC|ArgInfo::IVEC);
|
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||||
argindex[iarg] = argi.get_index1();
|
argindex[iarg] = argi.get_index1();
|
||||||
auto name = argi.get_name();
|
auto name = argi.get_name();
|
||||||
|
|
||||||
@ -1559,50 +1520,58 @@ int DumpCustom::parse_fields(int narg, char **arg)
|
|||||||
field2index[iarg] = add_variable(name);
|
field2index[iarg] = add_variable(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per-atom floating point vector = d_ID
|
// custom per-atom floating point vector or array
|
||||||
|
|
||||||
case ArgInfo::DVEC:
|
case ArgInfo::DNAME:
|
||||||
pack_choice[iarg] = &DumpCustom::pack_custom;
|
pack_choice[iarg] = &DumpCustom::pack_custom;
|
||||||
vtype[iarg] = Dump::DOUBLE;
|
vtype[iarg] = Dump::DOUBLE;
|
||||||
|
|
||||||
tmp = -1;
|
n = atom->find_custom(name,flag,cols);
|
||||||
n = atom->find_custom(name,tmp);
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||||
|
if (argindex[iarg] == 0) {
|
||||||
if (tmp != 1)
|
if (!flag || cols)
|
||||||
error->all(FLERR,"Custom per-atom property ID {} is not floating point", name);
|
error->all(FLERR,
|
||||||
|
"Property double vector for dump custom does not exist");
|
||||||
|
} else {
|
||||||
|
if (!flag || !cols)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Property double array for dump custom does not exist");
|
||||||
|
if (argindex[iarg] > atom->dcols[n])
|
||||||
|
error->all(FLERR,
|
||||||
|
"Dump custom property array is accessed out-of-range");
|
||||||
|
}
|
||||||
|
|
||||||
field2index[iarg] = add_custom(name,1);
|
field2index[iarg] = add_custom(name,1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per-atom integer vector = i_ID
|
// custom per-atom integer vector or array
|
||||||
|
|
||||||
case ArgInfo::IVEC:
|
case ArgInfo::INAME:
|
||||||
pack_choice[iarg] = &DumpCustom::pack_custom;
|
pack_choice[iarg] = &DumpCustom::pack_custom;
|
||||||
vtype[iarg] = Dump::INT;
|
vtype[iarg] = Dump::INT;
|
||||||
|
|
||||||
tmp = -1;
|
n = atom->find_custom(name,flag,cols);
|
||||||
n = atom->find_custom(name,tmp);
|
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||||
|
if (argindex[iarg] == 0) {
|
||||||
if (tmp != 0)
|
if (flag || cols)
|
||||||
error->all(FLERR,"Custom per-atom property ID {} is not integer", name);
|
error->all(FLERR,
|
||||||
|
"Property integer vector for dump custom does not exist");
|
||||||
|
} else {
|
||||||
|
if (flag || !cols)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Property integer array for dump custom does not exist");
|
||||||
|
if (argindex[iarg] > atom->icols[n])
|
||||||
|
error->all(FLERR,
|
||||||
|
"Dump custom property array is accessed out-of-range");
|
||||||
|
}
|
||||||
|
|
||||||
field2index[iarg] = add_custom(name,0);
|
field2index[iarg] = add_custom(name,0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per-atom floating point array = d2_ID
|
|
||||||
|
|
||||||
case ArgInfo::DARRAY:
|
|
||||||
return iarg;
|
|
||||||
|
|
||||||
// custom per-atom integer array = i2_ID
|
|
||||||
|
|
||||||
case ArgInfo::IARRAY:
|
|
||||||
return iarg;
|
|
||||||
|
|
||||||
// no match
|
// no match
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -1915,55 +1884,16 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
else if (strcmp(arg[1],"tqy") == 0) thresh_array[nthresh] = TQY;
|
else if (strcmp(arg[1],"tqy") == 0) thresh_array[nthresh] = TQY;
|
||||||
else if (strcmp(arg[1],"tqz") == 0) thresh_array[nthresh] = TQZ;
|
else if (strcmp(arg[1],"tqz") == 0) thresh_array[nthresh] = TQZ;
|
||||||
|
|
||||||
// custom per-atom array = i2_ID or d2_ID, must include bracketed index
|
|
||||||
// OLDSTYLE code - remove this after extend ArgInfo for i2/d2 arrays
|
|
||||||
|
|
||||||
else if (strncmp(arg[1],"i2_",3) == 0 || strncmp(arg[1],"d2_",3) == 0) {
|
|
||||||
int which = 0;
|
|
||||||
if (arg[1][0] == 'd') which = 1;
|
|
||||||
|
|
||||||
if (!which) thresh_array[nthresh] = IARRAY;
|
|
||||||
else thresh_array[nthresh] = DARRAY;
|
|
||||||
memory->grow(field2index,nfield+nthresh+1,"dump:field2index");
|
|
||||||
memory->grow(argindex,nfield+nthresh+1,"dump:argindex");
|
|
||||||
|
|
||||||
int n = strlen(arg[1]);
|
|
||||||
char *suffix = new char[n];
|
|
||||||
strcpy(suffix,&arg[1][3]);
|
|
||||||
|
|
||||||
char *ptr = strchr(suffix,'[');
|
|
||||||
if (ptr) {
|
|
||||||
if (suffix[strlen(suffix)-1] != ']')
|
|
||||||
error->all(FLERR,"Invalid attribute in dump custom command");
|
|
||||||
suffix[strlen(suffix)-1] = '\0';
|
|
||||||
argindex[nfield+nthresh] = utils::inumeric(FLERR,ptr+1,true,lmp);
|
|
||||||
*ptr = '\0';
|
|
||||||
} else error->all(FLERR,"Dump_modify per-atom custom array is not indexed");
|
|
||||||
|
|
||||||
int flag,cols;
|
|
||||||
n = atom->find_custom(suffix,flag,cols);
|
|
||||||
|
|
||||||
if ((!which && (n < 0 || flag || !cols)) ||
|
|
||||||
(which && (n < 0 || !flag || !cols)))
|
|
||||||
error->all(FLERR,"Could not find dump_modify per-atom custom array");
|
|
||||||
if (argindex[nfield+nthresh] <= 0 || argindex[nfield+nthresh] > cols)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Dump_modify per-atom custom array is accessed out-of-range");
|
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_custom(suffix,which);
|
|
||||||
delete [] suffix;
|
|
||||||
|
|
||||||
// compute or fix or variable or custom vector/array
|
// compute or fix or variable or custom vector/array
|
||||||
// NEWSTYLE code - add ArgInfo returns for IVEC, DVEC, IARRAY, DARRAY
|
|
||||||
// must grow field2index and argindex arrays, since access is beyond nfield
|
// must grow field2index and argindex arrays, since access is beyond nfield
|
||||||
|
|
||||||
} else {
|
else {
|
||||||
memory->grow(field2index,nfield+nthresh+1,"dump:field2index");
|
memory->grow(field2index,nfield+nthresh+1,"dump:field2index");
|
||||||
memory->grow(argindex,nfield+nthresh+1,"dump:argindex");
|
memory->grow(argindex,nfield+nthresh+1,"dump:argindex");
|
||||||
|
|
||||||
int n,tmp;
|
int n,flag,cols;
|
||||||
ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|
||||||
|ArgInfo::DVEC|ArgInfo::IVEC);
|
|ArgInfo::DNAME|ArgInfo::INAME);
|
||||||
argindex[nfield+nthresh] = argi.get_index1();
|
argindex[nfield+nthresh] = argi.get_index1();
|
||||||
auto name = argi.get_name();
|
auto name = argi.get_name();
|
||||||
|
|
||||||
@ -2026,39 +1956,55 @@ int DumpCustom::modify_param(int narg, char **arg)
|
|||||||
field2index[nfield+nthresh] = add_variable(name);
|
field2index[nfield+nthresh] = add_variable(name);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per atom floating point value = d_ID
|
// custom per atom floating point vector or array
|
||||||
|
|
||||||
case ArgInfo::DVEC:
|
case ArgInfo::DNAME:
|
||||||
|
n = atom->find_custom(name,flag,cols);
|
||||||
|
|
||||||
|
if (n < 0)
|
||||||
|
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||||
|
if (argindex[nfield+nthresh] == 0) {
|
||||||
|
if (flag || cols)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Property double vector for dump custom does not exist");
|
||||||
thresh_array[nthresh] = DVEC;
|
thresh_array[nthresh] = DVEC;
|
||||||
tmp = -1;
|
} else {
|
||||||
n = atom->find_custom(name,tmp);
|
if (flag || !cols)
|
||||||
if ((n < 0) || (tmp != 1))
|
error->all(FLERR,
|
||||||
error->all(FLERR,"Could not find dump modify custom atom floating point property ID: {}",name);
|
"Property double array for dump custom does not exist");
|
||||||
|
if (argindex[nfield+nthresh] > atom->dcols[n])
|
||||||
field2index[nfield+nthresh] = add_custom(name,1);
|
error->all(FLERR,
|
||||||
break;
|
"Dump custom property array is accessed out-of-range");
|
||||||
|
thresh_array[nthresh] = DARRAY;
|
||||||
// custom per atom integer value = i_ID
|
}
|
||||||
|
|
||||||
case ArgInfo::IVEC:
|
|
||||||
thresh_array[nthresh] = IVEC;
|
|
||||||
tmp = -1;
|
|
||||||
n = atom->find_custom(name,tmp);
|
|
||||||
if ((n < 0) || (tmp != 0))
|
|
||||||
error->all(FLERR,"Could not find dump modify custom atom integer property ID: {}",name);
|
|
||||||
|
|
||||||
field2index[nfield+nthresh] = add_custom(name,0);
|
field2index[nfield+nthresh] = add_custom(name,0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// custom per-atom floating point array = d2_ID
|
// custom per atom integer vector or array
|
||||||
|
|
||||||
case ArgInfo::DARRAY:
|
case ArgInfo::INAME:
|
||||||
return iarg;
|
n = atom->find_custom(name,flag,cols);
|
||||||
|
|
||||||
// custom per-atom integer array = i2_ID
|
if (n < 0)
|
||||||
|
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
|
||||||
|
if (argindex[nfield+nthresh] == 0) {
|
||||||
|
if (flag || cols)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Property integer vector for dump custom does not exist");
|
||||||
|
thresh_array[nthresh] = IVEC;
|
||||||
|
} else {
|
||||||
|
if (flag || !cols)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Property integer array for dump custom does not exist");
|
||||||
|
if (argindex[nfield+nthresh] > atom->icols[n])
|
||||||
|
error->all(FLERR,
|
||||||
|
"Dump custom property array is accessed out-of-range");
|
||||||
|
thresh_array[nthresh] = IARRAY;
|
||||||
|
}
|
||||||
|
|
||||||
case ArgInfo::IARRAY:
|
field2index[nfield+nthresh] = add_custom(name,0);
|
||||||
return iarg;
|
break;
|
||||||
|
|
||||||
// no match
|
// no match
|
||||||
|
|
||||||
|
|||||||
@ -93,21 +93,21 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^i_")) {
|
} else if (utils::strmatch(arg[iarg],"^i_")) {
|
||||||
style[nvalue] = IVEC;
|
style[nvalue] = IVEC;
|
||||||
int tmp;
|
int flag,cols;
|
||||||
index[nvalue] = atom->find_custom(&arg[iarg][2],tmp);
|
index[nvalue] = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||||
if (index[nvalue] >= 0)
|
if (index[nvalue] >= 0)
|
||||||
error->all(FLERR,"Fix property/atom vector name already exists");
|
error->all(FLERR,"Fix property/atom vector name already exists");
|
||||||
index[nvalue] = atom->add_custom(&arg[iarg][2],0);
|
index[nvalue] = atom->add_custom(&arg[iarg][2],0,0);
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++
|
iarg++;
|
||||||
|
|
||||||
} else if (utils::strmatch(arg[iarg],"^d_")) {
|
} else if (utils::strmatch(arg[iarg],"^d_")) {
|
||||||
style[nvalue] = DVEC;
|
style[nvalue] = DVEC;
|
||||||
int tmp;
|
int flag,ncols;
|
||||||
index[nvalue] = atom->find_custom(&arg[iarg][2],tmp);
|
index[nvalue] = atom->find_custom(&arg[iarg][2],flag,ncols);
|
||||||
if (index[nvalue] >= 0)
|
if (index[nvalue] >= 0)
|
||||||
error->all(FLERR,"Fix property/atom vector name already exists");
|
error->all(FLERR,"Fix property/atom vector name already exists");
|
||||||
index[nvalue] = atom->add_custom(&arg[iarg][2],1);
|
index[nvalue] = atom->add_custom(&arg[iarg][2],1,0);
|
||||||
nvalue++;
|
nvalue++;
|
||||||
iarg++;
|
iarg++;
|
||||||
|
|
||||||
@ -121,8 +121,8 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (arg[iarg][0] == 'd') which = 1;
|
if (arg[iarg][0] == 'd') which = 1;
|
||||||
if (which == 0) style[nvalue] = IARRAY;
|
if (which == 0) style[nvalue] = IARRAY;
|
||||||
else style[nvalue] = DARRAY;
|
else style[nvalue] = DARRAY;
|
||||||
int tmp1,tmp2;
|
int flag,ncols;
|
||||||
index[nvalue] = atom->find_custom(&arg[iarg][3],tmp1,tmp2);
|
index[nvalue] = atom->find_custom(&arg[iarg][3],flag,ncols);
|
||||||
if (index[nvalue] >= 0)
|
if (index[nvalue] >= 0)
|
||||||
error->all(FLERR,"Fix property/atom array name already exists");
|
error->all(FLERR,"Fix property/atom array name already exists");
|
||||||
cols[nvalue] = utils::inumeric(FLERR,arg[iarg+1],true,lmp);
|
cols[nvalue] = utils::inumeric(FLERR,arg[iarg+1],true,lmp);
|
||||||
@ -418,8 +418,10 @@ void FixPropertyAtom::write_data_section_keyword(int /*mth*/, FILE *fp)
|
|||||||
if (style[i] == MOLECULE) fputs(" mol",fp);
|
if (style[i] == MOLECULE) fputs(" mol",fp);
|
||||||
else if (style[i] == CHARGE) fputs(" q",fp);
|
else if (style[i] == CHARGE) fputs(" q",fp);
|
||||||
else if (style[i] == RMASS) fputs(" rmass",fp);
|
else if (style[i] == RMASS) fputs(" rmass",fp);
|
||||||
else if (style[i] == INTEGER) fprintf(fp," i_%s", atom->iname[index[i]]);
|
else if (style[i] == IVEC) fprintf(fp," i_%s", atom->ivname[index[i]]);
|
||||||
else if (style[i] == DOUBLE) fprintf(fp, " d_%s", atom->dname[index[i]]);
|
else if (style[i] == DVEC) fprintf(fp, " d_%s", atom->dvname[index[i]]);
|
||||||
|
else if (style[i] == IARRAY) fprintf(fp, " i_%s", atom->ianame[index[i]]);
|
||||||
|
else if (style[i] == DARRAY) fprintf(fp, " d_%s", atom->daname[index[i]]);
|
||||||
}
|
}
|
||||||
fputs("\n\n",fp);
|
fputs("\n\n",fp);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -222,33 +222,6 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
"Fix store/state for atom property that isn't allocated");
|
"Fix store/state for atom property that isn't allocated");
|
||||||
pack_choice[nvalues++] = &FixStoreState::pack_tqz;
|
pack_choice[nvalues++] = &FixStoreState::pack_tqz;
|
||||||
|
|
||||||
// custom per-atom array
|
|
||||||
// OLDSTYLE code
|
|
||||||
|
|
||||||
} else if (strncmp(arg[iarg],"i2_",3) == 0 ||
|
|
||||||
strncmp(arg[iarg],"d2_",3) == 0) {
|
|
||||||
if (strncmp(arg[iarg],"i2_",3) == 0) which[nvalues] = IARRAY;
|
|
||||||
else if (strncmp(arg[iarg],"d2_",3) == 0) which[nvalues] = DARRAY;
|
|
||||||
|
|
||||||
int n = strlen(arg[iarg]);
|
|
||||||
char *suffix = new char[n];
|
|
||||||
strcpy(suffix,&arg[iarg][3]);
|
|
||||||
|
|
||||||
char *ptr = strchr(suffix,'[');
|
|
||||||
if (!ptr) error->all(FLERR,"Illegal fix store/state command");
|
|
||||||
|
|
||||||
if (suffix[strlen(suffix)-1] != ']')
|
|
||||||
error->all(FLERR,"Illegal fix store/state command");
|
|
||||||
suffix[strlen(suffix)-1] = '\0';
|
|
||||||
argindex[nvalues] = utils::inumeric(FLERR,ptr+1,true,lmp);
|
|
||||||
*ptr = '\0';
|
|
||||||
|
|
||||||
n = strlen(suffix) + 1;
|
|
||||||
ids[nvalues] = new char[n];
|
|
||||||
strcpy(ids[nvalues],suffix);
|
|
||||||
nvalues++;
|
|
||||||
delete [] suffix;
|
|
||||||
|
|
||||||
// compute or fix or variable or custom per-atom vector or array
|
// compute or fix or variable or custom per-atom vector or array
|
||||||
// NEWSTYLE code
|
// NEWSTYLE code
|
||||||
|
|
||||||
@ -293,16 +266,16 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (modify->compute[icompute]->peratom_flag == 0)
|
if (modify->compute[icompute]->peratom_flag == 0)
|
||||||
error->all(FLERR,"Fix store/state compute "
|
error->all(FLERR,"Fix store/state compute "
|
||||||
"does not calculate per-atom values");
|
"does not calculate per-atom values");
|
||||||
if (argindex[m] == 0 &&
|
if (argindex[i] == 0 &&
|
||||||
modify->compute[icompute]->size_peratom_cols != 0)
|
modify->compute[icompute]->size_peratom_cols != 0)
|
||||||
error->all(FLERR,"Fix store/state compute does not "
|
error->all(FLERR,"Fix store/state compute does not "
|
||||||
"calculate a per-atom vector");
|
"calculate a per-atom vector");
|
||||||
if (argindex[m] && modify->compute[icompute]->size_peratom_cols == 0)
|
if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Fix store/state compute does not "
|
"Fix store/state compute does not "
|
||||||
"calculate a per-atom array");
|
"calculate a per-atom array");
|
||||||
if (argindex[m] &&
|
if (argindex[i] &&
|
||||||
argindex[m] > modify->compute[icompute]->size_peratom_cols)
|
argindex[i] > modify->compute[icompute]->size_peratom_cols)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Fix store/state compute array is accessed out-of-range");
|
"Fix store/state compute array is accessed out-of-range");
|
||||||
|
|
||||||
@ -314,13 +287,13 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (modify->fix[ifix]->peratom_flag == 0)
|
if (modify->fix[ifix]->peratom_flag == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Fix store/state fix does not calculate per-atom values");
|
"Fix store/state fix does not calculate per-atom values");
|
||||||
if (argindex[m] == 0 && modify->fix[ifix]->size_peratom_cols != 0)
|
if (argindex[i] == 0 && modify->fix[ifix]->size_peratom_cols != 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Fix store/state fix does not calculate a per-atom vector");
|
"Fix store/state fix does not calculate a per-atom vector");
|
||||||
if (argindex[m] && modify->fix[ifix]->size_peratom_cols == 0)
|
if (argindex[i] && modify->fix[ifix]->size_peratom_cols == 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Fix store/state fix does not calculate a per-atom array");
|
"Fix store/state fix does not calculate a per-atom array");
|
||||||
if (argindex[m] && argindex[m] > modify->fix[ifix]->size_peratom_cols)
|
if (argindex[i] && argindex[i] > modify->fix[ifix]->size_peratom_cols)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Fix store/state fix array is accessed out-of-range");
|
"Fix store/state fix array is accessed out-of-range");
|
||||||
if (nevery % modify->fix[ifix]->peratom_freq)
|
if (nevery % modify->fix[ifix]->peratom_freq)
|
||||||
@ -334,33 +307,41 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
if (input->variable->atomstyle(ivariable) == 0)
|
if (input->variable->atomstyle(ivariable) == 0)
|
||||||
error->all(FLERR,"Fix store/state variable is not atom-style variable");
|
error->all(FLERR,"Fix store/state variable is not atom-style variable");
|
||||||
|
|
||||||
|
} else if (which[i] == ArgInfo::DNAME) {
|
||||||
|
int icustom,iflag,icol;
|
||||||
|
icustom = atom->find_custom(ids[i],iflag,icol);
|
||||||
|
if (icustom < 0)
|
||||||
|
error->all(FLERR,"Custom vector/array for fix store/state does not exist");
|
||||||
|
if (argindex[i] == 0) {
|
||||||
|
if (!iflag || icol)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Custom double vector for fix store/state does not exist");
|
||||||
|
} else {
|
||||||
|
if (!iflag || !icol)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Custom double array for fix store/state does not exist");
|
||||||
|
if (argindex[i] > atom->dcols[icustom])
|
||||||
|
error->all(FLERR,
|
||||||
|
"Fix store/state custom array is accessed out-of-range");
|
||||||
|
}
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::INAME) {
|
} else if (which[i] == ArgInfo::INAME) {
|
||||||
int icustom,iflag,cols;
|
int icustom,iflag,icol;
|
||||||
icustom = atom->find_custom(ids[i],iflag,cols);
|
icustom = atom->find_custom(ids[i],iflag,icol);
|
||||||
if ((icustom < 0) || iflag ||,cols)
|
if (icustom < 0)
|
||||||
|
error->all(FLERR,"Custom vector/array for fix store/state does not exist");
|
||||||
|
if (argindex[i] == 0) {
|
||||||
|
if (iflag || icol)
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Custom integer vector for fix store/state does not exist");
|
"Custom integer vector for fix store/state does not exist");
|
||||||
|
} else {
|
||||||
} else if (which[i] == ArgInfo::DNAME) {
|
if (iflag || !icol)
|
||||||
int icustom,iflag,cols;
|
|
||||||
icustom = atom->find_custom(ids[i],iflag,cols);
|
|
||||||
if ((icustom < 0) || iflag ||,cols)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Custom floating point vector for fix store/state does not exist");
|
|
||||||
|
|
||||||
} else if (which[i] == ArgInfo::IARRAY) {
|
|
||||||
int icustom,flag,cols;
|
|
||||||
icustom = atom->find_custom(ids[i],flag,cols);
|
|
||||||
if ((icustom < 0) || flag || !cols)
|
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Custom integer array for fix store/state does not exist");
|
"Custom integer array for fix store/state does not exist");
|
||||||
|
if (argindex[i] > atom->icols[icustom])
|
||||||
} else if (which[m] == Arginfo::DARRAY) {
|
|
||||||
int icustom,flag,cols;
|
|
||||||
icustom = atom->find_custom(ids[i],flag,cols);
|
|
||||||
if ((icustom < 0) || !flag || !cols)
|
|
||||||
error->all(FLERR,
|
error->all(FLERR,
|
||||||
"Custom floating point array for fix store/state does not exist");
|
"Fix store/state custom array is accessed out-of-range");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,36 +431,13 @@ void FixStoreState::init()
|
|||||||
error->all(FLERR,"Variable name for fix store/state does not exist");
|
error->all(FLERR,"Variable name for fix store/state does not exist");
|
||||||
value2index[m] = ivariable;
|
value2index[m] = ivariable;
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::IVEC) {
|
} else if (which[m] == ArgInfo::INAME || which[m] == ArgInfo::DNAME) {
|
||||||
int icustom,iflag,cols;
|
int icustom,iflag,cols;
|
||||||
icustom = atom->find_custom(ids[m],iflag,cols);
|
icustom = atom->find_custom(ids[m],iflag,cols);
|
||||||
if ((icustom < 0) || iflag || cols)
|
if (icustom < 0)
|
||||||
error->all(FLERR,
|
error->all(FLERR,"Custom vector/array for fix store/state does not exist");
|
||||||
"Custom integer vector for fix store/state does not exist");
|
|
||||||
value2index[m] = icustom;
|
value2index[m] = icustom;
|
||||||
|
}
|
||||||
} else if (which[m] == ArgInfo::DVEC) {
|
|
||||||
int icustom,iflag,cols;
|
|
||||||
icustom = atom->find_custom(ids[m],iflag,cols);
|
|
||||||
if ((icustom < 0) || iflag || cols)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Custom floating point vector for fix store/state does not exist");
|
|
||||||
value2index[m] = icustom;
|
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::IARRAY) {
|
|
||||||
int icustom,iflag,cols;
|
|
||||||
icustom = atom->find_custom(ids[m],iflag,cols);
|
|
||||||
if ((icustom < 0) || iflag || !cols)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Custom integer array for fix store/state does not exist");
|
|
||||||
value2index[m] = icustom;
|
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::DARRAY) {
|
|
||||||
int icustom,iflag,cols;
|
|
||||||
icustom = atom->find_custom(ids[m],iflag,cols);
|
|
||||||
if ((icustom < 0) || iflag || !cols)
|
|
||||||
error->all(FLERR,
|
|
||||||
"Custom floating point array for fix store/state does not exist"); value2index[m] = icustom;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,33 +524,36 @@ void FixStoreState::end_of_step()
|
|||||||
|
|
||||||
// evaluate atom-style variable
|
// evaluate atom-style variable
|
||||||
|
|
||||||
} else if (which[m] == VARIABLE) {
|
} else if (which[m] == ArgInfo::VARIABLE) {
|
||||||
input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0);
|
input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0);
|
||||||
|
|
||||||
|
|
||||||
// access custom atom property fields
|
// access custom atom vector/array fields
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::IVEC) {
|
} else if (which[m] == ArgInfo::DNAME) {
|
||||||
int *ivector = atom->ivector[n];
|
if (j == 0) {
|
||||||
for (i = 0; i < nlocal; i++)
|
|
||||||
if (mask[i] & groupbit) values[i][m] = ivector[i];
|
|
||||||
|
|
||||||
} else if (which[m] == ArgInfo::DVEC) {
|
|
||||||
double *dvector = atom->dvector[n];
|
double *dvector = atom->dvector[n];
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) values[i][m] = dvector[i];
|
if (mask[i] & groupbit) values[i][m] = dvector[i];
|
||||||
|
} else {
|
||||||
} else if (which[m] == ArgInfo::IARRAY) {
|
|
||||||
int **iarray = atom->iarray[n];
|
|
||||||
int jm1 = j - 1;
|
|
||||||
for (i = 0; i < nlocal; i++)
|
|
||||||
if (mask[i] & groupbit) values[i][m] = iarray[i][jm1];
|
|
||||||
} else if (which[m] == ArgInfo::DARRAY) {
|
|
||||||
double **darray = atom->darray[n];
|
double **darray = atom->darray[n];
|
||||||
int jm1 = j - 1;
|
int jm1 = j - 1;
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
if (mask[i] & groupbit) values[i][m] = darray[i][jm1];
|
if (mask[i] & groupbit) values[i][m] = darray[i][jm1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (which[m] == ArgInfo::INAME) {
|
||||||
|
if (j == 0) {
|
||||||
|
int *ivector = atom->ivector[n];
|
||||||
|
for (i = 0; i < nlocal; i++)
|
||||||
|
if (mask[i] & groupbit) values[i][m] = ivector[i];
|
||||||
|
} else {
|
||||||
|
int **iarray = atom->iarray[n];
|
||||||
|
int jm1 = j - 1;
|
||||||
|
for (i = 0; i < nlocal; i++)
|
||||||
|
if (mask[i] & groupbit) values[i][m] = iarray[i][jm1];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3127,7 +3127,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
|
|
||||||
// compute
|
// compute
|
||||||
|
|
||||||
if (vptr==nullptr && utils::strmatch(name,"^c_"))
|
if (vptr==nullptr && utils::strmatch(name,"^c_")) {
|
||||||
|
|
||||||
fcid = lmp->modify->find_compute(&name[2]);
|
fcid = lmp->modify->find_compute(&name[2]);
|
||||||
if (fcid < 0) {
|
if (fcid < 0) {
|
||||||
@ -3156,7 +3156,7 @@ void lammps_gather_concat(void *handle, char *name, int type, int count, void *d
|
|||||||
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
else vptr = (void *) lmp->modify->compute[fcid]->array_atom;
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom fix property/atom vector or array
|
// custom per-atom vector or array
|
||||||
// OLDSTYLE code
|
// OLDSTYLE code
|
||||||
|
|
||||||
if ((vptr==nullptr) &&
|
if ((vptr==nullptr) &&
|
||||||
|
|||||||
12
src/set.cpp
12
src/set.cpp
@ -576,9 +576,9 @@ void Set::command(int narg, char **arg)
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||||
if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1);
|
if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1);
|
||||||
else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
else ivalue = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
int flag;
|
int flag,cols;
|
||||||
index_custom = atom->find_custom(&arg[iarg][2],flag);
|
index_custom = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||||
if (index_custom < 0 || flag != 0)
|
if (index_custom < 0 || flag || cols)
|
||||||
error->all(FLERR,"Set command integer vector does not exist");
|
error->all(FLERR,"Set command integer vector does not exist");
|
||||||
set(IVEC);
|
set(IVEC);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
@ -587,9 +587,9 @@ void Set::command(int narg, char **arg)
|
|||||||
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
if (iarg+2 > narg) error->all(FLERR,"Illegal set command");
|
||||||
if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1);
|
if (utils::strmatch(arg[iarg+1],"^v_")) varparse(arg[iarg+1],1);
|
||||||
else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
else dvalue = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
int flag;
|
int flag,cols;
|
||||||
index_custom = atom->find_custom(&arg[iarg][2],flag);
|
index_custom = atom->find_custom(&arg[iarg][2],flag,cols);
|
||||||
if (index_custom < 0 || flag != 1)
|
if (index_custom < 0 || flag || cols)
|
||||||
error->all(FLERR,"Set command floating point vector does not exist");
|
error->all(FLERR,"Set command floating point vector does not exist");
|
||||||
set(DVEC);
|
set(DVEC);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|||||||
@ -609,13 +609,12 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod
|
|||||||
|
|
||||||
// only match custom array reference with a '*' wildcard
|
// only match custom array reference with a '*' wildcard
|
||||||
// number range in the first pair of square brackets
|
// number range in the first pair of square brackets
|
||||||
|
|
||||||
// OLDSTYLE code
|
// OLDSTYLE code
|
||||||
|
|
||||||
if (strncmp(arg[iarg],"i2_",3) == 0 || strncmp(arg[iarg],"d2_",3) == 0) {
|
if (strncmp(arg[iarg],"i2_",3) == 0 || strncmp(arg[iarg],"d2_",3) == 0) {
|
||||||
ptr1 = strchr(arg[iarg],'[');
|
char *ptr1 = strchr(arg[iarg],'[');
|
||||||
if (ptr1) {
|
if (ptr1) {
|
||||||
ptr2 = strchr(ptr1,']');
|
char *ptr2 = strchr(ptr1,']');
|
||||||
if (ptr2) {
|
if (ptr2) {
|
||||||
*ptr2 = '\0';
|
*ptr2 = '\0';
|
||||||
if (strchr(ptr1,'*')) {
|
if (strchr(ptr1,'*')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user