|
Orrery
A GPU-accelerated N-body gravitational simulator
|
One particle's place on the curve. More...
#include <orrery/solvers/morton.hpp>
Public Attributes | |
| MortonCode | code {} |
| core::Index | index {} |
Friends | |
| constexpr auto | operator<=> (const MortonKey &, const MortonKey &) noexcept=default |
| Ordered by code, and by index where two codes are equal. | |
One particle's place on the curve.
The code and the index travel together because both are needed after the sort: the code builds the tree and the index says which particle of the caller's configuration each sorted slot came from. Sorting them as one 16-byte record rather than as two arrays permuted afterwards is the choice that keeps the sort to one pass over one array.
Ordered by code, and by index where two codes are equal.
Defaulted, which for a class compares the members in declaration order and so is exactly the ordering wanted here rather than a shorthand for something close to it.
The tie-break on the index is what makes the ordering total rather than merely weak, and a total order is what makes the result independent of the sorting algorithm, of the number of threads it ran on and of how they happened to divide the array. Identical codes are common: every configuration with two particles closer together than the finest grid cell has some, and a configuration with repeated positions has many. Without the tie-break their order would be an implementation detail, and each particle's acceleration is summed in the order they end up in.