Skip to content

Commit

Permalink
Use max radius between particle pairs to guarantee symmetry;
Browse files Browse the repository at this point in the history
update expected test value accordingly
  • Loading branch information
streeve committed Feb 28, 2025
1 parent 9c1f0d4 commit 350a041
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions core/src/Cabana_VerletList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,22 @@ struct VerletListBuilder
rsqr = neighborhood_radius * neighborhood_radius;
}

KOKKOS_INLINE_FUNCTION auto cutoff( [[maybe_unused]] const int p ) const
KOKKOS_INLINE_FUNCTION auto cutoff( [[maybe_unused]] const int i,
[[maybe_unused]] const int j ) const
{
// Square the radius on the fly if using a per-particle field to avoid a
// deep copy.
if constexpr ( is_slice<RadiusType>::value ||
Kokkos::is_view<RadiusType>::value )
return radius( p ) * radius( p );
// This value is already squared.
{
auto max_radius = Kokkos::max( radius( i ), radius( j ) );
return max_radius * max_radius;
}
else
{
// This value is already squared.
return rsqr;
}
}

// Neighbor count team operator (only used for CSR lists).
Expand Down Expand Up @@ -373,7 +379,7 @@ struct VerletListBuilder
PositionValueType dist_sqr = dx * dx + dy * dy + dz * dz;

// If within the cutoff add to the count.
if ( dist_sqr <= cutoff( pid ) )
if ( dist_sqr <= cutoff( pid, nid ) )
local_count += 1;
}
}
Expand Down Expand Up @@ -583,7 +589,7 @@ struct VerletListBuilder

// If within the cutoff increment the neighbor count and add as a
// neighbor at that index.
if ( dist_sqr <= cutoff( pid ) )
if ( dist_sqr <= cutoff( pid, nid ) )
{
_data.addNeighbor( pid, nid );
}
Expand Down
2 changes: 1 addition & 1 deletion core/unit_test/tstNeighborList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void testNonUniformRadius()
if ( p == 0 || p == test_data.num_particle - 1 )
EXPECT_EQ( list_copy.counts( p ), 6 );
else
EXPECT_EQ( list_copy.counts( p ), 3 );
EXPECT_EQ( list_copy.counts( p ), 4 );
}
}

Expand Down

0 comments on commit 350a041

Please sign in to comment.