fix bugs related to custom per-atom properties in dump style custom

This commit is contained in:
Axel Kohlmeyer
2021-10-17 09:43:25 -04:00
parent f392b089a4
commit 6145ef9cd2

View File

@ -131,7 +131,7 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
if (ioptional < nfield &&
strcmp(style,"image") != 0 && strcmp(style,"movie") != 0)
error->all(FLERR,"Invalid attribute in dump custom command");
error->all(FLERR,"Invalid attribute {} in dump {} command",earg[ioptional],style);
// noptional = # of optional args
// reset nfield to subtract off optional args
@ -238,9 +238,8 @@ DumpCustom::~DumpCustom()
for (int i = 0; i < ncustom; i++) delete[] id_custom[i];
memory->sfree(id_custom);
delete [] custom;
delete [] custom_flag;
memory->sfree(custom);
memory->sfree(custom_flag);
memory->destroy(choose);
memory->destroy(dchoose);
memory->destroy(clist);
@ -909,32 +908,27 @@ int DumpCustom::count()
} else if (thresh_array[ithresh] == Q) {
if (!atom->q_flag)
error->all(FLERR,
"Threshold for an atom property that isn't allocated");
error->all(FLERR,"Threshold for an atom property that isn't allocated");
ptr = atom->q;
nstride = 1;
} else if (thresh_array[ithresh] == MUX) {
if (!atom->mu_flag)
error->all(FLERR,
"Threshold for an atom property that isn't allocated");
error->all(FLERR,"Threshold for an atom property that isn't allocated");
ptr = &atom->mu[0][0];
nstride = 4;
} else if (thresh_array[ithresh] == MUY) {
if (!atom->mu_flag)
error->all(FLERR,
"Threshold for an atom property that isn't allocated");
error->all(FLERR,"Threshold for an atom property that isn't allocated");
ptr = &atom->mu[0][1];
nstride = 4;
} else if (thresh_array[ithresh] == MUZ) {
if (!atom->mu_flag)
error->all(FLERR,
"Threshold for an atom property that isn't allocated");
error->all(FLERR,"Threshold for an atom property that isn't allocated");
ptr = &atom->mu[0][2];
nstride = 4;
} else if (thresh_array[ithresh] == MU) {
if (!atom->mu_flag)
error->all(FLERR,
"Threshold for an atom property that isn't allocated");
error->all(FLERR,"Threshold for an atom property that isn't allocated");
ptr = &atom->mu[0][3];
nstride = 4;
@ -1521,7 +1515,7 @@ int DumpCustom::parse_fields(int narg, char **arg)
field2index[iarg] = add_variable(name);
break;
// custom per-atom floating point vector or array
// custom per-atom floating point vector or array = d_ID d2_ID
case ArgInfo::DNAME:
pack_choice[iarg] = &DumpCustom::pack_custom;
@ -1533,18 +1527,18 @@ int DumpCustom::parse_fields(int narg, char **arg)
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
if (argindex[iarg] == 0) {
if (!flag || cols)
error->all(FLERR,"Property double vector for dump custom does not exist");
error->all(FLERR,"Property double vector {} for dump custom does not exist",name);
} else {
if (!flag || !cols)
error->all(FLERR,"Property double array for dump custom does not exist");
error->all(FLERR,"Property double array {} for dump custom does not exist",name);
if (argindex[iarg] > atom->dcols[n])
error->all(FLERR,"Dump custom property array is accessed out-of-range");
error->all(FLERR,"Dump custom property array {} is accessed out-of-range",name);
}
field2index[iarg] = add_custom(name,1);
break;
// custom per-atom integer vector or array
// custom per-atom integer vector or array = i_ID or i2_ID
case ArgInfo::INAME:
pack_choice[iarg] = &DumpCustom::pack_custom;
@ -1556,15 +1550,12 @@ int DumpCustom::parse_fields(int narg, char **arg)
error->all(FLERR,"Could not find custom per-atom property ID: {}", name);
if (argindex[iarg] == 0) {
if (flag || cols)
error->all(FLERR,
"Property integer vector for dump custom does not exist");
error->all(FLERR,"Property integer vector {} for dump custom does not exist",name);
} else {
if (flag || !cols)
error->all(FLERR,
"Property integer array for dump custom does not exist");
error->all(FLERR,"Property integer array {} for dump custom does not exist",name);
if (argindex[iarg] > atom->icols[n])
error->all(FLERR,
"Dump custom property array is accessed out-of-range");
error->all(FLERR,"Dump custom property array {} is accessed out-of-range",name);
}
field2index[iarg] = add_custom(name,0);
@ -1574,6 +1565,7 @@ int DumpCustom::parse_fields(int narg, char **arg)
default:
return iarg;
break;
}
}
}
@ -1667,13 +1659,9 @@ int DumpCustom::add_custom(const char *id, int flag)
if (strcmp(id,id_custom[icustom]) == 0) break;
if (icustom < ncustom) return icustom;
id_custom = (char **)
memory->srealloc(id_custom,(ncustom+1)*sizeof(char *),"dump:id_custom");
delete [] custom;
custom = new int[ncustom+1];
delete [] custom_flag;
custom_flag = new int[ncustom+1];
id_custom = (char **) memory->srealloc(id_custom,(ncustom+1)*sizeof(char *),"dump:id_custom");
custom = (int *) memory->srealloc(custom,(ncustom+1)*sizeof(int),"dump:custom");
custom_flag = (int *) memory->srealloc(custom_flag,(ncustom+1)*sizeof(int),"dump:custom_flag");
id_custom[ncustom] = utils::strdup(id);
custom_flag[ncustom] = flag;
@ -1962,21 +1950,18 @@ int DumpCustom::modify_param(int narg, char **arg)
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");
if (!flag || cols)
error->all(FLERR,"Property double vector for dump custom does not exist");
thresh_array[nthresh] = DVEC;
} else {
if (flag || !cols)
error->all(FLERR,
"Property double array for dump custom does not exist");
if (!flag || !cols)
error->all(FLERR,"Property double array for dump custom does not exist");
if (argindex[nfield+nthresh] > atom->dcols[n])
error->all(FLERR,
"Dump custom property array is accessed out-of-range");
error->all(FLERR,"Dump custom property array is accessed out-of-range");
thresh_array[nthresh] = DARRAY;
}
field2index[nfield+nthresh] = add_custom(name,0);
field2index[nfield+nthresh] = add_custom(name,thresh_array[nthresh]);
break;
// custom per atom integer vector or array
@ -1988,20 +1973,17 @@ int DumpCustom::modify_param(int narg, char **arg)
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");
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");
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");
error->all(FLERR,"Dump custom property array is accessed out-of-range");
thresh_array[nthresh] = IARRAY;
}
field2index[nfield+nthresh] = add_custom(name,0);
field2index[nfield+nthresh] = add_custom(name,thresh_array[nthresh]);
break;
// no match