Loading...
Searching...
No Matches
TRRFile.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_FORMAT_TRRFILE_H
#define BALL_FORMAT_TRRFILE_H
#ifndef BALL_FORMAT_TRAJECTORYFILE_H
# include <BALL/FORMAT/trajectoryFile.h>
#endif
#ifndef BALL_SYSTEM_BINARYFILEADAPTOR_H
# include <BALL/SYSTEM/binaryFileAdaptor.h>
#endif
namespace BALL
{
class BALL_EXPORT TRRFile
: public TrajectoryFile
{
public:
static const double to_angstrom;
static const double to_nanometer;
class BALL_EXPORT TRRHeader
{
public:
Size MAGIC;
Size VERSION;
Size title_string_length;
String title_string;
Size ir_size;
Size e_size;
Size bounding_box_data_size;
Size vir_size;
Size pres_size;
Size top_size;
Size sym_size;
Size position_data_size;
Size velocity_data_size;
Size force_data_size;
Size number_of_atoms;
Size timestep_index;
Size nre;
float timestep_time;
float lambda;
TRRHeader()
: MAGIC(1993),
VERSION(13),
title_string_length(24),
title_string("Created by BALL::TRRFile"),
ir_size(0),
e_size(0),
vir_size(0),
pres_size(0),
top_size(0),
sym_size(0),
velocity_data_size(0),
force_data_size(0),
timestep_index(0),
nre(0),
timestep_time(0.002),
lambda(0)
{
}
};
TRRFile();
TRRFile(const String& name, File::OpenMode open_mode = std::ios::in);
virtual ~TRRFile();
virtual void clear();
bool operator == (const TRRFile& file) const;
virtual bool init();
virtual bool readHeader();
virtual bool writeNextHeader(const TRRHeader& header);
virtual bool readNextHeader(TRRHeader& header);
virtual bool append(const SnapShot& snapshot);
virtual bool read(SnapShot& snapshot);
virtual bool skipFrame();
virtual Size getNumberOfSnapShots();
virtual TRRFile& operator >> (SnapShotManager& ssm);
virtual bool flushToDisk(const std::vector<SnapShot>& buffer);
bool hasVelocities() const;
void setVelocityStorage(bool storage);
bool hasForces() const;
void setForceStorage(bool storage);
Size getPrecision() const;
bool setPrecision(const Size precision);
float getTimestep() const;
void setTimestep(float timestep);
Vector3 getBoundingBoxX() const;
Vector3 getBoundingBoxY() const;
Vector3 getBoundingBoxZ() const;
void setBoundingBox(const Vector3& x, const Vector3& y, const Vector3& z);
private:
const TRRFile& operator = (const TRRFile& file);
protected:
// the current step's header
TRRHeader header_;
// the precision of the file in bytes per value
Size precision_;
// a flag deciding if the file contains velocities
bool has_velocities_;
// a flag deciding if the file contains forces
bool has_forces_;
// the index of the current timestep / snapshot
Size timestep_index_;
// the length of the timestep
float timestep_;
// three vectors containing the base vectors of the box in
// nanometers
Vector3 box1_, box2_, box3_;
BinaryFileAdaptor<Size> adapt_size_;
BinaryFileAdaptor<char> adapt_char_;
BinaryFileAdaptor<float> adapt_float_;
BinaryFileAdaptor<double> adapt_double_;
Size old_file_size_;
};
} // namespace BALL
#endif // BALL_FORMAT_TRRFILE_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
binaryFileAdaptor.h
BALL::BinaryFileAdaptor
Definition binaryFileAdaptor.h:54
BALL::File::OpenMode
std::ios::openmode OpenMode
Definition file.h:165
BALL::SnapShotManager
Definition snapShotManager.h:34
BALL::SnapShot
Definition snapShot.h:30
BALL::String
Definition string.h:57
BALL::TRRFile::TRRHeader
Definition TRRFile.h:47
BALL::TRRFile::TRRHeader::timestep_index
Size timestep_index
Definition TRRFile.h:120
BALL::TRRFile::TRRHeader::velocity_data_size
Size velocity_data_size
Definition TRRFile.h:106
BALL::TRRFile::TRRHeader::pres_size
Size pres_size
Definition TRRFile.h:85
BALL::TRRFile::TRRHeader::ir_size
Size ir_size
Definition TRRFile.h:61
BALL::TRRFile::TRRHeader::title_string_length
Size title_string_length
The length of the title string.
Definition TRRFile.h:55
BALL::TRRFile::TRRHeader::e_size
Size e_size
Definition TRRFile.h:65
BALL::TRRFile::TRRHeader::position_data_size
Size position_data_size
Definition TRRFile.h:100
BALL::TRRFile::TRRHeader::vir_size
Size vir_size
Definition TRRFile.h:79
BALL::TRRFile::TRRHeader::bounding_box_data_size
Size bounding_box_data_size
Definition TRRFile.h:73
BALL::TRRFile::TRRHeader::force_data_size
Size force_data_size
Definition TRRFile.h:112
BALL::TRRFile::TRRHeader::title_string
String title_string
The title string.
Definition TRRFile.h:57
BALL::TRRFile::TRRHeader::TRRHeader
TRRHeader()
Definition TRRFile.h:136
BALL::TRRFile::TRRHeader::number_of_atoms
Size number_of_atoms
Definition TRRFile.h:116
BALL::TRRFile::TRRHeader::nre
Size nre
Definition TRRFile.h:125
BALL::TRRFile::TRRHeader::top_size
Size top_size
Definition TRRFile.h:90
BALL::TRRFile::TRRHeader::MAGIC
Size MAGIC
Magic number for the TRR format. This must be equal to 1993.
Definition TRRFile.h:51
BALL::TRRFile::TRRHeader::timestep_time
float timestep_time
Definition TRRFile.h:129
BALL::TRRFile::TRRHeader::lambda
float lambda
Definition TRRFile.h:134
BALL::TRRFile::TRRHeader::VERSION
Size VERSION
The version number of the TRR format.
Definition TRRFile.h:53
BALL::TRRFile::TRRHeader::sym_size
Size sym_size
Definition TRRFile.h:95
BALL::TRRFile::old_file_size_
Size old_file_size_
Definition TRRFile.h:319
BALL::TRRFile::to_angstrom
static const double to_angstrom
Definition TRRFile.h:33
BALL::TRRFile::TRRFile
TRRFile(const String &name, File::OpenMode open_mode=std::ios::in)
Construct and open a file.
BALL::TRRFile::setVelocityStorage
void setVelocityStorage(bool storage)
BALL::TRRFile::skipFrame
virtual bool skipFrame()
BALL::TRRFile::getTimestep
float getTimestep() const
BALL::TRRFile::setTimestep
void setTimestep(float timestep)
BALL::TRRFile::adapt_size_
BinaryFileAdaptor< Size > adapt_size_
Definition TRRFile.h:314
BALL::TRRFile::box2_
Vector3 box2_
Definition TRRFile.h:312
BALL::TRRFile::box1_
Vector3 box1_
Definition TRRFile.h:312
BALL::TRRFile::setForceStorage
void setForceStorage(bool storage)
BALL::TRRFile::precision_
Size precision_
Definition TRRFile.h:296
BALL::TRRFile::flushToDisk
virtual bool flushToDisk(const std::vector< SnapShot > &buffer)
BALL::TRRFile::setBoundingBox
void setBoundingBox(const Vector3 &x, const Vector3 &y, const Vector3 &z)
BALL::TRRFile::has_forces_
bool has_forces_
Definition TRRFile.h:302
BALL::TRRFile::writeNextHeader
virtual bool writeNextHeader(const TRRHeader &header)
BALL::TRRFile::read
virtual bool read(SnapShot &snapshot)
BALL::TRRFile::timestep_
float timestep_
Definition TRRFile.h:308
BALL::TRRFile::has_velocities_
bool has_velocities_
Definition TRRFile.h:299
BALL::TRRFile::header_
TRRHeader header_
Definition TRRFile.h:293
BALL::TRRFile::readHeader
virtual bool readHeader()
BALL::TRRFile::timestep_index_
Size timestep_index_
Definition TRRFile.h:305
BALL::TRRFile::adapt_char_
BinaryFileAdaptor< char > adapt_char_
Definition TRRFile.h:315
BALL::TRRFile::getBoundingBoxX
Vector3 getBoundingBoxX() const
BALL::TRRFile::clear
virtual void clear()
Clear method.
BALL::TRRFile::adapt_float_
BinaryFileAdaptor< float > adapt_float_
Definition TRRFile.h:316
BALL::TRRFile::getPrecision
Size getPrecision() const
BALL::TRRFile::hasForces
bool hasForces() const
BALL::TRRFile::hasVelocities
bool hasVelocities() const
BALL::TRRFile::append
virtual bool append(const SnapShot &snapshot)
BALL::TRRFile::TRRFile
TRRFile()
Default constructor.
BALL::TRRFile::box3_
Vector3 box3_
Definition TRRFile.h:312
BALL::TRRFile::~TRRFile
virtual ~TRRFile()
Destructor.
BALL::TRRFile::to_nanometer
static const double to_nanometer
Definition TRRFile.h:34
BALL::TRRFile::readNextHeader
virtual bool readNextHeader(TRRHeader &header)
BALL::TRRFile::getBoundingBoxZ
Vector3 getBoundingBoxZ() const
BALL::TRRFile::init
virtual bool init()
Initialize the file for usage.
BALL::TRRFile::getBoundingBoxY
Vector3 getBoundingBoxY() const
BALL::TRRFile::setPrecision
bool setPrecision(const Size precision)
BALL::TRRFile::adapt_double_
BinaryFileAdaptor< double > adapt_double_
Definition TRRFile.h:317
BALL::TRRFile::getNumberOfSnapShots
virtual Size getNumberOfSnapShots()
BALL::TrajectoryFile::TrajectoryFile
TrajectoryFile()
Default constructor.
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Vector3
TVector3< float > Vector3
Definition vector3.h:1084
trajectoryFile.h