add and use Neighbor::modify_params() convenience function

This commit is contained in:
Axel Kohlmeyer
2021-04-13 14:53:03 -04:00
parent 208d9f1fce
commit 3b2c0871cc
6 changed files with 21 additions and 35 deletions

View File

@ -187,14 +187,7 @@ void FixChargeRegulation::init() {
// neighbor list exclusion setup
// turn off interactions between group all and the exclusion group
int narg = 4;
char **arg = new char*[narg];;
arg[0] = (char *) "exclude";
arg[1] = (char *) "group";
arg[2] = (char *) group_id.c_str();
arg[3] = (char *) "all";
neighbor->modify_params(narg,arg);
delete [] arg;
neighbor->modify_params(fmt::format("exclude group {} all",group_id));
}
// check that no deletable atoms are in atom->firstgroup

View File

@ -580,14 +580,7 @@ void FixGCMC::init()
// neighbor list exclusion setup
// turn off interactions between group all and the exclusion group
int narg = 4;
char **arg = new char*[narg];;
arg[0] = (char *) "exclude";
arg[1] = (char *) "group";
arg[2] = (char *) group_id.c_str();
arg[3] = (char *) "all";
neighbor->modify_params(narg,arg);
delete [] arg;
neighbor->modify_params(fmt::format("exclude group {} all",group_id);
}
// create a new group for temporary use with selected molecules

View File

@ -342,14 +342,7 @@ void FixWidom::init()
// neighbor list exclusion setup
// turn off interactions between group all and the exclusion group
int narg = 4;
char **arg = new char*[narg];;
arg[0] = (char *) "exclude";
arg[1] = (char *) "group";
arg[2] = (char *) group_id.c_str();
arg[3] = (char *) "all";
neighbor->modify_params(narg,arg);
delete [] arg;
neighbor->modify_params(fmt::format("exclude group {} all",group_id));
}
// create a new group for temporary use with selected molecules

View File

@ -128,20 +128,10 @@ void FixSRP::init()
// bond particles do not interact with other types
// type bptype only interacts with itself
char* arg1[4];
arg1[0] = (char *) "exclude";
arg1[1] = (char *) "type";
char c0[20];
char c1[20];
for (int z = 1; z < atom->ntypes; z++) {
if (z == bptype)
continue;
sprintf(c0, "%d", z);
arg1[2] = c0;
sprintf(c1, "%d", bptype);
arg1[3] = c1;
neighbor->modify_params(4, arg1);
neighbor->modify_params(fmt::format("exclude type {} {}",z,bptype));
}
}

View File

@ -2356,6 +2356,22 @@ void Neighbor::modify_params(int narg, char **arg)
}
}
/* ----------------------------------------------------------------------
convenience function to allow modifying parameters from a single string
------------------------------------------------------------------------- */
void Neighbor::modify_params(const std::string &modcmd)
{
auto args = utils::split_words(modcmd);
char **newarg = new char*[args.size()];
int i=0;
for (const auto &arg : args) {
newarg[i++] = (char *)arg.c_str();
}
modify_params(args.size(),newarg);
delete[] newarg;
}
/* ----------------------------------------------------------------------
remove the first group-group exclusion matching group1, group2
------------------------------------------------------------------------- */

View File

@ -118,6 +118,7 @@ class Neighbor : protected Pointers {
void set(int, char **); // set neighbor style and skin distance
void reset_timestep(bigint); // reset of timestep counter
void modify_params(int, char**); // modify params that control builds
void modify_params(const std::string &); // convenience overload
void exclusion_group_group_delete(int, int); // rm a group-group exclusion
int exclude_setting(); // return exclude value to accelerator pkg