15 #ifndef Intrepid2_ViewIterator_h
16 #define Intrepid2_ViewIterator_h
41 template<
class ViewType,
typename ScalarType>
45 Kokkos::Array<int,7> dims_;
46 Kokkos::Array<int,7> index_;
50 KOKKOS_INLINE_FUNCTION
55 for (
unsigned d=0; d<getFunctorRank(view); d++)
57 dims_[d] = view.extent_int(d);
60 for (
unsigned d=getFunctorRank(view); d<7; d++)
69 KOKKOS_INLINE_FUNCTION
72 return view_.access(index_[0],index_[1],index_[2],index_[3],index_[4],index_[5],index_[6]);
77 KOKKOS_INLINE_FUNCTION
78 void set(
const ScalarType &value)
80 view_.access(index_[0],index_[1],index_[2],index_[3],index_[4],index_[5],index_[6]) = value;
85 KOKKOS_INLINE_FUNCTION
88 const int rank = getFunctorRank(view_);
89 for (
int r=rank-1; r>=0; r--)
91 if (index_[r]+1 < dims_[r])
102 KOKKOS_INLINE_FUNCTION
105 const int rank = getFunctorRank(view_);
106 for (
int r=rank-1; r>=0; r--)
108 if (index_[r]+1 < dims_[r])
127 KOKKOS_INLINE_FUNCTION
130 const auto rank = view_.rank();
131 for (
int r=rank-1; r>=0; r--)
133 if (index_[r]-1 >= 0)
141 index_[r] = dims_[r]-1;
153 KOKKOS_INLINE_FUNCTION
157 for (
int d=0; d<7; d++)
159 if (d>0) index_1D *= dims_[d-1];
160 index_1D += index_[d];
168 KOKKOS_INLINE_FUNCTION
171 Kokkos::Array<int,7> location;
172 int remainder = enumerationIndex;
173 for (
int d=6; d>=0; d--)
175 location[d] = remainder % dims_[d];
176 remainder /= dims_[d];
185 KOKKOS_INLINE_FUNCTION
188 return index_[dimension];
194 KOKKOS_INLINE_FUNCTION
197 return dims_[dimension];
202 KOKKOS_INLINE_FUNCTION
203 void reset(
unsigned from_rank_number=0)
205 for (
unsigned d=from_rank_number; d<view_.rank(); d++)
213 KOKKOS_INLINE_FUNCTION
221 KOKKOS_INLINE_FUNCTION
KOKKOS_INLINE_FUNCTION void reset(unsigned from_rank_number=0)
KOKKOS_INLINE_FUNCTION int nextIncrementRank()
KOKKOS_INLINE_FUNCTION int getExtent(int dimension)
KOKKOS_INLINE_FUNCTION int getEnumerationIndex()
Header function for Intrepid2::Util class and other utility functions.
KOKKOS_INLINE_FUNCTION void set(const ScalarType &value)
KOKKOS_INLINE_FUNCTION bool decrement()
KOKKOS_INLINE_FUNCTION void setEnumerationIndex(const int &enumerationIndex)
KOKKOS_INLINE_FUNCTION int increment()
KOKKOS_INLINE_FUNCTION void setLocation(const Kokkos::Array< int, 7 > &location)
A helper class that allows iteration over some part of a Kokkos View, while allowing the calling code...
KOKKOS_INLINE_FUNCTION Kokkos::Array< int, 7 > & getLocation()
KOKKOS_INLINE_FUNCTION int getIndex(int dimension)
KOKKOS_INLINE_FUNCTION ViewIterator(ViewType view)