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

Reads the format above. More...

#include <orrery/sim/trajectory.hpp>

Public Member Functions

 TrajectoryReader (const std::filesystem::path &path)
 Open the file and read its header.
const TrajectoryInfoinfo () const noexcept
std::span< const core::Real > masses () const noexcept
 The masses from the header, in the order the frames use.
bool read_frame (TrajectoryFrame &frame)
 Read the next frame into frame, or return false at the end of the file.

Detailed Description

Reads the format above.

The intended use is a loop over read_frame until it returns false, which happens at a clean end of file. Anything else, a truncated frame or one whose checksum does not match, throws instead, so that a reader cannot mistake a damaged file for a short run.

Constructor & Destructor Documentation

◆ TrajectoryReader()

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

Open the file and read its header.

Throws std::runtime_error if the file cannot be opened, does not carry the magic, is of an unknown version, or was written by a build of the other precision.

Member Function Documentation

◆ read_frame()

bool orrery::sim::TrajectoryReader::read_frame ( TrajectoryFrame & frame)
nodiscard

Read the next frame into frame, or return false at the end of the file.

frame is resized as needed and may be reused across calls, which is what keeps reading a long trajectory free of allocation after the first frame.

Throws std::runtime_error on a partial or corrupt frame.


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