Remove AnalysisNeighborhood::setUseBoundingBox()
authorTeemu Murtola <teemu.murtola@gmail.com>
Tue, 13 Jan 2015 18:48:41 +0000 (20:48 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 19 Jan 2015 05:12:13 +0000 (06:12 +0100)
Originally, this was added to provide more control for the caller about
how the search is done, with main user probably being more comprehensive
tests.  This method was possible because at that time, all the
coordinates were clamped to the edges of the grid when determining the
cell, so it was at most a bit inefficient if some positions were outside
the grid.

But now, there is no clamping, so this method no longer works correctly:
the grid must cover all the reference positions (i.e., be at least the
size of the bounding box), so that the reference positions really are
within the grid cell to which they belong.  Otherwise, when the grid
cells to search are pruned based on their distance from the test
position, some pairs could be missed.

Change-Id: I94ae4081f456c08ff89779ef20b91be0ca061d96

src/gromacs/selection/nbsearch.cpp
src/gromacs/selection/nbsearch.h

index 2fe48376b843f09b9f3678f77d58fb1b8a420abd..8d808900fc69c9eb6dee895855ec218fd8f12e89 100644 (file)
@@ -132,15 +132,12 @@ class AnalysisNeighborhoodSearchImpl
          * Initializes the search with a given box and reference positions.
          *
          * \param[in] mode            Search mode to use.
-         * \param[in] bUseBoundingBox Whether to use bounding box for
-         *     non-periodic grids.
          * \param[in] bXY             Whether to use 2D searching.
          * \param[in] excls           Exclusions.
          * \param[in] pbc             PBC information.
          * \param[in] positions       Set of reference positions.
          */
         void init(AnalysisNeighborhood::SearchMode     mode,
-                  bool                                 bUseBoundingBox,
                   bool                                 bXY,
                   const t_blocka                      *excls,
                   const t_pbc                         *pbc,
@@ -176,14 +173,11 @@ class AnalysisNeighborhoodSearchImpl
          * \param[in] pbc      Information about the box.
          * \param[in] posCount Number of positions in \p x.
          * \param[in] x        Reference positions that will be put on the grid.
-         * \param[in] bUseBoundingBox  If `true`, non-periodic grid dimensions
-         *     will use the bounding box of \p x instead of the box.
          * \param[in] bForce   If `true`, grid searching will be used if at all
          *     possible, even if a simple search might give better performance.
          * \returns   `false` if grid search is not suitable.
          */
-        bool initGrid(const t_pbc &pbc, int posCount, const rvec x[],
-                      bool bUseBoundingBox, bool bForce);
+        bool initGrid(const t_pbc &pbc, int posCount, const rvec x[], bool bForce);
         /*! \brief
          * Maps a point into a grid cell.
          *
@@ -600,8 +594,7 @@ bool AnalysisNeighborhoodSearchImpl::initGridCells(
 }
 
 bool AnalysisNeighborhoodSearchImpl::initGrid(
-        const t_pbc &pbc, int posCount, const rvec x[], bool bUseBoundingBox,
-        bool bForce)
+        const t_pbc &pbc, int posCount, const rvec x[], bool bForce)
 {
     if (posCount == 0)
     {
@@ -641,7 +634,7 @@ bool AnalysisNeighborhoodSearchImpl::initGrid(
     clear_rvec(gridOrigin_);
     for (int dd = 0; dd < DIM; ++dd)
     {
-        if (bUseBoundingBox && !bGridPBC_[dd] && !bSingleCell[dd])
+        if (!bGridPBC_[dd] && !bSingleCell[dd])
         {
             gridOrigin_[dd] = origin[dd];
             clear_rvec(box[dd]);
@@ -879,7 +872,6 @@ int AnalysisNeighborhoodSearchImpl::shiftCell(const ivec cell, rvec shift) const
 
 void AnalysisNeighborhoodSearchImpl::init(
         AnalysisNeighborhood::SearchMode     mode,
-        bool                                 bUseBoundingBox,
         bool                                 bXY,
         const t_blocka                      *excls,
         const t_pbc                         *pbc,
@@ -925,7 +917,7 @@ void AnalysisNeighborhoodSearchImpl::init(
     }
     else if (bTryGrid_)
     {
-        bGrid_ = initGrid(pbc_, positions.count_, positions.x_, bUseBoundingBox,
+        bGrid_ = initGrid(pbc_, positions.count_, positions.x_,
                           mode == AnalysisNeighborhood::eSearchMode_Grid);
     }
     refIndices_ = positions.indices_;
@@ -1240,8 +1232,7 @@ class AnalysisNeighborhood::Impl
         typedef std::vector<SearchImplPointer> SearchList;
 
         Impl()
-            : cutoff_(0), excls_(NULL), mode_(eSearchMode_Automatic),
-              bUseBoundingBox_(true), bXY_(false)
+            : cutoff_(0), excls_(NULL), mode_(eSearchMode_Automatic), bXY_(false)
         {
         }
         ~Impl()
@@ -1261,7 +1252,6 @@ class AnalysisNeighborhood::Impl
         real                    cutoff_;
         const t_blocka         *excls_;
         SearchMode              mode_;
-        bool                    bUseBoundingBox_;
         bool                    bXY_;
 };
 
@@ -1304,11 +1294,6 @@ void AnalysisNeighborhood::setCutoff(real cutoff)
     impl_->cutoff_ = cutoff;
 }
 
-void AnalysisNeighborhood::setUseBoundingBox(bool bUseBoundingBox)
-{
-    impl_->bUseBoundingBox_ = bUseBoundingBox;
-}
-
 void AnalysisNeighborhood::setXYMode(bool bXY)
 {
     impl_->bXY_ = bXY;
@@ -1336,7 +1321,7 @@ AnalysisNeighborhood::initSearch(const t_pbc                         *pbc,
                                  const AnalysisNeighborhoodPositions &positions)
 {
     Impl::SearchImplPointer search(impl_->getSearch());
-    search->init(mode(), impl_->bUseBoundingBox_, impl_->bXY_, impl_->excls_,
+    search->init(mode(), impl_->bXY_, impl_->excls_,
                  pbc, positions);
     return AnalysisNeighborhoodSearch(search);
 }
index bc5baba8d156311576a793b962ea429b0a2b30d8..d5ae8d41c417f126324520bb99a70ae683d903dc 100644 (file)
@@ -252,28 +252,6 @@ class AnalysisNeighborhood
          * Does not throw.
          */
         void setCutoff(real cutoff);
-        /*! \brief
-         * Sets the search to prefer a grid that covers the bounding box of
-         * reference positions.
-         *
-         * By default, non-periodic dimensions will ignore the size of the box
-         * passed to initSearch() and construct a grid based on the bounding
-         * box of the reference positions.
-         *
-         * If you call this method with `false`, the size of the box will be
-         * used instead to set the grid.  If one of the box vectors is zero,
-         * then grid searching will not be used for that dimension.  This
-         * allows you to control the size of the used grid in case the default
-         * is not suitable.  However, in this case the grid will currently
-         * always start at the origin.
-         *
-         * Currently, this only influences cases where the grid is not
-         * periodic in some dimensions, i.e., `pbc` passed to initSearch() is
-         * NULL, `epbcNONE`, or `epbcXY`.
-         *
-         * Does not throw.
-         */
-        void setUseBoundingBox(bool bUseBoundingBox);
         /*! \brief
          * Sets the search to only happen in the XY plane.
          *