add ArgInfo support to some dump styles

This commit is contained in:
Axel Kohlmeyer
2021-02-01 09:39:50 -05:00
parent fae6fef1ac
commit 55da46f3e3
3 changed files with 330 additions and 405 deletions

View File

@ -17,12 +17,15 @@
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "dump_cfg.h" #include "dump_cfg.h"
#include <cstring>
#include "arg_info.h"
#include "atom.h" #include "atom.h"
#include "domain.h" #include "domain.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "error.h"
#include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define UNWRAPEXPAND 10.0 #define UNWRAPEXPAND 10.0
@ -67,18 +70,14 @@ DumpCFG::DumpCFG(LAMMPS *lmp, int narg, char **arg) :
int i = 0; int i = 0;
for (int iarg = 5; iarg < nfield; iarg++, i++) { for (int iarg = 5; iarg < nfield; iarg++, i++) {
if ((strncmp(earg[iarg],"c_",2) == 0 || ArgInfo argi(earg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
strncmp(earg[iarg],"f_",2) == 0 || |ArgInfo::DNAME|ArgInfo::INAME);
strncmp(earg[iarg],"v_",2) == 0) && strchr(earg[iarg],'[')) {
char *ptr = strchr(earg[iarg],'[');
char *ptr2 = strchr(ptr,']');
auxname[i] = new char[strlen(earg[iarg])];
*ptr = '\0';
*ptr2 = '\0';
strcpy(auxname[i],earg[iarg]);
strcat(auxname[i],"_");
strcat(auxname[i],ptr+1);
if (argi.get_dim() == 1) {
std::string newarg(std::to_string(earg[iarg][0]));
newarg += '_' + argi.get_name() + '_' + std::to_string(argi.get_index1());
auxname[i] = new char[newarg.size()+1];
strcpy(auxname[i],newarg.c_str());
} else { } else {
auxname[i] = new char[strlen(earg[iarg]) + 1]; auxname[i] = new char[strlen(earg[iarg]) + 1];
strcpy(auxname[i],earg[iarg]); strcpy(auxname[i],earg[iarg]);

View File

@ -13,6 +13,7 @@
#include "dump_custom.h" #include "dump_custom.h"
#include "arg_info.h"
#include "atom.h" #include "atom.h"
#include "compute.h" #include "compute.h"
#include "domain.h" #include "domain.h"
@ -1252,327 +1253,302 @@ int DumpCustom::parse_fields(int narg, char **arg)
{ {
// customize by adding to if statement // customize by adding to if statement
int i;
for (int iarg = 0; iarg < narg; iarg++) { for (int iarg = 0; iarg < narg; iarg++) {
i = iarg;
if (strcmp(arg[iarg],"id") == 0) { if (strcmp(arg[iarg],"id") == 0) {
pack_choice[i] = &DumpCustom::pack_id; pack_choice[iarg] = &DumpCustom::pack_id;
if (sizeof(tagint) == sizeof(smallint)) vtype[i] = Dump::INT; if (sizeof(tagint) == sizeof(smallint)) vtype[iarg] = Dump::INT;
else vtype[i] = Dump::BIGINT; else vtype[iarg] = Dump::BIGINT;
} else if (strcmp(arg[iarg],"mol") == 0) { } else if (strcmp(arg[iarg],"mol") == 0) {
if (!atom->molecule_flag) if (!atom->molecule_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_molecule; pack_choice[iarg] = &DumpCustom::pack_molecule;
if (sizeof(tagint) == sizeof(smallint)) vtype[i] = Dump::INT; if (sizeof(tagint) == sizeof(smallint)) vtype[iarg] = Dump::INT;
else vtype[i] = Dump::BIGINT; else vtype[iarg] = Dump::BIGINT;
} else if (strcmp(arg[iarg],"proc") == 0) { } else if (strcmp(arg[iarg],"proc") == 0) {
pack_choice[i] = &DumpCustom::pack_proc; pack_choice[iarg] = &DumpCustom::pack_proc;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
} else if (strcmp(arg[iarg],"procp1") == 0) { } else if (strcmp(arg[iarg],"procp1") == 0) {
pack_choice[i] = &DumpCustom::pack_procp1; pack_choice[iarg] = &DumpCustom::pack_procp1;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
} else if (strcmp(arg[iarg],"type") == 0) { } else if (strcmp(arg[iarg],"type") == 0) {
pack_choice[i] = &DumpCustom::pack_type; pack_choice[iarg] = &DumpCustom::pack_type;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
} else if (strcmp(arg[iarg],"element") == 0) { } else if (strcmp(arg[iarg],"element") == 0) {
pack_choice[i] = &DumpCustom::pack_type; pack_choice[iarg] = &DumpCustom::pack_type;
vtype[i] = Dump::STRING; vtype[iarg] = Dump::STRING;
} else if (strcmp(arg[iarg],"mass") == 0) { } else if (strcmp(arg[iarg],"mass") == 0) {
pack_choice[i] = &DumpCustom::pack_mass; pack_choice[iarg] = &DumpCustom::pack_mass;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"x") == 0) { } else if (strcmp(arg[iarg],"x") == 0) {
pack_choice[i] = &DumpCustom::pack_x; pack_choice[iarg] = &DumpCustom::pack_x;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"y") == 0) { } else if (strcmp(arg[iarg],"y") == 0) {
pack_choice[i] = &DumpCustom::pack_y; pack_choice[iarg] = &DumpCustom::pack_y;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"z") == 0) { } else if (strcmp(arg[iarg],"z") == 0) {
pack_choice[i] = &DumpCustom::pack_z; pack_choice[iarg] = &DumpCustom::pack_z;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"xs") == 0) { } else if (strcmp(arg[iarg],"xs") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_xs_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_xs_triclinic;
else pack_choice[i] = &DumpCustom::pack_xs; else pack_choice[iarg] = &DumpCustom::pack_xs;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"ys") == 0) { } else if (strcmp(arg[iarg],"ys") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_ys_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_ys_triclinic;
else pack_choice[i] = &DumpCustom::pack_ys; else pack_choice[iarg] = &DumpCustom::pack_ys;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"zs") == 0) { } else if (strcmp(arg[iarg],"zs") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_zs_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_zs_triclinic;
else pack_choice[i] = &DumpCustom::pack_zs; else pack_choice[iarg] = &DumpCustom::pack_zs;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"xu") == 0) { } else if (strcmp(arg[iarg],"xu") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_xu_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_xu_triclinic;
else pack_choice[i] = &DumpCustom::pack_xu; else pack_choice[iarg] = &DumpCustom::pack_xu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"yu") == 0) { } else if (strcmp(arg[iarg],"yu") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_yu_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_yu_triclinic;
else pack_choice[i] = &DumpCustom::pack_yu; else pack_choice[iarg] = &DumpCustom::pack_yu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"zu") == 0) { } else if (strcmp(arg[iarg],"zu") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_zu_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_zu_triclinic;
else pack_choice[i] = &DumpCustom::pack_zu; else pack_choice[iarg] = &DumpCustom::pack_zu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"xsu") == 0) { } else if (strcmp(arg[iarg],"xsu") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_xsu_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_xsu_triclinic;
else pack_choice[i] = &DumpCustom::pack_xsu; else pack_choice[iarg] = &DumpCustom::pack_xsu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"ysu") == 0) { } else if (strcmp(arg[iarg],"ysu") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_ysu_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_ysu_triclinic;
else pack_choice[i] = &DumpCustom::pack_ysu; else pack_choice[iarg] = &DumpCustom::pack_ysu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"zsu") == 0) { } else if (strcmp(arg[iarg],"zsu") == 0) {
if (domain->triclinic) pack_choice[i] = &DumpCustom::pack_zsu_triclinic; if (domain->triclinic) pack_choice[iarg] = &DumpCustom::pack_zsu_triclinic;
else pack_choice[i] = &DumpCustom::pack_zsu; else pack_choice[iarg] = &DumpCustom::pack_zsu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"ix") == 0) { } else if (strcmp(arg[iarg],"ix") == 0) {
pack_choice[i] = &DumpCustom::pack_ix; pack_choice[iarg] = &DumpCustom::pack_ix;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
} else if (strcmp(arg[iarg],"iy") == 0) { } else if (strcmp(arg[iarg],"iy") == 0) {
pack_choice[i] = &DumpCustom::pack_iy; pack_choice[iarg] = &DumpCustom::pack_iy;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
} else if (strcmp(arg[iarg],"iz") == 0) { } else if (strcmp(arg[iarg],"iz") == 0) {
pack_choice[i] = &DumpCustom::pack_iz; pack_choice[iarg] = &DumpCustom::pack_iz;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
} else if (strcmp(arg[iarg],"vx") == 0) { } else if (strcmp(arg[iarg],"vx") == 0) {
pack_choice[i] = &DumpCustom::pack_vx; pack_choice[iarg] = &DumpCustom::pack_vx;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"vy") == 0) { } else if (strcmp(arg[iarg],"vy") == 0) {
pack_choice[i] = &DumpCustom::pack_vy; pack_choice[iarg] = &DumpCustom::pack_vy;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"vz") == 0) { } else if (strcmp(arg[iarg],"vz") == 0) {
pack_choice[i] = &DumpCustom::pack_vz; pack_choice[iarg] = &DumpCustom::pack_vz;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"fx") == 0) { } else if (strcmp(arg[iarg],"fx") == 0) {
pack_choice[i] = &DumpCustom::pack_fx; pack_choice[iarg] = &DumpCustom::pack_fx;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"fy") == 0) { } else if (strcmp(arg[iarg],"fy") == 0) {
pack_choice[i] = &DumpCustom::pack_fy; pack_choice[iarg] = &DumpCustom::pack_fy;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"fz") == 0) { } else if (strcmp(arg[iarg],"fz") == 0) {
pack_choice[i] = &DumpCustom::pack_fz; pack_choice[iarg] = &DumpCustom::pack_fz;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"q") == 0) { } else if (strcmp(arg[iarg],"q") == 0) {
if (!atom->q_flag) if (!atom->q_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_q; pack_choice[iarg] = &DumpCustom::pack_q;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"mux") == 0) { } else if (strcmp(arg[iarg],"mux") == 0) {
if (!atom->mu_flag) if (!atom->mu_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_mux; pack_choice[iarg] = &DumpCustom::pack_mux;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"muy") == 0) { } else if (strcmp(arg[iarg],"muy") == 0) {
if (!atom->mu_flag) if (!atom->mu_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_muy; pack_choice[iarg] = &DumpCustom::pack_muy;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"muz") == 0) { } else if (strcmp(arg[iarg],"muz") == 0) {
if (!atom->mu_flag) if (!atom->mu_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_muz; pack_choice[iarg] = &DumpCustom::pack_muz;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"mu") == 0) { } else if (strcmp(arg[iarg],"mu") == 0) {
if (!atom->mu_flag) if (!atom->mu_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_mu; pack_choice[iarg] = &DumpCustom::pack_mu;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"radius") == 0) { } else if (strcmp(arg[iarg],"radius") == 0) {
if (!atom->radius_flag) if (!atom->radius_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_radius; pack_choice[iarg] = &DumpCustom::pack_radius;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"diameter") == 0) { } else if (strcmp(arg[iarg],"diameter") == 0) {
if (!atom->radius_flag) if (!atom->radius_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_diameter; pack_choice[iarg] = &DumpCustom::pack_diameter;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"omegax") == 0) { } else if (strcmp(arg[iarg],"omegax") == 0) {
if (!atom->omega_flag) if (!atom->omega_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_omegax; pack_choice[iarg] = &DumpCustom::pack_omegax;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"omegay") == 0) { } else if (strcmp(arg[iarg],"omegay") == 0) {
if (!atom->omega_flag) if (!atom->omega_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_omegay; pack_choice[iarg] = &DumpCustom::pack_omegay;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"omegaz") == 0) { } else if (strcmp(arg[iarg],"omegaz") == 0) {
if (!atom->omega_flag) if (!atom->omega_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_omegaz; pack_choice[iarg] = &DumpCustom::pack_omegaz;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"angmomx") == 0) { } else if (strcmp(arg[iarg],"angmomx") == 0) {
if (!atom->angmom_flag) if (!atom->angmom_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_angmomx; pack_choice[iarg] = &DumpCustom::pack_angmomx;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"angmomy") == 0) { } else if (strcmp(arg[iarg],"angmomy") == 0) {
if (!atom->angmom_flag) if (!atom->angmom_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_angmomy; pack_choice[iarg] = &DumpCustom::pack_angmomy;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"angmomz") == 0) { } else if (strcmp(arg[iarg],"angmomz") == 0) {
if (!atom->angmom_flag) if (!atom->angmom_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_angmomz; pack_choice[iarg] = &DumpCustom::pack_angmomz;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"tqx") == 0) { } else if (strcmp(arg[iarg],"tqx") == 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_tqx; pack_choice[iarg] = &DumpCustom::pack_tqx;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} else if (strcmp(arg[iarg],"tqy") == 0) { } else if (strcmp(arg[iarg],"tqy") == 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_tqy; pack_choice[iarg] = &DumpCustom::pack_tqy;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
} 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;
} else {
int n,tmp;
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
|ArgInfo::DNAME|ArgInfo::INAME);
argindex[iarg] = argi.get_index1();
switch (argi.get_type()) {
case ArgInfo::UNKNOWN:
error->all(FLERR,"Invalid attribute in dump custom command");
break;
// compute value = c_ID // compute value = c_ID
// if no trailing [], then arg is set to 0, else arg is int between [] // if no trailing [], then arg is set to 0, else arg is int between []
} else if (strncmp(arg[iarg],"c_",2) == 0) { case ArgInfo::COMPUTE:
pack_choice[i] = &DumpCustom::pack_compute; pack_choice[iarg] = &DumpCustom::pack_compute;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
int n = strlen(arg[iarg]); n = modify->find_compute(argi.get_name());
char *suffix = new char[n];
strcpy(suffix,&arg[iarg][2]);
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Invalid attribute in dump custom command");
argindex[i] = atoi(ptr+1);
*ptr = '\0';
} else argindex[i] = 0;
n = modify->find_compute(suffix);
if (n < 0) error->all(FLERR,"Could not find dump custom compute ID"); if (n < 0) error->all(FLERR,"Could not find dump custom compute ID");
if (modify->compute[n]->peratom_flag == 0) if (modify->compute[n]->peratom_flag == 0)
error->all(FLERR,"Dump custom compute does not compute per-atom info"); error->all(FLERR,"Dump custom compute does not compute per-atom info");
if (argindex[i] == 0 && modify->compute[n]->size_peratom_cols > 0) if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
error->all(FLERR, error->all(FLERR,
"Dump custom compute does not calculate per-atom vector"); "Dump custom compute does not calculate per-atom vector");
if (argindex[i] > 0 && modify->compute[n]->size_peratom_cols == 0) if (argi.get_index1() > 0 && modify->compute[n]->size_peratom_cols == 0)
error->all(FLERR, error->all(FLERR,
"Dump custom compute does not calculate per-atom array"); "Dump custom compute does not calculate per-atom array");
if (argindex[i] > 0 && if (argi.get_index1() > 0 &&
argindex[i] > modify->compute[n]->size_peratom_cols) argi.get_index1() > modify->compute[n]->size_peratom_cols)
error->all(FLERR,"Dump custom compute vector is accessed out-of-range"); error->all(FLERR,"Dump custom compute vector is accessed out-of-range");
field2index[i] = add_compute(suffix); field2index[iarg] = add_compute(argi.get_name());
delete [] suffix; break;
// fix value = f_ID // fix value = f_ID
// if no trailing [], then arg is set to 0, else arg is between [] // if no trailing [], then arg is set to 0, else arg is between []
} else if (strncmp(arg[iarg],"f_",2) == 0) { case ArgInfo::FIX:
pack_choice[i] = &DumpCustom::pack_fix; pack_choice[iarg] = &DumpCustom::pack_fix;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
int n = strlen(arg[iarg]); n = modify->find_fix(argi.get_name());
char *suffix = new char[n];
strcpy(suffix,&arg[iarg][2]);
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Invalid attribute in dump custom command");
argindex[i] = atoi(ptr+1);
*ptr = '\0';
} else argindex[i] = 0;
n = modify->find_fix(suffix);
if (n < 0) error->all(FLERR,"Could not find dump custom fix ID"); if (n < 0) error->all(FLERR,"Could not find dump custom fix ID");
if (modify->fix[n]->peratom_flag == 0) if (modify->fix[n]->peratom_flag == 0)
error->all(FLERR,"Dump custom fix does not compute per-atom info"); error->all(FLERR,"Dump custom fix does not compute per-atom info");
if (argindex[i] == 0 && modify->fix[n]->size_peratom_cols > 0) if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
error->all(FLERR,"Dump custom fix does not compute per-atom vector"); error->all(FLERR,"Dump custom fix does not compute per-atom vector");
if (argindex[i] > 0 && modify->fix[n]->size_peratom_cols == 0) if (argi.get_index1() > 0 && modify->fix[n]->size_peratom_cols == 0)
error->all(FLERR,"Dump custom fix does not compute per-atom array"); error->all(FLERR,"Dump custom fix does not compute per-atom array");
if (argindex[i] > 0 && if (argi.get_index1() > 0 &&
argindex[i] > modify->fix[n]->size_peratom_cols) argi.get_index1() > modify->fix[n]->size_peratom_cols)
error->all(FLERR,"Dump custom fix vector is accessed out-of-range"); error->all(FLERR,"Dump custom fix vector is accessed out-of-range");
field2index[i] = add_fix(suffix); field2index[iarg] = add_fix(argi.get_name());
delete [] suffix; break;
// variable value = v_name // variable value = v_name
} else if (strncmp(arg[iarg],"v_",2) == 0) { case ArgInfo::VARIABLE:
pack_choice[i] = &DumpCustom::pack_variable; pack_choice[iarg] = &DumpCustom::pack_variable;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
int n = strlen(arg[iarg]); n = input->variable->find(argi.get_name());
char *suffix = new char[n];
strcpy(suffix,&arg[iarg][2]);
argindex[i] = 0;
n = input->variable->find(suffix);
if (n < 0) error->all(FLERR,"Could not find dump custom variable name"); if (n < 0) error->all(FLERR,"Could not find dump custom variable name");
if (input->variable->atomstyle(n) == 0) if (input->variable->atomstyle(n) == 0)
error->all(FLERR,"Dump custom variable is not atom-style variable"); error->all(FLERR,"Dump custom variable is not atom-style variable");
field2index[i] = add_variable(suffix); field2index[iarg] = add_variable(argi.get_name());
delete [] suffix; break;
// custom per-atom floating point value = d_ID // custom per-atom floating point value = d_ID
} else if (strncmp(arg[iarg],"d_",2) == 0) { case ArgInfo::DNAME:
pack_choice[i] = &DumpCustom::pack_custom; pack_choice[iarg] = &DumpCustom::pack_custom;
vtype[i] = Dump::DOUBLE; vtype[iarg] = Dump::DOUBLE;
int n = strlen(arg[iarg]); tmp = -1;
char *suffix = new char[n]; n = atom->find_custom(argi.get_name(),tmp);
strcpy(suffix,&arg[iarg][2]);
argindex[i] = 0;
int tmp = -1;
n = atom->find_custom(suffix,tmp);
if (n < 0) if (n < 0)
error->all(FLERR,"Could not find custom per-atom property ID"); error->all(FLERR,"Could not find custom per-atom property ID");
if (tmp != 1) if (tmp != 1)
error->all(FLERR,"Custom per-atom property ID is not floating point"); error->all(FLERR,"Custom per-atom property ID is not floating point");
field2index[i] = add_custom(suffix,1); field2index[iarg] = add_custom(argi.get_name(),1);
delete [] suffix; break;
// custom per-atom integer value = i_ID // custom per-atom integer value = i_ID
} else if (strncmp(arg[iarg],"i_",2) == 0) { case ArgInfo::INAME:
pack_choice[i] = &DumpCustom::pack_custom; pack_choice[iarg] = &DumpCustom::pack_custom;
vtype[i] = Dump::INT; vtype[iarg] = Dump::INT;
int n = strlen(arg[iarg]); tmp = -1;
char *suffix = new char[n]; n = atom->find_custom(argi.get_name(),tmp);
strcpy(suffix,&arg[iarg][2]);
argindex[i] = 0;
int tmp = -1;
n = atom->find_custom(suffix,tmp);
if (n < 0) if (n < 0)
error->all(FLERR,"Could not find custom per-atom property ID"); error->all(FLERR,"Could not find custom per-atom property ID");
if (tmp != 0) if (tmp != 0)
error->all(FLERR,"Custom per-atom property ID is not integer"); error->all(FLERR,"Custom per-atom property ID is not integer");
field2index[i] = add_custom(suffix,0); field2index[iarg] = add_custom(argi.get_name(),0);
delete [] suffix; break;
} else return iarg; default:
return iarg;
break;
}
}
} }
return narg; return narg;
@ -1897,149 +1873,113 @@ 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;
// compute value = c_ID else {
// if no trailing [], then arg is set to 0, else arg is between []
// must grow field2index and argindex arrays, since access is beyond nfield // must grow field2index and argindex arrays, since access is beyond nfield
else if (strncmp(arg[1],"c_",2) == 0) {
thresh_array[nthresh] = COMPUTE;
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 = strlen(arg[1]);
char *suffix = new char[n];
strcpy(suffix,&arg[1][2]);
char *ptr = strchr(suffix,'['); int n,tmp;
if (ptr) { ArgInfo argi(arg[1],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE
if (suffix[strlen(suffix)-1] != ']') |ArgInfo::DNAME|ArgInfo::INAME);
argindex[nfield+nthresh] = argi.get_index1();
switch (argi.get_type()) {
case ArgInfo::UNKNOWN:
error->all(FLERR,"Invalid attribute in dump modify command"); error->all(FLERR,"Invalid attribute in dump modify command");
argindex[nfield+nthresh] = atoi(ptr+1); break;
*ptr = '\0';
} else argindex[nfield+nthresh] = 0;
n = modify->find_compute(suffix); // compute value = c_ID
// if no trailing [], then arg is set to 0, else arg is between []
case ArgInfo::COMPUTE:
thresh_array[nthresh] = COMPUTE;
n = modify->find_compute(argi.get_name());
if (n < 0) error->all(FLERR,"Could not find dump modify compute ID"); if (n < 0) error->all(FLERR,"Could not find dump modify compute ID");
if (modify->compute[n]->peratom_flag == 0) if (modify->compute[n]->peratom_flag == 0)
error->all(FLERR, error->all(FLERR,
"Dump modify compute ID does not compute per-atom info"); "Dump modify compute ID does not compute per-atom info");
if (argindex[nfield+nthresh] == 0 && if (argi.get_dim() == 0 && modify->compute[n]->size_peratom_cols > 0)
modify->compute[n]->size_peratom_cols > 0)
error->all(FLERR, error->all(FLERR,
"Dump modify compute ID does not compute per-atom vector"); "Dump modify compute ID does not compute per-atom vector");
if (argindex[nfield+nthresh] > 0 && if (argi.get_index1() > 0 && modify->compute[n]->size_peratom_cols == 0)
modify->compute[n]->size_peratom_cols == 0)
error->all(FLERR, error->all(FLERR,
"Dump modify compute ID does not compute per-atom array"); "Dump modify compute ID does not compute per-atom array");
if (argindex[nfield+nthresh] > 0 && if (argi.get_index1() > 0 &&
argindex[nfield+nthresh] > modify->compute[n]->size_peratom_cols) argi.get_index1() > modify->compute[n]->size_peratom_cols)
error->all(FLERR,"Dump modify compute ID vector is not large enough"); error->all(FLERR,"Dump modify compute ID vector is not large enough");
field2index[nfield+nthresh] = add_compute(suffix); field2index[nfield+nthresh] = add_compute(argi.get_name());
delete [] suffix; break;
// fix value = f_ID // fix value = f_ID
// if no trailing [], then arg is set to 0, else arg is between [] // if no trailing [], then arg is set to 0, else arg is between []
// must grow field2index and argindex arrays, since access is beyond nfield
} else if (strncmp(arg[1],"f_",2) == 0) { case ArgInfo::FIX:
thresh_array[nthresh] = FIX; thresh_array[nthresh] = FIX;
memory->grow(field2index,nfield+nthresh+1,"dump:field2index"); n = modify->find_fix(argi.get_name());
memory->grow(argindex,nfield+nthresh+1,"dump:argindex");
int n = strlen(arg[1]);
char *suffix = new char[n];
strcpy(suffix,&arg[1][2]);
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Invalid attribute in dump modify command");
argindex[nfield+nthresh] = atoi(ptr+1);
*ptr = '\0';
} else argindex[nfield+nthresh] = 0;
n = modify->find_fix(suffix);
if (n < 0) error->all(FLERR,"Could not find dump modify fix ID"); if (n < 0) error->all(FLERR,"Could not find dump modify fix ID");
if (modify->fix[n]->peratom_flag == 0) if (modify->fix[n]->peratom_flag == 0)
error->all(FLERR,"Dump modify fix ID does not compute per-atom info"); error->all(FLERR,"Dump modify fix ID does not compute per-atom info");
if (argindex[nfield+nthresh] == 0 && if (argi.get_dim() == 0 && modify->fix[n]->size_peratom_cols > 0)
modify->fix[n]->size_peratom_cols > 0)
error->all(FLERR,"Dump modify fix ID does not compute per-atom vector"); error->all(FLERR,"Dump modify fix ID does not compute per-atom vector");
if (argindex[nfield+nthresh] > 0 && if (argi.get_index1() > 0 && modify->fix[n]->size_peratom_cols == 0)
modify->fix[n]->size_peratom_cols == 0)
error->all(FLERR,"Dump modify fix ID does not compute per-atom array"); error->all(FLERR,"Dump modify fix ID does not compute per-atom array");
if (argindex[nfield+nthresh] > 0 && if (argi.get_index1() > 0 &&
argindex[nfield+nthresh] > modify->fix[n]->size_peratom_cols) argi.get_index1() > modify->fix[n]->size_peratom_cols)
error->all(FLERR,"Dump modify fix ID vector is not large enough"); error->all(FLERR,"Dump modify fix ID vector is not large enough");
field2index[nfield+nthresh] = add_fix(suffix); field2index[nfield+nthresh] = add_fix(argi.get_name());
delete [] suffix; break;
// variable value = v_ID // variable value = v_ID
// must grow field2index and argindex arrays, since access is beyond nfield // must grow field2index and argindex arrays, since access is beyond nfield
} else if (strncmp(arg[1],"v_",2) == 0) { case ArgInfo::VARIABLE:
thresh_array[nthresh] = VARIABLE; thresh_array[nthresh] = VARIABLE;
memory->grow(field2index,nfield+nthresh+1,"dump:field2index"); n = input->variable->find(argi.get_name());
memory->grow(argindex,nfield+nthresh+1,"dump:argindex");
int n = strlen(arg[1]);
char *suffix = new char[n];
strcpy(suffix,&arg[1][2]);
argindex[nfield+nthresh] = 0;
n = input->variable->find(suffix);
if (n < 0) error->all(FLERR,"Could not find dump modify variable name"); if (n < 0) error->all(FLERR,"Could not find dump modify variable name");
if (input->variable->atomstyle(n) == 0) if (input->variable->atomstyle(n) == 0)
error->all(FLERR,"Dump modify variable is not atom-style variable"); error->all(FLERR,"Dump modify variable is not atom-style variable");
field2index[nfield+nthresh] = add_variable(suffix); field2index[nfield+nthresh] = add_variable(argi.get_name());
delete [] suffix; break;
// custom per atom floating point value = d_ID // custom per atom floating point value = d_ID
// must grow field2index and argindex arrays, since access is beyond nfield
} else if (strncmp(arg[1],"d_",2) == 0) { case ArgInfo::DNAME:
thresh_array[nthresh] = DNAME; thresh_array[nthresh] = DNAME;
memory->grow(field2index,nfield+nthresh+1,"dump:field2index"); tmp = -1;
memory->grow(argindex,nfield+nthresh+1,"dump:argindex"); n = atom->find_custom(argi.get_name(),tmp);
int n = strlen(arg[1]);
char *suffix = new char[n];
strcpy(suffix,&arg[1][2]);
argindex[nfield+nthresh] = 0;
int tmp = -1;
n = atom->find_custom(suffix,tmp);
if ((n < 0) || (tmp != 1)) if ((n < 0) || (tmp != 1))
error->all(FLERR,"Could not find dump modify " error->all(FLERR,"Could not find dump modify "
"custom atom floating point property ID"); "custom atom floating point property ID");
field2index[nfield+nthresh] = add_custom(suffix,1); field2index[nfield+nthresh] = add_custom(argi.get_name(),1);
delete [] suffix; break;
// custom per atom integer value = i_ID // custom per atom integer value = i_ID
// must grow field2index and argindex arrays, since access is beyond nfield
} else if (strncmp(arg[1],"i_",2) == 0) { case ArgInfo::INAME:
thresh_array[nthresh] = INAME; thresh_array[nthresh] = INAME;
memory->grow(field2index,nfield+nthresh+1,"dump:field2index"); tmp = -1;
memory->grow(argindex,nfield+nthresh+1,"dump:argindex"); n = atom->find_custom(argi.get_name(),tmp);
int n = strlen(arg[1]);
char *suffix = new char[n];
strcpy(suffix,&arg[1][2]);
argindex[nfield+nthresh] = 0;
int tmp = -1;
n = atom->find_custom(suffix,tmp);
if ((n < 0) || (tmp != 0)) if ((n < 0) || (tmp != 0))
error->all(FLERR,"Could not find dump modify " error->all(FLERR,"Could not find dump modify "
"custom atom integer property ID"); "custom atom integer property ID");
field2index[nfield+nthresh] = add_custom(suffix,0); field2index[nfield+nthresh] = add_custom(argi.get_name(),0);
delete [] suffix; break;
} else error->all(FLERR,"Invalid dump_modify thresh attribute"); default:
error->all(FLERR,"Invalid dump_modify thresh attribute");
break;
}
}
// set operation type of threshold // set operation type of threshold

View File

@ -13,6 +13,7 @@
#include "dump_local.h" #include "dump_local.h"
#include "arg_info.h"
#include "compute.h" #include "compute.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
@ -404,85 +405,70 @@ void DumpLocal::parse_fields(int narg, char **arg)
// customize by adding to if statement // customize by adding to if statement
int i;
for (int iarg = 0; iarg < narg; iarg++) { for (int iarg = 0; iarg < narg; iarg++) {
i = iarg;
if (strcmp(arg[iarg],"index") == 0) { if (strcmp(arg[iarg],"index") == 0) {
pack_choice[i] = &DumpLocal::pack_index; pack_choice[iarg] = &DumpLocal::pack_index;
vtype[i] = INT; vtype[iarg] = INT;
} else {
int n;
ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX);
computefixflag = 1;
vtype[iarg] = DOUBLE;
argindex[iarg] = argi.get_index1();
switch (argi.get_type()) {
// compute value = c_ID // compute value = c_ID
// if no trailing [], then arg is set to 0, else arg is int between [] // if no trailing [], then arg is set to 0, else arg is int between []
} else if (strncmp(arg[iarg],"c_",2) == 0) { case ArgInfo::COMPUTE:
computefixflag = 1; pack_choice[iarg] = &DumpLocal::pack_compute;
pack_choice[i] = &DumpLocal::pack_compute;
vtype[i] = DOUBLE;
int n = strlen(arg[iarg]); n = modify->find_compute(argi.get_name());
char *suffix = new char[n];
strcpy(suffix,&arg[iarg][2]);
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Invalid attribute in dump local command");
argindex[i] = atoi(ptr+1);
*ptr = '\0';
} else argindex[i] = 0;
n = modify->find_compute(suffix);
if (n < 0) error->all(FLERR,"Could not find dump local compute ID"); if (n < 0) error->all(FLERR,"Could not find dump local compute ID");
if (modify->compute[n]->local_flag == 0) if (modify->compute[n]->local_flag == 0)
error->all(FLERR,"Dump local compute does not compute local info"); error->all(FLERR,"Dump local compute does not compute local info");
if (argindex[i] == 0 && modify->compute[n]->size_local_cols > 0) if (argi.get_dim() == 0 && modify->compute[n]->size_local_cols > 0)
error->all(FLERR,"Dump local compute does not calculate local vector"); error->all(FLERR,"Dump local compute does not calculate local vector");
if (argindex[i] > 0 && modify->compute[n]->size_local_cols == 0) if (argi.get_index1() > 0 && modify->compute[n]->size_local_cols == 0)
error->all(FLERR,"Dump local compute does not calculate local array"); error->all(FLERR,"Dump local compute does not calculate local array");
if (argindex[i] > 0 && if (argi.get_index1() > 0 &&
argindex[i] > modify->compute[n]->size_local_cols) argi.get_index1() > modify->compute[n]->size_local_cols)
error->all(FLERR,"Dump local compute vector is accessed out-of-range"); error->all(FLERR,"Dump local compute vector is accessed out-of-range");
field2index[i] = add_compute(suffix); field2index[iarg] = add_compute(argi.get_name());
delete [] suffix; break;
// fix value = f_ID // fix value = f_ID
// if no trailing [], then arg is set to 0, else arg is between [] // if no trailing [], then arg is set to 0, else arg is between []
} else if (strncmp(arg[iarg],"f_",2) == 0) { case ArgInfo::FIX:
computefixflag = 1; pack_choice[iarg] = &DumpLocal::pack_fix;
pack_choice[i] = &DumpLocal::pack_fix;
vtype[i] = DOUBLE;
int n = strlen(arg[iarg]); n = modify->find_fix(argi.get_name());
char *suffix = new char[n];
strcpy(suffix,&arg[iarg][2]);
char *ptr = strchr(suffix,'[');
if (ptr) {
if (suffix[strlen(suffix)-1] != ']')
error->all(FLERR,"Invalid attribute in dump local command");
argindex[i] = atoi(ptr+1);
*ptr = '\0';
} else argindex[i] = 0;
n = modify->find_fix(suffix);
if (n < 0) error->all(FLERR,"Could not find dump local fix ID"); if (n < 0) error->all(FLERR,"Could not find dump local fix ID");
if (modify->fix[n]->local_flag == 0) if (modify->fix[n]->local_flag == 0)
error->all(FLERR,"Dump local fix does not compute local info"); error->all(FLERR,"Dump local fix does not compute local info");
if (argindex[i] == 0 && modify->fix[n]->size_local_cols > 0) if (argi.get_dim() == 0 && modify->fix[n]->size_local_cols > 0)
error->all(FLERR,"Dump local fix does not compute local vector"); error->all(FLERR,"Dump local fix does not compute local vector");
if (argindex[i] > 0 && modify->fix[n]->size_local_cols == 0) if (argi.get_index1() > 0 && modify->fix[n]->size_local_cols == 0)
error->all(FLERR,"Dump local fix does not compute local array"); error->all(FLERR,"Dump local fix does not compute local array");
if (argindex[i] > 0 && if (argi.get_index1() > 0 &&
argindex[i] > modify->fix[n]->size_local_cols) argi.get_index1() > modify->fix[n]->size_local_cols)
error->all(FLERR,"Dump local fix vector is accessed out-of-range"); error->all(FLERR,"Dump local fix vector is accessed out-of-range");
field2index[i] = add_fix(suffix); field2index[iarg] = add_fix(argi.get_name());
delete [] suffix; break;
} else error->all(FLERR,"Invalid attribute in dump local command"); case ArgInfo::NONE: // fallthrough
case ArgInfo::UNKNOWN: // fallthrough
default:
error->all(FLERR,"Invalid attribute in dump local command");
break;
}
}
} }
if (computefixflag == 0) if (computefixflag == 0)