Readers.h¶
Readers for parsing LAMMPS dumpfiles and datafiles.
-
struct
InputStream¶ - #include <Readers.h>
Convenience wrapper around ifstream.
Public Functions
-
InputStream()¶
-
InputStream(string _filename)¶ Open the stream upon instantiation.
-
~InputStream()¶ Close the stream.
-
void
open(string _filename)¶ Open the stream and call verifyStream.
-
void
skipLines(int numLines)¶ Skip
numLineslines forward in the file.
-
void
skipWhitespace()¶ Consume consecutive whitespace following the cursor.
-
bool
search(string term)¶ Search for line containing
term.Move the ifstream cursor to the beginning of the first line containing
term. (the matching line will not be consumed) Returns whether the line was found
-
string
search(vector<string> terms)¶ Search for line containing an element of
terms.Move the ifstream cursor one line past the first line containing one of the strings in
terms. (the matching line will be consumed) Returns the line found
-
bool
searchLine(string term)¶ Skip past line containing
term.Move the ifstream cursor one line past the first line exactly equal to
term. (the matching line will be consumed) Returns whether the line was found.
-
string
searchLine(vector<string> terms)¶ Skip past line containing an element of
terms.
-
bool
nextLineBlank()¶ Whether the next line is blank.
-
string
peekLine()¶ Read the next line and return the cursor to its previous position.
-
-
class
HeaderReader¶ - #include <Readers.h>
Reads the header from a LAMMPS dumpfile.
Read the timestep and box bounds.
- Note
- Could also (but currently does not) read the number of atoms.
- See
- TimestepReader.
Public Functions
-
void
setContext(Options options, InputStream *_inputStreamPtr, SimData *_simDataPtr, Timestep *_timestepPtr, int *_lineNumPtr, BoxBounds *_boundsPtr)¶ Copy options and save pointers to relevant quantities.
Called by TimestepReader::setContext.
-
void
readHeader()¶
Public Members
-
int *
lineNumPtr¶
-
class
LineReader¶ - #include <Readers.h>
Reads one line at a time of atom positions from LAMMPS dumpfile.
Reads scaled positions and calculates unitful positions.
- See
- TimestepReader.
Public Functions
-
void
setContext(Options options, InputStream *_inputStreamPtr, int *_atomNumPtr, int *_lineNumPtr, BoxBounds *_boundsPtr)¶ Copy options and save pointers to relevant quantities.
Called by TimestepReader::setContext.
-
class
TimestepReader¶ - #include <Readers.h>
Read one timestep at a time from a LAMMP dumpfile.
Reads both the header and position lines.
- See
- FrameReader.
Public Functions
-
TimestepReader()¶
-
void
setContext(Options _options, InputStream *_inputStreamPtr, AtomArray *_atomArrayPtr, Timestep *_timestepPtr, SimData *_simDataPtr)¶ Copy options and save pointers to relevant quantities.
Called by FrameReader::setContext.
-
void
readTimestep(int stepInFrame)¶ Read one timestep.
stepInFrameis necessary to determine the index to store atom position in atomArrayPtr.
-
class
FrameReader¶ - #include <Readers.h>
Read one frame, containing multiple timesteps from a LAMMP dumpfile.
The size of a frame is determined by Options::stepsPerFrame (although the last frame may be a different size).
- See
- Frame::stepsThisFrame.
- See
- LastFrame::numSteps.
- See
- DumpfileReader.
Public Functions
-
FrameReader()¶
-
void
setContext(Options options, AtomArray *_atomArrayPtr, SimData *_simDataPtr)¶ Copy options and save pointers to relevant quantities.
Called by DumpfileReader::DumpfileReader.
-
void
openStream()¶ Open inputStream with Options::dumpfile.
-
void
updateFrame()¶ Set frame variables from first timestep in frame.
Timestep::stepNum -> Frame::frameStep Timestep::time -> Frame::time
-
void
readFrame()¶ Read one frame.
Read first timestep separately to set frame variables to those of the first timestep in the frame.
-
void
countAtoms()¶ Count the number of atoms in the simulation (in one timestep).
-
void
countSteps()¶ Count the number of timesteps in the dumpfile.
Called by DumpfileReader::DumpfileReader.
-
class
DatafileReader¶ - #include <Readers.h>
Read a LAMMPS Datafile.
Reads box dimensions, number of atoms, masses of each type, and water bonds (useful if water molecule orientation is desired).
- Note
- Water bonds are not currently utilized.
Public Functions
-
void
openStream()¶ Open Options::datafile for reading.
-
void
read()¶ Read the whole datafile.
-
struct
DumpfileReader¶ - #include <Readers.h>
Read a LAMMPS Dumpfile one frame at a time.
Public Functions
-
void
countAtoms()¶ Count the number of water atoms in the first timestep.
- Note
- This method is not currently called anywhere.
-
void
countSteps()¶
-
void
readFrame()¶
-
bool
good()¶ Whether another frame can be read.
Compare frame numbers to see if this is the end.
-
void