CompareNodes Class Reference

Public Member Functions

int operator() (Node *const &node1_pt, Node *const &node2_pt)
 Define the comparison operator using the round brackets. More...
 

Detailed Description

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// A class to do comparison of the nodes based on lexicographical ordering in the Cartesian coordinates. This is required to symmetrise eigenfunction (which is a bit of a hack)

Member Function Documentation

◆ operator()()

int CompareNodes::operator() ( Node *const &  node1_pt,
Node *const &  node2_pt 
)
inline

Define the comparison operator using the round brackets.

71  {
72  //Find the dimension of the node
73  unsigned n_dim = node1_pt->ndim();
74  //Check that the dimensions of both nodes are the same
75  {
76  unsigned n_dim2 = node2_pt->ndim();
77  //If not issue a warning
78  if(n_dim != n_dim2)
79  {
80  std::ostringstream warn_message;
81  warn_message
82  << "Warning: Two nodess do not have the same dimension"
83  << n_dim << " and " << n_dim2 << ". They cannot be compared\n";
84  OomphLibWarning(warn_message.str(),
85  "CompareNodes::()",
87  }
88  }
89 
90  //Get the global coordinates of the nodes
91  Vector<double> x1(n_dim), x2(n_dim);
92  for(unsigned i=0;i<n_dim;i++)
93  {
94  x1[i] = node1_pt->x(i);
95  x2[i] = node2_pt->x(i);
96  }
97 
98  //This is the Stroustrup-approved way to do lexicographical ordering
99  //Loop over the components until they are not equal
100  //to within a given tolerance
101  {
102  unsigned i=0; double tol = 1.0e-14;
103  while(i!=n_dim && (std::abs(x1[i]-x2[i]) < tol)){ ++i;}
104  //If we've reached the end, the coordinates are equal, return false
105  if(i==n_dim) {return 0;}
106  //Otherwise, return the ordering on the final component
107  return x1[i] < x2[i];
108  }
109  }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
int i
Definition: BiCGSTAB_step_by_step.cpp:9
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
Definition: oomph_definitions.h:267
Vector< double > x1(const Vector< double > &coord)
Cartesian coordinates centered at the point (0.5,1)
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:86
Vector< double > x2(const Vector< double > &coord)
Cartesian coordinates centered at the point (1.5,1)
Definition: poisson/poisson_with_singularity/two_d_poisson.cc:102
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61

References abs(), i, oomph::Node::ndim(), OOMPH_EXCEPTION_LOCATION, oomph::Node::x(), Global_parameters::x1(), and Global_parameters::x2().


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