rename reset metacommands to use reset_atoms
This commit is contained in:
@ -38,7 +38,7 @@ Contributing Author: Jacob Gissinger (jacob.r.gissinger@gmail.com)
|
||||
#include "neighbor.h"
|
||||
#include "pair.h"
|
||||
#include "random_mars.h"
|
||||
#include "reset_mol_ids.h"
|
||||
#include "reset_atoms_mol.h"
|
||||
#include "respa.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
@ -118,8 +118,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
|
||||
fix3 = nullptr;
|
||||
reset_mol_ids = nullptr;
|
||||
|
||||
if (narg < 8) error->all(FLERR,"Illegal fix bond/react command: "
|
||||
"too few arguments");
|
||||
if (narg < 8) error->all(FLERR,"Illegal fix bond/react command: " "too few arguments");
|
||||
|
||||
MPI_Comm_rank(world,&me);
|
||||
MPI_Comm_size(world,&nprocs);
|
||||
@ -209,7 +208,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
if (reset_mol_ids_flag) {
|
||||
delete reset_mol_ids;
|
||||
reset_mol_ids = new ResetMolIDs(lmp);
|
||||
reset_mol_ids = new ResetAtomsMol(lmp);
|
||||
reset_mol_ids->create_computes(id,group->names[igroup]);
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ class FixBondReact : public Fix {
|
||||
class RanMars **random; // random number for 'prob' keyword
|
||||
class RanMars **rrhandom; // random number for Arrhenius constraint
|
||||
class NeighList *list;
|
||||
class ResetMolIDs *reset_mol_ids; // class for resetting mol IDs
|
||||
class ResetAtomsMol *reset_mol_ids; // class for resetting mol IDs
|
||||
|
||||
int *reacted_mol, *unreacted_mol;
|
||||
int *limit_duration; // indicates how long to relax
|
||||
|
||||
@ -32,9 +32,6 @@ void Deprecated::command(int narg, char **arg)
|
||||
if (cmd == "DEPRECATED") {
|
||||
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nCommand 'DEPRECATED' is a dummy command\n\n");
|
||||
return;
|
||||
} else if (cmd == "reset_ids") {
|
||||
if (lmp->comm->me == 0)
|
||||
utils::logmesg(lmp, "\n'reset_ids' has been renamed to 'reset atom_ids'\n\n");
|
||||
} else if (utils::strmatch(cmd, "^kim_")) {
|
||||
std::string newcmd("kim");
|
||||
newcmd += " " + cmd.substr(4);
|
||||
@ -48,8 +45,9 @@ void Deprecated::command(int narg, char **arg)
|
||||
input->one(newcmd);
|
||||
return;
|
||||
} else if (utils::strmatch(cmd, "^reset_")) {
|
||||
std::string newcmd("reset");
|
||||
newcmd += " " + cmd.substr(6);
|
||||
std::string newcmd("reset_atoms");
|
||||
if ((cmd == "reset_ids") || (cmd == "reset_atom_ids")) newcmd += " id";
|
||||
if (cmd == "reset_mol_ids") newcmd += " mol";
|
||||
if (lmp->comm->me == 0)
|
||||
utils::logmesg(lmp, "\nWARNING: '{}' has been renamed to '{}'. Please update your input.\n\n",
|
||||
cmd, newcmd);
|
||||
|
||||
@ -14,14 +14,13 @@
|
||||
#ifdef COMMAND_CLASS
|
||||
// clang-format off
|
||||
CommandStyle(DEPRECATED,Deprecated);
|
||||
CommandStyle(reset_ids,Deprecated);
|
||||
CommandStyle(kim_init,Deprecated);
|
||||
CommandStyle(kim_interactions,Deprecated);
|
||||
CommandStyle(kim_param,Deprecated);
|
||||
CommandStyle(kim_property,Deprecated);
|
||||
CommandStyle(kim_query,Deprecated);
|
||||
CommandStyle(reset_ids,Deprecated);
|
||||
CommandStyle(reset_atom_ids,Deprecated);
|
||||
CommandStyle(reset_image_flags,Deprecated);
|
||||
CommandStyle(reset_mol_ids,Deprecated);
|
||||
CommandStyle(message,Deprecated);
|
||||
CommandStyle(server,Deprecated);
|
||||
|
||||
@ -831,7 +831,7 @@ int Input::execute_command()
|
||||
// process "meta-commands", i.e. commands that may have sub-commands
|
||||
// they return 1 if there was a match and 0 if not
|
||||
|
||||
if (mycmd == "reset") flag = meta(mycmd);
|
||||
if (mycmd == "reset_atoms") flag = meta(mycmd);
|
||||
if (flag) return 0;
|
||||
|
||||
// invoke commands added via style_command.h
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "reset_atom_ids.h"
|
||||
#include "reset_atoms_id.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
@ -31,7 +31,7 @@ using namespace LAMMPS_NS;
|
||||
#if defined(LMP_QSORT)
|
||||
// allocate space for static class variable
|
||||
// prototype for non-class function
|
||||
ResetIDs::AtomRvous *ResetIDs::sortrvous;
|
||||
ResetAtomsID::AtomRvous *ResetAtomsID::sortrvous;
|
||||
static int compare_coords(const void *, const void *);
|
||||
#else
|
||||
// prototype for non-class function
|
||||
@ -43,19 +43,19 @@ static int compare_coords(const int, const int, void *);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ResetIDs::ResetIDs(LAMMPS *lmp) : Command(lmp) {}
|
||||
ResetAtomsID::ResetAtomsID(LAMMPS *lmp) : Command(lmp) {}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ResetIDs::command(int narg, char **arg)
|
||||
void ResetAtomsID::command(int narg, char **arg)
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR, "Reset atom_ids command before simulation box is defined");
|
||||
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset atom_ids unless atoms have IDs");
|
||||
error->all(FLERR, "Reset_atoms id command before simulation box is defined");
|
||||
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms id unless atoms have IDs");
|
||||
|
||||
for (int i = 0; i < modify->nfix; i++)
|
||||
if (modify->fix[i]->stores_ids)
|
||||
error->all(FLERR, "Cannot use reset atom_ids when a fix exists that stores atom IDs");
|
||||
error->all(FLERR, "Cannot use reset_atoms id when a fix exists that stores atom IDs");
|
||||
|
||||
if (comm->me == 0) utils::logmesg(lmp, "Resetting atom IDs ...\n");
|
||||
|
||||
@ -66,11 +66,11 @@ void ResetIDs::command(int narg, char **arg)
|
||||
int iarg = 0;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "sort") == 0) {
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset atom_ids", error);
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms id", error);
|
||||
sortflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
} else
|
||||
error->all(FLERR, "Unknown reset atom_ids keyword: {}", arg[iarg]);
|
||||
error->all(FLERR, "Unknown reset_atoms id keyword: {}", arg[iarg]);
|
||||
}
|
||||
|
||||
// create an atom map if one doesn't exist already
|
||||
@ -278,7 +278,7 @@ void ResetIDs::command(int narg, char **arg)
|
||||
MPI_Allreduce(&badcount, &all, 1, MPI_INT, MPI_SUM, world);
|
||||
if (all)
|
||||
error->all(FLERR,
|
||||
"Reset atom_ids is missing {} bond topology atom IDs - use comm_modify cutoff", all);
|
||||
"reset_atoms id is missing {} bond topology atom IDs - use comm_modify cutoff", all);
|
||||
|
||||
// reset IDs and atom map for owned atoms
|
||||
|
||||
@ -312,7 +312,7 @@ void ResetIDs::command(int narg, char **arg)
|
||||
spatial sort of atoms followed by rendezvous comm to reset atom IDs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ResetIDs::sort()
|
||||
void ResetAtomsID::sort()
|
||||
{
|
||||
double mylo[3], myhi[3], bboxlo[3], bboxhi[3];
|
||||
|
||||
@ -469,11 +469,11 @@ void ResetIDs::sort()
|
||||
outbuf = list of N IDRvous datums, sent back to sending proc
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&outbuf, void *ptr)
|
||||
int ResetAtomsID::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&outbuf, void *ptr)
|
||||
{
|
||||
int i, ibin, index;
|
||||
|
||||
auto rptr = (ResetIDs *) ptr;
|
||||
auto rptr = (ResetAtomsID *) ptr;
|
||||
Memory *memory = rptr->memory;
|
||||
Error *error = rptr->error;
|
||||
MPI_Comm world = rptr->world;
|
||||
@ -504,7 +504,7 @@ int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&ou
|
||||
if (in[i].ibin < binlo || in[i].ibin >= binhi) {
|
||||
//printf("BAD me %d i %d %d ibin %d binlohi %d %d\n",
|
||||
// rptr->comm->me,i,n,in[i].ibin,binlo,binhi);
|
||||
error->one(FLERR, "Bad spatial bin assignment in reset atom_ids sort");
|
||||
error->one(FLERR, "Bad spatial bin assignment in reset_atoms id sort");
|
||||
}
|
||||
ibin = in[i].ibin - binlo;
|
||||
if (head[ibin] < 0) head[ibin] = i;
|
||||
@ -597,7 +597,7 @@ int compare_coords(const void *iptr, const void *jptr)
|
||||
{
|
||||
int i = *((int *) iptr);
|
||||
int j = *((int *) jptr);
|
||||
ResetIDs::AtomRvous *rvous = ResetIDs::sortrvous;
|
||||
ResetAtomsID::AtomRvous *rvous = ResetAtomsID::sortrvous;
|
||||
double *xi = rvous[i].x;
|
||||
double *xj = rvous[j].x;
|
||||
if (xi[0] < xj[0]) return -1;
|
||||
@ -618,7 +618,7 @@ int compare_coords(const void *iptr, const void *jptr)
|
||||
|
||||
int compare_coords(const int i, const int j, void *ptr)
|
||||
{
|
||||
auto rvous = (ResetIDs::AtomRvous *) ptr;
|
||||
auto rvous = (ResetAtomsID::AtomRvous *) ptr;
|
||||
double *xi = rvous[i].x;
|
||||
double *xj = rvous[j].x;
|
||||
if (xi[0] < xj[0]) return -1;
|
||||
@ -13,18 +13,18 @@
|
||||
|
||||
#ifdef COMMAND_CLASS
|
||||
// clang-format off
|
||||
CommandStyle(RESET_ATOM_IDS,ResetIDs);
|
||||
CommandStyle(RESET_ATOMS_ID,ResetAtomsID);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_RESET_IDS_H
|
||||
#define LMP_RESET_IDS_H
|
||||
#ifndef LMP_RESET_ATOMS_ID_H
|
||||
#define LMP_RESET_ATOMS_ID_H
|
||||
|
||||
#include "command.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ResetIDs : public Command {
|
||||
class ResetAtomsID : public Command {
|
||||
public:
|
||||
struct AtomRvous {
|
||||
bigint ibin;
|
||||
@ -42,7 +42,7 @@ class ResetIDs : public Command {
|
||||
static AtomRvous *sortrvous;
|
||||
#endif
|
||||
|
||||
ResetIDs(class LAMMPS *);
|
||||
ResetAtomsID(class LAMMPS *);
|
||||
void command(int, char **) override;
|
||||
|
||||
private:
|
||||
@ -54,8 +54,6 @@ class ResetIDs : public Command {
|
||||
|
||||
void sort();
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -11,7 +11,7 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "reset_image_flags.h"
|
||||
#include "reset_atoms_image.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
@ -31,27 +31,27 @@ using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ResetImageFlags::ResetImageFlags(LAMMPS *lmp) : Command(lmp) {}
|
||||
ResetAtomsImage::ResetAtomsImage(LAMMPS *lmp) : Command(lmp) {}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
called as reset_image_flags command in input script
|
||||
called as reset_atoms image command in input script
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ResetImageFlags::command(int narg, char **arg)
|
||||
void ResetAtomsImage::command(int narg, char **arg)
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR, "Reset image_flags command before simulation box is defined");
|
||||
error->all(FLERR, "Reset_atoms image command before simulation box is defined");
|
||||
if (atom->tag_enable == 0)
|
||||
error->all(FLERR, "Cannot use reset image_flags unless atoms have IDs");
|
||||
error->all(FLERR, "Cannot use reset_atoms image unless atoms have IDs");
|
||||
if (atom->avec->bonds_allow == 0)
|
||||
error->all(FLERR, "Cannot use reset image_flags used when bonds are not allowed");
|
||||
error->all(FLERR, "Cannot use reset_atoms image used when bonds are not allowed");
|
||||
|
||||
// process args
|
||||
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "reset image_flags", error);
|
||||
if (narg > 1) error->all(FLERR, "Unknown reset image_flags keyword: {}", arg[1]);
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "reset_atoms image", error);
|
||||
if (narg > 1) error->all(FLERR, "Unknown reset_atoms image keyword: {}", arg[1]);
|
||||
int igroup = group->find(arg[0]);
|
||||
if (igroup < 0) error->all(FLERR, "Could not find reset image_flags group {}", arg[0]);
|
||||
if (igroup < 0) error->all(FLERR, "Could not find reset_atoms image group {}", arg[0]);
|
||||
int groupbit = group->bitmask[igroup];
|
||||
|
||||
if (comm->me == 0) utils::logmesg(lmp, "Resetting image flags ...\n");
|
||||
@ -137,5 +137,5 @@ void ResetImageFlags::command(int narg, char **arg)
|
||||
|
||||
MPI_Barrier(world);
|
||||
if (comm->me == 0)
|
||||
utils::logmesg(lmp, " reset image_flags CPU = {:.3f} seconds\n", platform::walltime() - time1);
|
||||
utils::logmesg(lmp, " reset_atoms image CPU = {:.3f} seconds\n", platform::walltime() - time1);
|
||||
}
|
||||
@ -13,24 +13,22 @@
|
||||
|
||||
#ifdef COMMAND_CLASS
|
||||
// clang-format off
|
||||
CommandStyle(RESET_IMAGE_FLAGS,ResetImageFlags);
|
||||
CommandStyle(RESET_ATOMS_IMAGE,ResetAtomsImage);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_RESET_IMAGE_FLAGS_H
|
||||
#define LMP_RESET_IMAGE_FLAGS_H
|
||||
#ifndef LMP_RESET_ATOMS_IMAGE_H
|
||||
#define LMP_RESET_ATOMS_IMAGE_H
|
||||
|
||||
#include "command.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ResetImageFlags : public Command {
|
||||
class ResetAtomsImage : public Command {
|
||||
public:
|
||||
ResetImageFlags(class LAMMPS *);
|
||||
ResetAtomsImage(class LAMMPS *);
|
||||
void command(int, char **) override;
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -15,7 +15,7 @@
|
||||
Contributing author: Jacob Gissinger (jacob.gissinger@colorado.edu)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "reset_mol_ids.h"
|
||||
#include "reset_atoms_mol.h"
|
||||
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
@ -32,7 +32,7 @@ using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ResetMolIDs::ResetMolIDs(LAMMPS *lmp) : Command(lmp), cfa(nullptr), cca(nullptr)
|
||||
ResetAtomsMol::ResetAtomsMol(LAMMPS *lmp) : Command(lmp), cfa(nullptr), cca(nullptr)
|
||||
{
|
||||
// default settings
|
||||
|
||||
@ -46,46 +46,46 @@ ResetMolIDs::ResetMolIDs(LAMMPS *lmp) : Command(lmp), cfa(nullptr), cca(nullptr)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ResetMolIDs::~ResetMolIDs()
|
||||
ResetAtomsMol::~ResetAtomsMol()
|
||||
{
|
||||
if (!idfrag.empty()) modify->delete_compute(idfrag);
|
||||
if (compressflag && !idchunk.empty()) modify->delete_compute(idchunk);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
called as reset mol_ids command in input script
|
||||
called as reset_atoms mol command in input script
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ResetMolIDs::command(int narg, char **arg)
|
||||
void ResetAtomsMol::command(int narg, char **arg)
|
||||
{
|
||||
if (domain->box_exist == 0)
|
||||
error->all(FLERR, "Reset mol_ids command before simulation box is defined");
|
||||
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset mol_ids unless atoms have IDs");
|
||||
error->all(FLERR, "Reset_atoms mol command before simulation box is defined");
|
||||
if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms mol unless atoms have IDs");
|
||||
if (atom->molecular != Atom::MOLECULAR)
|
||||
error->all(FLERR, "Can only use reset mol_ids on molecular systems");
|
||||
error->all(FLERR, "Can only use reset_atoms mol on molecular systems");
|
||||
|
||||
// process args
|
||||
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "reset mol_ids", error);
|
||||
if (narg < 1) utils::missing_cmd_args(FLERR, "reset_atoms mol", error);
|
||||
char *groupid = arg[0];
|
||||
|
||||
int iarg = 1;
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "compress") == 0) {
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset mol_ids compress", error);
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms mol compress", error);
|
||||
compressflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg], "single") == 0) {
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset mol_ids single", error);
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms mol single", error);
|
||||
singleflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg], "offset") == 0) {
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset mol_ids offset", error);
|
||||
if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms mol offset", error);
|
||||
offset = utils::tnumeric(FLERR, arg[iarg + 1], true, lmp);
|
||||
if (offset < -1) error->all(FLERR, "Illegal reset mol_ids command");
|
||||
if (offset < -1) error->all(FLERR, "Illegal reset_atoms mol offset: {}", offset);
|
||||
iarg += 2;
|
||||
} else
|
||||
error->all(FLERR, "Unknown reset mol_ids keyword: {}", arg[iarg]);
|
||||
error->all(FLERR, "Unknown reset_atoms mol keyword: {}", arg[iarg]);
|
||||
}
|
||||
|
||||
if (comm->me == 0) utils::logmesg(lmp, "Resetting molecule IDs ...\n");
|
||||
@ -128,30 +128,30 @@ void ResetMolIDs::command(int narg, char **arg)
|
||||
utils::logmesg(lmp, " number of new molecule IDs = unknown\n");
|
||||
else
|
||||
utils::logmesg(lmp, " number of new molecule IDs = {}\n", nchunk);
|
||||
utils::logmesg(lmp, " reset mol_ids CPU = {:.3f} seconds\n", platform::walltime() - time1);
|
||||
utils::logmesg(lmp, " reset_atoms mol CPU = {:.3f} seconds\n", platform::walltime() - time1);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
create computes used by reset_mol_ids
|
||||
create computes used by reset_atoms_mol
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ResetMolIDs::create_computes(char *fixid, char *groupid)
|
||||
void ResetAtomsMol::create_computes(char *fixid, char *groupid)
|
||||
{
|
||||
int igroup = group->find(groupid);
|
||||
if (igroup < 0) error->all(FLERR, "Could not find reset mol_ids group {}", groupid);
|
||||
if (igroup < 0) error->all(FLERR, "Could not find reset_atoms mol group {}", groupid);
|
||||
groupbit = group->bitmask[igroup];
|
||||
|
||||
// create instances of compute fragment/atom, compute reduce (if needed),
|
||||
// and compute chunk/atom. all use the group-ID for this command.
|
||||
// 'fixid' allows for creating independent instances of the computes
|
||||
|
||||
idfrag = fmt::format("{}_reset_mol_ids_FRAGMENT_ATOM", fixid);
|
||||
idfrag = fmt::format("{}_reset_atoms_mol_FRAGMENT_ATOM", fixid);
|
||||
auto use_single = singleflag ? "yes" : "no";
|
||||
cfa = dynamic_cast<ComputeFragmentAtom *>(modify->add_compute(
|
||||
fmt::format("{} {} fragment/atom single {}", idfrag, groupid, use_single)));
|
||||
|
||||
idchunk = fmt::format("{}_reset_mol_ids_CHUNK_ATOM", fixid);
|
||||
idchunk = fmt::format("{}_reset_atoms_mol_CHUNK_ATOM", fixid);
|
||||
if (compressflag)
|
||||
cca = dynamic_cast<ComputeChunkAtom *>(modify->add_compute(
|
||||
fmt::format("{} {} chunk/atom molecule compress yes", idchunk, groupid)));
|
||||
@ -161,7 +161,7 @@ void ResetMolIDs::create_computes(char *fixid, char *groupid)
|
||||
called from command() and directly from fixes that update molecules
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void ResetMolIDs::reset()
|
||||
void ResetAtomsMol::reset()
|
||||
{
|
||||
// invoke peratom method of compute fragment/atom
|
||||
// walks bond connectivity and assigns each atom a fragment ID
|
||||
@ -13,21 +13,21 @@
|
||||
|
||||
#ifdef COMMAND_CLASS
|
||||
// clang-format off
|
||||
CommandStyle(RESET_MOL_IDS,ResetMolIDs);
|
||||
CommandStyle(RESET_ATOMS_MOL,ResetAtomsMol);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_RESET_MOL_IDS_H
|
||||
#define LMP_RESET_MOL_IDS_H
|
||||
#ifndef LMP_RESET_ATOMS_MOL_H
|
||||
#define LMP_RESET_ATOMS_MOL_H
|
||||
|
||||
#include "command.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class ResetMolIDs : public Command {
|
||||
class ResetAtomsMol : public Command {
|
||||
public:
|
||||
ResetMolIDs(class LAMMPS *);
|
||||
~ResetMolIDs() override;
|
||||
ResetAtomsMol(class LAMMPS *);
|
||||
~ResetAtomsMol() override;
|
||||
void command(int, char **) override;
|
||||
void create_computes(char *, char *);
|
||||
void reset();
|
||||
@ -43,7 +43,6 @@ class ResetMolIDs : public Command {
|
||||
class ComputeFragmentAtom *cfa;
|
||||
class ComputeChunkAtom *cca;
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
#endif
|
||||
@ -53,10 +53,10 @@ endif()
|
||||
target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME KimCommands COMMAND test_kim_commands)
|
||||
|
||||
add_executable(test_reset_ids test_reset_ids.cpp)
|
||||
target_compile_definitions(test_reset_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME ResetIDs COMMAND test_reset_ids)
|
||||
add_executable(test_reset_atoms test_reset_atoms.cpp)
|
||||
target_compile_definitions(test_reset_atoms PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(test_reset_atoms PRIVATE lammps GTest::GMock)
|
||||
add_test(NAME ResetAtoms COMMAND test_reset_atoms)
|
||||
|
||||
if(PKG_MOLECULE)
|
||||
add_executable(test_compute_global test_compute_global.cpp)
|
||||
|
||||
@ -37,11 +37,11 @@ namespace LAMMPS_NS {
|
||||
#define STRINGIFY(val) XSTR(val)
|
||||
#define XSTR(val) #val
|
||||
|
||||
class ResetAtomIDsTest : public LAMMPSTest {
|
||||
class ResetAtomsIDTest : public LAMMPSTest {
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
testbinary = "ResetAtomIDsTest";
|
||||
testbinary = "ResetAtomsIDTest";
|
||||
LAMMPSTest::SetUp();
|
||||
if (info->has_style("atom", "full")) {
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
@ -52,7 +52,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ResetAtomIDsTest, MolIDAll)
|
||||
TEST_F(ResetAtomsIDTest, MolIDAll)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
@ -90,7 +90,7 @@ TEST_F(ResetAtomIDsTest, MolIDAll)
|
||||
// the original data file has two different molecule IDs
|
||||
// for two residues of the same molecule/fragment.
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset mol_ids all");
|
||||
command("reset_atoms mol all");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(1)], 1);
|
||||
@ -124,7 +124,7 @@ TEST_F(ResetAtomIDsTest, MolIDAll)
|
||||
ASSERT_EQ(molid[GETIDX(29)], 5);
|
||||
}
|
||||
|
||||
TEST_F(ResetAtomIDsTest, DeletePlusAtomID)
|
||||
TEST_F(ResetAtomsIDTest, DeletePlusAtomID)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
@ -135,7 +135,7 @@ TEST_F(ResetAtomIDsTest, DeletePlusAtomID)
|
||||
command("group allwater molecule 3:6");
|
||||
command("group twowater molecule 4:6:2");
|
||||
command("delete_atoms group twowater compress no bond yes");
|
||||
command("reset mol_ids all");
|
||||
command("reset_atoms mol all");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->atom->natoms, 23);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 26);
|
||||
@ -194,7 +194,7 @@ TEST_F(ResetAtomIDsTest, DeletePlusAtomID)
|
||||
ASSERT_GE(GETIDX(26), 0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset atom_ids");
|
||||
command("reset_atoms id");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 23);
|
||||
@ -202,7 +202,7 @@ TEST_F(ResetAtomIDsTest, DeletePlusAtomID)
|
||||
ASSERT_GE(GETIDX(i), 0);
|
||||
}
|
||||
|
||||
TEST_F(ResetAtomIDsTest, PartialOffset)
|
||||
TEST_F(ResetAtomsIDTest, PartialOffset)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
@ -212,7 +212,7 @@ TEST_F(ResetAtomIDsTest, PartialOffset)
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("group allwater molecule 3:6");
|
||||
command("group nowater subtract all allwater");
|
||||
command("reset mol_ids allwater offset 4");
|
||||
command("reset_atoms mol allwater offset 4");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->atom->natoms, 29);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 29);
|
||||
@ -248,7 +248,7 @@ TEST_F(ResetAtomIDsTest, PartialOffset)
|
||||
ASSERT_EQ(molid[GETIDX(29)], 8);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset mol_ids nowater offset 0");
|
||||
command("reset_atoms mol nowater offset 0");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(1)], 1);
|
||||
@ -282,7 +282,7 @@ TEST_F(ResetAtomIDsTest, PartialOffset)
|
||||
ASSERT_EQ(molid[GETIDX(29)], 8);
|
||||
}
|
||||
|
||||
TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
TEST_F(ResetAtomsIDTest, DeleteAdd)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
@ -294,7 +294,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
command("group twowater molecule 4:6:2");
|
||||
command("group nowater subtract all allwater");
|
||||
command("delete_atoms group twowater compress no bond yes mol yes");
|
||||
command("reset mol_ids allwater");
|
||||
command("reset_atoms mol allwater");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->atom->natoms, 23);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 26);
|
||||
@ -353,7 +353,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
ASSERT_GE(GETIDX(26), 0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset atom_ids sort yes");
|
||||
command("reset_atoms id sort yes");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 23);
|
||||
@ -361,7 +361,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
ASSERT_GE(GETIDX(i), 0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset mol_ids nowater offset 1");
|
||||
command("reset_atoms mol nowater offset 1");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(1)], 2);
|
||||
@ -393,7 +393,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
command("create_atoms 2 single 1.0 0.0 0.0");
|
||||
command("create_atoms 3 single 2.0 0.0 0.0");
|
||||
command("create_atoms 4 single 3.0 0.0 0.0");
|
||||
command("reset mol_ids all single yes");
|
||||
command("reset_atoms mol all single yes");
|
||||
END_HIDE_OUTPUT();
|
||||
ASSERT_EQ(lmp->atom->natoms, 27);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 27);
|
||||
@ -407,7 +407,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
ASSERT_EQ(molid[GETIDX(27)], 7);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset mol_ids all single no");
|
||||
command("reset_atoms mol all single no");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(21)], 3);
|
||||
@ -419,7 +419,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
ASSERT_EQ(molid[GETIDX(27)], 0);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset mol_ids all compress no single yes");
|
||||
command("reset_atoms mol all compress no single yes");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
ASSERT_EQ(molid[GETIDX(21)], 21);
|
||||
@ -431,7 +431,7 @@ TEST_F(ResetAtomIDsTest, DeleteAdd)
|
||||
ASSERT_EQ(molid[GETIDX(27)], 27);
|
||||
}
|
||||
|
||||
TEST_F(ResetAtomIDsTest, TopologyData)
|
||||
TEST_F(ResetAtomsIDTest, TopologyData)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
@ -526,7 +526,7 @@ TEST_F(ResetAtomIDsTest, TopologyData)
|
||||
ASSERT_EQ(angle_atom3[GETIDX(24)][0], 26);
|
||||
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("reset atom_ids sort yes");
|
||||
command("reset_atoms id sort yes");
|
||||
END_HIDE_OUTPUT();
|
||||
|
||||
num_bond = lmp->atom->num_bond;
|
||||
@ -619,82 +619,85 @@ TEST_F(ResetAtomIDsTest, TopologyData)
|
||||
ASSERT_EQ(angle_atom3[GETIDX(22)][0], 23);
|
||||
}
|
||||
|
||||
TEST_F(ResetAtomIDsTest, DeathTests)
|
||||
TEST_F(ResetAtomsIDTest, DeathTests)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal reset mol_ids command.*", command("reset mol_ids"););
|
||||
TEST_FAILURE(".*ERROR: Unknown reset mol_ids keyword: 1.*",
|
||||
command("reset mol_ids all offset 1 1"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset mol_ids command.*",
|
||||
command("reset mol_ids all offset -2"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*", command("reset mol_ids all offset xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_atoms mol command.*", command("reset_atoms mol"););
|
||||
TEST_FAILURE(".*ERROR: Unknown reset_atoms mol keyword: 1.*",
|
||||
command("reset_atoms mol all offset 1 1"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_atoms mol offset: -2.*",
|
||||
command("reset_atoms mol all offset -2"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
|
||||
command("reset mol_ids all compress yes single no offset xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset mol_ids offset command: missing argument.*",
|
||||
command("reset mol_ids all offset"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset mol_ids compress command: missing argument.*",
|
||||
command("reset mol_ids all compress"););
|
||||
command("reset_atoms mol all offset xxx"););
|
||||
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
|
||||
command("reset_atoms mol all compress yes single no offset xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_atoms mol offset command: missing argument.*",
|
||||
command("reset_atoms mol all offset"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_atoms mol compress command: missing argument.*",
|
||||
command("reset_atoms mol all compress"););
|
||||
|
||||
TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*",
|
||||
command("reset mol_ids all compress xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset mol_ids single command: missing argument.*",
|
||||
command("reset mol_ids all single"););
|
||||
command("reset_atoms mol all compress xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_atoms mol single command: missing argument.*",
|
||||
command("reset_atoms mol all single"););
|
||||
TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*",
|
||||
command("reset mol_ids all single xxx"););
|
||||
command("reset_atoms mol all single xxx"););
|
||||
|
||||
TEST_FAILURE(".*ERROR: Illegal reset image_flags command: missing argument.*",
|
||||
command("reset image_flags"););
|
||||
TEST_FAILURE(".*ERROR: Unknown reset image_flags keyword: xxx.*",
|
||||
command("reset image_flags all xxx"););
|
||||
TEST_FAILURE(".*ERROR: Could not find reset image_flags group xxx.*",
|
||||
command("reset image_flags xxx"););
|
||||
TEST_FAILURE(".*ERROR: Illegal reset_atoms image command: missing argument.*",
|
||||
command("reset_atoms image"););
|
||||
TEST_FAILURE(".*ERROR: Unknown reset_atoms image keyword: xxx.*",
|
||||
command("reset_atoms image all xxx"););
|
||||
TEST_FAILURE(".*ERROR: Could not find reset_atoms image group xxx.*",
|
||||
command("reset_atoms image xxx"););
|
||||
}
|
||||
|
||||
class ResetMolIDsTest : public LAMMPSTest {
|
||||
class ResetAtomsMolTest : public LAMMPSTest {
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
testbinary = "ResetAtomIDsTest";
|
||||
testbinary = "ResetAtomsMolTest";
|
||||
LAMMPSTest::SetUp();
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ResetMolIDsTest, FailBeforeBox)
|
||||
TEST_F(ResetAtomsMolTest, FailBeforeBox)
|
||||
{
|
||||
TEST_FAILURE(".*ERROR: Reset mol_ids command before simulation box is.*",
|
||||
command("reset mol_ids all"););
|
||||
TEST_FAILURE(".*ERROR: Reset image_flags command before simulation box is.*",
|
||||
command("reset image_flags all"););
|
||||
TEST_FAILURE(".*ERROR: Reset_atoms id command before simulation box is.*",
|
||||
command("reset_atoms id"););
|
||||
TEST_FAILURE(".*ERROR: Reset_atoms mol command before simulation box is.*",
|
||||
command("reset_atoms mol all"););
|
||||
TEST_FAILURE(".*ERROR: Reset_atoms image command before simulation box is.*",
|
||||
command("reset_atoms image all"););
|
||||
}
|
||||
|
||||
TEST_F(ResetMolIDsTest, FailMissingId)
|
||||
TEST_F(ResetAtomsMolTest, FailMissingId)
|
||||
{
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("atom_modify id no");
|
||||
command("region box block 0 1 0 1 0 1");
|
||||
command("create_box 1 box");
|
||||
END_HIDE_OUTPUT();
|
||||
TEST_FAILURE(".*ERROR: Cannot use reset mol_ids unless.*", command("reset mol_ids all"););
|
||||
TEST_FAILURE(".*ERROR: Cannot use reset image_flags unless.*",
|
||||
command("reset image_flags all"););
|
||||
TEST_FAILURE(".*ERROR: Cannot use reset_atoms mol unless.*", command("reset_atoms mol all"););
|
||||
TEST_FAILURE(".*ERROR: Cannot use reset_atoms image unless.*",
|
||||
command("reset_atoms image all"););
|
||||
}
|
||||
|
||||
TEST_F(ResetMolIDsTest, FailOnlyMolecular)
|
||||
TEST_F(ResetAtomsMolTest, FailOnlyMolecular)
|
||||
{
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("clear");
|
||||
command("region box block 0 1 0 1 0 1");
|
||||
command("create_box 1 box");
|
||||
END_HIDE_OUTPUT();
|
||||
TEST_FAILURE(".*ERROR: Can only use reset mol_ids.*", command("reset mol_ids all"););
|
||||
TEST_FAILURE(".*ERROR: Can only use reset_atoms mol.*", command("reset_atoms mol all"););
|
||||
}
|
||||
|
||||
class ResetImageFlagsTest : public LAMMPSTest {
|
||||
class ResetAtomsImageTest : public LAMMPSTest {
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
testbinary = "ResetAtomIDsTest";
|
||||
testbinary = "ResetAtomsImageTest";
|
||||
LAMMPSTest::SetUp();
|
||||
if (info->has_style("atom", "full")) {
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
@ -722,7 +725,7 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(ResetImageFlagsTest, ResetImageFlags)
|
||||
TEST_F(ResetAtomsImageTest, ResetAtomsImage)
|
||||
{
|
||||
if (lmp->atom->natoms == 0) GTEST_SKIP();
|
||||
EXPECT_EQ(lmp->atom->image[GETIDX(1)], lammps_encode_image_flags(1, 1, -1));
|
||||
@ -759,7 +762,7 @@ TEST_F(ResetImageFlagsTest, ResetImageFlags)
|
||||
EXPECT_EQ(lmp->atom->image[GETIDX(32)], lammps_encode_image_flags(0, 20, 0));
|
||||
BEGIN_HIDE_OUTPUT();
|
||||
command("group subset id 5:32");
|
||||
command("reset image_flags subset");
|
||||
command("reset_atoms image subset");
|
||||
END_HIDE_OUTPUT();
|
||||
EXPECT_EQ(lmp->atom->image[GETIDX(1)], lammps_encode_image_flags(1, 1, -1));
|
||||
EXPECT_EQ(lmp->atom->image[GETIDX(2)], lammps_encode_image_flags(1, 1, -1));
|
||||
Reference in New Issue
Block a user