#include "fix_event_hyper.h"
#include "comm.h"
#include "error.h"
#include "update.h"
using namespace LAMMPS_NS;
using namespace FixConst;
FixEventHyper::FixEventHyper(LAMMPS *lmp, int narg, char **arg) :
FixEvent(lmp, narg, arg)
{
if (narg != 3) error->all(FLERR,"Illegal fix event command");
restart_global = 1;
event_number = 0;
event_timestep = update->ntimestep;
clock = 0;
}
void FixEventHyper::store_event_hyper(bigint ntimestep, int delta_clock)
{
store_event();
event_timestep = ntimestep;
clock += delta_clock;
event_number++;
}
void FixEventHyper::write_restart(FILE *fp)
{
int n = 0;
double list[6];
list[n++] = event_number;
list[n++] = event_timestep;
list[n++] = clock;
list[n++] = replica_number;
list[n++] = correlated_event;
list[n++] = ncoincident;
if (comm->me == 0) {
int size = n * sizeof(double);
fwrite(&size,sizeof(int),1,fp);
fwrite(list,sizeof(double),n,fp);
}
}
void FixEventHyper::restart(char *buf)
{
int n = 0;
double *list = (double *) buf;
event_number = static_cast<int> (list[n++]);
event_timestep = static_cast<bigint> (list[n++]);
clock = static_cast<bigint> (list[n++]);
replica_number = static_cast<int> (list[n++]);
correlated_event = static_cast<int> (list[n++]);
ncoincident = static_cast<int> (list[n++]);
}