From f4d2ebfb545db98633306ec3efb49000be4a2095 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Fri, 20 May 2011 15:40:22 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@6153 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/modify.cpp | 67 +++++++++++++++++++++++++++++++++++++++++--------- src/modify.h | 8 +++--- 2 files changed, 60 insertions(+), 15 deletions(-) diff --git a/src/modify.cpp b/src/modify.cpp index 329cd268a2..514341fc17 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -591,7 +591,7 @@ int Modify::min_reset_ref() add a new fix or replace one with same ID ------------------------------------------------------------------------- */ -void Modify::add_fix(int narg, char **arg) +void Modify::add_fix(int narg, char **arg, char *suffix) { if (domain->box_exist == 0) error->all("Fix command before simulation box is defined"); @@ -636,17 +636,39 @@ void Modify::add_fix(int narg, char **arg) } } - // create the Fix + // create the Fix, first with suffix appended - if (0) return; // dummy line to enable else-if macro expansion + int success = 0; + + if (suffix) { + char estyle[256]; + sprintf(estyle,"%s/%s",arg[2],suffix); + success = 1; + + if (0) return; #define FIX_CLASS #define FixStyle(key,Class) \ - else if (strcmp(arg[2],#key) == 0) fix[ifix] = new Class(lmp,narg,arg); + else if (strcmp(estyle,#key) == 0) fix[ifix] = new Class(lmp,narg,arg); #include "style_fix.h" +#undef FixStyle #undef FIX_CLASS - else error->all("Invalid fix style"); + else success = 0; + } + + if (!success) { + if (0) return; + +#define FIX_CLASS +#define FixStyle(key,Class) \ + else if (strcmp(arg[2],#key) == 0) fix[ifix] = new Class(lmp,narg,arg); +#include "style_fix.h" +#undef FixStyle +#undef FIX_CLASS + + else error->all("Invalid fix style"); + } // set fix mask values and increment nfix (if new) @@ -740,7 +762,7 @@ int Modify::find_fix(const char *id) add a new compute ------------------------------------------------------------------------- */ -void Modify::add_compute(int narg, char **arg) +void Modify::add_compute(int narg, char **arg, char *suffix) { if (narg < 3) error->all("Illegal compute command"); @@ -758,18 +780,41 @@ void Modify::add_compute(int narg, char **arg) memory->srealloc(compute,maxcompute*sizeof(Compute *),"modify:compute"); } - // create the Compute + // create the Compute, first with suffix appended - if (0) return; // dummy line to enable else-if macro expansion + int success = 0; + + if (suffix) { + char estyle[256]; + sprintf(estyle,"%s/%s",arg[2],suffix); + success = 1; + + if (0) return; #define COMPUTE_CLASS #define ComputeStyle(key,Class) \ - else if (strcmp(arg[2],#key) == 0) \ - compute[ncompute] = new Class(lmp,narg,arg); + else if (strcmp(estyle,#key) == 0) \ + compute[ncompute] = new Class(lmp,narg,arg); #include "style_compute.h" +#undef ComputeStyle #undef COMPUTE_CLASS - else error->all("Invalid compute style"); + else success = 0; + } + + if (!success) { + if (0) return; + +#define COMPUTE_CLASS +#define ComputeStyle(key,Class) \ + else if (strcmp(arg[2],#key) == 0) \ + compute[ncompute] = new Class(lmp,narg,arg); +#include "style_compute.h" +#undef ComputeStyle +#undef COMPUTE_CLASS + + else error->all("Invalid compute style"); + } ncompute++; } diff --git a/src/modify.h b/src/modify.h index 81d9401e69..fdd25b1045 100644 --- a/src/modify.h +++ b/src/modify.h @@ -40,7 +40,7 @@ class Modify : protected Pointers { class Compute **compute; Modify(class LAMMPS *); - ~Modify(); + virtual ~Modify(); void init(); void setup(int); void setup_pre_exchange(); @@ -79,12 +79,12 @@ class Modify : protected Pointers { double max_alpha(double *); int min_dof(); - void add_fix(int, char **); + void add_fix(int, char **, char *suffix = NULL); void modify_fix(int, char **); void delete_fix(const char *); int find_fix(const char *); - void add_compute(int, char **); + void add_compute(int, char **, char *suffix = NULL); void modify_compute(int, char **); void delete_compute(char *); int find_compute(char *); @@ -98,7 +98,7 @@ class Modify : protected Pointers { bigint memory_usage(); - private: + protected: // lists of fixes to apply at different stages of timestep