|
Orrery
A GPU-accelerated N-body gravitational simulator
|
A gravitational simulation in progress. More...
#include <orrery/sim/simulation.hpp>
Public Member Functions | |
| Simulation (core::ParticleData particles, std::unique_ptr< solvers::ForceSolver > solver, std::unique_ptr< integrators::Integrator > integrator, core::Real timestep, std::unique_ptr< backend::Executor > executor=nullptr, std::unique_ptr< RunOutput > output=nullptr) | |
| Take ownership of a configuration and the machinery to advance it. | |
| Simulation (const Simulation &)=delete | |
| Simulation & | operator= (const Simulation &)=delete |
| Simulation (Simulation &&) noexcept | |
| Simulation & | operator= (Simulation &&) noexcept |
| void | step () |
| Advance by one step and count it. | |
| void | run (core::Index steps) |
| Record the current state, then take steps steps, recording as the output asks. | |
| void | restore (core::ParticleData particles, core::Index step, bool accelerations_are_current=false) |
| Replace the state and the step counter, as a resume does. | |
| core::Index | step_index () const noexcept |
| core::Real | time () const noexcept |
| The simulated time, step * timestep. | |
| core::Real | timestep () const noexcept |
| const core::ParticleData & | particles () const noexcept |
| const solvers::ForceSolver & | solver () const noexcept |
| const integrators::Integrator & | integrator () const noexcept |
| core::Diagnostics | measure () const |
| Measure the conserved quantities of the current state. | |
A gravitational simulation in progress.
| orrery::sim::Simulation::Simulation | ( | core::ParticleData | particles, |
| std::unique_ptr< solvers::ForceSolver > | solver, | ||
| std::unique_ptr< integrators::Integrator > | integrator, | ||
| core::Real | timestep, | ||
| std::unique_ptr< backend::Executor > | executor = nullptr, | ||
| std::unique_ptr< RunOutput > | output = nullptr ) |
Take ownership of a configuration and the machinery to advance it.
executor may be null, and is only held so that it outlives the solver that refers to it. output may be null, which is a run that computes and records nothing and is what most of the test suite wants.
Establishes the acceleration invariant, which costs one force evaluation.
| void orrery::sim::Simulation::step | ( | ) |
Advance by one step and count it.
Does not record anything. run is what drives the output, and a caller that wants both writes the loop itself.
| void orrery::sim::Simulation::run | ( | core::Index | steps | ) |
Record the current state, then take steps steps, recording as the output asks.
The initial state is recorded before the first step, so that a trajectory begins at the configuration the run started from rather than one step into it, and a diagnostics file has a row to be relative to.
| void orrery::sim::Simulation::restore | ( | core::ParticleData | particles, |
| core::Index | step, | ||
| bool | accelerations_are_current = false ) |
Replace the state and the step counter, as a resume does.
The particle count may differ from the current one. Re-establishes the acceleration invariant from the state given rather than trusting the accelerations in it, unless accelerations_are_current says they came from a checkpoint and are already the accelerations at these positions, in which case they are kept exactly. That distinction is the whole of bitwise resume: recomputing would give the same answer for every solver in this project and is not guaranteed to for one added later (ADR-0032).
|
nodiscard |
Measure the conserved quantities of the current state.
Softened with whatever the solver softens with, asked of the solver rather than stored beside it, for the reason ADR-0008 gives: a potential energy computed with a different softening from the force kernel turns the conservation result into a measurement of the mismatch.
Costs an N^2 pass and shares no code with the solver, which is what makes it evidence rather than a restatement. A run measures it every few hundred steps rather than every step.