From 93115ad750234a5cb28792675cdf24503283f6e7 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 20 May 2011 15:44:23 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@6154 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/force.cpp | 36 +++++++++++++++++++++++++++++------- src/force.h | 4 ++-- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/force.cpp b/src/force.cpp index 8068717be5..867101dac4 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -117,32 +117,54 @@ void Force::init() create a pair style, called from input script or restart file ------------------------------------------------------------------------- */ -void Force::create_pair(const char *style) +void Force::create_pair(const char *style, char *suffix) { delete [] pair_style; if (pair) delete pair; - pair = new_pair(style); + pair = new_pair(style,suffix); int n = strlen(style) + 1; pair_style = new char[n]; strcpy(pair_style,style); } /* ---------------------------------------------------------------------- - generate a pair class + generate a pair class, first with suffix appended ------------------------------------------------------------------------- */ -Pair *Force::new_pair(const char *style) +Pair *Force::new_pair(const char *style, char *suffix) { - if (strcmp(style,"none") == 0) return NULL; + int success = 0; + + if (suffix) { + char estyle[256]; + sprintf(estyle,"%s/%s",style,suffix); + success = 1; + + if (0) return NULL; #define PAIR_CLASS #define PairStyle(key,Class) \ - else if (strcmp(style,#key) == 0) return new Class(lmp); + else if (strcmp(estyle,#key) == 0) return new Class(lmp); +#include "style_pair.h" +#undef PairStyle +#undef PAIR_CLASS + + else success = 0; + } + + if (!success) { + if (strcmp(style,"none") == 0) return NULL; + +#define PAIR_CLASS +#define PairStyle(key,Class) \ + else if (strcmp(style,#key) == 0) return new Class(lmp); #include "style_pair.h" #undef PAIR_CLASS - else error->all("Invalid pair style"); + else error->all("Invalid pair style"); + } + return NULL; } diff --git a/src/force.h b/src/force.h index ee6343db98..d8b4a20136 100644 --- a/src/force.h +++ b/src/force.h @@ -64,8 +64,8 @@ class Force : protected Pointers { ~Force(); void init(); - void create_pair(const char *); - class Pair *new_pair(const char *); + void create_pair(const char *, char *suffix = NULL); + class Pair *new_pair(const char *, char *suffix = NULL); class Pair *pair_match(const char *, int); void create_bond(const char *);