Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / analysisdata / modules / histogram.cpp
index 72572d2d56b4aeb35b37a3d8c37da17bafc7015c..cc9c601e962dd34123bf9ca57a3ad5746f9e8c88 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -39,7 +39,9 @@
  * \author Teemu Murtola <teemu.murtola@gmail.com>
  * \ingroup module_analysisdata
  */
-#include "gromacs/analysisdata/modules/histogram.h"
+#include "gmxpre.h"
+
+#include "histogram.h"
 
 #include <cmath>
 
@@ -200,7 +202,7 @@ AnalysisHistogramSettings::findBin(real y) const
 namespace
 {
 
-/*! \internal \brief
+/*! \brief
  * Represents copies of average histograms.
  *
  * Methods in AbstractAverageHistogram that return new histogram instances
@@ -343,7 +345,10 @@ AbstractAverageHistogram::normalizeProbability()
         {
             sum += value(i, c).value();
         }
-        scaleSingle(c, 1.0 / (sum * xstep()));
+        if (sum > 0.0)
+        {
+            scaleSingle(c, 1.0 / (sum * xstep()));
+        }
     }
 }
 
@@ -390,7 +395,8 @@ AbstractAverageHistogram::scaleAllByVector(real factor[])
 namespace internal
 {
 
-/*! \internal \brief
+/*! \internal
+ * \brief
  * Implements average histogram module that averages per-frame histograms.
  *
  * This class is used for accumulating average histograms in per-frame
@@ -402,7 +408,7 @@ namespace internal
  * \ingroup module_analysisdata
  */
 class BasicAverageHistogramModule : public AbstractAverageHistogram,
-                                    public AnalysisDataModuleInterface
+                                    public AnalysisDataModuleSerial
 {
     public:
         BasicAverageHistogramModule();
@@ -631,8 +637,10 @@ AnalysisDataSimpleHistogramModule::flags() const
 }
 
 
-void
-AnalysisDataSimpleHistogramModule::dataStarted(AbstractAnalysisData *data)
+bool
+AnalysisDataSimpleHistogramModule::parallelDataStarted(
+        AbstractAnalysisData              *data,
+        const AnalysisDataParallelOptions &options)
 {
     addModule(impl_->averager_);
     setDataSetCount(data->dataSetCount());
@@ -640,7 +648,8 @@ AnalysisDataSimpleHistogramModule::dataStarted(AbstractAnalysisData *data)
     {
         setColumnCount(i, settings().binCount());
     }
-    impl_->storage_.startDataStorage(this, &moduleManager());
+    impl_->storage_.startParallelDataStorage(this, &moduleManager(), options);
+    return true;
 }
 
 
@@ -756,8 +765,10 @@ AnalysisDataWeightedHistogramModule::flags() const
 }
 
 
-void
-AnalysisDataWeightedHistogramModule::dataStarted(AbstractAnalysisData *data)
+bool
+AnalysisDataWeightedHistogramModule::parallelDataStarted(
+        AbstractAnalysisData              *data,
+        const AnalysisDataParallelOptions &options)
 {
     addModule(impl_->averager_);
     setDataSetCount(data->dataSetCount());
@@ -765,7 +776,8 @@ AnalysisDataWeightedHistogramModule::dataStarted(AbstractAnalysisData *data)
     {
         setColumnCount(i, settings().binCount());
     }
-    impl_->storage_.startDataStorage(this, &moduleManager());
+    impl_->storage_.startParallelDataStorage(this, &moduleManager(), options);
+    return true;
 }