From b2da9223d2c35aa9f038480c692108d7cfecf5e3 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Fri, 5 Jul 2024 10:31:33 +0200 Subject: [PATCH 1/5] in function MMG5_bdrySet, remove face tags that make no sense --- src/mmg3d/hash_3d.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/mmg3d/hash_3d.c b/src/mmg3d/hash_3d.c index 50fa9080f..9792ff88f 100644 --- a/src/mmg3d/hash_3d.c +++ b/src/mmg3d/hash_3d.c @@ -2014,7 +2014,17 @@ int MMG5_bdrySet(MMG5_pMesh mesh) { pxt = &mesh->xtetra[pt->xt]; pxt->ref[i] = ptt->ref; pxt->ftag[i] |= MG_BDY; - pxt->ftag[i] |= (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); + + /* Store tags that are common to the 3 edges of the triangles */ + tag = (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); + + /* Remove infos that make no sense along faces */ + tag &= ~MG_GEO; + tag &= ~MG_NOM; + assert( !(tag & MG_CRN) && "MG_CRN tag has no sense along edges" ); + + /* Assign tag to the face */ + pxt->ftag[i] |= tag; } } } @@ -2047,7 +2057,17 @@ int MMG5_bdrySet(MMG5_pMesh mesh) { pxt = &mesh->xtetra[mesh->xt]; pxt->ref[i] = ptt->ref; pxt->ftag[i] |= MG_BDY; - pxt->ftag[i] |= (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); + + /* Store tags that are common to the 3 edges of the triangles */ + tag = (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); + + /* Remove infos that make no sense along faces */ + tag &= ~MG_GEO; + tag &= ~MG_NOM; + assert( !(tag & MG_CRN) && "MG_CRN tag has no sense along edges" ); + + /* Assign tag to the face */ + pxt->ftag[i] |= tag; } } } From ff4c6da492953bcf1e22151bcab9dec662c9bc2a Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Fri, 5 Jul 2024 11:48:42 +0200 Subject: [PATCH 2/5] Added function MMG3D_chkfacetags --- src/mmg3d/analys_3d.c | 4 ++++ src/mmg3d/chkmsh_3d.c | 28 ++++++++++++++++++++++++++++ src/mmg3d/libmmg3d_private.h | 1 + 3 files changed, 33 insertions(+) diff --git a/src/mmg3d/analys_3d.c b/src/mmg3d/analys_3d.c index f3078e6c9..f0a2d5ce7 100644 --- a/src/mmg3d/analys_3d.c +++ b/src/mmg3d/analys_3d.c @@ -1471,6 +1471,10 @@ int MMG3D_analys(MMG5_pMesh mesh) { /* define geometry for non manifold points */ if ( !MMG3D_nmgeom(mesh) ) return 0; +#ifndef NDEBUG + MMG3D_chkfacetags(mesh); +#endif + #ifdef USE_POINTMAP /* Initialize source point with input index */ MMG5_int ip; diff --git a/src/mmg3d/chkmsh_3d.c b/src/mmg3d/chkmsh_3d.c index c6c05e39e..544148e6d 100644 --- a/src/mmg3d/chkmsh_3d.c +++ b/src/mmg3d/chkmsh_3d.c @@ -305,6 +305,31 @@ void MMG3D_chkedgetag(MMG5_pMesh mesh, MMG5_int ip1, MMG5_int ip2, int tag) { } } +/** + * \param mesh pointer to the mesh + * + * Check that faces do not have nonsensical tags (MG_GEO, MG_NOM, MG_CRN). + * + */ +void MMG3D_chkfacetags(MMG5_pMesh mesh) { + MMG5_pTetra pt; + MMG5_pxTetra pxt; + MMG5_int k; + int i, tag; + + for (k=1; k<=mesh->ne; k++) { + pt = &mesh->tetra[k]; + if ( !MG_EOK(pt) ) continue; + if ( !pt->xt ) continue; + + pxt = &mesh->xtetra[pt->xt]; + for (i=0; i<4; i++) { + tag = pxt->ftag[i]; + assert(!(tag & (MG_GEO & MG_NOM & MG_CRN)) && "Nonsensical tag on face"); + } + } +} + /** * \param mesh pointer to the mesh * \param ppt pointer to unconsistent point @@ -483,6 +508,9 @@ int MMG5_mmg3dChkmsh(MMG5_pMesh mesh,int severe,MMG5_int base) { /* Check edge tag consistency (between xtetra) */ MMG3D_chkmeshedgestags(mesh); + /* Check that faces do not have nonsensical tags*/ + MMG3D_chkfacetags(mesh); + /* Check point tags consistency with edge tag */ MMG3D_chkpointtag(mesh); diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 6b841411f..ce8a64993 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -466,6 +466,7 @@ MMG5_int MMG3D_indPt(MMG5_pMesh mesh,MMG5_int kp); void MMG5_printTetra(MMG5_pMesh mesh,char* fileName); void MMG3D_chkpointtag(MMG5_pMesh mesh); void MMG3D_chkmeshedgestags(MMG5_pMesh mesh); +void MMG3D_chkfacetags(MMG5_pMesh mesh); int MMG3D_chk_shellEdgeTag(MMG5_pMesh mesh,MMG5_int start, int8_t ia,int16_t tag,MMG5_int ref); #ifdef USE_SCOTCH From cf8450c7aa6a746d90c12a029efc04830c31ed50 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Fri, 5 Jul 2024 15:35:28 +0200 Subject: [PATCH 3/5] in function MMG5_bdrySet, modified treatment of face tags for prisms --- src/mmg3d/hash_3d.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mmg3d/hash_3d.c b/src/mmg3d/hash_3d.c index 9792ff88f..41497c696 100644 --- a/src/mmg3d/hash_3d.c +++ b/src/mmg3d/hash_3d.c @@ -2228,7 +2228,17 @@ int MMG5_bdrySet(MMG5_pMesh mesh) { pxp = &mesh->xprism[mesh->xpr]; pxp->ref[i] = ptt->ref; pxp->ftag[i] |= MG_BDY; - pxp->ftag[i] |= (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); + + /* Store tags that are common to the 3 edges of the triangles */ + tag = (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); + + /* Remove infos that make no sense along faces */ + tag &= ~MG_GEO; + tag &= ~MG_NOM; + assert( !(tag & MG_CRN) && "MG_CRN tag has no sense along edges" ); + + /* Assign tag to the face */ + pxp->ftag[i] |= tag; for (j=0; j<3; j++) { pxp->tag[MMG5_iarf[i][j]] |= pxp->ftag[i] | ptt->tag[j]; From 2042d9dc69c3c5558176d279cac7352854503203 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Fri, 5 Jul 2024 15:49:43 +0200 Subject: [PATCH 4/5] Added some comments --- src/mmg3d/hash_3d.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mmg3d/hash_3d.c b/src/mmg3d/hash_3d.c index 41497c696..60f081148 100644 --- a/src/mmg3d/hash_3d.c +++ b/src/mmg3d/hash_3d.c @@ -2058,6 +2058,8 @@ int MMG5_bdrySet(MMG5_pMesh mesh) { pxt->ref[i] = ptt->ref; pxt->ftag[i] |= MG_BDY; + /* here we may wrongfully add MG_REF and/or MG_BDY face tags to internal triangles + in opnbdy mode */ /* Store tags that are common to the 3 edges of the triangles */ tag = (ptt->tag[0] & ptt->tag[1] & ptt->tag[2]); From 7de7e10e9d3f278ac99008f3a1929d7fc3f3474e Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Mon, 22 Jul 2024 12:01:25 +0200 Subject: [PATCH 5/5] Modified wrong assert --- src/mmg3d/chkmsh_3d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mmg3d/chkmsh_3d.c b/src/mmg3d/chkmsh_3d.c index 544148e6d..845cd6310 100644 --- a/src/mmg3d/chkmsh_3d.c +++ b/src/mmg3d/chkmsh_3d.c @@ -325,7 +325,7 @@ void MMG3D_chkfacetags(MMG5_pMesh mesh) { pxt = &mesh->xtetra[pt->xt]; for (i=0; i<4; i++) { tag = pxt->ftag[i]; - assert(!(tag & (MG_GEO & MG_NOM & MG_CRN)) && "Nonsensical tag on face"); + assert(!(tag & (MG_GEO | MG_NOM | MG_CRN)) && "Nonsensical tag on face"); } } }