@@ -106,7 +106,10 @@ namespace ArborX
106106{
107107// ! Neighbor access trait for Cabana slice and/or Kokkos View.
108108template <typename Positions>
109- struct AccessTraits <Positions, PrimitivesTag,
109+ struct AccessTraits <Positions,
110+ #if ARBORX_VERSION < 10799
111+ PrimitivesTag,
112+ #endif
110113 std::enable_if_t <Cabana::is_slice<Positions>{} ||
111114 Kokkos::is_view<Positions>{}>>
112115{
@@ -120,17 +123,21 @@ struct AccessTraits<Positions, PrimitivesTag,
120123 return Cabana::size ( x );
121124 }
122125 // ! Get the particle at the index.
123- static KOKKOS_FUNCTION Point get ( Positions const & x, size_type i )
126+ static KOKKOS_FUNCTION auto get ( Positions const & x, size_type i )
124127 {
125- return { static_cast <float >( x ( i, 0 ) ),
126- static_cast <float >( x ( i, 1 ) ),
127- static_cast <float >( x ( i, 2 ) ) };
128+ return Point { static_cast <float >( x ( i, 0 ) ),
129+ static_cast <float >( x ( i, 1 ) ),
130+ static_cast <float >( x ( i, 2 ) ) };
128131 }
129132};
130133// ! Neighbor access trait.
131134template <typename Positions>
132- struct AccessTraits <
133- Cabana::Experimental::Impl::SubPositionsAndRadius<Positions>, PredicatesTag>
135+ struct AccessTraits <Cabana::Experimental::Impl::SubPositionsAndRadius<Positions>
136+ #if ARBORX_VERSION < 10799
137+ ,
138+ PredicatesTag
139+ #endif
140+ >
134141{
135142 // ! Position wrapper with partial range and radius information.
136143 using PositionLike =
@@ -148,10 +155,15 @@ struct AccessTraits<
148155 static KOKKOS_FUNCTION auto get ( PositionLike const & x, size_type i )
149156 {
150157 assert ( i < size ( x ) );
151- auto const point =
152- AccessTraits<typename PositionLike::positions_type,
153- PrimitivesTag>::get ( x.data , x.first + i );
154- return attach ( intersects ( Sphere{ point, x.radius } ), (int )i );
158+ auto const point = AccessTraits<typename PositionLike::positions_type
159+ #if ARBORX_VERSION < 10799
160+ ,
161+ PrimitivesTag
162+ #endif
163+ >::get ( x.data , x.first + i );
164+ return attach (
165+ intersects ( Sphere{ point, static_cast <float >( x.radius ) } ),
166+ (int )i );
155167 }
156168};
157169} // namespace ArborX
@@ -186,6 +198,21 @@ struct CollisionFilter<HalfNeighborTag>
186198template <typename Tag>
187199struct NeighborDiscriminatorCallback
188200{
201+ #if ARBORX_VERSION >= 10799
202+ template <typename Predicate, typename Geometry, typename OutputFunctor>
203+ KOKKOS_FUNCTION void
204+ operator ()( Predicate const & predicate,
205+ ArborX::PairValueIndex<Geometry, int > const & value_pair,
206+ OutputFunctor const & out ) const
207+ {
208+ int const primitive_index = value_pair.index ;
209+ int const predicate_index = getData ( predicate );
210+ if ( CollisionFilter<Tag>::keep ( predicate_index, primitive_index ) )
211+ {
212+ out ( primitive_index );
213+ }
214+ }
215+ #else
189216 template <typename Predicate, typename OutputFunctor>
190217 KOKKOS_FUNCTION void operator ()( Predicate const & predicate,
191218 int primitive_index,
@@ -197,13 +224,28 @@ struct NeighborDiscriminatorCallback
197224 out ( primitive_index );
198225 }
199226 }
227+ #endif
200228};
201229
202230// Count in the first pass
203231template <typename Counts, typename Tag>
204232struct NeighborDiscriminatorCallback2D_FirstPass
205233{
206234 Counts counts;
235+ #if ARBORX_VERSION >= 10799
236+ template <typename Predicate, typename Geometry>
237+ KOKKOS_FUNCTION void
238+ operator ()( Predicate const & predicate,
239+ ArborX::PairValueIndex<Geometry, int > const & value_pair ) const
240+ {
241+ int const primitive_index = value_pair.index ;
242+ int const predicate_index = getData ( predicate );
243+ if ( CollisionFilter<Tag>::keep ( predicate_index, primitive_index ) )
244+ {
245+ ++counts ( predicate_index ); // WARNING see below**
246+ }
247+ }
248+ #else
207249 template <typename Predicate>
208250 KOKKOS_FUNCTION void operator ()( Predicate const & predicate,
209251 int primitive_index ) const
@@ -214,6 +256,7 @@ struct NeighborDiscriminatorCallback2D_FirstPass
214256 ++counts ( predicate_index ); // WARNING see below**
215257 }
216258 }
259+ #endif
217260};
218261
219262// Preallocate and attempt fill in the first pass
@@ -222,6 +265,29 @@ struct NeighborDiscriminatorCallback2D_FirstPass_BufferOptimization
222265{
223266 Counts counts;
224267 Neighbors neighbors;
268+ #if ARBORX_VERSION >= 10799
269+ template <typename Predicate, typename Geometry>
270+ KOKKOS_FUNCTION void
271+ operator ()( Predicate const & predicate,
272+ ArborX::PairValueIndex<Geometry, int > const & value_pair ) const
273+ {
274+ int const primitive_index = value_pair.index ;
275+ int const predicate_index = getData ( predicate );
276+ auto & count = counts ( predicate_index );
277+ if ( CollisionFilter<Tag>::keep ( predicate_index, primitive_index ) )
278+ {
279+ if ( count < (int )neighbors.extent ( 1 ) )
280+ {
281+ neighbors ( predicate_index, count++ ) =
282+ primitive_index; // WARNING see below**
283+ }
284+ else
285+ {
286+ count++;
287+ }
288+ }
289+ }
290+ #else
225291 template <typename Predicate>
226292 KOKKOS_FUNCTION void operator ()( Predicate const & predicate,
227293 int primitive_index ) const
@@ -241,6 +307,7 @@ struct NeighborDiscriminatorCallback2D_FirstPass_BufferOptimization
241307 }
242308 }
243309 }
310+ #endif
244311};
245312
246313// Fill in the second pass
@@ -249,6 +316,23 @@ struct NeighborDiscriminatorCallback2D_SecondPass
249316{
250317 Counts counts;
251318 Neighbors neighbors;
319+ #if ARBORX_VERSION >= 10799
320+ template <typename Predicate, typename Geometry>
321+ KOKKOS_FUNCTION void
322+ operator ()( Predicate const & predicate,
323+ ArborX::PairValueIndex<Geometry, int > const & value_pair ) const
324+ {
325+ int const primitive_index = value_pair.index ;
326+ int const predicate_index = getData ( predicate );
327+ auto & count = counts ( predicate_index );
328+ if ( CollisionFilter<Tag>::keep ( predicate_index, primitive_index ) )
329+ {
330+ assert ( count < (int )neighbors.extent ( 1 ) );
331+ neighbors ( predicate_index, count++ ) =
332+ primitive_index; // WARNING see below**
333+ }
334+ }
335+ #else
252336 template <typename Predicate>
253337 KOKKOS_FUNCTION void operator ()( Predicate const & predicate,
254338 int primitive_index ) const
@@ -262,6 +346,7 @@ struct NeighborDiscriminatorCallback2D_SecondPass
262346 primitive_index; // WARNING see below**
263347 }
264348 }
349+ #endif
265350};
266351
267352// NOTE** Taking advantage of the knowledge that one predicate is processed by a
@@ -319,7 +404,12 @@ auto makeNeighborList( ExecutionSpace space, Tag, Positions const& positions,
319404
320405 using memory_space = typename Positions::memory_space;
321406
407+ #if ARBORX_VERSION >= 10799
408+ ArborX::BoundingVolumeHierarchy bvh (
409+ space, ArborX::Experimental::attach_indices<int >( positions ) );
410+ #else
322411 ArborX::BVH<memory_space> bvh ( space, positions );
412+ #endif
323413
324414 Kokkos::View<int *, memory_space> indices (
325415 Kokkos::view_alloc ( " indices" , Kokkos::WithoutInitializing ), 0 );
@@ -444,14 +534,23 @@ auto make2DNeighborList( ExecutionSpace space, Tag, Positions const& positions,
444534
445535 using memory_space = typename Positions::memory_space;
446536
537+ #if ARBORX_VERSION >= 10799
538+ ArborX::BoundingVolumeHierarchy bvh (
539+ space, ArborX::Experimental::attach_indices<int >( positions ) );
540+ #else
447541 ArborX::BVH<memory_space> bvh ( space, positions );
542+ #endif
448543
449544 auto const predicates =
450545 Impl::makePredicates ( positions, first, last, radius );
451546
452547 auto const n_queries =
453- ArborX::AccessTraits<std::remove_const_t <decltype ( predicates )>,
454- ArborX::PredicatesTag>::size ( predicates );
548+ ArborX::AccessTraits<std::remove_const_t <decltype ( predicates )>
549+ #if ARBORX_VERSION < 10799
550+ ,
551+ ArborX::PredicatesTag
552+ #endif
553+ >::size ( predicates );
455554
456555 Kokkos::View<int **, memory_space> neighbors;
457556 Kokkos::View<int *, memory_space> counts ( " counts" , n_queries );
0 commit comments