11 switch (output_format) {
29 auto file_extension = std::find_if(supported.begin(), supported.end(), [&
params, &output_format](
const auto& pair) {
30 return pair.second == output_format;
35 if (entry.path().extension() ==
"." + file_extension) {
36 std::string filename = entry.path().filename().string();
37 std::string iteration_str =
38 filename.substr(filename.find_last_of(
"_") + 1, filename.find_last_of(
".") - filename.find_last_of(
"_") - 1);
40 size_t iteration = std::stoul(iteration_str);
43 std::filesystem::remove(entry.path());
60 throw std::runtime_error(
"No file writer set. Not writing file.");
66 size_t iteration,
const std::unique_ptr<ParticleContainer>& particle_container)
const {
67 return writeFile(iteration, particle_container->getParticles());
std::optional< const std::filesystem::path > writeFile(size_t iteration, const std::unique_ptr< ParticleContainer > &particle_container) const
Writes the given ParticleContainers particle data to a file.
std::unique_ptr< FileWriter > file_writer
Pointer to the FileWriter object to use.
const SimulationParams & params
SimulationParams object which provides the output directory path.
FileOutputHandler(const OutputFormat output_format, const SimulationParams ¶ms)
Construct a new FileOutputHandler object.
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Contains all parameters needed to run a simulation.
std::filesystem::path output_dir_path
Path to the directory in which to save the simulation output.
size_t start_iteration
Start iteration of the simulation.