LOOS  v2.3.2
loos::DCDWriter Class Reference

A very lightweight class for writing simple DCDs. More...

#include <dcdwriter.hpp>

Inheritance diagram for loos::DCDWriter:
Collaboration diagram for loos::DCDWriter:

Public Member Functions

 DCDWriter (const std::string &s, const bool append=false)
 Setup for writing to a file named by s. More...
 
 DCDWriter (std::iostream &fs, const bool append=false)
 Setup for writing to a stream.
 
 DCDWriter (const std::string &s, const std::vector< AtomicGroup > &grps, const bool append=false)
 Writes the coordinates of grps to file s as a DCD.
 
 DCDWriter (const std::string &s, const std::vector< AtomicGroup > &grps, const std::string &comment, const bool append=false)
 Writes coordinates of grps adding comment as a TITLE record.
 
 DCDWriter (const std::string &s, const std::vector< AtomicGroup > &grps, const std::vector< std::string > &comments, const bool append=false)
 Writes coordinates of grps adding comments as TITLE records.
 
void setHeader (const int na, const int ns, const greal ts, const bool bf)
 Sets header parameters. More...
 
void setTitles (const std::vector< std::string > &titles)
 
void setTitle (const std::string &s)
 
void addTitle (const std::string &s)
 
void setComments (const std::vector< std::string > &comments)
 Set comments in metadata (not all formats support)
 
bool hasComments () const
 Does format support comments in metadata?
 
void writeFrame (const AtomicGroup &grp)
 Writes a frame to a growing DCD. More...
 
void writeFrames (const std::vector< AtomicGroup > &grps)
 Same as writeFrame(), but writes out the vector of frames...
 
void writeHeader (void)
 
uint framesWritten (void) const
 Total frames in output file. More...
 
- Public Member Functions inherited from loos::TrajectoryWriter
 TrajectoryWriter (const std::string &fname, const bool append=false)
 Write a trajectory to a file, optionally appending.
 
 TrajectoryWriter (std::iostream *s, const bool append=false)
 Write a trajectory to a stream. More...
 
virtual void setComments (const std::string &s)
 Set comment in metadata (not all formats support)
 
virtual void writeFrame (const AtomicGroup &model, const uint step, const double time)
 Write a single frame specifying the step and timepoint. More...
 
virtual bool hasFrameStep () const
 Can format write step on a per-frame basis?
 
virtual bool hasFrameTime () const
 Can format write time on a per-frame basis?
 
bool isAppending () const
 Returns true if appending to an existing trajectory.
 

Static Public Member Functions

static pTrajectoryWriter create (const std::string &s, const bool append=false)
 

Additional Inherited Members

- Protected Attributes inherited from loos::TrajectoryWriter
std::iostream * stream_
 
std::string _filename
 
bool appending_
 
bool delete_
 

Detailed Description

A very lightweight class for writing simple DCDs.

Definition at line 48 of file dcdwriter.hpp.

Constructor & Destructor Documentation

loos::DCDWriter::DCDWriter ( const std::string &  s,
const bool  append = false 
)
inlineexplicit

Setup for writing to a file named by s.

You can opt to write the header explicitly, i.e.

DCDWriter dcd("output.dcd");
dcd.setHeader(500, 10, 1e-3, no);
dcd.setTitles("MY TITLE HERE");
dcd.writeHeader();
dcd.writeFrame(frame);

Or you can let dcdwriter create the header from the first frame written...

Definition at line 70 of file dcdwriter.hpp.

Member Function Documentation

uint loos::DCDWriter::framesWritten ( void  ) const
inlinevirtual

Total frames in output file.

For files being appended too, this includes the frames already written...

Implements loos::TrajectoryWriter.

Definition at line 209 of file dcdwriter.hpp.

void loos::DCDWriter::setHeader ( const int  na,
const int  ns,
const greal  ts,
const bool  bf 
)
inline

Sets header parameters.

These must be set prior to writing a header or frame, but it is not an error to not do so... Arguments:

  • na Number of atoms
  • ns Number of steps (total frames)
  • ts Timestep of each frame
  • bf Flag for whether or not each frame will include periodic box info as Xtal data

Definition at line 162 of file dcdwriter.hpp.

void loos::DCDWriter::writeFrame ( const AtomicGroup grp)
virtual

Writes a frame to a growing DCD.

writeFrame() will automatically extend the DCD for you if you write past the initially specified number of frames. Alternatively, you can just begin writing frames without explicitly writing a header and let writeFrame() handle it for you. As the DCD grows, writeFrame() will automatically update the header information for you.

Implements loos::TrajectoryWriter.

Definition at line 109 of file dcdwriter.cpp.


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