Gromacs  2025-dev-20241008-cf8b9ef
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions
gmx::AnalysisDataFrameLocalData< ValueType > Class Template Reference

#include <gromacs/analysisdata/framelocaldata.h>

Description

template<typename ValueType>
class gmx::AnalysisDataFrameLocalData< ValueType >

Container for an array of frame-local values that supports parallel data processing.

Template Parameters
ValueTypeType of values to store.

This class provides a convenient interface to create an array of frame-local data for use in analysis data modules that support parallel processing. The object is initialized by setting the desired dimensionality with setDataSetCount() and setColumnCount(), followed by a call to init(), typically in IAnalysisDataModule::parallelDataStarted(),

After initialization, frameData() can be used to access the data for a given frame, independently from other frames. This works if the assumptions about parallelism hold: if N is the parallelization factor given for init() with AnalysisDataParallelOptions::parallelizationFactor(), then frame i+N must not be accessed before all processing for frame i is finished. Technically, the data for different frames is kept in a ring buffer of size N.

The data for a frame is not cleared after it is reused for a new frame (but is initially cleared). This allows using the data for accumulating values over all frames in a lock-free manner.

frameDataSet() is provided for convenience when only a single data set needs to be accessed (typically in IAnalysisDataModule::pointsAdded()).

Methods in this class do not throw except where indicated.

See Also
AnalysisDataFrameLocalData

Public Types

typedef std::vector< ValueType > ValueArray
 Shorthand for the internal array of values for a frame.
 
typedef
AnalysisDataFrameLocalDataHandle
< ValueType > 
FrameHandle
 Shorthand for a handle to a single frame.
 
typedef
AnalysisDataFrameLocalDataSetHandle
< ValueType > 
DataSetHandle
 Shorthand for a handle to a single data set.
 

Public Member Functions

 AnalysisDataFrameLocalData ()
 Constructs an empty container with a single data set.
 
bool isInitialized () const
 Whether init() has been called.
 
int frameCount () const
 Returns number of independent data frames in this object. More...
 
void setDataSetCount (int dataSetCount)
 Sets the number of data sets stored for each frame. More...
 
void setColumnCount (int dataSet, int columnCount)
 Sets the number of columns stored for a data set. More...
 
void init (const AnalysisDataParallelOptions &opt)
 Initializes the storage to support specified parallelism. More...
 
FrameHandle frameData (int frameIndex)
 Returns a handle to access data for a frame.
 
DataSetHandle frameDataSet (int frameIndex, int dataSet)
 Returns a handle to access a single data set within a frame.
 

Member Function Documentation

template<typename ValueType>
int gmx::AnalysisDataFrameLocalData< ValueType >::frameCount ( ) const
inline

Returns number of independent data frames in this object.

This supports looping over all the frame arrays to, e.g., sum them up at the end in accumulation scenarios.

template<typename ValueType>
void gmx::AnalysisDataFrameLocalData< ValueType >::init ( const AnalysisDataParallelOptions opt)
inline

Initializes the storage to support specified parallelism.

Exceptions
std::bad_allocif out of memory.
template<typename ValueType>
void gmx::AnalysisDataFrameLocalData< ValueType >::setColumnCount ( int  dataSet,
int  columnCount 
)
inline

Sets the number of columns stored for a data set.

Must be called for each data set that needs to have values, otherwise there will be zero columns for that data set. Cannot be called after init().

template<typename ValueType>
void gmx::AnalysisDataFrameLocalData< ValueType >::setDataSetCount ( int  dataSetCount)
inline

Sets the number of data sets stored for each frame.

Exceptions
std::bad_allocif out of memory.

If not called, there is a single data set in the object. Cannot be called after init().


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