Gromacs
2024.4
|
#include <gromacs/selection/poscalc.h>
Collection of gmx_ana_poscalc_t
structures for the same topology.
Calculations within one collection share the same topology, and they are optimized. Calculations in different collections do not interact. The topology for a collection can be set with setTopology(). This needs to be done before calling gmx_ana_poscalc_set_maxindex() for any calculation in the collection, unless that calculation does not require topology information.
A new calculation is created with createCalculation(). If flags need to be adjusted later, gmx_ana_poscalc_set_flags() can be used. After the flags are final, the largest possible index group for which the positions are needed has to be set with gmx_ana_poscalc_set_maxindex(). setTopology() should have been called before this function is called. After the above calls, gmx_ana_poscalc_init_pos() can be used to initialize output to a gmx_ana_pos_t
structure. Several different structures can be initialized for the same calculation; the only requirement is that the structure passed later to gmx_ana_poscalc_update() has been initialized properly. The memory allocated for a calculation can be freed with gmx_ana_poscalc_free().
The position evaluation is simple: initFrame() should be called once for each frame, and gmx_ana_poscalc_update() can then be called for each calculation that is needed for that frame.
It is also possible to initialize the calculations based on a type provided as a string. The possible strings are listed in typeEnumValues, and the string can be converted to the parameters for createCalculation() using typeFromEnum(). createCalculationFromEnum() is also provided for convenience.
Classes | |
class | Impl |
Private implementation class for PositionCalculationCollection. More... | |
Public Types | |
enum | RequiredTopologyInfo { RequiredTopologyInfo::None, RequiredTopologyInfo::Topology, RequiredTopologyInfo::TopologyAndMasses } |
Describes what topology information is needed for position calculation. More... | |
Public Member Functions | |
PositionCalculationCollection () | |
Creates a new position calculation collection object. More... | |
~PositionCalculationCollection () | |
Destroys a position calculation collection and its calculations. More... | |
void | setTopology (const gmx_mtop_t *top) |
Sets the topology used for the calculations. More... | |
void | printTree (FILE *fp) const |
Prints information about calculations. More... | |
gmx_ana_poscalc_t * | createCalculation (e_poscalc_t type, int flags) |
Creates a new position calculation. More... | |
gmx_ana_poscalc_t * | createCalculationFromEnum (const char *post, int flags) |
Creates a new position calculation based on an enum value. More... | |
void | getRequiredAtoms (gmx_ana_index_t *out) const |
Computes the atoms required to evaluate this collection. More... | |
void | initEvaluation () |
Initializes evaluation for a position calculation collection. More... | |
void | initFrame (const t_trxframe *fr) |
Initializes a position calculation collection for a new frame. More... | |
Static Public Member Functions | |
static void | typeFromEnum (const char *post, e_poscalc_t *type, int *flags) |
Converts a string to parameters for createCalculationFromEnum(). More... | |
static RequiredTopologyInfo | requiredTopologyInfoForType (const char *post, bool forces) |
Returns what information is needed for position evaluation. More... | |
Static Public Attributes | |
static const char *const | typeEnumValues [] |
Array of strings acceptable for position calculation type enum. More... | |
Friends | |
struct | ::gmx_ana_poscalc_t |
Needed to access the implementation class from the C code. | |
gmx::PositionCalculationCollection::PositionCalculationCollection | ( | ) |
Creates a new position calculation collection object.
std::bad_alloc | if out of memory. |
gmx::PositionCalculationCollection::~PositionCalculationCollection | ( | ) |
Destroys a position calculation collection and its calculations.
Any calculations in the collection are also freed, even if references to them are left.
gmx_ana_poscalc_t * gmx::PositionCalculationCollection::createCalculation | ( | e_poscalc_t | type, |
int | flags | ||
) |
Creates a new position calculation.
[in] | type | Type of calculation. |
[in] | flags | Flags for setting calculation options (see documentation of the flags). |
Does not throw currently, but may throw std::bad_alloc in the future.
gmx_ana_poscalc_t * gmx::PositionCalculationCollection::createCalculationFromEnum | ( | const char * | post, |
int | flags | ||
) |
Creates a new position calculation based on an enum value.
[in] | post | One of the strings acceptable for typeFromEnum(). |
[in] | flags | Flags for setting calculation options (see documentation of the flags). |
InternalError | if post is not recognized. |
This is a convenience wrapper for createCalculation(). flags
sets the default calculation options if not overridden by post
; see typeFromEnum().
May also throw std::bad_alloc in the future.
void gmx::PositionCalculationCollection::getRequiredAtoms | ( | gmx_ana_index_t * | out | ) | const |
Computes the atoms required to evaluate this collection.
[out] | out | Maximal group of atoms required to evaluate the positions. |
Does not throw.
void gmx::PositionCalculationCollection::initEvaluation | ( | ) |
Initializes evaluation for a position calculation collection.
This function does some final initialization of the data structures in the collection to prepare them for evaluation. After this function has been called, it is no longer possible to add new calculations to the collection.
Multiple calls to the function are ignored.
Does not throw currently, but may throw std::bad_alloc in the future.
void gmx::PositionCalculationCollection::initFrame | ( | const t_trxframe * | fr | ) |
Initializes a position calculation collection for a new frame.
[in] | fr | Frame to initialize evaluation for. |
Should be called for each frame before calling gmx_ana_poscalc_update().
This function calls initEvaluation() automatically if it has not been called earlier.
Does not currently throw, but may throw std::bad_alloc in the future.
void gmx::PositionCalculationCollection::printTree | ( | FILE * | fp | ) | const |
Prints information about calculations.
[in] | fp | File handle to receive the output. |
The output is very technical, making this function mainly useful for debugging purposes.
Does not throw.
|
static |
Returns what information is needed for position evaluation.
[in] | post | Position type (see typeFromEnum()). |
[in] | forces | Whether forces are needed. |
void gmx::PositionCalculationCollection::setTopology | ( | const gmx_mtop_t * | top | ) |
Sets the topology used for the calculations.
[in] | top | Topology data structure. |
This function should be called to set the topology before using gmx_ana_poscalc_set_maxindex() for any calculation that requires topology information.
Does not throw.
|
static |
Converts a string to parameters for createCalculationFromEnum().
[in] | post | String (typically an enum argument). Allowed values: 'atom', 'res_com', 'res_cog', 'mol_com', 'mol_cog', or one of the last four prepended by 'whole_', 'part_', or 'dyn_'. |
[out] | type | e_poscalc_t corresponding to post . |
[in,out] | flags | Flags corresponding to post . On input, the flags should contain the default flags. On exit, the flags POS_MASS, POS_COMPLMAX and POS_COMPLWHOLE have been set according to post (the completion flags are left at the default values if no completion prefix is given). |
InternalError | if post is not recognized. |
post
, but the results are undefined.
|
static |
Array of strings acceptable for position calculation type enum.
This array contains the acceptable values for typeFromEnum() and createCalculationFromEnum(). The array contains a NULL pointer after the last item to indicate the end of the list.