Molecular Dynamics Simulation  1.0
OutputFormats.cpp
Go to the documentation of this file.
1 #include "OutputFormats.h"
2 
3 #include "io/logger/Logger.h"
4 
5 const std::map<std::string, OutputFormat> get_supported_output_formats() {
6  return {{"vtu", OutputFormat::VTU}, {"xyz", OutputFormat::XYZ}, {"chkpt", OutputFormat::CHKPT}};
7 }
8 
9 OutputFormat convertToOutputFormat(const std::string& output_format) {
10  auto supported = get_supported_output_formats();
11 
12  if (!supported.contains(output_format)) {
13  auto supported_formats = std::string();
14  for (auto& [name, format] : supported) {
15  supported_formats += name + ", ";
16  }
17 
18  Logger::logger->error("Invalid output format given: {}. Supported output formats are: {}", output_format, supported_formats);
19  throw std::runtime_error("Invalid output format given");
20  }
21 
22  return supported[output_format];
23 }
const std::map< std::string, OutputFormat > get_supported_output_formats()
Returns a mappping of supported output formats.
OutputFormat convertToOutputFormat(const std::string &output_format)
Converts a string to an OutputFormat.
OutputFormat
Enum class to specify the output format.
Definition: OutputFormats.h:9
static std::shared_ptr< spdlog::logger > logger
Publically accessible shared pointer to the logger.
Definition: Logger.h:35