2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2009,2010,2011,2012,2013, by the GROMACS development team, led by
5 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 * others, as listed in the AUTHORS file in the top-level source
7 * directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
37 * Implements neighborhood searching for analysis (from nbsearch.h).
40 * The grid implementation could still be optimized in several different ways:
41 * - Triclinic grid cells are not the most efficient shape, but make PBC
43 * - Precalculating the required PBC shift for a pair of cells outside the
44 * inner loop. After this is done, it should be quite straightforward to
45 * move to rectangular cells.
46 * - Pruning grid cells from the search list if they are completely outside
47 * the sphere that is being considered.
48 * - A better heuristic could be added for falling back to simple loops for a
49 * small number of reference particles.
50 * - A better heuristic for selecting the grid size.
51 * - A multi-level grid implementation could be used to be able to use small
52 * grids for short cutoffs with very inhomogeneous particle distributions
53 * without a memory cost.
55 * \author Teemu Murtola <teemu.murtola@gmail.com>
56 * \ingroup module_selection
58 #include "gromacs/selection/nbsearch.h"
65 #include "gromacs/legacyheaders/smalloc.h"
66 #include "gromacs/legacyheaders/typedefs.h"
67 #include "gromacs/legacyheaders/pbc.h"
68 #include "gromacs/legacyheaders/vec.h"
69 #include "gromacs/legacyheaders/thread_mpi/mutex.h"
71 #include "gromacs/selection/position.h"
72 #include "gromacs/utility/gmxassert.h"
80 /********************************************************************
81 * Implementation class declarations
84 class AnalysisNeighborhoodSearchImpl
87 typedef AnalysisNeighborhoodPairSearch::ImplPointer
88 PairSearchImplPointer;
89 typedef std::vector<PairSearchImplPointer> PairSearchList;
90 typedef std::vector<std::vector<int> > CellList;
92 explicit AnalysisNeighborhoodSearchImpl(real cutoff);
93 ~AnalysisNeighborhoodSearchImpl();
95 void init(AnalysisNeighborhood::SearchMode mode,
96 const t_pbc *pbc, int n, const rvec x[], const int *refid);
97 PairSearchImplPointer getPairSearch();
99 real cutoffSquared() const { return cutoff2_; }
100 bool usesGridSearch() const { return bGrid_; }
103 //! Calculates offsets to neighboring grid cells that should be considered.
104 void initGridCellNeighborList();
106 * Determines a suitable grid size and sets up the cells.
108 * \param[in] pbc Information about the box.
109 * \returns false if grid search is not suitable.
111 bool initGridCells(const t_pbc *pbc);
113 * Sets ua a search grid for a given box.
115 * \param[in] pbc Information about the box.
116 * \returns false if grid search is not suitable.
118 bool initGrid(const t_pbc *pbc);
120 * Maps a point into a grid cell.
122 * \param[in] x Point to map.
123 * \param[out] cell Indices of the grid cell in which \p x lies.
125 * \p x should be within the triclinic unit cell.
127 void mapPointToGridCell(const rvec x, ivec cell) const;
129 * Calculates linear index of a grid cell.
131 * \param[in] cell Cell indices.
132 * \returns Linear index of \p cell.
134 int getGridCellIndex(const ivec cell) const;
136 * Adds an index into a grid cell.
138 * \param[in] cell Cell into which \p i should be added.
139 * \param[in] i Index to add.
141 void addToGridCell(const ivec cell, int i);
143 //! Whether to try grid searching.
147 //! The cutoff squared.
150 //! Number of reference points for the current frame.
152 //! Reference point positions.
154 //! Reference position ids (NULL if not available).
159 //! Number of excluded reference positions for current test particle.
161 //! Exclusions for current test particle.
164 //! Whether grid searching is actually used for the current positions.
166 //! Array allocated for storing in-unit-cell reference positions.
168 //! Allocation count for xref_alloc.
170 //! false if the box is rectangular.
172 //! Box vectors of a single grid cell.
174 //! The reciprocal cell vectors as columns; the inverse of \p cellbox.
176 //! Number of cells along each dimension.
178 //! Data structure to hold the grid cell contents.
180 //! Number of neighboring cells to consider.
182 //! Offsets of the neighboring cells to consider.
184 //! Allocation count for \p gnboffs.
187 tMPI::mutex createPairSearchMutex_;
188 PairSearchList pairSearchList_;
190 friend class AnalysisNeighborhoodPairSearchImpl;
192 GMX_DISALLOW_COPY_AND_ASSIGN(AnalysisNeighborhoodSearchImpl);
195 class AnalysisNeighborhoodPairSearchImpl
198 explicit AnalysisNeighborhoodPairSearchImpl(const AnalysisNeighborhoodSearchImpl &search)
199 : search_(search), testIndex_(0)
202 clear_ivec(testcell_);
206 //! Clears the loop indices.
208 //! Initializes a search to find reference positions neighboring \p x.
209 void startSearch(const rvec x, int testIndex);
210 //! Searches for the next neighbor.
211 template <class Action>
212 bool searchNext(Action action);
213 //! Initializes a pair representing the pair found by searchNext().
214 void initFoundPair(AnalysisNeighborhoodPair *pair) const;
217 //! Checks whether a reference positiong should be excluded.
218 bool isExcluded(int j);
220 const AnalysisNeighborhoodSearchImpl &search_;
222 //! Stores test position during a pair loop.
224 //! Stores the previous returned position during a pair loop.
226 //! Stores the current exclusion index during loops.
228 //! Stores the test particle cell index during loops.
230 //! Stores the current cell neighbor index during pair loops.
232 //! Stores the index within the current cell during pair loops.
235 GMX_DISALLOW_COPY_AND_ASSIGN(AnalysisNeighborhoodPairSearchImpl);
238 /********************************************************************
239 * AnalysisNeighborhoodSearchImpl
242 AnalysisNeighborhoodSearchImpl::AnalysisNeighborhoodSearchImpl(real cutoff)
248 cutoff_ = GMX_REAL_MAX;
251 cutoff2_ = sqr(cutoff_);
267 clear_mat(recipcell_);
268 clear_ivec(ncelldim_);
275 AnalysisNeighborhoodSearchImpl::~AnalysisNeighborhoodSearchImpl()
277 PairSearchList::const_iterator i;
278 for (i = pairSearchList_.begin(); i != pairSearchList_.end(); ++i)
280 GMX_RELEASE_ASSERT(i->unique(),
281 "Dangling AnalysisNeighborhoodPairSearch reference");
287 AnalysisNeighborhoodSearchImpl::PairSearchImplPointer
288 AnalysisNeighborhoodSearchImpl::getPairSearch()
290 tMPI::lock_guard<tMPI::mutex> lock(createPairSearchMutex_);
291 // TODO: Consider whether this needs to/can be faster, e.g., by keeping a
292 // separate pool of unused search objects.
293 PairSearchList::const_iterator i;
294 for (i = pairSearchList_.begin(); i != pairSearchList_.end(); ++i)
301 PairSearchImplPointer pairSearch(new AnalysisNeighborhoodPairSearchImpl(*this));
302 pairSearchList_.push_back(pairSearch);
306 void AnalysisNeighborhoodSearchImpl::initGridCellNeighborList()
308 int maxx, maxy, maxz;
311 /* Find the extent of the sphere in triclinic coordinates */
312 maxz = static_cast<int>(cutoff_ * recipcell_[ZZ][ZZ]) + 1;
313 rvnorm = sqrt(sqr(recipcell_[YY][YY]) + sqr(recipcell_[ZZ][YY]));
314 maxy = static_cast<int>(cutoff_ * rvnorm) + 1;
315 rvnorm = sqrt(sqr(recipcell_[XX][XX]) + sqr(recipcell_[YY][XX])
316 + sqr(recipcell_[ZZ][XX]));
317 maxx = static_cast<int>(cutoff_ * rvnorm) + 1;
319 /* Calculate the number of cells and reallocate if necessary */
320 ngridnb_ = (2 * maxx + 1) * (2 * maxy + 1) * (2 * maxz + 1);
321 if (gnboffs_nalloc_ < ngridnb_)
323 gnboffs_nalloc_ = ngridnb_;
324 srenew(gnboffs_, gnboffs_nalloc_);
327 /* Store the whole cube */
328 /* TODO: Prune off corners that are not needed */
330 for (int x = -maxx; x <= maxx; ++x)
332 for (int y = -maxy; y <= maxy; ++y)
334 for (int z = -maxz; z <= maxz; ++z)
345 bool AnalysisNeighborhoodSearchImpl::initGridCells(const t_pbc *pbc)
347 const real targetsize =
348 pow(pbc->box[XX][XX] * pbc->box[YY][YY] * pbc->box[ZZ][ZZ]
349 * 10 / nref_, static_cast<real>(1./3.));
352 for (int dd = 0; dd < DIM; ++dd)
354 ncelldim_[dd] = static_cast<int>(pbc->box[dd][dd] / targetsize);
355 cellCount *= ncelldim_[dd];
356 if (ncelldim_[dd] < 3)
361 // Never decrease the size of the cell vector to avoid reallocating
362 // memory for the nested vectors. The actual size of the vector is not
363 // used outside this function.
364 if (cells_.size() < static_cast<size_t>(cellCount))
366 cells_.resize(cellCount);
368 for (int ci = 0; ci < cellCount; ++ci)
375 bool AnalysisNeighborhoodSearchImpl::initGrid(const t_pbc *pbc)
377 /* TODO: This check could be improved. */
378 if (0.5*pbc->max_cutoff2 < cutoff2_)
383 if (!initGridCells(pbc))
388 bTric_ = TRICLINIC(pbc->box);
391 for (int dd = 0; dd < DIM; ++dd)
393 svmul(1.0 / ncelldim_[dd], pbc->box[dd], cellbox_[dd]);
395 m_inv_ur0(cellbox_, recipcell_);
399 for (int dd = 0; dd < DIM; ++dd)
401 cellbox_[dd][dd] = pbc->box[dd][dd] / ncelldim_[dd];
402 recipcell_[dd][dd] = 1.0 / cellbox_[dd][dd];
405 initGridCellNeighborList();
409 void AnalysisNeighborhoodSearchImpl::mapPointToGridCell(const rvec x,
416 tmvmul_ur0(recipcell_, x, tx);
417 for (int dd = 0; dd < DIM; ++dd)
419 cell[dd] = static_cast<int>(tx[dd]);
424 for (int dd = 0; dd < DIM; ++dd)
426 cell[dd] = static_cast<int>(x[dd] * recipcell_[dd][dd]);
431 int AnalysisNeighborhoodSearchImpl::getGridCellIndex(const ivec cell) const
433 GMX_ASSERT(cell[XX] >= 0 && cell[XX] < ncelldim_[XX],
434 "Grid cell X index out of range");
435 GMX_ASSERT(cell[YY] >= 0 && cell[YY] < ncelldim_[YY],
436 "Grid cell Y index out of range");
437 GMX_ASSERT(cell[ZZ] >= 0 && cell[ZZ] < ncelldim_[ZZ],
438 "Grid cell Z index out of range");
439 return cell[XX] + cell[YY] * ncelldim_[XX]
440 + cell[ZZ] * ncelldim_[XX] * ncelldim_[YY];
443 void AnalysisNeighborhoodSearchImpl::addToGridCell(const ivec cell, int i)
445 const int ci = getGridCellIndex(cell);
446 cells_[ci].push_back(i);
449 void AnalysisNeighborhoodSearchImpl::init(
450 AnalysisNeighborhood::SearchMode mode,
451 const t_pbc *pbc, int n, const rvec x[], const int *refid)
453 pbc_ = const_cast<t_pbc *>(pbc);
455 // TODO: Consider whether it would be possible to support grid searching in
457 if (mode == AnalysisNeighborhood::eSearchMode_Simple
458 || pbc_ == NULL || pbc_->ePBC != epbcXYZ)
464 // TODO: Actually implement forcing eSearchMode_Grid
465 bGrid_ = initGrid(pbc_);
469 if (xref_nalloc_ < n)
471 srenew(xref_alloc_, n);
476 for (int i = 0; i < n; ++i)
478 copy_rvec(x[i], xref_alloc_[i]);
480 put_atoms_in_triclinic_unitcell(ecenterTRIC, pbc_->box, n, xref_alloc_);
481 for (int i = 0; i < n; ++i)
485 mapPointToGridCell(xref_[i], refcell);
486 addToGridCell(refcell, i);
498 * Sets the exclusions for the next neighborhood search.
500 * \param[in,out] d Neighborhood search data structure.
501 * \param[in] nexcl Number of reference positions to exclude from next
503 * \param[in] excl Indices of reference positions to exclude.
505 * The set exclusions remain in effect until the next call of this function.
508 gmx_ana_nbsearch_set_excl(gmx_ana_nbsearch_t *d, int nexcl, int excl[])
516 /********************************************************************
517 * AnalysisNeighborhoodPairSearchImpl
520 void AnalysisNeighborhoodPairSearchImpl::reset()
528 bool AnalysisNeighborhoodPairSearchImpl::isExcluded(int j)
530 if (exclind_ < search_.nexcl_)
534 while (exclind_ < search_.nexcl_
535 && search_.excl_[exclind_] < search_.refid_[j])
539 if (exclind_ < search_.nexcl_
540 && search_.refid_[j] == search_.excl_[exclind_])
548 while (search_.bGrid_ && exclind_ < search_.nexcl_
549 && search_.excl_[exclind_] < j)
553 if (search_.excl_[exclind_] == j)
563 void AnalysisNeighborhoodPairSearchImpl::startSearch(const rvec x, int testIndex)
565 testIndex_ = testIndex;
566 copy_rvec(x, xtest_);
569 put_atoms_in_triclinic_unitcell(ecenterTRIC, search_.pbc_->box,
571 search_.mapPointToGridCell(xtest_, testcell_);
576 template <class Action>
577 bool AnalysisNeighborhoodPairSearchImpl::searchNext(Action action)
582 int cai = prevcai_ + 1;
584 for (; nbi < search_.ngridnb_; ++nbi)
588 ivec_add(testcell_, search_.gnboffs_[nbi], cell);
589 cell[XX] = (cell[XX] + search_.ncelldim_[XX]) % search_.ncelldim_[XX];
590 cell[YY] = (cell[YY] + search_.ncelldim_[YY]) % search_.ncelldim_[YY];
591 cell[ZZ] = (cell[ZZ] + search_.ncelldim_[ZZ]) % search_.ncelldim_[ZZ];
593 const int ci = search_.getGridCellIndex(cell);
594 const int cellSize = static_cast<int>(search_.cells_[ci].size());
595 /* TODO: Calculate the required PBC shift outside the inner loop */
596 for (; cai < cellSize; ++cai)
598 const int i = search_.cells_[ci][cai];
604 pbc_dx_aiuc(search_.pbc_, xtest_, search_.xref_[i], dx);
605 const real r2 = norm2(dx);
606 if (r2 <= search_.cutoff2_)
623 for (int i = previ_ + 1; i < search_.nref_; ++i)
632 pbc_dx(search_.pbc_, xtest_, search_.xref_[i], dx);
636 rvec_sub(xtest_, search_.xref_[i], dx);
638 const real r2 = norm2(dx);
639 if (r2 <= search_.cutoff2_)
653 void AnalysisNeighborhoodPairSearchImpl::initFoundPair(
654 AnalysisNeighborhoodPair *pair) const
658 *pair = AnalysisNeighborhoodPair();
662 *pair = AnalysisNeighborhoodPair(previ_, testIndex_);
666 } // namespace internal
672 * Search action to find the next neighbor.
674 * Used as the action for AnalysisNeighborhoodPairSearchImpl::searchNext() to
675 * find the next neighbor.
677 * Simply breaks the loop on the first found neighbor.
679 bool withinAction(int /*i*/, real /*r2*/)
685 * Search action find the minimum distance.
687 * Used as the action for AnalysisNeighborhoodPairSearchImpl::searchNext() to
688 * find the nearest neighbor.
690 * With this action, AnalysisNeighborhoodPairSearchImpl::searchNext() always
691 * returns false, and the output is put into the variables passed by pointer
692 * into the constructor. If no neighbors are found, the output variables are
693 * not modified, i.e., the caller must initialize them.
699 * Initializes the action with given output locations.
701 * \param[out] closestPoint Index of the closest reference location.
702 * \param[out] minDist2 Minimum distance squared.
704 * The constructor call does not modify the pointed values, but only
705 * stores the pointers for later use.
706 * See the class description for additional semantics.
708 MindistAction(int *closestPoint, real *minDist2)
709 : closestPoint_(*closestPoint), minDist2_(*minDist2)
713 //! Processes a neighbor to find the nearest point.
714 bool operator()(int i, real r2)
728 GMX_DISALLOW_ASSIGN(MindistAction);
733 /********************************************************************
734 * AnalysisNeighborhood::Impl
737 class AnalysisNeighborhood::Impl
740 typedef AnalysisNeighborhoodSearch::ImplPointer SearchImplPointer;
741 typedef std::vector<SearchImplPointer> SearchList;
743 Impl() : cutoff_(0), mode_(eSearchMode_Automatic)
748 SearchList::const_iterator i;
749 for (i = searchList_.begin(); i != searchList_.end(); ++i)
751 GMX_RELEASE_ASSERT(i->unique(),
752 "Dangling AnalysisNeighborhoodSearch reference");
756 SearchImplPointer getSearch();
758 tMPI::mutex createSearchMutex_;
759 SearchList searchList_;
764 AnalysisNeighborhood::Impl::SearchImplPointer
765 AnalysisNeighborhood::Impl::getSearch()
767 tMPI::lock_guard<tMPI::mutex> lock(createSearchMutex_);
768 // TODO: Consider whether this needs to/can be faster, e.g., by keeping a
769 // separate pool of unused search objects.
770 SearchList::const_iterator i;
771 for (i = searchList_.begin(); i != searchList_.end(); ++i)
778 SearchImplPointer search(new internal::AnalysisNeighborhoodSearchImpl(cutoff_));
779 searchList_.push_back(search);
783 /********************************************************************
784 * AnalysisNeighborhood
787 AnalysisNeighborhood::AnalysisNeighborhood()
792 AnalysisNeighborhood::~AnalysisNeighborhood()
796 void AnalysisNeighborhood::setCutoff(real cutoff)
798 GMX_RELEASE_ASSERT(impl_->searchList_.empty(),
799 "Changing the cutoff after initSearch() not currently supported");
800 impl_->cutoff_ = cutoff;
803 void AnalysisNeighborhood::setMode(SearchMode mode)
808 AnalysisNeighborhood::SearchMode AnalysisNeighborhood::mode() const
813 AnalysisNeighborhoodSearch
814 AnalysisNeighborhood::initSearch(const t_pbc *pbc, int n, const rvec x[])
816 Impl::SearchImplPointer search(impl_->getSearch());
817 search->init(mode(), pbc, n, x, NULL);
818 return AnalysisNeighborhoodSearch(search);
821 AnalysisNeighborhoodSearch
822 AnalysisNeighborhood::initSearch(const t_pbc *pbc, const gmx_ana_pos_t *p)
824 Impl::SearchImplPointer search(impl_->getSearch());
825 search->init(mode(), pbc, p->nr, p->x, p->m.refid);
826 return AnalysisNeighborhoodSearch(search);
829 /********************************************************************
830 * AnalysisNeighborhoodSearch
833 AnalysisNeighborhoodSearch::AnalysisNeighborhoodSearch()
837 AnalysisNeighborhoodSearch::AnalysisNeighborhoodSearch(const ImplPointer &impl)
842 void AnalysisNeighborhoodSearch::reset()
847 AnalysisNeighborhood::SearchMode AnalysisNeighborhoodSearch::mode() const
849 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
850 return (impl_->usesGridSearch()
851 ? AnalysisNeighborhood::eSearchMode_Grid
852 : AnalysisNeighborhood::eSearchMode_Simple);
855 bool AnalysisNeighborhoodSearch::isWithin(const rvec x) const
857 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
858 internal::AnalysisNeighborhoodPairSearchImpl pairSearch(*impl_);
859 pairSearch.startSearch(x, 0);
860 return pairSearch.searchNext(&withinAction);
863 bool AnalysisNeighborhoodSearch::isWithin(const gmx_ana_pos_t *p, int i) const
865 return isWithin(p->x[i]);
868 real AnalysisNeighborhoodSearch::minimumDistance(const rvec x) const
870 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
871 internal::AnalysisNeighborhoodPairSearchImpl pairSearch(*impl_);
872 pairSearch.startSearch(x, 0);
873 real minDist2 = impl_->cutoffSquared();
874 int closestPoint = -1;
875 MindistAction action(&closestPoint, &minDist2);
876 (void)pairSearch.searchNext(action);
877 return sqrt(minDist2);
880 real AnalysisNeighborhoodSearch::minimumDistance(const gmx_ana_pos_t *p, int i) const
882 return minimumDistance(p->x[i]);
885 AnalysisNeighborhoodPair
886 AnalysisNeighborhoodSearch::nearestPoint(const rvec x) const
888 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
889 internal::AnalysisNeighborhoodPairSearchImpl pairSearch(*impl_);
890 pairSearch.startSearch(x, 0);
891 real minDist2 = impl_->cutoffSquared();
892 int closestPoint = -1;
893 MindistAction action(&closestPoint, &minDist2);
894 (void)pairSearch.searchNext(action);
895 return AnalysisNeighborhoodPair(closestPoint, 0);
898 AnalysisNeighborhoodPair
899 AnalysisNeighborhoodSearch::nearestPoint(const gmx_ana_pos_t *p, int i) const
901 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
902 internal::AnalysisNeighborhoodPairSearchImpl pairSearch(*impl_);
903 pairSearch.startSearch(p->x[i], 0);
904 real minDist2 = impl_->cutoffSquared();
905 int closestPoint = -1;
906 MindistAction action(&closestPoint, &minDist2);
907 (void)pairSearch.searchNext(action);
908 return AnalysisNeighborhoodPair(closestPoint, i);
911 AnalysisNeighborhoodPairSearch
912 AnalysisNeighborhoodSearch::startPairSearch(const rvec x)
914 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
915 Impl::PairSearchImplPointer pairSearch(impl_->getPairSearch());
916 pairSearch->startSearch(x, 0);
917 return AnalysisNeighborhoodPairSearch(pairSearch);
920 AnalysisNeighborhoodPairSearch
921 AnalysisNeighborhoodSearch::startPairSearch(const gmx_ana_pos_t *p, int i)
923 GMX_RELEASE_ASSERT(impl_, "Accessing an invalid search object");
924 Impl::PairSearchImplPointer pairSearch(impl_->getPairSearch());
925 pairSearch->startSearch(p->x[i], i);
926 return AnalysisNeighborhoodPairSearch(pairSearch);
929 /********************************************************************
930 * AnalysisNeighborhoodPairSearch
933 AnalysisNeighborhoodPairSearch::AnalysisNeighborhoodPairSearch(
934 const ImplPointer &impl)
939 bool AnalysisNeighborhoodPairSearch::findNextPair(AnalysisNeighborhoodPair *pair)
941 bool bFound = impl_->searchNext(&withinAction);
942 impl_->initFoundPair(pair);