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

This commit is contained in:
sjplimp
2009-03-16 22:34:07 +00:00
parent 7a32bab5d9
commit 5a0f2e17b3
7 changed files with 136 additions and 10 deletions

View File

@ -135,6 +135,9 @@ void Dump::write()
boxyhi = domain->boxhi_bound[1]; boxyhi = domain->boxhi_bound[1];
boxzlo = domain->boxlo_bound[2]; boxzlo = domain->boxlo_bound[2];
boxzhi = domain->boxhi_bound[2]; boxzhi = domain->boxhi_bound[2];
boxxy = domain->xy;
boxxz = domain->xz;
boxyz = domain->yz;
} }
// nme = # of dump lines this proc will contribute to dump // nme = # of dump lines this proc will contribute to dump

View File

@ -52,8 +52,9 @@ class Dump : protected Pointers {
protected: protected:
double boxxlo,boxxhi; // local copies of domain values double boxxlo,boxxhi; // local copies of domain values
double boxylo,boxyhi; // adjusted to be bounding box for triclinic double boxylo,boxyhi; // lo/hi are bounding box for triclinic
double boxzlo,boxzhi; double boxzlo,boxzhi;
double boxxy,boxxz,boxyz;
virtual void openfile(); virtual void openfile();
virtual int modify_param(int, char **) {return 0;} virtual int modify_param(int, char **) {return 0;}

View File

@ -61,10 +61,27 @@ void DumpAtom::init()
strcat(format,"\n"); strcat(format,"\n");
} }
// setup column string
if (scale_flag == 0 && image_flag == 0)
columns = "id type x y z";
else if (scale_flag == 0 && image_flag == 1)
columns = "id type x y z ix iy iz";
else if (scale_flag == 1 && image_flag == 0)
columns = "id type xs ys zs";
else if (scale_flag == 1 && image_flag == 1)
columns = "id type xs ys zs ix iy iz";
// setup function ptrs // setup function ptrs
if (binary) header_choice = &DumpAtom::header_binary; if (binary && domain->triclinic == 0)
else header_choice = &DumpAtom::header_item; header_choice = &DumpAtom::header_binary;
else if (binary && domain->triclinic == 1)
header_choice = &DumpAtom::header_binary_triclinic;
else if (!binary && domain->triclinic == 0)
header_choice = &DumpAtom::header_item;
else if (!binary && domain->triclinic == 1)
header_choice = &DumpAtom::header_item_triclinic;
if (scale_flag == 1 && image_flag == 0 && domain->triclinic == 0) if (scale_flag == 1 && image_flag == 0 && domain->triclinic == 0)
pack_choice = &DumpAtom::pack_scale_noimage; pack_choice = &DumpAtom::pack_scale_noimage;
@ -146,6 +163,7 @@ void DumpAtom::header_binary(int ndump)
{ {
fwrite(&update->ntimestep,sizeof(int),1,fp); fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp); fwrite(&ndump,sizeof(int),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp); fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp); fwrite(&boxxhi,sizeof(double),1,fp);
fwrite(&boxylo,sizeof(double),1,fp); fwrite(&boxylo,sizeof(double),1,fp);
@ -161,6 +179,29 @@ void DumpAtom::header_binary(int ndump)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void DumpAtom::header_binary_triclinic(int ndump)
{
fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp);
fwrite(&boxylo,sizeof(double),1,fp);
fwrite(&boxyhi,sizeof(double),1,fp);
fwrite(&boxzlo,sizeof(double),1,fp);
fwrite(&boxzhi,sizeof(double),1,fp);
fwrite(&boxxy,sizeof(double),1,fp);
fwrite(&boxxz,sizeof(double),1,fp);
fwrite(&boxyz,sizeof(double),1,fp);
fwrite(&size_one,sizeof(int),1,fp);
if (multiproc) {
int one = 1;
fwrite(&one,sizeof(int),1,fp);
} else fwrite(&nprocs,sizeof(int),1,fp);
}
/* ---------------------------------------------------------------------- */
void DumpAtom::header_item(int ndump) void DumpAtom::header_item(int ndump)
{ {
fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,"ITEM: TIMESTEP\n");
@ -171,7 +212,22 @@ void DumpAtom::header_item(int ndump)
fprintf(fp,"%g %g\n",boxxlo,boxxhi); fprintf(fp,"%g %g\n",boxxlo,boxxhi);
fprintf(fp,"%g %g\n",boxylo,boxyhi); fprintf(fp,"%g %g\n",boxylo,boxyhi);
fprintf(fp,"%g %g\n",boxzlo,boxzhi); fprintf(fp,"%g %g\n",boxzlo,boxzhi);
fprintf(fp,"ITEM: ATOMS\n"); fprintf(fp,"ITEM: ATOMS %s\n",columns);
}
/* ---------------------------------------------------------------------- */
void DumpAtom::header_item_triclinic(int ndump)
{
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
fprintf(fp,"%d\n",ndump);
fprintf(fp,"ITEM: BOX BOUNDS xy xz yz\n");
fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz);
fprintf(fp,"%g %g %g\n",boxzlo,boxzhi,boxyz);
fprintf(fp,"ITEM: ATOMS %s\n",columns);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -27,6 +27,8 @@ class DumpAtom : public Dump {
int scale_flag; // 1 if atom coords are scaled, 0 if no int scale_flag; // 1 if atom coords are scaled, 0 if no
int image_flag; // 1 if append box count to atom coords, 0 if no int image_flag; // 1 if append box count to atom coords, 0 if no
char *columns; // column labels
int modify_param(int, char **); int modify_param(int, char **);
void write_header(int); void write_header(int);
int count(); int count();
@ -36,7 +38,9 @@ class DumpAtom : public Dump {
typedef void (DumpAtom::*FnPtrHeader)(int); typedef void (DumpAtom::*FnPtrHeader)(int);
FnPtrHeader header_choice; // ptr to write header functions FnPtrHeader header_choice; // ptr to write header functions
void header_binary(int); void header_binary(int);
void header_binary_triclinic(int);
void header_item(int); void header_item(int);
void header_item_triclinic(int);
typedef int (DumpAtom::*FnPtrPack)(); typedef int (DumpAtom::*FnPtrPack)();
FnPtrPack pack_choice; // ptr to pack functions FnPtrPack pack_choice; // ptr to pack functions

View File

@ -61,7 +61,7 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
thresh_op = NULL; thresh_op = NULL;
thresh_value = NULL; thresh_value = NULL;
// compute, fix, variables the dump accesses // computes, fixes, variables which the dump accesses
field2index = (int *) memory->smalloc(nfield*sizeof(int),"dump:field2index"); field2index = (int *) memory->smalloc(nfield*sizeof(int),"dump:field2index");
argindex = (int *) memory->smalloc(nfield*sizeof(int),"dump:argindex"); argindex = (int *) memory->smalloc(nfield*sizeof(int),"dump:argindex");
@ -102,6 +102,17 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
vformat[i] = NULL; vformat[i] = NULL;
} }
// setup column string
int n = 0;
for (int iarg = 5; iarg < narg; iarg++) n += strlen(arg[iarg]) + 2;
columns = new char[n];
columns[0] = '\0';
for (int iarg = 5; iarg < narg; iarg++) {
strcat(columns,arg[iarg]);
strcat(columns," ");
}
// one-time file open // one-time file open
if (multifile == 0) openfile(); if (multifile == 0) openfile();
@ -140,6 +151,8 @@ DumpCustom::~DumpCustom()
for (int i = 0; i < size_one; i++) delete [] vformat[i]; for (int i = 0; i < size_one; i++) delete [] vformat[i];
delete [] vformat; delete [] vformat;
delete [] columns;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -169,8 +182,14 @@ void DumpCustom::init()
// setup function ptrs // setup function ptrs
if (binary) header_choice = &DumpCustom::header_binary; if (binary && domain->triclinic == 0)
else header_choice = &DumpCustom::header_item; header_choice = &DumpCustom::header_binary;
else if (binary && domain->triclinic == 1)
header_choice = &DumpCustom::header_binary_triclinic;
else if (!binary && domain->triclinic == 0)
header_choice = &DumpCustom::header_item;
else if (!binary && domain->triclinic == 1)
header_choice = &DumpCustom::header_item_triclinic;
if (binary) write_choice = &DumpCustom::write_binary; if (binary) write_choice = &DumpCustom::write_binary;
else write_choice = &DumpCustom::write_text; else write_choice = &DumpCustom::write_text;
@ -215,6 +234,7 @@ void DumpCustom::header_binary(int ndump)
{ {
fwrite(&update->ntimestep,sizeof(int),1,fp); fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp); fwrite(&ndump,sizeof(int),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp); fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp); fwrite(&boxxhi,sizeof(double),1,fp);
fwrite(&boxylo,sizeof(double),1,fp); fwrite(&boxylo,sizeof(double),1,fp);
@ -230,6 +250,29 @@ void DumpCustom::header_binary(int ndump)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void DumpCustom::header_binary_triclinic(int ndump)
{
fwrite(&update->ntimestep,sizeof(int),1,fp);
fwrite(&ndump,sizeof(int),1,fp);
fwrite(&domain->triclinic,sizeof(int),1,fp);
fwrite(&boxxlo,sizeof(double),1,fp);
fwrite(&boxxhi,sizeof(double),1,fp);
fwrite(&boxylo,sizeof(double),1,fp);
fwrite(&boxyhi,sizeof(double),1,fp);
fwrite(&boxzlo,sizeof(double),1,fp);
fwrite(&boxzhi,sizeof(double),1,fp);
fwrite(&boxxy,sizeof(double),1,fp);
fwrite(&boxxz,sizeof(double),1,fp);
fwrite(&boxyz,sizeof(double),1,fp);
fwrite(&size_one,sizeof(int),1,fp);
if (multiproc) {
int one = 1;
fwrite(&one,sizeof(int),1,fp);
} else fwrite(&nprocs,sizeof(int),1,fp);
}
/* ---------------------------------------------------------------------- */
void DumpCustom::header_item(int ndump) void DumpCustom::header_item(int ndump)
{ {
fprintf(fp,"ITEM: TIMESTEP\n"); fprintf(fp,"ITEM: TIMESTEP\n");
@ -240,7 +283,22 @@ void DumpCustom::header_item(int ndump)
fprintf(fp,"%g %g\n",boxxlo,boxxhi); fprintf(fp,"%g %g\n",boxxlo,boxxhi);
fprintf(fp,"%g %g\n",boxylo,boxyhi); fprintf(fp,"%g %g\n",boxylo,boxyhi);
fprintf(fp,"%g %g\n",boxzlo,boxzhi); fprintf(fp,"%g %g\n",boxzlo,boxzhi);
fprintf(fp,"ITEM: ATOMS\n"); fprintf(fp,"ITEM: ATOMS %s\n",columns);
}
/* ---------------------------------------------------------------------- */
void DumpCustom::header_item_triclinic(int ndump)
{
fprintf(fp,"ITEM: TIMESTEP\n");
fprintf(fp,"%d\n",update->ntimestep);
fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
fprintf(fp,"%d\n",ndump);
fprintf(fp,"ITEM: BOX BOUNDS xy xz yz\n");
fprintf(fp,"%g %g %g\n",boxxlo,boxxhi,boxxy);
fprintf(fp,"%g %g %g\n",boxylo,boxyhi,boxxz);
fprintf(fp,"%g %g %g\n",boxzlo,boxzhi,boxyz);
fprintf(fp,"ITEM: ATOMS %s\n",columns);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -37,6 +37,8 @@ class DumpCustom : public Dump {
int *vtype; // type of each vector (INT, DOUBLE) int *vtype; // type of each vector (INT, DOUBLE)
char **vformat; // format string for each vector element char **vformat; // format string for each vector element
char *columns; // column labels
int maxlocal; // size of atom selection and variable arrays int maxlocal; // size of atom selection and variable arrays
int *choose; // 1 if output this atom, 0 if no int *choose; // 1 if output this atom, 0 if no
double *dchoose; // value for each atom to threshhold against double *dchoose; // value for each atom to threshhold against
@ -76,7 +78,9 @@ class DumpCustom : public Dump {
typedef void (DumpCustom::*FnPtrHeader)(int); typedef void (DumpCustom::*FnPtrHeader)(int);
FnPtrHeader header_choice; // ptr to write header functions FnPtrHeader header_choice; // ptr to write header functions
void header_binary(int); void header_binary(int);
void header_binary_triclinic(int);
void header_item(int); void header_item(int);
void header_item_triclinic(int);
typedef void (DumpCustom::*FnPtrData)(int, double *); typedef void (DumpCustom::*FnPtrData)(int, double *);
FnPtrData write_choice; // ptr to write data functions FnPtrData write_choice; // ptr to write data functions

View File

@ -84,7 +84,7 @@ void Group::assign(int narg, char **arg)
if (narg < 2) error->all("Illegal group command"); if (narg < 2) error->all("Illegal group command");
// find group in existing list // find group in existing list
// igroup = -1 is a new group name, add it // igroup = -1 requires a new group, add it
int igroup = find(arg[0]); int igroup = find(arg[0]);
@ -329,7 +329,7 @@ void Group::create(char *name, int *flag)
int i; int i;
// find group in existing list // find group in existing list
// igroup = -1 is a new group name, add it // igroup = -1 requires a new group, add it
int igroup = find(name); int igroup = find(name);