Skip to content

Commit

Permalink
fixup: partial range total/max linked cell neighbors
Browse files Browse the repository at this point in the history
  • Loading branch information
streeve committed Oct 11, 2024
1 parent f7384bc commit e00db62
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions core/src/Cabana_LinkedCellList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,18 +761,29 @@ class NeighborList<LinkedCellList<MemorySpace, Scalar>>
//! Neighbor list type.
using list_type = LinkedCellList<MemorySpace, Scalar>;

//! Get the maximum number of neighbors per particle.
//! Get the total number of neighbors across all particles.
KOKKOS_INLINE_FUNCTION static std::size_t
totalNeighbor( const list_type& list )
{
return Impl::totalNeighbor( list, list.numParticles() );
std::size_t total_n = 0;
// Sum neighbors across all particles in range.
for ( std::size_t p = list.getParticleBegin();
p < list.getParticleEnd(); p++ )
total_n += numNeighbor( list, p );
return total_n;
}

//! Get the maximum number of neighbors across all particles.
//! Get the maximum number of neighbors per particles.
KOKKOS_INLINE_FUNCTION
static std::size_t maxNeighbor( const list_type& list )
{
return Impl::maxNeighbor( list, list.numParticles() );
std::size_t max_n = 0;
// Max neighbors across all particles in range.
for ( std::size_t p = list.getParticleBegin();
p < list.getParticleEnd(); p++ )
if ( numNeighbor( list, p ) > max_n )
max_n = numNeighbor( list, p );
return max_n;
}

//! Get the number of neighbors for a given particle index.
Expand Down

0 comments on commit e00db62

Please sign in to comment.