Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
diagnostics_log.hpp
Go to the documentation of this file.
1#pragma once
2
32
33#include <filesystem>
34#include <fstream>
35#include <optional>
36
38#include "orrery/core/types.hpp"
39
40namespace orrery::sim {
41
44public:
49 explicit DiagnosticsLog(const std::filesystem::path& path);
50
59 void record(core::Index step, core::Real time, const core::Diagnostics& diagnostics);
60
62 [[nodiscard]] std::optional<core::Real> reference_energy() const noexcept {
63 return reference_energy_;
64 }
65
66 [[nodiscard]] bool ok() const { return file_.good(); }
67
68 void flush() { file_.flush(); }
69
70private:
71 std::ofstream file_;
72 std::optional<core::Real> reference_energy_;
73};
74
75} // namespace orrery::sim
void record(core::Index step, core::Real time, const core::Diagnostics &diagnostics)
Write one row.
DiagnosticsLog(const std::filesystem::path &path)
Create the file and write the header row.
std::optional< core::Real > reference_energy() const noexcept
The total energy of the first row, if there has been one.
Definition diagnostics_log.hpp:62
The conserved quantities, which are how this project knows it is right.
Every conserved quantity of a configuration, measured at one instant.
Definition diagnostics.hpp:52
The scalar and index types that every layer of the project agrees on.
std::size_t Index
The type of a particle index and of any count of particles.
Definition types.hpp:45