Gromacs
2025.0-dev-20241011-013a99c
|
#include <gromacs/selection/nbsearch.h>
Initialized neighborhood search with a fixed set of reference positions.
An instance of this class is obtained through AnalysisNeighborhood::initSearch(), and can be used to do multiple searches against the provided set of reference positions. It is possible to create concurrent pair searches (including from different threads), as well as call other methods in this class while a pair search is in progress.
This class works like a pointer: copies of it point to the same search. In general, avoid creating copies, and only use the copy/assignment support for moving the variable around. With C++11, this class would best be movable.
Methods in this class do not throw unless otherwise indicated.
Public Types | |
typedef std::shared_ptr < internal::AnalysisNeighborhoodSearchImpl > | ImplPointer |
Internal short-hand type for a pointer to the implementation class. More... | |
Public Member Functions | |
AnalysisNeighborhoodSearch () | |
Initializes an invalid search. More... | |
AnalysisNeighborhoodSearch (const ImplPointer &impl) | |
Internally initialize the search. More... | |
void | reset () |
Clears this search. More... | |
AnalysisNeighborhood::SearchMode | mode () const |
Returns the searching algorithm that this search is using. More... | |
bool | isWithin (const AnalysisNeighborhoodPositions &positions) const |
Checks whether a point is within a neighborhood. More... | |
real | minimumDistance (const AnalysisNeighborhoodPositions &positions) const |
Calculates the minimum distance from the reference points. More... | |
AnalysisNeighborhoodPair | nearestPoint (const AnalysisNeighborhoodPositions &positions) const |
Finds the closest reference point. More... | |
AnalysisNeighborhoodPairSearch | startSelfPairSearch () const |
Starts a search to find all reference position pairs within a cutoff. More... | |
AnalysisNeighborhoodPairSearch | startPairSearch (const AnalysisNeighborhoodPositions &positions) const |
Starts a search to find reference positions within a cutoff. More... | |
typedef std::shared_ptr<internal::AnalysisNeighborhoodSearchImpl> gmx::AnalysisNeighborhoodSearch::ImplPointer |
Internal short-hand type for a pointer to the implementation class.
shared_ptr is used here to automatically keep a reference count to track whether an implementation class is still used outside the AnalysisNeighborhood object. Ownership currently always stays with AnalysisNeighborhood; it always keeps one instance of the pointer.
gmx::AnalysisNeighborhoodSearch::AnalysisNeighborhoodSearch | ( | ) |
Initializes an invalid search.
Such an object cannot be used for searching. It needs to be assigned a value from AnalysisNeighborhood::initSearch() before it can be used. Provided to allow declaring a variable to hold the search before calling AnalysisNeighborhood::initSearch().
|
explicit |
Internally initialize the search.
Used to implement AnalysisNeighborhood::initSearch(). Cannot be called from user code.
bool gmx::AnalysisNeighborhoodSearch::isWithin | ( | const AnalysisNeighborhoodPositions & | positions | ) | const |
Checks whether a point is within a neighborhood.
[in] | positions | Set of test positions to use. |
real gmx::AnalysisNeighborhoodSearch::minimumDistance | ( | const AnalysisNeighborhoodPositions & | positions | ) | const |
Calculates the minimum distance from the reference points.
[in] | positions | Set of test positions to use. |
AnalysisNeighborhood::SearchMode gmx::AnalysisNeighborhoodSearch::mode | ( | ) | const |
Returns the searching algorithm that this search is using.
The return value is never AnalysisNeighborhood::eSearchMode_Automatic.
AnalysisNeighborhoodPair gmx::AnalysisNeighborhoodSearch::nearestPoint | ( | const AnalysisNeighborhoodPositions & | positions | ) | const |
Finds the closest reference point.
[in] | positions | Set of test positions to use. |
void gmx::AnalysisNeighborhoodSearch::reset | ( | ) |
Clears this search.
Equivalent to "*this = AnalysisNeighborhoodSearch();"
. Currently, this is necessary to avoid unnecessary memory allocation if the previous search variable is still in scope when you want to call AnalysisNeighborhood::initSearch() again.
AnalysisNeighborhoodPairSearch gmx::AnalysisNeighborhoodSearch::startPairSearch | ( | const AnalysisNeighborhoodPositions & | positions | ) | const |
Starts a search to find reference positions within a cutoff.
[in] | positions | Set of test positions to use. |
std::bad_alloc | if out of memory. |
If you want to pass the same positions here as you used for the reference positions, consider using startSelfPairSearch(). It can be up to 50% faster.
AnalysisNeighborhoodPairSearch gmx::AnalysisNeighborhoodSearch::startSelfPairSearch | ( | ) | const |
Starts a search to find all reference position pairs within a cutoff.
std::bad_alloc | if out of memory. |
This works as if the reference positions were passed to startPairSearch(), except that it only returns each pair once, instead of returning both i-j and j-i pairs, as startPairSearch() does. i-i pairs are not returned. Note that the order of ref/test indices in the returned pairs is not predictable. That is, one of i-j or j-i is always returned, but there is no control which one.