AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS > Struct Template Reference

This class encapsulates data for strided structured indexing and provides methods for creating/manipulating indices. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/main/src/axom/bump/views/StridedStructuredIndexing.hpp>

Public Types

using IndexType = IndexT
 
using LogicalIndex = axom::StackArray< IndexType, NDIMS >
 

Public Member Functions

AXOM_HOST_DEVICE StridedStructuredIndexing ()
 constructor More...
 
AXOM_HOST_DEVICE StridedStructuredIndexing (const LogicalIndex &dims, const LogicalIndex &offsets, const LogicalIndex &strides)
 Constructor. More...
 
AXOM_HOST_DEVICE IndexType size () const
 Return the number of values in the index space. More...
 
AXOM_HOST_DEVICE const LogicalIndexlogicalDimensions () const
 Return the logical dimensions. More...
 
AXOM_HOST_DEVICE IndexType ::type jStride () const
 
template<size_t _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==3, IndexType >::type kStride () const
 Return the k stride. More...
 
AXOM_HOST_DEVICE IndexType globalToGlobal (const LogicalIndex &global) const
 Turn a global logical index into an index. More...
 
AXOM_HOST_DEVICE LogicalIndex globalToLocal (const LogicalIndex &global) const
 Convert global logical index to a local one. More...
 
AXOM_HOST_DEVICE IndexType globalToLocal (IndexType global) const
 Turn a global index into a local index. More...
 
AXOM_HOST_DEVICE LogicalIndex localToGlobal (const LogicalIndex &local) const
 Convert local logical index to a global one. More...
 
AXOM_HOST_DEVICE IndexType localToGlobal (IndexType local) const
 Convert local logical index to a global one. More...
 
AXOM_HOST_DEVICE IndexType logicalIndexToIndex (const LogicalIndex &logical) const
 Turn a local logical index into a local flat index. More...
 
AXOM_HOST_DEVICE bool contains (const LogicalIndex &logical) const
 Determines whether the indexing contains the supplied logical index. More...
 
AXOM_HOST_DEVICE bool contains (IndexType index) const
 Determines whether the indexing contains the supplied index. More...
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==1, LogicalIndex >::type globalToGlobal (IndexType global) const
 Turn a global index into a global logical index. More...
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==2, LogicalIndex >::type globalToGlobal (IndexType global) const
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==3, LogicalIndex >::type globalToGlobal (IndexType global) const
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==1, LogicalIndex >::type indexToLogicalIndex (IndexType index) const
 Turn a local index into a local logical index. More...
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==2, LogicalIndex >::type indexToLogicalIndex (IndexType index) const
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==3, LogicalIndex >::type indexToLogicalIndex (IndexType index) const
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==1, StridedStructuredIndexing >::type expand () const
 Expand the current StridedStructuredIndexing by one in each dimension. More...
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==2, StridedStructuredIndexing >::type expand () const
 
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if< _ndims==3, StridedStructuredIndexing >::type expand () const
 
AXOM_HOST_DEVICE LogicalIndex clamp (const LogicalIndex &logical) const
 Given a logical index that may or may not be in the index space, return a clamped logical index that is in the index space. The logical indices are clamped to [0, dimensions-1] in each dimension. More...
 
IndexType clamp (IndexType index) const
 

Static Public Member Functions

constexpr static AXOM_HOST_DEVICE int dimension ()
 
static constexpr AXOM_HOST_DEVICE bool supports_strided_structured_indexing ()
 Return whether the view supports strided structured indexing. More...
 

Public Attributes

LogicalIndex m_dimensions {}
 
LogicalIndex m_offsets {}
 
LogicalIndex m_strides {}
 

Detailed Description

template<typename IndexT, int NDIMS = 3>
struct axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >

This class encapsulates data for strided structured indexing and provides methods for creating/manipulating indices.

Template Parameters
IndexTThe type used for indices.
NDIMSThe number of dimensions.

Strided structured indexing lets us index part of a larger overall indexing space. We can index it using indices local to the selected window and the class provides a mechanism to return indices in the overall indexing space.

Example:

x—x—x—x—x—x—x | | | | | | | x—x—*—*—*—*—x *=real node, x=ignored node, O=origin node 16 | | | | | | | x—x—*—*—*—*—x dims={4,3} | | | | | | | origin={2,2} x—x—O—*—*—*—x stride={1,7} | | | | | | | x—x—x—x—x—x—x | | | | | | | x—x—x—x—x—x—x

Member Typedef Documentation

◆ IndexType

template<typename IndexT , int NDIMS = 3>
using axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::IndexType = IndexT

◆ LogicalIndex

template<typename IndexT , int NDIMS = 3>
using axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::LogicalIndex = axom::StackArray<IndexType, NDIMS>

Constructor & Destructor Documentation

◆ StridedStructuredIndexing() [1/2]

◆ StridedStructuredIndexing() [2/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::StridedStructuredIndexing ( const LogicalIndex dims,
const LogicalIndex offsets,
const LogicalIndex strides 
)
inline

Constructor.

Parameters
dimsThe number of zones in each logical dimension.
offsetsThe offset of the first zone from the mesh origin in each logical dimension.
stridesThe amount to stride when moving to the next element for each logical dimension.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions, and SLIC_ERROR_IF.

Member Function Documentation

◆ dimension()

template<typename IndexT , int NDIMS = 3>
constexpr static AXOM_HOST_DEVICE int axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::dimension ( )
inlinestaticconstexpr

◆ supports_strided_structured_indexing()

template<typename IndexT , int NDIMS = 3>
static constexpr AXOM_HOST_DEVICE bool axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::supports_strided_structured_indexing ( )
inlinestaticconstexpr

Return whether the view supports strided structured indexing.

Returns
true

◆ size()

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE IndexType axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::size ( ) const
inline

Return the number of values in the index space.

Returns
The number of values in the index space.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions.

◆ logicalDimensions()

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE const LogicalIndex& axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::logicalDimensions ( ) const
inline

Return the logical dimensions.

Returns
The logical dimensions.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions.

◆ jStride()

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE IndexType ::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::jStride ( ) const
inline

◆ kStride()

template<typename IndexT , int NDIMS = 3>
template<size_t _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 3, IndexType>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::kStride ( ) const
inline

Return the k stride.

Returns
The k stride to move forward a "page".

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_strides.

◆ globalToGlobal() [1/4]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE IndexType axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::globalToGlobal ( const LogicalIndex global) const
inline

Turn a global logical index into an index.

Parameters
globalThe global logical index to convert.
Returns
The global index.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_strides.

◆ globalToGlobal() [2/4]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 1, LogicalIndex>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::globalToGlobal ( IndexType  global) const
inline

Turn a global index into a global logical index.

Parameters
globalThe index to convert.
Returns
The local index that corresponds to the local.

◆ globalToGlobal() [3/4]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 2, LogicalIndex>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::globalToGlobal ( IndexType  global) const
inline

◆ globalToGlobal() [4/4]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 3, LogicalIndex>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::globalToGlobal ( IndexType  global) const
inline

◆ globalToLocal() [1/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE LogicalIndex axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::globalToLocal ( const LogicalIndex global) const
inline

Convert global logical index to a local one.

Parameters
localThe local logical index.
Returns
local logical index.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_offsets.

◆ globalToLocal() [2/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE IndexType axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::globalToLocal ( IndexType  global) const
inline

◆ localToGlobal() [1/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE LogicalIndex axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::localToGlobal ( const LogicalIndex local) const
inline

Convert local logical index to a global one.

Parameters
localThe local logical index.
Returns
global logical index.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_offsets.

◆ localToGlobal() [2/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE IndexType axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::localToGlobal ( IndexType  local) const
inline

◆ indexToLogicalIndex() [1/3]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 1, LogicalIndex>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::indexToLogicalIndex ( IndexType  index) const
inline

Turn a local index into a local logical index.

Parameters
indexThe index to convert.
Returns
The local logical index that corresponds to the index.

◆ indexToLogicalIndex() [2/3]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 2, LogicalIndex>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::indexToLogicalIndex ( IndexType  index) const
inline

◆ indexToLogicalIndex() [3/3]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 3, LogicalIndex>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::indexToLogicalIndex ( IndexType  index) const
inline

◆ logicalIndexToIndex()

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE IndexType axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::logicalIndexToIndex ( const LogicalIndex logical) const
inline

Turn a local logical index into a local flat index.

Parameters
logicalThe logical indexto convert to a flat index.
Returns
The index that corresponds to the logical index.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions.

◆ contains() [1/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE bool axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::contains ( const LogicalIndex logical) const
inline

Determines whether the indexing contains the supplied logical index.

Parameters
logicalThe logical index being tested.
Returns
True if the logical index is within the index, false otherwise.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::dimension(), and axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions.

◆ contains() [2/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE bool axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::contains ( IndexType  index) const
inline

Determines whether the indexing contains the supplied index.

Parameters
indexThe index being tested.
Returns
True if the index is within the index, false otherwise.

References axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::contains(), and axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::indexToLogicalIndex().

◆ expand() [1/3]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 1, StridedStructuredIndexing>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::expand ( ) const
inline

◆ expand() [2/3]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 2, StridedStructuredIndexing>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::expand ( ) const
inline

◆ expand() [3/3]

template<typename IndexT , int NDIMS = 3>
template<int _ndims = NDIMS>
AXOM_HOST_DEVICE std::enable_if<_ndims == 3, StridedStructuredIndexing>::type axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::expand ( ) const
inline

◆ clamp() [1/2]

template<typename IndexT , int NDIMS = 3>
AXOM_HOST_DEVICE LogicalIndex axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::clamp ( const LogicalIndex logical) const
inline

Given a logical index that may or may not be in the index space, return a clamped logical index that is in the index space. The logical indices are clamped to [0, dimensions-1] in each dimension.

Parameters
logicalThe input logical index being clamped.
Return values
Anew LogicalIndex that is in the index space.

References axom::utilities::clampVal(), axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::dimension(), and axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions.

◆ clamp() [2/2]

Member Data Documentation

◆ m_dimensions

template<typename IndexT , int NDIMS = 3>
LogicalIndex axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_dimensions {}

◆ m_offsets

template<typename IndexT , int NDIMS = 3>
LogicalIndex axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_offsets {}

◆ m_strides

template<typename IndexT , int NDIMS = 3>
LogicalIndex axom::bump::views::StridedStructuredIndexing< IndexT, NDIMS >::m_strides {}

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