Skip to content

Commit

Permalink
Extracted triangle deletion phase outside of triangle flagging loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Prigent committed Apr 16, 2024
1 parent c0d254d commit 9c45b08
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
32 changes: 24 additions & 8 deletions src/mmg3d/hash_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,9 +1556,11 @@ int MMG5_chkBdryTria(MMG5_pMesh mesh) {
* user */
if ( mesh->nt ) {
ier = MMG5_chkBdryTria_hashBoundaries(mesh,ntmesh,&hashElt);
// Travel through the tria, delete those that are not in the hash tab or
// Travel through the tria, flag those that are not in the hash tab or
// that are stored more that once.
ier = MMG5_chkBdryTria_deleteExtraBoundaries(mesh,&ntpres,&hashElt);
ier = MMG5_chkBdryTria_flagExtraTriangles(mesh,&ntpres,&hashElt);
// Delete flagged triangles
ier = MMG5_chkBdryTria_deleteExtraTriangles(mesh);
}
ntmesh +=ntpres;

Expand Down Expand Up @@ -1796,16 +1798,14 @@ int MMG5_chkBdryTria_hashBoundaries(MMG5_pMesh mesh, MMG5_int ntmesh, MMG5_Hash
* that are stored more that once.
*
*/
int MMG5_chkBdryTria_deleteExtraBoundaries(MMG5_pMesh mesh, MMG5_int* ntpres, MMG5_Hash *hashElt) {
int MMG5_chkBdryTria_flagExtraTriangles(MMG5_pMesh mesh, MMG5_int* ntpres, MMG5_Hash *hashElt) {

MMG5_pTria ptt, pttnew;
MMG5_Hash hashTri;
MMG5_int nt, nbl, k, kk, i, j;
MMG5_int k, kk, i, j;
MMG5_int ia, ib, ic, adj;
int iface;

nt=0; nbl=1;

if ( ! MMG5_hashNew(mesh,&hashTri,0.51*mesh->nt,1.51*mesh->nt) ) return 0;

for (k=1; k<=mesh->nt; k++) {
Expand All @@ -1827,13 +1827,15 @@ int MMG5_chkBdryTria_deleteExtraBoundaries(MMG5_pMesh mesh, MMG5_int* ntpres, MM
}
else if ( j > 0 ) {
/* the face already exists in the tria table */
ptt->v[0] = 0;
continue;

Check warning on line 1831 in src/mmg3d/hash_3d.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/hash_3d.c#L1830-L1831

Added lines #L1830 - L1831 were not covered by tests
}

if ( !i ) {
/* the triangle is not a boundary tri or a tri at the interface of two
* subdomains with different references and the user don't ask to keep
* it. */
ptt->v[0] = 0;
continue;
}

Expand All @@ -1847,6 +1849,22 @@ int MMG5_chkBdryTria_deleteExtraBoundaries(MMG5_pMesh mesh, MMG5_int* ntpres, MM
++(*ntpres);
}
}
}
MMG5_DEL_MEM(mesh,hashElt->item);
MMG5_DEL_MEM(mesh,hashTri.item);
return 1;
}

int MMG5_chkBdryTria_deleteExtraTriangles(MMG5_pMesh mesh) {

MMG5_pTria ptt, pttnew;
MMG5_int nt, nbl, k;

nt = 0; nbl = 1;
for (k=1; k<=mesh->nt; k++) {
ptt = &mesh->tria[k];

if ( !MG_EOK(ptt) ) continue;

++nt;
if ( k!=nbl ) {
Expand All @@ -1863,8 +1881,6 @@ int MMG5_chkBdryTria_deleteExtraBoundaries(MMG5_pMesh mesh, MMG5_int* ntpres, MM
MMG5_SAFE_REALLOC(mesh->tria,mesh->nt+1,nt+1,MMG5_Tria,"triangles",return 0);

Check warning on line 1881 in src/mmg3d/hash_3d.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/hash_3d.c#L1880-L1881

Added lines #L1880 - L1881 were not covered by tests
mesh->nt = nt;
}
MMG5_DEL_MEM(mesh,hashElt->item);
MMG5_DEL_MEM(mesh,hashTri.item);
return 1;
}

Expand Down
3 changes: 2 additions & 1 deletion src/mmg3d/libmmg3d_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,9 @@ void MMG3D_Free_topoTables(MMG5_pMesh mesh);
int MMG5_chkBdryTria(MMG5_pMesh mesh);
int MMG5_chkBdryTria_countBoundaries(MMG5_pMesh mesh, MMG5_int *ntmesh, MMG5_int *ntpres);
int MMG5_chkBdryTria_hashBoundaries(MMG5_pMesh mesh, MMG5_int ntmesh, MMG5_Hash *hashElt);
int MMG5_chkBdryTria_deleteExtraBoundaries(MMG5_pMesh mesh, MMG5_int* ntpres, MMG5_Hash* hashElt);
int MMG5_chkBdryTria_flagExtraTriangles(MMG5_pMesh mesh, MMG5_int* ntpres, MMG5_Hash* hashElt);
int MMG5_chkBdryTria_addMissingTriangles(MMG5_pMesh mesh, MMG5_int ntmesh, MMG5_int ntpres);
int MMG5_chkBdryTria_deleteExtraTriangles(MMG5_pMesh mesh);
int MMG5_mmg3dBezierCP(MMG5_pMesh mesh,MMG5_Tria *pt,MMG5_pBezier pb,int8_t ori);
extern int MMG5_BezierTgt(double c1[3],double c2[3],double n1[3],double n2[3],double t1[3],double t2[3]);
extern double MMG5_BezierGeod(double c1[3], double c2[3], double t1[3], double t2[3]);
Expand Down

0 comments on commit 9c45b08

Please sign in to comment.