Molecular Dynamics  v0.4
Project for the Practical hosted by the Scientific Computing Chair
Static Public Member Functions | Static Private Member Functions | List of all members
FileReader Class Reference

Class for reading particles from txt files. At the moment file formats Cuboid and Particle are supported. More...

#include <TxtReader.h>

Collaboration diagram for FileReader:
Collaboration graph

Static Public Member Functions

static int readFile (ParticleContainer &particles, const std::string &filename)
 Read txt files containing cuboid or particle data. More...
 

Static Private Member Functions

static int readCuboid (ParticleContainer &particles, std::ifstream &input_file)
 Helper method to read files containing cuboids. More...
 
static int readParticle (ParticleContainer &particles, std::ifstream &input_file)
 Helper method to read files containing particles. More...
 

Detailed Description

Class for reading particles from txt files. At the moment file formats Cuboid and Particle are supported.

Member Function Documentation

◆ readCuboid()

int FileReader::readCuboid ( ParticleContainer particles,
std::ifstream &  input_file 
)
staticprivate

Helper method to read files containing cuboids.

Parameters
particlesParticle Container to store the particles in.
input_fileInput file stream being currently at the position of that line, in which the number of cuboids is specified.

Only parses files correctly which adhere to the particle format. If the file pretends to contain valid cuboid data, but violates the input format for some reason, this method may provide erroneous data. If an error is detected, this function returns -1. The key word Cuboid in the first non comment line of a file indicates the cuboid file format. Look at 2D-cuboid.collision.txt for reference.

Returns
0, if the operation was successful, -1 otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readFile()

int FileReader::readFile ( ParticleContainer particles,
const std::string &  filename 
)
static

Read txt files containing cuboid or particle data.

Parameters
particlesParticle Container to store the particles in.
filenamePath to the file to be read.

Valid file formats are Cuboid and Particle. The format of a txt file must be specified in the first line that is not a comment. Look at the files in the input file for more information. Any other file format will be rejected. If the specified file format is violated, the data may not be read correctly.

Returns
0, if the operation was successful, -1 if the file format is violated, -2 if the file could not be opened and -3 if the the file format is unknown
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readParticle()

int FileReader::readParticle ( ParticleContainer particles,
std::ifstream &  input_file 
)
staticprivate

Helper method to read files containing particles.

Parameters
particlesParticle Container to store the particles in.
input_fileInput file stream being currently at the position of that line, in which the number of particles is specified.

Only parses files correctly which adhere to the particle format. If the file pretends to contain valid particle data, but violates the input format for some reason, this method may provide erroneous data. If an error is detected, this function returns -1. The key word Particle in the first non comment line of a file indicates the particle file format. Look at eingabe-sonne.txt for reference.

Returns
0, if the operation was successful, -1 otherwise
Here is the call graph for this function:
Here is the caller graph for this function:

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