Orrery
A GPU-accelerated N-body gravitational simulator
Toggle main menu visibility
Loading...
Searching...
No Matches
softening.hpp
Go to the documentation of this file.
1
#pragma once
2
35
36
#include <cmath>
37
38
#include "
orrery/core/types.hpp
"
39
40
namespace
orrery::core {
41
49
class
Softening
{
50
public
:
56
constexpr
Softening
() noexcept = default;
57
66
constexpr explicit
Softening
(Real length) noexcept : squared_(length * length) {}
67
69
[[nodiscard]]
constexpr
Real
squared
() const noexcept {
return
squared_; }
70
71
[[nodiscard]] Real length() const noexcept {
return
std::sqrt(squared_); }
72
73
private
:
74
Real squared_{};
75
};
76
82
[[nodiscard]]
inline
Real
softened_inverse_distance
(Real separation_squared,
83
Softening
softening)
noexcept
{
84
return
Real{1} / std::sqrt(separation_squared + softening.squared());
85
}
86
95
[[nodiscard]]
inline
Real
softened_inverse_distance_cubed
(Real separation_squared,
96
Softening
softening)
noexcept
{
97
const
Real inverse =
softened_inverse_distance
(separation_squared, softening);
98
return
inverse * inverse * inverse;
99
}
100
101
}
// namespace orrery::core
orrery::core::Softening
The softening length of the Plummer kernel above.
Definition
softening.hpp:49
orrery::core::Softening::Softening
constexpr Softening() noexcept=default
No softening: exact point masses.
orrery::core::Softening::squared
constexpr Real squared() const noexcept
The softening length squared, which is the form every kernel uses.
Definition
softening.hpp:69
orrery::core::softened_inverse_distance
Real softened_inverse_distance(Real separation_squared, Softening softening) noexcept
The factor 1 / sqrt(r^2 + eps^2) of the softened potential.
Definition
softening.hpp:82
orrery::core::softened_inverse_distance_cubed
Real softened_inverse_distance_cubed(Real separation_squared, Softening softening) noexcept
The factor 1 / (r^2 + eps^2)^(3/2) of the softened acceleration.
Definition
softening.hpp:95
types.hpp
The scalar and index types that every layer of the project agrees on.
orrery
core
softening.hpp
Generated by
1.17.0