Superclass which implements functionality to output data to a file on disk.
More...
#include <FileWriter.h>
|
| | FileWriter () |
| | Creates a new FileWriter with no file initialized.
|
| |
| | FileWriter (const std::string &filename) |
| | Creates a new FileWriter and opens the file with the given name.
|
| |
| virtual | ~FileWriter () |
| | Closes the opened file and destroys the FileWriter object.
|
| |
| void | openFile (const std::string &filename) |
| | Opens / creates the file with the given name.
|
| |
| void | closeFile () |
| | Closes the opened file if it exists, otherwise does nothing.
|
| |
| void | writeFile (const std::string &content, const std::string &filename="", int iteration=-1, int total=-1) |
| | Overwrites the contents of the file opened in m_file with a given string. On error, the program will terminate.
|
| |
| virtual void | writeParticles (const ParticleContainer &particles, int iteration, int total)=0 |
| | Interface function for writing the type, mass, position, velocity and force of a ParticleContainer to a file. Terminates program execution on error.
|
| |
|
| static void | initializeFolder (const std::string &dirname) |
| | (Re)initializes the output directory.
|
| |
|
| std::ofstream | m_file |
| | Output stream containing the file to write contents to.
|
| |
Superclass which implements functionality to output data to a file on disk.
◆ FileWriter() [1/2]
| FileWriter::FileWriter |
( |
| ) |
|
Creates a new FileWriter with no file initialized.
◆ FileWriter() [2/2]
| FileWriter::FileWriter |
( |
const std::string & |
filename | ) |
|
|
explicit |
Creates a new FileWriter and opens the file with the given name.
- Parameters
-
| filename | The name of the file to load into the output stream m_file. |
◆ ~FileWriter()
| virtual FileWriter::~FileWriter |
( |
| ) |
|
|
virtual |
Closes the opened file and destroys the FileWriter object.
◆ closeFile()
| void FileWriter::closeFile |
( |
| ) |
|
Closes the opened file if it exists, otherwise does nothing.
◆ initializeFolder()
| static void FileWriter::initializeFolder |
( |
const std::string & |
dirname | ) |
|
|
static |
(Re)initializes the output directory.
First, the function checks if the output directory exists. If it doesn't, it creates it. Otherwise, it deletes everything inside it.
- Parameters
-
| dirname | The name of the output directory. |
◆ openFile()
| void FileWriter::openFile |
( |
const std::string & |
filename | ) |
|
Opens / creates the file with the given name.
- Parameters
-
| filename | The name of the file to load into the output stream m_file. |
◆ writeFile()
| void FileWriter::writeFile |
( |
const std::string & |
content, |
|
|
const std::string & |
filename = "", |
|
|
int |
iteration = -1, |
|
|
int |
total = -1 |
|
) |
| |
Overwrites the contents of the file opened in m_file with a given string. On error, the program will terminate.
- Parameters
-
| content | The string to be written inside of the file. |
| filename | An optional filename to be used with spdlog to display the name of the file currently being written to. |
| iteration | The optional current iteration of the simulation. |
| total | The optional total number of iterations, used to display the current percentage. |
◆ writeParticles()
| virtual void FileWriter::writeParticles |
( |
const ParticleContainer & |
particles, |
|
|
int |
iteration, |
|
|
int |
total |
|
) |
| |
|
pure virtual |
Interface function for writing the type, mass, position, velocity and force of a ParticleContainer to a file. Terminates program execution on error.
- Parameters
-
| particles | The ParticleContainer. |
| iteration | The number of the current iteration, used to generate a unique filename. |
| total | The total number of iterations, used to display the current percentage. |
Implemented in NullWriter, VTKWriter, and XYZWriter.
◆ m_file
| std::ofstream FileWriter::m_file |
|
protected |
Output stream containing the file to write contents to.
The documentation for this class was generated from the following file: