[cig-commits] r5983 - in long/3D/Gale/trunk: . src/StGermain/Discretisation/Mesh/src

walter at geodynamics.org walter at geodynamics.org
Thu Feb 8 09:28:18 PST 2007


Author: walter
Date: 2007-02-08 09:28:17 -0800 (Thu, 08 Feb 2007)
New Revision: 5983

Modified:
   long/3D/Gale/trunk/
   long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c
Log:
 r1532 at earth:  boo | 2007-02-07 21:41:48 -0800
 Add in a tolerance when comparing two numbers, because if one is in the register, and the other is not, then we can get a spurious comparison



Property changes on: long/3D/Gale/trunk
___________________________________________________________________
Name: svk:merge
   - 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1530
   + 3a629746-de10-0410-b17b-fd6ecaaa963e:/cig:1532

Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c	2007-02-08 05:29:55 UTC (rev 5982)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/Mesh_Algorithms.c	2007-02-08 17:28:17 UTC (rev 5983)
@@ -406,7 +406,12 @@
 	unsigned*		nbrs;
 	double			nbrSep;
 	unsigned		nbr_i;
+        /* Factor is a number close to one to represent how close two
+           doubles have to be to each other in order to be "equal". */
+        double                  factor;
 
+        factor=1.0+1e-10;
+
 	assert( self );
 	assert( self->mesh );
 	assert( Mesh_HasIncidence( self->mesh, MT_VERTEX, MT_VERTEX ) );
@@ -432,15 +437,17 @@
 
 		/* Compare to neighbours. */
 		for( nbr_i = 0; nbr_i < nNbrs; nbr_i++ ) {
-			/* Calculate neighbour separation. */
-			nbrSep = Vec_Sep( nDims, Mesh_GetVertex( mesh, nbrs[nbr_i] ), point );
-
-			/* Closer? */
-			if( nbrSep < sep ) {
-				curVert = nbrs[nbr_i];
-				sep = nbrSep;
-				done = False;
-			}
+                  /* Calculate neighbour separation. */
+                  nbrSep = Vec_Sep( nDims, Mesh_GetVertex( mesh, nbrs[nbr_i] ), point );
+                      /* Closer?
+                         We multiply by "factor" because if two points
+                         are equidistant, then whether one value is in
+                         a register will determine which one is closer. */
+                      if( nbrSep*factor < sep ) {
+                        curVert = nbrs[nbr_i];
+                        sep = nbrSep;
+                        done = False;
+                      }
 		}
 	}
 	while( !done );



More information about the cig-commits mailing list