Commit 816fa934 authored by sjplimp's avatar sjplimp Committed by GitHub
Browse files

Merge pull request #499 from akohlmey/add-fix-compute-style-bugfix

Fix bug where fix/compute style names were not correctly set with suffixes
parents f4f975ed 99a68e48
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -424,7 +424,7 @@ void PairGranHookeHistory::init_style()
    fixarg[1] = (char *) "all";
    fixarg[2] = (char *) "SHEAR_HISTORY";
    fixarg[3] = dnumstr;
    modify->add_fix(4,fixarg,1);
    modify->add_fix(4,fixarg);
    delete [] fixarg;
    fix_history = (FixShearHistory *) modify->fix[modify->nfix-1];
    fix_history->pair = this;
+2 −2
Original line number Diff line number Diff line
@@ -1478,7 +1478,7 @@ void Input::comm_style()

void Input::compute()
{
  modify->add_compute(narg,arg,1);
  modify->add_compute(narg,arg);
}

/* ---------------------------------------------------------------------- */
@@ -1556,7 +1556,7 @@ void Input::dump_modify()

void Input::fix()
{
  modify->add_fix(narg,arg,1);
  modify->add_fix(narg,arg);
}

/* ---------------------------------------------------------------------- */
+20 −8
Original line number Diff line number Diff line
@@ -819,20 +819,26 @@ void Modify::add_fix(int narg, char **arg, int trysuffix)

  if (trysuffix && lmp->suffix_enable) {
    if (lmp->suffix) {
      char estyle[256];
      int n = strlen(arg[2])+strlen(lmp->suffix)+2;
      char *estyle = new char[n];
      sprintf(estyle,"%s/%s",arg[2],lmp->suffix);
      if (fix_map->find(estyle) != fix_map->end()) {
        FixCreator fix_creator = (*fix_map)[estyle];
        fix[ifix] = fix_creator(lmp,narg,arg);
      }
        delete[] fix[ifix]->style;
        fix[ifix]->style = estyle;
      } else delete[] estyle;
    }
    if (fix[ifix] == NULL && lmp->suffix2) {
      char estyle[256];
      int n = strlen(arg[2])+strlen(lmp->suffix2)+2;
      char *estyle = new char[n];
      sprintf(estyle,"%s/%s",arg[2],lmp->suffix2);
      if (fix_map->find(estyle) != fix_map->end()) {
        FixCreator fix_creator = (*fix_map)[estyle];
        fix[ifix] = fix_creator(lmp,narg,arg);
      }
        delete[] fix[ifix]->style;
        fix[ifix]->style = estyle;
      } else delete[] estyle;
    }
  }

@@ -1018,20 +1024,26 @@ void Modify::add_compute(int narg, char **arg, int trysuffix)

  if (trysuffix && lmp->suffix_enable) {
    if (lmp->suffix) {
      char estyle[256];
      int n = strlen(arg[2])+strlen(lmp->suffix)+2;
      char *estyle = new char[n];
      sprintf(estyle,"%s/%s",arg[2],lmp->suffix);
      if (compute_map->find(estyle) != compute_map->end()) {
        ComputeCreator compute_creator = (*compute_map)[estyle];
        compute[ncompute] = compute_creator(lmp,narg,arg);
      }
        delete[] compute[ncompute]->style;
        compute[ncompute]->style = estyle;
      } else delete[] estyle;
    }
    if (compute[ncompute] == NULL && lmp->suffix2) {
      char estyle[256];
      int n = strlen(arg[2])+strlen(lmp->suffix2)+2;
      char *estyle = new char[n];
      sprintf(estyle,"%s/%s",arg[2],lmp->suffix2);
      if (compute_map->find(estyle) != compute_map->end()) {
        ComputeCreator compute_creator = (*compute_map)[estyle];
        compute[ncompute] = compute_creator(lmp,narg,arg);
      }
        delete[] compute[ncompute]->style;
        compute[ncompute]->style = estyle;
      } else delete[] estyle;
    }
  }

+2 −2
Original line number Diff line number Diff line
@@ -92,14 +92,14 @@ class Modify : protected Pointers {
  virtual int min_dof();
  virtual int min_reset_ref();

  void add_fix(int, char **, int trysuffix=0);
  void add_fix(int, char **, int trysuffix=1);
  void modify_fix(int, char **);
  void delete_fix(const char *);
  int find_fix(const char *);
  int find_fix_by_style(const char *);
  int check_package(const char *);

  void add_compute(int, char **, int trysuffix=0);
  void add_compute(int, char **, int trysuffix=1);
  void modify_compute(int, char **);
  void delete_compute(const char *);
  int find_compute(const char *);
+3 −3
Original line number Diff line number Diff line
@@ -49,18 +49,18 @@ Output::Output(LAMMPS *lmp) : Pointers(lmp)
  newarg[0] = (char *) "thermo_temp";
  newarg[1] = (char *) "all";
  newarg[2] = (char *) "temp";
  modify->add_compute(3,newarg,1);
  modify->add_compute(3,newarg);

  newarg[0] = (char *) "thermo_press";
  newarg[1] = (char *) "all";
  newarg[2] = (char *) "pressure";
  newarg[3] = (char *) "thermo_temp";
  modify->add_compute(4,newarg,1);
  modify->add_compute(4,newarg);

  newarg[0] = (char *) "thermo_pe";
  newarg[1] = (char *) "all";
  newarg[2] = (char *) "pe";
  modify->add_compute(3,newarg,1);
  modify->add_compute(3,newarg);

  delete [] newarg;