diff --git a/src/dump.cpp b/src/dump.cpp index 1114624552..dc81b24252 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -135,6 +135,9 @@ void Dump::write() boxyhi = domain->boxhi_bound[1]; boxzlo = domain->boxlo_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 diff --git a/src/dump.h b/src/dump.h index 80a9b7a9d7..7e6bdc8ce0 100644 --- a/src/dump.h +++ b/src/dump.h @@ -52,8 +52,9 @@ class Dump : protected Pointers { protected: 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 boxxy,boxxz,boxyz; virtual void openfile(); virtual int modify_param(int, char **) {return 0;} diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 0f71b58efd..c5c03e2050 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -61,10 +61,27 @@ void DumpAtom::init() 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 - if (binary) header_choice = &DumpAtom::header_binary; - else header_choice = &DumpAtom::header_item; + if (binary && domain->triclinic == 0) + 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) pack_choice = &DumpAtom::pack_scale_noimage; @@ -146,6 +163,7 @@ void DumpAtom::header_binary(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); @@ -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) { 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",boxylo,boxyhi); 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); } /* ---------------------------------------------------------------------- */ diff --git a/src/dump_atom.h b/src/dump_atom.h index 7d207cdfa2..56b6188e94 100644 --- a/src/dump_atom.h +++ b/src/dump_atom.h @@ -27,6 +27,8 @@ class DumpAtom : public Dump { 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 + char *columns; // column labels + int modify_param(int, char **); void write_header(int); int count(); @@ -36,7 +38,9 @@ class DumpAtom : public Dump { typedef void (DumpAtom::*FnPtrHeader)(int); FnPtrHeader header_choice; // ptr to write header functions void header_binary(int); + void header_binary_triclinic(int); void header_item(int); + void header_item_triclinic(int); typedef int (DumpAtom::*FnPtrPack)(); FnPtrPack pack_choice; // ptr to pack functions diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index ea6fecb596..a9068f151b 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -61,7 +61,7 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) : thresh_op = 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"); argindex = (int *) memory->smalloc(nfield*sizeof(int),"dump:argindex"); @@ -102,6 +102,17 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) : 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 if (multifile == 0) openfile(); @@ -140,6 +151,8 @@ DumpCustom::~DumpCustom() for (int i = 0; i < size_one; i++) delete [] vformat[i]; delete [] vformat; + + delete [] columns; } /* ---------------------------------------------------------------------- */ @@ -169,8 +182,14 @@ void DumpCustom::init() // setup function ptrs - if (binary) header_choice = &DumpCustom::header_binary; - else header_choice = &DumpCustom::header_item; + if (binary && domain->triclinic == 0) + 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; else write_choice = &DumpCustom::write_text; @@ -215,6 +234,7 @@ void DumpCustom::header_binary(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); @@ -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) { 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",boxylo,boxyhi); 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); } /* ---------------------------------------------------------------------- */ diff --git a/src/dump_custom.h b/src/dump_custom.h index 5398a41132..2988fe2717 100644 --- a/src/dump_custom.h +++ b/src/dump_custom.h @@ -37,6 +37,8 @@ class DumpCustom : public Dump { int *vtype; // type of each vector (INT, DOUBLE) char **vformat; // format string for each vector element + char *columns; // column labels + int maxlocal; // size of atom selection and variable arrays int *choose; // 1 if output this atom, 0 if no double *dchoose; // value for each atom to threshhold against @@ -76,7 +78,9 @@ class DumpCustom : public Dump { typedef void (DumpCustom::*FnPtrHeader)(int); FnPtrHeader header_choice; // ptr to write header functions void header_binary(int); + void header_binary_triclinic(int); void header_item(int); + void header_item_triclinic(int); typedef void (DumpCustom::*FnPtrData)(int, double *); FnPtrData write_choice; // ptr to write data functions diff --git a/src/group.cpp b/src/group.cpp index 42b392be4b..0b8196e08d 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -84,7 +84,7 @@ void Group::assign(int narg, char **arg) if (narg < 2) error->all("Illegal group command"); // 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]); @@ -329,7 +329,7 @@ void Group::create(char *name, int *flag) int i; // 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);