LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare Class Reference

Public Member Functions

 FuzzyPointCompare (Real tol)
 
bool operator() (const Point &lhs, const Point &rhs)
 
bool operator() (const std::pair< Point, dof_id_type > &lhs, const std::pair< Point, dof_id_type > &rhs)
 
bool operator() (const Point &lhs, std::pair< Point, dof_id_type > &rhs)
 
bool operator() (std::pair< Point, dof_id_type > &lhs, const Point &rhs)
 

Private Attributes

Real _tol
 

Detailed Description

Definition at line 41 of file replicated_mesh.C.

Constructor & Destructor Documentation

LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare::FuzzyPointCompare ( Real  tol)
inline

Definition at line 48 of file replicated_mesh.C.

Member Function Documentation

bool LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare::operator() ( const Point lhs,
const Point rhs 
)
inline

Definition at line 51 of file replicated_mesh.C.

References std::abs(), std::max(), and libMesh::Real.

52  {
53  for (unsigned i=0; i<LIBMESH_DIM; ++i)
54  {
55  // If the current components are within some tolerance
56  // of one another, then don't attempt the less-than comparison.
57  // Note that this may cause something strange to happen, as Roy
58  // believes he can prove it is not a total ordering...
59  Real rel_size = std::max(std::abs(lhs(i)), std::abs(rhs(i)));
60 
61  // Don't use relative tolerance if both numbers are already small.
62  // How small? Some possible options are:
63  // * std::numeric_limits<Real>::epsilon()
64  // * TOLERANCE
65  // * 1.0
66  // If we use std::numeric_limits<Real>::epsilon(), we'll
67  // do more relative comparisons for small numbers, but
68  // increase the chance for false positives? If we pick 1.0,
69  // we'll never "increase" the difference between small numbers
70  // in the test below.
71  if (rel_size < 1.)
72  rel_size = 1.;
73 
74  // Don't attempt the comparison if lhs(i) and rhs(i) are too close
75  // together.
76  if ( std::abs(lhs(i) - rhs(i)) / rel_size < _tol)
77  continue;
78 
79  if (lhs(i) < rhs(i))
80  return true;
81  if (lhs(i) > rhs(i))
82  return false;
83  }
84 
85  // We compared all the components without returning yet, so
86  // each component was neither greater than nor less than they other.
87  // They might be equal, so return false.
88  return false;
89  }
double abs(double a)
long double max(long double a, double b)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare::operator() ( const std::pair< Point, dof_id_type > &  lhs,
const std::pair< Point, dof_id_type > &  rhs 
)
inline

Definition at line 92 of file replicated_mesh.C.

94  {
95  return (*this)(lhs.first, rhs.first);
96  }
bool LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare::operator() ( const Point lhs,
std::pair< Point, dof_id_type > &  rhs 
)
inline

Definition at line 101 of file replicated_mesh.C.

102  {
103  return (*this)(lhs, rhs.first);
104  }
bool LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare::operator() ( std::pair< Point, dof_id_type > &  lhs,
const Point rhs 
)
inline

Definition at line 107 of file replicated_mesh.C.

108  {
109  return (*this)(lhs.first, rhs);
110  }

Member Data Documentation

Real LIBMESH_DEFINE_HASH_POINTERS::FuzzyPointCompare::_tol
private

Definition at line 44 of file replicated_mesh.C.


The documentation for this class was generated from the following file: