Unverified Commit 91502b8b authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

more simplification

parent 41d62b8b
Loading
Loading
Loading
Loading
+8 −19
Original line number Diff line number Diff line
@@ -489,32 +489,21 @@ void Balance::options(int iarg, int narg, char **arg)

void Balance::weight_storage(char *prefix)
{
  char *fixargs[6];

  if (prefix) {
    int n = strlen(prefix) + 32;
    fixargs[0] = new char[n];
    strcpy(fixargs[0],prefix);
    strcat(fixargs[0],"IMBALANCE_WEIGHTS");
  } else fixargs[0] = (char *) "IMBALANCE_WEIGHTS";

  fixargs[1] = (char *) "all";
  fixargs[2] = (char *) "STORE";
  fixargs[3] = (char *) "peratom";
  fixargs[4] = (char *) "0";
  fixargs[5] = (char *) "1";

  int ifix = modify->find_fix(fixargs[0]);
  std::string cmd = "";

  if (prefix) cmd = prefix;
  cmd += "IMBALANCE_WEIGHTS";

  int ifix = modify->find_fix(cmd.c_str());
  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];
  } else fixstore = (FixStore *) modify->fix[ifix];

  // do not carry weights with atoms during normal atom migration

  fixstore->disable = 1;

  if (prefix) delete [] fixargs[0];
}

/* ----------------------------------------------------------------------
+9 −17
Original line number Diff line number Diff line
@@ -5073,24 +5073,16 @@ VarReader::VarReader(LAMMPS *lmp, char *name, char *file, int flag) :

  if (style == ATOMFILE) {
    if (atom->map_style == 0)
      error->all(FLERR,
                 "Cannot use atomfile-style variable unless atom map exists");

    int n = strlen(name) + strlen("_VARIABLE_STORE") + 1;
    id_fix = new char[n];
    strcpy(id_fix,name);
    strcat(id_fix,"_VARIABLE_STORE");

    char **newarg = new char*[6];
    newarg[0] = id_fix;
    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);
      error->all(FLERR,"Cannot use atomfile-style "
                 "variable unless an atom map exists");

    std::string cmd = name + std::string("_VARIABLE_STORE");
    id_fix = new char[cmd.size()+1];
    strcpy(id_fix,cmd.c_str());

    cmd += " all STORE peratom 0 1";
    modify->add_fix(cmd);
    fixstore = (FixStore *) modify->fix[modify->nfix-1];
    delete [] newarg;

    buffer = new char[CHUNK*MAXLINE];
  }