Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
orrery::sim::DiagnosticsLog Class Reference

Appends one row per measurement to a CSV file. More...

#include <orrery/sim/diagnostics_log.hpp>

Public Member Functions

 DiagnosticsLog (const std::filesystem::path &path)
 Create the file and write the header row.
void record (core::Index step, core::Real time, const core::Diagnostics &diagnostics)
 Write one row.
std::optional< core::Real > reference_energy () const noexcept
 The total energy of the first row, if there has been one.
bool ok () const
void flush ()

Detailed Description

Appends one row per measurement to a CSV file.

Constructor & Destructor Documentation

◆ DiagnosticsLog()

orrery::sim::DiagnosticsLog::DiagnosticsLog ( const std::filesystem::path & path)
explicit

Create the file and write the header row.

Throws std::runtime_error if the file cannot be opened. A setup boundary, and the right place to discover an unwritable path.

Member Function Documentation

◆ record()

void orrery::sim::DiagnosticsLog::record ( core::Index step,
core::Real time,
const core::Diagnostics & diagnostics )

Write one row.

The first row measured fixes the reference the energy error is relative to, which is the initial state when a run starts and the state resumed from when it is resumed. That difference is real and is why the step number is in the file: an energy error column from a resumed run is relative to where that segment began, and a reader joining two segments has the information needed to notice.


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