11#ifndef EBGEOMETRY_SFC_HPP
12#define EBGEOMETRY_SFC_HPP
81 inline static uint64_t
90 [[nodiscard]]
inline static Index
91 decode(
const uint64_t& a_code)
noexcept;
97 static constexpr uint_fast64_t
Mask_64[6]{
98 0x1fffff, 0x1f00000000ffff, 0x1f0000ff0000ff, 0x100f00f00f00f00f, 0x10c30c30c30c30c3, 0x1249249249249249};
113 [[nodiscard]]
inline static uint64_t
122 [[nodiscard]]
inline static Index
144 [[nodiscard]]
inline static uint64_t
153 [[nodiscard]]
inline static Index
174[[nodiscard]]
inline std::vector<Index>
190template <
class Curve = Morton,
class T>
191[[nodiscard]]
inline std::vector<uint32_t>
254 const Vec3T<T> halfLo = T(0.5) * a_lo;
255 const Vec3T<T> extent = T(0.5) * a_hi - halfLo;
269 key(
const Vec3T<T>& a_point,
const uint32_t a_index)
const noexcept
273 for (
int dir = 0; dir < 3; dir++) {
287#include "EBGeometry_SFCImplem.hpp"
A fixed-size array that compiles for both host and device.
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Scalar helpers and numeric limits that compile for both host and device.
Declaration of 2D and 3D point/vector classes with templated precision, and free functions on them.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:258
constexpr T clamp(const T &a_value, const T &a_lo, const T &a_hi) noexcept
A value limited to [lo, hi].
Definition EBGeometry_Math.hpp:78
constexpr T max(const T &a_a, const T &a_b) noexcept
The larger of two values.
Definition EBGeometry_Math.hpp:61
static constexpr unsigned int ValidBits
Maximum available bits per dimension. 21 is the largest value for which 3*ValidBits (63) still fits i...
Definition EBGeometry_SFC.hpp:63
std::vector< Index > computeBins(const std::vector< Vec3T< T > > &a_points)
Bin a set of points into the space-filling curve's integer grid, normalizing by their own bounding ra...
uint64_t Code
Alias for SFC code.
Definition EBGeometry_SFC.hpp:52
static constexpr Code ValidSpan
Maximum permitted span along any spatial coordinate.
Definition EBGeometry_SFC.hpp:68
std::vector< uint32_t > order(const std::vector< Vec3T< T > > &a_points)
Return the index permutation that orders a_points along a space-filling curve.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Fixed-size array with host- and device-callable members.
Definition EBGeometry_Array.hpp:33
The Morton grid over a box: a point's cell is (p / 2 - lo / 2) * scale, clamped to [0,...
Definition EBGeometry_SFC.hpp:237
MortonKey key(const Vec3T< T > &a_point, const uint32_t a_index) const noexcept
A point's key.
Definition EBGeometry_SFC.hpp:269
Vec3T< T > m_halfLo
Half the box's lower corner.
Definition EBGeometry_SFC.hpp:239
T m_scale
Cells per unit of halved length (0 for a box of one point).
Definition EBGeometry_SFC.hpp:242
static MortonGrid over(const Vec3T< T > &a_lo, const Vec3T< T > &a_hi) noexcept
The grid over a box.
Definition EBGeometry_SFC.hpp:252
A point's sort key: its cell's Morton code, then its index, so that no two keys are equal and every s...
Definition EBGeometry_SFC.hpp:208
bool operator<(const MortonKey &a_other) const noexcept
Whether this key sorts before a_other: by code, then by index.
Definition EBGeometry_SFC.hpp:222
uint32_t m_index
The point's index.
Definition EBGeometry_SFC.hpp:213
uint64_t m_code
The Morton code of the point's cell.
Definition EBGeometry_SFC.hpp:210
Implementation of the 3D Hilbert space-filling curve.
Definition EBGeometry_SFC.hpp:138
static Index decode(const uint64_t &a_code) noexcept
Decode the linear Hilbert distance back into an Index.
static uint64_t encode(const Index &a_point) noexcept
Encode the input point into the linear Hilbert distance.
Implementation of the Morton SFC.
Definition EBGeometry_SFC.hpp:74
static Index decode(const uint64_t &a_code) noexcept
Decode the 64-bit Morton code into an Index.
static constexpr uint_fast64_t Mask_64[6]
Mask for magic-bits encoding of 3D Morton code.
Definition EBGeometry_SFC.hpp:97
static uint64_t encode(const Index &a_point) noexcept
Encode an input point into a Morton index with a 64-bit representation.
Implementation of a nested index SFC.
Definition EBGeometry_SFC.hpp:107
static Index decode(const uint64_t &a_code) noexcept
Decode the 64-bit SFC code into an Index.
static uint64_t encode(const Index &a_point) noexcept
Encode the input point into the SFC code.