From fb79efbe0d6a15fb652b959cf2a33fb6b97c3c3c Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Mon, 18 Dec 2023 11:01:50 +0100 Subject: [PATCH] Split internal edges connecting bdy points (mmg3d lag). - Autorize the split of internal edges connecting boundary points in lagrangian option of mmg3d. - Fix the detection of boundary edges (that has lead to forbid the previous splits, see commit `73ae8fe7e`). Erroneous check was added by commit `5384387d7` under the erroneous assertion that boundary edges belonging to boundary faces are always marked as `MG_BDY`. It is not the case as at least pattern splitting are created regular boundary edges with no tags and as tetra without boundary faces may have edges along the boundary and either no xtetra, or a xtetra with a 0 tag for the edge or a xtetra whith suitable edge infos. --- src/mmg3d/colver_3d.c | 1 - src/mmg3d/libmmg3d_private.h | 1 + src/mmg3d/mmg3d3.c | 22 +++++++++++++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/mmg3d/colver_3d.c b/src/mmg3d/colver_3d.c index d4e53e73f..5400b4a72 100644 --- a/src/mmg3d/colver_3d.c +++ b/src/mmg3d/colver_3d.c @@ -428,7 +428,6 @@ int MMG3D_get_shellEdgeTag_oneDir(MMG5_pMesh mesh,MMG5_int start, MMG5_int na, * consistent through the edge shell); * */ -static inline int MMG3D_get_shellEdgeTag(MMG5_pMesh mesh,MMG5_int start, int8_t ia,int16_t *tag,MMG5_int *ref) { MMG5_pTetra pt; MMG5_pxTetra pxt; diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 5f46d2380..472f7ed89 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -260,6 +260,7 @@ void MMG3D_coquilFaceSecondLoopInit(MMG5_pMesh mesh,MMG5_int piv,int8_t *iface,i void MMG5_coquilFaceErrorMessage(MMG5_pMesh mesh, MMG5_int k1, MMG5_int k2); int16_t MMG5_coquilTravel(MMG5_pMesh,MMG5_int,MMG5_int,MMG5_int*,MMG5_int*,int8_t*,int8_t*); int16_t MMG5_openCoquilTravel(MMG5_pMesh,MMG5_int,MMG5_int,MMG5_int*,MMG5_int*,int8_t*,int8_t*); +int MMG3D_get_shellEdgeTag(MMG5_pMesh,MMG5_int,int8_t,int16_t*,MMG5_int *); int MMG5_settag(MMG5_pMesh,MMG5_int,int,int16_t,int); int MMG5_deltag(MMG5_pMesh,MMG5_int,int,int16_t); int MMG5_setNmTag(MMG5_pMesh mesh, MMG5_Hash *hash); diff --git a/src/mmg3d/mmg3d3.c b/src/mmg3d/mmg3d3.c index b07d4a56a..d92575362 100644 --- a/src/mmg3d/mmg3d3.c +++ b/src/mmg3d/mmg3d3.c @@ -136,11 +136,26 @@ static MMG5_int MMG5_spllag(MMG5_pMesh mesh,MMG5_pSol disp,MMG5_pSol met,int itd p1 = &mesh->point[ip2]; /* Skip the non-internal edges */ + + // Fast check but incomplete: regular boundary edges may have no tags (bdy + // tags are not added at new edges created during the split of boudary + // faces for example). if ( pxt && (pxt->tag[i] & MG_BDY) ) continue; + // Slower test but allowing to be sure to detect boundary edges + int16_t tag = 0; + MMG5_int ref = 0; + if ( !MMG3D_get_shellEdgeTag(mesh,k,MMG5_iarf[i][0],&tag,&ref) ) { + fprintf(stderr,"\n ## Warning: %s: 0. unable to get edge info" + " (tetra %d).\n",__func__,MMG3D_indElt(mesh,k)); + continue; + } - if( (p0->tag & MG_BDY) && (p1->tag & MG_BDY) ) continue; + if ( tag & MG_BDY ) { + continue; + } + /* Here we are sure to work on a non-boundary edge */ len = (p1->c[0]-p0->c[0])*(p1->c[0]-p0->c[0]) + (p1->c[1]-p0->c[1])*(p1->c[1]-p0->c[1]) + (p1->c[2]-p0->c[2])*(p1->c[2]-p0->c[2]); @@ -150,11 +165,12 @@ static MMG5_int MMG5_spllag(MMG5_pMesh mesh,MMG5_pSol disp,MMG5_pSol met,int itd imax = i; } } + if ( imax==-1 ) { if ( !mmgWarn0 ){ mmgWarn0 = 1; - fprintf(stderr,"\n ## Warning: %s: all edges of tetra %" MMG5_PRId " are required" - " or of length null.\n",__func__,k); + fprintf(stderr,"\n ## Warning: %s: No possible edge split in tetra %" MMG5_PRId + ".\n",__func__,MMG3D_indElt(mesh,k)); } continue; }