more simplification

This commit is contained in:
Axel Kohlmeyer
2020-06-26 16:22:19 -04:00
parent 41d62b8b8b
commit 91502b8bf6
2 changed files with 13 additions and 32 deletions

View File

@ -489,32 +489,21 @@ void Balance::options(int iarg, int narg, char **arg)
void Balance::weight_storage(char *prefix) void Balance::weight_storage(char *prefix)
{ {
char *fixargs[6]; std::string cmd = "";
if (prefix) { if (prefix) cmd = prefix;
int n = strlen(prefix) + 32; cmd += "IMBALANCE_WEIGHTS";
fixargs[0] = new char[n];
strcpy(fixargs[0],prefix);
strcat(fixargs[0],"IMBALANCE_WEIGHTS");
} else fixargs[0] = (char *) "IMBALANCE_WEIGHTS";
fixargs[1] = (char *) "all"; int ifix = modify->find_fix(cmd.c_str());
fixargs[2] = (char *) "STORE";
fixargs[3] = (char *) "peratom";
fixargs[4] = (char *) "0";
fixargs[5] = (char *) "1";
int ifix = modify->find_fix(fixargs[0]);
if (ifix < 1) { if (ifix < 1) {
modify->add_fix(6,fixargs); cmd += " all STORE peratom 0 1";
modify->add_fix(cmd);
fixstore = (FixStore *) modify->fix[modify->nfix-1]; fixstore = (FixStore *) modify->fix[modify->nfix-1];
} else fixstore = (FixStore *) modify->fix[ifix]; } else fixstore = (FixStore *) modify->fix[ifix];
// do not carry weights with atoms during normal atom migration // do not carry weights with atoms during normal atom migration
fixstore->disable = 1; fixstore->disable = 1;
if (prefix) delete [] fixargs[0];
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------

View File

@ -5073,24 +5073,16 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) :
if (style == ATOMFILE) { if (style == ATOMFILE) {
if (atom->map_style == 0) if (atom->map_style == 0)
error->all(FLERR, error->all(FLERR,"Cannot use atomfile-style "
"Cannot use atomfile-style variable unless atom map exists"); "variable unless an atom map exists");
int n = strlen(name) + strlen("_VARIABLE_STORE") + 1; std::string cmd = name + std::string("_VARIABLE_STORE");
id_fix = new char[n]; id_fix = new char[cmd.size()+1];
strcpy(id_fix,name); strcpy(id_fix,cmd.c_str());
strcat(id_fix,"_VARIABLE_STORE");
char **newarg = new char*[6]; cmd += " all STORE peratom 0 1";
newarg[0] = id_fix; modify->add_fix(cmd);
newarg[1] = (char *) "all";
newarg[2] = (char *) "STORE";
newarg[3] = (char *) "peratom";
newarg[4] = (char *) "0";
newarg[5] = (char *) "1";
modify->add_fix(6,newarg);
fixstore = (FixStore *) modify->fix[modify->nfix-1]; fixstore = (FixStore *) modify->fix[modify->nfix-1];
delete [] newarg;
buffer = new char[CHUNK*MAXLINE]; buffer = new char[CHUNK*MAXLINE];
} }