72namespace orrery::solvers {
138 [[nodiscard]]
constexpr bool leaf() const noexcept {
return particle_count > 0; }
221 std::span<const MortonKey> keys,
const BoundingCube& cube,
226 [[nodiscard]] std::span<const TreeNode>
nodes() const noexcept {
return nodes_; }
232 [[nodiscard]] std::span<const Quadrupole>
quadrupoles() const noexcept {
return quadrupoles_; }
234 [[nodiscard]]
bool empty() const noexcept {
return nodes_.empty(); }
248 [[nodiscard]]
unsigned depth() const noexcept {
return depth_; }
262 core::Index top_index{};
266 std::vector<TreeNode> nodes;
267 std::vector<Quadrupole> quadrupoles;
275 core::Index leaves{};
282 core::Vec3Span<const core::Real> positions;
283 std::span<const core::Real> masses;
284 std::span<const MortonKey> keys;
302 void descend(
const BuildInput& input, core::Index begin, core::Index end,
unsigned level,
303 core::Vec3 centre, core::Real size, core::Index threshold);
306 void build_subtree(
const BuildInput& input, Subtree& subtree)
const;
317 void emit(
const BuildInput& input, Subtree& sink, core::Index begin, core::Index end,
318 unsigned level, core::Vec3 centre, core::Real size)
const;
322 [[nodiscard]] Subtree& next_subtree();
326 [[nodiscard]] core::Real acceptance_radius_squared(core::Real size,
327 core::Real offset)
const noexcept;
332 std::vector<TreeNode> nodes_;
333 std::vector<Quadrupole> quadrupoles_;
344 std::vector<Subtree> subtrees_;
347 core::Index subtree_count_{};
352 std::vector<TreeNode> assembled_;
353 std::vector<Quadrupole> assembled_quadrupoles_;
357 std::vector<core::Index> shift_;
360 std::vector<TopCell> top_cells_;
362 TreeParameters parameters_;
363 core::Index leaf_count_{};
Something that can run a loop body over a range, possibly in parallel.
Definition executor.hpp:52
The octree of one configuration, built from Morton-sorted particles.
Definition octree.hpp:208
std::span< const TreeNode > nodes() const noexcept
The nodes, in depth-first order.
Definition octree.hpp:226
std::span< const Quadrupole > quadrupoles() const noexcept
The quadrupole moment of each node, or an empty span when the moments were not asked for.
Definition octree.hpp:232
const TreeParameters & parameters() const noexcept
The parameters the last build used, after the corrections described on TreeParameters.
Definition octree.hpp:238
unsigned depth() const noexcept
The depth of the deepest leaf, counting the root as depth zero.
Definition octree.hpp:248
core::Index leaf_count() const noexcept
How many nodes are leaves.
Definition octree.hpp:245
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.
How a kernel asks for a loop to be run in parallel.
The order the tree solver reads particles in, and the reason it is not the order they arrived in.
TreeParameters corrected_parameters(TreeParameters parameters) noexcept
parameters with the corrections its own documentation describes: the opening angle brought into [0,...
A view of three component arrays of equal length.
Definition vec3_span.hpp:33
A vector in three-dimensional Euclidean space.
Definition vec3.hpp:26
The cube that encloses a configuration.
Definition morton.hpp:85
The traceless second moment of a cell about its centre of mass.
Definition octree.hpp:89
One cell of the tree.
Definition octree.hpp:104
core::Index first_particle
The first particle of a leaf, in the sorted order.
Definition octree.hpp:133
core::Real mass
The total mass of everything below this node.
Definition octree.hpp:106
core::Real acceptance_radius_squared
The squared distance from the centre of mass beyond which this node may be treated as a single mass.
Definition octree.hpp:126
core::Index next
The index just past this node's subtree, which is where a walk that does not descend into it continue...
Definition octree.hpp:130
core::Vec3 centre_of_mass
The mass-weighted mean position of everything below this node.
Definition octree.hpp:109
core::Index particle_count
How many particles a leaf holds, and zero for an internal node.
Definition octree.hpp:136
The choices that decide what the tree costs and how accurate it is.
Definition octree.hpp:147
bool quadrupole
Whether to compute and use the quadrupole moment of each cell.
Definition octree.hpp:190
core::Index leaf_capacity
The most particles a cell may hold and still be a leaf.
Definition octree.hpp:178
core::Real opening_angle
The opening angle, in the sense of the criterion in octree.hpp's acceptance radius: a cell of size s ...
Definition octree.hpp:163
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
A three-component vector for interfaces, not for storage.
Three parallel component arrays, viewed as one sequence of 3-vectors.