From 1a143280ac58e84365652234473f7be33594f58d Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Thu, 3 Jan 2013 11:14:07 +0100
Subject: [PATCH] Small cleanup

Allow to better isolate the heavy part to be parallelized
---
 src/colvar/PathMSDBase.cpp | 21 +++++++++++----------
 src/colvar/PathMSDBase.h   |  1 -
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/colvar/PathMSDBase.cpp b/src/colvar/PathMSDBase.cpp
index 8aa380520..bb81dfd6e 100644
--- a/src/colvar/PathMSDBase.cpp
+++ b/src/colvar/PathMSDBase.cpp
@@ -97,25 +97,23 @@ void PathMSDBase::calculate(){
 
   //log.printf("NOW CALCULATE! \n");
 
-  // clean vectors
-  for(unsigned i=0;i< derivs_z.size();i++){derivs_z[i].zero();}
 
-  // full list: resize and calculate the msd 
+  // resize the list to full
   if(imgVec.empty()){ // this is the signal that means: recalculate all 
       imgVec.resize(nframes);  
-      derivs_v.clear();for(unsigned i=0;i<nframes;i++){derivs_v.push_back(derivs_z);}
       for(unsigned i=0;i<nframes;i++){
-          imgVec[i].distder=derivs_z;
           imgVec[i].property=indexvec[i];
           imgVec[i].index=i;
-          imgVec[i].distance=msdv[imgVec[i].index].calculate(getPositions(),imgVec[i].distder,true);
       }
-  }else{// just recalculate rmsd for the things you have in the list and assume that property and msdv are ok 
-	for(unsigned i=0;i<imgVec.size();i++){
-		imgVec[i].distance=msdv[imgVec[i].index].calculate(getPositions(),imgVec[i].distder,true);
-        }  
   }
 
+// THIS IS THE HEAVY PART (RMSD STUFF)
+// if imgVec.size() is less than nframes, it means that only some msd will be calculated
+  for(unsigned i=0;i<imgVec.size();i++){
+    imgVec[i].distance=msdv[imgVec[i].index].calculate(getPositions(),imgVec[i].distder,true);
+  }
+// END OF THE HEAVY PART
+
   vector<Value*> val_s_path;
   if(labels.size()>0){
     for(unsigned i=0;i<labels.size();i++){ val_s_path.push_back(getPntrToComponent(labels[i].c_str()));}
@@ -128,6 +126,9 @@ void PathMSDBase::calculate(){
   double partition=0.;
   double tmp;
 
+  // clean vector
+  for(unsigned i=0;i< derivs_z.size();i++){derivs_z[i].zero();}
+
   typedef  vector< class ImagePath  >::iterator imgiter;
   for(imgiter it=imgVec.begin();it!=imgVec.end();++it){ 
     (*it).similarity=exp(-lambda*((*it).distance));
diff --git a/src/colvar/PathMSDBase.h b/src/colvar/PathMSDBase.h
index 128b79073..748670722 100644
--- a/src/colvar/PathMSDBase.h
+++ b/src/colvar/PathMSDBase.h
@@ -69,7 +69,6 @@ class PathMSDBase : public Colvar {
   std::string reference;
   std::vector<Vector> derivs_s;
   std::vector<Vector> derivs_z;
-  std::vector< std::vector <Vector> > derivs_v;
   std::vector <ImagePath> imgVec; // this can be used for doing neighlist   
 protected:
   std::vector<PDB> pdbv;
-- 
GitLab