Unverified Commit 24e48760 authored by Steve Plimpton's avatar Steve Plimpton Committed by GitHub
Browse files

Merge pull request #845 from akohlmey/dummy-pair-restart-warning

More consistent and transparent handling for force styles with restarts
parents b5ee7137 69ca8e55
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -78,6 +78,8 @@ Force::Force(LAMMPS *lmp) : Pointers(lmp)
  kspace_style = new char[n];
  strcpy(kspace_style,str);

  pair_restart = NULL;

  // fill pair map with pair styles listed in style_pair.h

  pair_map = new PairCreatorMap();
@@ -146,6 +148,8 @@ Force::~Force()
  delete [] improper_style;
  delete [] kspace_style;

  delete [] pair_restart;

  if (pair) delete pair;
  if (bond) delete bond;
  if (angle) delete angle;
@@ -174,6 +178,16 @@ void Force::init()
{
  qqrd2e = qqr2e/dielectric;

  // check if pair style must be specified after restart
  if (pair_restart) {
    if (!pair) {
      char msg[128];
      sprintf(msg,"Must re-specify non-restarted pair style (%s) "
              "after read_restart", pair_restart);
      error->all(FLERR,msg);
    }
  }

  if (kspace) kspace->init();         // kspace must come before pair
  if (pair) pair->init();             // so g_ewald is defined
  if (bond) bond->init();
@@ -197,8 +211,10 @@ void Force::create_pair(const char *style, int trysuffix)
{
  delete [] pair_style;
  if (pair) delete pair;
  if (pair_restart) delete [] pair_restart;
  pair_style = NULL;
  pair = NULL;
  pair_restart = NULL;

  int sflag;
  pair = new_pair(style,trysuffix,sflag);
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ class Force : protected Pointers {

  class Pair *pair;
  char *pair_style;
  char *pair_restart;

  class Bond *bond;
  char *bond_style;
+6 −0
Original line number Diff line number Diff line
@@ -692,6 +692,12 @@ void Pair::compute_dummy(int eflag, int vflag)
  else evflag = 0;
}

/* ---------------------------------------------------------------------- */
void Pair::read_restart(FILE *)
{
  error->all(FLERR,"BUG: restartinfo=1 but no restart support in pair style");
}

/* -------------------------------------------------------------------
   register a callback to a compute, so it can compute and accumulate
   additional properties during the pair computation from within
+1 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ class Pair : protected Pointers {
  virtual void free_disp_tables();

  virtual void write_restart(FILE *) {}
  virtual void read_restart(FILE *) {}
  virtual void read_restart(FILE *);
  virtual void write_restart_settings(FILE *) {}
  virtual void read_restart_settings(FILE *) {}
  virtual void write_data(FILE *) {}
+48 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ enum{VERSION,SMALLINT,TAGINT,BIGINT,
     MULTIPROC,MPIIO,PROCSPERFILE,PERPROC,
     IMAGEINT,BOUNDMIN,TIMESTEP,
     ATOM_ID,ATOM_MAP_STYLE,ATOM_MAP_USER,ATOM_SORTFREQ,ATOM_SORTBIN,
     COMM_MODE,COMM_CUTOFF,COMM_VEL};
     COMM_MODE,COMM_CUTOFF,COMM_VEL,NO_PAIR};

#define LB_FACTOR 1.1

@@ -832,6 +832,12 @@ void ReadRestart::header(int incompatible)
      for (int i = 0; i < nargcopy; i++)
        argcopy[i] = read_string();
      atom->create_avec(style,nargcopy,argcopy,1);
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  restoring atom style %s from "
                            "restart\n", style);
        if (logfile) fprintf(logfile,"  restoring atom style %s from "
                             "restart\n", style);
      }
      for (int i = 0; i < nargcopy; i++) delete [] argcopy[i];
      delete [] argcopy;
      delete [] style;
@@ -948,30 +954,71 @@ void ReadRestart::force_fields()
      style = read_string();
      force->create_pair(style,1);
      delete [] style;
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  restoring pair style %s from "
                            "restart\n", force->pair_style);
        if (logfile) fprintf(logfile,"  restoring pair style %s from "
                             "restart\n", force->pair_style);
      }
      force->pair->read_restart(fp);

    } else if (flag == NO_PAIR) {
      style = read_string();
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  pair style %s stores no "
                            "restart info\n", style);
        if (logfile) fprintf(logfile,"  pair style %s stores no "
                             "restart info\n", style);
      }
      force->create_pair("none",0);
      force->pair_restart = style;

    } else if (flag == BOND) {
      style = read_string();
      force->create_bond(style,1);
      delete [] style;
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  restoring bond style %s from "
                            "restart\n", force->bond_style);
        if (logfile) fprintf(logfile,"  restoring bond style %s from "
                             "restart\n", force->bond_style);
      }
      force->bond->read_restart(fp);

    } else if (flag == ANGLE) {
      style = read_string();
      force->create_angle(style,1);
      delete [] style;
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  restoring angle style %s from "
                            "restart\n", force->angle_style);
        if (logfile) fprintf(logfile,"  restoring angle style %s from "
                             "restart\n", force->angle_style);
      }
      force->angle->read_restart(fp);

    } else if (flag == DIHEDRAL) {
      style = read_string();
      force->create_dihedral(style,1);
      delete [] style;
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  restoring dihedral style %s from "
                            "restart\n", force->dihedral_style);
        if (logfile) fprintf(logfile,"  restoring dihedral style %s from "
                             "restart\n", force->dihedral_style);
      }
      force->dihedral->read_restart(fp);

    } else if (flag == IMPROPER) {
      style = read_string();
      force->create_improper(style,1);
      delete [] style;
      if (comm->me ==0) {
        if (screen) fprintf(screen,"  restoring improper style %s from "
                            "restart\n", force->improper_style);
        if (logfile) fprintf(logfile,"  restoring improper style %s from "
                             "restart\n", force->improper_style);
      }
      force->improper->read_restart(fp);

    } else error->all(FLERR,
Loading