|
Orrery
A GPU-accelerated N-body gravitational simulator
|
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 ¶meters, backend::Executor *executor) |
| Build the tree over particles already sorted by Morton code. | |
| std::span< const TreeNode > | nodes () const noexcept |
| The nodes, in depth-first order. | |
| std::span< const Quadrupole > | quadrupoles () const noexcept |
| The quadrupole moment of each node, or an empty span when the moments were not asked for. | |
| bool | empty () const noexcept |
| const TreeParameters & | parameters () 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. | |
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.
| 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.
|
inlinenodiscardnoexcept |
The nodes, in depth-first order.
The root is the first, where there is one.
|
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].
|
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.