git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14426 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2016-01-12 00:29:49 +00:00
parent 20cc9e51cd
commit 0da05dcdf4
2 changed files with 34 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include <string.h>
#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
------------------------------------------------------------------------- */

View File

@ -20,6 +20,7 @@ FixStyle(STORE,FixStore)
#ifndef LMP_FIX_STORE_H
#define LMP_FIX_STORE_H
#include <stdio.h>
#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 *);