diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index 3f0cb6e253..fd0748c92f 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -4237,6 +4237,52 @@ void PairAIREBO::spline_init() for (i = 2; i < 10; i++) Tf[2][2][i] = -0.0040480; } +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairAIREBO::write_restart(FILE *fp) +{ + write_restart_settings(fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairAIREBO::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairAIREBO::write_restart_settings(FILE *fp) +{ + fwrite(&cutlj,sizeof(double),1,fp); + fwrite(&ljflag,sizeof(int),1,fp); + fwrite(&torflag,sizeof(int),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairAIREBO::read_restart_settings(FILE *fp) +{ + if (comm->me == 0) { + fread(&cutlj,sizeof(double),1,fp); + fread(&ljflag,sizeof(int),1,fp); + fread(&torflag,sizeof(int),1,fp); + } + MPI_Bcast(&cutlj,1,MPI_DOUBLE,0,world); + MPI_Bcast(&ljflag,1,MPI_INT,0,world); + MPI_Bcast(&torflag,1,MPI_INT,0,world); +} + /* ---------------------------------------------------------------------- memory usage of local atom-based arrays ------------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_airebo.h b/src/MANYBODY/pair_airebo.h index 166e1ed4ed..050ccb324e 100644 --- a/src/MANYBODY/pair_airebo.h +++ b/src/MANYBODY/pair_airebo.h @@ -33,6 +33,10 @@ class PairAIREBO : public Pair { void coeff(int, char **); void init_style(); double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); double memory_usage(); protected: diff --git a/src/REAX/pair_reax.cpp b/src/REAX/pair_reax.cpp index f32281f5f6..ffc8756a7f 100644 --- a/src/REAX/pair_reax.cpp +++ b/src/REAX/pair_reax.cpp @@ -1050,6 +1050,55 @@ void PairREAX::sparse_product(const int &n, const int &nlocal, } } +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairREAX::write_restart(FILE *fp) +{ + write_restart_settings(fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairREAX::read_restart(FILE *fp) +{ + read_restart_settings(fp); + allocate(); +} + +/* ---------------------------------------------------------------------- + proc 0 writes to restart file +------------------------------------------------------------------------- */ + +void PairREAX::write_restart_settings(FILE *fp) +{ + fwrite(&hbcut,sizeof(double),1,fp); + fwrite(&ihbnew,sizeof(int),1,fp); + fwrite(&itripstaball,sizeof(int),1,fp); + fwrite(&precision,sizeof(double),1,fp); +} + +/* ---------------------------------------------------------------------- + proc 0 reads from restart file, bcasts +------------------------------------------------------------------------- */ + +void PairREAX::read_restart_settings(FILE *fp) +{ + if (comm->me == 0) { + fread(&hbcut,sizeof(double),1,fp); + fread(&ihbnew,sizeof(int),1,fp); + fread(&itripstaball,sizeof(int),1,fp); + fread(&precision,sizeof(double),1,fp); + } + MPI_Bcast(&hbcut,1,MPI_DOUBLE,0,world); + MPI_Bcast(&ihbnew,1,MPI_INT,0,world); + MPI_Bcast(&itripstaball,1,MPI_INT,0,world); + MPI_Bcast(&precision,1,MPI_DOUBLE,0,world); +} + /* ---------------------------------------------------------------------- memory usage of local atom-based arrays ------------------------------------------------------------------------- */ diff --git a/src/REAX/pair_reax.h b/src/REAX/pair_reax.h index a051c97dc0..27d360eb7b 100644 --- a/src/REAX/pair_reax.h +++ b/src/REAX/pair_reax.h @@ -34,6 +34,10 @@ class PairREAX : public Pair { void coeff(int, char **); void init_style(); double init_one(int, int); + void write_restart(FILE *); + void read_restart(FILE *); + void write_restart_settings(FILE *); + void read_restart_settings(FILE *); double memory_usage(); int pack_comm(int, int *, double *, int, int *); diff --git a/src/read_restart.cpp b/src/read_restart.cpp index 0514cea310..8092eff57c 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -307,7 +307,8 @@ void ReadRestart::command(int narg, char **arg) if (logfile) fprintf(logfile," " BIGINT_FORMAT " atoms\n",natoms); } - if (natoms != atom->natoms) error->all(FLERR,"Did not assign all atoms correctly"); + if (natoms != atom->natoms) + error->all(FLERR,"Did not assign all atoms correctly"); if (me == 0) { if (atom->nbonds) { @@ -501,7 +502,8 @@ void ReadRestart::header() int dimension = read_int(); domain->dimension = dimension; if (domain->dimension == 2 && domain->zperiodic == 0) - error->all(FLERR,"Cannot run 2d simulation with nonperiodic Z dimension"); + error->all(FLERR, + "Cannot run 2d simulation with nonperiodic Z dimension"); // read nprocs from restart file, warn if different @@ -531,14 +533,16 @@ void ReadRestart::header() int newton_pair_file = read_int(); if (force->newton_pair != 1) { if (newton_pair_file != force->newton_pair && me == 0) - error->warning(FLERR,"Restart file used different newton pair setting, " + error->warning(FLERR, + "Restart file used different newton pair setting, " "using input script value"); } } else if (flag == NEWTON_BOND) { int newton_bond_file = read_int(); if (force->newton_bond != 1) { if (newton_bond_file != force->newton_bond && me == 0) - error->warning(FLERR,"Restart file used different newton bond setting, " + error->warning(FLERR, + "Restart file used different newton bond setting, " "using restart file value"); } force->newton_bond = newton_bond_file; @@ -707,7 +711,8 @@ void ReadRestart::type_arrays() atom->set_mass(mass); delete [] mass; - } else error->all(FLERR,"Invalid flag in type arrays section of restart file"); + } else error->all(FLERR, + "Invalid flag in type arrays section of restart file"); flag = read_int(); } @@ -778,7 +783,8 @@ void ReadRestart::force_fields() delete [] style; force->improper->read_restart(fp); - } else error->all(FLERR,"Invalid flag in force field section of restart file"); + } else error->all(FLERR, + "Invalid flag in force field section of restart file"); flag = read_int(); }