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

This commit is contained in:
sjplimp
2013-04-03 17:59:23 +00:00
parent 80507c3612
commit 609226f8d0
4 changed files with 61 additions and 65 deletions

View File

@ -96,10 +96,13 @@ void AtomVec::write_vel(FILE *fp, int n, double **buf)
}
/* ----------------------------------------------------------------------
pack bond info for data file
pack bond info for data file into buf if non-NULL
return count of bonds from this proc
do not count/pack bonds with bondtype = 0
if bondtype is negative, flip back to positive
------------------------------------------------------------------------- */
void AtomVec::pack_bond(int **buf)
int AtomVec::pack_bond(int **buf)
{
int *tag = atom->tag;
int *num_bond = atom->num_bond;
@ -113,21 +116,29 @@ void AtomVec::pack_bond(int **buf)
if (newton_bond) {
for (i = 0; i < nlocal; i++)
for (j = 0; j < num_bond[i]; j++) {
buf[m][0] = bond_type[i][j];
if (bond_type[i][j] == 0) continue;
if (buf) {
buf[m][0] = MAX(bond_type[i][j],-bond_type[i][j]);
buf[m][1] = tag[i];
buf[m][2] = bond_atom[i][j];
}
m++;
}
} else {
for (i = 0; i < nlocal; i++)
for (j = 0; j < num_bond[i]; j++)
if (tag[i] < bond_atom[i][j]) {
buf[m][0] = bond_type[i][j];
if (bond_type[i][j] == 0) continue;
if (buf) {
buf[m][0] = MAX(bond_type[i][j],-bond_type[i][j]);
buf[m][1] = tag[i];
buf[m][2] = bond_atom[i][j];
}
m++;
}
}
return m;
}
/* ----------------------------------------------------------------------
@ -143,10 +154,13 @@ void AtomVec::write_bond(FILE *fp, int n, int **buf, int index)
}
/* ----------------------------------------------------------------------
pack angle info for data file
pack angle info for data file into buf if non-NULL
return count of angles from this proc
do not count/pack angles with angletype = 0
if angletype is negative, flip back to positive
------------------------------------------------------------------------- */
void AtomVec::pack_angle(int **buf)
int AtomVec::pack_angle(int **buf)
{
int *tag = atom->tag;
int *num_angle = atom->num_angle;
@ -162,23 +176,31 @@ void AtomVec::pack_angle(int **buf)
if (newton_bond) {
for (i = 0; i < nlocal; i++)
for (j = 0; j < num_angle[i]; j++) {
buf[m][0] = angle_type[i][j];
if (angle_type[i][j] == 0) continue;
if (buf) {
buf[m][0] = MAX(angle_type[i][j],-angle_type[i][j]);
buf[m][1] = angle_atom1[i][j];
buf[m][2] = angle_atom2[i][j];
buf[m][3] = angle_atom3[i][j];
}
m++;
}
} else {
for (i = 0; i < nlocal; i++)
for (j = 0; j < num_angle[i]; j++)
if (tag[i] == angle_atom2[i][j]) {
buf[m][0] = angle_type[i][j];
if (angle_type[i][j] == 0) continue;
if (buf) {
buf[m][0] = MAX(angle_type[i][j],-angle_type[i][j]);
buf[m][1] = angle_atom1[i][j];
buf[m][2] = angle_atom2[i][j];
buf[m][3] = angle_atom3[i][j];
}
m++;
}
}
return m;
}
/* ----------------------------------------------------------------------

View File

@ -98,9 +98,9 @@ class AtomVec : protected Pointers {
virtual void write_vel(FILE *, int, double **);
virtual int write_vel_hybrid(FILE *, double *) {return 0;}
void pack_bond(int **);
int pack_bond(int **);
void write_bond(FILE *, int, int **, int);
void pack_angle(int **);
int pack_angle(int **);
void write_angle(FILE *, int, int **, int);
void pack_dihedral(int **);
void write_dihedral(FILE *, int, int **, int);

View File

@ -112,6 +112,7 @@ void WriteData::write(char *file)
// if unequal and thermo lostflag is "error", don't write data file
bigint nblocal = atom->nlocal;
bigint natoms;
MPI_Allreduce(&nblocal,&natoms,1,MPI_LMP_BIGINT,MPI_SUM,world);
if (natoms != atom->natoms && output->thermo->lostflag == ERROR)
error->all(FLERR,"Atom count is inconsistent, cannot write data file");
@ -165,11 +166,17 @@ void WriteData::header()
fprintf(fp,"%d atom types\n",atom->ntypes);
if (atom->nbonds || atom->nbondtypes) {
fprintf(fp,BIGINT_FORMAT " bonds\n",atom->nbonds);
nbonds_local = atom->avec->pack_bond(NULL);
bigint nbonds;
MPI_Allreduce(&nbonds_local,&nbonds,1,MPI_LMP_BIGINT,MPI_SUM,world);
fprintf(fp,BIGINT_FORMAT " bonds\n",nbonds);
fprintf(fp,"%d bond types\n",atom->nbondtypes);
}
if (atom->nangles || atom->nangletypes) {
fprintf(fp,BIGINT_FORMAT " angles\n",atom->nangles);
nangles_local = atom->avec->pack_angle(NULL);
bigint nangles;
MPI_Allreduce(&nangles_local,&nangles,1,MPI_LMP_BIGINT,MPI_SUM,world);
fprintf(fp,BIGINT_FORMAT " angles\n",nangles);
fprintf(fp,"%d angle types\n",atom->nangletypes);
}
if (atom->ndihedrals || atom->ndihedraltypes) {
@ -214,19 +221,21 @@ void WriteData::force_fields()
fprintf(fp,"\nPair Coeffs\n\n");
force->pair->write_data(fp);
}
if (atom->avec->bonds_allow && force->bond) {
if (atom->avec->bonds_allow && force->bond && force->bond->writedata) {
fprintf(fp,"\nBond Coeffs\n\n");
force->bond->write_data(fp);
}
if (atom->avec->angles_allow && force->angle) {
if (atom->avec->angles_allow && force->angle && force->angle->writedata) {
fprintf(fp,"\nAngle Coeffs\n\n");
force->angle->write_data(fp);
}
if (atom->avec->dihedrals_allow && force->dihedral) {
if (atom->avec->dihedrals_allow && force->dihedral &&
force->dihedral->writedata) {
fprintf(fp,"\nDihedral Coeffs\n\n");
force->dihedral->write_data(fp);
}
if (atom->avec->impropers_allow && force->improper) {
if (atom->avec->impropers_allow && force->improper &&
force->improper->writedata) {
fprintf(fp,"\nImproper Coeffs\n\n");
force->improper->write_data(fp);
}
@ -343,27 +352,9 @@ void WriteData::velocities()
void WriteData::bonds()
{
// communication buffer for all my Bond info
// max_size = largest buffer needed by any proc
int ncol = 3;
int *tag = atom->tag;
int *num_bond = atom->num_bond;
int **bond_atom = atom->bond_atom;
int nlocal = atom->nlocal;
int newton_bond = force->newton_bond;
int i,j;
int sendrow = 0;
if (newton_bond) {
for (i = 0; i < nlocal; i++)
sendrow += num_bond[i];
} else {
for (i = 0; i < nlocal; i++)
for (j = 0; j < num_bond[i]; j++)
if (tag[i] < bond_atom[i][j]) sendrow++;
}
int sendrow = static_cast<int> (nbonds_local);
int maxrow;
MPI_Allreduce(&sendrow,&maxrow,1,MPI_INT,MPI_MAX,world);
@ -413,27 +404,9 @@ void WriteData::bonds()
void WriteData::angles()
{
// communication buffer for all my Angle info
// max_size = largest buffer needed by any proc
int ncol = 4;
int *tag = atom->tag;
int *num_angle = atom->num_angle;
int **angle_atom2 = atom->angle_atom2;
int nlocal = atom->nlocal;
int newton_bond = force->newton_bond;
int i,j;
int sendrow = 0;
if (newton_bond) {
for (i = 0; i < nlocal; i++)
sendrow += num_angle[i];
} else {
for (i = 0; i < nlocal; i++)
for (j = 0; j < num_angle[i]; j++)
if (tag[i] == angle_atom2[i][j]) sendrow++;
}
int sendrow = static_cast<int> (nangles_local);
int maxrow;
MPI_Allreduce(&sendrow,&maxrow,1,MPI_INT,MPI_MAX,world);

View File

@ -34,7 +34,8 @@ class WriteData : protected Pointers {
private:
int me,nprocs;
FILE *fp;
bigint natoms; // natoms (sum of nlocal) to write into file
bigint nbonds_local;
bigint nangles_local;
void header();
void type_arrays();