diff --git a/src/multicolvar/WillardChandlerSurface.cpp b/src/multicolvar/WillardChandlerSurface.cpp index 1372cec0e8d3ceb91fe80bdbd8b21a1678f55cb8..96bea6080bd8e1f044eb60cc1cfd12e47375762b 100644 --- a/src/multicolvar/WillardChandlerSurface.cpp +++ b/src/multicolvar/WillardChandlerSurface.cpp @@ -176,7 +176,9 @@ void WillardChandlerSurface::update(){ plumed_dbg_assert( stash ); std::vector<double> cvals( mycolv->getNumberOfQuantities() ); Vector origin = getPosition(0); std::vector<double> pp( 3 ); Vector fpos; - for(unsigned i=0;i<mycolv->getFullNumberOfTasks();++i){ + unsigned rank=comm.Get_rank(), size=comm.Get_size(); + + for(unsigned i=rank;i<mycolv->getFullNumberOfTasks();i+=size){ stash->retrieveValue( i, false, cvals ); Vector apos = pbcDistance( mycolv->getCentralAtomPos( mycolv->getTaskCode(i) ), origin ); @@ -186,6 +188,8 @@ void WillardChandlerSurface::update(){ KernelFunctions kernel( pp, bw, kerneltype, false, cvals[0]*cvals[1], true ); gg.addKernel( kernel ); } + gg.mpiSumValuesAndDerivatives( comm ); + unsigned npoints=0; std::vector<std::vector<double> > contour_points; gg.findSetOfPointsOnContour( contour, npoints, contour_points ); if(npoints==0 ) warning("found no points on Willard-Chandler surface try changing the CONTOUR parameter"); diff --git a/src/tools/Grid.cpp b/src/tools/Grid.cpp index 0a8bb36d887dd686cdac6511bb41cb3ebadfe776..92b19517af653637a0a292ff334e4493c5bd516e 100644 --- a/src/tools/Grid.cpp +++ b/src/tools/Grid.cpp @@ -33,6 +33,7 @@ #include "Exception.h" #include "KernelFunctions.h" #include "MinimiseBase.h" +#include "Communicator.h" using namespace std; namespace PLMD{ @@ -939,4 +940,8 @@ double Grid::integrate( std::vector<unsigned>& npoints ){ return box_vol*integral; } +void Grid::mpiSumValuesAndDerivatives( Communicator& comm ){ + comm.Sum( grid_ ); for(unsigned i=0;i<der_.size();++i) comm.Sum( der_[i] ); +} + } diff --git a/src/tools/Grid.h b/src/tools/Grid.h index 7c0afe7c0058a36eea25f802837fb1d9cd56dc6e..8d3e4d4180a5c8766efc6e2b41fa3db5c616cc3c 100644 --- a/src/tools/Grid.h +++ b/src/tools/Grid.h @@ -64,6 +64,7 @@ class Value; class IFile; class OFile; class KernelFunctions; +class Communicator; /// \ingroup TOOLBOX class Grid @@ -211,6 +212,8 @@ public: void setOutputFmt(std::string ss){fmt_=ss;} /// Integrate the function calculated on the grid double integrate( std::vector<unsigned>& npoints ); +/// + void mpiSumValuesAndDerivatives( Communicator& comm ); };