Io module
Contents
- Reference
Namespaces
- namespace io
- Handles Input-Output Operations. This contains general functions for reading in and writing out files.
Functions
- auto file_exists(const std::string& name) -> bool
- auto tokenizer(std::string line) -> std::vector<std::string>
- auto tokenizerDouble(std::string line) -> std::vector<double>
- auto getTotalTimesteps(std::string filename, int* totalSteps) -> int
- auto writeRDF(double* rdfArray, double binsize, int nbin, std::string filename = "rdf.dat") -> int
Function documentation
bool file_exists(const std::string& name)
#include <code/cpp/include/inputOutput.hpp>
Parameters | |
---|---|
name in | The name of the file |
Function for checking if a file exists or not.
std::vector<std::string> tokenizer(std::string line)
#include <code/cpp/include/inputOutput.hpp>
Parameters | |
---|---|
line in | The string containing the line to be tokenized |
Function for tokenizing line strings into words (strings) delimited by whitespace. This returns a vector with the words in it.
std::vector<double> tokenizerDouble(std::string line)
#include <code/cpp/include/inputOutput.hpp>
Parameters | |
---|---|
line in | The string containing the line to be tokenized |
Function for tokenizing line strings into a vector of doubles.
int getTotalTimesteps(std::string filename,
int* totalSteps)
#include <code/cpp/include/inputOutput.hpp>
Parameters | |
---|---|
filename in | The path of the LAMMPS trajectory file |
totalSteps in | Pointer to the total number of steps or frames in the trajectory |
Returns | an int value of 0 (successful file opening) or 1 (error) |
Function for getting the total number of timesteps from a lammps trajectory. This also includes 'incomplete' frames, so it should be used with caution.
int writeRDF(double* rdfArray,
double binsize,
int nbin,
std::string filename = "rdf.dat")
#include <code/cpp/include/inputOutput.hpp>
Parameters | |
---|---|
rdfArray in | The array containing the calculated |
binsize in | The bin-width or bin size of each bin, which is user-defined |
nbin in | The total number of bins in the histogram |
filename in | (Optional argument) Specifies a user-defined file output name, which will be saved inside a directory called 'output' in the top-level directory of the code folder. |
Returns | an int value of 0 (success) or 1 (error) |
Writes out a file containing the r and g(r) values