changes in package files to match new find_custom() syntax
This commit is contained in:
@ -64,7 +64,7 @@ Syntax
|
|||||||
*single* args = none
|
*single* args = none
|
||||||
*molecule* args = none
|
*molecule* args = none
|
||||||
*custom* args = *i_propname* or *v_varname*
|
*custom* args = *i_propname* or *v_varname*
|
||||||
i_propname = an integer property defined via fix property/atom
|
i_propname = a custom integer vector defined via fix property/atom
|
||||||
v_varname = an atom-style or atomfile-style variable
|
v_varname = an atom-style or atomfile-style variable
|
||||||
*group* args = N groupID1 groupID2 ...
|
*group* args = N groupID1 groupID2 ...
|
||||||
N = # of groups
|
N = # of groups
|
||||||
@ -287,15 +287,16 @@ includes atoms you want to be part of rigid bodies.
|
|||||||
|
|
||||||
Bodystyle *custom* is similar to bodystyle *molecule* except that it
|
Bodystyle *custom* is similar to bodystyle *molecule* except that it
|
||||||
is more flexible in using other per-atom properties to define the sets
|
is more flexible in using other per-atom properties to define the sets
|
||||||
of atoms that form rigid bodies. An integer vector defined by the
|
of atoms that form rigid bodies. A custom per-atom integer vector
|
||||||
:doc:`fix property/atom <fix_property_atom>` command can be used. Or an
|
defined by the :doc:`fix property/atom <fix_property_atom>` command
|
||||||
:doc:`atom-style or atomfile-style variable <variable>` can be used; the
|
can be used. Or an :doc:`atom-style or atomfile-style variable
|
||||||
floating-point value produced by the variable is rounded to an
|
<variable>` can be used; the floating-point value produced by the
|
||||||
integer. As with bodystyle *molecule*\ , each set of atoms in the fix
|
variable is rounded to an integer. As with bodystyle *molecule*\ ,
|
||||||
groups with the same integer value is treated as a different rigid
|
each set of atoms in the fix groups with the same integer value is
|
||||||
body. Since fix property/atom vectors and atom-style variables
|
treated as a different rigid body. Since fix property/atom custom
|
||||||
produce values for all atoms, you should be careful to use a fix group
|
vectors and atom-style variables produce values for all atoms, you
|
||||||
that only includes atoms you want to be part of rigid bodies.
|
should be careful to use a fix group that only includes atoms you want
|
||||||
|
to be part of rigid bodies.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|||||||
@ -129,14 +129,10 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// determine whether atom-style variable or atom property is used
|
// determine whether atom-style variable or atom property is used
|
||||||
|
|
||||||
if (strstr(arg[4],"i_") == arg[4]) {
|
if (strstr(arg[4],"i_") == arg[4]) {
|
||||||
int is_double=0;
|
int flag,cols;
|
||||||
int custom_index = atom->find_custom(arg[4]+2,is_double);
|
int custom_index = atom->find_custom(arg[4]+2,flag,cols);
|
||||||
if (custom_index == -1)
|
if (custom_index < 0 || !flag || cols)
|
||||||
error->all(FLERR,"Fix rigid custom requires "
|
error->all(FLERR,"Fix rigid custom requires custom integer vector");
|
||||||
"previously defined property/atom");
|
|
||||||
else if (is_double)
|
|
||||||
error->all(FLERR,"Fix rigid custom requires "
|
|
||||||
"integer-valued property/atom");
|
|
||||||
int minval = INT_MAX;
|
int minval = INT_MAX;
|
||||||
int *value = atom->ivector[custom_index];
|
int *value = atom->ivector[custom_index];
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
|
|||||||
@ -113,15 +113,10 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
// determine whether atom-style variable or atom property is used
|
// determine whether atom-style variable or atom property is used
|
||||||
|
|
||||||
if (strstr(arg[4],"i_") == arg[4]) {
|
if (strstr(arg[4],"i_") == arg[4]) {
|
||||||
int is_double=0;
|
int flag,cols;
|
||||||
int custom_index = atom->find_custom(arg[4]+2,is_double);
|
int custom_index = atom->find_custom(arg[4]+2,flag,cols);
|
||||||
if (custom_index == -1)
|
if (custom_index < 0 || !flag || cols)
|
||||||
error->all(FLERR,"Fix rigid/small custom requires "
|
error->all(FLERR,"Fix rigid custom requires custom integer vector");
|
||||||
"previously defined property/atom");
|
|
||||||
else if (is_double)
|
|
||||||
error->all(FLERR,"Fix rigid/small custom requires "
|
|
||||||
"integer-valued property/atom");
|
|
||||||
|
|
||||||
int minval = INT_MAX;
|
int minval = INT_MAX;
|
||||||
int *value = atom->ivector[custom_index];
|
int *value = atom->ivector[custom_index];
|
||||||
for (i = 0; i < nlocal; i++)
|
for (i = 0; i < nlocal; i++)
|
||||||
|
|||||||
@ -683,8 +683,8 @@ void FixBondReact::post_constructor()
|
|||||||
// initialize per-atom statted_flags to 1
|
// initialize per-atom statted_flags to 1
|
||||||
// (only if not already initialized by restart)
|
// (only if not already initialized by restart)
|
||||||
if (fix3->restart_reset != 1) {
|
if (fix3->restart_reset != 1) {
|
||||||
int flag;
|
int flag,cols;
|
||||||
int index = atom->find_custom("statted_tags",flag);
|
int index = atom->find_custom("statted_tags",flag,cols);
|
||||||
int *i_statted_tags = atom->ivector[index];
|
int *i_statted_tags = atom->ivector[index];
|
||||||
|
|
||||||
for (int i = 0; i < atom->nlocal; i++)
|
for (int i = 0; i < atom->nlocal; i++)
|
||||||
@ -715,8 +715,8 @@ void FixBondReact::post_constructor()
|
|||||||
|
|
||||||
// initialize per-atom statted_tags to 1
|
// initialize per-atom statted_tags to 1
|
||||||
// need to correct for smooth restarts
|
// need to correct for smooth restarts
|
||||||
//int flag;
|
//int flag,cols;
|
||||||
//int index = atom->find_custom(statted_id,flag);
|
//int index = atom->find_custom(statted_id,flag,cols);
|
||||||
//int *i_statted_tags = atom->ivector[index];
|
//int *i_statted_tags = atom->ivector[index];
|
||||||
//for (int i = 0; i < atom->nlocal; i++)
|
//for (int i = 0; i < atom->nlocal; i++)
|
||||||
// i_statted_tags[i] = 1;
|
// i_statted_tags[i] = 1;
|
||||||
@ -1021,8 +1021,8 @@ void FixBondReact::far_partner()
|
|||||||
firstneigh = list->firstneigh;
|
firstneigh = list->firstneigh;
|
||||||
|
|
||||||
// per-atom property indicating if in bond/react master group
|
// per-atom property indicating if in bond/react master group
|
||||||
int flag;
|
int flag,cols;
|
||||||
int index1 = atom->find_custom("limit_tags",flag);
|
int index1 = atom->find_custom("limit_tags",flag,cols);
|
||||||
int *i_limit_tags = atom->ivector[index1];
|
int *i_limit_tags = atom->ivector[index1];
|
||||||
|
|
||||||
int i,j;
|
int i,j;
|
||||||
@ -1108,8 +1108,8 @@ void FixBondReact::close_partner()
|
|||||||
int *mask = atom->mask;
|
int *mask = atom->mask;
|
||||||
|
|
||||||
// per-atom property indicating if in bond/react master group
|
// per-atom property indicating if in bond/react master group
|
||||||
int flag;
|
int flag,cols;
|
||||||
int index1 = atom->find_custom("limit_tags",flag);
|
int index1 = atom->find_custom("limit_tags",flag,cols);
|
||||||
int *i_limit_tags = atom->ivector[index1];
|
int *i_limit_tags = atom->ivector[index1];
|
||||||
|
|
||||||
// loop over special list
|
// loop over special list
|
||||||
@ -1377,8 +1377,8 @@ void FixBondReact::make_a_guess()
|
|||||||
int nfirst_neighs = onemol_nxspecial[pion][0];
|
int nfirst_neighs = onemol_nxspecial[pion][0];
|
||||||
|
|
||||||
// per-atom property indicating if in bond/react master group
|
// per-atom property indicating if in bond/react master group
|
||||||
int flag;
|
int flag,cols;
|
||||||
int index1 = atom->find_custom("limit_tags",flag);
|
int index1 = atom->find_custom("limit_tags",flag,cols);
|
||||||
int *i_limit_tags = atom->ivector[index1];
|
int *i_limit_tags = atom->ivector[index1];
|
||||||
|
|
||||||
if (status == GUESSFAIL && avail_guesses == 0) {
|
if (status == GUESSFAIL && avail_guesses == 0) {
|
||||||
@ -2341,17 +2341,17 @@ void FixBondReact::limit_bond(int limit_bond_mode)
|
|||||||
// we must keep our own list of limited atoms
|
// we must keep our own list of limited atoms
|
||||||
// this will be a new per-atom property!
|
// this will be a new per-atom property!
|
||||||
|
|
||||||
int flag;
|
int flag,cols;
|
||||||
int index1 = atom->find_custom("limit_tags",flag);
|
int index1 = atom->find_custom("limit_tags",flag,cols);
|
||||||
int *i_limit_tags = atom->ivector[index1];
|
int *i_limit_tags = atom->ivector[index1];
|
||||||
|
|
||||||
int *i_statted_tags;
|
int *i_statted_tags;
|
||||||
if (stabilization_flag == 1) {
|
if (stabilization_flag == 1) {
|
||||||
int index2 = atom->find_custom(statted_id,flag);
|
int index2 = atom->find_custom(statted_id,flag,cols);
|
||||||
i_statted_tags = atom->ivector[index2];
|
i_statted_tags = atom->ivector[index2];
|
||||||
}
|
}
|
||||||
|
|
||||||
int index3 = atom->find_custom("react_tags",flag);
|
int index3 = atom->find_custom("react_tags",flag,cols);
|
||||||
int *i_react_tags = atom->ivector[index3];
|
int *i_react_tags = atom->ivector[index3];
|
||||||
|
|
||||||
for (int i = 0; i < temp_limit_num; i++) {
|
for (int i = 0; i < temp_limit_num; i++) {
|
||||||
@ -2374,17 +2374,17 @@ void FixBondReact::unlimit_bond()
|
|||||||
//let's now unlimit in terms of i_limit_tags
|
//let's now unlimit in terms of i_limit_tags
|
||||||
//we just run through all nlocal, looking for > limit_duration
|
//we just run through all nlocal, looking for > limit_duration
|
||||||
//then we return i_limit_tag to 0 (which removes from dynamic group)
|
//then we return i_limit_tag to 0 (which removes from dynamic group)
|
||||||
int flag;
|
int flag,cols;
|
||||||
int index1 = atom->find_custom("limit_tags",flag);
|
int index1 = atom->find_custom("limit_tags",flag,cols);
|
||||||
int *i_limit_tags = atom->ivector[index1];
|
int *i_limit_tags = atom->ivector[index1];
|
||||||
|
|
||||||
int *i_statted_tags;
|
int *i_statted_tags;
|
||||||
if (stabilization_flag == 1) {
|
if (stabilization_flag == 1) {
|
||||||
int index2 = atom->find_custom(statted_id,flag);
|
int index2 = atom->find_custom(statted_id,flag,cols);
|
||||||
i_statted_tags = atom->ivector[index2];
|
i_statted_tags = atom->ivector[index2];
|
||||||
}
|
}
|
||||||
|
|
||||||
int index3 = atom->find_custom("react_tags",flag);
|
int index3 = atom->find_custom("react_tags",flag,cols);
|
||||||
int *i_react_tags = atom->ivector[index3];
|
int *i_react_tags = atom->ivector[index3];
|
||||||
|
|
||||||
for (int i = 0; i < atom->nlocal; i++) {
|
for (int i = 0; i < atom->nlocal; i++) {
|
||||||
|
|||||||
@ -237,9 +237,15 @@ void DumpVTK::init_style()
|
|||||||
|
|
||||||
int icustom;
|
int icustom;
|
||||||
for (int i = 0; i < ncustom; i++) {
|
for (int i = 0; i < ncustom; i++) {
|
||||||
icustom = atom->find_custom(id_custom[i],flag_custom[i]);
|
int flag,cols;
|
||||||
|
icustom = atom->find_custom(id_custom[i],flag,cols);
|
||||||
if (icustom < 0)
|
if (icustom < 0)
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
error->all(FLERR,"Could not find dump vtk atom property name");
|
||||||
|
custom[i] = icustom;
|
||||||
|
if (!flag && !cols) custom_flag[i] = IVEC;
|
||||||
|
else if (flag && !cols) custom_flag[i] = DVEC;
|
||||||
|
else if (!flag && cols) custom_flag[i] = IARRAY;
|
||||||
|
else if (flag && cols) custom_flag[i] = DARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set index and check validity of region
|
// set index and check validity of region
|
||||||
@ -1511,6 +1517,7 @@ int DumpVTK::parse_fields(int narg, char **arg)
|
|||||||
name[Z] = "z";
|
name[Z] = "z";
|
||||||
|
|
||||||
// customize by adding to if statement
|
// customize by adding to if statement
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for (int iarg = 5; iarg < narg; iarg++) {
|
for (int iarg = 5; iarg < narg; iarg++) {
|
||||||
i = iarg-5;
|
i = iarg-5;
|
||||||
@ -1825,49 +1832,67 @@ int DumpVTK::parse_fields(int narg, char **arg)
|
|||||||
name[ATTRIBUTES+i] = suffix;
|
name[ATTRIBUTES+i] = suffix;
|
||||||
delete [] suffix;
|
delete [] suffix;
|
||||||
|
|
||||||
// custom per-atom floating point value = d_ID
|
// custom per-atom integer value = i_ID or d_ID
|
||||||
|
|
||||||
|
} else if (strncmp(arg[iarg],"i_",2) == 0 ||
|
||||||
|
strncmp(arg[iarg],"d_",2) == 0) {
|
||||||
|
int which = 0;
|
||||||
|
if (arg[iarg][0] == 'd') which = 1;
|
||||||
|
|
||||||
} else if (strncmp(arg[iarg],"d_",2) == 0) {
|
|
||||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
||||||
vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
if (!which) vtype[ATTRIBUTES+i] = Dump::INT;
|
||||||
|
else vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||||
|
|
||||||
int n = strlen(arg[iarg]);
|
int n = strlen(arg[iarg]);
|
||||||
char *suffix = new char[n];
|
char *suffix = new char[n];
|
||||||
strcpy(suffix,&arg[iarg][2]);
|
strcpy(suffix,&arg[iarg][2]);
|
||||||
argindex[ATTRIBUTES+i] = 0;
|
argindex[ATTRIBUTES+i] = 0;
|
||||||
|
|
||||||
int tmp = -1;
|
int flag,cols;
|
||||||
n = atom->find_custom(suffix,tmp);
|
n = atom->find_custom(suffix,flag,cols);
|
||||||
if (n < 0)
|
if ((!which && (n < 0 || flag || cols)) ||
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
(which && (n < 0 || !flag || cols)))
|
||||||
|
error->all(FLERR,"Dump vtk per-atom custom vector does not exist");
|
||||||
|
|
||||||
if (tmp != 1)
|
field2index[ATTRIBUTES+i] = add_custom(suffix);
|
||||||
error->all(FLERR,"Custom per-atom property ID is not floating point");
|
|
||||||
|
|
||||||
field2index[ATTRIBUTES+i] = add_custom(suffix,1);
|
|
||||||
name[ATTRIBUTES+i] = suffix;
|
name[ATTRIBUTES+i] = suffix;
|
||||||
delete [] suffix;
|
delete [] suffix;
|
||||||
|
|
||||||
// custom per-atom integer value = i_ID
|
// custom per-atom array = i2_ID or d2_ID, must include bracketed index
|
||||||
|
|
||||||
|
} else if (strncmp(arg[iarg],"i2_",3) == 0 ||
|
||||||
|
strncmp(arg[iarg],"d2_",3) == 0) {
|
||||||
|
int which = 0;
|
||||||
|
if (arg[iarg][0] == 'd') which = 1;
|
||||||
|
|
||||||
} else if (strncmp(arg[iarg],"i_",2) == 0) {
|
|
||||||
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
pack_choice[ATTRIBUTES+i] = &DumpVTK::pack_custom;
|
||||||
vtype[ATTRIBUTES+i] = Dump::INT;
|
if (!which) vtype[ATTRIBUTES+i] = Dump::INT;
|
||||||
|
else vtype[ATTRIBUTES+i] = Dump::DOUBLE;
|
||||||
|
|
||||||
int n = strlen(arg[iarg]);
|
int n = strlen(arg[iarg]);
|
||||||
char *suffix = new char[n];
|
char *suffix = new char[n];
|
||||||
strcpy(suffix,&arg[iarg][2]);
|
strcpy(suffix,&arg[iarg][3]);
|
||||||
argindex[ATTRIBUTES+i] = 0;
|
|
||||||
|
|
||||||
int tmp = -1;
|
char *ptr = strchr(suffix,'[');
|
||||||
n = atom->find_custom(suffix,tmp);
|
if (ptr) {
|
||||||
if (n < 0)
|
if (suffix[strlen(suffix)-1] != ']')
|
||||||
error->all(FLERR,"Could not find custom per-atom property ID");
|
error->all(FLERR,"Invalid attribute in dump custom command");
|
||||||
|
suffix[strlen(suffix)-1] = '\0';
|
||||||
|
argindex[ATTRIBUTES+i] = utils::inumeric(FLERR,ptr+1,true,lmp);
|
||||||
|
*ptr = '\0';
|
||||||
|
} else error->all(FLERR,"Dump custom per-atom custom array is not indexed");
|
||||||
|
|
||||||
if (tmp != 0)
|
int flag,cols;
|
||||||
error->all(FLERR,"Custom per-atom property ID is not integer");
|
n = atom->find_custom(suffix,flag,cols);
|
||||||
|
|
||||||
field2index[ATTRIBUTES+i] = add_custom(suffix,0);
|
if ((!which && (n < 0 || flag || !cols)) ||
|
||||||
|
(which && (n < 0 || !flag || !cols)))
|
||||||
|
error->all(FLERR,"Dump vtk per-atom custom array does not exist");
|
||||||
|
if (argindex[i] <= 0 || argindex[i] > cols)
|
||||||
|
error->all(FLERR,
|
||||||
|
"Dump vtk per-atom custom array is accessed out-of-range");
|
||||||
|
|
||||||
|
field2index[i] = add_custom(suffix);
|
||||||
name[ATTRIBUTES+i] = suffix;
|
name[ATTRIBUTES+i] = suffix;
|
||||||
delete [] suffix;
|
delete [] suffix;
|
||||||
|
|
||||||
@ -2006,27 +2031,28 @@ int DumpVTK::add_variable(char *id)
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
add custom atom property to list used by dump
|
add custom atom property to list used by dump
|
||||||
return index of where this property is in list
|
return index of where this property is in Atom class custom lists
|
||||||
if already in list, do not add, just return index, else add to list
|
if already in list, do not add, just return index, else add to list
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int DumpVTK::add_custom(char *id, int flag)
|
int DumpVTK::add_custom(char *id)
|
||||||
{
|
{
|
||||||
int icustom;
|
int icustom;
|
||||||
for (icustom = 0; icustom < ncustom; icustom++)
|
for (icustom = 0; icustom < ncustom; icustom++)
|
||||||
if ((strcmp(id,id_custom[icustom]) == 0)
|
if (strcmp(id,id_custom[icustom]) == 0) break;
|
||||||
&& (flag == flag_custom[icustom])) break;
|
|
||||||
if (icustom < ncustom) return icustom;
|
if (icustom < ncustom) return icustom;
|
||||||
|
|
||||||
id_custom = (char **)
|
id_custom = (char **)
|
||||||
memory->srealloc(id_custom,(ncustom+1)*sizeof(char *),"dump:id_custom");
|
memory->srealloc(id_custom,(ncustom+1)*sizeof(char *),"dump:id_custom");
|
||||||
flag_custom = (int *)
|
|
||||||
memory->srealloc(flag_custom,(ncustom+1)*sizeof(int),"dump:flag_custom");
|
delete [] custom;
|
||||||
|
custom = new int[ncustom+1];
|
||||||
|
delete [] custom_flag;
|
||||||
|
custom_flag = new int[ncustom+1];
|
||||||
|
|
||||||
int n = strlen(id) + 1;
|
int n = strlen(id) + 1;
|
||||||
id_custom[ncustom] = new char[n];
|
id_custom[ncustom] = new char[n];
|
||||||
strcpy(id_custom[ncustom],id);
|
strcpy(id_custom[ncustom],id);
|
||||||
flag_custom[ncustom] = flag;
|
|
||||||
|
|
||||||
ncustom++;
|
ncustom++;
|
||||||
return ncustom-1;
|
return ncustom-1;
|
||||||
|
|||||||
Reference in New Issue
Block a user