Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
runge_kutta4.hpp
Go to the documentation of this file.
1#pragma once
2
31
32#include <string_view>
33
35#include "orrery/core/types.hpp"
39
40namespace orrery::integrators {
41
48class RungeKutta4 final : public Integrator {
49public:
50 void step(core::ParticleData& data, core::Real timestep, AccelerationField& field) override;
51
52 [[nodiscard]] std::string_view name() const noexcept override { return "RK4"; }
53
54 [[nodiscard]] int order() const noexcept override { return 4; }
55
56 [[nodiscard]] bool is_symplectic() const noexcept override { return false; }
57
65 [[nodiscard]] core::Index force_evaluations_per_step() const noexcept override { return 4; }
66
67private:
70 void evaluate_stage(core::ParticleData& data, AccelerationField& field, core::Real scale,
71 core::Real weight);
72
73 core::Vec3Array initial_positions_;
74 core::Vec3Array initial_velocities_;
75 core::Vec3Array position_derivative_sum_;
76 core::Vec3Array velocity_derivative_sum_;
77};
78
79} // 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
A resizable array of 3-vectors in component-array layout.
Definition vec3_array.hpp:34
The acceleration produced by a set of masses at a set of positions.
Definition acceleration_field.hpp:37
The classical fourth-order Runge-Kutta method.
Definition runge_kutta4.hpp:48
bool is_symplectic() const noexcept override
Whether the method preserves the phase-space volume of the flow.
Definition runge_kutta4.hpp:56
void step(core::ParticleData &data, core::Real timestep, AccelerationField &field) override
Advance the configuration by one step of timestep.
core::Index force_evaluations_per_step() const noexcept override
Four, and the first of them is free.
Definition runge_kutta4.hpp:65
std::string_view name() const noexcept override
The method's name, for diagnostics output and test messages.
Definition runge_kutta4.hpp:52
int order() const noexcept override
The order of the method: the power of the timestep that the error after a fixed interval of simulated...
Definition runge_kutta4.hpp:54
The interface every time integrator presents, and the contract about accelerations that makes the che...
The particle store: one contiguous array per component.
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.