49 #ifndef Intrepid2_ViewIterator_h
50 #define Intrepid2_ViewIterator_h
75 template<
class ViewType,
typename ScalarType>
79 Kokkos::Array<int,7> dims_;
80 Kokkos::Array<int,7> index_;
84 KOKKOS_INLINE_FUNCTION
89 for (
unsigned d=0; d<getFunctorRank(view); d++)
91 dims_[d] = view.extent_int(d);
94 for (
unsigned d=getFunctorRank(view); d<7; d++)
103 KOKKOS_INLINE_FUNCTION
106 return view_.access(index_[0],index_[1],index_[2],index_[3],index_[4],index_[5],index_[6]);
111 KOKKOS_INLINE_FUNCTION
112 void set(
const ScalarType &value)
114 view_.access(index_[0],index_[1],index_[2],index_[3],index_[4],index_[5],index_[6]) = value;
119 KOKKOS_INLINE_FUNCTION
122 const int rank = getFunctorRank(view_);
123 for (
int r=rank-1; r>=0; r--)
125 if (index_[r]+1 < dims_[r])
136 KOKKOS_INLINE_FUNCTION
139 const int rank = getFunctorRank(view_);
140 for (
int r=rank-1; r>=0; r--)
142 if (index_[r]+1 < dims_[r])
161 KOKKOS_INLINE_FUNCTION
164 const auto rank = view_.rank();
165 for (
int r=rank-1; r>=0; r--)
167 if (index_[r]-1 >= 0)
175 index_[r] = dims_[r]-1;
187 KOKKOS_INLINE_FUNCTION
191 for (
int d=0; d<7; d++)
193 if (d>0) index_1D *= dims_[d-1];
194 index_1D += index_[d];
202 KOKKOS_INLINE_FUNCTION
205 Kokkos::Array<int,7> location;
206 int remainder = enumerationIndex;
207 for (
int d=6; d>=0; d--)
209 location[d] = remainder % dims_[d];
210 remainder /= dims_[d];
219 KOKKOS_INLINE_FUNCTION
222 return index_[dimension];
228 KOKKOS_INLINE_FUNCTION
231 return dims_[dimension];
236 KOKKOS_INLINE_FUNCTION
237 void reset(
unsigned from_rank_number=0)
239 for (
unsigned d=from_rank_number; d<view_.rank(); d++)
247 KOKKOS_INLINE_FUNCTION
255 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)