3#include <AMReX_Config.H>
32#if (AMREX_SPACEDIM == 3)
34 x = (
x | (
x << 16)) & 0x030000FF;
39 x = (
x | (
x << 8)) & 0x0300F00F;
44 x = (
x | (
x << 4)) & 0x030C30C3;
49 x = (
x | (
x << 2)) & 0x09249249;
55#elif (AMREX_SPACEDIM == 2)
57 x = (
x | (
x << 8)) & 0x00FF00FF;
62 x = (
x | (
x << 4)) & 0x0F0F0F0F;
67 x = (
x | (
x << 2)) & 0x33333333;
72 x = (
x | (
x << 1)) & 0x55555555;
78#elif (AMREX_SPACEDIM == 1)
97std::uint32_t
toUInt10 (amrex::Real
x, amrex::Real xmin, amrex::Real xmax)
noexcept {
99 constexpr std::uint32_t code_offset = (1U << 10);
100 return (std::uint32_t)(((
x - xmin)/(xmax - xmin)) * code_offset);
117std::uint32_t
toUInt16 (amrex::Real
x, amrex::Real xmin, amrex::Real xmax)
noexcept {
119 constexpr std::uint32_t code_offset = (1U << 16);
120 return (std::uint32_t)(((
x - xmin)/(xmax - xmin)) * code_offset);
135std::uint32_t
toUInt32 (amrex::Real
x, amrex::Real xmin, amrex::Real xmax)
noexcept {
137 constexpr unsigned long long code_offset = (1ULL << 32);
138 return (std::uint32_t)(((
x - xmin)/(xmax - xmin)) * Real(code_offset));
163#if (AMREX_SPACEDIM == 3)
164 std::uint32_t a =
toUInt10(
x, plo[0], phi[0]);
165 std::uint32_t
b =
toUInt10(
y, plo[1], phi[1]);
166 std::uint32_t c =
toUInt10(
z, plo[2], phi[2]);
167#elif (AMREX_SPACEDIM == 2)
168 std::uint32_t a =
toUInt16(
x, plo[0], phi[0]);
169 std::uint32_t
b =
toUInt16(
y, plo[1], phi[1]);
170#elif (AMREX_SPACEDIM == 1)
171 std::uint32_t a =
toUInt32(
x, plo[0], phi[0]);
187#if (AMREX_SPACEDIM == 3)
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Definition AMReX_Morton.H:12
__host__ __device__ std::uint32_t toUInt16(amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept
Convert a Real to a uint32, keeping only 16 significant bits. This puts the first 16 bits of x into r...
Definition AMReX_Morton.H:117
__host__ __device__ std::uint32_t makeSpace(std::uint32_t x) noexcept
This makes space in the input 32-bit integer by splitting the bits so they can be interleaved.
Definition AMReX_Morton.H:31
__host__ __device__ std::uint32_t toUInt10(amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept
Convert a Real to a uint32, keeping only 10 significant bits. This puts the first 10 bits of x into r...
Definition AMReX_Morton.H:97
__host__ __device__ std::uint32_t toUInt32(amrex::Real x, amrex::Real xmin, amrex::Real xmax) noexcept
Convert a Real to a uint32, keeping all significant bits. It is assumed that xmin <= x < xmax.
Definition AMReX_Morton.H:135
__host__ __device__ std::uint32_t get32BitCode(Real x, Real y, Real z, const GpuArray< amrex::Real, 3 > &plo, const GpuArray< amrex::Real, 3 > &phi) noexcept
Given a 3D real-space coordinate, returns a Morton code stored in an unsigned 32 bit integer.
Definition AMReX_Morton.H:160
Definition AMReX_Array.H:34
Definition AMReX_Dim3.H:13