[cig-commits] r4087 - in long/3D/Gale/trunk/src/StGermain: .
Discretisation/Mesh/src
walter at geodynamics.org
walter at geodynamics.org
Thu Jul 20 20:13:26 PDT 2006
Author: walter
Date: 2006-07-20 20:13:26 -0700 (Thu, 20 Jul 2006)
New Revision: 4087
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c
Log:
r2551 at earth: boo | 2006-07-20 20:01:51 -0700
r2527 at earth (orig r3696): LukeHodkinson | 2006-07-19 19:57:49 -0700
The method used to speed up locating a
particle's containing element fails under certain topological
situations. Included a fall-back to use the brute force
method when this happens which, fortunately, is rarely.
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2550
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3695
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2551
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3696
Modified: long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c 2006-07-21 03:12:59 UTC (rev 4086)
+++ long/3D/Gale/trunk/src/StGermain/Discretisation/Mesh/src/MeshClass.c 2006-07-21 03:13:26 UTC (rev 4087)
@@ -1627,6 +1627,8 @@
Coord* nodeCrds = self->nodeCoord;
unsigned curNode;
unsigned nDims = self->nSpaceDims;
+ double dist, tmp;
+ unsigned d_i;
/* Must have neighbours enabled. */
assert( self->buildNodeNeighbourTbl && self->nodeNeighbourTbl );
@@ -1634,25 +1636,23 @@
/* Begin somewhere in the middle. */
curNode = self->nodeLocalCount / 2;
+ /* Calc distance squared to current node. */
+ tmp = nodeCrds[curNode][0] - crd[0];
+ dist = tmp * tmp;
+ for( d_i = 1; d_i < nDims; d_i++ ) {
+ tmp = nodeCrds[curNode][d_i] - crd[d_i];
+ dist += tmp * tmp;
+ }
+
/* Loop until we've found closest local node. */
do {
unsigned nNbrs = self->nodeNeighbourCountTbl[curNode];
unsigned* nbrs = self->nodeNeighbourTbl[curNode];
- double dist;
- double tmp;
- unsigned nbr_i, d_i;
+ unsigned nbr_i;
/* Assume we'll be done after this loop. */
done = True;
- /* Calc distance squared to current node. */
- tmp = nodeCrds[curNode][0] - crd[0];
- dist = tmp * tmp;
- for( d_i = 1; d_i < nDims; d_i++ ) {
- tmp = nodeCrds[curNode][d_i] - crd[d_i];
- dist += tmp * tmp;
- }
-
/* Compare to neighbours. */
for( nbr_i = 0; nbr_i < nNbrs; nbr_i++ ) {
double nbrDist;
@@ -1719,11 +1719,16 @@
return eLyt->elementWithPoint( eLyt, self->layout->decomp, pnt, bndStat, 0, NULL );
else if( self->nodeNeighbourTbl ) {
unsigned closeNode;
+ unsigned elInd;
/* If node neighbour table is built, use it to speed things up. */
closeNode = Mesh_ClosestNode( self, pnt );
- return eLyt->elementWithPoint( eLyt, self->layout->decomp, pnt, bndStat,
- self->nodeElementCountTbl[closeNode], self->nodeElementTbl[closeNode] );
+ elInd = eLyt->elementWithPoint( eLyt, self->layout->decomp, pnt, bndStat,
+ self->nodeElementCountTbl[closeNode], self->nodeElementTbl[closeNode] );
+ if( elInd >= self->elementLocalCount )
+ elInd = eLyt->elementWithPoint( eLyt, self->layout->decomp, pnt, bndStat, 0, NULL );
+
+ return elInd;
}
else
return eLyt->elementWithPoint( eLyt, self->layout->decomp, pnt, bndStat, 0, NULL );
More information about the cig-commits
mailing list