diff --git a/doc/src/fix_deform.txt b/doc/src/fix_deform.txt index 8c3a9fa499..d3254eece6 100644 --- a/doc/src/fix_deform.txt +++ b/doc/src/fix_deform.txt @@ -565,8 +565,10 @@ more instructions on how to use the accelerated styles effectively. [Restart, fix_modify, output, run start/stop, minimize info:] -No information about this fix is written to "binary restart -files"_restart.html. None of the "fix_modify"_fix_modify.html options +This fix will restore the initial box settings from "binary restart +files"_restart.html, which allows the fix to be properly continue +deformation, when using the start/stop options of the "run"_run.html +command. None of the "fix_modify"_fix_modify.html options are relevant to this fix. No global or per-atom quantities are stored by this fix for access by various "output commands"_Section_howto.html#howto_15. diff --git a/src/fix_deform.cpp b/src/fix_deform.cpp index 171a90ba3a..705f1970af 100644 --- a/src/fix_deform.cpp +++ b/src/fix_deform.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -enum{NONE,FINAL,DELTA,SCALE,VEL,ERATE,TRATE,VOLUME,WIGGLE,VARIABLE}; +enum{NONE=0,FINAL,DELTA,SCALE,VEL,ERATE,TRATE,VOLUME,WIGGLE,VARIABLE}; enum{ONE_FROM_ONE,ONE_FROM_TWO,TWO_FROM_ONE}; // same as domain.cpp, fix_nvt_sllod.cpp, compute_temp_deform.cpp @@ -52,6 +52,7 @@ rfix(NULL), irregular(NULL), set(NULL) if (narg < 4) error->all(FLERR,"Illegal fix deform command"); no_change_box = 1; + restart_global = 1; nevery = force->inumeric(FLERR,arg[3]); if (nevery <= 0) error->all(FLERR,"Illegal fix deform command"); @@ -59,12 +60,7 @@ rfix(NULL), irregular(NULL), set(NULL) // set defaults set = new Set[6]; - set[0].style = set[1].style = set[2].style = - set[3].style = set[4].style = set[5].style = NONE; - set[0].hstr = set[1].hstr = set[2].hstr = - set[3].hstr = set[4].hstr = set[5].hstr = NULL; - set[0].hratestr = set[1].hratestr = set[2].hratestr = - set[3].hratestr = set[4].hratestr = set[5].hratestr = NULL; + memset(set,0,6*sizeof(Set)); // parse arguments @@ -343,11 +339,9 @@ rfix(NULL), irregular(NULL), set(NULL) set[i].hi_initial = domain->boxhi[i]; set[i].vol_initial = domain->xprd * domain->yprd * domain->zprd; } - for (int i = 3; i < 6; i++) { - if (i == 5) set[i].tilt_initial = domain->xy; - else if (i == 4) set[i].tilt_initial = domain->xz; - else if (i == 3) set[i].tilt_initial = domain->yz; - } + set[3].tilt_initial = domain->yz; + set[4].tilt_initial = domain->xz; + set[5].tilt_initial = domain->xy; // reneighboring only forced if flips can occur due to shape changes @@ -955,6 +949,43 @@ void FixDeform::end_of_step() if (kspace_flag) force->kspace->setup(); } +/* ---------------------------------------------------------------------- + write Set data to restart file +------------------------------------------------------------------------- */ + +void FixDeform::write_restart(FILE *fp) +{ + if (comm->me == 0) { + int size = 6*sizeof(Set); + fwrite(&size,sizeof(int),1,fp); + fwrite(set,sizeof(Set),6,fp); + } +} + +/* ---------------------------------------------------------------------- + use selected state info from restart file to restart the Fix +------------------------------------------------------------------------- */ + +void FixDeform::restart(char *buf) +{ + int samestyle = 1; + Set *set_restart = (Set *) buf; + for (int i=0; i<6; ++i) { + // restore data from initial state + set[i].lo_initial = set_restart[i].lo_initial; + set[i].hi_initial = set_restart[i].hi_initial; + set[i].vol_initial = set_restart[i].vol_initial; + set[i].tilt_initial = set_restart[i].tilt_initial; + // check if style settings are consitent (should do the whole set?) + if (set[i].style != set_restart[i].style) + samestyle = 0; + if (set[i].substyle != set_restart[i].substyle) + samestyle = 0; + } + if (!samestyle) + error->all(FLERR,"Fix deform settings not consistent with restart"); +} + /* ---------------------------------------------------------------------- */ void FixDeform::options(int narg, char **arg) diff --git a/src/fix_deform.h b/src/fix_deform.h index cdda1b8547..4d440eb3c7 100644 --- a/src/fix_deform.h +++ b/src/fix_deform.h @@ -35,6 +35,8 @@ class FixDeform : public Fix { void init(); virtual void pre_exchange(); virtual void end_of_step(); + virtual void write_restart(FILE *); + virtual void restart(char *buf); double memory_usage(); protected: