From afd1b872e9ada0ab040754f6025d617889d22d19 Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Fri, 2 Dec 2011 14:13:18 +0100 Subject: [PATCH] Added interface to Gromacs-like Replica EXchange I am starting to merge my GREX branch, which should be general enough to be used in any REX framework where coordinates are swapped (a-la-gromacs). Since GREX significantly modifies the MD-PLUMED interface through the addition of several new cmd(), I tried to encapsulate it as a separate objects with a cmd()-like interface. Commands from MD starting with GREX are automatically forwarded to that object. E.g. plumed_cmd(plumed,"GREX init",NULL); or so should initialize the GREX object, etc. Up to this point I just upload the interface, later on I will add the real GREX object, for which I still have to do some cleaning. --- src/PlumedMain.cpp | 9 ++++++++- src/PlumedMain.h | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PlumedMain.cpp b/src/PlumedMain.cpp index 3b7bcd4be..e3267f097 100644 --- a/src/PlumedMain.cpp +++ b/src/PlumedMain.cpp @@ -73,13 +73,17 @@ static class PlumedMainInitializer{ PlumedMain::PlumedMain(): initialized(false), + grex(NULL), log(comm), step(0), active(false), atoms(*this), actionSet((*this)), novirial(false) -{ +{} + +PlumedMain::~PlumedMain(){ + if(grex) delete grex; } ///////////////////////////////////////////////////////////// @@ -259,6 +263,9 @@ void PlumedMain::cmd(const std::string & word,void*val){ int check=0; if(actionRegister().check(words[1])) check=1; *(static_cast<int*>(val))=check; + } else if(nw==2 && words[0]=="GREX"){ + assert(grex); + grex->cmd(words[1],val); } else{ // error fprintf(stderr,"+++ PLUMED ERROR\n"); diff --git a/src/PlumedMain.h b/src/PlumedMain.h index 0b4a3835a..060800e18 100644 --- a/src/PlumedMain.h +++ b/src/PlumedMain.h @@ -47,6 +47,7 @@ public: PlumedCommunicator comm; private: + WithCmd* grex; /// Flag to avoid double initialization bool initialized; /// Name of MD engine @@ -91,7 +92,7 @@ public: /// and an MD engine, this is the right place /// Notice that this interface should always keep retro-compatibility void cmd(const std::string&key,void*val=NULL); - ~PlumedMain(){}; + ~PlumedMain(); /// Read an input file. /// \param str name of the file void readInputFile(std::string str); -- GitLab