diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index 41a1831dc8..3df85d629f 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -527,9 +527,8 @@ double ComputeReduce::compute_one(int m, int flag) if (val.flavor == PERATOM) { if (aidx == 0) { double *fix_vector = val.val.f->vector_atom; - int n = nlocal; if (flag < 0) { - for (int i = 0; i < n; i++) + for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) combine(one, fix_vector[i], i); } else one = fix_vector[flag]; diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index cd29e785ec..664aac841a 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -35,175 +35,188 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), - nvalues(0), which(nullptr), argindex(nullptr), value2index(nullptr), - ids(nullptr), values(nullptr), - vbuf(nullptr), pack_choice(nullptr) + Fix(lmp, narg, arg), avalues(nullptr), vbuf(nullptr) { - if (narg < 5) error->all(FLERR,"Illegal fix store/state command"); + if (narg < 5) utils::missing_cmd_args(FLERR,"fix store/state", error); restart_peratom = 1; peratom_freq = 1; nevery = utils::inumeric(FLERR,arg[3],false,lmp); - if (nevery < 0) error->all(FLERR,"Illegal fix store/state command"); + if (nevery < 0) error->all(FLERR,"Invalid fix store/state never value {}", nevery); - // parse values until one isn't recognized + // parse values // customize a new keyword by adding to if statement - pack_choice = new FnPtrPack[narg-4]; - which = new int[narg-4]; - argindex = new int[narg-4]; - ids = new char*[narg-4]; - value2index = new int[narg-4]; - nvalues = 0; + values.clear(); cfv_any = 0; int iarg = 4; while (iarg < narg) { - which[nvalues] = ArgInfo::KEYWORD; - ids[nvalues] = nullptr; + + value_t val; + val.which = ArgInfo::KEYWORD; + val.argindex = -1; + val.id = ""; + val.val.c = nullptr; + val.pack_choice = nullptr; if (strcmp(arg[iarg],"id") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_id; + val.pack_choice = &FixStoreState::pack_id; } else if (strcmp(arg[iarg],"mol") == 0) { if (!atom->molecule_flag) - error->all(FLERR, - "Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_molecule; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_molecule; } else if (strcmp(arg[iarg],"type") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_type; + val.pack_choice = &FixStoreState::pack_type; } else if (strcmp(arg[iarg],"mass") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_mass; + val.pack_choice = &FixStoreState::pack_mass; } else if (strcmp(arg[iarg],"x") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_x; + val.pack_choice = &FixStoreState::pack_x; } else if (strcmp(arg[iarg],"y") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_y; + val.pack_choice = &FixStoreState::pack_y; } else if (strcmp(arg[iarg],"z") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_z; + val.pack_choice = &FixStoreState::pack_z; } else if (strcmp(arg[iarg],"xs") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_xs_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_xs; + val.pack_choice = &FixStoreState::pack_xs_triclinic; + else val.pack_choice = &FixStoreState::pack_xs; } else if (strcmp(arg[iarg],"ys") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_ys_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_ys; + val.pack_choice = &FixStoreState::pack_ys_triclinic; + else val.pack_choice = &FixStoreState::pack_ys; } else if (strcmp(arg[iarg],"zs") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_zs_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_zs; + val.pack_choice = &FixStoreState::pack_zs_triclinic; + else val.pack_choice = &FixStoreState::pack_zs; } else if (strcmp(arg[iarg],"xu") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_xu_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_xu; + val.pack_choice = &FixStoreState::pack_xu_triclinic; + else val.pack_choice = &FixStoreState::pack_xu; } else if (strcmp(arg[iarg],"yu") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_yu_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_yu; + val.pack_choice = &FixStoreState::pack_yu_triclinic; + else val.pack_choice = &FixStoreState::pack_yu; } else if (strcmp(arg[iarg],"zu") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_zu_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_zu; + val.pack_choice = &FixStoreState::pack_zu_triclinic; + else val.pack_choice = &FixStoreState::pack_zu; } else if (strcmp(arg[iarg],"xsu") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_xsu_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_xsu; + val.pack_choice = &FixStoreState::pack_xsu_triclinic; + else val.pack_choice = &FixStoreState::pack_xsu; } else if (strcmp(arg[iarg],"ysu") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_ysu_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_ysu; + val.pack_choice = &FixStoreState::pack_ysu_triclinic; + else val.pack_choice = &FixStoreState::pack_ysu; } else if (strcmp(arg[iarg],"zsu") == 0) { if (domain->triclinic) - pack_choice[nvalues++] = &FixStoreState::pack_zsu_triclinic; - else pack_choice[nvalues++] = &FixStoreState::pack_zsu; + val.pack_choice = &FixStoreState::pack_zsu_triclinic; + else val.pack_choice = &FixStoreState::pack_zsu; } else if (strcmp(arg[iarg],"ix") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_ix; + val.pack_choice = &FixStoreState::pack_ix; } else if (strcmp(arg[iarg],"iy") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_iy; + val.pack_choice = &FixStoreState::pack_iy; } else if (strcmp(arg[iarg],"iz") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_iz; + val.pack_choice = &FixStoreState::pack_iz; } else if (strcmp(arg[iarg],"vx") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_vx; + val.pack_choice = &FixStoreState::pack_vx; } else if (strcmp(arg[iarg],"vy") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_vy; + val.pack_choice = &FixStoreState::pack_vy; } else if (strcmp(arg[iarg],"vz") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_vz; + val.pack_choice = &FixStoreState::pack_vz; } else if (strcmp(arg[iarg],"fx") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_fx; + val.pack_choice = &FixStoreState::pack_fx; } else if (strcmp(arg[iarg],"fy") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_fy; + val.pack_choice = &FixStoreState::pack_fy; } else if (strcmp(arg[iarg],"fz") == 0) { - pack_choice[nvalues++] = &FixStoreState::pack_fz; + val.pack_choice = &FixStoreState::pack_fz; } else if (strcmp(arg[iarg],"q") == 0) { if (!atom->q_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_q; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_q; } else if (strcmp(arg[iarg],"mux") == 0) { if (!atom->mu_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_mux; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_mux; } else if (strcmp(arg[iarg],"muy") == 0) { if (!atom->mu_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_muy; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_muy; } else if (strcmp(arg[iarg],"muz") == 0) { if (!atom->mu_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_muz; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_muz; } else if (strcmp(arg[iarg],"mu") == 0) { if (!atom->mu_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_mu; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_mu; } else if (strcmp(arg[iarg],"radius") == 0) { if (!atom->radius_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_radius; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_radius; } else if (strcmp(arg[iarg],"diameter") == 0) { if (!atom->radius_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_diameter; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_diameter; } else if (strcmp(arg[iarg],"omegax") == 0) { if (!atom->omega_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_omegax; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_omegax; } else if (strcmp(arg[iarg],"omegay") == 0) { if (!atom->omega_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_omegay; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_omegay; } else if (strcmp(arg[iarg],"omegaz") == 0) { if (!atom->omega_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_omegaz; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_omegaz; } else if (strcmp(arg[iarg],"angmomx") == 0) { if (!atom->angmom_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_angmomx; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_angmomx; } else if (strcmp(arg[iarg],"angmomy") == 0) { if (!atom->angmom_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_angmomy; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_angmomy; } else if (strcmp(arg[iarg],"angmomz") == 0) { if (!atom->angmom_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_angmomz; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_angmomz; } else if (strcmp(arg[iarg],"tqx") == 0) { if (!atom->torque_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_tqx; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_tqx; } else if (strcmp(arg[iarg],"tqy") == 0) { if (!atom->torque_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_tqy; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_tqy; } else if (strcmp(arg[iarg],"tqz") == 0) { if (!atom->torque_flag) - error->all(FLERR,"Fix store/state for atom property that isn't allocated"); - pack_choice[nvalues++] = &FixStoreState::pack_tqz; + error->all(FLERR, "Cannot use fix store/state {} for atom style {}", + arg[iarg], atom->get_style()); + val.pack_choice = &FixStoreState::pack_tqz; // compute or fix or variable or custom per-atom vector or array @@ -211,16 +224,15 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : ArgInfo argi(arg[iarg],ArgInfo::COMPUTE|ArgInfo::FIX|ArgInfo::VARIABLE |ArgInfo::DNAME|ArgInfo::INAME); - if (argi.get_type() == ArgInfo::NONE) break; - if ((argi.get_type() == ArgInfo::UNKNOWN) || (argi.get_dim() > 1)) - error->all(FLERR,"Illegal fix store/state command"); + val.which = argi.get_type(); + val.argindex = argi.get_index1(); + val.id = argi.get_name(); - which[nvalues] = argi.get_type(); - argindex[nvalues] = argi.get_index1(); - ids[nvalues] = argi.copy_name(); - nvalues++; + if (val.which == ArgInfo::NONE) break; + if ((val.which == ArgInfo::UNKNOWN) || (argi.get_dim() > 1)) + error->all(FLERR,"Illegal fix store/state argument: {}", arg[iarg]); } - + values.push_back(val); iarg++; } @@ -230,94 +242,79 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : while (iarg < narg) { if (strcmp(arg[iarg],"com") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix store/state command"); + if (iarg+2 > narg) utils::missing_cmd_args(FLERR,"fix store/state com", error); comflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; - } else error->all(FLERR,"Illegal fix store/state command"); + } else error->all(FLERR,"Unknown fix store/state keyword: {}", arg[iarg]); } // error check - for (int i = 0; i < nvalues; i++) { - if (which[i] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[i]); - if (icompute < 0) - error->all(FLERR,"Compute ID for fix store/state does not exist"); - if (modify->compute[icompute]->peratom_flag == 0) - error->all(FLERR,"Fix store/state compute does not calculate per-atom values"); - if (argindex[i] == 0 && - modify->compute[icompute]->size_peratom_cols != 0) - error->all(FLERR,"Fix store/state compute does not calculate a per-atom vector"); - if (argindex[i] && modify->compute[icompute]->size_peratom_cols == 0) - error->all(FLERR, - "Fix store/state compute does not calculate a per-atom array"); - if (argindex[i] && - argindex[i] > modify->compute[icompute]->size_peratom_cols) - error->all(FLERR, - "Fix store/state compute array is accessed out-of-range"); + for (auto &val : values) { + if (val.which == ArgInfo::COMPUTE) { + val.val.c = modify->get_compute_by_id(val.id); + if (!val.val.c) + error->all(FLERR,"Compute ID {} for fix store/state does not exist", val.id); + if (val.val.c->peratom_flag == 0) + error->all(FLERR,"Fix store/state compute {} does not calculate per-atom values", val.id); + if (val.argindex == 0 && + val.val.c->size_peratom_cols != 0) + error->all(FLERR,"Fix store/state compute {} does not calculate per-atom vector", val.id); + if (val.argindex && val.val.c->size_peratom_cols == 0) + error->all(FLERR, "Fix store/state compute {} does not calculate per-atom array", val.id); + if (val.argindex && (val.argindex > val.val.c->size_peratom_cols)) + error->all(FLERR, "Fix store/state compute array {} is accessed out-of-range", val.id); - } else if (which[i] == ArgInfo::FIX) { - int ifix = modify->find_fix(ids[i]); - if (ifix < 0) - error->all(FLERR, - "Fix ID for fix store/state does not exist"); - if (modify->fix[ifix]->peratom_flag == 0) - error->all(FLERR, - "Fix store/state fix does not calculate per-atom values"); - if (argindex[i] == 0 && modify->fix[ifix]->size_peratom_cols != 0) - error->all(FLERR, - "Fix store/state fix does not calculate a per-atom vector"); - if (argindex[i] && modify->fix[ifix]->size_peratom_cols == 0) - error->all(FLERR, - "Fix store/state fix does not calculate a per-atom array"); - if (argindex[i] && argindex[i] > modify->fix[ifix]->size_peratom_cols) - error->all(FLERR, - "Fix store/state fix array is accessed out-of-range"); - if (nevery % modify->fix[ifix]->peratom_freq) - error->all(FLERR, - "Fix for fix store/state not computed at compatible time"); + } else if (val.which == ArgInfo::FIX) { + val.val.f = modify->get_fix_by_id(val.id); + if (!val.val.f) + error->all(FLERR, "Fix ID {} for fix store/state does not exist", val.id); + if (val.val.f->peratom_flag == 0) + error->all(FLERR, "Fix store/state fix {} does not calculate per-atom values", val.id); + if (val.argindex == 0 && val.val.f->size_peratom_cols != 0) + error->all(FLERR, "Fix store/state fix {} does not calculate per-atom vector", val.id); + if (val.argindex && val.val.f->size_peratom_cols == 0) + error->all(FLERR, "Fix store/state fix {} does not calculate per-atom array", val.id); + if (val.argindex && (val.argindex > val.val.f->size_peratom_cols)) + error->all(FLERR, "Fix store/state fix {} array is accessed out-of-range", val.id); + if (nevery % val.val.f->peratom_freq) + error->all(FLERR, "Fix {} for fix store/state not computed at compatible time", val.id); - } else if (which[i] == ArgInfo::VARIABLE) { - int ivariable = input->variable->find(ids[i]); - if (ivariable < 0) - error->all(FLERR,"Variable name for fix store/state does not exist"); - if (input->variable->atomstyle(ivariable) == 0) - error->all(FLERR,"Fix store/state variable is not atom-style variable"); + } else if (val.which == ArgInfo::VARIABLE) { + val.val.v = input->variable->find(val.id.c_str()); + if (val.val.v < 0) + error->all(FLERR, "Variable name {} for fix store/state does not exist", val.id); + if (input->variable->atomstyle(val.val.v) == 0) + error->all(FLERR,"Fix store/state variable {} is not atom-style variable", val.id); - } 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) { + } else if (val.which == ArgInfo::DNAME) { + int iflag,icol; + val.val.d = atom->find_custom(val.id.c_str(),iflag,icol); + if (val.val.d < 0) + error->all(FLERR,"Custom vector/array {} for fix store/state does not exist", val.id); + if (val.argindex == 0) { if (!iflag || icol) - error->all(FLERR, - "Custom double vector for fix store/state does not exist"); + error->all(FLERR, "Custom property {} for fix store/state is not double vector", val.id); } 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"); + error->all(FLERR, "Custom property {} for fix store/state is not double array", val.id); + if (val.argindex > atom->dcols[val.val.d]) + error->all(FLERR, "Fix store/state custom array {} is accessed out-of-range", val.id); } - } else if (which[i] == ArgInfo::INAME) { - 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) { + } else if (val.which == ArgInfo::INAME) { + int iflag,icol; + val.val.i = atom->find_custom(val.id.c_str(),iflag,icol); + if (val.val.i < 0) + error->all(FLERR, "Custom vector/array {} for fix store/state does not exist", val.id); + if (val.argindex == 0) { if (iflag || icol) - error->all(FLERR, - "Custom integer vector for fix store/state does not exist"); + error->all(FLERR, "Custom property {} for fix store/state is not integer vector", val.id); } else { if (iflag || !icol) - error->all(FLERR, - "Custom integer array for fix store/state does not exist"); - if (argindex[i] > atom->icols[icustom]) - error->all(FLERR, - "Fix store/state custom array is accessed out-of-range"); + error->all(FLERR, "Custom property {} for fix store/state is not integer array", val.id); + if (val.argindex > atom->icols[val.val.i]) + error->all(FLERR, "Fix store/state custom array {} is accessed out-of-range", val.id); } } } @@ -325,13 +322,13 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : // this fix produces either a per-atom vector or array peratom_flag = 1; - if (nvalues == 1) size_peratom_cols = 0; - else size_peratom_cols = nvalues; + if (values.size() == 1) size_peratom_cols = 0; + else size_peratom_cols = values.size(); // perform initial allocation of atom-based array // register with Atom class - values = nullptr; + avalues = nullptr; FixStoreState::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); @@ -341,8 +338,8 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : int nlocal = atom->nlocal; for (int i = 0; i < nlocal; i++) - for (int m = 0; m < nvalues; m++) - values[i][m] = 0.0; + for (int m = 0; m < values.size(); m++) + avalues[i][m] = 0.0; // store current values for keywords but not for compute, fix, variable @@ -361,14 +358,7 @@ FixStoreState::~FixStoreState() atom->delete_callback(id,Atom::GROW); atom->delete_callback(id,Atom::RESTART); - delete [] which; - delete [] argindex; - for (int m = 0; m < nvalues; m++) delete [] ids[m]; - delete [] ids; - delete [] value2index; - delete [] pack_choice; - - memory->destroy(values); + memory->destroy(avalues); } /* ---------------------------------------------------------------------- */ @@ -389,31 +379,33 @@ void FixStoreState::init() if (!firstflag && nevery == 0) return; - for (int m = 0; m < nvalues; m++) { - if (which[m] == ArgInfo::COMPUTE) { - int icompute = modify->find_compute(ids[m]); - if (icompute < 0) - error->all(FLERR,"Compute ID for fix store/state does not exist"); - value2index[m] = icompute; + for (auto &val : values) { + if (val.which == ArgInfo::COMPUTE) { + val.val.c = modify->get_compute_by_id(val.id); + if (!val.val.c) + error->all(FLERR,"Compute ID {} for fix store/state does not exist", val.id); - } else if (which[m] == ArgInfo::FIX) { - int ifix = modify->find_fix(ids[m]); - if (ifix < 0) - error->all(FLERR,"Fix ID for fix store/state does not exist"); - value2index[m] = ifix; + } else if (val.which == ArgInfo::FIX) { + val.val.f = modify->get_fix_by_id(val.id); + if (!val.val.f) + error->all(FLERR,"Fix ID {} for fix store/state does not exist", val.id); - } else if (which[m] == ArgInfo::VARIABLE) { - int ivariable = input->variable->find(ids[m]); - if (ivariable < 0) - error->all(FLERR,"Variable name for fix store/state does not exist"); - value2index[m] = ivariable; + } else if (val.which == ArgInfo::VARIABLE) { + val.val.v = input->variable->find(val.id.c_str()); + if (val.val.v < 0) + error->all(FLERR,"Variable name {} for fix store/state does not exist", val.id); - } else if (which[m] == ArgInfo::INAME || which[m] == ArgInfo::DNAME) { - int icustom,iflag,cols; - icustom = atom->find_custom(ids[m],iflag,cols); - if (icustom < 0) - error->all(FLERR,"Custom vector/array for fix store/state does not exist"); - value2index[m] = icustom; + } else if (val.which == ArgInfo::DNAME) { + int iflag,cols; + val.val.d = atom->find_custom(val.id.c_str(), iflag, cols); + if (val.val.d < 0) + error->all(FLERR,"Custom vector/array {} for fix store/state does not exist", val.id); + + } else if (val.which == ArgInfo::INAME) { + int iflag,cols; + val.val.i = atom->find_custom(val.id.c_str(), iflag, cols); + if (val.val.i < 0) + error->all(FLERR,"Custom vector/array {} for fix store/state does not exist", val.id); } } } @@ -437,8 +429,6 @@ void FixStoreState::setup(int /*vflag*/) void FixStoreState::end_of_step() { - int i,j,n; - // compute com if comflag set if (comflag) { @@ -452,86 +442,85 @@ void FixStoreState::end_of_step() // fill vector or array with per-atom values - if (values) vbuf = &values[0][0]; + if (avalues) vbuf = &avalues[0][0]; else vbuf = nullptr; - for (int m = 0; m < nvalues; m++) { - if (which[m] == ArgInfo::KEYWORD && kflag) (this->*pack_choice[m])(m); + int m = 0; + for (auto &val : values) { + if (val.which == ArgInfo::KEYWORD && kflag) + (this->*val.pack_choice)(m); else if (cfv_flag) { - n = value2index[m]; - j = argindex[m]; int *mask = atom->mask; int nlocal = atom->nlocal; - // invoke compute if not previously invoked + // invoke compute if not previously invoked, then access fields - if (which[m] == ArgInfo::COMPUTE) { - Compute *compute = modify->compute[n]; - if (!(compute->invoked_flag & Compute::INVOKED_PERATOM)) { - compute->compute_peratom(); - compute->invoked_flag |= Compute::INVOKED_PERATOM; + if (val.which == ArgInfo::COMPUTE) { + if (!(val.val.c->invoked_flag & Compute::INVOKED_PERATOM)) { + val.val.c->compute_peratom(); + val.val.c->invoked_flag |= Compute::INVOKED_PERATOM; } - if (j == 0) { - double *compute_vector = compute->vector_atom; - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) values[i][m] = compute_vector[i]; + if (val.argindex == 0) { + double *compute_vector = val.val.c->vector_atom; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[i][m] = compute_vector[i]; } else { - int jm1 = j - 1; - double **compute_array = compute->array_atom; - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) values[i][m] = compute_array[i][jm1]; + int jm1 = val.argindex - 1; + double **compute_array = val.val.c->array_atom; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[i][m] = compute_array[i][jm1]; } // access fix fields, guaranteed to be ready - } else if (which[m] == ArgInfo::FIX) { - if (j == 0) { - double *fix_vector = modify->fix[n]->vector_atom; - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) values[i][m] = fix_vector[i]; + } else if (val.which == ArgInfo::FIX) { + if (val.argindex == 0) { + double *fix_vector = val.val.f->vector_atom; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[i][m] = fix_vector[i]; } else { - int jm1 = j - 1; - double **fix_array = modify->fix[n]->array_atom; - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) values[i][m] = fix_array[i][jm1]; + int jm1 = val.argindex - 1; + double **fix_array = val.val.f->array_atom; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[i][m] = fix_array[i][jm1]; } // evaluate atom-style variable - } else if (which[m] == ArgInfo::VARIABLE) { - input->variable->compute_atom(n,igroup,&values[0][m],nvalues,0); - + } else if (val.which == ArgInfo::VARIABLE) { + input->variable->compute_atom(val.val.v, igroup, &avalues[0][m], values.size(),0); // access custom atom vector/array fields - } else if (which[m] == ArgInfo::DNAME) { - if (j == 0) { - double *dvector = atom->dvector[n]; - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) values[i][m] = dvector[i]; + } else if (val.which == ArgInfo::DNAME) { + if (val.argindex == 0) { + double *dvector = atom->dvector[val.val.d]; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[i][m] = dvector[i]; } else { - double **darray = atom->darray[n]; - int jm1 = j - 1; - for (i = 0; i < nlocal; i++) - if (mask[i] & groupbit) values[i][m] = darray[i][jm1]; + double **darray = atom->darray[val.val.d]; + int jm1 = val.argindex - 1; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[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 if (val.which == ArgInfo::INAME) { + if (val.argindex == 0) { + int *ivector = atom->ivector[val.val.i]; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[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]; + int **iarray = atom->iarray[val.val.i]; + int jm1 = val.argindex - 1; + for (int i = 0; i < nlocal; i++) + if (mask[i] & groupbit) avalues[i][m] = iarray[i][jm1]; } } } + ++m; } // if any compute/fix/variable and nevery, wrap with clear/add @@ -548,7 +537,7 @@ void FixStoreState::end_of_step() double FixStoreState::memory_usage() { - double bytes = (double)atom->nmax*nvalues * sizeof(double); + double bytes = (double)atom->nmax*values.size() * sizeof(double); return bytes; } @@ -558,11 +547,11 @@ double FixStoreState::memory_usage() void FixStoreState::grow_arrays(int nmax) { - memory->grow(values,nmax,nvalues,"store/state:values"); - if (nvalues == 1) { - if (nmax) vector_atom = &values[0][0]; + memory->grow(avalues,nmax,values.size(),"store/state:avalues"); + if (values.size() == 1) { + if (nmax) vector_atom = &avalues[0][0]; else vector_atom = nullptr; - } else array_atom = values; + } else array_atom = avalues; } /* ---------------------------------------------------------------------- @@ -571,7 +560,7 @@ void FixStoreState::grow_arrays(int nmax) void FixStoreState::copy_arrays(int i, int j, int /*delflag*/) { - for (int m = 0; m < nvalues; m++) values[j][m] = values[i][m]; + for (int m = 0; m < values.size(); m++) avalues[j][m] = avalues[i][m]; } /* ---------------------------------------------------------------------- @@ -580,8 +569,8 @@ void FixStoreState::copy_arrays(int i, int j, int /*delflag*/) int FixStoreState::pack_exchange(int i, double *buf) { - for (int m = 0; m < nvalues; m++) buf[m] = values[i][m]; - return nvalues; + for (int m = 0; m < values.size(); m++) buf[m] = avalues[i][m]; + return values.size(); } /* ---------------------------------------------------------------------- @@ -590,8 +579,8 @@ int FixStoreState::pack_exchange(int i, double *buf) int FixStoreState::unpack_exchange(int nlocal, double *buf) { - for (int m = 0; m < nvalues; m++) values[nlocal][m] = buf[m]; - return nvalues; + for (int m = 0; m < values.size(); m++) avalues[nlocal][m] = buf[m]; + return values.size(); } /* ---------------------------------------------------------------------- @@ -601,9 +590,9 @@ int FixStoreState::unpack_exchange(int nlocal, double *buf) int FixStoreState::pack_restart(int i, double *buf) { // pack buf[0] this way because other fixes unpack it - buf[0] = nvalues+1; - for (int m = 0; m < nvalues; m++) buf[m+1] = values[i][m]; - return nvalues+1; + buf[0] = values.size()+1; + for (int m = 0; m < values.size(); m++) buf[m+1] = avalues[i][m]; + return values.size()+1; } /* ---------------------------------------------------------------------- @@ -621,7 +610,7 @@ void FixStoreState::unpack_restart(int nlocal, int nth) for (int i = 0; i < nth; i++) m += static_cast (extra[nlocal][m]); m++; - for (int i = 0; i < nvalues; i++) values[nlocal][i] = extra[nlocal][m++]; + for (int i = 0; i < values.size(); i++) avalues[nlocal][i] = extra[nlocal][m++]; } /* ---------------------------------------------------------------------- @@ -630,7 +619,7 @@ void FixStoreState::unpack_restart(int nlocal, int nth) int FixStoreState::maxsize_restart() { - return nvalues+1; + return values.size()+1; } /* ---------------------------------------------------------------------- @@ -639,12 +628,12 @@ int FixStoreState::maxsize_restart() int FixStoreState::size_restart(int /*nlocal*/) { - return nvalues+1; + return values.size()+1; } /* ---------------------------------------------------------------------- one method for every keyword fix store/state can archive - the atom property is packed into buf starting at n with stride nvalues + the atom property is packed into buf starting at n with stride values.size() customize a new keyword by adding a method ------------------------------------------------------------------------- */ @@ -659,7 +648,7 @@ void FixStoreState::pack_id(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = tag[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -674,7 +663,7 @@ void FixStoreState::pack_molecule(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = molecule[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -689,7 +678,7 @@ void FixStoreState::pack_type(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = type[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -707,13 +696,13 @@ void FixStoreState::pack_mass(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = rmass[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } else { for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = mass[type[i]]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } } @@ -729,7 +718,7 @@ void FixStoreState::pack_x(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = x[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -744,7 +733,7 @@ void FixStoreState::pack_y(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = x[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -759,7 +748,7 @@ void FixStoreState::pack_z(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = x[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -777,7 +766,7 @@ void FixStoreState::pack_xs(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = (x[i][0] - boxxlo) * invxprd; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -795,7 +784,7 @@ void FixStoreState::pack_ys(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = (x[i][1] - boxylo) * invyprd; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -813,7 +802,7 @@ void FixStoreState::pack_zs(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = (x[i][2] - boxzlo) * invzprd; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -833,7 +822,7 @@ void FixStoreState::pack_xs_triclinic(int n) vbuf[n] = h_inv[0]*(x[i][0]-boxlo[0]) + h_inv[5]*(x[i][1]-boxlo[1]) + h_inv[4]*(x[i][2]-boxlo[2]); else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -852,7 +841,7 @@ void FixStoreState::pack_ys_triclinic(int n) if (mask[i] & groupbit) vbuf[n] = h_inv[1]*(x[i][1]-boxlo[1]) + h_inv[3]*(x[i][2]-boxlo[2]); else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -871,7 +860,7 @@ void FixStoreState::pack_zs_triclinic(int n) if (mask[i] & groupbit) vbuf[n] = h_inv[2]*(x[i][2]-boxlo[2]); else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -891,7 +880,7 @@ void FixStoreState::pack_xu(int n) vbuf[n] = x[i][0] + ((image[i] & IMGMASK) - IMGMAX) * xprd; if (comflag) vbuf[n] -= cm[0]; } else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -911,7 +900,7 @@ void FixStoreState::pack_yu(int n) vbuf[n] = x[i][1] + ((image[i] >> IMGBITS & IMGMASK) - IMGMAX) * yprd; if (comflag) vbuf[n] -= cm[1]; } else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -931,7 +920,7 @@ void FixStoreState::pack_zu(int n) vbuf[n] = x[i][2] + ((image[i] >> IMG2BITS) - IMGMAX) * zprd; if (comflag) vbuf[n] -= cm[2]; } else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -955,7 +944,7 @@ void FixStoreState::pack_xu_triclinic(int n) vbuf[n] = x[i][0] + h[0]*xbox + h[5]*ybox + h[4]*zbox; if (comflag) vbuf[n] -= cm[0]; } else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -978,7 +967,7 @@ void FixStoreState::pack_yu_triclinic(int n) vbuf[n] = x[i][1] + h[1]*ybox + h[3]*zbox; if (comflag) vbuf[n] -= cm[1]; } else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1000,7 +989,7 @@ void FixStoreState::pack_zu_triclinic(int n) vbuf[n] = x[i][2] + h[2]*zbox; if (comflag) vbuf[n] -= cm[2]; } else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1020,7 +1009,7 @@ void FixStoreState::pack_xsu(int n) if (mask[i] & groupbit) vbuf[n] = (x[i][0]-boxxlo)*invxprd + ((image[i] & IMGMASK) - IMGMAX); else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1041,7 +1030,7 @@ void FixStoreState::pack_ysu(int n) vbuf[n] = (x[i][1]-boxylo)*invyprd + (image[i] >> IMGBITS & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1061,7 +1050,7 @@ void FixStoreState::pack_zsu(int n) if (mask[i] & groupbit) vbuf[n] = (x[i][2]-boxzlo)*invzprd + (image[i] >> IMG2BITS) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1082,7 +1071,7 @@ void FixStoreState::pack_xsu_triclinic(int n) vbuf[n] = h_inv[0]*(x[i][0]-boxlo[0]) + h_inv[5]*(x[i][1]-boxlo[1]) + h_inv[4]*(x[i][2]-boxlo[2]) + (image[i] & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1103,7 +1092,7 @@ void FixStoreState::pack_ysu_triclinic(int n) vbuf[n] = h_inv[1]*(x[i][1]-boxlo[1]) + h_inv[3]*(x[i][2]-boxlo[2]) + (image[i] >> IMGBITS & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1123,7 +1112,7 @@ void FixStoreState::pack_zsu_triclinic(int n) if (mask[i] & groupbit) vbuf[n] = h_inv[2]*(x[i][2]-boxlo[2]) + (image[i] >> IMG2BITS) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1138,7 +1127,7 @@ void FixStoreState::pack_ix(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = (image[i] & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1154,7 +1143,7 @@ void FixStoreState::pack_iy(int n) if (mask[i] & groupbit) vbuf[n] = (image[i] >> IMGBITS & IMGMASK) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1169,7 +1158,7 @@ void FixStoreState::pack_iz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = (image[i] >> IMG2BITS) - IMGMAX; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1184,7 +1173,7 @@ void FixStoreState::pack_vx(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = v[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1199,7 +1188,7 @@ void FixStoreState::pack_vy(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = v[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1214,7 +1203,7 @@ void FixStoreState::pack_vz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = v[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1229,7 +1218,7 @@ void FixStoreState::pack_fx(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = f[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1244,7 +1233,7 @@ void FixStoreState::pack_fy(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = f[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1259,7 +1248,7 @@ void FixStoreState::pack_fz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = f[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1274,7 +1263,7 @@ void FixStoreState::pack_q(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = q[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1289,7 +1278,7 @@ void FixStoreState::pack_mux(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = mu[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1304,7 +1293,7 @@ void FixStoreState::pack_muy(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = mu[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1319,7 +1308,7 @@ void FixStoreState::pack_muz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = mu[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1334,7 +1323,7 @@ void FixStoreState::pack_mu(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = mu[i][3]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1349,7 +1338,7 @@ void FixStoreState::pack_radius(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = radius[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1364,7 +1353,7 @@ void FixStoreState::pack_diameter(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = 2.0*radius[i]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1379,7 +1368,7 @@ void FixStoreState::pack_omegax(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = omega[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1394,7 +1383,7 @@ void FixStoreState::pack_omegay(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = omega[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1409,7 +1398,7 @@ void FixStoreState::pack_omegaz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = omega[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1424,7 +1413,7 @@ void FixStoreState::pack_angmomx(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = angmom[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1439,7 +1428,7 @@ void FixStoreState::pack_angmomy(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = angmom[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1454,7 +1443,7 @@ void FixStoreState::pack_angmomz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = angmom[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1469,7 +1458,7 @@ void FixStoreState::pack_tqx(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = torque[i][0]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1484,7 +1473,7 @@ void FixStoreState::pack_tqy(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = torque[i][1]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } @@ -1499,6 +1488,6 @@ void FixStoreState::pack_tqz(int n) for (int i = 0; i < nlocal; i++) { if (mask[i] & groupbit) vbuf[n] = torque[i][2]; else vbuf[n] = 0.0; - n += nvalues; + n += values.size(); } } diff --git a/src/fix_store_state.h b/src/fix_store_state.h index 245d54c8e5..19821d55ef 100644 --- a/src/fix_store_state.h +++ b/src/fix_store_state.h @@ -44,10 +44,22 @@ class FixStoreState : public Fix { int maxsize_restart() override; private: - int nvalues; - int *which, *argindex, *value2index; - char **ids; - double **values; // archived atom properties + struct value_t { + int which; + int argindex; + std::string id; + union { + class Compute *c; + class Fix *f; + int v; + int d; + int i; + } val; + void (FixStoreState::* pack_choice)(int); // ptr to pack function + }; + std::vector values; + + double **avalues; // archived atom properties double *vbuf; // 1d ptr to values int comflag; @@ -56,9 +68,6 @@ class FixStoreState : public Fix { int kflag, cfv_flag, firstflag; int cfv_any; // 1 if any compute/fix/variable specified - typedef void (FixStoreState::*FnPtrPack)(int); - FnPtrPack *pack_choice; // ptrs to pack functions - void pack_id(int); void pack_molecule(int); void pack_type(int); @@ -113,8 +122,6 @@ class FixStoreState : public Fix { void pack_tqy(int); void pack_tqz(int); }; - } // namespace LAMMPS_NS - #endif #endif