LOOS 4.1.0
The Lightweight Object Oriented Structural analysis library/toolkit
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
loos::DCDWriter Class Reference

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

#include <dcdwriter.hpp>

Inheritance diagram for loos::DCDWriter:
Inheritance graph
[legend]
Collaboration diagram for loos::DCDWriter:
Collaboration graph
[legend]

Public Member Functions

 DCDWriter (const std::string &s, const bool append=false)
 Setup for writing to a file named by s.
 
 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.
 
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.
 
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.
 
- 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.
 
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.
 
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.

Constructor & Destructor Documentation

◆ DCDWriter()

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);
A very lightweight class for writing simple DCDs.
Definition dcdwriter.hpp:48
Simple matrix template class using policy classes to determine behavior.
Definition MatrixImpl.hpp:148
-picker

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

Member Function Documentation

◆ framesWritten()

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.

◆ hasComments()

bool loos::DCDWriter::hasComments ( ) const
inlinevirtual

Does format support comments in metadata?

Reimplemented from loos::TrajectoryWriter.

◆ setComments()

void loos::DCDWriter::setComments ( const std::vector< std::string > & comments)
inlinevirtual

Set comments in metadata (not all formats support)

Reimplemented from loos::TrajectoryWriter.

◆ setHeader()

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

◆ writeFrame()

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.


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