Molecular Dynamics Simulation  1.0
Public Member Functions | List of all members
CheckPointWriter Class Reference

Class to write particle data to a .chkpt file. More...

#include <CheckPointWriter.h>

Inheritance diagram for CheckPointWriter:
Inheritance graph
Collaboration diagram for CheckPointWriter:
Collaboration graph

Public Member Functions

const std::filesystem::path writeFile (const SimulationParams &params, size_t iteration, const std::vector< Particle > &particles) const override
 Writes the data of the given ParticleContainer to a .vtu file. More...
 
- Public Member Functions inherited from FileWriter
virtual ~FileWriter ()=default
 virtual destructor for correct cleanup of derived classes More...
 

Detailed Description

Class to write particle data to a .chkpt file.

Definition at line 10 of file CheckPointWriter.h.

Member Function Documentation

◆ writeFile()

const std::filesystem::path CheckPointWriter::writeFile ( const SimulationParams params,
size_t  iteration,
const std::vector< Particle > &  particles 
) const
overridevirtual

Writes the data of the given ParticleContainer to a .vtu file.

Parameters
paramsSimulationParams object which provides the output directory path
iterationThe current iteration number
particlesA vector of particles to write to the file
Returns
The path to the written file

Implements FileWriter.

Definition at line 9 of file CheckPointWriter.cpp.

10  {
11  auto file_name = params.output_dir_path / fmt::format("MD_CHKPT_{:08d}.chkpt", iteration);
12 
13  MetaDataDataType meta_data{params.input_file_path.string(), params.input_file_hash, params.end_time, params.delta_t, iteration};
14 
15  CheckPointFileType::ParticleData_type xsd_particles{};
16 
17  xsd_particles.particle().reserve(particles.size());
18 
19  for (const Particle& particle : particles) {
20  xsd_particles.particle().push_back(InternalToXSDTypeAdapter::convertToParticle(particle));
21  }
22 
23  CheckPointFileType checkpointfile(meta_data, xsd_particles);
24 
25  std::ofstream file(file_name);
26  CheckPoint(file, checkpointfile);
27  file.close();
28 
29  return file_name;
30 }
static ParticleType convertToParticle(const Particle &particle)
Class to represent a particle.
Definition: Particle.h:26
double delta_t
Time step of a single simulation iteration.
std::filesystem::path output_dir_path
Path to the directory in which to save the simulation output.
std::filesystem::path input_file_path
Path to the input file of the simulation.
std::size_t input_file_hash
Hash of the input file of the simulation.
double end_time
End time of the simulation.

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