Commit 7f05c578 authored by Jacob Gissinger's avatar Jacob Gissinger
Browse files

add group::assign convenience version

parent 77a6c7b7
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -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
   add flagged atoms to a new or existing group
------------------------------------------------------------------------- */
------------------------------------------------------------------------- */
+1 −0
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ class Group : protected Pointers {
  Group(class LAMMPS *);
  Group(class LAMMPS *);
  ~Group();
  ~Group();
  void assign(int, char **);         // assign atoms to a 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
  void create(char *, int *);        // add flagged atoms to a group
  int find(const char *);            // lookup name in list of groups
  int find(const char *);            // lookup name in list of groups
  int find_or_create(const char *);  // lookup name or create new group
  int find_or_create(const char *);  // lookup name or create new group