add group::assign convenience version
This commit is contained in:
@ -547,6 +547,22 @@ void Group::assign(int narg, char **arg)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convenience function to allow assigning to groups from a single string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::assign(const std::string &fixcmd)
|
||||
{
|
||||
std::vector<std::string> args = utils::split_words(fixcmd);
|
||||
char **newarg = new char*[args.size()];
|
||||
int i=0;
|
||||
for (const auto &arg : args) {
|
||||
newarg[i++] = (char *)arg.c_str();
|
||||
}
|
||||
assign(args.size(),newarg);
|
||||
delete[] newarg;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
add flagged atoms to a new or existing group
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
@ -30,6 +30,7 @@ class Group : protected Pointers {
|
||||
Group(class LAMMPS *);
|
||||
~Group();
|
||||
void assign(int, char **); // assign atoms to a group
|
||||
void assign(const std::string &); // convenience function
|
||||
void create(char *, int *); // add flagged atoms to a group
|
||||
int find(const char *); // lookup name in list of groups
|
||||
int find_or_create(const char *); // lookup name or create new group
|
||||
|
||||
Reference in New Issue
Block a user