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

The octree of one configuration, built from Morton-sorted particles. More...

#include <orrery/solvers/octree.hpp>

Public Member Functions

void build (core::Vec3Span< const core::Real > positions, std::span< const core::Real > masses, std::span< const MortonKey > keys, const BoundingCube &cube, const TreeParameters &parameters, backend::Executor *executor)
 Build the tree over particles already sorted by Morton code.
std::span< const TreeNodenodes () const noexcept
 The nodes, in depth-first order.
std::span< const Quadrupolequadrupoles () const noexcept
 The quadrupole moment of each node, or an empty span when the moments were not asked for.
bool empty () const noexcept
const TreeParametersparameters () const noexcept
 The parameters the last build used, after the corrections described on TreeParameters.
core::Index leaf_count () const noexcept
 How many nodes are leaves.
unsigned depth () const noexcept
 The depth of the deepest leaf, counting the root as depth zero.

Detailed Description

The octree of one configuration, built from Morton-sorted particles.

Rebuilt in place: a solver holds one of these for its lifetime and calls build on every force evaluation, so the node array is allocated on the first evaluation and reused by every later one. The tree of a configuration depends only on the positions and the parameters, and not on how many threads built it.

Member Function Documentation

◆ build()

void orrery::solvers::Octree::build ( core::Vec3Span< const core::Real > positions,
std::span< const core::Real > masses,
std::span< const MortonKey > keys,
const BoundingCube & cube,
const TreeParameters & parameters,
backend::Executor * executor )

Build the tree over particles already sorted by Morton code.

positions, masses and keys describe the same particles in the same sorted order, and cube is the cube those codes were computed in. The solver above holds the permuted copies and passes them here; nothing in this class reorders anything.

Runs the per-subtree work through executor where one is given.

Safe to call with no particles, which produces a tree with no nodes.

◆ nodes()

std::span< const TreeNode > orrery::solvers::Octree::nodes ( ) const
inlinenodiscardnoexcept

The nodes, in depth-first order.

The root is the first, where there is one.

◆ quadrupoles()

std::span< const Quadrupole > orrery::solvers::Octree::quadrupoles ( ) const
inlinenodiscardnoexcept

The quadrupole moment of each node, or an empty span when the moments were not asked for.

Indexed by node, so quadrupoles()[n] belongs to nodes()[n].

◆ leaf_count()

core::Index orrery::solvers::Octree::leaf_count ( ) const
inlinenodiscardnoexcept

How many nodes are leaves.

Reported because the ratio of leaves to particles is the first thing to look at when a tree is slower than it should be: a tree whose leaves average two particles is paying for nodes it could have avoided.


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