From 53cb64f48647412f021149997f0b9ad3994ce71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9lestin=20Marot?= <celestin.marot@uclouvain.be> Date: Thu, 18 Mar 2021 22:56:01 +0100 Subject: [PATCH] much faster work-around --- contrib/hxt/tetMesh/src/hxt_tetDelaunay.c | 33 ++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/contrib/hxt/tetMesh/src/hxt_tetDelaunay.c b/contrib/hxt/tetMesh/src/hxt_tetDelaunay.c index ebd561dceb..9bfab36e69 100644 --- a/contrib/hxt/tetMesh/src/hxt_tetDelaunay.c +++ b/contrib/hxt/tetMesh/src/hxt_tetDelaunay.c @@ -517,6 +517,8 @@ static inline HXTStatus walking2Cavity(HXTMesh* mesh, HXTPartition* partition, u // we should pass in orient3d mode here :p unsigned index = 4; + unsigned outside = 0; + unsigned wantToGoInOtherPartition = 0; unsigned randomU = hxtReproducibleLCG(&seed); for (unsigned j=0; j<4; j++) { @@ -534,6 +536,7 @@ static inline HXTStatus walking2Cavity(HXTMesh* mesh, HXTPartition* partition, u // vtaCoord[0], vtaCoord[1], vtaCoord[2]); // } + outside = 1; uint32_t node = mesh->tetrahedra.node[curNeigh[i]]; if(node==HXT_GHOST_VERTEX) { @@ -541,11 +544,14 @@ static inline HXTStatus walking2Cavity(HXTMesh* mesh, HXTPartition* partition, u return HXT_STATUS_OK; } - if(vertexOutOfPartition(vertices, node, rel, partition->startDist)) - return HXT_STATUS_CONFLICT; - - index=i; - break; + if(vertexOutOfPartition(vertices, node, rel, partition->startDist)){ + if(wantToGoInOtherPartition++ > 1000) + return HXT_STATUS_CONFLICT; + } + else { + index=i; + break; + } } } } @@ -555,10 +561,13 @@ static inline HXTStatus walking2Cavity(HXTMesh* mesh, HXTPartition* partition, u const double* __restrict__ b = vertices[curNode[1]].coord; const double* __restrict__ c = vertices[curNode[2]].coord; const double* __restrict__ d = vertices[curNode[3]].coord; - if( (orient3d(a,b,c,vtaCoord)>=0) + - (orient3d(a,b,vtaCoord,d)>=0) + - (orient3d(a,vtaCoord,c,d)>=0) + - (orient3d(vtaCoord,b,c,d)>=0)>2 ){ + if(outside) { + return HXT_STATUS_CONFLICT; + } + else if( (orient3d(a,b,c,vtaCoord)>=0) + + (orient3d(a,b,vtaCoord,d)>=0) + + (orient3d(a,vtaCoord,c,d)>=0) + + (orient3d(vtaCoord,b,c,d)>=0)>2 ){ *curTet = nextTet; return HXT_STATUS_DOUBLE_PT; } @@ -566,12 +575,6 @@ static inline HXTStatus walking2Cavity(HXTMesh* mesh, HXTPartition* partition, u return HXT_STATUS_OK; } -#ifdef DEBUG - nstep++; - if(nstep > mesh->tetrahedra.num) - return HXT_ERROR_MSG(HXT_STATUS_ERROR, "walk stuck in an infinite loop"); -#endif - enteringFace = curNeigh[index]&3; nextTet = curNeigh[index]/4; } -- GitLab