BALL  1.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Protected Member Functions | Protected Attributes | List of all members
BALL::SnapShotManager Class Reference

#include <BALL/MOLMEC/COMMON/snapShotManager.h>

Classes

struct  Default
 Local class for handling default values for the options. More...
 
struct  Option
 Local class for handling options. More...
 

Public Member Functions

Constructors and Destructors
 SnapShotManager ()
 Default constructor. More...
 
 SnapShotManager (System *my_system, TrajectoryFile *my_snapshot_file=0)
 
 SnapShotManager (System *my_system, const ForceField *my_force_field, TrajectoryFile *my_snapshot_file)
 
 SnapShotManager (System *my_system, const ForceField *my_force_field, const Options &my_options, TrajectoryFile *file)
 
 SnapShotManager (const SnapShotManager &manager)
 Copy constructor. More...
 
virtual ~SnapShotManager ()
 Destructor. More...
 
Setup methods
bool setup (System *my_system, const ForceField *my_forcefield, TrajectoryFile *my_snapshot_file)
 
bool setup (System *my_system, TrajectoryFile *my_snapshot_file)
 
virtual bool setup ()
 
Assignment
const SnapShotManageroperator= (const SnapShotManager &manager)
 
virtual void clear ()
 Clear method. More...
 
Debugging and diagnostics
virtual bool isValid () const
 
Accessors
void setSystem (System *my_system)
 
SystemgetSystem () const
 get a const pointer to the system member More...
 
void setForceField (const ForceField *my_ff)
 set the force field More...
 
const ForceFieldgetForceField () const
 get a const pointer to the force field More...
 
void setTrajectoryFile (TrajectoryFile *my_file)
 set the trajectory file More...
 
TrajectoryFilegetTrajectoryFile () const
 get a pointer to the trajectory file More...
 
void setFlushToDiskFrequency (Size number)
 
Size getFlushToDiskFrequency () const
 
virtual void takeSnapShot () throw (File::CannotWrite)
 
virtual bool applySnapShot (Size number)
 
virtual bool applyFirstSnapShot ()
 
virtual bool applyNextSnapShot ()
 
virtual bool applyLastSnapShot ()
 
virtual void flushToDisk () throw (File::CannotWrite)
 
Size getNumberOfSnapShotsInBuffer ()
 
Position getCurrentSnapshotNumber () const
 
bool readFromFile ()
 
void clearBuffer ()
 Clear all currently loaded SnapShot 's. More...
 

Public Attributes

Public Attributes
Options options
 The available options for this class. More...
 

Protected Member Functions

double calculateKineticEnergy_ ()
 

Protected Attributes

Systemsystem_ptr_
 
const ForceFieldforce_field_ptr_
 
vector< SnapShotsnapshot_buffer_
 
TrajectoryFiletrajectory_file_ptr_
 
Size flush_to_disk_frequency_
 
Size buffer_counter_
 
Position current_snapshot_
 

Detailed Description

Snapshot management e.g. for MD simulations. This class manages a list of single SnapShot objects. Snapshots are numbered starting with 1.

Definition at line 33 of file snapShotManager.h.

Constructor & Destructor Documentation

BALL::SnapShotManager::SnapShotManager ( )

Default constructor.

BALL::SnapShotManager::SnapShotManager ( System my_system,
TrajectoryFile my_snapshot_file = 0 
)

Constructor for a system and trajectory file. The internal reference to a force field will be set to NULL

Parameters
my_systemthe system to bind this manager to
my_snapshot_filean optional file containing a trajectory for the my_system's atoms
BALL::SnapShotManager::SnapShotManager ( System my_system,
const ForceField my_force_field,
TrajectoryFile my_snapshot_file 
)

This constructor expects a valid system, a valid force field and the name of a snapshot file. Any existing file of the given name will be overwritten.

Parameters
my_systemthe system to bind this manager to
my_force_fieldthe force field that is bound to the system
my_snapshot_filea file containing a trajectory for the my_system's atoms
BALL::SnapShotManager::SnapShotManager ( System my_system,
const ForceField my_force_field,
const Options my_options,
TrajectoryFile file 
)

This constructor expects a valid system, a valid force field and the name of a snapshot file. Any existing file of the given name will be overwritten.

Parameters
my_systemthe system to bind this manager to
my_force_fieldthe force field that is bound to the system
my_options
filenamethe name of the snapshot file
BALL::SnapShotManager::SnapShotManager ( const SnapShotManager manager)

Copy constructor.

virtual BALL::SnapShotManager::~SnapShotManager ( )
virtual

Destructor.

Member Function Documentation

virtual bool BALL::SnapShotManager::applyFirstSnapShot ( )
virtual

Read a the first SnapShot from the associated TrajectoryFile.

Parameters
snapshota buffer for returning the snapshot
Returns
true if the snapshot could be read, false ow.
virtual bool BALL::SnapShotManager::applyLastSnapShot ( )
virtual

This method applies the last SnapShot of the associated file i. e. writes all available data (positions, forces, etc.) from the SnapShot to the System. Note that a SnapShot does not need to have all data.

virtual bool BALL::SnapShotManager::applyNextSnapShot ( )
virtual

Read a the next SnapShot from the associated TrajectoryFile and apply it to the system

Parameters
snapshota buffer for returning the snapshot
Returns
true if the snapshot could be read, false ow.
virtual bool BALL::SnapShotManager::applySnapShot ( Size  number)
virtual

Read a certain SnapShot from a TrajectoryFile. This method tries to read SnapShot number number from the file

Parameters
numberthe number of the snapshot we want to read
snapshota buffer for returning the snapshot
Returns
true if the snapshot could be read, false ow.
double BALL::SnapShotManager::calculateKineticEnergy_ ( )
protected
virtual void BALL::SnapShotManager::clear ( )
virtual

Clear method.

void BALL::SnapShotManager::clearBuffer ( )

Clear all currently loaded SnapShot 's.

virtual void BALL::SnapShotManager::flushToDisk ( ) throw (File::CannotWrite)
virtual

This method writes all snapshots taken so far to hard disk

Exceptions
File::CannotWritethrown if the snapshots could not be flushed to disk
Position BALL::SnapShotManager::getCurrentSnapshotNumber ( ) const
inline

Definition at line 227 of file snapShotManager.h.

Size BALL::SnapShotManager::getFlushToDiskFrequency ( ) const

Get the current frequency for doing saves to hard disk

Returns
the number of snapshots to take before flushing them to disk
const ForceField* BALL::SnapShotManager::getForceField ( ) const

get a const pointer to the force field

Size BALL::SnapShotManager::getNumberOfSnapShotsInBuffer ( )
inline

Definition at line 224 of file snapShotManager.h.

System* BALL::SnapShotManager::getSystem ( ) const

get a const pointer to the system member

TrajectoryFile* BALL::SnapShotManager::getTrajectoryFile ( ) const

get a pointer to the trajectory file

virtual bool BALL::SnapShotManager::isValid ( ) const
virtual

Is the SnapshotManager ready for use?

const SnapShotManager& BALL::SnapShotManager::operator= ( const SnapShotManager manager)

The assignment operator.

bool BALL::SnapShotManager::readFromFile ( )

Try to read all SnapShot 's from the TrajectoryFile into the memory.

void BALL::SnapShotManager::setFlushToDiskFrequency ( Size  number)

Set the frequency for saving snapshots to hard disk. Every 'number' iterations, a save will be done.

Parameters
numberthe number of snapshots to take before flushing to disk
void BALL::SnapShotManager::setForceField ( const ForceField my_ff)

set the force field

void BALL::SnapShotManager::setSystem ( System my_system)

Set the system member

Parameters
my_systema const pointer to the system to which this SnapshotManager will be bound
void BALL::SnapShotManager::setTrajectoryFile ( TrajectoryFile my_file)

set the trajectory file

bool BALL::SnapShotManager::setup ( System my_system,
const ForceField my_forcefield,
TrajectoryFile my_snapshot_file 
)

This setup method sets all necessary members and calls setup afterwards.

Parameters
my_systemthe System to which we want to bind this SnapShotManager
my_force_fieldthe respective forcefield
my_snapshot_filethe trajectory file we want to use
Returns
true, if the setup was succesful, false ow.
bool BALL::SnapShotManager::setup ( System my_system,
TrajectoryFile my_snapshot_file 
)

This setup method sets all necessary members and calls setup afterwards. The internal force field reference is set to NULL.

Parameters
my_systemthe System to which we want to bind this SnapShotManager
my_snapshot_filethe trajectory file we want to use
Returns
true, if the setup was succesful, false ow.
virtual bool BALL::SnapShotManager::setup ( )
virtual

The setup method does all preparations necessary for using the SnapshotManager.

Returns
true, if setup was succesful
virtual void BALL::SnapShotManager::takeSnapShot ( ) throw (File::CannotWrite)
virtual

This method takes a snapshot of the system's current state and stores it in main memory. If there is not sufficient space, the snapshots collected so far are flushed to hard disk. The first snapshot taken has index 1.

Exceptions
File::CannotWritethrown if the snapshot could not be flushed to disk

Member Data Documentation

Size BALL::SnapShotManager::buffer_counter_
protected

Definition at line 267 of file snapShotManager.h.

Position BALL::SnapShotManager::current_snapshot_
protected

Definition at line 270 of file snapShotManager.h.

Size BALL::SnapShotManager::flush_to_disk_frequency_
protected

Definition at line 264 of file snapShotManager.h.

const ForceField* BALL::SnapShotManager::force_field_ptr_
protected

Definition at line 253 of file snapShotManager.h.

Options BALL::SnapShotManager::options

The available options for this class.

Definition at line 241 of file snapShotManager.h.

vector<SnapShot> BALL::SnapShotManager::snapshot_buffer_
protected

Definition at line 256 of file snapShotManager.h.

System* BALL::SnapShotManager::system_ptr_
protected

Definition at line 250 of file snapShotManager.h.

TrajectoryFile* BALL::SnapShotManager::trajectory_file_ptr_
protected

Definition at line 259 of file snapShotManager.h.