56namespace orrery::sim {
81 bool has_velocities =
false;
120 core::Real timestep,
bool with_velocities);
132 [[nodiscard]]
bool ok()
const {
return file_.good(); }
143 bool has_velocities_;
162 [[nodiscard]]
const TrajectoryInfo& info() const noexcept {
return info_; }
165 [[nodiscard]] std::span<const core::Real>
masses() const noexcept {
return masses_; }
178 std::filesystem::path path_;
180 std::vector<core::Real> masses_;
Storage for a set of point masses in structure-of-arrays layout.
Definition particle_data.hpp:43
A resizable array of 3-vectors in component-array layout.
Definition vec3_array.hpp:34
TrajectoryReader(const std::filesystem::path &path)
Open the file and read its header.
bool read_frame(TrajectoryFrame &frame)
Read the next frame into frame, or return false at the end of the file.
std::span< const core::Real > masses() const noexcept
The masses from the header, in the order the frames use.
Definition trajectory.hpp:165
void write_frame(core::Index step, core::Real time, const core::ParticleData &data)
Append one frame.
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 flush()
Flush what has been written without closing the file.
Definition trajectory.hpp:138
bool ok() const
Whether every write so far reached the disc.
Definition trajectory.hpp:132
core::Index frame_count() const noexcept
How many frames have been written.
Definition trajectory.hpp:129
The particle store: one contiguous array per component.
One recorded instant.
Definition trajectory.hpp:92
core::Index step
Which step of the run this is, counting from zero at the initial state.
Definition trajectory.hpp:94
core::Real time
The simulated time, which is step * timestep.
Definition trajectory.hpp:97
core::Vec3Array velocities
Empty unless the file has velocities in it.
Definition trajectory.hpp:102
What a trajectory file's header says about it.
Definition trajectory.hpp:74
core::Real timestep
The timestep the run used, so that a frame's step index can be turned into a time without the configu...
Definition trajectory.hpp:79
bool single_precision
Whether the file was written by a single-precision build.
Definition trajectory.hpp:88
constexpr std::uint32_t kTrajectoryVersion
The version of the layout in docs/formats/trajectory.md.
Definition trajectory.hpp:71
constexpr std::string_view kTrajectoryMagic
The eight bytes every trajectory file starts with.
Definition trajectory.hpp:64
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
Storage for a vector quantity that is not part of the particle state.