Intrepid2
Public Types | Public Member Functions | Protected Attributes | List of all members
Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType > Class Template Reference

A helper class that allows iteration over three Kokkos Views simultaneously, according to tensor combination rules: More...

#include <Intrepid2_TensorViewIterator.hpp>

Public Types

enum  RankCombinationType { DIMENSION_MATCH , TENSOR_PRODUCT , TENSOR_CONTRACTION }
 
using RankCombinationViewType = Kokkos::View<RankCombinationType*, typename TensorViewType::device_type>
 

Public Member Functions

KOKKOS_INLINE_FUNCTION TensorViewIterator (TensorViewType tensor_view, ViewType1 view1, ViewType2 view2, RankCombinationViewType rank_combination_types)
 Constructor.
 
KOKKOS_INLINE_FUNCTION int nextIncrementRank ()
 
KOKKOS_INLINE_FUNCTION int increment ()
 
KOKKOS_INLINE_FUNCTION void setLocation (const Kokkos::Array< int, 7 > location)
 
KOKKOS_INLINE_FUNCTION void setLocation (Kokkos::Array< int, 7 > location1, Kokkos::Array< int, 7 > location2)
 
KOKKOS_INLINE_FUNCTION ScalarType getView1Entry ()
 
KOKKOS_INLINE_FUNCTION ScalarType getView2Entry ()
 
KOKKOS_INLINE_FUNCTION void set (ScalarType value)
 

Protected Attributes

ViewIterator< TensorViewType, ScalarType > tensor_view_iterator_
 
ViewIterator< ViewType1, ScalarType > view1_iterator_
 
ViewIterator< ViewType2, ScalarType > view2_iterator_
 
RankCombinationViewType rank_combination_types_
 

Detailed Description

template<class TensorViewType, class ViewType1, class ViewType2, typename ScalarType>
class Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >

A helper class that allows iteration over three Kokkos Views simultaneously, according to tensor combination rules:

See also
Intrepid2::ViewIterator
Remarks
This class is under active development; its interface should be understood to be in flux. Furthermore, this may eventually move to another Trilinos package.

Definition at line 73 of file Intrepid2_TensorViewIterator.hpp.

Member Typedef Documentation

◆ RankCombinationViewType

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
using Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::RankCombinationViewType = Kokkos::View<RankCombinationType*, typename TensorViewType::device_type>

Definition at line 82 of file Intrepid2_TensorViewIterator.hpp.

Member Enumeration Documentation

◆ RankCombinationType

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
enum Intrepid2::TensorViewIterator::RankCombinationType

Definition at line 76 of file Intrepid2_TensorViewIterator.hpp.

Constructor & Destructor Documentation

◆ TensorViewIterator()

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::TensorViewIterator ( TensorViewType tensor_view,
ViewType1 view1,
ViewType2 view2,
RankCombinationViewType rank_combination_types )
inline

Constructor.

Parameters
[in]tensor_view- the view that stores the tensor combination
[in]view1- first component view
[in]view2- second component view
[in]rank_combination_types- vector with length equal to the maximum rank of the views provided, specifying how component views should be combined to produce tensor view. rank_combination_types entries can be as follows:
  • DIMENSION_MATCH: component views and tensor view all have same extent in this rank, and should iterate in tandem.
  • TENSOR_PRODUCT: if component views have extents a and b in this rank, the tensor view has extent a*b.
  • TENSOR_CONTRACTION: component views have matching extents in this rank; tensor view has extent 1.

For TENSOR_PRODUCT combinations in a given rank, view1 increments first. For example, if view1 has entries [x,y] and view2 has entries [0,1] in a given TENSOR_PRODUCT rank, there will be four entries in the tensor_view, in the following order:

  • (x,0)
  • (y,0)
  • (x,1)
  • (y,1)

Tensor contractions are only allowed in the final dimension(s); if rank d has a TENSOR_CONTRACTION entry, then all subsequent ranks must also contract.

Definition at line 111 of file Intrepid2_TensorViewIterator.hpp.

References INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE.

Member Function Documentation

◆ getView1Entry()

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION ScalarType Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::getView1Entry ( )
inline

Getter for view1.

Returns
the value at the current location in view1

Definition at line 296 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::ViewIterator< ViewType, ScalarType >::get().

◆ getView2Entry()

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION ScalarType Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::getView2Entry ( )
inline

Getter for view1.

Returns
the value at the current location in view2

Definition at line 304 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::ViewIterator< ViewType, ScalarType >::get().

◆ increment()

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION int Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::increment ( )
inline

Move to the next location. Note that during contractions, the tensor view location will not change; the returned rank corresponds to the other two views in that case.

Returns
the rank of the leftmost index that was changed in any of the views; -1 if increment reached the end of the views

Definition at line 188 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::device_assert(), Intrepid2::ViewIterator< ViewType, ScalarType >::increment(), Intrepid2::ViewIterator< ViewType, ScalarType >::nextIncrementRank(), and Intrepid2::ViewIterator< ViewType, ScalarType >::reset().

◆ nextIncrementRank()

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION int Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::nextIncrementRank ( )
inline
Returns
the leftmost rank ordinal whose index will change on next increment in any of the views (-1 if next increment will go out of bounds)

Definition at line 177 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::ViewIterator< ViewType, ScalarType >::nextIncrementRank().

◆ set()

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION void Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::set ( ScalarType value)
inline

Setter for tensor view.

Parameters
[in]value- the value to set in the tensor view

Definition at line 312 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::ViewIterator< ViewType, ScalarType >::set().

◆ setLocation() [1/2]

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION void Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::setLocation ( const Kokkos::Array< int, 7 > location)
inline

Sets the current location in all three views to the specified location.

Parameters
[in]location- the location as a 7-element array value.

Definition at line 238 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::ViewIterator< ViewType, ScalarType >::setLocation().

◆ setLocation() [2/2]

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
KOKKOS_INLINE_FUNCTION void Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::setLocation ( Kokkos::Array< int, 7 > location1,
Kokkos::Array< int, 7 > location2 )
inline

Sets the current location in the two component views to the specified locations, and sets the tensor view location to the location corresponding to the two component locations.

Parameters
[in]location1- the location in view1 as a 7-element array value.
[in]location2- the location in view2 as a 7-element array value.

Definition at line 249 of file Intrepid2_TensorViewIterator.hpp.

References Intrepid2::device_assert(), Intrepid2::ViewIterator< ViewType, ScalarType >::getExtent(), and Intrepid2::ViewIterator< ViewType, ScalarType >::setLocation().

Member Data Documentation

◆ rank_combination_types_

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
RankCombinationViewType Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::rank_combination_types_
protected

Definition at line 89 of file Intrepid2_TensorViewIterator.hpp.

◆ tensor_view_iterator_

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
ViewIterator<TensorViewType, ScalarType> Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::tensor_view_iterator_
protected

Definition at line 85 of file Intrepid2_TensorViewIterator.hpp.

◆ view1_iterator_

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
ViewIterator<ViewType1, ScalarType> Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::view1_iterator_
protected

Definition at line 86 of file Intrepid2_TensorViewIterator.hpp.

◆ view2_iterator_

template<class TensorViewType , class ViewType1 , class ViewType2 , typename ScalarType >
ViewIterator<ViewType2, ScalarType> Intrepid2::TensorViewIterator< TensorViewType, ViewType1, ViewType2, ScalarType >::view2_iterator_
protected

Definition at line 87 of file Intrepid2_TensorViewIterator.hpp.


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