Gromacs  2024.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Friends
gmx::TopologyInformation Class Reference

#include <gromacs/trajectoryanalysis/topologyinformation.h>

Description

Topology information available to a trajectory analysis module.

This class is used to provide topology information to trajectory analysis modules and to manage memory for them. Having a single wrapper object instead of passing each item separately makes TrajectoryAnalysisModule interface simpler, and also reduces the need to change existing code if additional information is added.

It is intended that eventually most clients of this class will be analysis tools ported to the new analysis framework, but we will use this infrastructure also from the legacy analysis tools during the transition period. That will make it easier to put those tools under tests, and eventually port them.

Methods in this class do not throw if not explicitly stated.

The main data content is constant once loaded, but some content is constructed only when required (e.g. atoms_ and expandedTopology_). Their data members are mutable, so that the lazy construction idiom works properly. Some clients wish to modify the t_atoms, so there is an efficient mechanism for them to get a copy they can modify without disturbing this class. (The implementation releases the cached lazily constructed atoms_, but from the point of view of the caller, that is a copy.) The getters and copy functions are const for callers, which correctly expresses that the topology information is not being changed, merely copied and presented in a different form.

Examples:
template.cpp.

Public Member Functions

bool hasTopology () const
 Returns true if a topology file was loaded.
 
bool hasFullTopology () const
 Returns true if a full topology file was loaded.
 
void fillFromInputFile (const std::string &filename)
 Builder function to fill the contents of TopologyInformation in topInfo from filename. More...
 
gmx_mtop_t * mtop () const
 Returns the loaded topology, or nullptr if not loaded.
 
const gmx_localtop_texpandedTopology () const
 Returns the loaded topology fully expanded, or nullptr if no topology is available.
 
const t_atoms * atoms () const
 Returns a read-only handle to the fully expanded atom data arrays, which might be valid but empty if no topology is available.
 
AtomsDataPtr copyAtoms () const
 Copies the fully expanded atom data arrays, which might be valid but empty if no topology is available.
 
PbcType pbcType () const
 Returns the pbcType field from the topology.
 
ArrayRef< const RVecx () const
 Gets the configuration positions from the topology file. More...
 
ArrayRef< const RVecv () const
 Gets the configuration velocities from the topology file. More...
 
void getBox (matrix box) const
 Gets the configuration box from the topology file. More...
 
const char * name () const
 Returns a name for the topology. More...
 

Friends

class TrajectoryAnalysisRunnerCommon
 Needed to initialize the data.
 

Member Function Documentation

void gmx::TopologyInformation::fillFromInputFile ( const std::string &  filename)

Builder function to fill the contents of TopologyInformation in topInfo from filename.

Different tools require, might need, would benefit from, or do not need topology information. This functions implements the two-phase construction that is currently needed to support that.

Any coordinate or run input file format will work, but the kind of data available from the getter methods afterwards will vary. For example, the mtop() available after reading a plain structure file will have a single molecule block and molecule type, regardless of contents.

After reading, this object can return many kinds of primary and derived data structures to its caller.

Todo:
This should throw upon error but currently does not.
void gmx::TopologyInformation::getBox ( matrix  box) const

Gets the configuration box from the topology file.

Parameters
[out]boxBox size from the topology file, must not be nullptr.
const char * gmx::TopologyInformation::name ( ) const

Returns a name for the topology.

If a full topology was read from a a file, returns the name it contained, otherwise the empty string.

ArrayRef< const RVec > gmx::TopologyInformation::v ( ) const

Gets the configuration velocities from the topology file.

If TrajectoryAnalysisSettings::efUseTopV has not been specified, this method should not be called.

Exceptions
APIErrorif topology velocity coordinates are not available
ArrayRef< const RVec > gmx::TopologyInformation::x ( ) const

Gets the configuration positions from the topology file.

If TrajectoryAnalysisSettings::efUseTopX has not been specified, this method should not be called.

Exceptions
APIErrorif topology position coordinates are not available

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