diff --git a/src/group.cpp b/src/group.cpp index a586c33ed9..b438e8fede 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -623,6 +623,21 @@ int Group::find_unused() return -1; } +/* ---------------------------------------------------------------------- + return group bitmask for given group id. Error out if group is not found. +------------------------------------------------------------------------- */ + +int Group::get_bitmask_by_id(const std::string &file, int line, const std::string &name, + const std::string &caller) +{ + int igroup = 0; + while (igroup < MAX_GROUP) + if (names[igroup] && (name == names[igroup])) break; + if (igroup == MAX_GROUP) + error->all(file, line, "Group ID {} requested by {} does not exist", name, caller); + return bitmask[igroup]; +} + /* ---------------------------------------------------------------------- add atoms to group that are in same molecules as atoms already in group do not include molID = 0 diff --git a/src/group.h b/src/group.h index 0820c7d4b2..728b0a1d02 100644 --- a/src/group.h +++ b/src/group.h @@ -31,11 +31,13 @@ class Group : protected Pointers { Group(class LAMMPS *); ~Group() override; + void assign(int, char **); // assign atoms to a group void assign(const std::string &); // convenience function void create(const std::string &, int *); // add flagged atoms to a group int find(const std::string &); // lookup name in list of groups int find_or_create(const char *); // lookup name or create new group + int get_bitmask_by_id(const std::string &, int, const std::string &, const std::string &); void write_restart(FILE *); void read_restart(FILE *);