MolSim
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
VTKWriter Class Reference

Class which implements functionality to generate VTK output from particles. More...

#include <VTKWriter.h>

Inheritance diagram for VTKWriter:
FileWriter

Public Member Functions

 VTKWriter ()
 Creates a new uninitialized VTKWriter.
 
 VTKWriter (const std::string &basename)
 Creates a new VTKWriter with the given basename for future file outputs.
 
 VTKWriter (const std::string &basename, const std::string &dirname)
 Creates a new VTKWriter with the given basename for future file outputs in the specified directory.
 
virtual ~VTKWriter ()
 Destroys the current VTKWriter object.
 
void writeParticles (const ParticleContainer &particles, int iteration, int total) override
 Writes the type, mass, position, velocity and force of a ParticleContainer to a VTK file. Terminates program execution on error.
 
- Public Member Functions inherited from FileWriter
 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.
 

Private Member Functions

void initializeOutput (int numParticles)
 Initializes m_vtkFile with necessary metadata for writing purposes. Terminates program execution on error.
 
void writeFile (int iteration, int total)
 Writes the contents of m_vtkFile into a given VTK file. Terminates program execution on error.
 
void plotParticle (const Particle &p)
 Plots a single particle to m_vtkFile. Terminates program execution on error.
 

Private Attributes

VTKFile_tm_vtkFile
 The VTK file instance containing particle data.
 
std::string m_basename = "MD_vtk"
 The base name of the generated files.
 
std::string m_dirname = "vtk"
 The name of the directory in which to store the generated files.
 

Additional Inherited Members

- Static Public Member Functions inherited from FileWriter
static void initializeFolder (const std::string &dirname)
 (Re)initializes the output directory.
 
- Protected Attributes inherited from FileWriter
std::ofstream m_file
 Output stream containing the file to write contents to.
 

Detailed Description

Class which implements functionality to generate VTK output from particles.

Constructor & Destructor Documentation

◆ VTKWriter() [1/3]

VTKWriter::VTKWriter ( )

Creates a new uninitialized VTKWriter.

◆ VTKWriter() [2/3]

VTKWriter::VTKWriter ( const std::string &  basename)
explicit

Creates a new VTKWriter with the given basename for future file outputs.

Parameters
basenameThe base name of the generated files.

◆ VTKWriter() [3/3]

VTKWriter::VTKWriter ( const std::string &  basename,
const std::string &  dirname 
)

Creates a new VTKWriter with the given basename for future file outputs in the specified directory.

Parameters
basenameThe base name of the generated files.
dirnameThe directory name of the generated files.

◆ ~VTKWriter()

virtual VTKWriter::~VTKWriter ( )
virtual

Destroys the current VTKWriter object.

Member Function Documentation

◆ initializeOutput()

void VTKWriter::initializeOutput ( int  numParticles)
private

Initializes m_vtkFile with necessary metadata for writing purposes. Terminates program execution on error.

Parameters
numParticlesThe total number of particles.

◆ plotParticle()

void VTKWriter::plotParticle ( const Particle p)
private

Plots a single particle to m_vtkFile. Terminates program execution on error.

Parameters
pThe particle to be plotted.

◆ writeFile()

void VTKWriter::writeFile ( int  iteration,
int  total 
)
private

Writes the contents of m_vtkFile into a given VTK file. Terminates program execution on error.

Parameters
iterationThe current iteration of the simulation.
totalThe total number of iterations, used to display the current percentage.

◆ writeParticles()

void VTKWriter::writeParticles ( const ParticleContainer particles,
int  iteration,
int  total 
)
overridevirtual

Writes the type, mass, position, velocity and force of a ParticleContainer to a VTK file. Terminates program execution on error.

Parameters
particlesThe ParticleContainer.
iterationThe number of the current iteration, used to generate a unique filename.
totalThe total number of iterations, used to display the current percentage.

Implements FileWriter.

Member Data Documentation

◆ m_basename

std::string VTKWriter::m_basename = "MD_vtk"
private

The base name of the generated files.

◆ m_dirname

std::string VTKWriter::m_dirname = "vtk"
private

The name of the directory in which to store the generated files.

◆ m_vtkFile

VTKFile_t* VTKWriter::m_vtkFile
private

The VTK file instance containing particle data.


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