add restart support to fix temp/rescale, fix spring/chunk, and fix spring/rg
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include "atom.h"
|
||||
#include "comm.h"
|
||||
#include "update.h"
|
||||
#include "force.h"
|
||||
#include "respa.h"
|
||||
@ -37,6 +38,7 @@ FixSpringChunk::FixSpringChunk(LAMMPS *lmp, int narg, char **arg) :
|
||||
{
|
||||
if (narg != 6) error->all(FLERR,"Illegal fix spring/chunk command");
|
||||
|
||||
restart_global = 1;
|
||||
scalar_flag = 1;
|
||||
global_freq = 1;
|
||||
extscalar = 1;
|
||||
@ -241,6 +243,58 @@ void FixSpringChunk::min_post_force(int vflag)
|
||||
post_force(vflag);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
writ number of chunks and position of original COM into restart
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixSpringChunk::write_restart(FILE *fp)
|
||||
{
|
||||
double n = nchunk;
|
||||
|
||||
if (comm->me == 0) {
|
||||
int size = (3*n+1) * sizeof(double);
|
||||
fwrite(&size,sizeof(int),1,fp);
|
||||
fwrite(&n,sizeof(double),1,fp);
|
||||
fwrite(&com0[0][0],3*sizeof(double),nchunk,fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
use state info from restart file to restart the Fix
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixSpringChunk::restart(char *buf)
|
||||
{
|
||||
double *list = (double *) buf;
|
||||
int n = list[0];
|
||||
|
||||
memory->destroy(com0);
|
||||
memory->destroy(fcom);
|
||||
|
||||
int icompute = modify->find_compute(idchunk);
|
||||
if (icompute < 0)
|
||||
error->all(FLERR,"Chunk/atom compute does not exist for fix spring/chunk");
|
||||
cchunk = (ComputeChunkAtom *) modify->compute[icompute];
|
||||
if (strcmp(cchunk->style,"chunk/atom") != 0)
|
||||
error->all(FLERR,"Fix spring/chunk does not use chunk/atom compute");
|
||||
nchunk = cchunk->setup_chunks();
|
||||
cchunk->compute_ichunk();
|
||||
memory->create(com0,nchunk,3,"spring/chunk:com0");
|
||||
memory->create(fcom,nchunk,3,"spring/chunk:fcom");
|
||||
printf("restart chunks:%d computed chunks: %d\n",n,nchunk);
|
||||
|
||||
if (n != nchunk) {
|
||||
if (comm->me == 0)
|
||||
error->warning(FLERR,"Number of chunks has changed. Cannot use restart");
|
||||
memory->destroy(com0);
|
||||
memory->destroy(fcom);
|
||||
nchunk = 1;
|
||||
} else {
|
||||
cchunk->lock(this,update->ntimestep,-1);
|
||||
memcpy(&com0[0][0],list+1,3*n*sizeof(double));
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
energy of stretched spring
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user