From 6dbd12107376c389f2f50d21750c5b2325bf6cec Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 10 Aug 2012 15:06:10 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8591 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/compute_property_local.cpp | 68 ++++++++++++++++++++++++++++++++-- src/compute_property_local.h | 2 + src/thermo.cpp | 54 ++++++++++++++++++--------- 3 files changed, 102 insertions(+), 22 deletions(-) diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp index 32787313ef..c9dff6d999 100644 --- a/src/compute_property_local.cpp +++ b/src/compute_property_local.cpp @@ -62,6 +62,18 @@ ComputePropertyLocal::ComputePropertyLocal(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, "Compute property/local cannot use these inputs together"); kindflag = NEIGH; + } else if (strcmp(arg[iarg],"ntype1") == 0) { + pack_choice[i] = &ComputePropertyLocal::pack_ptype1; + if (kindflag != NONE && kindflag != NEIGH) + error->all(FLERR, + "Compute property/local cannot use these inputs together"); + kindflag = NEIGH; + } else if (strcmp(arg[iarg],"ntype2") == 0) { + pack_choice[i] = &ComputePropertyLocal::pack_ptype2; + if (kindflag != NONE && kindflag != NEIGH) + error->all(FLERR, + "Compute property/local cannot use these inputs together"); + kindflag = NEIGH; } else if (strcmp(arg[iarg],"patom1") == 0) { pack_choice[i] = &ComputePropertyLocal::pack_patom1; @@ -75,6 +87,18 @@ ComputePropertyLocal::ComputePropertyLocal(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR, "Compute property/local cannot use these inputs together"); kindflag = PAIR; + } else if (strcmp(arg[iarg],"ptype1") == 0) { + pack_choice[i] = &ComputePropertyLocal::pack_ptype1; + if (kindflag != NONE && kindflag != PAIR) + error->all(FLERR, + "Compute property/local cannot use these inputs together"); + kindflag = PAIR; + } else if (strcmp(arg[iarg],"ptype2") == 0) { + pack_choice[i] = &ComputePropertyLocal::pack_ptype2; + if (kindflag != NONE && kindflag != PAIR) + error->all(FLERR, + "Compute property/local cannot use these inputs together"); + kindflag = PAIR; } else if (strcmp(arg[iarg],"batom1") == 0) { pack_choice[i] = &ComputePropertyLocal::pack_batom1; @@ -359,8 +383,8 @@ int ComputePropertyLocal::count_pairs(int allflag, int forceflag) if (forceflag && rsq >= cutsq[itype][jtype]) continue; if (allflag) { - indices[m][0] = tag[i]; - indices[m][1] = tag[j]; + indices[m][0] = i; + indices[m][1] = j; } m++; } @@ -582,8 +606,12 @@ double ComputePropertyLocal::memory_usage() void ComputePropertyLocal::pack_patom1(int n) { + int i; + int *tag = atom->tag; + for (int m = 0; m < ncount; m++) { - buf[n] = indices[m][0]; + i = indices[m][0]; + buf[n] = tag[i]; n += nvalues; } } @@ -592,8 +620,40 @@ void ComputePropertyLocal::pack_patom1(int n) void ComputePropertyLocal::pack_patom2(int n) { + int i; + int *tag = atom->tag; + for (int m = 0; m < ncount; m++) { - buf[n] = indices[m][1]; + i = indices[m][1]; + buf[n] = tag[i]; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputePropertyLocal::pack_ptype1(int n) +{ + int i; + int *type = atom->type; + + for (int m = 0; m < ncount; m++) { + i = indices[m][0]; + buf[n] = type[i]; + n += nvalues; + } +} + +/* ---------------------------------------------------------------------- */ + +void ComputePropertyLocal::pack_ptype2(int n) +{ + int i; + int *type = atom->type; + + for (int m = 0; m < ncount; m++) { + i = indices[m][0]; + buf[n] = type[i]; n += nvalues; } } diff --git a/src/compute_property_local.h b/src/compute_property_local.h index eab19768f6..fe52ab8488 100644 --- a/src/compute_property_local.h +++ b/src/compute_property_local.h @@ -58,6 +58,8 @@ class ComputePropertyLocal : public Compute { void pack_patom1(int); void pack_patom2(int); + void pack_ptype1(int); + void pack_ptype2(int); void pack_batom1(int); void pack_batom2(int); diff --git a/src/thermo.cpp b/src/thermo.cpp index 52d87e19ad..aeb9f17b40 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -966,13 +966,15 @@ int Thermo::evaluate_keyword(char *word, double *answer) } else if (strcmp(word,"elapsed") == 0) { if (update->whichflag == 0) - error->all(FLERR,"This variable thermo keyword cannot be used between runs"); + error->all(FLERR, + "This variable thermo keyword cannot be used between runs"); compute_elapsed(); dvalue = bivalue; } else if (strcmp(word,"elaplong") == 0) { if (update->whichflag == 0) - error->all(FLERR,"This variable thermo keyword cannot be used between runs"); + error->all(FLERR, + "This variable thermo keyword cannot be used between runs"); compute_elapsed_long(); dvalue = bivalue; @@ -981,17 +983,20 @@ int Thermo::evaluate_keyword(char *word, double *answer) } else if (strcmp(word,"cpu") == 0) { if (update->whichflag == 0) - error->all(FLERR,"This variable thermo keyword cannot be used between runs"); + error->all(FLERR, + "This variable thermo keyword cannot be used between runs"); compute_cpu(); } else if (strcmp(word,"tpcpu") == 0) { if (update->whichflag == 0) - error->all(FLERR,"This variable thermo keyword cannot be used between runs"); + error->all(FLERR, + "This variable thermo keyword cannot be used between runs"); compute_tpcpu(); } else if (strcmp(word,"spcpu") == 0) { if (update->whichflag == 0) - error->all(FLERR,"This variable thermo keyword cannot be used between runs"); + error->all(FLERR, + "This variable thermo keyword cannot be used between runs"); compute_spcpu(); } else if (strcmp(word,"atoms") == 0) { @@ -1028,7 +1033,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) } else if (strcmp(word,"pe") == 0) { if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); if (update->whichflag == 0) { if (pe->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " @@ -1055,7 +1061,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) } else if (strcmp(word,"etotal") == 0) { if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); if (update->whichflag == 0) { if (pe->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " @@ -1079,7 +1086,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) } else if (strcmp(word,"enthalpy") == 0) { if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); if (update->whichflag == 0) { if (pe->invoked_scalar != update->ntimestep) error->all(FLERR,"Compute used in variable thermo keyword between runs " @@ -1116,7 +1124,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_evdwl(); @@ -1124,7 +1133,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_ecoul(); @@ -1132,7 +1142,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_epair(); @@ -1140,7 +1151,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_ebond(); @@ -1148,7 +1160,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_eangle(); @@ -1156,7 +1169,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_edihed(); @@ -1164,7 +1178,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_eimp(); @@ -1172,7 +1187,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_emol(); @@ -1180,7 +1196,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_elong(); @@ -1188,7 +1205,8 @@ int Thermo::evaluate_keyword(char *word, double *answer) if (update->eflag_global != update->ntimestep) error->all(FLERR,"Energy was not tallied on needed timestep"); if (!pe) - error->all(FLERR,"Thermo keyword in variable requires thermo to use/init pe"); + error->all(FLERR, + "Thermo keyword in variable requires thermo to use/init pe"); pe->invoked_flag |= INVOKED_SCALAR; compute_etail();