Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
amrex::BoxIndexerND< dim, UIntT > Struct Template Reference

Utility that maps flattened point indices back to IntVectND coordinates. More...

#include <AMReX_Box.H>

Public Types

using UInt = UIntT
using Divmod = std::conditional_t<sizeof(UInt) == 4, Math::FastDivmodU32, Math::FastDivmodU64>

Public Member Functions

 BoxIndexerND (BoxND< dim > const &box)
__host__ __device__ IntVectND< dim > intVect (std::uint64_t icell) const
 Convert flattened point index icell to its IntVectND coordinate.
__host__ __device__ Dim3 operator() (std::uint64_t icell) const
 Functor returning the coordinate padded to Dim3.
__host__ __device__ UInt numPts () const
 Return the number of points covered by the indexed box.

Public Attributes

UInt npts
Divmod fdm [dim-1]
IntVectND< dim > lo

Detailed Description

template<int dim, typename UIntT = detail::BoxIndexerUInt>
struct amrex::BoxIndexerND< dim, UIntT >

Utility that maps flattened point indices back to IntVectND coordinates.

The constructor captures a sequence of fast divmod helpers that implement fast division by the running products of box lengths, so repeated calls to intVect or the Dim3 functor avoid costly integer divisions while walking a BoxND.

Template Parameters
dimBox dimensionality.
UIntTIndex type, std::uint32_t or std::uint64_t. The 32-bit version is much cheaper on GPUs, but limits the box to fewer than 2^31 points. The default is 32-bit in GPU builds unless AMREX_ARRAY4_64BIT_INDEX is defined, and 64-bit in CPU builds. Use std::uint64_t for a large box that is not a fab box, e.g., a domain.

Member Typedef Documentation

◆ Divmod

template<int dim, typename UIntT = detail::BoxIndexerUInt>
using amrex::BoxIndexerND< dim, UIntT >::Divmod = std::conditional_t<sizeof(UInt) == 4, Math::FastDivmodU32, Math::FastDivmodU64>

◆ UInt

template<int dim, typename UIntT = detail::BoxIndexerUInt>
using amrex::BoxIndexerND< dim, UIntT >::UInt = UIntT

Constructor & Destructor Documentation

◆ BoxIndexerND()

template<int dim, typename UIntT = detail::BoxIndexerUInt>
amrex::BoxIndexerND< dim, UIntT >::BoxIndexerND ( BoxND< dim > const & box)
inline

Member Function Documentation

◆ intVect()

template<int dim, typename UIntT = detail::BoxIndexerUInt>
__host__ __device__ IntVectND< dim > amrex::BoxIndexerND< dim, UIntT >::intVect ( std::uint64_t icell) const
inlinenodiscard

Convert flattened point index icell to its IntVectND coordinate.

Parameters
icellZero-based flattened point index.
Returns
Coordinate within the tracked box.

◆ numPts()

template<int dim, typename UIntT = detail::BoxIndexerUInt>
__host__ __device__ UInt amrex::BoxIndexerND< dim, UIntT >::numPts ( ) const
inlinenodiscard

Return the number of points covered by the indexed box.

Returns
Total number of points.

◆ operator()()

template<int dim, typename UIntT = detail::BoxIndexerUInt>
__host__ __device__ Dim3 amrex::BoxIndexerND< dim, UIntT >::operator() ( std::uint64_t icell) const
inlinenodiscard

Functor returning the coordinate padded to Dim3.

Parameters
icellZero-based flattened point index.
Returns
Coordinate as Dim3.

Member Data Documentation

◆ fdm

template<int dim, typename UIntT = detail::BoxIndexerUInt>
Divmod amrex::BoxIndexerND< dim, UIntT >::fdm[dim-1]

◆ lo

template<int dim, typename UIntT = detail::BoxIndexerUInt>
IntVectND<dim> amrex::BoxIndexerND< dim, UIntT >::lo

◆ npts

template<int dim, typename UIntT = detail::BoxIndexerUInt>
UInt amrex::BoxIndexerND< dim, UIntT >::npts

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