when creating or replacing a fix or compute, return pointer to new instance
This commit is contained in:
@ -803,7 +803,7 @@ int Modify::min_reset_ref()
|
||||
add a new fix or replace one with same ID
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
Fix *Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR,"Illegal fix command");
|
||||
|
||||
@ -956,13 +956,14 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)
|
||||
if (newflag) nfix++;
|
||||
fmask[ifix] = fix[ifix]->setmask();
|
||||
fix[ifix]->post_constructor();
|
||||
return fix[ifix];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convenience function to allow adding a fix from a single string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::add_fix(const std::string &fixcmd, int trysuffix)
|
||||
Fix *Modify::add_fix(const std::string &fixcmd, int trysuffix)
|
||||
{
|
||||
auto args = utils::split_words(fixcmd);
|
||||
std::vector<char *> newarg(args.size());
|
||||
@ -970,7 +971,7 @@ void Modify::add_fix(const std::string &fixcmd, int trysuffix)
|
||||
for (const auto &arg : args) {
|
||||
newarg[i++] = (char *)arg.c_str();
|
||||
}
|
||||
add_fix(args.size(),newarg.data(),trysuffix);
|
||||
return add_fix(args.size(),newarg.data(),trysuffix);
|
||||
}
|
||||
|
||||
|
||||
@ -981,8 +982,7 @@ void Modify::add_fix(const std::string &fixcmd, int trysuffix)
|
||||
replace it later with the desired Fix instance
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::replace_fix(const char *replaceID,
|
||||
int narg, char **arg, int trysuffix)
|
||||
Fix *Modify::replace_fix(const char *replaceID, int narg, char **arg, int trysuffix)
|
||||
{
|
||||
int ifix = find_fix(replaceID);
|
||||
if (ifix < 0) error->all(FLERR,"Modify replace_fix ID {} could not be found", replaceID);
|
||||
@ -1007,15 +1007,14 @@ void Modify::replace_fix(const char *replaceID,
|
||||
// invoke add_fix
|
||||
// it will find and overwrite the replaceID fix
|
||||
|
||||
add_fix(narg,arg,trysuffix);
|
||||
return add_fix(narg,arg,trysuffix);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convenience function to allow replacing a fix from a single string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::replace_fix(const std::string &oldfix,
|
||||
const std::string &fixcmd, int trysuffix)
|
||||
Fix *Modify::replace_fix(const std::string &oldfix, const std::string &fixcmd, int trysuffix)
|
||||
{
|
||||
auto args = utils::split_words(fixcmd);
|
||||
std::vector<char *> newarg(args.size());
|
||||
@ -1023,7 +1022,7 @@ void Modify::replace_fix(const std::string &oldfix,
|
||||
for (const auto &arg : args) {
|
||||
newarg[i++] = (char *)arg.c_str();
|
||||
}
|
||||
replace_fix(oldfix.c_str(),args.size(),newarg.data(),trysuffix);
|
||||
return replace_fix(oldfix.c_str(),args.size(),newarg.data(),trysuffix);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -1213,7 +1212,7 @@ int Modify::check_rigid_list_overlap(int *select)
|
||||
add a new compute
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
Compute *Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
{
|
||||
if (narg < 3) error->all(FLERR,"Illegal compute command");
|
||||
|
||||
@ -1268,14 +1267,14 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)
|
||||
if (compute[ncompute] == nullptr)
|
||||
error->all(FLERR,utils::check_packages_for_style("compute",arg[2],lmp));
|
||||
|
||||
ncompute++;
|
||||
return compute[ncompute++];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
convenience function to allow adding a compute from a single string
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Modify::add_compute(const std::string &computecmd, int trysuffix)
|
||||
Compute *Modify::add_compute(const std::string &computecmd, int trysuffix)
|
||||
{
|
||||
auto args = utils::split_words(computecmd);
|
||||
std::vector<char *>newarg(args.size());
|
||||
@ -1283,7 +1282,7 @@ void Modify::add_compute(const std::string &computecmd, int trysuffix)
|
||||
for (const auto &arg : args) {
|
||||
newarg[i++] = (char *)arg.c_str();
|
||||
}
|
||||
add_compute(args.size(),newarg.data(),trysuffix);
|
||||
return add_compute(args.size(),newarg.data(),trysuffix);
|
||||
}
|
||||
|
||||
|
||||
|
||||
12
src/modify.h
12
src/modify.h
@ -100,18 +100,18 @@ class Modify : protected Pointers {
|
||||
virtual int min_dof();
|
||||
virtual int min_reset_ref();
|
||||
|
||||
void add_fix(int, char **, int trysuffix = 1);
|
||||
void add_fix(const std::string &, int trysuffix = 1);
|
||||
void replace_fix(const char *, int, char **, int trysuffix = 1);
|
||||
void replace_fix(const std::string &, const std::string &, int trysuffix = 1);
|
||||
Fix *add_fix(int, char **, int trysuffix = 1);
|
||||
Fix *add_fix(const std::string &, int trysuffix = 1);
|
||||
Fix *replace_fix(const char *, int, char **, int trysuffix = 1);
|
||||
Fix *replace_fix(const std::string &, const std::string &, int trysuffix = 1);
|
||||
void modify_fix(int, char **);
|
||||
void delete_fix(const std::string &);
|
||||
void delete_fix(int);
|
||||
int find_fix(const std::string &);
|
||||
int find_fix_by_style(const char *);
|
||||
|
||||
void add_compute(int, char **, int trysuffix = 1);
|
||||
void add_compute(const std::string &, int trysuffix = 1);
|
||||
Compute *add_compute(int, char **, int trysuffix = 1);
|
||||
Compute *add_compute(const std::string &, int trysuffix = 1);
|
||||
void modify_compute(int, char **);
|
||||
void delete_compute(const std::string &);
|
||||
void delete_compute(int);
|
||||
|
||||
Reference in New Issue
Block a user