Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
orrery::solvers::BarnesHutSolver Class Referencefinal

The Barnes-Hut solver described above. More...

#include <orrery/solvers/barnes_hut_solver.hpp>

Inheritance diagram for orrery::solvers::BarnesHutSolver:
orrery::solvers::ForceSolver orrery::integrators::AccelerationField

Public Member Functions

 BarnesHutSolver (TreeParameters parameters={}) noexcept
 A solver over exact point masses, evaluated on the calling thread.
 BarnesHutSolver (TreeParameters parameters, core::Softening softening) noexcept
 A solver softening at the given length.
 BarnesHutSolver (TreeParameters parameters, core::Softening softening, backend::Executor &executor) noexcept
 A softened solver evaluated through executor.
void evaluate (core::Vec3Span< const core::Real > positions, std::span< const core::Real > masses, core::Vec3Span< core::Real > accelerations) override
 Write the acceleration at each position into accelerations.
std::string_view name () const noexcept override
 The solver's name, for benchmark tables and test messages.
core::Softening softening () const noexcept override
 The softening this solver applies.
InteractionCount interaction_count () const noexcept override
 The work done since construction or since the last reset.
void reset_interaction_count () noexcept override
 Set every counter back to zero.
const TreeParametersparameters () const noexcept
 The parameters in force, which are the ones asked for after correction.
const Octreetree () const noexcept
 The tree the last evaluation built, empty before the first.
const EvaluationTimingstimings () const noexcept
 Where the last evaluation's time went.
const backend::Executorexecutor () const noexcept
 The executor this solver evaluates through, or null if it runs on the calling thread.
void select_kernel (KernelKind kind) noexcept
 Ask for a particular kernel for the pairs at the leaves, and settle for the scalar one if this machine cannot run it.
KernelKind kernel () const noexcept
 The kernel this solver will use at the leaves.
Public Member Functions inherited from orrery::solvers::ForceSolver
 ~ForceSolver () override=default
 Public and virtual, the second by inheritance from AccelerationField.

Additional Inherited Members

Protected Member Functions inherited from orrery::solvers::ForceSolver
 ForceSolver (const ForceSolver &)=default
 ForceSolver (ForceSolver &&)=default
ForceSolver & operator= (const ForceSolver &)=default
ForceSolver & operator= (ForceSolver &&)=default
Protected Member Functions inherited from orrery::integrators::AccelerationField
 AccelerationField (const AccelerationField &)=default
 AccelerationField (AccelerationField &&)=default
AccelerationField & operator= (const AccelerationField &)=default
AccelerationField & operator= (AccelerationField &&)=default

Detailed Description

The Barnes-Hut solver described above.

Constructor & Destructor Documentation

◆ BarnesHutSolver() [1/2]

orrery::solvers::BarnesHutSolver::BarnesHutSolver ( TreeParameters parameters = {})
inlineexplicitnoexcept

A solver over exact point masses, evaluated on the calling thread.

The parameters are corrected on the way in, so a solver constructed with an opening angle of two reports one and behaves accordingly.

◆ BarnesHutSolver() [2/2]

orrery::solvers::BarnesHutSolver::BarnesHutSolver ( TreeParameters parameters,
core::Softening softening,
backend::Executor & executor )
inlinenoexcept

A softened solver evaluated through executor.

The executor is referred to rather than owned and must outlive the solver, for the reason DirectSolver gives: a pool of threads is a machine-wide resource and a solver that owned one could not be created inside a loop.

Member Function Documentation

◆ evaluate()

void orrery::solvers::BarnesHutSolver::evaluate ( core::Vec3Span< const core::Real > positions,
std::span< const core::Real > masses,
core::Vec3Span< core::Real > accelerations )
overridevirtual

Write the acceleration at each position into accelerations.

The three views must describe the same particles in the same order and have the same length, as AccelerationField requires.

Safe to call with no particles.

Implements orrery::integrators::AccelerationField.

◆ name()

std::string_view orrery::solvers::BarnesHutSolver::name ( ) const
inlinenodiscardoverridevirtualnoexcept

The solver's name, for benchmark tables and test messages.

Implements orrery::solvers::ForceSolver.

◆ softening()

core::Softening orrery::solvers::BarnesHutSolver::softening ( ) const
inlinenodiscardoverridevirtualnoexcept

The softening this solver applies.

Exposed so that a caller measuring energies asks the solver what it softened with rather than carrying a second copy of the value alongside it. Two copies of a number that must agree are how they come to disagree, and a potential energy computed with a different softening from the force kernel turns the project's headline conservation result into a measurement of the mismatch (ADR-0008).

Implements orrery::solvers::ForceSolver.

◆ interaction_count()

InteractionCount orrery::solvers::BarnesHutSolver::interaction_count ( ) const
inlinenodiscardoverridevirtualnoexcept

The work done since construction or since the last reset.

Cheap: solvers accumulate this as they go and this call only reads it.

Implements orrery::solvers::ForceSolver.

◆ reset_interaction_count()

void orrery::solvers::BarnesHutSolver::reset_interaction_count ( )
inlineoverridevirtualnoexcept

Set every counter back to zero.

A benchmark counts the work of the measured region rather than of the warm-up that preceded it, and the two are otherwise indistinguishable once they have been added together.

Implements orrery::solvers::ForceSolver.

◆ tree()

const Octree & orrery::solvers::BarnesHutSolver::tree ( ) const
inlinenodiscardnoexcept

The tree the last evaluation built, empty before the first.

Exposed so that a test can assert what the tree is and a benchmark can report its shape beside its timing. A depth or a leaf count is the first thing to look at when a tree costs more than it should, and recovering either from outside would mean building a second tree.

◆ select_kernel()

void orrery::solvers::BarnesHutSolver::select_kernel ( KernelKind kind)
inlinenoexcept

Ask for a particular kernel for the pairs at the leaves, and settle for the scalar one if this machine cannot run it.

The same knob DirectSolver offers and for the same callers: the accuracy test comparing kernels and the benchmark timing them. It matters more here than it looks. A tree solver's leaves are short ranges, so the vector kernel is called with a few dozen sources rather than a few thousand, and how much of Phase 7's speedup survives that is a measurement rather than a deduction.


The documentation for this class was generated from the following file: