Gromacs
2024.3
|
#include <gromacs/selection/selection.h>
Provides access to information about a single selected position.
Each position has associated coordinates, and possibly velocities and forces if they have been requested and are available. It also has a set of atoms associated with it; typically the coordinates are the center-of-mass or center-of-geometry coordinates for that set of atoms. It is possible that there are not atoms associated if the selection has been provided as a fixed position.
After the selection has been compiled, but not yet evaluated, the contents of the coordinate, velocity and force vectors are undefined.
Default copy constructor and assignment operators are used, and work as intended: the copy references the same position and works identically.
Methods in this class do not throw.
Public Member Functions | |
SelectionPosition (const internal::SelectionData &sel, int index) | |
Constructs a wrapper object for given selection position. More... | |
e_index_t | type () const |
Returns type of this position. More... | |
const rvec & | x () const |
Returns coordinates for this position. | |
const rvec & | v () const |
Returns velocity for this position. More... | |
const rvec & | f () const |
Returns force for this position. More... | |
real | mass () const |
Returns total mass for this position. More... | |
real | charge () const |
Returns total charge for this position. More... | |
int | atomCount () const |
Returns the number of atoms that make up this position. | |
ArrayRef< const int > | atomIndices () const |
Return atom indices that make up this position. | |
bool | selected () const |
Returns whether this position is selected in the current frame. More... | |
int | refId () const |
Returns reference ID for this position. More... | |
int | mappedId () const |
Returns mapped ID for this position. More... | |
operator AnalysisNeighborhoodPositions () const | |
Allows passing a selection position directly to neighborhood searching. More... | |
|
inline |
Constructs a wrapper object for given selection position.
[in] | sel | Selection from which the position is wrapped. |
[in] | index | Zero-based index of the position to wrap. |
Asserts if index
is out of range.
Only for internal use of the library. To obtain a SelectionPosition object in other code, use Selection::position().
|
inline |
Returns total charge for this position.
Returns the sum of charges of atoms that make up this position. If there are no atoms associated or charges are not available, returns zero.
|
inline |
Returns force for this position.
Must not be called if Selection::hasForces() returns false.
|
inline |
Returns mapped ID for this position.
Returns ID of the position that corresponds to that set with Selection::setOriginalId().
If for an array id
, setOriginalId(i, id[i])
has been called for each i
, then it always holds that mappedId()==id
[refId()].
Selection::setOriginalId() has not been called, the default values are dependent on type():
All the default values are zero-based.
|
inline |
Returns total mass for this position.
Returns the total mass of atoms that make up this position. If there are no atoms associated or masses are not available, returns unity.
gmx::SelectionPosition::operator AnalysisNeighborhoodPositions | ( | ) | const |
Allows passing a selection position directly to neighborhood searching.
When initialized this way, AnalysisNeighborhoodPair objects return the index that can be used to access this position using Selection::position().
Works exactly like if AnalysisNeighborhoodPositions had a constructor taking a SelectionPosition object as a parameter. See AnalysisNeighborhoodPositions for rationale and additional discussion.
|
inline |
Returns reference ID for this position.
For dynamic selections, this provides means to associate positions across frames. After compilation, these IDs are consequently numbered starting from zero. For each frame, the ID then reflects the location of the position in the original array of positions. If SelectionOption::dynamicMask() has been set for the parent selection, the IDs for positions not present in the current selection are set to -1, otherwise they are removed completely.
Example: If a dynamic selection consists of at most three positions, after compilation refId() will return 0, 1, 2 for them, respectively. If for a particular frame, only the first and the third are present, refId() will return 0, 2. If SelectionOption::dynamicMask() has been set, all three positions can be accessed also for that frame and refId() will return 0, -1, 2.
|
inline |
Returns whether this position is selected in the current frame.
The return value is equivalent to refid()
== -1. Returns always true if SelectionOption::dynamicMask() has not been set.
|
inline |
Returns type of this position.
Currently always returns the same as Selection::type().
|
inline |
Returns velocity for this position.
Must not be called if Selection::hasVelocities() returns false.