3333 * // Create chunked iterator and process edges
3434 * specfem::execution::ChunkedEdgeIterator iterator(ParallelConfig(), edges,
3535 * num_points); specfem::execution::for_all("process_edges", iterator,
36- * KOKKOS_LAMBDA(const auto& index) {
36+ * KOKKOS_LAMBDA(const auto& iterator_index) {
37+ * const auto index = iterator_index.get_index();
3738 * // Access edge point data
3839 * int ispec = index.ispec; // Element index
3940 * int ipoint = index.ipoint; // Point index along edge
@@ -80,7 +81,8 @@ namespace specfem::execution {
8081 * @code{.cpp}
8182 * // Typically used within chunked edge iterator lambdas
8283 * specfem::execution::for_all("process_edges", iterator,
83- * KOKKOS_LAMBDA(const EdgePointIndex<dim2, int, ExecutionSpace>& index) {
84+ * KOKKOS_LAMBDA(const auto & iterator_index) {
85+ * const auto index = iterator_index.get_index();
8486 * int element_id = index.ispec; // Element containing this edge point
8587 * int z_coord = index.iz; // Local z-coordinate within element
8688 * int x_coord = index.ix; // Local x-coordinate within element
@@ -121,6 +123,11 @@ class EdgePointIndex {
121123 KOKKOS_INLINE_FUNCTION
122124 constexpr const index_type &get_index () const { return this ->index ; }
123125
126+ KOKKOS_INLINE_FUNCTION
127+ constexpr const index_type &get_local_index () const {
128+ return this ->local_index ; // /< Returns the local point index
129+ }
130+
124131 /* *
125132 * @brief Constructor for EdgePointIndex
126133 *
@@ -130,8 +137,10 @@ class EdgePointIndex {
130137 */
131138 KOKKOS_INLINE_FUNCTION
132139 EdgePointIndex (const specfem::point::index<DimensionTag, false > &index,
133- const int ipoint, const KokkosIndexType &kokkos_index)
134- : index(index.ispec, kokkos_index, ipoint, index.iz, index.ix),
140+ const int gedge, const int iedge, const int ipoint,
141+ const KokkosIndexType &kokkos_index)
142+ : index(index.ispec, gedge, ipoint, index.iz, index.ix),
143+ local_index (index.ispec, iedge, ipoint, index.iz, index.ix),
135144 kokkos_index(kokkos_index) {}
136145
137146 /* *
@@ -144,7 +153,8 @@ class EdgePointIndex {
144153 constexpr const iterator_type get_iterator () const { return iterator_type{}; }
145154
146155private:
147- index_type index; // /< Local element coordinates of the edge point
156+ index_type index; // /< Local element coordinates of the edge point
157+ index_type local_index; // /< Local element coordinates relative to chunk
148158
149159 KokkosIndexType kokkos_index; // /< Kokkos index type
150160};
@@ -201,6 +211,7 @@ class ChunkEdgeIterator : public TeamThreadRangePolicy<TeamMemberType, int> {
201211 const int iedge = i % nedges;
202212 const int ipoint = i / nedges;
203213 const int ispec = edges (iedge).ispec ;
214+ const int gedge = edges (iedge).iedge ;
204215 const specfem::mesh_entity::dim2::type edge_type = edges (iedge).edge_type ;
205216 const auto index =
206217 (edges (iedge).reverse_orientation )
@@ -209,7 +220,7 @@ class ChunkEdgeIterator : public TeamThreadRangePolicy<TeamMemberType, int> {
209220 : ChunkEdgeIterator::compute_index (ispec, ipoint, num_points,
210221 edge_type);
211222
212- return index_type{ index, ipoint , iedge };
223+ return index_type{ index, gedge , iedge, ipoint, i };
213224 }
214225
215226 /* *
@@ -463,10 +474,15 @@ class ChunkedEdgeIterator : public TeamPolicy<ParallelConfig> {
463474 // /< specfem::execution::for_each_level
464475 using execution_space =
465476 typename base_type::execution_space; // /< Execution space type.
466- using base_index_type = specfem::point::edge_index<
467- ParallelConfig::dimension>; // /< Index type to be used when calling
468- // /< @ref specfem::execution::for_all
469- // /< with this iterator.
477+ using base_index_type = EdgePointIndex<
478+ ParallelConfig::dimension, int ,
479+ typename base_type::execution_space>; // /< Index type
480+ // /< to be used
481+ // /< when calling
482+ // /< @ref
483+ // /< specfem::execution::for_all
484+ // /< with this
485+ // /< iterator.
470486
471487 /* *
472488 * @brief Constructor with explicit edge view and point count
0 commit comments