Orrery
A GPU-accelerated N-body gravitational simulator
Toggle main menu visibility
Loading...
Searching...
No Matches
run_output.hpp
Go to the documentation of this file.
1
#pragma once
2
25
26
#include <filesystem>
27
#include <optional>
28
#include <span>
29
30
#include "
orrery/core/types.hpp
"
31
#include "
orrery/sim/configuration.hpp
"
32
#include "
orrery/sim/diagnostics_log.hpp
"
33
#include "
orrery/sim/trajectory.hpp
"
34
35
namespace
orrery::sim {
36
37
class
Simulation
;
38
40
class
RunOutput {
41
public
:
42
virtual
~RunOutput() =
default
;
43
55
virtual
void
record
(
const
Simulation
& simulation,
bool
is_final) = 0;
56
57
protected
:
58
// As on the other interfaces in this project: a class with a virtual
59
// destructor suppresses the implicit copy and move operations, and copying
60
// an implementation through a reference to this base would slice it.
61
RunOutput() =
default
;
62
RunOutput(
const
RunOutput&) =
default
;
63
RunOutput(RunOutput&&) =
default
;
64
RunOutput& operator=(
const
RunOutput&) =
default
;
65
RunOutput& operator=(RunOutput&&) =
default
;
66
};
67
73
class
FileOutput
final :
public
RunOutput {
74
public
:
86
FileOutput
(
const
Configuration
& configuration, std::span<const core::Real> masses);
87
88
void
record
(
const
Simulation
& simulation,
bool
is_final)
override
;
89
91
[[nodiscard]]
core::Index
frames_written
() const noexcept;
92
94
[[nodiscard]] core::Index
checkpoints_written
() const noexcept {
return
checkpoints_; }
95
96
private
:
102
[[nodiscard]]
bool
due(
core::Index
step,
core::Index
stride,
bool
is_final)
const
noexcept
;
103
104
Configuration
configuration_;
105
106
std::optional<TrajectoryWriter> trajectory_;
107
std::optional<DiagnosticsLog> diagnostics_;
108
109
std::filesystem::path checkpoint_path_;
110
core::Index
checkpoints_ = 0;
111
bool
first_ =
true
;
112
};
113
114
}
// namespace orrery::sim
orrery::sim::FileOutput::FileOutput
FileOutput(const Configuration &configuration, std::span< const core::Real > masses)
Open what configuration asks for.
orrery::sim::FileOutput::frames_written
core::Index frames_written() const noexcept
How many trajectory frames have been written.
orrery::sim::FileOutput::checkpoints_written
core::Index checkpoints_written() const noexcept
How many checkpoints have been written.
Definition
run_output.hpp:94
orrery::sim::FileOutput::record
void record(const Simulation &simulation, bool is_final) override
Record the current state of simulation.
orrery::sim::RunOutput::record
virtual void record(const Simulation &simulation, bool is_final)=0
Record the current state of simulation.
orrery::sim::Simulation
A gravitational simulation in progress.
Definition
simulation.hpp:56
configuration.hpp
Everything a run is, as data.
diagnostics_log.hpp
The conserved quantities of a run, as they change, in a format anything can read.
orrery::sim::Configuration
A whole run, as data.
Definition
configuration.hpp:332
trajectory.hpp
The trajectory file: what the simulation looked like, frame by frame.
types.hpp
The scalar and index types that every layer of the project agrees on.
orrery::core::Index
std::size_t Index
The type of a particle index and of any count of particles.
Definition
types.hpp:45
orrery
sim
run_output.hpp
Generated by
1.17.0