30#include <boost/filesystem.hpp>
31#include <boost/mpi/communicator.hpp>
38#include <unordered_map>
71static std::unordered_map<std::string, H5MDOutputFields>
const fields_map = {
89 for (
auto const &field_name : fields) {
91 throw std::invalid_argument(
"Unknown field '" + field_name +
"'");
116 std::vector<std::string>
const &output_fields, std::string
mass_unit,
190 std::vector<std::string> out = {};
192 out.push_back(kv.first);
206 void init_file(std::string
const &
file_path);
212 void create_file(
const std::string &
file_path);
218 void load_file(
const std::string &
file_path);
223 void create_groups();
229 void create_datasets();
234 void load_datasets();
249 void create_hard_links();
251 std::string m_script_path;
252 std::string m_mass_unit;
253 std::string m_length_unit;
254 std::string m_time_unit;
255 std::string m_force_unit;
256 std::string m_velocity_unit;
257 std::string m_charge_unit;
258 boost::mpi::communicator m_comm;
259 unsigned int m_fields;
260 std::string m_backup_filename;
261 boost::filesystem::path m_absolute_script_path;
262 std::unique_ptr<h5xx::file> m_h5md_file;
263 std::unique_ptr<std::unordered_map<std::string, h5xx::dataset>> m_datasets;
268 const char *
what() const noexcept
override {
269 return "The given .h5 file does not match the specifications in 'fields'.";
274 const char *
what() const noexcept
override {
275 return "A backup of the .h5 file exists. This usually means that either "
276 "you forgot to call the 'close' method or your simulation crashed.";
Vector implementation and trait types for boost qvm interoperability.
Class for writing H5MD files.
void write(const ParticleRange &particles, double time, int step, BoxGeometry const &geometry)
Write data to the hdf5 file.
auto const & length_unit() const
Retrieve the set length unit.
auto const & time_unit() const
Retrieve the set time unit.
void close()
Method to perform the renaming of the temporary file from "filename" + ".bak" to "filename".
auto const & force_unit() const
Retrieve the set force unit.
auto const & mass_unit() const
Retrieve the set mass unit.
auto const & charge_unit() const
Retrieve the set charge unit.
auto const & velocity_unit() const
Retrieve the set velocity unit.
auto valid_fields() const
Build the list of valid output fields.
std::string file_path() const
Retrieve the path to the hdf5 file.
auto const & script_path() const
Retrieve the path to the simulation script.
void flush()
Method to enforce flushing the buffer to disk.
auto fields_list_to_bitfield(std::vector< std::string > const &fields)
H5MDOutputFields
Constants which indicate what to output.
static std::unordered_map< std::string, H5MDOutputFields > const fields_map
Layout information for H5MD files.
const char * what() const noexcept override
const char * what() const noexcept override