|
Orrery
A GPU-accelerated N-body gravitational simulator
|
Writes the format above. More...
#include <orrery/sim/trajectory.hpp>
Public Member Functions | |
| TrajectoryWriter (const std::filesystem::path &path, std::span< const core::Real > masses, core::Real timestep, bool with_velocities) | |
| Create the file and write its header. | |
| void | write_frame (core::Index step, core::Real time, const core::ParticleData &data) |
| Append one frame. | |
| core::Index | frame_count () const noexcept |
| How many frames have been written. | |
| bool | ok () const |
| Whether every write so far reached the disc. | |
| void | flush () |
| Flush what has been written without closing the file. | |
Writes the format above.
Owns the file and closes it on destruction. A writer whose stream has failed stays failed and reports it from ok(); the alternative, throwing from inside the step loop, is forbidden by section 4 of the implementation plan and would in any case turn a full disc into a lost simulation rather than a lost output file.
| orrery::sim::TrajectoryWriter::TrajectoryWriter | ( | const std::filesystem::path & | path, |
| std::span< const core::Real > | masses, | ||
| core::Real | timestep, | ||
| bool | with_velocities ) |
Create the file and write its header.
Throws std::runtime_error if the file cannot be opened, which is a setup boundary: a run should stop at once when its output path is unwritable rather than compute for an hour and then discover it.
| void orrery::sim::TrajectoryWriter::write_frame | ( | core::Index | step, |
| core::Real | time, | ||
| const core::ParticleData & | data ) |
Append one frame.
The configuration must have the same particle count the header declared. Does nothing once the stream has failed.
|
inline |
Flush what has been written without closing the file.
Called after a checkpoint is taken, so that the two outputs agree about how far the run had got if the process dies immediately afterwards.