Go to the documentation of this file.
6 #ifndef OPENMPCD_VTFSNAPSHOTFILE_HPP
7 #define OPENMPCD_VTFSNAPSHOTFILE_HPP
14 #include <boost/optional.hpp>
58 boost::optional<std::string>
name;
59 boost::optional<std::string>
type;
110 return structureBlockProcessed;
128 const FP& x,
const FP& y,
const FP& z);
135 return primarySimulationVolumeSizeSet;
151 return primarySimulationVolumeSize;
169 const std::pair<std::size_t, std::size_t>
194 const std::size_t count,
const FP radius,
195 const std::string& name,
const std::string& type);
202 if(atomRanges.empty())
205 return atomRanges.back().last + 1;
246 void declareBond(std::size_t atom1, std::size_t atom2);
255 const std::set<std::pair<std::size_t, std::size_t> >&
getBonds()
const
273 bool hasBond(std::size_t atom1, std::size_t atom2)
const;
300 const FP*
const positions,
301 const FP*
const velocities = NULL);
345 FP*
const velocities = NULL,
346 bool*
const velocitiesEncountered = NULL);
357 AtomProperties properties;
368 void assertWriteMode()
const;
376 void assertReadMode()
const;
384 void assertStructureBlockNotProcessed()
const;
396 void writeStructureBlock();
406 void readStructureBlock();
416 void readUnitcellLine(
const std::string& line);
426 void writeAtomLines();
438 void readAtomLine(
const std::string& line_);
444 void setAtomRange(
const AtomRange& range);
453 void assertAtomRangesContiguous()
const;
463 void writeBondLines();
475 void readBondLine(
const std::string& line_);
487 const std::string getLine(
const bool extract);
494 static const std::string stripLeadingWhitespace(
const std::string& str);
506 template<
typename T>
static T lexicalCast(
const std::string& str)
510 return boost::lexical_cast<T>(str);
512 catch(
const boost::bad_lexical_cast&)
522 bool structureBlockProcessed;
525 bool primarySimulationVolumeSizeSet;
529 Vector3D<FP> primarySimulationVolumeSize;
532 AtomProperties defaultAtomProperties;
534 std::list<AtomRange> atomRanges;
536 std::set<std::pair<std::size_t, std::size_t> > bonds;
bool structureBlockHasBeenProcessed() const
Returns whether the structure block has been processed already.
const Vector3D< FP > & getPrimarySimulationVolumeSize() const
Returns the size of the primary simulation volume.
virtual ~VTFSnapshotFile()
The destructor.
Exception for a forbidden function call.
#define OPENMPCD_THROW(ExceptionType, message)
Throws the given ExceptionType, passing the given message along with file and line number information...
void writeTimestepBlock(const FP *const positions, const FP *const velocities=NULL)
Starts a new timestep block, and writes the atom coordinates given.
std::size_t getNumberOfAtoms() const
Returns the number of atoms that have been declared.
boost::optional< std::string > name
The name of the atom.
VTFSnapshotFile(const std::string &path_)
The constructor.
const std::pair< std::size_t, std::size_t > declareAtoms(const std::size_t count)
Declares a number of atoms.
Collection of properties of atoms.
boost::optional< FP > radius
The radius of the atom.
const AtomProperties & getAtomProperties(const std::size_t atomID) const
Returns the properties of the given atomID.
void declareBond(std::size_t atom1, std::size_t atom2)
Declares a bond between the two given atoms.
const std::set< std::pair< std::size_t, std::size_t > > & getBonds() const
Returns the set of bonds between atoms.
double FP
Default floating point type.
bool readTimestepBlock(FP *const positions, FP *const velocities=NULL, bool *const velocitiesEncountered=NULL)
Reads the next timestep block.
void setPrimarySimulationVolumeSize(const FP &x, const FP &y, const FP &z)
Sets the size of the primary simulation volume.
bool isInWriteMode() const
Returns whether the instance is in write mode.
Representation of a simulation snapshot file in the VTF format.
Base class for files that contain one or more simulation snapshots.
bool primarySimulationVolumeSizeIsSet() const
Returns whether the size of the primary simulation volume is set.
bool hasBond(std::size_t atom1, std::size_t atom2) const
Returns whether the two given atoms share a bond.
bool isValidAtomID(const std::size_t atomID) const
Returns whether the given number is a valid atom ID, i.e.
boost::optional< std::string > type
The type of the atom.
bool isInReadMode() const
Returns whether the instance is in read mode.