From 0f3c9e1e3d2bd198b5443ffa89e76f90ac4feeab Mon Sep 17 00:00:00 2001 From: sjplimp Date: Thu, 17 May 2012 17:40:45 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@8069 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/pair_hybrid.cpp | 23 +++++++++++++++++++---- src/pair_hybrid.h | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 73dd0709d5..00e530d5a2 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -206,7 +206,7 @@ void PairHybrid::settings(int narg, char **arg) build_styles(); - // allocate list of sub-styles as big as possibly needed + // allocate list of sub-styles as big as possibly needed if no extra args styles = new Pair*[narg]; keywords = new char*[narg]; @@ -214,6 +214,7 @@ void PairHybrid::settings(int narg, char **arg) // allocate each sub-style // call settings() with set of args that are not pair style names + // use known_style() to determine which args these are int iarg,jarg,dummy; @@ -235,12 +236,12 @@ void PairHybrid::settings(int narg, char **arg) nstyles++; } - // free allstyles + // free allstyles created by build_styles() for (int i = 0; i < nallstyles; i++) delete [] allstyles[i]; delete [] allstyles; - // multiple[i] = 1 to N if sub-style used multiple times, else 0 + // multiple[i] = 1 to M if sub-style used multiple times, else 0 for (int i = 0; i < nstyles; i++) { int count = 0; @@ -599,9 +600,12 @@ void PairHybrid::read_restart(FILE *fp) if (me == 0) fread(&nstyles,sizeof(int),1,fp); MPI_Bcast(&nstyles,1,MPI_INT,0,world); + // allocate list of sub-styles + styles = new Pair*[nstyles]; keywords = new char*[nstyles]; - + multiple = new int[nstyles]; + // each sub-style is created via new_pair() // each reads its settings, but no coeff info @@ -615,6 +619,17 @@ void PairHybrid::read_restart(FILE *fp) styles[m] = force->new_pair(keywords[m],lmp->suffix,dummy); styles[m]->read_restart_settings(fp); } + + // multiple[i] = 1 to M if sub-style used multiple times, else 0 + + for (int i = 0; i < nstyles; i++) { + int count = 0; + for (int j = 0; j < nstyles; j++) { + if (strcmp(keywords[j],keywords[i]) == 0) count++; + if (j == i) multiple[i] = count; + } + if (count == 1) multiple[i] = 0; + } } /* ---------------------------------------------------------------------- diff --git a/src/pair_hybrid.h b/src/pair_hybrid.h index 61a717e5db..78cd09a9d0 100644 --- a/src/pair_hybrid.h +++ b/src/pair_hybrid.h @@ -27,7 +27,7 @@ namespace LAMMPS_NS { class PairHybrid : public Pair { public: - int nstyles; // # of different sub-styles + int nstyles; // # of sub-styles Pair **styles; // list of Pair style classes char **keywords; // style name of each Pair style int *multiple; // 0 if style used once, else Mth instance