forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13905 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
1c3e0dbfe9
commit
c85a42ab6d
|
@ -0,0 +1,60 @@
|
|||
# Install/unInstall package files in LAMMPS
|
||||
# mode = 0/1/2 for uninstall/install/update
|
||||
|
||||
mode=$1
|
||||
|
||||
# arg1 = file, arg2 = file it depends on
|
||||
|
||||
action () {
|
||||
if (test $mode = 0) then
|
||||
rm -f ../$1
|
||||
elif (! cmp -s $1 ../$1) then
|
||||
if (test -z "$2" || test -e ../$2) then
|
||||
cp $1 ..
|
||||
if (test $mode = 2) then
|
||||
echo " updating src/$1"
|
||||
fi
|
||||
fi
|
||||
elif (test -n "$2") then
|
||||
if (test ! -e ../$2) then
|
||||
rm -f ../$1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# all package files with no dependencies
|
||||
|
||||
for file in *.cpp *.h; do
|
||||
action $file
|
||||
done
|
||||
|
||||
# edit 2 Makefile.package files to include/exclude package info
|
||||
|
||||
if (test $1 = 1) then
|
||||
|
||||
if (test -e ../Makefile.package) then
|
||||
sed -i -e 's/[^ \t]*compress[^ \t]* //' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSINC =[ \t]*|&$(compress_SYSINC) |' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSLIB =[ \t]*|&$(compress_SYSLIB) |' ../Makefile.package
|
||||
sed -i -e 's|^PKG_SYSPATH =[ \t]*|&$(compress_SYSPATH) |' ../Makefile.package
|
||||
fi
|
||||
|
||||
if (test -e ../Makefile.package.settings) then
|
||||
sed -i -e '/^include.*compress.*$/d' ../Makefile.package.settings
|
||||
# multiline form needed for BSD sed on Macs
|
||||
sed -i -e '4 i \
|
||||
include ..\/..\/lib\/compress\/Makefile.lammps
|
||||
' ../Makefile.package.settings
|
||||
fi
|
||||
|
||||
elif (test $1 = 0) then
|
||||
|
||||
if (test -e ../Makefile.package) then
|
||||
sed -i -e 's/[^ \t]*compress[^ \t]* //' ../Makefile.package
|
||||
fi
|
||||
|
||||
if (test -e ../Makefile.package.settings) then
|
||||
sed -i -e '/^include.*compress.*$/d' ../Makefile.package.settings
|
||||
fi
|
||||
|
||||
fi
|
|
@ -0,0 +1,13 @@
|
|||
This package provides alternative styles that allow compressed file I/O
|
||||
via compression libraries. This is similar to what is enabled through
|
||||
using the -DLAMMPS_GZIP preprocessor flag, but it does not open a pipe
|
||||
to an external executable that handles the compression. These styles
|
||||
use library calls to libraries like zlib instead and thus have to be
|
||||
compiled using the library header files and linked to the respective
|
||||
library. This provides an alternative for compressed file I/O on systems
|
||||
where using a pipe can cause problems, e.g. when using RDMA communication
|
||||
with pinned memory like clusters with infiniband or myrinet.
|
||||
|
||||
At the moment a few selected dump styles are supported
|
||||
for writing via this packaging.
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "dump_atom_gz.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
DumpAtomGZ::DumpAtomGZ(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpAtom(lmp, narg, arg)
|
||||
{
|
||||
gzFp = NULL;
|
||||
|
||||
if (!compressed)
|
||||
error->all(FLERR,"Dump atom/gz only writes compressed files");
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpAtomGZ::~DumpAtomGZ()
|
||||
{
|
||||
if (gzFp) gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
fp = NULL;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
generic opening of a dump file
|
||||
ASCII or binary or gzipped
|
||||
some derived classes override this function
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DumpAtomGZ::openfile()
|
||||
{
|
||||
// single file, already opened, so just return
|
||||
|
||||
if (singlefile_opened) return;
|
||||
if (multifile == 0) singlefile_opened = 1;
|
||||
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
|
||||
char *filecurrent = filename;
|
||||
if (multiproc) filecurrent = multiname;
|
||||
|
||||
if (multifile) {
|
||||
char *filestar = filecurrent;
|
||||
filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar,'*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s",
|
||||
filestar,update->ntimestep,ptr+1);
|
||||
else {
|
||||
char bif[8],pad[16];
|
||||
strcpy(bif,BIGINT_FORMAT);
|
||||
sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]);
|
||||
sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
|
||||
}
|
||||
*ptr = '*';
|
||||
}
|
||||
|
||||
// each proc with filewriter = 1 opens a file
|
||||
|
||||
if (filewriter) {
|
||||
if (append_flag) {
|
||||
gzFp = gzopen(filecurrent,"ab9");
|
||||
} else {
|
||||
gzFp = gzopen(filecurrent,"wb9");
|
||||
}
|
||||
|
||||
if (gzFp == NULL) error->one(FLERR,"Cannot open dump file");
|
||||
} else gzFp = NULL;
|
||||
|
||||
// delete string with timestep replaced
|
||||
|
||||
if (multifile) delete [] filecurrent;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpAtomGZ::write_header(bigint ndump)
|
||||
{
|
||||
if ((multiproc) || (!multiproc && me == 0)) {
|
||||
if (domain->triclinic == 0) {
|
||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||
gzprintf(gzFp,"ITEM: BOX BOUNDS %s\n",boundstr);
|
||||
gzprintf(gzFp,"%g %g\n",boxxlo,boxxhi);
|
||||
gzprintf(gzFp,"%g %g\n",boxylo,boxyhi);
|
||||
gzprintf(gzFp,"%g %g\n",boxzlo,boxzhi);
|
||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
||||
} else {
|
||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||
gzprintf(gzFp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr);
|
||||
gzprintf(gzFp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
|
||||
gzprintf(gzFp,"%g %g %g\n",boxylo,boxyhi,boxxz);
|
||||
gzprintf(gzFp,"%g %g %g\n",boxzlo,boxzhi,boxyz);
|
||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpAtomGZ::write_data(int n, double *mybuf)
|
||||
{
|
||||
gzwrite(gzFp,mybuf,sizeof(char)*n);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpAtomGZ::write()
|
||||
{
|
||||
DumpAtom::write();
|
||||
if (filewriter) {
|
||||
if (multifile) {
|
||||
gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
} else {
|
||||
if (flush_flag)
|
||||
gzflush(gzFp,Z_SYNC_FLUSH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef DUMP_CLASS
|
||||
|
||||
DumpStyle(atom/gz,DumpAtomGZ)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_ATOM_GZ_H
|
||||
#define LMP_DUMP_ATOM_GZ_H
|
||||
|
||||
#include "dump_atom.h"
|
||||
|
||||
// forward definition from zlib.h
|
||||
typedef struct gzFile_s *gzFile;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DumpAtomGZ : public DumpAtom {
|
||||
public:
|
||||
DumpAtomGZ(class LAMMPS *, int, char **);
|
||||
virtual ~DumpAtomGZ();
|
||||
|
||||
protected:
|
||||
gzFile gzFp; // file pointer for the compressed output stream
|
||||
|
||||
virtual void openfile();
|
||||
virtual void write_header(bigint);
|
||||
virtual void write_data(int, double *);
|
||||
virtual void write();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Dump atom/gz only writes compressed files
|
||||
|
||||
The dump atom/gz output file name must have a .gz suffix.
|
||||
|
||||
*/
|
|
@ -0,0 +1,154 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "dump_cfg_gz.h"
|
||||
#include "atom.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
#define UNWRAPEXPAND 10.0
|
||||
|
||||
DumpCFGGZ::DumpCFGGZ(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpCFG(lmp, narg, arg)
|
||||
{
|
||||
gzFp = NULL;
|
||||
|
||||
if (!compressed)
|
||||
error->all(FLERR,"Dump cfg/gz only writes compressed files");
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpCFGGZ::~DumpCFGGZ()
|
||||
{
|
||||
if (gzFp) gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
fp = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
generic opening of a dump file
|
||||
ASCII or binary or gzipped
|
||||
some derived classes override this function
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DumpCFGGZ::openfile()
|
||||
{
|
||||
// single file, already opened, so just return
|
||||
|
||||
if (singlefile_opened) return;
|
||||
if (multifile == 0) singlefile_opened = 1;
|
||||
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
|
||||
char *filecurrent = filename;
|
||||
if (multiproc) filecurrent = multiname;
|
||||
|
||||
if (multifile) {
|
||||
char *filestar = filecurrent;
|
||||
filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar,'*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s",
|
||||
filestar,update->ntimestep,ptr+1);
|
||||
else {
|
||||
char bif[8],pad[16];
|
||||
strcpy(bif,BIGINT_FORMAT);
|
||||
sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]);
|
||||
sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
|
||||
}
|
||||
*ptr = '*';
|
||||
}
|
||||
|
||||
// each proc with filewriter = 1 opens a file
|
||||
|
||||
if (filewriter) {
|
||||
if (append_flag) {
|
||||
gzFp = gzopen(filecurrent,"ab9");
|
||||
} else {
|
||||
gzFp = gzopen(filecurrent,"wb9");
|
||||
}
|
||||
|
||||
if (gzFp == NULL) error->one(FLERR,"Cannot open dump file");
|
||||
} else gzFp = NULL;
|
||||
|
||||
// delete string with timestep replaced
|
||||
|
||||
if (multifile) delete [] filecurrent;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpCFGGZ::write_header(bigint n)
|
||||
{
|
||||
// set scale factor used by AtomEye for CFG viz
|
||||
// default = 1.0
|
||||
// for peridynamics, set to pre-computed PD scale factor
|
||||
// so PD particles mimic C atoms
|
||||
// for unwrapped coords, set to UNWRAPEXPAND (10.0)
|
||||
// so molecules are not split across periodic box boundaries
|
||||
|
||||
double scale = 1.0;
|
||||
if (atom->peri_flag) scale = atom->pdscale;
|
||||
else if (unwrapflag == 1) scale = UNWRAPEXPAND;
|
||||
|
||||
char str[64];
|
||||
sprintf(str,"Number of particles = %s\n",BIGINT_FORMAT);
|
||||
gzprintf(gzFp,str,n);
|
||||
gzprintf(gzFp,"A = %g Angstrom (basic length-scale)\n",scale);
|
||||
gzprintf(gzFp,"H0(1,1) = %g A\n",domain->xprd);
|
||||
gzprintf(gzFp,"H0(1,2) = 0 A \n");
|
||||
gzprintf(gzFp,"H0(1,3) = 0 A \n");
|
||||
gzprintf(gzFp,"H0(2,1) = %g A \n",domain->xy);
|
||||
gzprintf(gzFp,"H0(2,2) = %g A\n",domain->yprd);
|
||||
gzprintf(gzFp,"H0(2,3) = 0 A \n");
|
||||
gzprintf(gzFp,"H0(3,1) = %g A \n",domain->xz);
|
||||
gzprintf(gzFp,"H0(3,2) = %g A \n",domain->yz);
|
||||
gzprintf(gzFp,"H0(3,3) = %g A\n",domain->zprd);
|
||||
gzprintf(gzFp,".NO_VELOCITY.\n");
|
||||
gzprintf(gzFp,"entry_count = %d\n",nfield-2);
|
||||
for (int i = 0; i < nfield-5; i++)
|
||||
gzprintf(gzFp,"auxiliary[%d] = %s\n",i,auxname[i]);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpCFGGZ::write_data(int n, double *mybuf)
|
||||
{
|
||||
gzwrite(gzFp,mybuf,sizeof(char)*n);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpCFGGZ::write()
|
||||
{
|
||||
DumpCFG::write();
|
||||
if (filewriter) {
|
||||
if (multifile) {
|
||||
gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
} else {
|
||||
if (flush_flag)
|
||||
gzflush(gzFp,Z_SYNC_FLUSH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef DUMP_CLASS
|
||||
|
||||
DumpStyle(cfg/gz,DumpCFGGZ)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_CFG_GZ_H
|
||||
#define LMP_DUMP_CFG_GZ_H
|
||||
|
||||
#include "dump_cfg.h"
|
||||
|
||||
// forward definition from zlib.h
|
||||
typedef struct gzFile_s *gzFile;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DumpCFGGZ : public DumpCFG {
|
||||
public:
|
||||
DumpCFGGZ(class LAMMPS *, int, char **);
|
||||
virtual ~DumpCFGGZ();
|
||||
|
||||
protected:
|
||||
gzFile gzFp; // file pointer for the compressed output stream
|
||||
|
||||
virtual void openfile();
|
||||
virtual void write_header(bigint);
|
||||
virtual void write_data(int, double *);
|
||||
virtual void write();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Dump cfg/gz only writes compressed files
|
||||
|
||||
The dump cfg/gz output file name must have a .gz suffix.
|
||||
|
||||
*/
|
|
@ -0,0 +1,145 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "dump_custom_gz.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
DumpCustomGZ::DumpCustomGZ(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpCustom(lmp, narg, arg)
|
||||
{
|
||||
gzFp = NULL;
|
||||
|
||||
if (!compressed)
|
||||
error->all(FLERR,"Dump custom/gz only writes compressed files");
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpCustomGZ::~DumpCustomGZ()
|
||||
{
|
||||
if (gzFp) gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
fp = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
generic opening of a dump file
|
||||
ASCII or binary or gzipped
|
||||
some derived classes override this function
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DumpCustomGZ::openfile()
|
||||
{
|
||||
// single file, already opened, so just return
|
||||
|
||||
if (singlefile_opened) return;
|
||||
if (multifile == 0) singlefile_opened = 1;
|
||||
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
|
||||
char *filecurrent = filename;
|
||||
if (multiproc) filecurrent = multiname;
|
||||
|
||||
if (multifile) {
|
||||
char *filestar = filecurrent;
|
||||
filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar,'*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s",
|
||||
filestar,update->ntimestep,ptr+1);
|
||||
else {
|
||||
char bif[8],pad[16];
|
||||
strcpy(bif,BIGINT_FORMAT);
|
||||
sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]);
|
||||
sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
|
||||
}
|
||||
*ptr = '*';
|
||||
}
|
||||
|
||||
// each proc with filewriter = 1 opens a file
|
||||
|
||||
if (filewriter) {
|
||||
if (append_flag) {
|
||||
gzFp = gzopen(filecurrent,"ab9");
|
||||
} else {
|
||||
gzFp = gzopen(filecurrent,"wb9");
|
||||
}
|
||||
|
||||
if (gzFp == NULL) error->one(FLERR,"Cannot open dump file");
|
||||
} else gzFp = NULL;
|
||||
|
||||
// delete string with timestep replaced
|
||||
|
||||
if (multifile) delete [] filecurrent;
|
||||
}
|
||||
|
||||
void DumpCustomGZ::write_header(bigint ndump)
|
||||
{
|
||||
if ((multiproc) || (!multiproc && me == 0)) {
|
||||
if (domain->triclinic == 0) {
|
||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||
gzprintf(gzFp,"ITEM: BOX BOUNDS %s\n",boundstr);
|
||||
gzprintf(gzFp,"%g %g\n",boxxlo,boxxhi);
|
||||
gzprintf(gzFp,"%g %g\n",boxylo,boxyhi);
|
||||
gzprintf(gzFp,"%g %g\n",boxzlo,boxzhi);
|
||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
||||
} else {
|
||||
gzprintf(gzFp,"ITEM: TIMESTEP\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",update->ntimestep);
|
||||
gzprintf(gzFp,"ITEM: NUMBER OF ATOMS\n");
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||
gzprintf(gzFp,"ITEM: BOX BOUNDS xy xz yz %s\n",boundstr);
|
||||
gzprintf(gzFp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
|
||||
gzprintf(gzFp,"%g %g %g\n",boxylo,boxyhi,boxxz);
|
||||
gzprintf(gzFp,"%g %g %g\n",boxzlo,boxzhi,boxyz);
|
||||
gzprintf(gzFp,"ITEM: ATOMS %s\n",columns);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpCustomGZ::write_data(int n, double *mybuf)
|
||||
{
|
||||
gzwrite(gzFp,mybuf,sizeof(char)*n);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpCustomGZ::write()
|
||||
{
|
||||
DumpCustom::write();
|
||||
if (filewriter) {
|
||||
if (multifile) {
|
||||
gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
} else {
|
||||
if (flush_flag)
|
||||
gzflush(gzFp,Z_SYNC_FLUSH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef DUMP_CLASS
|
||||
|
||||
DumpStyle(custom/gz,DumpCustomGZ)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_CUSTOM_GZ_H
|
||||
#define LMP_DUMP_CUSTOM_GZ_H
|
||||
|
||||
#include "dump_custom.h"
|
||||
|
||||
// forward definition from zlib.h
|
||||
typedef struct gzFile_s *gzFile;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DumpCustomGZ : public DumpCustom {
|
||||
public:
|
||||
DumpCustomGZ(class LAMMPS *, int, char **);
|
||||
virtual ~DumpCustomGZ();
|
||||
|
||||
protected:
|
||||
gzFile gzFp; // file pointer for the compressed output stream
|
||||
|
||||
virtual void openfile();
|
||||
virtual void write_header(bigint);
|
||||
virtual void write_data(int, double *);
|
||||
virtual void write();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Dump custom/gz only writes compressed files
|
||||
|
||||
The dump custom/gz output file name must have a .gz suffix.
|
||||
|
||||
*/
|
|
@ -0,0 +1,125 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "dump_xyz_gz.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "update.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <zlib.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
DumpXYZGZ::DumpXYZGZ(LAMMPS *lmp, int narg, char **arg) :
|
||||
DumpXYZ(lmp, narg, arg)
|
||||
{
|
||||
gzFp = NULL;
|
||||
|
||||
if (!compressed)
|
||||
error->all(FLERR,"Dump xyz/gz only writes compressed files");
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
DumpXYZGZ::~DumpXYZGZ()
|
||||
{
|
||||
if (gzFp) gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
fp = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
generic opening of a dump file
|
||||
ASCII or binary or gzipped
|
||||
some derived classes override this function
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void DumpXYZGZ::openfile()
|
||||
{
|
||||
// single file, already opened, so just return
|
||||
|
||||
if (singlefile_opened) return;
|
||||
if (multifile == 0) singlefile_opened = 1;
|
||||
|
||||
// if one file per timestep, replace '*' with current timestep
|
||||
|
||||
char *filecurrent = filename;
|
||||
if (multiproc) filecurrent = multiname;
|
||||
|
||||
if (multifile) {
|
||||
char *filestar = filecurrent;
|
||||
filecurrent = new char[strlen(filestar) + 16];
|
||||
char *ptr = strchr(filestar,'*');
|
||||
*ptr = '\0';
|
||||
if (padflag == 0)
|
||||
sprintf(filecurrent,"%s" BIGINT_FORMAT "%s",
|
||||
filestar,update->ntimestep,ptr+1);
|
||||
else {
|
||||
char bif[8],pad[16];
|
||||
strcpy(bif,BIGINT_FORMAT);
|
||||
sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]);
|
||||
sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1);
|
||||
}
|
||||
*ptr = '*';
|
||||
}
|
||||
|
||||
// each proc with filewriter = 1 opens a file
|
||||
|
||||
if (filewriter) {
|
||||
if (append_flag) {
|
||||
gzFp = gzopen(filecurrent,"ab9");
|
||||
} else {
|
||||
gzFp = gzopen(filecurrent,"wb9");
|
||||
}
|
||||
|
||||
if (gzFp == NULL) error->one(FLERR,"Cannot open dump file");
|
||||
} else gzFp = NULL;
|
||||
|
||||
// delete string with timestep replaced
|
||||
|
||||
if (multifile) delete [] filecurrent;
|
||||
}
|
||||
|
||||
void DumpXYZGZ::write_header(bigint ndump)
|
||||
{
|
||||
if (me == 0) {
|
||||
gzprintf(gzFp,BIGINT_FORMAT "\n",ndump);
|
||||
gzprintf(gzFp,"Atoms. Timestep: " BIGINT_FORMAT "\n",update->ntimestep);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpXYZGZ::write_data(int n, double *mybuf)
|
||||
{
|
||||
gzwrite(gzFp,mybuf,sizeof(char)*n);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void DumpXYZGZ::write()
|
||||
{
|
||||
DumpXYZ::write();
|
||||
if (filewriter) {
|
||||
if (multifile) {
|
||||
gzclose(gzFp);
|
||||
gzFp = NULL;
|
||||
} else {
|
||||
if (flush_flag)
|
||||
gzflush(gzFp,Z_SYNC_FLUSH);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/* -*- c++ -*- ----------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
http://lammps.sandia.gov, Sandia National Laboratories
|
||||
Steve Plimpton, sjplimp@sandia.gov
|
||||
|
||||
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||
certain rights in this software. This software is distributed under
|
||||
the GNU General Public License.
|
||||
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef DUMP_CLASS
|
||||
|
||||
DumpStyle(xyz/gz,DumpXYZGZ)
|
||||
|
||||
#else
|
||||
|
||||
#ifndef LMP_DUMP_XYZ_GZ_H
|
||||
#define LMP_DUMP_XYZ_GZ_H
|
||||
|
||||
#include "dump_xyz.h"
|
||||
|
||||
// forward definition from zlib.h
|
||||
typedef struct gzFile_s *gzFile;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class DumpXYZGZ : public DumpXYZ {
|
||||
public:
|
||||
DumpXYZGZ(class LAMMPS *, int, char **);
|
||||
virtual ~DumpXYZGZ();
|
||||
|
||||
protected:
|
||||
gzFile gzFp; // file pointer for the compressed output stream
|
||||
|
||||
virtual void openfile();
|
||||
virtual void write_header(bigint);
|
||||
virtual void write_data(int, double *);
|
||||
virtual void write();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ERROR/WARNING messages:
|
||||
|
||||
E: Dump xyz/gz only writes compressed files
|
||||
|
||||
The dump xyz/gz output file name must have a .gz suffix.
|
||||
|
||||
*/
|
|
@ -77,6 +77,8 @@ action pair_lj_class2_coul_long_gpu.cpp pair_lj_class2_coul_long.cpp
|
|||
action pair_lj_class2_coul_long_gpu.h pair_lj_class2_coul_long.cpp
|
||||
action pair_lj_class2_gpu.cpp pair_lj_class2.cpp
|
||||
action pair_lj_class2_gpu.h pair_lj_class2.cpp
|
||||
action pair_lj_cubic_gpu.cpp
|
||||
action pair_lj_cubic_gpu.h
|
||||
action pair_lj_cut_coul_cut_gpu.cpp
|
||||
action pair_lj_cut_coul_cut_gpu.h
|
||||
action pair_lj_cut_coul_debye_gpu.cpp
|
||||
|
@ -109,10 +111,14 @@ action pair_sw_gpu.cpp pair_sw.cpp
|
|||
action pair_sw_gpu.h pair_sw.h
|
||||
action pair_table_gpu.cpp pair_table.cpp
|
||||
action pair_table_gpu.h pair_table.cpp
|
||||
action pair_tersoff_gpu.cpp pair_tersoff.cpp
|
||||
action pair_tersoff_gpu.h pair_tersoff.cpp
|
||||
action pair_yukawa_colloid_gpu.cpp pair_yukawa_colloid.cpp
|
||||
action pair_yukawa_colloid_gpu.h pair_yukawa_colloid.cpp
|
||||
action pair_yukawa_gpu.cpp pair_yukawa.cpp
|
||||
action pair_yukawa_gpu.h pair_yukawa.cpp
|
||||
action pair_zbl_gpu.cpp
|
||||
action pair_zbl_gpu.h
|
||||
action pppm_gpu.cpp pppm.cpp
|
||||
action pppm_gpu.h pppm.cpp
|
||||
|
||||
|
|
|
@ -115,6 +115,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
|
|||
if (strcmp(arg[iarg+1],"off") == 0) newtonflag = 0;
|
||||
else if (strcmp(arg[iarg+1],"on") == 0) newtonflag = 1;
|
||||
else error->all(FLERR,"Illegal package gpu command");
|
||||
iarg += 2;
|
||||
} else if (strcmp(arg[iarg],"binsize") == 0) {
|
||||
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
|
||||
binsize = force->numeric(FLERR,arg[iarg+1]);
|
||||
|
|
|
@ -41,7 +41,8 @@ endif
|
|||
|
||||
# Package variables
|
||||
|
||||
PACKAGE = asphere body class2 colloid coreshell dipole fld gpu granular kim \
|
||||
PACKAGE = asphere body class2 colloid compress coreshell dipole fld gpu \
|
||||
granular kim \
|
||||
kokkos kspace manybody mc meam misc molecule mpiio opt peri poems \
|
||||
python qeq reax replica rigid shock snap srd voronoi xtc
|
||||
|
||||
|
@ -50,7 +51,7 @@ PACKUSER = user-atc user-awpmd user-cg-cmm user-colvars user-cuda \
|
|||
user-misc user-molfile user-omp user-phonon user-qmmm user-qtb \
|
||||
user-quip user-reaxc user-smd user-sph
|
||||
|
||||
PACKLIB = gpu kim kokkos meam poems python reax voronoi \
|
||||
PACKLIB = compress gpu kim kokkos meam poems python reax voronoi \
|
||||
user-atc user-awpmd user-colvars user-cuda user-molfile \
|
||||
user-qmmm user-quip
|
||||
|
||||
|
|
|
@ -131,6 +131,10 @@ class Compute : protected Pointers {
|
|||
|
||||
virtual double memory_usage() {return 0.0;}
|
||||
|
||||
virtual void pair_tally_callback(int, int, int, int,
|
||||
double, double, double,
|
||||
double, double, double) {}
|
||||
|
||||
virtual int unsigned data_mask() {return datamask;}
|
||||
virtual int unsigned data_mask_ext() {return datamask_ext;}
|
||||
|
||||
|
|
63
src/pair.cpp
63
src/pair.cpp
|
@ -32,6 +32,8 @@
|
|||
#include "force.h"
|
||||
#include "kspace.h"
|
||||
#include "update.h"
|
||||
#include "modify.h"
|
||||
#include "compute.h"
|
||||
#include "accelerator_cuda.h"
|
||||
#include "suffix.h"
|
||||
#include "atom_masks.h"
|
||||
|
@ -96,6 +98,9 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp)
|
|||
eatom = NULL;
|
||||
vatom = NULL;
|
||||
|
||||
num_tally_compute = 0;
|
||||
list_tally_compute = NULL;
|
||||
|
||||
// CUDA and KOKKOS per-fix data masks
|
||||
|
||||
datamask = ALL_MASK;
|
||||
|
@ -112,6 +117,9 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp)
|
|||
|
||||
Pair::~Pair()
|
||||
{
|
||||
num_tally_compute = 0;
|
||||
memory->sfree((void *)list_tally_compute);
|
||||
|
||||
if (copymode) return;
|
||||
|
||||
memory->destroy(eatom);
|
||||
|
@ -685,6 +693,53 @@ void Pair::compute_dummy(int eflag, int vflag)
|
|||
else evflag = 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
register a callback to a compute, so it can compute and accumulate
|
||||
additional properties during the pair computation from within
|
||||
Pair::ev_tally(). ensure each compute instance is registered only once
|
||||
---------------------------------------------------------------------- */
|
||||
void Pair::add_tally_callback(Compute *ptr)
|
||||
{
|
||||
int i,found=-1;
|
||||
|
||||
for (i=0; i < num_tally_compute; ++i) {
|
||||
if (list_tally_compute[i] == ptr)
|
||||
found = i;
|
||||
}
|
||||
|
||||
if (found < 0) {
|
||||
found = num_tally_compute;
|
||||
++num_tally_compute;
|
||||
void *p = memory->srealloc((void *)list_tally_compute,
|
||||
sizeof(Compute **) * num_tally_compute,
|
||||
"pair:list_tally_compute");
|
||||
list_tally_compute = (Compute **) p;
|
||||
list_tally_compute[num_tally_compute-1] = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------
|
||||
unregister a callback to a fix for additional pairwise tallying
|
||||
---------------------------------------------------------------------- */
|
||||
void Pair::del_tally_callback(Compute *ptr)
|
||||
{
|
||||
int i,found=-1;
|
||||
|
||||
for (i=0; i < num_tally_compute; ++i) {
|
||||
if (list_tally_compute[i] == ptr)
|
||||
found = i;
|
||||
}
|
||||
|
||||
if (found < 0)
|
||||
return;
|
||||
|
||||
// compact the list of active computes
|
||||
--num_tally_compute;
|
||||
for (i=found; i < num_tally_compute; ++i) {
|
||||
list_tally_compute[i] = list_tally_compute[i+1];
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
setup for energy, virial computation
|
||||
see integrate::ev_set() for values of eflag (0-3) and vflag (0-6)
|
||||
|
@ -866,6 +921,14 @@ void Pair::ev_tally(int i, int j, int nlocal, int newton_pair,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (num_tally_compute > 0) {
|
||||
for (int k=0; k < num_tally_compute; ++k) {
|
||||
Compute *c = list_tally_compute[k];
|
||||
c->pair_tally_callback(i, j, nlocal, newton_pair,
|
||||
evdwl, ecoul, fpair, delx, dely, delz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
|
@ -186,6 +186,15 @@ class Pair : protected Pointers {
|
|||
virtual unsigned int data_mask() {return datamask;}
|
||||
virtual unsigned int data_mask_ext() {return datamask_ext;}
|
||||
|
||||
// management of callbacks to be run from ev_tally()
|
||||
|
||||
private:
|
||||
int num_tally_compute;
|
||||
class Compute **list_tally_compute;
|
||||
public:
|
||||
void add_tally_callback(class Compute *);
|
||||
void del_tally_callback(class Compute *);
|
||||
|
||||
protected:
|
||||
int instance_me; // which Pair class instantiation I am
|
||||
|
||||
|
|
Loading…
Reference in New Issue