Skip to content

Commit

Permalink
Implements getNeighbor algorithm for linkedCellLists (needs testing)
Browse files Browse the repository at this point in the history
  • Loading branch information
lebuller committed Nov 9, 2023
1 parent 6afc76e commit f79b4cf
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions core/src/Cabana_LinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,36 @@ class NeighborList<LinkedCellList<DeviceType, Scalar>>

//! Get the id for a neighbor for a given particle index and the index of
//! the neighbor relative to the particle.
KOKKOS_INLINE_FUNCTION
static std::size_t getNeighbor( const list_type& list, const std::size_t,
const std::size_t neighbor_index,
const bool sorted = true )
template <class CellIndexType>
KOKKOS_INLINE_FUNCTION static std::size_t
getNeighbor( const list_type& list, const CellIndexType cell,
const std::size_t particle_index,
const std::size_t neighbor_index, const bool sorted = true )
{
if ( sorted )
return neighbor_index;
else
return list.permutation( neighbor_index );
int total_count = 0;
int previous_count = 0;
int imin, imax, jmin, jmax, kmin, kmax;
list.getStencilCells( cell( particle_index ), imin, imax, jmin, jmax,
kmin, kmax );

// Loop over the cell stencil.
for ( int i = imin; i < imax; ++i )
for ( int j = jmin; j < jmax; ++j )
for ( int k = kmin; k < kmax; ++k )
{
total_count += list.binSize( i, j, k );
if ( total_count > neighbor_index )
{
int particle_id = list.binOffset( i, j, k ) +
( neighbor_index - previous_count );
if ( sorted )
return particle_id;
else
return list.permutation( particle_id );
break;
}
previous_count = total_count;
}
}
};

Expand Down

0 comments on commit f79b4cf

Please sign in to comment.