diff --git a/src/analysis/Histogram.cpp b/src/analysis/Histogram.cpp index d2519e7f9038791fd88e342a42b7b453a353d3ec..73fde2065fadce288298156a25d0b2d46ec22c32 100644 --- a/src/analysis/Histogram.cpp +++ b/src/analysis/Histogram.cpp @@ -208,6 +208,7 @@ void Histogram::performTask( const unsigned& task_index, const unsigned& current } void Histogram::performAnalysis(){ + if( mygrid->wasreset() ) mygrid->clear(); runAllTasks(); mygrid->setNorm( getNormalization() ); } diff --git a/src/gridtools/ConvertToFES.cpp b/src/gridtools/ConvertToFES.cpp index eef7fd498bfe4980db74c9b701daee30f1cf7840..0d7ce6d8ba6b8f189e0bce2ee3c60f8246a3ba03 100644 --- a/src/gridtools/ConvertToFES.cpp +++ b/src/gridtools/ConvertToFES.cpp @@ -81,7 +81,7 @@ unsigned ConvertToFES::getNumberOfQuantities() const { } void ConvertToFES::performOperationsWithGrid( const bool& from_update ){ - outgrid->clear(); runAllTasks(); + outgrid->clear(); runAllTasks(); outgrid->reset(); } void ConvertToFES::performTask( const unsigned& task_index, const unsigned& current, MultiValue& myvals ) const { diff --git a/src/gridtools/FindContour.cpp b/src/gridtools/FindContour.cpp index ba1238444135c435ddf8d8ba5ad49631e7b6e502..889f757e5fc8fb088b94aff6d8d22beaa40451af 100644 --- a/src/gridtools/FindContour.cpp +++ b/src/gridtools/FindContour.cpp @@ -143,7 +143,7 @@ void FindContour::performOperationsWithGrid( const bool& from_update ){ contour_points[npoints].resize( mygrid->getDimension() ); mygrid->getGridPointCoordinates( i, contour_points[npoints] ); // Setup direction vector - direction[j]=0.9999*dx[j]; + direction[j]=0.999999999*dx[j]; // And do proper search for contour point mymin.linesearch( direction, contour_points[npoints], &FindContour::getDifferenceFromContour ); direction[j]=0.0; npoints++; @@ -154,7 +154,7 @@ void FindContour::performOperationsWithGrid( const bool& from_update ){ } // Clear the grid ready for next time - if( from_update ) mygrid->clear(); + if( from_update ) mygrid->reset(); of.printf("%u\n",npoints); of.printf("Points found on isocontour\n"); diff --git a/src/gridtools/GridVessel.cpp b/src/gridtools/GridVessel.cpp index 2b3fb435414f849c5b94bad3a48f279929f2bf08..6c3b498b0568aeb921474f3e794fe2745608d9ec 100644 --- a/src/gridtools/GridVessel.cpp +++ b/src/gridtools/GridVessel.cpp @@ -266,9 +266,13 @@ void GridVessel::getNeighbors( const std::vector<double>& pp, const std::vector< } } -void GridVessel::clear(){ +void GridVessel::reset(){ if( !nomemory ) return ; wascleared=true; +} + +void GridVessel::clear(){ + plumed_assert( wascleared ); data.assign( data.size(), 0.0 ); } diff --git a/src/gridtools/GridVessel.h b/src/gridtools/GridVessel.h index f18680b180d403438e0c879baf7657b63e6a00c5..cdc74eac6dcf49ffc847a16da36ad1854dcffa45 100644 --- a/src/gridtools/GridVessel.h +++ b/src/gridtools/GridVessel.h @@ -135,6 +135,8 @@ public: double getGridExtent( const unsigned& i ) const ; /// Clear all the data stored on the grid virtual void clear(); +/// Reset the grid so that it is cleared at start of next time it is calculated + void reset(); /// This ensures that Gaussian cube fies are in correct units void setCubeUnits( const double& units ); /// This ensures that Gaussian cube files are in correct units diff --git a/src/gridtools/PrintCube.cpp b/src/gridtools/PrintCube.cpp index f4955a9f5d38b689828bf1d22020c740522df74a..09b216818b265f55dd943ff46257f948eb279c75 100644 --- a/src/gridtools/PrintCube.cpp +++ b/src/gridtools/PrintCube.cpp @@ -90,7 +90,7 @@ void PrintCube::performOperationsWithGrid( const bool& from_update ){ ofile.close(); // Clear the grid ready for next time - if( from_update ) mygrid->clear(); + if( from_update ) mygrid->reset(); } } diff --git a/src/gridtools/PrintGrid.cpp b/src/gridtools/PrintGrid.cpp index a1ab192609945903b40dfa2bb9107df1b8dbe935..fde1633362b03f2a6208217a73d785c7b0205947 100644 --- a/src/gridtools/PrintGrid.cpp +++ b/src/gridtools/PrintGrid.cpp @@ -98,7 +98,7 @@ void PrintGrid::performOperationsWithGrid( const bool& from_update ){ ofile.close(); // Clear the grid ready for next time - if( from_update ) mygrid->clear(); + if( from_update ) mygrid->reset(); } } diff --git a/src/multicolvar/MultiColvarDensity.cpp b/src/multicolvar/MultiColvarDensity.cpp index 9d731faf63a1d686a3aaa582b7e70ae720fce701..d76188970c67ae1af17ba1e4139dde0c2a4f64c0 100644 --- a/src/multicolvar/MultiColvarDensity.cpp +++ b/src/multicolvar/MultiColvarDensity.cpp @@ -202,12 +202,7 @@ void MultiColvarDensity::update(){ } } for(unsigned i=0;i<directions.size();++i){ Tools::convert(min[i],gmin[i]); Tools::convert(max[i],gmax[i]); } - - if( plumed.getRestart() ){ - error("restarting of MultiColvarDensity is not yet implemented"); - } else { - mygrid->setBounds( gmin, gmax, nbins, gspacing ); resizeFunctions(); - } + mygrid->clear(); mygrid->setBounds( gmin, gmax, nbins, gspacing ); resizeFunctions(); } else { for(unsigned i=0;i<directions.size();++i){ double max; Tools::convert( mygrid->getMax()[i], max );