Skip to content
Snippets Groups Projects
Commit 1fc093a9 authored by Carlo Camilloni's avatar Carlo Camilloni
Browse files

Colvar: optimised for many CVS

parent c50585b7
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
along with plumed. If not, see <http://www.gnu.org/licenses/>. along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "Colvar.h" #include "Colvar.h"
#include "tools/OpenMP.h"
#include <vector> #include <vector>
#include <string> #include <string>
...@@ -64,9 +63,12 @@ void Colvar::apply(){ ...@@ -64,9 +63,12 @@ void Colvar::apply(){
} }
v.zero(); v.zero();
const unsigned stride=comm.Get_size();
const unsigned rank=comm.Get_rank();
if(!isEnergy){ if(!isEnergy){
for(int i=0;i<getNumberOfComponents();++i){ for(int i=rank;i<getNumberOfComponents();i+=stride){
if( getPntrToComponent(i)->applyForce( forces ) ){ if(getPntrToComponent(i)->applyForce( forces )){
for(unsigned j=0;j<nat;++j){ for(unsigned j=0;j<nat;++j){
f[j][0]+=forces[3*j+0]; f[j][0]+=forces[3*j+0];
f[j][1]+=forces[3*j+1]; f[j][1]+=forces[3*j+1];
...@@ -81,8 +83,11 @@ void Colvar::apply(){ ...@@ -81,8 +83,11 @@ void Colvar::apply(){
v(2,0)+=forces[3*nat+6]; v(2,0)+=forces[3*nat+6];
v(2,1)+=forces[3*nat+7]; v(2,1)+=forces[3*nat+7];
v(2,2)+=forces[3*nat+8]; v(2,2)+=forces[3*nat+8];
} }
} }
comm.Sum(&f[0][0],3*nat);
comm.Sum(&v[0][0],9);
} else if( isEnergy ){ } else if( isEnergy ){
forces.resize(1); forces.resize(1);
if( getPntrToComponent(0)->applyForce( forces ) ) modifyForceOnEnergy()+=forces[0]; if( getPntrToComponent(0)->applyForce( forces ) ) modifyForceOnEnergy()+=forces[0];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment