Skip to content

Commit

Permalink
use relative distances for coincidence test in hex lattice
Browse files Browse the repository at this point in the history
  • Loading branch information
gridley committed Nov 19, 2019
1 parent 50a271b commit 3379e67
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lattice.cpp
Expand Up @@ -895,8 +895,12 @@ HexLattice::get_indices(Position r, Direction u) const
Position r_t = get_local_position(r, i_xyz);
// calculate distance
double d = r_t.x*r_t.x + r_t.y*r_t.y;
// check for coincidence
bool on_boundary = coincident(d, d_min);
// check for coincidence. Because the numerical error incurred
// in hex geometry is higher than other geometries, the relative
// coincidence is checked here so that coincidence is successfully
// detected on large hex lattice with particles far from the origin
// which have rounding errors larger than the FP_COINCIDENT thresdhold.
bool on_boundary = coincident(1.0, d_min/d);
if (d < d_min || on_boundary) {
// normalize r_t and find dot product
r_t /= std::sqrt(d);
Expand Down

0 comments on commit 3379e67

Please sign in to comment.