diff --git a/src/fix_store.cpp b/src/fix_store.cpp index abdbd20774..ecd052a295 100644 --- a/src/fix_store.cpp +++ b/src/fix_store.cpp @@ -15,6 +15,7 @@ #include #include "fix_store.h" #include "atom.h" +#include "comm.h" #include "force.h" #include "memory.h" #include "error.h" @@ -123,6 +124,35 @@ int FixStore::setmask() return mask; } +/* ---------------------------------------------------------------------- + write global array to restart file +------------------------------------------------------------------------- */ + +void FixStore::write_restart(FILE *fp) +{ + int n = nrow*ncol; + if (comm->me == 0) { + int size = n * sizeof(double); + fwrite(&size,sizeof(int),1,fp); + if (vecflag) fwrite(vstore,sizeof(double),n,fp); + else fwrite(&astore[0][0],sizeof(double),n,fp); + } +} + +/* ---------------------------------------------------------------------- + use global array from restart file to restart the Fix +------------------------------------------------------------------------- */ + +void FixStore::restart(char *buf) +{ + // HOWTO insure size of buf is the same + + int n = nrow*ncol; + double *dbuf = (double *) buf; + if (vecflag) memcpy(vstore,dbuf,n*sizeof(double)); + else memcpy(&astore[0][0],dbuf,n*sizeof(double)); +} + /* ---------------------------------------------------------------------- allocate atom-based array ------------------------------------------------------------------------- */ diff --git a/src/fix_store.h b/src/fix_store.h index 459e3f05c1..8bfef28c90 100644 --- a/src/fix_store.h +++ b/src/fix_store.h @@ -20,6 +20,7 @@ FixStyle(STORE,FixStore) #ifndef LMP_FIX_STORE_H #define LMP_FIX_STORE_H +#include #include "fix.h" namespace LAMMPS_NS { @@ -35,6 +36,9 @@ class FixStore : public Fix { ~FixStore(); int setmask(); + void write_restart(FILE *); + void restart(char *); + void grow_arrays(int); void copy_arrays(int, int, int); int pack_exchange(int, double *);