From bbaf00743c3cf3b35f3fda90199ab933057c3baf Mon Sep 17 00:00:00 2001 From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Mon, 18 Oct 2010 17:20:07 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@5060 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/compute_pair.cpp | 17 ++++++++++++++++- src/compute_pair.h | 3 ++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/compute_pair.cpp b/src/compute_pair.cpp index 2786af11fc..951df069ee 100644 --- a/src/compute_pair.cpp +++ b/src/compute_pair.cpp @@ -29,7 +29,11 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : if (narg != 4) error->all("Illegal compute pair command"); if (igroup) error->all("Compute pair must use group all"); - pair = force->pair_match(arg[3],1); + int n = strlen(arg[3]) + 1; + pstyle = new char[n]; + strcpy(pstyle,arg[3]); + + pair = force->pair_match(pstyle,1); if (!pair) error->all("Unrecognized pair style in compute pair command"); npair = pair->nextra; if (!npair) @@ -51,12 +55,23 @@ ComputePair::ComputePair(LAMMPS *lmp, int narg, char **arg) : ComputePair::~ComputePair() { + delete [] pstyle; delete [] one; delete [] vector; } /* ---------------------------------------------------------------------- */ +void ComputePair::init() +{ + // recheck for pair style in case it has been deleted + + pair = force->pair_match(pstyle,1); + if (!pair) error->all("Unrecognized pair style in compute pair command"); +} + +/* ---------------------------------------------------------------------- */ + void ComputePair::compute_vector() { invoked_vector = update->ntimestep; diff --git a/src/compute_pair.h b/src/compute_pair.h index 4c90bfa989..3d7d5dccfa 100644 --- a/src/compute_pair.h +++ b/src/compute_pair.h @@ -28,11 +28,12 @@ class ComputePair : public Compute { public: ComputePair(class LAMMPS *, int, char **); ~ComputePair(); - void init() {} + void init(); void compute_vector(); private: int npair; + char *pstyle; class Pair *pair; double *one; }; -- GitLab