Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/mmg2d/enforcement_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int MMG2D_bdryenforcement(MMG5_pMesh mesh,MMG5_pSol sol) {
MMG5_int list[MMG5_TRIA_LMAX],list2[3];
MMG5_int k,l,kk,nex,kdep,lon,iel;
int iare,ied;
MMG5_int ia,ib,ilon,rnd,idep,*adja,ir,adj;
MMG5_int ia,ib,ilon,ii,idep,*adja,ir,adj;
int8_t i,i1,i2,j;
// int iadr2,*adja2,ndel,iadr,ped0,ped1;
static int8_t mmgWarn0=0,mmgWarn1=0,mmgWarn2=0,mmgWarn3=0;
Expand Down Expand Up @@ -183,23 +183,23 @@ int MMG2D_bdryenforcement(MMG5_pMesh mesh,MMG5_pSol sol) {

/* Randomly swap edges in the list, while... */
ilon = lon;
srand(time(NULL));
ii = 0;

while ( ilon > 0 ) {
rnd = ( rand() % lon );
k = list[rnd] / 3;
k = list[ii] / 3;

/* Check for triangle k in the pipe until one triangle with base+1 is met (indicating that it is
crossed by the considered edge) */
l = 0;
while ( l++ < lon ) {
pt = &mesh->tria[k];
if ( pt->base == mesh->base+1 ) break;
k = list[(++rnd)%lon] / 3;
ii = (ii+1)%lon;
k = list[ii] / 3;
}

assert ( l <= lon );
idep = list[rnd] % 3;
idep = list[ii] % 3;
// if(mesh->info.ddebug) printf("i= %" MMG5_PRId " < %" MMG5_PRId " ? on demarre avec %" MMG5_PRId "\n",i,lon+1,k);
adja = &mesh->adja[3*(k-1)+1];

Expand Down Expand Up @@ -248,7 +248,8 @@ int MMG2D_bdryenforcement(MMG5_pMesh mesh,MMG5_pSol sol) {
}
break;
}
}
ii = (ii+1)%lon;
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/mmg2d/locate_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,21 @@ int MMG2D_cutEdgeTriangle(MMG5_pMesh mesh,MMG5_int k,MMG5_int ia,MMG5_int ib) {
prod3 = area3*area1;

/* Both edges p2p3 and p1p3 corresponding to prod2 and prod3 are cut by edge ia,ib */
if ( prod1 > 0 && ((prod2 < 0 || prod3 < 0))) {
if ( prod1 > MMG2D_EPSD && ((prod2 < -MMG2D_EPSD || prod3 < -MMG2D_EPSD ))) {
if ( (iare = MMG2D_cutEdge(mesh,pt,ppa,ppb)) ) {
return iare;
}
}

/* Both edges corresponding to prod1 and prod3 are cut by edge ia,ib */
if ( prod2 > 0 && ((prod1 < 0 || prod3 < 0))) {
if ( prod2 > MMG2D_EPSD && ((prod1 < -MMG2D_EPSD || prod3 < -MMG2D_EPSD ))) {
if ( (iare = MMG2D_cutEdge(mesh,pt,ppa,ppb)) ) {
return iare;
}
}

/* Both edges corresponding to prod1 and prod2 are cut by edge ia,ib */
if ( prod3 > 0 && ((prod2 < 0 || prod1 < 0))) {
if ( prod3 > MMG2D_EPSD && ((prod2 < -MMG2D_EPSD || prod1 < -MMG2D_EPSD ))) {
if ( (iare = MMG2D_cutEdge(mesh,pt,ppa,ppb)) ) {
return iare;
}
Expand All @@ -191,7 +191,7 @@ int MMG2D_cutEdgeTriangle(MMG5_pMesh mesh,MMG5_int k,MMG5_int ia,MMG5_int ib) {
for(i=0; i<3; i++){
if ( pt->v[i] == ia || ibreak ) {
/* One vertex is ia, and the opposite edge is frankly crossed */
if ( (prod1 < 0) || (prod2 < 0) || (prod3 < 0) ) {
if ( (prod1 < -MMG2D_EPSD) || (prod2 < -MMG2D_EPSD) || (prod3 < -MMG2D_EPSD) ) {
if ( (iare = MMG2D_cutEdge(mesh,pt,ppa,ppb)) ) {
return iare;
}
Expand Down
5 changes: 5 additions & 0 deletions src/mmg2d/swapar_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ int MMG2D_swapdelone(MMG5_pMesh mesh,MMG5_pSol sol,MMG5_int k,int8_t i,double cr
arean2 = MMG2D_quickarea(mesh->point[pt0->v[0]].c,mesh->point[pt0->v[1]].c,mesh->point[pt0->v[2]].c);
if ( cal2 > crit ) return 0;

/* Avoid creation of a flat triangle*/
if (fabs(arean1) < MMG2D_EPSD || fabs(arean2) < MMG2D_EPSD) {
return 0;
}

if ( arean1 < 0.0 || arean2 < 0.0 || fabs((area1+area2)-(arean1+arean2)) > MMG2D_EPSD ) {
if(mesh->info.ddebug) printf(" ## Warning: non convex configuration\n");
return 0;
Expand Down