Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
integrator.hpp
Go to the documentation of this file.
1#pragma once
2
32
33#include <string_view>
34
36#include "orrery/core/types.hpp"
38
39namespace orrery::integrators {
40
52 field.evaluate(data.positions(), data.masses(), data.accelerations());
53}
54
56class Integrator {
57public:
58 virtual ~Integrator() = default;
59
65 virtual void step(core::ParticleData& data, core::Real timestep, AccelerationField& field) = 0;
66
68 [[nodiscard]] virtual std::string_view name() const noexcept = 0;
69
72 [[nodiscard]] virtual int order() const noexcept = 0;
73
80 [[nodiscard]] virtual bool is_symplectic() const noexcept = 0;
81
87 [[nodiscard]] virtual core::Index force_evaluations_per_step() const noexcept = 0;
88
89protected:
90 // As on `AccelerationField`, and for the same reasons.
91 Integrator() = default;
92 Integrator(const Integrator&) = default;
93 Integrator(Integrator&&) = default;
94 Integrator& operator=(const Integrator&) = default;
95 Integrator& operator=(Integrator&&) = default;
96};
97
98} // namespace orrery::integrators
What an integrator is allowed to know about gravity.
Storage for a set of point masses in structure-of-arrays layout.
Definition particle_data.hpp:43
The acceleration produced by a set of masses at a set of positions.
Definition acceleration_field.hpp:37
virtual void evaluate(core::Vec3Span< const core::Real > positions, std::span< const core::Real > masses, core::Vec3Span< core::Real > accelerations)=0
Write the acceleration of each position into accelerations.
virtual core::Index force_evaluations_per_step() const noexcept=0
How many times step calls the acceleration field.
virtual bool is_symplectic() const noexcept=0
Whether the method preserves the phase-space volume of the flow.
virtual int order() const noexcept=0
The order of the method: the power of the timestep that the error after a fixed interval of simulated...
virtual std::string_view name() const noexcept=0
The method's name, for diagnostics output and test messages.
virtual void step(core::ParticleData &data, core::Real timestep, AccelerationField &field)=0
Advance the configuration by one step of timestep.
void refresh_accelerations(core::ParticleData &data, AccelerationField &field)
Establish the acceleration invariant for a configuration.
Definition integrator.hpp:51
The particle store: one contiguous array per component.
The scalar and index types that every layer of the project agrees on.