From 655daa0695767ab9940f053f5d3a22a83e48b5d5 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 9 Sep 2008 14:45:36 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@2105 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/dump_custom.cpp | 41 ++++++++++++++++++++++++++++++++++++++++- src/dump_custom.h | 1 + 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 74640721d5..775a52a0a9 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; // customize by adding keyword to 1st enum -enum{TAG,MOL,TYPE,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ, +enum{TAG,MOL,TYPE,MASS,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ, VX,VY,VZ,FX,FY,FZ, Q,MUX,MUY,MUZ,RADIUS,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ, QUATW,QUATI,QUATJ,QUATK,TQX,TQY,TQZ, @@ -339,6 +339,17 @@ int DumpCustom::count() for (i = 0; i < nlocal; i++) dchoose[i] = type[i]; ptr = dchoose; nstride = 1; + } else if (thresh_array[ithresh] == MASS) { + if (atom->mass) { + double *mass = atom->mass; + int *type = atom->type; + for (i = 0; i < nlocal; i++) dchoose[i] = mass[type[i]]; + ptr = dchoose; + nstride = 1; + } else { + ptr = atom->rmass; + nstride = 1; + } } else if (thresh_array[ithresh] == X) { ptr = &atom->x[0][0]; nstride = 3; @@ -658,6 +669,9 @@ void DumpCustom::parse_fields(int narg, char **arg) } else if (strcmp(arg[iarg],"type") == 0) { pack_choice[i] = &DumpCustom::pack_type; vtype[i] = INT; + } else if (strcmp(arg[iarg],"mass") == 0) { + pack_choice[i] = &DumpCustom::pack_mass; + vtype[i] = DOUBLE; } else if (strcmp(arg[iarg],"x") == 0) { pack_choice[i] = &DumpCustom::pack_x; @@ -1040,6 +1054,7 @@ int DumpCustom::modify_param(int narg, char **arg) if (strcmp(arg[1],"tag") == 0) thresh_array[nthresh] = TAG; else if (strcmp(arg[1],"mol") == 0) thresh_array[nthresh] = MOL; else if (strcmp(arg[1],"type") == 0) thresh_array[nthresh] = TYPE; + else if (strcmp(arg[1],"mass") == 0) thresh_array[nthresh] = MASS; else if (strcmp(arg[1],"x") == 0) thresh_array[nthresh] = X; else if (strcmp(arg[1],"y") == 0) thresh_array[nthresh] = Y; else if (strcmp(arg[1],"z") == 0) thresh_array[nthresh] = Z; @@ -1341,6 +1356,30 @@ void DumpCustom::pack_type(int n) /* ---------------------------------------------------------------------- */ +void DumpCustom::pack_mass(int n) +{ + int *type = atom->type; + double *mass = atom->mass; + double *rmass = atom->rmass; + int nlocal = atom->nlocal; + + if (mass) { + for (int i = 0; i < nlocal; i++) + if (choose[i]) { + buf[n] = mass[type[i]]; + n += size_one; + } + } else { + for (int i = 0; i < nlocal; i++) + if (choose[i]) { + buf[n] = rmass[i]; + n += size_one; + } + } +} + +/* ---------------------------------------------------------------------- */ + void DumpCustom::pack_x(int n) { double **x = atom->x; diff --git a/src/dump_custom.h b/src/dump_custom.h index 778d7d90b0..3d3243a88a 100644 --- a/src/dump_custom.h +++ b/src/dump_custom.h @@ -91,6 +91,7 @@ class DumpCustom : public Dump { void pack_tag(int); void pack_molecule(int); void pack_type(int); + void pack_mass(int); void pack_x(int); void pack_y(int); void pack_z(int);