AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::spin::Mortonizer< CoordType, MortonIndexType, 2 > Struct Template Reference

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/spin/MortonIndex.hpp>

Inheritance diagram for axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >:

Public Types

enum  {
  NDIM = 2 , COORD_BITS = std::numeric_limits<CoordType>::digits , MORTON_BITS = std::numeric_limits<MortonIndexType>::digits , MB_PER_DIM = MORTON_BITS / NDIM ,
  MAX_UNIQUE_BITS = (MB_PER_DIM < COORD_BITS) ? MB_PER_DIM : COORD_BITS , CONTRACT_MAX_ITER = NumReps<MortonIndexType>::value , EXPAND_MAX_ITER = NumReps<MortonIndexType>::value
}
 
using self = Mortonizer< CoordType, MortonIndexType, 2 >
 
using Base = MortonBase< CoordType, MortonIndexType, self >
 

Public Member Functions

 AXOM_STATIC_ASSERT_MSG (std::is_integral< CoordType >::value, "Coordtype must be integral for Morton indexing")
 
 AXOM_STATIC_ASSERT_MSG (std::is_integral< MortonIndexType >::value, "MortonIndexType must be integral for Morton indexing")
 

Static Public Member Functions

static AXOM_HOST_DEVICE MortonIndexType GetB (int i)
 
static AXOM_HOST_DEVICE int GetS (int i)
 
static AXOM_HOST_DEVICE MortonIndexType mortonize (CoordType x, CoordType y)
 A function to convert a 2D point to a Morton index. More...
 
static AXOM_HOST_DEVICE MortonIndexType mortonize (const primal::Point< CoordType, NDIM > &pt)
 A function to convert a 2D point to a Morton index. More...
 
static AXOM_HOST_DEVICE void demortonize (MortonIndexType morton, CoordType &x, CoordType &y)
 A function to convert a Morton index back to a 2D point. More...
 
static AXOM_HOST_DEVICE primal::Point< CoordType, NDIMdemortonize (MortonIndexType morton)
 A function to convert a Morton index back to a 2D point. More...
 
static int maxBitsPerCoord ()
 returns the maximum number of bits per coordinate More...
 
static int maxSetBit (CoordType x)
 Finds the index of the maximum set bit (MSB) in an integral type. More...
 

Static Protected Member Functions

static AXOM_HOST_DEVICE MortonIndexType expandBits (MortonIndexType x)
 Expands bits in bitwise representation of an integral type and zero-fills the holes. More...
 
static AXOM_HOST_DEVICE MortonIndexType contractBits (MortonIndexType x)
 Contracts bits in bitwise representation of x. More...
 

Member Typedef Documentation

◆ self

template<typename CoordType , typename MortonIndexType >
using axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::self = Mortonizer<CoordType, MortonIndexType, 2>

◆ Base

template<typename CoordType , typename MortonIndexType >
using axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::Base = MortonBase<CoordType, MortonIndexType, self>

Member Enumeration Documentation

◆ anonymous enum

template<typename CoordType , typename MortonIndexType >
anonymous enum
Enumerator
NDIM 

The dimension of the Mortonizer

COORD_BITS 

The number of bits in a CoordType

MORTON_BITS 

The number of bits in a MortonIndex

MB_PER_DIM 

The number of representable Morton bits per dimension

MAX_UNIQUE_BITS 

The maximum number of unique bits from each coordinate of type CoordType that can be represented in a MortonIndex.

Note
If we are use Mortonizer as a (one-way) hash function, it is ok to use more bits. But, if we would like to be able to reverse the MortonIndex, then we cannot safely use more than MAX_UNIQUE_BITS per coordinate.
CONTRACT_MAX_ITER 

The number of iterations required for converting from MortonIndexes to CoordType using the bit interleaving algorithm in MortonBase.

EXPAND_MAX_ITER 

The number of iterations required for converting between CoordTypes and MortonIndexes using the bit interleaving algorithm in MortonBase.

Member Function Documentation

◆ GetB()

template<typename CoordType , typename MortonIndexType >
static AXOM_HOST_DEVICE MortonIndexType axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::GetB ( int  i)
inlinestatic

◆ GetS()

template<typename CoordType , typename MortonIndexType >
static AXOM_HOST_DEVICE int axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::GetS ( int  i)
inlinestatic

◆ mortonize() [1/2]

template<typename CoordType , typename MortonIndexType >
static AXOM_HOST_DEVICE MortonIndexType axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::mortonize ( CoordType  x,
CoordType  y 
)
inlinestatic

A function to convert a 2D point to a Morton index.

Morton indexing interleaves the bits of the point's coordinates

Parameters
[in]xThe x-coordinate of the point
[in]yThe y-coordinate of the point
Precondition
CoordType must be an integral type
x and y must be positive with value less than \( 2^{16} \)
Note
These preconditions can easily be relaxed, if desired (e.g. to 32 bits for 64 bit Morton indices)
Returns
The MortonIndex of the 2D point

◆ mortonize() [2/2]

template<typename CoordType , typename MortonIndexType >
static AXOM_HOST_DEVICE MortonIndexType axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::mortonize ( const primal::Point< CoordType, NDIM > &  pt)
inlinestatic

A function to convert a 2D point to a Morton index.

See also
mortonize(CoordType, CoordType)

◆ demortonize() [1/2]

template<typename CoordType , typename MortonIndexType >
static AXOM_HOST_DEVICE void axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::demortonize ( MortonIndexType  morton,
CoordType &  x,
CoordType &  y 
)
inlinestatic

A function to convert a Morton index back to a 2D point.

Parameters
[in]mortonThe MortonIndex of the desired point
[out]xThe x-coordinate of the point
[out]yThe y-coordinate of the point Morton indexing interleaves the bits of the point's coordinates
Note
The point's coordinates are returned in the x and y parameters

◆ demortonize() [2/2]

template<typename CoordType , typename MortonIndexType >
static AXOM_HOST_DEVICE primal::Point<CoordType, NDIM> axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::demortonize ( MortonIndexType  morton)
inlinestatic

A function to convert a Morton index back to a 2D point.

See also
demortonize(MortonIndex,CoordType,CoordType)

◆ maxBitsPerCoord()

template<typename CoordType , typename MortonIndexType >
static int axom::spin::Mortonizer< CoordType, MortonIndexType, 2 >::maxBitsPerCoord ( )
inlinestatic

returns the maximum number of bits per coordinate

◆ AXOM_STATIC_ASSERT_MSG() [1/2]

axom::spin::MortonBase< CoordType, MortonIndexType, Mortonizer< CoordType, MortonIndexType, 2 > >::AXOM_STATIC_ASSERT_MSG ( std::is_integral< CoordType >::value  ,
"Coordtype must be integral for Morton indexing"   
)
inherited

◆ AXOM_STATIC_ASSERT_MSG() [2/2]

axom::spin::MortonBase< CoordType, MortonIndexType, Mortonizer< CoordType, MortonIndexType, 2 > >::AXOM_STATIC_ASSERT_MSG ( std::is_integral< MortonIndexType >::value  ,
"MortonIndexType must be integral for Morton indexing"   
)
inherited

◆ expandBits()

static AXOM_HOST_DEVICE MortonIndexType axom::spin::MortonBase< CoordType, MortonIndexType, Mortonizer< CoordType, MortonIndexType, 2 > >::expandBits ( MortonIndexType  x)
inlinestaticprotectedinherited

Expands bits in bitwise representation of an integral type and zero-fills the holes.

Parameters
[in]xThe integer type that we are expanding
Returns
A zero-filled expanded MortonIndex In dimension D, it adds (D-1) zeros between each bit, so, e.g. in 2D, 6 == 0b0110 becomes 0b*0*1*1*0 == 0b00010100 == 20

◆ contractBits()

static AXOM_HOST_DEVICE MortonIndexType axom::spin::MortonBase< CoordType, MortonIndexType, Mortonizer< CoordType, MortonIndexType, 2 > >::contractBits ( MortonIndexType  x)
inlinestaticprotectedinherited

Contracts bits in bitwise representation of x.

Parameters
[in]xThe Morton index that we are contracting
Returns
A contracted MortonIndex

In dimension D, it retains every (D-1) \(^th\) bit, so, e.g. in 2D, 20 = 0b00010100 == 0b*0*1*1*0 becomes 0b0110 = 6

◆ maxSetBit()

static int axom::spin::MortonBase< CoordType, MortonIndexType, Mortonizer< CoordType, MortonIndexType, 2 > >::maxSetBit ( CoordType  x)
inlinestaticinherited

Finds the index of the maximum set bit (MSB) in an integral type.


The documentation for this struct was generated from the following file: