Gromacs  2022.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends
gmx::PositionCalculationCollection Class Reference

#include <gromacs/selection/poscalc.h>

Description

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_tcreateCalculation (e_poscalc_t type, int flags)
 Creates a new position calculation. More...
 
gmx_ana_poscalc_tcreateCalculationFromEnum (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.
 

Member Enumeration Documentation

Describes what topology information is needed for position calculation.

Enumerator
None 

No topology is needed.

Topology 

Topology is needed (residue/molecule info).

TopologyAndMasses 

Masses are needed.

Constructor & Destructor Documentation

gmx::PositionCalculationCollection::PositionCalculationCollection ( )

Creates a new position calculation collection object.

Exceptions
std::bad_allocif 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.

Member Function Documentation

gmx_ana_poscalc_t * gmx::PositionCalculationCollection::createCalculation ( e_poscalc_t  type,
int  flags 
)

Creates a new position calculation.

Parameters
[in]typeType of calculation.
[in]flagsFlags 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.

Parameters
[in]postOne of the strings acceptable for typeFromEnum().
[in]flagsFlags for setting calculation options (see documentation of the flags).
Exceptions
InternalErrorif 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.

See Also
createCalculation(), typeFromEnum()
void gmx::PositionCalculationCollection::getRequiredAtoms ( gmx_ana_index_t out) const

Computes the atoms required to evaluate this collection.

Parameters
[out]outMaximal 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.

Parameters
[in]frFrame 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.

Parameters
[in]fpFile handle to receive the output.

The output is very technical, making this function mainly useful for debugging purposes.

Does not throw.

PositionCalculationCollection::RequiredTopologyInfo gmx::PositionCalculationCollection::requiredTopologyInfoForType ( const char *  post,
bool  forces 
)
static

Returns what information is needed for position evaluation.

Parameters
[in]postPosition type (see typeFromEnum()).
[in]forcesWhether forces are needed.
Returns
What topology information is required for initializing and/or evaluating the positions.
void gmx::PositionCalculationCollection::setTopology ( const gmx_mtop_t *  top)

Sets the topology used for the calculations.

Parameters
[in]topTopology 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.

void gmx::PositionCalculationCollection::typeFromEnum ( const char *  post,
e_poscalc_t type,
int *  flags 
)
static

Converts a string to parameters for createCalculationFromEnum().

Parameters
[in]postString (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]typee_poscalc_t corresponding to post.
[in,out]flagsFlags 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).
Exceptions
InternalErrorif post is not recognized.
Attention
Checking is not complete, and other values than those listed above may be accepted for post, but the results are undefined.
See Also
typeEnumValues

Member Data Documentation

const char *const gmx::PositionCalculationCollection::typeEnumValues
static
Initial value:
= {
"atom", "res_com", "res_cog", "mol_com", "mol_cog",
"whole_res_com", "whole_res_cog", "whole_mol_com", "whole_mol_cog", "part_res_com",
"part_res_cog", "part_mol_com", "part_mol_cog", "dyn_res_com", "dyn_res_cog",
"dyn_mol_com", "dyn_mol_cog", nullptr,
}

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.


The documentation for this class was generated from the following files: