From f384c2206fe4a3c47b96254ad0333df978464108 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Fri, 4 Aug 2023 14:26:54 +0200 Subject: [PATCH 01/19] Add hash function to update and get hash.item[].s - used in parmmg to update communicator --- src/common/hash.c | 66 ++++++++++++++++++++++++++++++++++ src/common/libmmgtypes.h | 2 +- src/common/mmgcommon_private.h | 2 ++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/src/common/hash.c b/src/common/hash.c index 02ea1a229..f79607347 100644 --- a/src/common/hash.c +++ b/src/common/hash.c @@ -424,6 +424,42 @@ int MMG5_hashUpdate(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { return 0; } +/** + * \param mesh pointer toward the mesh structure. + * \param hash pointer toward the hash table of edges. + * \param a index of the first extremity of the edge. + * \param b index of the second extremity of the edge. + * \param k new index of point along the edge. + * \return 1 if success, 0 if fail (edge is not found). + * + * Update the index of the point stored along the edge \f$[a;b]\f$ + * + */ +int MMG5_hashUpdate_s(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { + MMG5_hedge *ph; + MMG5_int key; + MMG5_int ia,ib; + + ia = MG_MIN(a,b); + ib = MG_MAX(a,b); + key = (MMG5_KA*(int64_t)ia + MMG5_KB*(int64_t)ib) % hash->siz; + ph = &hash->item[key]; + + while ( ph->a ) { + if ( ph->a == ia && ph->b == ib ) { + ph->s = k; + return 1; + } + + if ( !ph->nxt ) return 0; + + ph = &hash->item[ph->nxt]; + + } + + return 0; +} + /** * \param mesh pointer toward the mesh structure. * \param hash pointer toward the hash table of edges. @@ -515,6 +551,36 @@ MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { return 0; } +/** + * \param hash pointer toward the hash table of edges. + * \param a index of the first extremity of the edge. + * \param b index of the second extremity of the edge. + * \return the index of point stored along \f$[a;b]\f$. + * + * Find the index of point stored along \f$[a;b]\f$. + * + */ +int MMG5_hashGet_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { + MMG5_hedge *ph; + MMG5_int key; + MMG5_int ia,ib; + + if ( !hash->item ) return 0; + + ia = MG_MIN(a,b); + ib = MG_MAX(a,b); + key = (MMG5_KA*(int64_t)ia + MMG5_KB*(int64_t)ib) % hash->siz; + ph = &hash->item[key]; + + if ( !ph->a ) return 0; + if ( ph->a == ia && ph->b == ib ) return ph->s; + while ( ph->nxt ) { + ph = &hash->item[ph->nxt]; + if ( ph->a == ia && ph->b == ib ) return ph->s; + } + return 0; +} + /** * \param mesh pointer toward the mesh structure. * \param hash pointer toward the hash table of edges. diff --git a/src/common/libmmgtypes.h b/src/common/libmmgtypes.h index e1084add1..f0f194dcb 100644 --- a/src/common/libmmgtypes.h +++ b/src/common/libmmgtypes.h @@ -335,7 +335,7 @@ typedef struct { MMG5_int ref; /*!< Reference of the triangle */ MMG5_int base; MMG5_int cc; /*!< used to store the tetra + tetra face indices - that allow to access to the tria */ + that allow to access to the tria 4*k + i */ MMG5_int edg[3]; /*!< edg[i] contains the ref of the \f$i^{th}\f$ edge of triangle */ MMG5_int flag; diff --git a/src/common/mmgcommon_private.h b/src/common/mmgcommon_private.h index 1e139dbac..ee5cf8a0e 100644 --- a/src/common/mmgcommon_private.h +++ b/src/common/mmgcommon_private.h @@ -676,8 +676,10 @@ typedef struct MMG5_iNode_s { MMG5_int MMG5_hashFace(MMG5_pMesh,MMG5_Hash*,MMG5_int,MMG5_int,MMG5_int,MMG5_int); int MMG5_hashEdge(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); int MMG5_hashUpdate(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); + int MMG5_hashUpdate_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,int16_t k); MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b); + MMG5_int MMG5_hashGet_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b); int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash,MMG5_int hsiz,MMG5_int hmax); int MMG5_intmetsavedir(MMG5_pMesh mesh, double *m,double *n,double *mr); int MMG5_intridmet(MMG5_pMesh,MMG5_pSol,MMG5_int,MMG5_int,double,double*,double*); From 241a629926adca8d5a134f9f1c1e24a5372ebad5 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Fri, 4 Aug 2023 14:27:34 +0200 Subject: [PATCH 02/19] Add split using global vertex indices - for parmmg convenience --- src/mmg3d/libmmg3d_private.h | 4 + src/mmg3d/split_3d.c | 1228 ++++++++++++++++++++++++++++++---- 2 files changed, 1120 insertions(+), 112 deletions(-) diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 4577a0da2..d469bf5a6 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -315,22 +315,26 @@ int MMG3D_setMeshSize_initData(MMG5_pMesh,MMG5_int,MMG5_int,MMG5_int,MMG5_int,M int MMG3D_setMeshSize_alloc(MMG5_pMesh); int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp); +int MMG5_split1_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG5_split1b(MMG5_pMesh,MMG5_pSol,int64_t*,int,MMG5_int,int,int8_t,int8_t); MMG5_int MMG5_splitedg(MMG5_pMesh mesh, MMG5_pSol met,MMG5_int iel, int iar, double crit); int MMG3D_split2sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); +int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split3_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split3cone_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); +int MMG5_split3cone_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG3D_split3op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3op(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6],int8_t); int MMG3D_split4sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split4op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); +int MMG5_split4op_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG3D_split5_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split5(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split6_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index c460a2c94..b3e36bb42 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -244,6 +244,131 @@ int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m } return 1; } + +/** + * \param mesh pointer toward the mesh structure. + * \param met pointer toward the metric structure. + * \param k index of element to split. + * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param metRidTyp metric storage (classic or special) + * + * \return 0 if fail, 1 otherwise + * + * Split 1 edge of tetra \a k. + * + */ +int MMG5_split1_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank) { + MMG5_pTetra pt,pt1; + MMG5_xTetra xt,xt1; + MMG5_pxTetra pxt0; + MMG5_int iel; + int8_t i,isxt,isxt1; + uint8_t tau[4]; + const uint8_t *taued; + + /* create a new tetra */ + pt = &mesh->tetra[k]; + iel = MMG3D_newElt(mesh); + if ( !iel ) { + MMG3D_TETRA_REALLOC(mesh,iel,mesh->gap, + fprintf(stderr,"\n ## Error: %s: unable to allocate" + " a new element.\n",__func__); + MMG5_INCREASE_MEM_MESSAGE(); + fprintf(stderr," Exit program.\n"); + return 0); + pt = &mesh->tetra[k]; + } + + pt1 = &mesh->tetra[iel]; + pt1 = memcpy(pt1,pt,sizeof(MMG5_Tetra)); + pxt0 = NULL; + if ( pt->xt ) { + pxt0 = &mesh->xtetra[pt->xt]; + memcpy(&xt,pxt0,sizeof(MMG5_xTetra)); + memcpy(&xt1,pxt0,sizeof(MMG5_xTetra)); + } + else { + memset(&xt,0,sizeof(MMG5_xTetra)); + memset(&xt1,0,sizeof(MMG5_xTetra)); + } + + MMG3D_split1_cfg(pt->flag,tau,&taued); + + /* Generic formulation of split of 1 edge */ + pt->v[tau[1]] = pt1->v[tau[0]] = vx[taued[0]]; + + if ( pt->xt ) { + /* Reset edge tag */ + xt.tag [taued[3]] = 0; xt.tag [taued[4]] = 0; + xt1.tag[taued[1]] = 0; xt1.tag[taued[2]] = 0; + xt.edg [taued[3]] = 0; xt.edg [taued[4]] = 0; + xt1.edg[taued[1]] = 0; xt1.edg[taued[2]] = 0; + xt.ref [ tau[0]] = 0; xt.ftag [ tau[0]] = 0; MG_SET( xt.ori, tau[0]); + xt1.ref[ tau[1]] = 0; xt1.ftag[ tau[1]] = 0; MG_SET(xt1.ori, tau[1]); + } + + pt->flag = pt1->flag = 0; + isxt = 0 ; + isxt1 = 0; + for (i=0; i<4; i++) { + if ( xt.ref[i] || xt.ftag[i] ) isxt = 1; + if ( xt1.ref[i] || xt1.ftag[i] ) isxt1 = 1; + if ( isxt && isxt1 ) goto nextstep1; + } + +nextstep1: + if ( pt->xt ) { + if ( isxt && !isxt1 ) { + pt1->xt = 0; + memcpy(pxt0,&xt,sizeof(MMG5_xTetra)); + } + else if ( !isxt && isxt1 ) { + pt1->xt = pt->xt; + pt->xt = 0; + pxt0 = &mesh->xtetra[pt1->xt]; + memcpy(pxt0,&xt1,sizeof(MMG5_xTetra)); + } + else if ( isxt && isxt1 ) { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + pxt0 = &mesh->xtetra[pt->xt]; + } + pt1->xt = mesh->xt; + + assert ( pxt0 ); + memcpy(pxt0,&xt,sizeof(MMG5_xTetra)); + pxt0 = &mesh->xtetra[mesh->xt]; + assert ( pxt0 ); + memcpy(pxt0,&xt1,sizeof(MMG5_xTetra)); + } + else { + pt->xt = 0; + pt1->xt = 0; + } + } + /* Quality update */ + if ( (!metRidTyp) && met->m && met->size>1 ) { + pt->qual=MMG5_caltet33_ani(mesh,met,pt); + pt1->qual=MMG5_caltet33_ani(mesh,met,pt1); + } + else if ( (!met) || (!met->m) ) { + /* in ls mode + -A option, orcal calls caltet_ani that fails */ + pt->qual=MMG5_caltet_iso(mesh,met,pt); + pt1->qual=MMG5_caltet_iso(mesh,met,pt1); + } + else { + pt->qual=MMG5_orcal(mesh,met,k); + pt1->qual=MMG5_orcal(mesh,met,iel); + } + return 1; +} + /** * \param mesh pointer toward the mesh structure * \param start index of the tetra that we want to split @@ -1353,67 +1478,6 @@ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t return 1; } -/** - * \param mesh pointer toward the mesh structure. - * \param met pointer toward the metric structure. - * \param k index of element to split. - * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. - * - * \return 0 if the split fail, 1 otherwise - * - * Simulate split of two opposite edges. - * - */ -int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]){ - MMG5_pTetra pt,pt0; - double vold,vnew; - uint8_t tau[4]; - const uint8_t *taued; - - pt = &mesh->tetra[k]; - pt0 = &mesh->tetra[0]; - vold = MMG5_orvol(mesh->point,pt->v); - - if ( vold < MMG5_EPSOK ) return 0; - - /* identity is case 33 */ - tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; - taued = &MMG5_permedge[0][0]; - switch(pt->flag){ - case 18: - tau[0] = 3; tau[1] = 1; tau[2] = 0; tau[3] = 2; - taued = &MMG5_permedge[10][0]; - break; - case 12: - tau[0] = 0; tau[1] = 3; tau[2] = 1; tau[3] = 2; - taued = &MMG5_permedge[2][0]; - break; - } - - /* Test orientation of the 4 tets to be created */ - memcpy(pt0,pt,sizeof(MMG5_Tetra)); - pt0->v[tau[1]] = vx[taued[0]]; pt0->v[tau[2]] = vx[taued[5]]; - vnew = MMG5_orvol(mesh->point,pt0->v); - if ( vnew < MMG5_EPSOK ) return 0; - - memcpy(pt0,pt,sizeof(MMG5_Tetra)); - pt0->v[tau[1]] = vx[taued[0]]; pt0->v[tau[3]] = vx[taued[5]]; - vnew = MMG5_orvol(mesh->point,pt0->v); - if ( vnew < MMG5_EPSOK ) return 0; - - memcpy(pt0,pt,sizeof(MMG5_Tetra)); - pt0->v[tau[0]] = vx[taued[0]]; pt0->v[tau[2]] = vx[taued[5]]; - vnew = MMG5_orvol(mesh->point,pt0->v); - if ( vnew < MMG5_EPSOK ) return 0; - - memcpy(pt0,pt,sizeof(MMG5_Tetra)); - pt0->v[tau[0]] = vx[taued[0]]; pt0->v[tau[3]] = vx[taued[5]]; - vnew = MMG5_orvol(mesh->point,pt0->v); - if ( vnew < MMG5_EPSOK ) return 0; - - return 1; -} - /** * \param mesh pointer toward the mesh structure. * \param met pointer toward the metric structure. @@ -1423,73 +1487,307 @@ int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]){ * * \return 0 if fail, 1 otherwise * - * Split of two OPPOSITE edges + * Split of two edges that belong to a common face : 1 tetra becomes 3 * */ -int MMG5_split2(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) { - MMG5_pTetra pt[4]; - MMG5_xTetra xt[4]; +int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank){ + MMG5_pTetra pt[3]; + MMG5_xTetra xt[3]; MMG5_pxTetra pxt0; - int i; - MMG5_int newtet[4]; - int8_t flg,firstxt,isxt[4]; + int i,flg; + MMG5_int newtet[3]; + int8_t imin_l,imin,firstxt,isxt[3]; uint8_t tau[4]; const uint8_t *taued; - const int ne=4; + const int ne=3; pt[0] = &mesh->tetra[k]; flg = pt[0]->flag; pt[0]->flag = 0; newtet[0]=k; - /* Create 3 new tetra */ + /* Create 2 new tetra */ if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { return 0; } - /* identity : case 33 */ - tau[0] = 0; tau[1] = 1; tau[2] = 2; tau[3] = 3; - taued = &MMG5_permedge[0][0]; - switch(flg){ - case 18: - tau[0] = 3; tau[1] = 1; tau[2] = 0; tau[3] = 2; - taued = &MMG5_permedge[10][0]; - break; - case 12: - tau[0] = 0; tau[1] = 3; tau[2] = 1; tau[3] = 2; - taued = &MMG5_permedge[2][0]; - break; - } - - /* Generic formulation for the split of 2 opposite edges */ - pt[0]->v[tau[1]] = vx[taued[0]]; pt[0]->v[tau[2]] = vx[taued[5]]; - pt[1]->v[tau[1]] = vx[taued[0]]; pt[1]->v[tau[3]] = vx[taued[5]]; - pt[2]->v[tau[0]] = vx[taued[0]]; pt[2]->v[tau[2]] = vx[taued[5]]; - pt[3]->v[tau[0]] = vx[taued[0]]; pt[3]->v[tau[3]] = vx[taued[5]]; + imin_l = MMG3D_split2sf_cfg(flg,tau,&taued,pt[0]); + + imin = (vGlobNum[tau[1]] < vGlobNum[tau[2]]) ? tau[1] : tau[2] ; + + // fprintf(stdout," MMG5_split2sf_GlobNum :: myrank %d, tetra %d; Flag %d \n" + // " vGlobNum %d-%d-%d-%d \n" + // " tau %d-%d-%d-%d, taued %d \n" + // " imin:: %d, imin_l:: %d \n" + // " BEFORE :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n", + // myrank,k,flg, + // vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], + // tau[0],tau[1],tau[2],tau[3],taued[0], + // imin,imin_l, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); - xt[0].tag[taued[1]] = 0; xt[0].tag[taued[3]] = 0; - xt[0].tag[taued[4]] = 0; xt[0].edg[taued[1]] = 0; - xt[0].edg[taued[3]] = 0; xt[0].edg[taued[4]] = 0; - xt[0].ref [ tau[0]] = 0; xt[0].ref [ tau[3]] = 0; - xt[0].ftag[ tau[0]] = 0; xt[0].ftag[ tau[3]] = 0; - MG_SET(xt[0].ori, tau[0]); MG_SET(xt[0].ori, tau[3]); + /* Generic formulation for the split of 2 edges belonging to a common face */ + pt[0]->v[tau[1]] = vx[taued[4]] ; pt[0]->v[tau[2]] = vx[taued[5]]; + xt[0].tag[taued[0]] = 0; xt[0].tag[taued[1]] = 0; + xt[0].tag[taued[3]] = 0; xt[0].edg[taued[0]] = 0; + xt[0].edg[taued[1]] = 0; xt[0].edg[taued[3]] = 0; + xt[0].ref[ tau[3]] = 0; xt[0].ftag[ tau[3]] = 0; MG_SET(xt[0].ori, tau[3]); - xt[1].tag[taued[2]] = 0; xt[1].tag[taued[3]] = 0; - xt[1].tag[taued[4]] = 0; xt[1].edg[taued[2]] = 0; - xt[1].edg[taued[3]] = 0; xt[1].edg[taued[4]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[2]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[2]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[2]); + if ( imin == tau[1] ) { + pt[1]->v[tau[2]] = vx[taued[5]]; pt[1]->v[tau[3]] = vx[taued[4]]; + pt[2]->v[tau[3]] = vx[taued[5]]; - xt[2].tag[taued[1]] = 0; xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[3]] = 0; xt[2].edg[taued[1]] = 0; - xt[2].edg[taued[2]] = 0; xt[2].edg[taued[3]] = 0; - xt[2].ref [ tau[1]] = 0; xt[2].ref [ tau[3]] = 0; - xt[2].ftag[ tau[1]] = 0; xt[2].ftag[ tau[3]] = 0; - MG_SET(xt[2].ori, tau[1]); MG_SET(xt[2].ori, tau[3]); + xt[1].tag[taued[1]] = 0; xt[1].tag[taued[2]] = 0; + xt[1].tag[taued[3]] = 0; xt[1].tag[taued[5]] = 0; + xt[1].edg[taued[1]] = 0; xt[1].edg[taued[2]] = 0; + xt[1].edg[taued[3]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[1]] = 0; xt[1].ref [ tau[3]] = 0; + xt[1].ftag[ tau[1]] = 0; xt[1].ftag[ tau[3]] = 0; + MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[3]); - xt[3].tag[taued[1]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].tag[taued[4]] = 0; xt[3].edg[taued[1]] = 0; + xt[2].tag[taued[2]] = 0; xt[2].tag[taued[4]] = 0; + xt[2].edg[taued[2]] = 0; xt[2].edg[taued[4]] = 0; + xt[2].ref[ tau[2]] = 0; xt[2].ftag[ tau[2]] = 0; MG_SET(xt[2].ori, tau[2]); + } + else { + pt[1]->v[tau[3]] = vx[taued[4]]; + pt[2]->v[tau[1]] = vx[taued[4]]; pt[2]->v[tau[3]] = vx[taued[5]]; + + xt[1].tag[taued[2]] = 0; xt[1].tag[taued[5]] = 0; + xt[1].edg[taued[2]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref[ tau[1]] = 0; xt[1].ftag[ tau[1]] = 0; MG_SET(xt[1].ori, tau[1]); + + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[3]] = 0; xt[2].tag[taued[4]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[2]] = 0; + xt[2].edg[taued[3]] = 0; xt[2].edg[taued[4]] = 0; + xt[2].ref [ tau[2]] = 0; xt[2].ref [ tau[3]] = 0; + xt[2].ftag[ tau[2]] = 0; xt[2].ftag[ tau[3]] = 0; + MG_SET(xt[2].ori, tau[2]); MG_SET(xt[2].ori, tau[3]); + } + + // fprintf(stdout," MMG5_split2sf_GlobNum :: myrank %d, tetra %d; Flag %d \n" + // " AFTER :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n", + // myrank,k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + + /* Assignation of the xt fields to the appropriate tets */ + isxt[0] = isxt[1] = isxt[2] = 0; + for (i=0; i<4; i++) { + if ( xt[0].ref[i] || xt[0].ftag[i] ) isxt[0] = 1; + if ( xt[1].ref[i] || xt[1].ftag[i] ) isxt[1] = 1; + if ( xt[2].ref[i] || xt[2].ftag[i] ) isxt[2] = 1; + } + + if ( pt[0]->xt ) { + if ( isxt[0] ) { + memcpy(pxt0,&xt[0],sizeof(MMG5_xTetra)); + pt[1]->xt = pt[2]->xt = 0; + for (i=1; i<3; i++) { + if ( isxt[i] ) { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + } + pt[i]->xt = mesh->xt; + pxt0 = &mesh->xtetra[mesh->xt]; + memcpy(pxt0,&(xt[i]),sizeof(MMG5_xTetra)); + } + } + } + else { + firstxt = 1; + pt[1]->xt = pt[2]->xt = 0; + for (i=1; i<3; i++) { + if ( isxt[i] ) { + if ( firstxt ) { + firstxt = 0; + pt[i]->xt = pt[0]->xt; + pxt0 = &mesh->xtetra[pt[i]->xt]; + memcpy(pxt0,&(xt[i]),sizeof(MMG5_xTetra)); + } + else { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + } + pt[i]->xt = mesh->xt; + pxt0 = &mesh->xtetra[mesh->xt]; + memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); + } + } + } + pt[0]->xt = 0; + } + } + + /* Quality update */ + MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); + + return 1; +} + +/** + * \param mesh pointer toward the mesh structure. + * \param met pointer toward the metric structure. + * \param k index of element to split. + * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * + * \return 0 if the split fail, 1 otherwise + * + * Simulate split of two opposite edges. + * + */ +int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]){ + MMG5_pTetra pt,pt0; + double vold,vnew; + uint8_t tau[4]; + const uint8_t *taued; + + pt = &mesh->tetra[k]; + pt0 = &mesh->tetra[0]; + vold = MMG5_orvol(mesh->point,pt->v); + + if ( vold < MMG5_EPSOK ) return 0; + + /* identity is case 33 */ + tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; + taued = &MMG5_permedge[0][0]; + switch(pt->flag){ + case 18: + tau[0] = 3; tau[1] = 1; tau[2] = 0; tau[3] = 2; + taued = &MMG5_permedge[10][0]; + break; + case 12: + tau[0] = 0; tau[1] = 3; tau[2] = 1; tau[3] = 2; + taued = &MMG5_permedge[2][0]; + break; + } + + /* Test orientation of the 4 tets to be created */ + memcpy(pt0,pt,sizeof(MMG5_Tetra)); + pt0->v[tau[1]] = vx[taued[0]]; pt0->v[tau[2]] = vx[taued[5]]; + vnew = MMG5_orvol(mesh->point,pt0->v); + if ( vnew < MMG5_EPSOK ) return 0; + + memcpy(pt0,pt,sizeof(MMG5_Tetra)); + pt0->v[tau[1]] = vx[taued[0]]; pt0->v[tau[3]] = vx[taued[5]]; + vnew = MMG5_orvol(mesh->point,pt0->v); + if ( vnew < MMG5_EPSOK ) return 0; + + memcpy(pt0,pt,sizeof(MMG5_Tetra)); + pt0->v[tau[0]] = vx[taued[0]]; pt0->v[tau[2]] = vx[taued[5]]; + vnew = MMG5_orvol(mesh->point,pt0->v); + if ( vnew < MMG5_EPSOK ) return 0; + + memcpy(pt0,pt,sizeof(MMG5_Tetra)); + pt0->v[tau[0]] = vx[taued[0]]; pt0->v[tau[3]] = vx[taued[5]]; + vnew = MMG5_orvol(mesh->point,pt0->v); + if ( vnew < MMG5_EPSOK ) return 0; + + return 1; +} + +/** + * \param mesh pointer toward the mesh structure. + * \param met pointer toward the metric structure. + * \param k index of element to split. + * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param metRidTyp metric storage (classic or special) + * + * \return 0 if fail, 1 otherwise + * + * Split of two OPPOSITE edges + * + */ +int MMG5_split2(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) { + MMG5_pTetra pt[4]; + MMG5_xTetra xt[4]; + MMG5_pxTetra pxt0; + int i; + MMG5_int newtet[4]; + int8_t flg,firstxt,isxt[4]; + uint8_t tau[4]; + const uint8_t *taued; + const int ne=4; + + pt[0] = &mesh->tetra[k]; + flg = pt[0]->flag; + pt[0]->flag = 0; + newtet[0]=k; + + /* Create 3 new tetra */ + if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { + return 0; + } + + /* identity : case 33 */ + tau[0] = 0; tau[1] = 1; tau[2] = 2; tau[3] = 3; + taued = &MMG5_permedge[0][0]; + switch(flg){ + case 18: + tau[0] = 3; tau[1] = 1; tau[2] = 0; tau[3] = 2; + taued = &MMG5_permedge[10][0]; + break; + case 12: + tau[0] = 0; tau[1] = 3; tau[2] = 1; tau[3] = 2; + taued = &MMG5_permedge[2][0]; + break; + } + + /* Generic formulation for the split of 2 opposite edges */ + pt[0]->v[tau[1]] = vx[taued[0]]; pt[0]->v[tau[2]] = vx[taued[5]]; + pt[1]->v[tau[1]] = vx[taued[0]]; pt[1]->v[tau[3]] = vx[taued[5]]; + pt[2]->v[tau[0]] = vx[taued[0]]; pt[2]->v[tau[2]] = vx[taued[5]]; + pt[3]->v[tau[0]] = vx[taued[0]]; pt[3]->v[tau[3]] = vx[taued[5]]; + + xt[0].tag[taued[1]] = 0; xt[0].tag[taued[3]] = 0; + xt[0].tag[taued[4]] = 0; xt[0].edg[taued[1]] = 0; + xt[0].edg[taued[3]] = 0; xt[0].edg[taued[4]] = 0; + xt[0].ref [ tau[0]] = 0; xt[0].ref [ tau[3]] = 0; + xt[0].ftag[ tau[0]] = 0; xt[0].ftag[ tau[3]] = 0; + MG_SET(xt[0].ori, tau[0]); MG_SET(xt[0].ori, tau[3]); + + xt[1].tag[taued[2]] = 0; xt[1].tag[taued[3]] = 0; + xt[1].tag[taued[4]] = 0; xt[1].edg[taued[2]] = 0; + xt[1].edg[taued[3]] = 0; xt[1].edg[taued[4]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[2]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[2]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[2]); + + xt[2].tag[taued[1]] = 0; xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[3]] = 0; xt[2].edg[taued[1]] = 0; + xt[2].edg[taued[2]] = 0; xt[2].edg[taued[3]] = 0; + xt[2].ref [ tau[1]] = 0; xt[2].ref [ tau[3]] = 0; + xt[2].ftag[ tau[1]] = 0; xt[2].ftag[ tau[3]] = 0; + MG_SET(xt[2].ori, tau[1]); MG_SET(xt[2].ori, tau[3]); + + xt[3].tag[taued[1]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].tag[taued[4]] = 0; xt[3].edg[taued[1]] = 0; xt[3].edg[taued[2]] = 0; xt[3].edg[taued[4]] = 0; xt[3].ref [ tau[1]] = 0; xt[3].ref [ tau[2]] = 0; xt[3].ftag[ tau[1]] = 0; xt[3].ftag[ tau[2]] = 0; @@ -2020,18 +2318,389 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 ib = tau[1]; } - if ( (pt[0])->v[tau[3]] < (pt[0])->v[ia] ) { + if ( (pt[0])->v[tau[3]] < (pt[0])->v[ia] ) { + ib = ia; + ia = tau[3]; + } + else { + if ( (pt[0])->v[tau[3]] < (pt[0])->v[ib] ) { + ib = tau[3]; + } + else { + } + } + + // fprintf(stdout," MMG5_split3cone :: tetra %d; Flag %d \n" + // " pt[0].v %d-%d-%d-%d \n" + // " tau %d-%d-%d-%d, taued %d \n" + // " ia:: %d, ib:: %d \n" + // " BEFORE :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n", + // k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // tau[0],tau[1],tau[2],tau[3],taued[0], + // ia,ib, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + + pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; + xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; + xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; + xt[0].edg[taued[4]] = 0; xt[0].edg[taued[5]] = 0; + xt[0].ref [ tau[0]] = 0; + xt[0].ftag[ tau[0]] = 0; + MG_SET(xt[0].ori, tau[0]); + + if ( ia == tau[3] ) { + pt[1]->v[tau[0]] = vx[taued[2]] ; pt[1]->v[tau[1]] = vx[taued[0]] ; pt[1]->v[tau[2]] = vx[taued[1]]; + xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; xt[1].edg[taued[3]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[3]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[3]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[3]); + + if ( ib == tau[1] ) { + pt[2]->v[tau[0]] = vx[taued[0]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; + xt[2].tag[taued[1]] = 0; xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[3]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[1]] = 0; xt[2].edg[taued[2]] = 0; + xt[2].edg[taued[3]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[1]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[1]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[1]); + + pt[3]->v[tau[0]] = vx[taued[1]] ; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].edg[taued[0]] = 0; xt[3].edg[taued[2]] = 0; + xt[3].ref [ tau[2]] = 0; + xt[3].ftag[ tau[2]] = 0; + MG_SET(xt[3].ori, tau[2]); + } + else { + assert(ib == tau[2]); + + pt[2]->v[tau[0]] = vx[taued[1]] ; pt[2]->v[tau[1]] = vx[taued[0]] ; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[3]] = 0; xt[2].tag[taued[4]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[2]] = 0; + xt[2].edg[taued[3]] = 0; xt[2].edg[taued[4]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); + + pt[3]->v[tau[0]] = vx[taued[0]] ; + xt[3].tag[taued[1]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].edg[taued[1]] = 0; xt[3].edg[taued[2]] = 0; + xt[3].ref [ tau[1]] = 0; + xt[3].ftag[ tau[1]] = 0; + MG_SET(xt[3].ori, tau[1]); + } + } + + else if (ia == tau[2] ) { + pt[1]->v[tau[0]] = vx[taued[1]] ; pt[1]->v[tau[1]] = vx[taued[0]] ; pt[1]->v[tau[3]] = vx[taued[2]]; + xt[1].tag[taued[0]] = 0; xt[1].tag[taued[2]] = 0; + xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[2]] = 0; xt[1].edg[taued[3]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[2]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[2]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[2]); + + if ( ib == tau[3] ) { + pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[1]] = vx[taued[0]] ; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; + xt[2].tag[taued[3]] = 0; xt[2].tag[taued[4]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; + xt[2].edg[taued[3]] = 0; xt[2].edg[taued[4]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[3]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[3]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[3]); + + pt[3]->v[tau[0]] = vx[taued[0]] ; + xt[3].tag[taued[1]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].edg[taued[1]] = 0; xt[3].edg[taued[2]] = 0; + xt[3].ref [ tau[1]] = 0; + xt[3].ftag[ tau[1]] = 0; + MG_SET(xt[3].ori, tau[1]); + } + else { + assert(ib == tau[1]); + + pt[2]->v[tau[0]] = vx[taued[0]] ; pt[2]->v[tau[3]] = vx[taued[2]] ; + xt[2].tag[taued[1]] = 0; xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[1]] = 0; xt[2].edg[taued[2]] = 0; + xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[1]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[1]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[1]); + + pt[3]->v[tau[0]] = vx[taued[2]] ; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; + xt[3].edg[taued[0]] = 0; xt[3].edg[taued[1]] = 0; + xt[3].ref [ tau[3]] = 0; + xt[3].ftag[ tau[3]] = 0; + MG_SET(xt[3].ori, tau[3]); + } + } + else { + assert(ia == tau[1]); + + pt[1]->v[tau[0]] = vx[taued[0]] ; pt[1]->v[tau[2]] = vx[taued[1]] ; pt[1]->v[tau[3]] = vx[taued[2]]; + xt[1].tag[taued[1]] = 0; xt[1].tag[taued[2]] = 0; + xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[1]] = 0; + xt[1].edg[taued[2]] = 0; xt[1].edg[taued[3]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); + + if ( ib == tau[2] ) { + pt[2]->v[tau[0]] = vx[taued[1]] ; pt[2]->v[tau[3]] = vx[taued[2]] ; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[2]] = 0; + xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); + + pt[3]->v[tau[0]] = vx[taued[2]] ; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; + xt[3].edg[taued[0]] = 0; xt[3].edg[taued[1]] = 0; + xt[3].ref [ tau[3]] = 0; + xt[3].ftag[ tau[3]] = 0; + MG_SET(xt[3].ori, tau[3]); + } + else { + assert(ib == tau[3]); + + pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; + xt[2].tag[taued[3]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; + xt[2].edg[taued[3]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[3]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[3]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[3]); + + pt[3]->v[tau[0]] = vx[taued[1]] ; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].edg[taued[0]] = 0; xt[3].edg[taued[2]] = 0; + xt[3].ref [ tau[2]] = 0; + xt[3].ftag[ tau[2]] = 0; + MG_SET(xt[3].ori, tau[2]); + } + } + + // fprintf(stdout," MMG5_split3cone :: tetra %d; Flag %d \n" + // " AFTER :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n", + // k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + + /* Assignation of the xt fields to the appropriate tets */ + isxt[0] = isxt[1] = isxt[2] = isxt[3] = 0; + + for (i=0; i<4; i++) { + int j; + for (j=0; jxt ) { + if ( isxt[0] ) { + memcpy(pxt0,&xt[0],sizeof(MMG5_xTetra)); + pt[1]->xt = pt[2]->xt = pt[3]->xt = 0; + for (i=1; i<4; i++) { + if ( isxt[i] ) { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + } + pt[i]->xt = mesh->xt; + pxt0 = &mesh->xtetra[mesh->xt]; + memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); + } + } + } + else { + firstxt = 1; + pt[1]->xt = pt[2]->xt = pt[3]->xt = 0; + for ( i=1; i<4; i++) { + if ( isxt[i] ) { + if ( firstxt ) { + firstxt = 0; + pt[i]->xt = pt[0]->xt; + pxt0 = &mesh->xtetra[(pt[i])->xt]; + memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); + } + else { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + } + pt[i]->xt = mesh->xt; + pxt0 = &mesh->xtetra[mesh->xt]; + memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); + } + } + } + (pt[0])->xt = 0; + } + } + + /* Quality update */ + MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); + + + return 1; +} + +/** + * \param mesh pointer toward the mesh structure. + * \param met pointer toward the metric structure. + * \param k index of element to split. + * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param metRidTyp metric storage (classic or special) + * + * \return 0 if fail, 1 otherwise + * + * Split 3 opposite edges in a tetra + * + */ +int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank){ + MMG5_pTetra pt[4]; + MMG5_xTetra xt[4]; + MMG5_pxTetra pxt0; + int i; + MMG5_int newtet[4]; + int8_t flg,firstxt,isxt[4],ia,ib,ia_l,ib_l; + uint8_t tau[4]; + const uint8_t *taued; + const int ne=4; + + pt[0] = &mesh->tetra[k]; + flg = pt[0]->flag; + pt[0]->flag = 0; + newtet[0]=k; + + /* create 3 new tetras */ + if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { + return 0; + } + + /* Set permutation of vertices : reference configuration is 7 */ + tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; + taued = &MMG5_permedge[0][0]; + + switch(flg) { + case 25: + tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; + taued = &MMG5_permedge[4][0]; + break; + + case 42: + tau[0] = 2 ; tau[1] = 0 ; tau[2] = 1 ; tau[3] = 3; + taued = &MMG5_permedge[6][0]; + break; + + case 52: + tau[0] = 3 ; tau[1] = 1 ; tau[2] = 0 ; tau[3] = 2; + taued = &MMG5_permedge[10][0]; + break; + } + + /* Generic formulation of split of 3 edges in cone configuration (edges 0,1,2 splitted) */ + /* Fill ia,ib,ic so that pt->v[ia] < pt->v[ib] < pt->v[ic] */ + if ( (pt[0])->v[tau[1]] < (pt[0])->v[tau[2]] ) { + ia_l = tau[1]; + ib_l = tau[2]; + } + else { + ia_l = tau[2]; + ib_l = tau[1]; + } + + if ( (pt[0])->v[tau[3]] < (pt[0])->v[ia_l] ) { + ib_l = ia_l; + ia_l = tau[3]; + } + else { + if ( (pt[0])->v[tau[3]] < (pt[0])->v[ib_l] ) { + ib_l = tau[3]; + } + else { + } + } + + if ( vGlobNum[tau[1]] < vGlobNum[tau[2]] ) { + ia = tau[1]; + ib = tau[2]; + } + else { + ia = tau[2]; + ib = tau[1]; + } + + if ( vGlobNum[tau[3]] < vGlobNum[ia] ) { ib = ia; ia = tau[3]; } else { - if ( (pt[0])->v[tau[3]] < (pt[0])->v[ib] ) { + if ( vGlobNum[tau[3]] < vGlobNum[ib] ) { ib = tau[3]; } else { } } + // fprintf(stdout," MMG5_split3cone_GlobNum :: myrank %d, tetra %d; Flag %d \n" + // " vGlobNum %d-%d-%d-%d \n" + // " tau %d-%d-%d-%d, taued %d \n" + // " ia:: %d, ia_l:: %d, ib:: %d, ib_l:: %d \n" + // " BEFORE :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n", + // myrank,k,flg, + // vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], + // tau[0],tau[1],tau[2],tau[3],taued[0], + // ia,ia_l,ib,ib_l, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; @@ -2188,6 +2857,18 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 } } + // fprintf(stdout," MMG5_split3cone_GlobNum :: myrank %d, tetra %d; Flag %d \n" + // " AFTER :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n", + // myrank,k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + /* Assignation of the xt fields to the appropriate tets */ isxt[0] = isxt[1] = isxt[2] = isxt[3] = 0; @@ -2253,7 +2934,6 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 /* Quality update */ MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); - return 1; } @@ -3711,8 +4391,316 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t return 0; } + // fprintf(stdout," MMG5_split4op :: tetra %d; Flag %d \n" + // " pt[0].v %d-%d-%d-%d \n" + // " tau %d-%d-%d-%d, taued %d \n" + // " imin01:: %d, imin23:: %d \n" + // " BEFORE :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n" + // " pt[4].v %d-%d-%d-%d \n" + // " pt[5].v %d-%d-%d-%d \n", + // k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // tau[0],tau[1],tau[2],tau[3],taued[0], + // imin01,imin23, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], + // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], + // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + + + /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ + if ( imin01 == tau[0] ) { + pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; + xt[0].tag[taued[1]] = 0; xt[0].tag[taued[5]] = 0; + xt[0].tag[taued[2]] = 0; xt[0].edg[taued[1]] = 0; + xt[0].edg[taued[5]] = 0; xt[0].edg[taued[2]] = 0; + xt[0].ref [ tau[1]] = 0; + xt[0].ftag[ tau[1]] = 0; + MG_SET(xt[0].ori, tau[1]); + + pt[1]->v[tau[1]] = vx[taued[4]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; + xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; xt[1].edg[taued[3]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[3]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[3]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[3]); + + pt[2]->v[tau[1]] = vx[taued[3]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; pt[2]->v[tau[3]] = vx[taued[2]]; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[3]] = 0; + xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[3]] = 0; + xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); + } + else { + pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; + xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; + xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; + xt[0].edg[taued[4]] = 0; xt[0].edg[taued[5]] = 0; + xt[0].ref [ tau[0]] = 0; + xt[0].ftag[ tau[0]] = 0; + MG_SET(xt[0].ori, tau[0]); + + pt[1]->v[tau[0]] = vx[taued[1]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; + xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[2]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; xt[1].edg[taued[2]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[2]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[2]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[2]); + + pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[2]] = vx[taued[3]] ; pt[2]->v[tau[3]] = vx[taued[4]]; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; + xt[2].tag[taued[2]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; + xt[2].edg[taued[2]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[1]] = 0; xt[2].ref [ tau[3]] = 0; + xt[2].ftag[ tau[1]] = 0; xt[2].ftag[ tau[3]] = 0; + MG_SET(xt[2].ori, tau[1]); MG_SET(xt[2].ori, tau[3]); + } + + if ( imin23 == tau[2] ) { + pt[3]->v[tau[0]] = vx[taued[2]] ; pt[3]->v[tau[1]] = vx[taued[4]]; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; + xt[3].tag[taued[3]] = 0; xt[3].edg[taued[0]] = 0; + xt[3].edg[taued[1]] = 0; xt[3].edg[taued[3]] = 0; + xt[3].ref [ tau[3]] = 0; + xt[3].ftag[ tau[3]] = 0; + MG_SET(xt[3].ori, tau[3]); + + pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[3]] = vx[taued[4]]; + xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; + xt[4].tag[taued[2]] = 0; xt[4].tag[taued[4]] = 0; + xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; + xt[4].edg[taued[1]] = 0; xt[4].edg[taued[2]] = 0; + xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; + xt[4].ref [ tau[1]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; + xt[4].ftag[ tau[1]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; + MG_SET(xt[4].ori, tau[1]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); + + pt[5]->v[tau[0]] = vx[taued[1]] ; pt[5]->v[tau[1]] = vx[taued[3]] ; pt[5]->v[tau[3]] = vx[taued[2]]; + xt[5].tag[taued[0]] = 0; xt[5].tag[taued[2]] = 0; + xt[5].tag[taued[4]] = 0; xt[5].tag[taued[5]] = 0; + xt[5].edg[taued[0]] = 0; xt[5].edg[taued[2]] = 0; + xt[5].edg[taued[4]] = 0; xt[5].edg[taued[5]] = 0; + xt[5].ref [ tau[0]] = 0; xt[5].ref [ tau[2]] = 0; + xt[5].ftag[ tau[0]] = 0; xt[5].ftag[ tau[2]] = 0; + MG_SET(xt[5].ori, tau[0]); MG_SET(xt[5].ori, tau[2]); + } + else { + pt[3]->v[tau[0]] = vx[taued[1]] ; pt[3]->v[tau[1]] = vx[taued[3]]; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].tag[taued[4]] = 0; xt[3].edg[taued[0]] = 0; + xt[3].edg[taued[2]] = 0; xt[3].edg[taued[4]] = 0; + xt[3].ref [ tau[2]] = 0; + xt[3].ftag[ tau[2]] = 0; + MG_SET(xt[3].ori, tau[2]); + + pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[2]] = vx[taued[1]]; + xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; + xt[4].tag[taued[3]] = 0; xt[4].tag[taued[4]] = 0; + xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; + xt[4].edg[taued[1]] = 0; xt[4].edg[taued[3]] = 0; + xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; + xt[4].ref [ tau[0]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; + xt[4].ftag[ tau[0]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; + MG_SET(xt[4].ori, tau[0]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); + + pt[5]->v[tau[0]] = vx[taued[2]] ; pt[5]->v[tau[1]] = vx[taued[4]] ; pt[5]->v[tau[2]] = vx[taued[3]]; + xt[5].tag[taued[0]] = 0; xt[5].tag[taued[1]] = 0; + xt[5].tag[taued[3]] = 0; xt[5].tag[taued[5]] = 0; + xt[5].edg[taued[0]] = 0; xt[5].edg[taued[1]] = 0; + xt[5].edg[taued[3]] = 0; xt[5].edg[taued[5]] = 0; + xt[5].ref [ tau[1]] = 0; xt[5].ref [ tau[3]] = 0; + xt[5].ftag[ tau[1]] = 0; xt[5].ftag[ tau[3]] = 0; + MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); + } + + // fprintf(stdout," MMG5_split4op :: tetra %d; Flag %d \n" + // " AFTER :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n" + // " pt[4].v %d-%d-%d-%d \n" + // " pt[5].v %d-%d-%d-%d \n", + // k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], + // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], + // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + + /* Assignation of the xt fields to the appropriate tets */ + memset(isxt,0,ne*sizeof(int8_t)); + + for (i=0; i<4; i++) { + for(j=0;jxt ) { + if ( isxt[0] ) { + memcpy(pxt0,&xt[0],sizeof(MMG5_xTetra)); + pt[1]->xt = pt[2]->xt = pt[3]->xt = pt[4]->xt = pt[5]->xt = 0; + + for (i=1; i<6; i++) { + if ( isxt[i] ) { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + } + pt[i]->xt = mesh->xt; + pxt0 = &mesh->xtetra[mesh->xt]; + memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); + } + } + } + else { + firstxt = 1; + pt[1]->xt = pt[2]->xt = pt[3]->xt = pt[4]->xt = pt[5]->xt = 0; + + for (i=1; i<6; i++) { + if ( isxt[i] ) { + if ( firstxt ) { + firstxt = 0; + pt[i]->xt = pt[0]->xt; + pxt0 = &mesh->xtetra[ pt[i]->xt]; + memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); + } + else { + mesh->xt++; + if ( mesh->xt > mesh->xtmax ) { + /* realloc of xtetras table */ + MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, + "larger xtetra table", + mesh->xt--; + fprintf(stderr," Exit program.\n"); + return 0); + } + pt[i]->xt = mesh->xt; + pxt0 = &mesh->xtetra[mesh->xt]; + memcpy(pxt0,&(xt[i]),sizeof(MMG5_xTetra)); + } + } + } + pt[0]->xt = 0; + + } + } + + /* Quality update */ + MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); + + return 1; +} + +/** + * \param mesh pointer toward the mesh structure. + * \param met pointer toward the metric structure. + * \param k index of element to split. + * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param metRidTyp metric storage (classic or special) + * + * \return 0 if fail, 1 otherwise + * + * Split 4 edges in a configuration when no 3 edges lie on the same face + * + */ +int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank) { + MMG5_pTetra pt[6]; + MMG5_xTetra xt[6]; + MMG5_pxTetra pxt0; + MMG5_int newtet[6]; + int8_t flg,firstxt,isxt[6],i,j,imin01,imin23,imin01_l,imin23_l; + uint8_t tau[4]; + const uint8_t *taued; + const int ne=6; + + /* Store the initial tetra and flag */ + pt[0] = &mesh->tetra[k]; + flg = pt[0]->flag; + + /* Reinitialize the flag of the initial tetra */ + pt[0]->flag = 0; + + /* Store the id of the initial tetra */ + newtet[0] = k; + + /* Set permutation of vertices : reference configuration 30 */ + tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; + taued = &MMG5_permedge[0][0]; + + switch(flg){ + case 45: + tau[0] = 1 ; tau[1] = 3 ; tau[2] = 2 ; tau[3] = 0; + taued = &MMG5_permedge[5][0]; + break; + + case 51: + tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; + taued = &MMG5_permedge[4][0]; + break; + } + + /* Determine the rotation to be done to split following the pattern */ + imin01 = (vGlobNum[tau[0]] < vGlobNum[tau[1]]) ? tau[0] : tau[1]; + imin23 = (vGlobNum[tau[2]] < vGlobNum[tau[3]]) ? tau[2] : tau[3]; + + imin01_l = ((pt[0])->v[tau[0]] < (pt[0])->v[tau[1]]) ? tau[0] : tau[1]; + imin23_l = ((pt[0])->v[tau[2]] < (pt[0])->v[tau[3]]) ? tau[2] : tau[3]; + + /* Create 5 new tetras */ + if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { + return 0; + } + + // fprintf(stdout," MMG5_split4op_GlobNum :: myrank %d, tetra %d; Flag %d \n" + // " vGlobNum %d-%d-%d-%d \n" + // " tau %d-%d-%d-%d, taued %d \n" + // " imin01:: %d, imin01_l:: %d, imin23:: %d, imin23_l:: %d \n" + // " BEFORE :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n" + // " pt[4].v %d-%d-%d-%d \n" + // " pt[5].v %d-%d-%d-%d \n", + // myrank,k,flg, + // vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], + // tau[0],tau[1],tau[2],tau[3],taued[0], + // imin01,imin01_l,imin23,imin23_l, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], + // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], + // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ if ( imin01 == tau[0] ) { + pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; xt[0].tag[taued[1]] = 0; xt[0].tag[taued[5]] = 0; xt[0].tag[taued[2]] = 0; xt[0].edg[taued[1]] = 0; @@ -3826,6 +4814,22 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); } + // fprintf(stdout," MMG5_split4op_GlobNum :: myrank %d, tetra %d; Flag %d \n" + // " AFTER :: \n" + // " pt[0].v %d-%d-%d-%d \n" + // " pt[1].v %d-%d-%d-%d \n" + // " pt[2].v %d-%d-%d-%d \n" + // " pt[3].v %d-%d-%d-%d \n" + // " pt[4].v %d-%d-%d-%d \n" + // " pt[5].v %d-%d-%d-%d \n", + // myrank,k,flg, + // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], + // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], + // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + /* Assignation of the xt fields to the appropriate tets */ memset(isxt,0,ne*sizeof(int8_t)); From 7a7aea9f63b1b1281daf9efbfcc9abe80f3b8368 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Wed, 30 Aug 2023 15:41:38 +0200 Subject: [PATCH 03/19] (1) Remove functions to get and update s variable in hash table and (2) Add 2 new functions to get and update k and s variables at the same time in hash table --- src/common/hash.c | 36 +++++++++++++++++++++++++--------- src/common/mmgcommon_private.h | 4 ++-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/common/hash.c b/src/common/hash.c index f79607347..aa3e0ba8a 100644 --- a/src/common/hash.c +++ b/src/common/hash.c @@ -429,13 +429,17 @@ int MMG5_hashUpdate(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { * \param hash pointer toward the hash table of edges. * \param a index of the first extremity of the edge. * \param b index of the second extremity of the edge. - * \param k new index of point along the edge. + * \param k index of new point along the edge [a,b]. + * \param s If ls mode in ParMmg:: index of new point in internal edge communicator; + * otherwise, the value stored in variable s. * \return 1 if success, 0 if fail (edge is not found). * - * Update the index of the point stored along the edge \f$[a;b]\f$ + * Update the index of the new point stored along the edge \f$[a;b]\f$ + * If ls mode in ParMmg:: update the index of the new point in internal edge communicator; + * otherwise, update the value stored in variable s. * */ -int MMG5_hashUpdate_s(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { +int MMG5_hashUpdate_all(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k,MMG5_int s) { MMG5_hedge *ph; MMG5_int key; MMG5_int ia,ib; @@ -447,7 +451,8 @@ int MMG5_hashUpdate_s(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { while ( ph->a ) { if ( ph->a == ia && ph->b == ib ) { - ph->s = k; + ph->k = k; + ph->s = s; return 1; } @@ -555,12 +560,17 @@ MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { * \param hash pointer toward the hash table of edges. * \param a index of the first extremity of the edge. * \param b index of the second extremity of the edge. - * \return the index of point stored along \f$[a;b]\f$. + * \param k index of new point along the edge [a,b]. + * \param s If ls mode in ParMmg:: index of new point in internal edge communicator; + * otherwise, the value stored in variable s. + * \return 1 if success, 0 if fail (edge is not found). * - * Find the index of point stored along \f$[a;b]\f$. + * Find the index of the new point stored along the edge \f$[a;b]\f$ + * If ls mode in ParMmg:: find the index of the new point in internal edge communicator; + * otherwise, find the value stored in variable s. * */ -int MMG5_hashGet_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { +int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s) { MMG5_hedge *ph; MMG5_int key; MMG5_int ia,ib; @@ -573,10 +583,18 @@ int MMG5_hashGet_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { ph = &hash->item[key]; if ( !ph->a ) return 0; - if ( ph->a == ia && ph->b == ib ) return ph->s; + if ( ph->a == ia && ph->b == ib ) { + *k = ph->k; + *s = ph->s; + return 1; + } while ( ph->nxt ) { ph = &hash->item[ph->nxt]; - if ( ph->a == ia && ph->b == ib ) return ph->s; + if ( ph->a == ia && ph->b == ib ) { + *k = ph->k; + *s = ph->s; + return 1; + } } return 0; } diff --git a/src/common/mmgcommon_private.h b/src/common/mmgcommon_private.h index ee5cf8a0e..abbb76690 100644 --- a/src/common/mmgcommon_private.h +++ b/src/common/mmgcommon_private.h @@ -676,10 +676,10 @@ typedef struct MMG5_iNode_s { MMG5_int MMG5_hashFace(MMG5_pMesh,MMG5_Hash*,MMG5_int,MMG5_int,MMG5_int,MMG5_int); int MMG5_hashEdge(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); int MMG5_hashUpdate(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); - int MMG5_hashUpdate_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); + int MMG5_hashUpdate_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k,MMG5_int s); int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,int16_t k); MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b); - MMG5_int MMG5_hashGet_s(MMG5_Hash *hash,MMG5_int a,MMG5_int b); + MMG5_int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s); int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash,MMG5_int hsiz,MMG5_int hmax); int MMG5_intmetsavedir(MMG5_pMesh mesh, double *m,double *n,double *mr); int MMG5_intridmet(MMG5_pMesh,MMG5_pSol,MMG5_int,MMG5_int,double,double*,double*); From c92871bb4698f5bc8ba76c2184d6fdca4d896c5d Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Thu, 31 Aug 2023 15:11:54 +0200 Subject: [PATCH 04/19] Modification of split functions using global indices --- src/mmg3d/split_3d.c | 104 +++++++++++++++++++++---------------------- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index b3e36bb42..f3dfc1e79 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -2683,23 +2683,23 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } } - // fprintf(stdout," MMG5_split3cone_GlobNum :: myrank %d, tetra %d; Flag %d \n" - // " vGlobNum %d-%d-%d-%d \n" - // " tau %d-%d-%d-%d, taued %d \n" - // " ia:: %d, ia_l:: %d, ib:: %d, ib_l:: %d \n" - // " BEFORE :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n", - // myrank,k,flg, - // vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], - // tau[0],tau[1],tau[2],tau[3],taued[0], - // ia,ia_l,ib,ib_l, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + fprintf(stdout," MMG5_split3cone_GlobNum :: myrank %d, tetra %d; Flag %d \n" + " vGlobNum %d-%d-%d-%d \n" + " tau %d-%d-%d-%d, taued %d \n" + " ia:: %d, ia_l:: %d, ib:: %d, ib_l:: %d \n" + " BEFORE :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n", + myrank,k,flg, + vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], + tau[0],tau[1],tau[2],tau[3],taued[0], + ia,ia_l,ib,ib_l, + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; @@ -4676,27 +4676,24 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v return 0; } - // fprintf(stdout," MMG5_split4op_GlobNum :: myrank %d, tetra %d; Flag %d \n" - // " vGlobNum %d-%d-%d-%d \n" - // " tau %d-%d-%d-%d, taued %d \n" - // " imin01:: %d, imin01_l:: %d, imin23:: %d, imin23_l:: %d \n" - // " BEFORE :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n" - // " pt[4].v %d-%d-%d-%d \n" - // " pt[5].v %d-%d-%d-%d \n", - // myrank,k,flg, - // vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], - // tau[0],tau[1],tau[2],tau[3],taued[0], - // imin01,imin01_l,imin23,imin23_l, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], - // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], - // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + if (myrank == 0) { + fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin01_l:: %d, imin23:: %d, imin23_l:: %d \n" + " BEFORE :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n" + " pt[4].v %d-%d-%d-%d \n" + " pt[5].v %d-%d-%d-%d \n", + tau[0],tau[1],tau[2],tau[3],taued[0], + imin01,imin01_l,imin23,imin23_l, + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], + pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], + pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + } /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ if ( imin01 == tau[0] ) { @@ -4814,21 +4811,22 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); } - // fprintf(stdout," MMG5_split4op_GlobNum :: myrank %d, tetra %d; Flag %d \n" - // " AFTER :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n" - // " pt[4].v %d-%d-%d-%d \n" - // " pt[5].v %d-%d-%d-%d \n", - // myrank,k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], - // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], - // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + if (myrank == 0) { + fprintf(stdout," MMG5_split4op_GlobNum :: \n" + " AFTER :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n" + " pt[4].v %d-%d-%d-%d \n" + " pt[5].v %d-%d-%d-%d \n", + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], + pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], + pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + } /* Assignation of the xt fields to the appropriate tets */ memset(isxt,0,ne*sizeof(int8_t)); From c8fb0785f65c1d6ffec028d8aa0ea019e2e42bc5 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Fri, 1 Sep 2023 17:13:02 +0200 Subject: [PATCH 05/19] Progress in split using global num --- src/mmg3d/split_3d.c | 204 +++++++++++++++++++++---------------------- 1 file changed, 101 insertions(+), 103 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index f3dfc1e79..ae957a0c7 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -2683,23 +2683,21 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } } - fprintf(stdout," MMG5_split3cone_GlobNum :: myrank %d, tetra %d; Flag %d \n" - " vGlobNum %d-%d-%d-%d \n" - " tau %d-%d-%d-%d, taued %d \n" - " ia:: %d, ia_l:: %d, ib:: %d, ib_l:: %d \n" - " BEFORE :: \n" - " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n", - myrank,k,flg, - vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], + + if (!myrank) { + fprintf(stdout," MMG5_split3cone_GlobNum :: tau %d-%d-%d-%d, taued %d, ia:: %d, ia_l:: %d, ib:: %d, ib_l:: %d \n" + " BEFORE :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n", tau[0],tau[1],tau[2],tau[3],taued[0], ia,ia_l,ib,ib_l, pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + } pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; @@ -2857,17 +2855,17 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } } - // fprintf(stdout," MMG5_split3cone_GlobNum :: myrank %d, tetra %d; Flag %d \n" - // " AFTER :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n", - // myrank,k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + if (!myrank) { + fprintf(stdout," AFTER :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n", + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + } /* Assignation of the xt fields to the appropriate tets */ isxt[0] = isxt[1] = isxt[2] = isxt[3] = 0; @@ -4391,29 +4389,6 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t return 0; } - // fprintf(stdout," MMG5_split4op :: tetra %d; Flag %d \n" - // " pt[0].v %d-%d-%d-%d \n" - // " tau %d-%d-%d-%d, taued %d \n" - // " imin01:: %d, imin23:: %d \n" - // " BEFORE :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n" - // " pt[4].v %d-%d-%d-%d \n" - // " pt[5].v %d-%d-%d-%d \n", - // k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // tau[0],tau[1],tau[2],tau[3],taued[0], - // imin01,imin23, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], - // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], - // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); - - /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ if ( imin01 == tau[0] ) { pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; @@ -4529,22 +4504,6 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); } - // fprintf(stdout," MMG5_split4op :: tetra %d; Flag %d \n" - // " AFTER :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n" - // " pt[4].v %d-%d-%d-%d \n" - // " pt[5].v %d-%d-%d-%d \n", - // k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], - // pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], - // pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); - /* Assignation of the xt fields to the appropriate tets */ memset(isxt,0,ne*sizeof(int8_t)); @@ -4676,15 +4635,15 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v return 0; } - if (myrank == 0) { - fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin01_l:: %d, imin23:: %d, imin23_l:: %d \n" - " BEFORE :: \n" - " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n" - " pt[4].v %d-%d-%d-%d \n" - " pt[5].v %d-%d-%d-%d \n", + if (!myrank) { + fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin01_l:: %d, imin23:: %d, imin23_l:: %d \n" + " BEFORE :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n" + " pt[4].v %d-%d-%d-%d \n" + " pt[5].v %d-%d-%d-%d \n", tau[0],tau[1],tau[2],tau[3],taued[0], imin01,imin01_l,imin23,imin23_l, pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], @@ -4697,33 +4656,73 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ if ( imin01 == tau[0] ) { - pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; - pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; - xt[0].tag[taued[1]] = 0; xt[0].tag[taued[5]] = 0; - xt[0].tag[taued[2]] = 0; xt[0].edg[taued[1]] = 0; - xt[0].edg[taued[5]] = 0; xt[0].edg[taued[2]] = 0; - xt[0].ref [ tau[1]] = 0; - xt[0].ftag[ tau[1]] = 0; + pt[0]->v[tau[2]] = vx[taued[3]]; + pt[0]->v[tau[3]] = vx[taued[4]]; + + xt[0].tag[taued[1]] = 0; + xt[0].tag[taued[2]] = 0; + xt[0].tag[taued[5]] = 0; + + xt[0].edg[taued[1]] = 0; + xt[0].edg[taued[2]] = 0; + xt[0].edg[taued[5]] = 0; + + xt[0].ref[tau[1]] = 0; + + xt[0].ftag[tau[1]] = 0; + MG_SET(xt[0].ori, tau[1]); - pt[1]->v[tau[1]] = vx[taued[4]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; - xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; xt[1].edg[taued[3]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[3]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[3]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[3]); + pt[1]->v[tau[1]] = vx[taued[4]]; + pt[1]->v[tau[2]] = vx[taued[3]]; + pt[1]->v[tau[3]] = vx[taued[2]]; - pt[2]->v[tau[1]] = vx[taued[3]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; pt[2]->v[tau[3]] = vx[taued[2]]; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[3]] = 0; - xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[3]] = 0; - xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); + xt[1].tag[taued[0]] = 0; + xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[3]] = 0; + xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; + + xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; + xt[1].edg[taued[3]] = 0; + xt[1].edg[taued[4]] = 0; + xt[1].edg[taued[5]] = 0; + + xt[1].ref[tau[0]] = 0; + xt[1].ref[tau[1]] = 0; + xt[1].ref[tau[3]] = 0; + + xt[1].ftag[tau[0]] = 0; + xt[1].ftag[tau[1]] = 0; + xt[1].ftag[tau[3]] = 0; + + MG_SET(xt[1].ori, tau[0]); + MG_SET(xt[1].ori, tau[1]); + MG_SET(xt[1].ori, tau[3]); + + pt[2]->v[tau[1]] = vx[taued[3]]; + pt[2]->v[tau[2]] = vx[taued[1]]; + pt[2]->v[tau[3]] = vx[taued[2]]; + + xt[2].tag[taued[0]] = 0; + xt[2].tag[taued[3]] = 0; + xt[2].tag[taued[4]] = 0; + xt[2].tag[taued[5]] = 0; + + xt[2].edg[taued[0]] = 0; + xt[2].edg[taued[3]] = 0; + xt[2].edg[taued[4]] = 0; + xt[2].edg[taued[5]] = 0; + + xt[2].ref[tau[0]] = 0; + xt[2].ref[tau[2]] = 0; + + xt[2].ftag[tau[0]] = 0; + xt[2].ftag[tau[2]] = 0; + + MG_SET(xt[2].ori, tau[0]); + MG_SET(xt[2].ori, tau[2]); } else { pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; @@ -4811,15 +4810,14 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); } - if (myrank == 0) { - fprintf(stdout," MMG5_split4op_GlobNum :: \n" - " AFTER :: \n" - " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n" - " pt[4].v %d-%d-%d-%d \n" - " pt[5].v %d-%d-%d-%d \n", + if (!myrank) { + fprintf(stdout," AFTER :: \n" + " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n" + " pt[4].v %d-%d-%d-%d \n" + " pt[5].v %d-%d-%d-%d \n", pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], From 434e42d7220a55fa1f72cbb1a7fa4c44a52330d5 Mon Sep 17 00:00:00 2001 From: Laetitia Mottet Date: Mon, 4 Sep 2023 16:56:20 +0200 Subject: [PATCH 06/19] Modify split function --- src/mmg3d/split_3d.c | 261 +++++++++++++++++++++++++++++++------------ 1 file changed, 192 insertions(+), 69 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index ae957a0c7..bed1a58d2 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -4725,89 +4725,212 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MG_SET(xt[2].ori, tau[2]); } else { - pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; - xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; - xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; - xt[0].edg[taued[4]] = 0; xt[0].edg[taued[5]] = 0; - xt[0].ref [ tau[0]] = 0; - xt[0].ftag[ tau[0]] = 0; + pt[0]->v[tau[2]] = vx[taued[1]]; + pt[0]->v[tau[3]] = vx[taued[2]]; + + xt[0].tag[taued[3]] = 0; + xt[0].tag[taued[4]] = 0; + xt[0].tag[taued[5]] = 0; + + xt[0].edg[taued[3]] = 0; + xt[0].edg[taued[4]] = 0; + xt[0].edg[taued[5]] = 0; + + xt[0].ref[tau[0]] = 0; + + xt[0].ftag[tau[0]] = 0; + MG_SET(xt[0].ori, tau[0]); - pt[1]->v[tau[0]] = vx[taued[1]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; - xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[2]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; xt[1].edg[taued[2]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[2]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[2]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[2]); + pt[1]->v[tau[0]] = vx[taued[1]]; + pt[1]->v[tau[2]] = vx[taued[3]]; + pt[1]->v[tau[3]] = vx[taued[2]]; - pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[2]] = vx[taued[3]] ; pt[2]->v[tau[3]] = vx[taued[4]]; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; - xt[2].tag[taued[2]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; - xt[2].edg[taued[2]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[1]] = 0; xt[2].ref [ tau[3]] = 0; - xt[2].ftag[ tau[1]] = 0; xt[2].ftag[ tau[3]] = 0; - MG_SET(xt[2].ori, tau[1]); MG_SET(xt[2].ori, tau[3]); + xt[1].tag[taued[0]] = 0; + xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[2]] = 0; + xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; + + xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; + xt[1].edg[taued[2]] = 0; + xt[1].edg[taued[4]] = 0; + xt[1].edg[taued[5]] = 0; + + xt[1].ref[tau[0]] = 0; + xt[1].ref[tau[1]] = 0; + xt[1].ref[tau[2]] = 0; + + xt[1].ftag[tau[0]] = 0; + xt[1].ftag[tau[1]] = 0; + xt[1].ftag[tau[2]] = 0; + + MG_SET(xt[1].ori, tau[0]); + MG_SET(xt[1].ori, tau[1]); + MG_SET(xt[1].ori, tau[2]); + + pt[2]->v[tau[0]] = vx[taued[2]]; + pt[2]->v[tau[2]] = vx[taued[3]]; + pt[2]->v[tau[3]] = vx[taued[4]]; + + xt[2].tag[taued[0]] = 0; + xt[2].tag[taued[1]] = 0; + xt[2].tag[taued[2]] = 0; + xt[2].tag[taued[5]] = 0; + + xt[2].edg[taued[0]] = 0; + xt[2].edg[taued[1]] = 0; + xt[2].edg[taued[2]] = 0; + xt[2].edg[taued[5]] = 0; + + xt[2].ref[tau[1]] = 0; + xt[2].ref[tau[3]] = 0; + + xt[2].ftag[tau[1]] = 0; + xt[2].ftag[tau[3]] = 0; + + MG_SET(xt[2].ori, tau[1]); + MG_SET(xt[2].ori, tau[3]); } if ( imin23 == tau[2] ) { - pt[3]->v[tau[0]] = vx[taued[2]] ; pt[3]->v[tau[1]] = vx[taued[4]]; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; - xt[3].tag[taued[3]] = 0; xt[3].edg[taued[0]] = 0; - xt[3].edg[taued[1]] = 0; xt[3].edg[taued[3]] = 0; - xt[3].ref [ tau[3]] = 0; - xt[3].ftag[ tau[3]] = 0; + pt[3]->v[tau[0]] = vx[taued[2]]; + pt[3]->v[tau[1]] = vx[taued[4]]; + + xt[3].tag[taued[0]] = 0; + xt[3].tag[taued[1]] = 0; + xt[3].tag[taued[3]] = 0; + + xt[3].edg[taued[0]] = 0; + xt[3].edg[taued[1]] = 0; + xt[3].edg[taued[3]] = 0; + + xt[3].ref[tau[3]] = 0; + + xt[3].ftag[tau[3]] = 0; + MG_SET(xt[3].ori, tau[3]); - pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[3]] = vx[taued[4]]; - xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; - xt[4].tag[taued[2]] = 0; xt[4].tag[taued[4]] = 0; - xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; - xt[4].edg[taued[1]] = 0; xt[4].edg[taued[2]] = 0; - xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; - xt[4].ref [ tau[1]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; - xt[4].ftag[ tau[1]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; - MG_SET(xt[4].ori, tau[1]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); + pt[4]->v[tau[0]] = vx[taued[2]]; + pt[4]->v[tau[1]] = vx[taued[3]]; + pt[4]->v[tau[3]] = vx[taued[4]]; - pt[5]->v[tau[0]] = vx[taued[1]] ; pt[5]->v[tau[1]] = vx[taued[3]] ; pt[5]->v[tau[3]] = vx[taued[2]]; - xt[5].tag[taued[0]] = 0; xt[5].tag[taued[2]] = 0; - xt[5].tag[taued[4]] = 0; xt[5].tag[taued[5]] = 0; - xt[5].edg[taued[0]] = 0; xt[5].edg[taued[2]] = 0; - xt[5].edg[taued[4]] = 0; xt[5].edg[taued[5]] = 0; - xt[5].ref [ tau[0]] = 0; xt[5].ref [ tau[2]] = 0; - xt[5].ftag[ tau[0]] = 0; xt[5].ftag[ tau[2]] = 0; - MG_SET(xt[5].ori, tau[0]); MG_SET(xt[5].ori, tau[2]); + xt[4].tag[taued[0]] = 0; + xt[4].tag[taued[1]] = 0; + xt[4].tag[taued[2]] = 0; + xt[4].tag[taued[4]] = 0; + xt[4].tag[taued[5]] = 0; + + xt[4].edg[taued[0]] = 0; + xt[4].edg[taued[1]] = 0; + xt[4].edg[taued[2]] = 0; + xt[4].edg[taued[4]] = 0; + xt[4].edg[taued[5]] = 0; + + xt[4].ref[tau[1]] = 0; + xt[4].ref[tau[2]] = 0; + xt[4].ref[tau[3]] = 0; + + xt[4].ftag[tau[1]] = 0; + xt[4].ftag[tau[2]] = 0; + xt[4].ftag[tau[3]] = 0; + + MG_SET(xt[4].ori, tau[1]); + MG_SET(xt[4].ori, tau[2]); + MG_SET(xt[4].ori, tau[3]); + + pt[5]->v[tau[0]] = vx[taued[1]]; + pt[5]->v[tau[1]] = vx[taued[3]]; + pt[5]->v[tau[3]] = vx[taued[2]]; + + xt[5].tag[taued[0]] = 0; + xt[5].tag[taued[2]] = 0; + xt[5].tag[taued[4]] = 0; + xt[5].tag[taued[5]] = 0; + + xt[5].edg[taued[0]] = 0; + xt[5].edg[taued[2]] = 0; + xt[5].edg[taued[4]] = 0; + xt[5].edg[taued[5]] = 0; + + xt[5].ref[tau[0]] = 0; + xt[5].ref[tau[2]] = 0; + + xt[5].ftag[tau[0]] = 0; + xt[5].ftag[tau[2]] = 0; + + MG_SET(xt[5].ori, tau[0]); + MG_SET(xt[5].ori, tau[2]); } else { - pt[3]->v[tau[0]] = vx[taued[1]] ; pt[3]->v[tau[1]] = vx[taued[3]]; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].tag[taued[4]] = 0; xt[3].edg[taued[0]] = 0; - xt[3].edg[taued[2]] = 0; xt[3].edg[taued[4]] = 0; - xt[3].ref [ tau[2]] = 0; - xt[3].ftag[ tau[2]] = 0; + pt[3]->v[tau[0]] = vx[taued[1]]; + pt[3]->v[tau[1]] = vx[taued[3]]; + + xt[3].tag[taued[0]] = 0; + xt[3].tag[taued[2]] = 0; + xt[3].tag[taued[4]] = 0; + + xt[3].edg[taued[0]] = 0; + xt[3].edg[taued[2]] = 0; + xt[3].edg[taued[4]] = 0; + + xt[3].ref[tau[2]] = 0; + + xt[3].ftag[tau[2]] = 0; + MG_SET(xt[3].ori, tau[2]); - pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[2]] = vx[taued[1]]; - xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; - xt[4].tag[taued[3]] = 0; xt[4].tag[taued[4]] = 0; - xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; - xt[4].edg[taued[1]] = 0; xt[4].edg[taued[3]] = 0; - xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; - xt[4].ref [ tau[0]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; - xt[4].ftag[ tau[0]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; - MG_SET(xt[4].ori, tau[0]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); + pt[4]->v[tau[0]] = vx[taued[2]]; + pt[4]->v[tau[1]] = vx[taued[3]]; + pt[4]->v[tau[2]] = vx[taued[1]]; - pt[5]->v[tau[0]] = vx[taued[2]] ; pt[5]->v[tau[1]] = vx[taued[4]] ; pt[5]->v[tau[2]] = vx[taued[3]]; - xt[5].tag[taued[0]] = 0; xt[5].tag[taued[1]] = 0; - xt[5].tag[taued[3]] = 0; xt[5].tag[taued[5]] = 0; - xt[5].edg[taued[0]] = 0; xt[5].edg[taued[1]] = 0; - xt[5].edg[taued[3]] = 0; xt[5].edg[taued[5]] = 0; - xt[5].ref [ tau[1]] = 0; xt[5].ref [ tau[3]] = 0; - xt[5].ftag[ tau[1]] = 0; xt[5].ftag[ tau[3]] = 0; - MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); + xt[4].tag[taued[0]] = 0; + xt[4].tag[taued[1]] = 0; + xt[4].tag[taued[3]] = 0; + xt[4].tag[taued[4]] = 0; + xt[4].tag[taued[5]] = 0; + + xt[4].edg[taued[0]] = 0; + xt[4].edg[taued[1]] = 0; + xt[4].edg[taued[3]] = 0; + xt[4].edg[taued[4]] = 0; + xt[4].edg[taued[5]] = 0; + + xt[4].ref[tau[0]] = 0; + xt[4].ref[tau[2]] = 0; + xt[4].ref[tau[3]] = 0; + + xt[4].ftag[tau[0]] = 0; + xt[4].ftag[tau[2]] = 0; + xt[4].ftag[tau[3]] = 0; + + MG_SET(xt[4].ori, tau[0]); + MG_SET(xt[4].ori, tau[2]); + MG_SET(xt[4].ori, tau[3]); + + pt[5]->v[tau[0]] = vx[taued[2]]; + pt[5]->v[tau[1]] = vx[taued[4]]; + pt[5]->v[tau[2]] = vx[taued[3]]; + + xt[5].tag[taued[0]] = 0; + xt[5].tag[taued[1]] = 0; + xt[5].tag[taued[3]] = 0; + xt[5].tag[taued[5]] = 0; + + xt[5].edg[taued[0]] = 0; + xt[5].edg[taued[1]] = 0; + xt[5].edg[taued[3]] = 0; + xt[5].edg[taued[5]] = 0; + + xt[5].ref[tau[1]] = 0; + xt[5].ref[tau[3]] = 0; + + xt[5].ftag[tau[1]] = 0; + xt[5].ftag[tau[3]] = 0; + + MG_SET(xt[5].ori, tau[1]); + MG_SET(xt[5].ori, tau[3]); } if (!myrank) { From 57d8dcb45db5b7a83ffba7d852b3d30ebe30a791 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 11 Sep 2023 17:15:44 +0200 Subject: [PATCH 07/19] Split using global vertices --- src/mmg3d/libmmg3d_private.h | 1 + src/mmg3d/split_3d.c | 84 ++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 33 deletions(-) diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 358c4b3b8..f462155d8 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -333,6 +333,7 @@ int MMG3D_split3op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]) int MMG5_split3op(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6],int8_t); int MMG3D_split4sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); +void MMG3D_split4op_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4],const uint8_t **taued, uint8_t *imin01,uint8_t *imin23); int MMG3D_split4op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG5_split4op_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index bed1a58d2..2831b8a7a 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -2960,7 +2960,7 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int * */ static inline -void MMG3D_configSplit3op(MMG5_pTetra pt,MMG5_int vx[6],uint8_t tau[4], +void MMG3D_split3op_cfg(MMG5_pTetra pt,MMG5_int vx[6],uint8_t tau[4], const uint8_t **taued, uint8_t sym[4],uint8_t symed[6], uint8_t *ip0,uint8_t *ip1, @@ -3130,7 +3130,7 @@ int MMG3D_split3op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]) if ( vold < MMG5_EPSOK ) return 0; /* Set permutation /symmetry of vertices : generic case : 35 */ - MMG3D_configSplit3op(pt,vx,tau,&taued,sym,symed,&ip0,&ip1,&ip2,&ip3, + MMG3D_split3op_cfg(pt,vx,tau,&taued,sym,symed,&ip0,&ip1,&ip2,&ip3, &ie0,&ie1,&ie2,&ie3,&ie4,&ie5,&imin03,&imin12); memcpy(pt0,pt,sizeof(MMG5_Tetra)); @@ -3263,7 +3263,7 @@ int MMG5_split3op(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6],int newtet[0]=k; /* Set permutation /symmetry of vertices : generic case : 35 */ - MMG3D_configSplit3op(pt[0],vx,tau,&taued,sym,symed,&ip0,&ip1,&ip2,&ip3, + MMG3D_split3op_cfg(pt[0],vx,tau,&taued,sym,symed,&ip0,&ip1,&ip2,&ip3, &ie0,&ie1,&ie2,&ie3,&ie4,&ie5,&imin03,&imin12); pt[0]->flag = 0; @@ -3848,7 +3848,7 @@ MMG5_int MMG5_split4bar(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k,int8_t metRid * */ static inline -void MMG3D_configSplit4sf(MMG5_pTetra pt,MMG5_int vx[6],uint8_t tau[4], +void MMG3D_split4sf_cfg(MMG5_pTetra pt,MMG5_int vx[6],uint8_t tau[4], const uint8_t **taued, uint8_t *imin23,uint8_t *imin12) { tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; @@ -3939,7 +3939,7 @@ int MMG3D_split4sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]) if ( vold < MMG5_EPSOK ) return 0; /* Set permutation of vertices : reference configuration : 23 */ - MMG3D_configSplit4sf(pt,vx,tau,&taued,&imin23,&imin12); + MMG3D_split4sf_cfg(pt,vx,tau,&taued,&imin23,&imin12); /* Generic formulation of split of 4 edges (with 3 on same face) */ memcpy(pt0,pt,sizeof(MMG5_Tetra)); @@ -4042,7 +4042,7 @@ int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t newtet[0]=k; /* Set permutation of vertices : reference configuration : 23 */ - MMG3D_configSplit4sf(pt[0],vx,tau,&taued,&imin23,&imin12); + MMG3D_split4sf_cfg(pt[0],vx,tau,&taued,&imin23,&imin12); pt[0]->flag = 0; /* create 5 new tetras */ @@ -4218,6 +4218,44 @@ int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t return 1; } +/** + * \param flag initial tetra + * \param v index of tetra nodes + * \param tau vertices permutation + * \param taued edges permutation + * \param imin01 minimal index of vertices ip0 and ip1 + * \param imin23 minimal index of vertices ip2 and ip3 + * + * Set permutation of vertices for the split of 4 edges when on opposite edges. + * Reference configuration 30. + * + */ +inline +void MMG3D_split4op_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4], + const uint8_t **taued, uint8_t *imin01,uint8_t *imin23) { + + + /* Set permutation of vertices : reference configuration 30 */ + tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; + (*taued) = &MMG5_permedge[0][0]; + + switch(flag){ + case 45: + tau[0] = 1 ; tau[1] = 3 ; tau[2] = 2 ; tau[3] = 0; + (*taued) = &MMG5_permedge[5][0]; + break; + + case 51: + tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; + (*taued) = &MMG5_permedge[4][0]; + break; + } + + /* Determine the condition to choose the pattern of split to apply */ + *imin01 = (v[tau[0]] < v[tau[1]]) ? tau[0] : tau[1]; + *imin23 = (v[tau[2]] < v[tau[3]]) ? tau[2] : tau[3]; +} + /** * \param mesh pointer toward the mesh structure. * \param met pointer toward the metric structure. @@ -4592,14 +4630,14 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MMG5_xTetra xt[6]; MMG5_pxTetra pxt0; MMG5_int newtet[6]; - int8_t flg,firstxt,isxt[6],i,j,imin01,imin23,imin01_l,imin23_l; + int8_t flg,firstxt,isxt[6],i,j,imin01,imin23; uint8_t tau[4]; const uint8_t *taued; const int ne=6; /* Store the initial tetra and flag */ pt[0] = &mesh->tetra[k]; - flg = pt[0]->flag; + flg = pt[0]->flag; /* Reinitialize the flag of the initial tetra */ pt[0]->flag = 0; @@ -4607,28 +4645,9 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v /* Store the id of the initial tetra */ newtet[0] = k; - /* Set permutation of vertices : reference configuration 30 */ - tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; - taued = &MMG5_permedge[0][0]; - - switch(flg){ - case 45: - tau[0] = 1 ; tau[1] = 3 ; tau[2] = 2 ; tau[3] = 0; - taued = &MMG5_permedge[5][0]; - break; - - case 51: - tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; - taued = &MMG5_permedge[4][0]; - break; - } - - /* Determine the rotation to be done to split following the pattern */ - imin01 = (vGlobNum[tau[0]] < vGlobNum[tau[1]]) ? tau[0] : tau[1]; - imin23 = (vGlobNum[tau[2]] < vGlobNum[tau[3]]) ? tau[2] : tau[3]; - - imin01_l = ((pt[0])->v[tau[0]] < (pt[0])->v[tau[1]]) ? tau[0] : tau[1]; - imin23_l = ((pt[0])->v[tau[2]] < (pt[0])->v[tau[3]]) ? tau[2] : tau[3]; + /* Set permutation of vertices */ + // ACHTUNG : NOTE : This is fine when using Glob Num, not if we use pt->v + MMG3D_split4op_cfg(flg,vGlobNum,tau,&taued,&imin01,&imin23); /* Create 5 new tetras */ if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { @@ -4636,7 +4655,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v } if (!myrank) { - fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin01_l:: %d, imin23:: %d, imin23_l:: %d \n" + fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin23:: %d \n" " BEFORE :: \n" " pt[0].v %d-%d-%d-%d \n" " pt[1].v %d-%d-%d-%d \n" @@ -4644,8 +4663,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v " pt[3].v %d-%d-%d-%d \n" " pt[4].v %d-%d-%d-%d \n" " pt[5].v %d-%d-%d-%d \n", - tau[0],tau[1],tau[2],tau[3],taued[0], - imin01,imin01_l,imin23,imin23_l, + tau[0],tau[1],tau[2],tau[3],taued[0],imin01,imin23, pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], From 0897b020e2e8d7200681d6032a79d603822d26cc Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Tue, 12 Sep 2023 17:03:54 +0200 Subject: [PATCH 08/19] update gloabl split --- src/mmg3d/split_3d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 2831b8a7a..3a3e795e0 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -4252,8 +4252,8 @@ void MMG3D_split4op_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4], } /* Determine the condition to choose the pattern of split to apply */ - *imin01 = (v[tau[0]] < v[tau[1]]) ? tau[0] : tau[1]; - *imin23 = (v[tau[2]] < v[tau[3]]) ? tau[2] : tau[3]; + (*imin01) = (v[tau[0]] < v[tau[1]]) ? tau[0] : tau[1]; + (*imin23) = (v[tau[2]] < v[tau[3]]) ? tau[2] : tau[3]; } /** @@ -4632,7 +4632,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MMG5_int newtet[6]; int8_t flg,firstxt,isxt[6],i,j,imin01,imin23; uint8_t tau[4]; - const uint8_t *taued; + const uint8_t *taued=NULL; const int ne=6; /* Store the initial tetra and flag */ From 8904a877223e81cf1cb4275c95f2586b12195c69 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Thu, 14 Sep 2023 17:16:19 +0200 Subject: [PATCH 09/19] Modify split to have config function and using global numerotation --- src/mmg3d/libmmg3d_private.h | 3 + src/mmg3d/split_3d.c | 234 +++++++++++++++-------------------- 2 files changed, 101 insertions(+), 136 deletions(-) diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index f462155d8..414ea5c5d 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -314,11 +314,13 @@ int MMG3D_update_xtetra ( MMG5_pMesh mesh ); int MMG5_mmg3dChkmsh(MMG5_pMesh,int,MMG5_int); int MMG3D_setMeshSize_initData(MMG5_pMesh,MMG5_int,MMG5_int,MMG5_int,MMG5_int,MMG5_int,MMG5_int); int MMG3D_setMeshSize_alloc(MMG5_pMesh); +void MMG3D_split1_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued); int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp); int MMG5_split1_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG5_split1b(MMG5_pMesh,MMG5_pSol,int64_t*,int,MMG5_int,int,int8_t,int8_t); MMG5_int MMG5_splitedg(MMG5_pMesh mesh, MMG5_pSol met,MMG5_int iel, int iar, double crit); +uint8_t MMG3D_split2sf_cfg(MMG5_int flag,MMG5_int v[4],uint8_t *tau,const uint8_t **taued); int MMG3D_split2sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); @@ -326,6 +328,7 @@ int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split3_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); +void MMG3D_split3cone_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4],const uint8_t **taued, uint8_t *ia,uint8_t *ib); int MMG3D_split3cone_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG5_split3cone_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 3a3e795e0..997e3b5df 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -49,7 +49,7 @@ extern int8_t ddb; * splitted). * */ -static inline +inline void MMG3D_split1_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued) { /* default is case 1 */ @@ -1125,8 +1125,8 @@ int MMG5_split1b(MMG5_pMesh mesh, MMG5_pSol met,int64_t *list, int ret, MMG5_int * the i^th edge is splitted). * */ -static inline -uint8_t MMG3D_split2sf_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued,MMG5_pTetra pt) { +inline +uint8_t MMG3D_split2sf_cfg(MMG5_int flag,MMG5_int v[4],uint8_t *tau,const uint8_t **taued) { uint8_t imin; /* identity is case 48 */ @@ -1179,7 +1179,7 @@ uint8_t MMG3D_split2sf_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued,MMG5 break; } - imin = (pt->v[tau[1]] < pt->v[tau[2]]) ? tau[1] : tau[2] ; + imin = (v[tau[1]] < v[tau[2]]) ? tau[1] : tau[2] ; return imin; } @@ -1208,7 +1208,7 @@ int MMG3D_split2sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]){ if ( vold < MMG5_EPSOK ) return 0; - imin = MMG3D_split2sf_cfg(pt->flag,tau,&taued,pt); + imin = MMG3D_split2sf_cfg(pt->flag,pt->v,tau,&taued); /* Test orientation of the three tets to be created */ @@ -1370,7 +1370,7 @@ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t return 0; } - imin = MMG3D_split2sf_cfg(flg,tau,&taued,pt[0]); + imin = MMG3D_split2sf_cfg(flg,pt[0]->v,tau,&taued); /* Generic formulation for the split of 2 edges belonging to a common face */ pt[0]->v[tau[1]] = vx[taued[4]] ; pt[0]->v[tau[2]] = vx[taued[5]]; @@ -1496,7 +1496,7 @@ int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 MMG5_pxTetra pxt0; int i,flg; MMG5_int newtet[3]; - int8_t imin_l,imin,firstxt,isxt[3]; + int8_t imin,firstxt,isxt[3]; uint8_t tau[4]; const uint8_t *taued; const int ne=3; @@ -1511,27 +1511,14 @@ int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 return 0; } - imin_l = MMG3D_split2sf_cfg(flg,tau,&taued,pt[0]); + imin = MMG3D_split2sf_cfg(flg,vGlobNum,tau,&taued); - imin = (vGlobNum[tau[1]] < vGlobNum[tau[2]]) ? tau[1] : tau[2] ; - - // fprintf(stdout," MMG5_split2sf_GlobNum :: myrank %d, tetra %d; Flag %d \n" - // " vGlobNum %d-%d-%d-%d \n" - // " tau %d-%d-%d-%d, taued %d \n" - // " imin:: %d, imin_l:: %d \n" - // " BEFORE :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n", - // myrank,k,flg, - // vGlobNum[0],vGlobNum[1],vGlobNum[2],vGlobNum[3], - // tau[0],tau[1],tau[2],tau[3],taued[0], - // imin,imin_l, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + if (!myrank) { + fprintf(stdout," MMG5_split2sf_GlobNum :: tau %d-%d-%d-%d, taued %d, imin:: %d \n" + " Initial :: pt[0].v %d-%d-%d-%d \n", + tau[0],tau[1],tau[2],tau[3],taued[0],imin, + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3]); + } /* Generic formulation for the split of 2 edges belonging to a common face */ pt[0]->v[tau[1]] = vx[taued[4]] ; pt[0]->v[tau[2]] = vx[taued[5]]; @@ -1573,17 +1560,16 @@ int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 MG_SET(xt[2].ori, tau[2]); MG_SET(xt[2].ori, tau[3]); } - // fprintf(stdout," MMG5_split2sf_GlobNum :: myrank %d, tetra %d; Flag %d \n" - // " AFTER :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n", - // myrank,k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + if (!myrank) { + fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" + " pt[1].v %d-%d-%d-%d \n" + " pt[2].v %d-%d-%d-%d \n" + " pt[3].v %d-%d-%d-%d \n", + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], + pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], + pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], + pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + } /* Assignation of the xt fields to the appropriate tets */ isxt[0] = isxt[1] = isxt[2] = 0; @@ -2073,6 +2059,65 @@ int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m return 1; } +/** + * \param flag initial tetra + * \param v index of tetra nodes + * \param tau vertices permutation + * \param taued edges permutation + * \param ia first condition to choose the split + * \param ib second condition to choose the split + * + * Set permutation of vertices for the split of 3 edges in cone configuration. + * Reference configuration 7. + * + */ +inline +void MMG3D_split3cone_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4], + const uint8_t **taued, uint8_t *ia,uint8_t *ib) { + + + /* Set permutation of vertices : reference configuration 7 */ + tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; + (*taued) = &MMG5_permedge[0][0]; + + switch(flag) { + case 25: + tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; + (*taued) = &MMG5_permedge[4][0]; + break; + + case 42: + tau[0] = 2 ; tau[1] = 0 ; tau[2] = 1 ; tau[3] = 3; + (*taued) = &MMG5_permedge[6][0]; + break; + + case 52: + tau[0] = 3 ; tau[1] = 1 ; tau[2] = 0 ; tau[3] = 2; + (*taued) = &MMG5_permedge[10][0]; + break; + } + + /* Determine the condition to choose the pattern of split to apply */ + if ( v[tau[1]] < v[tau[2]] ) { + (*ia) = tau[1]; + (*ib) = tau[2]; + } + else { + (*ia) = tau[2]; + (*ib) = tau[1]; + } + + if ( v[tau[3]] < v[(*ia)] ) { + (*ib) = (*ia); + (*ia) = tau[3]; + } + else { + if ( v[tau[3]] < v[(*ib)] ) { + (*ib) = tau[3]; + } + } +} + /** * \param mesh pointer toward the mesh structure. * \param met pointer toward the metric structure. @@ -2603,7 +2648,7 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int MMG5_pxTetra pxt0; int i; MMG5_int newtet[4]; - int8_t flg,firstxt,isxt[4],ia,ib,ia_l,ib_l; + int8_t flg,firstxt,isxt[4],ia,ib; uint8_t tau[4]; const uint8_t *taued; const int ne=4; @@ -2618,85 +2663,15 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int return 0; } - /* Set permutation of vertices : reference configuration is 7 */ - tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; - taued = &MMG5_permedge[0][0]; - - switch(flg) { - case 25: - tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; - taued = &MMG5_permedge[4][0]; - break; - - case 42: - tau[0] = 2 ; tau[1] = 0 ; tau[2] = 1 ; tau[3] = 3; - taued = &MMG5_permedge[6][0]; - break; - - case 52: - tau[0] = 3 ; tau[1] = 1 ; tau[2] = 0 ; tau[3] = 2; - taued = &MMG5_permedge[10][0]; - break; - } - - /* Generic formulation of split of 3 edges in cone configuration (edges 0,1,2 splitted) */ - /* Fill ia,ib,ic so that pt->v[ia] < pt->v[ib] < pt->v[ic] */ - if ( (pt[0])->v[tau[1]] < (pt[0])->v[tau[2]] ) { - ia_l = tau[1]; - ib_l = tau[2]; - } - else { - ia_l = tau[2]; - ib_l = tau[1]; - } - - if ( (pt[0])->v[tau[3]] < (pt[0])->v[ia_l] ) { - ib_l = ia_l; - ia_l = tau[3]; - } - else { - if ( (pt[0])->v[tau[3]] < (pt[0])->v[ib_l] ) { - ib_l = tau[3]; - } - else { - } - } - - if ( vGlobNum[tau[1]] < vGlobNum[tau[2]] ) { - ia = tau[1]; - ib = tau[2]; - } - else { - ia = tau[2]; - ib = tau[1]; - } - - if ( vGlobNum[tau[3]] < vGlobNum[ia] ) { - ib = ia; - ia = tau[3]; - } - else { - if ( vGlobNum[tau[3]] < vGlobNum[ib] ) { - ib = tau[3]; - } - else { - } - } - + /* Set permutation of vertices */ + // ACHTUNG : NOTE : This is fine when using Glob Num, not fine if we use pt->v + MMG3D_split3cone_cfg(flg,vGlobNum,tau,&taued,&ia,&ib); if (!myrank) { - fprintf(stdout," MMG5_split3cone_GlobNum :: tau %d-%d-%d-%d, taued %d, ia:: %d, ia_l:: %d, ib:: %d, ib_l:: %d \n" - " BEFORE :: \n" - " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n", - tau[0],tau[1],tau[2],tau[3],taued[0], - ia,ia_l,ib,ib_l, - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); + fprintf(stdout," MMG5_split3cone_GlobNum :: tau %d-%d-%d-%d, taued %d, ia:: %d, ib:: %d \n" + " Initial :: pt[0].v %d-%d-%d-%d \n", + tau[0],tau[1],tau[2],tau[3],taued[0],ia,ib, + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3]); } pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; @@ -2856,8 +2831,7 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } if (!myrank) { - fprintf(stdout," AFTER :: \n" - " pt[0].v %d-%d-%d-%d \n" + fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" " pt[1].v %d-%d-%d-%d \n" " pt[2].v %d-%d-%d-%d \n" " pt[3].v %d-%d-%d-%d \n", @@ -4646,7 +4620,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v newtet[0] = k; /* Set permutation of vertices */ - // ACHTUNG : NOTE : This is fine when using Glob Num, not if we use pt->v + // ACHTUNG : NOTE : This is fine when using Glob Num, not fine if we use pt->v MMG3D_split4op_cfg(flg,vGlobNum,tau,&taued,&imin01,&imin23); /* Create 5 new tetras */ @@ -4655,21 +4629,10 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v } if (!myrank) { - fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin23:: %d \n" - " BEFORE :: \n" - " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n" - " pt[4].v %d-%d-%d-%d \n" - " pt[5].v %d-%d-%d-%d \n", - tau[0],tau[1],tau[2],tau[3],taued[0],imin01,imin23, - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], - pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], - pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); + fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin23:: %d \n" + " Initial :: pt[0].v %d-%d-%d-%d \n", + tau[0],tau[1],tau[2],tau[3],taued[0],imin01,imin23, + pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3]); } /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ @@ -4952,8 +4915,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v } if (!myrank) { - fprintf(stdout," AFTER :: \n" - " pt[0].v %d-%d-%d-%d \n" + fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" " pt[1].v %d-%d-%d-%d \n" " pt[2].v %d-%d-%d-%d \n" " pt[3].v %d-%d-%d-%d \n" From 496fa4b30602eaa30ea9b261056d924c56a06bda Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Tue, 19 Sep 2023 16:36:44 +0200 Subject: [PATCH 10/19] Modify print in split for debug convenience --- src/mmg3d/split_3d.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 997e3b5df..1fbbb4e34 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -1513,7 +1513,7 @@ int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 imin = MMG3D_split2sf_cfg(flg,vGlobNum,tau,&taued); - if (!myrank) { + if (myrank) { fprintf(stdout," MMG5_split2sf_GlobNum :: tau %d-%d-%d-%d, taued %d, imin:: %d \n" " Initial :: pt[0].v %d-%d-%d-%d \n", tau[0],tau[1],tau[2],tau[3],taued[0],imin, @@ -1560,7 +1560,7 @@ int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 MG_SET(xt[2].ori, tau[2]); MG_SET(xt[2].ori, tau[3]); } - if (!myrank) { + if (myrank) { fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" " pt[1].v %d-%d-%d-%d \n" " pt[2].v %d-%d-%d-%d \n" @@ -2667,7 +2667,7 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int // ACHTUNG : NOTE : This is fine when using Glob Num, not fine if we use pt->v MMG3D_split3cone_cfg(flg,vGlobNum,tau,&taued,&ia,&ib); - if (!myrank) { + if (myrank) { fprintf(stdout," MMG5_split3cone_GlobNum :: tau %d-%d-%d-%d, taued %d, ia:: %d, ib:: %d \n" " Initial :: pt[0].v %d-%d-%d-%d \n", tau[0],tau[1],tau[2],tau[3],taued[0],ia,ib, @@ -2830,7 +2830,7 @@ int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } } - if (!myrank) { + if (myrank) { fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" " pt[1].v %d-%d-%d-%d \n" " pt[2].v %d-%d-%d-%d \n" @@ -4628,7 +4628,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v return 0; } - if (!myrank) { + if (myrank) { fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin23:: %d \n" " Initial :: pt[0].v %d-%d-%d-%d \n", tau[0],tau[1],tau[2],tau[3],taued[0],imin01,imin23, @@ -4914,7 +4914,7 @@ int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MG_SET(xt[5].ori, tau[3]); } - if (!myrank) { + if (myrank) { fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" " pt[1].v %d-%d-%d-%d \n" " pt[2].v %d-%d-%d-%d \n" From 3e8f26c9fe0a7c4701e574287379126c8ea9587c Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Tue, 3 Oct 2023 17:25:06 +0200 Subject: [PATCH 11/19] Take into account Algiane feedbacks --- src/mmg3d/libmmg3d_private.h | 8 ++++---- src/mmg3d/split_3d.c | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 414ea5c5d..4bee309d6 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -317,13 +317,13 @@ int MMG3D_setMeshSize_alloc(MMG5_pMesh); void MMG3D_split1_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued); int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp); -int MMG5_split1_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG5_split1b(MMG5_pMesh,MMG5_pSol,int64_t*,int,MMG5_int,int,int8_t,int8_t); MMG5_int MMG5_splitedg(MMG5_pMesh mesh, MMG5_pSol met,MMG5_int iel, int iar, double crit); uint8_t MMG3D_split2sf_cfg(MMG5_int flag,MMG5_int v[4],uint8_t *tau,const uint8_t **taued); int MMG3D_split2sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); -int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split3_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); @@ -331,7 +331,7 @@ int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t) void MMG3D_split3cone_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4],const uint8_t **taued, uint8_t *ia,uint8_t *ib); int MMG3D_split3cone_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); -int MMG5_split3cone_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split3cone_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG3D_split3op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3op(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6],int8_t); int MMG3D_split4sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); @@ -339,7 +339,7 @@ int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_ void MMG3D_split4op_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4],const uint8_t **taued, uint8_t *imin01,uint8_t *imin23); int MMG3D_split4op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); -int MMG5_split4op_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split4op_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); int MMG3D_split5_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split5(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split6_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 1fbbb4e34..f52d4ad02 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -257,7 +257,7 @@ int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m * Split 1 edge of tetra \a k. * */ -int MMG5_split1_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank) { +int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank) { MMG5_pTetra pt,pt1; MMG5_xTetra xt,xt1; MMG5_pxTetra pxt0; @@ -431,6 +431,7 @@ int MMG3D_normalDeviation(MMG5_pMesh mesh , MMG5_int start, int8_t iface, int return ier; } + /** * \param mesh pointer toward the mesh structure. * \param met pointer toward the metric. @@ -1490,7 +1491,7 @@ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * Split of two edges that belong to a common face : 1 tetra becomes 3 * */ -int MMG5_split2sf_GlobNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank){ +int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank){ MMG5_pTetra pt[3]; MMG5_xTetra xt[3]; MMG5_pxTetra pxt0; @@ -2642,7 +2643,7 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 * Split 3 opposite edges in a tetra * */ -int MMG5_split3cone_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank){ +int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank){ MMG5_pTetra pt[4]; MMG5_xTetra xt[4]; MMG5_pxTetra pxt0; @@ -4599,7 +4600,7 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * Split 4 edges in a configuration when no 3 edges lie on the same face * */ -int MMG5_split4op_GlobNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank) { +int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank) { MMG5_pTetra pt[6]; MMG5_xTetra xt[6]; MMG5_pxTetra pxt0; @@ -5842,6 +5843,7 @@ int MMG3D_chksplit(MMG5_pMesh mesh, MMG5_pSol met,MMG5_int ip, } return 1; } + /** * \param mesh pointer toward the mesh structure. * \param met pointer toward the metric structure. From dd39ad08b873fff4b306793a4c969afe9fa0ce2b Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Fri, 13 Oct 2023 17:19:48 +0200 Subject: [PATCH 12/19] Clean comments for debug splits occuring in ParMmg --- src/mmg3d/libmmg3d_private.h | 8 ++--- src/mmg3d/split_3d.c | 66 +++--------------------------------- 2 files changed, 8 insertions(+), 66 deletions(-) diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 4bee309d6..4bfd00c07 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -317,13 +317,13 @@ int MMG3D_setMeshSize_alloc(MMG5_pMesh); void MMG3D_split1_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued); int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp); -int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp); int MMG5_split1b(MMG5_pMesh,MMG5_pSol,int64_t*,int,MMG5_int,int,int8_t,int8_t); MMG5_int MMG5_splitedg(MMG5_pMesh mesh, MMG5_pSol met,MMG5_int iel, int iar, double crit); uint8_t MMG3D_split2sf_cfg(MMG5_int flag,MMG5_int v[4],uint8_t *tau,const uint8_t **taued); int MMG3D_split2sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); -int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp); int MMG3D_split2_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split2(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split3_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); @@ -331,7 +331,7 @@ int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t) void MMG3D_split3cone_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4],const uint8_t **taued, uint8_t *ia,uint8_t *ib); int MMG3D_split3cone_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); -int MMG5_split3cone_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split3cone_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp); int MMG3D_split3op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split3op(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6],int8_t); int MMG3D_split4sf_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); @@ -339,7 +339,7 @@ int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_ void MMG3D_split4op_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4],const uint8_t **taued, uint8_t *imin01,uint8_t *imin23); int MMG3D_split4op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); -int MMG5_split4op_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp,MMG5_int myrank); +int MMG5_split4op_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp); int MMG3D_split5_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split5(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t); int MMG3D_split6_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index f52d4ad02..f682aaf31 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -257,7 +257,7 @@ int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m * Split 1 edge of tetra \a k. * */ -int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank) { +int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp) { MMG5_pTetra pt,pt1; MMG5_xTetra xt,xt1; MMG5_pxTetra pxt0; @@ -1491,7 +1491,7 @@ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * Split of two edges that belong to a common face : 1 tetra becomes 3 * */ -int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp, MMG5_int myrank){ +int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp){ MMG5_pTetra pt[3]; MMG5_xTetra xt[3]; MMG5_pxTetra pxt0; @@ -1514,13 +1514,6 @@ int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 imin = MMG3D_split2sf_cfg(flg,vGlobNum,tau,&taued); - if (myrank) { - fprintf(stdout," MMG5_split2sf_GlobNum :: tau %d-%d-%d-%d, taued %d, imin:: %d \n" - " Initial :: pt[0].v %d-%d-%d-%d \n", - tau[0],tau[1],tau[2],tau[3],taued[0],imin, - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3]); - } - /* Generic formulation for the split of 2 edges belonging to a common face */ pt[0]->v[tau[1]] = vx[taued[4]] ; pt[0]->v[tau[2]] = vx[taued[5]]; xt[0].tag[taued[0]] = 0; xt[0].tag[taued[1]] = 0; @@ -1561,17 +1554,6 @@ int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 MG_SET(xt[2].ori, tau[2]); MG_SET(xt[2].ori, tau[3]); } - if (myrank) { - fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n", - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); - } - /* Assignation of the xt fields to the appropriate tets */ isxt[0] = isxt[1] = isxt[2] = 0; for (i=0; i<4; i++) { @@ -2643,7 +2625,7 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 * Split 3 opposite edges in a tetra * */ -int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank){ +int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp){ MMG5_pTetra pt[4]; MMG5_xTetra xt[4]; MMG5_pxTetra pxt0; @@ -2668,13 +2650,6 @@ int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int // ACHTUNG : NOTE : This is fine when using Glob Num, not fine if we use pt->v MMG3D_split3cone_cfg(flg,vGlobNum,tau,&taued,&ia,&ib); - if (myrank) { - fprintf(stdout," MMG5_split3cone_GlobNum :: tau %d-%d-%d-%d, taued %d, ia:: %d, ib:: %d \n" - " Initial :: pt[0].v %d-%d-%d-%d \n", - tau[0],tau[1],tau[2],tau[3],taued[0],ia,ib, - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3]); - } - pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; @@ -2831,17 +2806,6 @@ int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } } - if (myrank) { - fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n", - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); - } - /* Assignation of the xt fields to the appropriate tets */ isxt[0] = isxt[1] = isxt[2] = isxt[3] = 0; @@ -4600,7 +4564,7 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * Split 4 edges in a configuration when no 3 edges lie on the same face * */ -int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp, MMG5_int myrank) { +int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp) { MMG5_pTetra pt[6]; MMG5_xTetra xt[6]; MMG5_pxTetra pxt0; @@ -4629,13 +4593,6 @@ int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v return 0; } - if (myrank) { - fprintf(stdout," MMG5_split4op_GlobNum :: tau %d-%d-%d-%d, taued %d, imin01:: %d, imin23:: %d \n" - " Initial :: pt[0].v %d-%d-%d-%d \n", - tau[0],tau[1],tau[2],tau[3],taued[0],imin01,imin23, - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3]); - } - /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ if ( imin01 == tau[0] ) { pt[0]->v[tau[2]] = vx[taued[3]]; @@ -4915,21 +4872,6 @@ int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v MG_SET(xt[5].ori, tau[3]); } - if (myrank) { - fprintf(stdout, " pt[0].v %d-%d-%d-%d \n" - " pt[1].v %d-%d-%d-%d \n" - " pt[2].v %d-%d-%d-%d \n" - " pt[3].v %d-%d-%d-%d \n" - " pt[4].v %d-%d-%d-%d \n" - " pt[5].v %d-%d-%d-%d \n", - pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3], - pt[4]->v[0],pt[4]->v[1],pt[4]->v[2],pt[4]->v[3], - pt[5]->v[0],pt[5]->v[1],pt[5]->v[2],pt[5]->v[3]); - } - /* Assignation of the xt fields to the appropriate tets */ memset(isxt,0,ne*sizeof(int8_t)); From e669076165d7b3a3cfbe29da00138694a7730f14 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 16 Oct 2023 13:22:57 +0200 Subject: [PATCH 13/19] Wrap the splits function used in ls for ParMmg convenience (to be able to use global indices of nodes to determine the split configuration) --- src/mmg3d/split_3d.c | 828 ++----------------------------------------- 1 file changed, 36 insertions(+), 792 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index f682aaf31..9745a94bd 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -128,121 +128,16 @@ int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]) { * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. * \param metRidTyp metric storage (classic or special) * - * \return 0 if fail, 1 otherwise - * * Split 1 edge of tetra \a k. * */ int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) { - MMG5_pTetra pt,pt1; - MMG5_xTetra xt,xt1; - MMG5_pxTetra pxt0; - MMG5_int iel; - int8_t i,isxt,isxt1; - uint8_t tau[4]; - const uint8_t *taued; + MMG5_pTetra pt; - /* create a new tetra */ + /* Tetra to be split */ pt = &mesh->tetra[k]; - iel = MMG3D_newElt(mesh); - if ( !iel ) { - MMG3D_TETRA_REALLOC(mesh,iel,mesh->gap, - fprintf(stderr,"\n ## Error: %s: unable to allocate" - " a new element.\n",__func__); - MMG5_INCREASE_MEM_MESSAGE(); - fprintf(stderr," Exit program.\n"); - return 0); - pt = &mesh->tetra[k]; - } - - pt1 = &mesh->tetra[iel]; - pt1 = memcpy(pt1,pt,sizeof(MMG5_Tetra)); - pxt0 = NULL; - if ( pt->xt ) { - pxt0 = &mesh->xtetra[pt->xt]; - memcpy(&xt,pxt0,sizeof(MMG5_xTetra)); - memcpy(&xt1,pxt0,sizeof(MMG5_xTetra)); - } - else { - memset(&xt,0,sizeof(MMG5_xTetra)); - memset(&xt1,0,sizeof(MMG5_xTetra)); - } - - MMG3D_split1_cfg(pt->flag,tau,&taued); - - /* Generic formulation of split of 1 edge */ - pt->v[tau[1]] = pt1->v[tau[0]] = vx[taued[0]]; - - if ( pt->xt ) { - /* Reset edge tag */ - xt.tag [taued[3]] = 0; xt.tag [taued[4]] = 0; - xt1.tag[taued[1]] = 0; xt1.tag[taued[2]] = 0; - xt.edg [taued[3]] = 0; xt.edg [taued[4]] = 0; - xt1.edg[taued[1]] = 0; xt1.edg[taued[2]] = 0; - xt.ref [ tau[0]] = 0; xt.ftag [ tau[0]] = 0; MG_SET( xt.ori, tau[0]); - xt1.ref[ tau[1]] = 0; xt1.ftag[ tau[1]] = 0; MG_SET(xt1.ori, tau[1]); - } - - pt->flag = pt1->flag = 0; - isxt = 0 ; - isxt1 = 0; - for (i=0; i<4; i++) { - if ( xt.ref[i] || xt.ftag[i] ) isxt = 1; - if ( xt1.ref[i] || xt1.ftag[i] ) isxt1 = 1; - if ( isxt && isxt1 ) goto nextstep1; - } - -nextstep1: - if ( pt->xt ) { - if ( isxt && !isxt1 ) { - pt1->xt = 0; - memcpy(pxt0,&xt,sizeof(MMG5_xTetra)); - } - else if ( !isxt && isxt1 ) { - pt1->xt = pt->xt; - pt->xt = 0; - pxt0 = &mesh->xtetra[pt1->xt]; - memcpy(pxt0,&xt1,sizeof(MMG5_xTetra)); - } - else if ( isxt && isxt1 ) { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - pxt0 = &mesh->xtetra[pt->xt]; - } - pt1->xt = mesh->xt; - assert ( pxt0 ); - memcpy(pxt0,&xt,sizeof(MMG5_xTetra)); - pxt0 = &mesh->xtetra[mesh->xt]; - assert ( pxt0 ); - memcpy(pxt0,&xt1,sizeof(MMG5_xTetra)); - } - else { - pt->xt = 0; - pt1->xt = 0; - } - } - /* Quality update */ - if ( (!metRidTyp) && met->m && met->size>1 ) { - pt->qual=MMG5_caltet33_ani(mesh,met,pt); - pt1->qual=MMG5_caltet33_ani(mesh,met,pt1); - } - else if ( (!met) || (!met->m) ) { - /* in ls mode + -A option, orcal calls caltet_ani that fails */ - pt->qual=MMG5_caltet_iso(mesh,met,pt); - pt1->qual=MMG5_caltet_iso(mesh,met,pt1); - } - else { - pt->qual=MMG5_orcal(mesh,met,k); - pt1->qual=MMG5_orcal(mesh,met,iel); - } - return 1; + return MMG5_split1_globNum(mesh,met,k,vx,pt->v,metRidTyp); } /** @@ -250,6 +145,7 @@ int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m * \param met pointer toward the metric structure. * \param k index of element to split. * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param vGlobNum vertices indices of the tetra k. * \param metRidTyp metric storage (classic or special) * * \return 0 if fail, 1 otherwise @@ -1345,138 +1241,16 @@ void MMG3D_update_qual(MMG5_pMesh mesh,MMG5_pSol met,const int ne, * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. * \param metRidTyp metric storage (classic or special) * - * \return 0 if fail, 1 otherwise - * * Split of two edges that belong to a common face : 1 tetra becomes 3 * */ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp){ - MMG5_pTetra pt[3]; - MMG5_xTetra xt[3]; - MMG5_pxTetra pxt0; - int i,flg; - MMG5_int newtet[3]; - int8_t imin,firstxt,isxt[3]; - uint8_t tau[4]; - const uint8_t *taued; - const int ne=3; - - pt[0] = &mesh->tetra[k]; - flg = pt[0]->flag; - pt[0]->flag = 0; - newtet[0]=k; - - /* Create 2 new tetra */ - if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { - return 0; - } - - imin = MMG3D_split2sf_cfg(flg,pt[0]->v,tau,&taued); - - /* Generic formulation for the split of 2 edges belonging to a common face */ - pt[0]->v[tau[1]] = vx[taued[4]] ; pt[0]->v[tau[2]] = vx[taued[5]]; - xt[0].tag[taued[0]] = 0; xt[0].tag[taued[1]] = 0; - xt[0].tag[taued[3]] = 0; xt[0].edg[taued[0]] = 0; - xt[0].edg[taued[1]] = 0; xt[0].edg[taued[3]] = 0; - xt[0].ref[ tau[3]] = 0; xt[0].ftag[ tau[3]] = 0; MG_SET(xt[0].ori, tau[3]); - - if ( imin == tau[1] ) { - pt[1]->v[tau[2]] = vx[taued[5]]; pt[1]->v[tau[3]] = vx[taued[4]]; - pt[2]->v[tau[3]] = vx[taued[5]]; - - xt[1].tag[taued[1]] = 0; xt[1].tag[taued[2]] = 0; - xt[1].tag[taued[3]] = 0; xt[1].tag[taued[5]] = 0; - xt[1].edg[taued[1]] = 0; xt[1].edg[taued[2]] = 0; - xt[1].edg[taued[3]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[1]] = 0; xt[1].ref [ tau[3]] = 0; - xt[1].ftag[ tau[1]] = 0; xt[1].ftag[ tau[3]] = 0; - MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[3]); - - xt[2].tag[taued[2]] = 0; xt[2].tag[taued[4]] = 0; - xt[2].edg[taued[2]] = 0; xt[2].edg[taued[4]] = 0; - xt[2].ref[ tau[2]] = 0; xt[2].ftag[ tau[2]] = 0; MG_SET(xt[2].ori, tau[2]); - } - else { - pt[1]->v[tau[3]] = vx[taued[4]]; - pt[2]->v[tau[1]] = vx[taued[4]]; pt[2]->v[tau[3]] = vx[taued[5]]; - - xt[1].tag[taued[2]] = 0; xt[1].tag[taued[5]] = 0; - xt[1].edg[taued[2]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref[ tau[1]] = 0; xt[1].ftag[ tau[1]] = 0; MG_SET(xt[1].ori, tau[1]); - - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[3]] = 0; xt[2].tag[taued[4]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[2]] = 0; - xt[2].edg[taued[3]] = 0; xt[2].edg[taued[4]] = 0; - xt[2].ref [ tau[2]] = 0; xt[2].ref [ tau[3]] = 0; - xt[2].ftag[ tau[2]] = 0; xt[2].ftag[ tau[3]] = 0; - MG_SET(xt[2].ori, tau[2]); MG_SET(xt[2].ori, tau[3]); - } - - /* Assignation of the xt fields to the appropriate tets */ - isxt[0] = isxt[1] = isxt[2] = 0; - for (i=0; i<4; i++) { - if ( xt[0].ref[i] || xt[0].ftag[i] ) isxt[0] = 1; - if ( xt[1].ref[i] || xt[1].ftag[i] ) isxt[1] = 1; - if ( xt[2].ref[i] || xt[2].ftag[i] ) isxt[2] = 1; - } - - if ( pt[0]->xt ) { - if ( isxt[0] ) { - memcpy(pxt0,&xt[0],sizeof(MMG5_xTetra)); - pt[1]->xt = pt[2]->xt = 0; - for (i=1; i<3; i++) { - if ( isxt[i] ) { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - } - pt[i]->xt = mesh->xt; - pxt0 = &mesh->xtetra[mesh->xt]; - memcpy(pxt0,&(xt[i]),sizeof(MMG5_xTetra)); - } - } - } - else { - firstxt = 1; - pt[1]->xt = pt[2]->xt = 0; - for (i=1; i<3; i++) { - if ( isxt[i] ) { - if ( firstxt ) { - firstxt = 0; - pt[i]->xt = pt[0]->xt; - pxt0 = &mesh->xtetra[pt[i]->xt]; - memcpy(pxt0,&(xt[i]),sizeof(MMG5_xTetra)); - } - else { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - } - pt[i]->xt = mesh->xt; - pxt0 = &mesh->xtetra[mesh->xt]; - memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); - } - } - } - pt[0]->xt = 0; - } - } + MMG5_pTetra pt; - /* Quality update */ - MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); + /* Tetra to be split */ + pt = &mesh->tetra[k]; - return 1; + return MMG5_split2sf_globNum(mesh,met,k,vx,pt->v,metRidTyp); } /** @@ -1484,6 +1258,7 @@ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * \param met pointer toward the metric structure. * \param k index of element to split. * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param vGlobNum vertices indices of the tetra k. * \param metRidTyp metric storage (classic or special) * * \return 0 if fail, 1 otherwise @@ -2288,344 +2063,32 @@ int MMG3D_split3cone_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6] * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. * \param metRidTyp metric storage (classic or special) * - * \return 0 if fail, 1 otherwise - * * Split 3 edge in cone configuration * */ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) { - MMG5_pTetra pt[4]; - MMG5_xTetra xt[4]; - MMG5_pxTetra pxt0; - int i; - MMG5_int newtet[4]; - int8_t flg,firstxt,isxt[4],ia,ib; - uint8_t tau[4]; - const uint8_t *taued; - const int ne=4; - - pt[0] = &mesh->tetra[k]; - flg = pt[0]->flag; - pt[0]->flag = 0; - newtet[0]=k; - - /* create 3 new tetras */ - if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { - return 0; - } - - /* Set permutation of vertices : reference configuration is 7 */ - tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; - taued = &MMG5_permedge[0][0]; - - switch(flg) { - case 25: - tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; - taued = &MMG5_permedge[4][0]; - break; - - case 42: - tau[0] = 2 ; tau[1] = 0 ; tau[2] = 1 ; tau[3] = 3; - taued = &MMG5_permedge[6][0]; - break; - - case 52: - tau[0] = 3 ; tau[1] = 1 ; tau[2] = 0 ; tau[3] = 2; - taued = &MMG5_permedge[10][0]; - break; - } - - /* Generic formulation of split of 3 edges in cone configuration (edges 0,1,2 splitted) */ - /* Fill ia,ib,ic so that pt->v[ia] < pt->v[ib] < pt->v[ic] */ - if ( (pt[0])->v[tau[1]] < (pt[0])->v[tau[2]] ) { - ia = tau[1]; - ib = tau[2]; - } - else { - ia = tau[2]; - ib = tau[1]; - } - - if ( (pt[0])->v[tau[3]] < (pt[0])->v[ia] ) { - ib = ia; - ia = tau[3]; - } - else { - if ( (pt[0])->v[tau[3]] < (pt[0])->v[ib] ) { - ib = tau[3]; - } - else { - } - } - - // fprintf(stdout," MMG5_split3cone :: tetra %d; Flag %d \n" - // " pt[0].v %d-%d-%d-%d \n" - // " tau %d-%d-%d-%d, taued %d \n" - // " ia:: %d, ib:: %d \n" - // " BEFORE :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n", - // k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // tau[0],tau[1],tau[2],tau[3],taued[0], - // ia,ib, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); - - pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; - xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; - xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; - xt[0].edg[taued[4]] = 0; xt[0].edg[taued[5]] = 0; - xt[0].ref [ tau[0]] = 0; - xt[0].ftag[ tau[0]] = 0; - MG_SET(xt[0].ori, tau[0]); - - if ( ia == tau[3] ) { - pt[1]->v[tau[0]] = vx[taued[2]] ; pt[1]->v[tau[1]] = vx[taued[0]] ; pt[1]->v[tau[2]] = vx[taued[1]]; - xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; xt[1].edg[taued[3]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[3]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[3]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[3]); - - if ( ib == tau[1] ) { - pt[2]->v[tau[0]] = vx[taued[0]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; - xt[2].tag[taued[1]] = 0; xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[3]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[1]] = 0; xt[2].edg[taued[2]] = 0; - xt[2].edg[taued[3]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[1]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[1]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[1]); - - pt[3]->v[tau[0]] = vx[taued[1]] ; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].edg[taued[0]] = 0; xt[3].edg[taued[2]] = 0; - xt[3].ref [ tau[2]] = 0; - xt[3].ftag[ tau[2]] = 0; - MG_SET(xt[3].ori, tau[2]); - } - else { - assert(ib == tau[2]); - - pt[2]->v[tau[0]] = vx[taued[1]] ; pt[2]->v[tau[1]] = vx[taued[0]] ; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[3]] = 0; xt[2].tag[taued[4]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[2]] = 0; - xt[2].edg[taued[3]] = 0; xt[2].edg[taued[4]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); - - pt[3]->v[tau[0]] = vx[taued[0]] ; - xt[3].tag[taued[1]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].edg[taued[1]] = 0; xt[3].edg[taued[2]] = 0; - xt[3].ref [ tau[1]] = 0; - xt[3].ftag[ tau[1]] = 0; - MG_SET(xt[3].ori, tau[1]); - } - } - - else if (ia == tau[2] ) { - pt[1]->v[tau[0]] = vx[taued[1]] ; pt[1]->v[tau[1]] = vx[taued[0]] ; pt[1]->v[tau[3]] = vx[taued[2]]; - xt[1].tag[taued[0]] = 0; xt[1].tag[taued[2]] = 0; - xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[2]] = 0; xt[1].edg[taued[3]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[2]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[2]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[2]); - - if ( ib == tau[3] ) { - pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[1]] = vx[taued[0]] ; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; - xt[2].tag[taued[3]] = 0; xt[2].tag[taued[4]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; - xt[2].edg[taued[3]] = 0; xt[2].edg[taued[4]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[3]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[3]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[3]); - - pt[3]->v[tau[0]] = vx[taued[0]] ; - xt[3].tag[taued[1]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].edg[taued[1]] = 0; xt[3].edg[taued[2]] = 0; - xt[3].ref [ tau[1]] = 0; - xt[3].ftag[ tau[1]] = 0; - MG_SET(xt[3].ori, tau[1]); - } - else { - assert(ib == tau[1]); - - pt[2]->v[tau[0]] = vx[taued[0]] ; pt[2]->v[tau[3]] = vx[taued[2]] ; - xt[2].tag[taued[1]] = 0; xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[1]] = 0; xt[2].edg[taued[2]] = 0; - xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[1]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[1]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[1]); - - pt[3]->v[tau[0]] = vx[taued[2]] ; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; - xt[3].edg[taued[0]] = 0; xt[3].edg[taued[1]] = 0; - xt[3].ref [ tau[3]] = 0; - xt[3].ftag[ tau[3]] = 0; - MG_SET(xt[3].ori, tau[3]); - } - } - else { - assert(ia == tau[1]); - - pt[1]->v[tau[0]] = vx[taued[0]] ; pt[1]->v[tau[2]] = vx[taued[1]] ; pt[1]->v[tau[3]] = vx[taued[2]]; - xt[1].tag[taued[1]] = 0; xt[1].tag[taued[2]] = 0; - xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[1]] = 0; - xt[1].edg[taued[2]] = 0; xt[1].edg[taued[3]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); - - if ( ib == tau[2] ) { - pt[2]->v[tau[0]] = vx[taued[1]] ; pt[2]->v[tau[3]] = vx[taued[2]] ; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[2]] = 0; - xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); - - pt[3]->v[tau[0]] = vx[taued[2]] ; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; - xt[3].edg[taued[0]] = 0; xt[3].edg[taued[1]] = 0; - xt[3].ref [ tau[3]] = 0; - xt[3].ftag[ tau[3]] = 0; - MG_SET(xt[3].ori, tau[3]); - } - else { - assert(ib == tau[3]); - - pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; - xt[2].tag[taued[3]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; - xt[2].edg[taued[3]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[3]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[3]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[3]); - - pt[3]->v[tau[0]] = vx[taued[1]] ; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].edg[taued[0]] = 0; xt[3].edg[taued[2]] = 0; - xt[3].ref [ tau[2]] = 0; - xt[3].ftag[ tau[2]] = 0; - MG_SET(xt[3].ori, tau[2]); - } - } - - // fprintf(stdout," MMG5_split3cone :: tetra %d; Flag %d \n" - // " AFTER :: \n" - // " pt[0].v %d-%d-%d-%d \n" - // " pt[1].v %d-%d-%d-%d \n" - // " pt[2].v %d-%d-%d-%d \n" - // " pt[3].v %d-%d-%d-%d \n", - // k,flg, - // pt[0]->v[0],pt[0]->v[1],pt[0]->v[2],pt[0]->v[3], - // pt[1]->v[0],pt[1]->v[1],pt[1]->v[2],pt[1]->v[3], - // pt[2]->v[0],pt[2]->v[1],pt[2]->v[2],pt[2]->v[3], - // pt[3]->v[0],pt[3]->v[1],pt[3]->v[2],pt[3]->v[3]); - - /* Assignation of the xt fields to the appropriate tets */ - isxt[0] = isxt[1] = isxt[2] = isxt[3] = 0; - - for (i=0; i<4; i++) { - int j; - for (j=0; jxt ) { - if ( isxt[0] ) { - memcpy(pxt0,&xt[0],sizeof(MMG5_xTetra)); - pt[1]->xt = pt[2]->xt = pt[3]->xt = 0; - for (i=1; i<4; i++) { - if ( isxt[i] ) { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - } - pt[i]->xt = mesh->xt; - pxt0 = &mesh->xtetra[mesh->xt]; - memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); - } - } - } - else { - firstxt = 1; - pt[1]->xt = pt[2]->xt = pt[3]->xt = 0; - for ( i=1; i<4; i++) { - if ( isxt[i] ) { - if ( firstxt ) { - firstxt = 0; - pt[i]->xt = pt[0]->xt; - pxt0 = &mesh->xtetra[(pt[i])->xt]; - memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); - } - else { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - } - pt[i]->xt = mesh->xt; - pxt0 = &mesh->xtetra[mesh->xt]; - memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); - } - } - } - (pt[0])->xt = 0; - } - } - - /* Quality update */ - MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); - - - return 1; -} - -/** - * \param mesh pointer toward the mesh structure. - * \param met pointer toward the metric structure. - * \param k index of element to split. - * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. - * \param metRidTyp metric storage (classic or special) - * - * \return 0 if fail, 1 otherwise - * - * Split 3 opposite edges in a tetra - * - */ -int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp){ + MMG5_pTetra pt; + + /* Tetra to be split */ + pt = &mesh->tetra[k]; + + return MMG5_split3cone_globNum(mesh,met,k,vx,pt->v,metRidTyp); +} + +/** + * \param mesh pointer toward the mesh structure. + * \param met pointer toward the metric structure. + * \param k index of element to split. + * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param vGlobNum vertices indices of the tetra k. + * \param metRidTyp metric storage (classic or special) + * + * \return 0 if fail, 1 otherwise + * + * Split 3 opposite edges in a tetra + * + */ +int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp){ MMG5_pTetra pt[4]; MMG5_xTetra xt[4]; MMG5_pxTetra pxt0; @@ -2647,7 +2110,6 @@ int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int } /* Set permutation of vertices */ - // ACHTUNG : NOTE : This is fine when using Glob Num, not fine if we use pt->v MMG3D_split3cone_cfg(flg,vGlobNum,tau,&taued,&ia,&ib); pt[0]->v[tau[1]] = vx[taued[0]] ; pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; @@ -4322,234 +3784,16 @@ int MMG3D_split4op_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]) * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. * \param metRidTyp metric storage (classic or special) * - * \return 0 if fail, 1 otherwise - * * Split 4 edges in a configuration when no 3 edges lie on the same face * */ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) { - MMG5_pTetra pt[6]; - MMG5_xTetra xt[6]; - MMG5_pxTetra pxt0; - MMG5_int newtet[6]; - int8_t flg,firstxt,isxt[6],i,j,imin01,imin23; - uint8_t tau[4]; - const uint8_t *taued; - const int ne=6; - - pt[0] = &mesh->tetra[k]; - flg = pt[0]->flag; - pt[0]->flag = 0; - newtet[0]=k; - - /* Set permutation of vertices : reference configuration 30 */ - tau[0] = 0 ; tau[1] = 1 ; tau[2] = 2 ; tau[3] = 3; - taued = &MMG5_permedge[0][0]; - - switch(flg){ - case 45: - tau[0] = 1 ; tau[1] = 3 ; tau[2] = 2 ; tau[3] = 0; - taued = &MMG5_permedge[5][0]; - break; - - case 51: - tau[0] = 1 ; tau[1] = 2 ; tau[2] = 0 ; tau[3] = 3; - taued = &MMG5_permedge[4][0]; - break; - } - - imin01 = ((pt[0])->v[tau[0]] < (pt[0])->v[tau[1]]) ? tau[0] : tau[1]; - imin23 = ((pt[0])->v[tau[2]] < (pt[0])->v[tau[3]]) ? tau[2] : tau[3]; - - /* create 5 new tetras */ - if ( !MMG3D_crea_newTetra(mesh,ne,newtet,pt,xt,&pxt0) ) { - return 0; - } - - /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ - if ( imin01 == tau[0] ) { - pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; - xt[0].tag[taued[1]] = 0; xt[0].tag[taued[5]] = 0; - xt[0].tag[taued[2]] = 0; xt[0].edg[taued[1]] = 0; - xt[0].edg[taued[5]] = 0; xt[0].edg[taued[2]] = 0; - xt[0].ref [ tau[1]] = 0; - xt[0].ftag[ tau[1]] = 0; - MG_SET(xt[0].ori, tau[1]); - - pt[1]->v[tau[1]] = vx[taued[4]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; - xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; xt[1].edg[taued[3]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[3]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[3]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[3]); - - pt[2]->v[tau[1]] = vx[taued[3]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; pt[2]->v[tau[3]] = vx[taued[2]]; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[3]] = 0; - xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[3]] = 0; - xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; - xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; - MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); - } - else { - pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; - xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; - xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; - xt[0].edg[taued[4]] = 0; xt[0].edg[taued[5]] = 0; - xt[0].ref [ tau[0]] = 0; - xt[0].ftag[ tau[0]] = 0; - MG_SET(xt[0].ori, tau[0]); - - pt[1]->v[tau[0]] = vx[taued[1]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; - xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[2]] = 0; xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; xt[1].edg[taued[2]] = 0; - xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; - xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[2]] = 0; - xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[2]] = 0; - MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[2]); - - pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[2]] = vx[taued[3]] ; pt[2]->v[tau[3]] = vx[taued[4]]; - xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; - xt[2].tag[taued[2]] = 0; xt[2].tag[taued[5]] = 0; - xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; - xt[2].edg[taued[2]] = 0; xt[2].edg[taued[5]] = 0; - xt[2].ref [ tau[1]] = 0; xt[2].ref [ tau[3]] = 0; - xt[2].ftag[ tau[1]] = 0; xt[2].ftag[ tau[3]] = 0; - MG_SET(xt[2].ori, tau[1]); MG_SET(xt[2].ori, tau[3]); - } - - if ( imin23 == tau[2] ) { - pt[3]->v[tau[0]] = vx[taued[2]] ; pt[3]->v[tau[1]] = vx[taued[4]]; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; - xt[3].tag[taued[3]] = 0; xt[3].edg[taued[0]] = 0; - xt[3].edg[taued[1]] = 0; xt[3].edg[taued[3]] = 0; - xt[3].ref [ tau[3]] = 0; - xt[3].ftag[ tau[3]] = 0; - MG_SET(xt[3].ori, tau[3]); - - pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[3]] = vx[taued[4]]; - xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; - xt[4].tag[taued[2]] = 0; xt[4].tag[taued[4]] = 0; - xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; - xt[4].edg[taued[1]] = 0; xt[4].edg[taued[2]] = 0; - xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; - xt[4].ref [ tau[1]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; - xt[4].ftag[ tau[1]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; - MG_SET(xt[4].ori, tau[1]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); - - pt[5]->v[tau[0]] = vx[taued[1]] ; pt[5]->v[tau[1]] = vx[taued[3]] ; pt[5]->v[tau[3]] = vx[taued[2]]; - xt[5].tag[taued[0]] = 0; xt[5].tag[taued[2]] = 0; - xt[5].tag[taued[4]] = 0; xt[5].tag[taued[5]] = 0; - xt[5].edg[taued[0]] = 0; xt[5].edg[taued[2]] = 0; - xt[5].edg[taued[4]] = 0; xt[5].edg[taued[5]] = 0; - xt[5].ref [ tau[0]] = 0; xt[5].ref [ tau[2]] = 0; - xt[5].ftag[ tau[0]] = 0; xt[5].ftag[ tau[2]] = 0; - MG_SET(xt[5].ori, tau[0]); MG_SET(xt[5].ori, tau[2]); - } - else { - pt[3]->v[tau[0]] = vx[taued[1]] ; pt[3]->v[tau[1]] = vx[taued[3]]; - xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; - xt[3].tag[taued[4]] = 0; xt[3].edg[taued[0]] = 0; - xt[3].edg[taued[2]] = 0; xt[3].edg[taued[4]] = 0; - xt[3].ref [ tau[2]] = 0; - xt[3].ftag[ tau[2]] = 0; - MG_SET(xt[3].ori, tau[2]); - - pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[2]] = vx[taued[1]]; - xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; - xt[4].tag[taued[3]] = 0; xt[4].tag[taued[4]] = 0; - xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; - xt[4].edg[taued[1]] = 0; xt[4].edg[taued[3]] = 0; - xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; - xt[4].ref [ tau[0]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; - xt[4].ftag[ tau[0]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; - MG_SET(xt[4].ori, tau[0]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); - - pt[5]->v[tau[0]] = vx[taued[2]] ; pt[5]->v[tau[1]] = vx[taued[4]] ; pt[5]->v[tau[2]] = vx[taued[3]]; - xt[5].tag[taued[0]] = 0; xt[5].tag[taued[1]] = 0; - xt[5].tag[taued[3]] = 0; xt[5].tag[taued[5]] = 0; - xt[5].edg[taued[0]] = 0; xt[5].edg[taued[1]] = 0; - xt[5].edg[taued[3]] = 0; xt[5].edg[taued[5]] = 0; - xt[5].ref [ tau[1]] = 0; xt[5].ref [ tau[3]] = 0; - xt[5].ftag[ tau[1]] = 0; xt[5].ftag[ tau[3]] = 0; - MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); - } - - /* Assignation of the xt fields to the appropriate tets */ - memset(isxt,0,ne*sizeof(int8_t)); - - for (i=0; i<4; i++) { - for(j=0;jxt ) { - if ( isxt[0] ) { - memcpy(pxt0,&xt[0],sizeof(MMG5_xTetra)); - pt[1]->xt = pt[2]->xt = pt[3]->xt = pt[4]->xt = pt[5]->xt = 0; - - for (i=1; i<6; i++) { - if ( isxt[i] ) { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - } - pt[i]->xt = mesh->xt; - pxt0 = &mesh->xtetra[mesh->xt]; - memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); - } - } - } - else { - firstxt = 1; - pt[1]->xt = pt[2]->xt = pt[3]->xt = pt[4]->xt = pt[5]->xt = 0; - - for (i=1; i<6; i++) { - if ( isxt[i] ) { - if ( firstxt ) { - firstxt = 0; - pt[i]->xt = pt[0]->xt; - pxt0 = &mesh->xtetra[ pt[i]->xt]; - memcpy(pxt0,&xt[i],sizeof(MMG5_xTetra)); - } - else { - mesh->xt++; - if ( mesh->xt > mesh->xtmax ) { - /* realloc of xtetras table */ - MMG5_TAB_RECALLOC(mesh,mesh->xtetra,mesh->xtmax,MMG5_GAP,MMG5_xTetra, - "larger xtetra table", - mesh->xt--; - fprintf(stderr," Exit program.\n"); - return 0); - } - pt[i]->xt = mesh->xt; - pxt0 = &mesh->xtetra[mesh->xt]; - memcpy(pxt0,&(xt[i]),sizeof(MMG5_xTetra)); - } - } - } - pt[0]->xt = 0; + MMG5_pTetra pt; - } - } - - /* Quality update */ - MMG3D_update_qual(mesh,met,ne,newtet,pt,metRidTyp); + /* Tetra to be split */ + pt = &mesh->tetra[k]; - return 1; + return MMG5_split4op_globNum(mesh,met,k,vx,pt->v,metRidTyp); } /** @@ -4557,6 +3801,7 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * \param met pointer toward the metric structure. * \param k index of element to split. * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. + * \param vGlobNum vertices indices of the tetra k. * \param metRidTyp metric storage (classic or special) * * \return 0 if fail, 1 otherwise @@ -4585,7 +3830,6 @@ int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int v newtet[0] = k; /* Set permutation of vertices */ - // ACHTUNG : NOTE : This is fine when using Glob Num, not fine if we use pt->v MMG3D_split4op_cfg(flg,vGlobNum,tau,&taued,&imin01,&imin23); /* Create 5 new tetras */ From a0ed52e7b48dcd36ced3c790cdce97700b92ceba Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 16 Oct 2023 14:44:58 +0200 Subject: [PATCH 14/19] Improve headers of functions --- src/mmg3d/split_3d.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 9745a94bd..7fb05ee15 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -1013,9 +1013,9 @@ int MMG5_split1b(MMG5_pMesh mesh, MMG5_pSol met,int64_t *list, int ret, MMG5_int /** * \param flag flag to detect the splitting configuration + * \param v indices of the tetra nodes * \param tau vertices permutation * \param taued edges permutation - * \param pt tetra in which the splitting is performed * * Compute vertices and edges permutation for the split of 2 edge along the same * face. The configuration flag is computed such as the i^th bit of flag is 1 if @@ -1081,7 +1081,6 @@ uint8_t MMG3D_split2sf_cfg(MMG5_int flag,MMG5_int v[4],uint8_t *tau,const uint8_ return imin; } - /** * \param mesh pointer toward the mesh structure. * \param met pointer toward the metric structure. @@ -1819,7 +1818,7 @@ int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m /** * \param flag initial tetra - * \param v index of tetra nodes + * \param v indices of the tetra nodes * \param tau vertices permutation * \param taued edges permutation * \param ia first condition to choose the split @@ -3621,7 +3620,7 @@ int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t /** * \param flag initial tetra - * \param v index of tetra nodes + * \param v indices of tetra nodes * \param tau vertices permutation * \param taued edges permutation * \param imin01 minimal index of vertices ip0 and ip1 From a963ebb87f8b0e31c0ca3dc08de395ac13c305ea Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 16 Oct 2023 15:01:48 +0200 Subject: [PATCH 15/19] Remove spaces between arguments --- src/mmg3d/split_3d.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 7fb05ee15..17ccb8855 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -1830,7 +1830,7 @@ int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m */ inline void MMG3D_split3cone_cfg(MMG5_int flag,MMG5_int v[4],uint8_t tau[4], - const uint8_t **taued, uint8_t *ia,uint8_t *ib) { + const uint8_t **taued,uint8_t *ia,uint8_t *ib) { /* Set permutation of vertices : reference configuration 7 */ @@ -2087,7 +2087,7 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 * Split 3 opposite edges in a tetra * */ -int MMG5_split3cone_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp){ +int MMG5_split3cone_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp){ MMG5_pTetra pt[4]; MMG5_xTetra xt[4]; MMG5_pxTetra pxt0; @@ -3808,7 +3808,7 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * Split 4 edges in a configuration when no 3 edges lie on the same face * */ -int MMG5_split4op_globNum(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, MMG5_int vx[6], MMG5_int vGlobNum[4], int8_t metRidTyp) { +int MMG5_split4op_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp) { MMG5_pTetra pt[6]; MMG5_xTetra xt[6]; MMG5_pxTetra pxt0; From 6b67fde0757ac0708bbd5fda425660ed3cc6934d Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 16 Oct 2023 15:05:59 +0200 Subject: [PATCH 16/19] Reverse formatting in split4op to comply with old formatting --- src/mmg3d/split_3d.c | 350 ++++++++++++------------------------------- 1 file changed, 93 insertions(+), 257 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 17ccb8855..067ac772b 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -3838,281 +3838,117 @@ int MMG5_split4op_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 /* Generic formulation for split of 4 edges, with no 3 edges lying on the same face */ if ( imin01 == tau[0] ) { - pt[0]->v[tau[2]] = vx[taued[3]]; - pt[0]->v[tau[3]] = vx[taued[4]]; - - xt[0].tag[taued[1]] = 0; - xt[0].tag[taued[2]] = 0; - xt[0].tag[taued[5]] = 0; - - xt[0].edg[taued[1]] = 0; - xt[0].edg[taued[2]] = 0; - xt[0].edg[taued[5]] = 0; - - xt[0].ref[tau[1]] = 0; - - xt[0].ftag[tau[1]] = 0; - + pt[0]->v[tau[2]] = vx[taued[3]] ; pt[0]->v[tau[3]] = vx[taued[4]]; + xt[0].tag[taued[1]] = 0; xt[0].tag[taued[5]] = 0; + xt[0].tag[taued[2]] = 0; xt[0].edg[taued[1]] = 0; + xt[0].edg[taued[5]] = 0; xt[0].edg[taued[2]] = 0; + xt[0].ref [ tau[1]] = 0; + xt[0].ftag[ tau[1]] = 0; MG_SET(xt[0].ori, tau[1]); - pt[1]->v[tau[1]] = vx[taued[4]]; - pt[1]->v[tau[2]] = vx[taued[3]]; - pt[1]->v[tau[3]] = vx[taued[2]]; - - xt[1].tag[taued[0]] = 0; - xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[3]] = 0; - xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; - - xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; - xt[1].edg[taued[3]] = 0; - xt[1].edg[taued[4]] = 0; - xt[1].edg[taued[5]] = 0; - - xt[1].ref[tau[0]] = 0; - xt[1].ref[tau[1]] = 0; - xt[1].ref[tau[3]] = 0; - - xt[1].ftag[tau[0]] = 0; - xt[1].ftag[tau[1]] = 0; - xt[1].ftag[tau[3]] = 0; - - MG_SET(xt[1].ori, tau[0]); - MG_SET(xt[1].ori, tau[1]); - MG_SET(xt[1].ori, tau[3]); - - pt[2]->v[tau[1]] = vx[taued[3]]; - pt[2]->v[tau[2]] = vx[taued[1]]; - pt[2]->v[tau[3]] = vx[taued[2]]; - - xt[2].tag[taued[0]] = 0; - xt[2].tag[taued[3]] = 0; - xt[2].tag[taued[4]] = 0; - xt[2].tag[taued[5]] = 0; - - xt[2].edg[taued[0]] = 0; - xt[2].edg[taued[3]] = 0; - xt[2].edg[taued[4]] = 0; - xt[2].edg[taued[5]] = 0; - - xt[2].ref[tau[0]] = 0; - xt[2].ref[tau[2]] = 0; - - xt[2].ftag[tau[0]] = 0; - xt[2].ftag[tau[2]] = 0; - - MG_SET(xt[2].ori, tau[0]); - MG_SET(xt[2].ori, tau[2]); + pt[1]->v[tau[1]] = vx[taued[4]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; + xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[3]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; xt[1].edg[taued[3]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[3]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[3]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[3]); + + pt[2]->v[tau[1]] = vx[taued[3]] ; pt[2]->v[tau[2]] = vx[taued[1]] ; pt[2]->v[tau[3]] = vx[taued[2]]; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[3]] = 0; + xt[2].tag[taued[4]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[3]] = 0; + xt[2].edg[taued[4]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[0]] = 0; xt[2].ref [ tau[2]] = 0; + xt[2].ftag[ tau[0]] = 0; xt[2].ftag[ tau[2]] = 0; + MG_SET(xt[2].ori, tau[0]); MG_SET(xt[2].ori, tau[2]); } else { - pt[0]->v[tau[2]] = vx[taued[1]]; - pt[0]->v[tau[3]] = vx[taued[2]]; - - xt[0].tag[taued[3]] = 0; - xt[0].tag[taued[4]] = 0; - xt[0].tag[taued[5]] = 0; - - xt[0].edg[taued[3]] = 0; - xt[0].edg[taued[4]] = 0; - xt[0].edg[taued[5]] = 0; - - xt[0].ref[tau[0]] = 0; - - xt[0].ftag[tau[0]] = 0; - + pt[0]->v[tau[2]] = vx[taued[1]] ; pt[0]->v[tau[3]] = vx[taued[2]]; + xt[0].tag[taued[3]] = 0; xt[0].tag[taued[4]] = 0; + xt[0].tag[taued[5]] = 0; xt[0].edg[taued[3]] = 0; + xt[0].edg[taued[4]] = 0; xt[0].edg[taued[5]] = 0; + xt[0].ref [ tau[0]] = 0; + xt[0].ftag[ tau[0]] = 0; MG_SET(xt[0].ori, tau[0]); - pt[1]->v[tau[0]] = vx[taued[1]]; - pt[1]->v[tau[2]] = vx[taued[3]]; - pt[1]->v[tau[3]] = vx[taued[2]]; - - xt[1].tag[taued[0]] = 0; - xt[1].tag[taued[1]] = 0; - xt[1].tag[taued[2]] = 0; - xt[1].tag[taued[4]] = 0; - xt[1].tag[taued[5]] = 0; - - xt[1].edg[taued[0]] = 0; - xt[1].edg[taued[1]] = 0; - xt[1].edg[taued[2]] = 0; - xt[1].edg[taued[4]] = 0; - xt[1].edg[taued[5]] = 0; - - xt[1].ref[tau[0]] = 0; - xt[1].ref[tau[1]] = 0; - xt[1].ref[tau[2]] = 0; - - xt[1].ftag[tau[0]] = 0; - xt[1].ftag[tau[1]] = 0; - xt[1].ftag[tau[2]] = 0; - - MG_SET(xt[1].ori, tau[0]); - MG_SET(xt[1].ori, tau[1]); - MG_SET(xt[1].ori, tau[2]); - - pt[2]->v[tau[0]] = vx[taued[2]]; - pt[2]->v[tau[2]] = vx[taued[3]]; - pt[2]->v[tau[3]] = vx[taued[4]]; - - xt[2].tag[taued[0]] = 0; - xt[2].tag[taued[1]] = 0; - xt[2].tag[taued[2]] = 0; - xt[2].tag[taued[5]] = 0; - - xt[2].edg[taued[0]] = 0; - xt[2].edg[taued[1]] = 0; - xt[2].edg[taued[2]] = 0; - xt[2].edg[taued[5]] = 0; - - xt[2].ref[tau[1]] = 0; - xt[2].ref[tau[3]] = 0; - - xt[2].ftag[tau[1]] = 0; - xt[2].ftag[tau[3]] = 0; + pt[1]->v[tau[0]] = vx[taued[1]] ; pt[1]->v[tau[2]] = vx[taued[3]] ; pt[1]->v[tau[3]] = vx[taued[2]]; + xt[1].tag[taued[0]] = 0; xt[1].tag[taued[1]] = 0; + xt[1].tag[taued[2]] = 0; xt[1].tag[taued[4]] = 0; + xt[1].tag[taued[5]] = 0; xt[1].edg[taued[0]] = 0; + xt[1].edg[taued[1]] = 0; xt[1].edg[taued[2]] = 0; + xt[1].edg[taued[4]] = 0; xt[1].edg[taued[5]] = 0; + xt[1].ref [ tau[0]] = 0; xt[1].ref [ tau[1]] = 0; xt[1].ref [tau[2]] = 0; + xt[1].ftag[ tau[0]] = 0; xt[1].ftag[ tau[1]] = 0; xt[1].ftag[tau[2]] = 0; + MG_SET(xt[1].ori, tau[0]); MG_SET(xt[1].ori, tau[1]); MG_SET(xt[1].ori, tau[2]); - MG_SET(xt[2].ori, tau[1]); - MG_SET(xt[2].ori, tau[3]); + pt[2]->v[tau[0]] = vx[taued[2]] ; pt[2]->v[tau[2]] = vx[taued[3]] ; pt[2]->v[tau[3]] = vx[taued[4]]; + xt[2].tag[taued[0]] = 0; xt[2].tag[taued[1]] = 0; + xt[2].tag[taued[2]] = 0; xt[2].tag[taued[5]] = 0; + xt[2].edg[taued[0]] = 0; xt[2].edg[taued[1]] = 0; + xt[2].edg[taued[2]] = 0; xt[2].edg[taued[5]] = 0; + xt[2].ref [ tau[1]] = 0; xt[2].ref [ tau[3]] = 0; + xt[2].ftag[ tau[1]] = 0; xt[2].ftag[ tau[3]] = 0; + MG_SET(xt[2].ori, tau[1]); MG_SET(xt[2].ori, tau[3]); } if ( imin23 == tau[2] ) { - pt[3]->v[tau[0]] = vx[taued[2]]; - pt[3]->v[tau[1]] = vx[taued[4]]; - - xt[3].tag[taued[0]] = 0; - xt[3].tag[taued[1]] = 0; - xt[3].tag[taued[3]] = 0; - - xt[3].edg[taued[0]] = 0; - xt[3].edg[taued[1]] = 0; - xt[3].edg[taued[3]] = 0; - - xt[3].ref[tau[3]] = 0; - - xt[3].ftag[tau[3]] = 0; - + pt[3]->v[tau[0]] = vx[taued[2]] ; pt[3]->v[tau[1]] = vx[taued[4]]; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[1]] = 0; + xt[3].tag[taued[3]] = 0; xt[3].edg[taued[0]] = 0; + xt[3].edg[taued[1]] = 0; xt[3].edg[taued[3]] = 0; + xt[3].ref [ tau[3]] = 0; + xt[3].ftag[ tau[3]] = 0; MG_SET(xt[3].ori, tau[3]); - pt[4]->v[tau[0]] = vx[taued[2]]; - pt[4]->v[tau[1]] = vx[taued[3]]; - pt[4]->v[tau[3]] = vx[taued[4]]; - - xt[4].tag[taued[0]] = 0; - xt[4].tag[taued[1]] = 0; - xt[4].tag[taued[2]] = 0; - xt[4].tag[taued[4]] = 0; - xt[4].tag[taued[5]] = 0; - - xt[4].edg[taued[0]] = 0; - xt[4].edg[taued[1]] = 0; - xt[4].edg[taued[2]] = 0; - xt[4].edg[taued[4]] = 0; - xt[4].edg[taued[5]] = 0; - - xt[4].ref[tau[1]] = 0; - xt[4].ref[tau[2]] = 0; - xt[4].ref[tau[3]] = 0; - - xt[4].ftag[tau[1]] = 0; - xt[4].ftag[tau[2]] = 0; - xt[4].ftag[tau[3]] = 0; - - MG_SET(xt[4].ori, tau[1]); - MG_SET(xt[4].ori, tau[2]); - MG_SET(xt[4].ori, tau[3]); - - pt[5]->v[tau[0]] = vx[taued[1]]; - pt[5]->v[tau[1]] = vx[taued[3]]; - pt[5]->v[tau[3]] = vx[taued[2]]; - - xt[5].tag[taued[0]] = 0; - xt[5].tag[taued[2]] = 0; - xt[5].tag[taued[4]] = 0; - xt[5].tag[taued[5]] = 0; - - xt[5].edg[taued[0]] = 0; - xt[5].edg[taued[2]] = 0; - xt[5].edg[taued[4]] = 0; - xt[5].edg[taued[5]] = 0; - - xt[5].ref[tau[0]] = 0; - xt[5].ref[tau[2]] = 0; - - xt[5].ftag[tau[0]] = 0; - xt[5].ftag[tau[2]] = 0; + pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[3]] = vx[taued[4]]; + xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; + xt[4].tag[taued[2]] = 0; xt[4].tag[taued[4]] = 0; + xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; + xt[4].edg[taued[1]] = 0; xt[4].edg[taued[2]] = 0; + xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; + xt[4].ref [ tau[1]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; + xt[4].ftag[ tau[1]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; + MG_SET(xt[4].ori, tau[1]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); - MG_SET(xt[5].ori, tau[0]); - MG_SET(xt[5].ori, tau[2]); + pt[5]->v[tau[0]] = vx[taued[1]] ; pt[5]->v[tau[1]] = vx[taued[3]] ; pt[5]->v[tau[3]] = vx[taued[2]]; + xt[5].tag[taued[0]] = 0; xt[5].tag[taued[2]] = 0; + xt[5].tag[taued[4]] = 0; xt[5].tag[taued[5]] = 0; + xt[5].edg[taued[0]] = 0; xt[5].edg[taued[2]] = 0; + xt[5].edg[taued[4]] = 0; xt[5].edg[taued[5]] = 0; + xt[5].ref [ tau[0]] = 0; xt[5].ref [ tau[2]] = 0; + xt[5].ftag[ tau[0]] = 0; xt[5].ftag[ tau[2]] = 0; + MG_SET(xt[5].ori, tau[0]); MG_SET(xt[5].ori, tau[2]); } else { - pt[3]->v[tau[0]] = vx[taued[1]]; - pt[3]->v[tau[1]] = vx[taued[3]]; - - xt[3].tag[taued[0]] = 0; - xt[3].tag[taued[2]] = 0; - xt[3].tag[taued[4]] = 0; - - xt[3].edg[taued[0]] = 0; - xt[3].edg[taued[2]] = 0; - xt[3].edg[taued[4]] = 0; - - xt[3].ref[tau[2]] = 0; - - xt[3].ftag[tau[2]] = 0; - + pt[3]->v[tau[0]] = vx[taued[1]] ; pt[3]->v[tau[1]] = vx[taued[3]]; + xt[3].tag[taued[0]] = 0; xt[3].tag[taued[2]] = 0; + xt[3].tag[taued[4]] = 0; xt[3].edg[taued[0]] = 0; + xt[3].edg[taued[2]] = 0; xt[3].edg[taued[4]] = 0; + xt[3].ref [ tau[2]] = 0; + xt[3].ftag[ tau[2]] = 0; MG_SET(xt[3].ori, tau[2]); - pt[4]->v[tau[0]] = vx[taued[2]]; - pt[4]->v[tau[1]] = vx[taued[3]]; - pt[4]->v[tau[2]] = vx[taued[1]]; - - xt[4].tag[taued[0]] = 0; - xt[4].tag[taued[1]] = 0; - xt[4].tag[taued[3]] = 0; - xt[4].tag[taued[4]] = 0; - xt[4].tag[taued[5]] = 0; - - xt[4].edg[taued[0]] = 0; - xt[4].edg[taued[1]] = 0; - xt[4].edg[taued[3]] = 0; - xt[4].edg[taued[4]] = 0; - xt[4].edg[taued[5]] = 0; - - xt[4].ref[tau[0]] = 0; - xt[4].ref[tau[2]] = 0; - xt[4].ref[tau[3]] = 0; - - xt[4].ftag[tau[0]] = 0; - xt[4].ftag[tau[2]] = 0; - xt[4].ftag[tau[3]] = 0; - - MG_SET(xt[4].ori, tau[0]); - MG_SET(xt[4].ori, tau[2]); - MG_SET(xt[4].ori, tau[3]); - - pt[5]->v[tau[0]] = vx[taued[2]]; - pt[5]->v[tau[1]] = vx[taued[4]]; - pt[5]->v[tau[2]] = vx[taued[3]]; - - xt[5].tag[taued[0]] = 0; - xt[5].tag[taued[1]] = 0; - xt[5].tag[taued[3]] = 0; - xt[5].tag[taued[5]] = 0; - - xt[5].edg[taued[0]] = 0; - xt[5].edg[taued[1]] = 0; - xt[5].edg[taued[3]] = 0; - xt[5].edg[taued[5]] = 0; - - xt[5].ref[tau[1]] = 0; - xt[5].ref[tau[3]] = 0; - - xt[5].ftag[tau[1]] = 0; - xt[5].ftag[tau[3]] = 0; + pt[4]->v[tau[0]] = vx[taued[2]] ; pt[4]->v[tau[1]] = vx[taued[3]] ; pt[4]->v[tau[2]] = vx[taued[1]]; + xt[4].tag[taued[0]] = 0; xt[4].tag[taued[1]] = 0; + xt[4].tag[taued[3]] = 0; xt[4].tag[taued[4]] = 0; + xt[4].tag[taued[5]] = 0; xt[4].edg[taued[0]] = 0; + xt[4].edg[taued[1]] = 0; xt[4].edg[taued[3]] = 0; + xt[4].edg[taued[4]] = 0; xt[4].edg[taued[5]] = 0; + xt[4].ref [ tau[0]] = 0; xt[4].ref [ tau[2]] = 0; xt[4].ref [tau[3]] = 0; + xt[4].ftag[ tau[0]] = 0; xt[4].ftag[ tau[2]] = 0; xt[4].ftag[tau[3]] = 0; + MG_SET(xt[4].ori, tau[0]); MG_SET(xt[4].ori, tau[2]); MG_SET(xt[4].ori, tau[3]); - MG_SET(xt[5].ori, tau[1]); - MG_SET(xt[5].ori, tau[3]); + pt[5]->v[tau[0]] = vx[taued[2]] ; pt[5]->v[tau[1]] = vx[taued[4]] ; pt[5]->v[tau[2]] = vx[taued[3]]; + xt[5].tag[taued[0]] = 0; xt[5].tag[taued[1]] = 0; + xt[5].tag[taued[3]] = 0; xt[5].tag[taued[5]] = 0; + xt[5].edg[taued[0]] = 0; xt[5].edg[taued[1]] = 0; + xt[5].edg[taued[3]] = 0; xt[5].edg[taued[5]] = 0; + xt[5].ref [ tau[1]] = 0; xt[5].ref [ tau[3]] = 0; + xt[5].ftag[ tau[1]] = 0; xt[5].ftag[ tau[3]] = 0; + MG_SET(xt[5].ori, tau[1]); MG_SET(xt[5].ori, tau[3]); } /* Assignation of the xt fields to the appropriate tets */ From 5485e534de030b9e7bfcd9aad84d03c3df814302 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 16 Oct 2023 16:12:03 +0200 Subject: [PATCH 17/19] Modify type of function MMG5_hashGet_all --- src/common/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/hash.c b/src/common/hash.c index aa3e0ba8a..cae177441 100644 --- a/src/common/hash.c +++ b/src/common/hash.c @@ -570,7 +570,7 @@ MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { * otherwise, find the value stored in variable s. * */ -int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s) { +MMG5_int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s) { MMG5_hedge *ph; MMG5_int key; MMG5_int ia,ib; From 36584a22dc284871cb199163d791fbd0a163b842 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Tue, 17 Oct 2023 15:44:58 +0200 Subject: [PATCH 18/19] Fix type inconsistencies in split3d --- src/mmg3d/split_3d.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 067ac772b..59ef81231 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -1271,8 +1271,8 @@ int MMG5_split2sf_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 MMG5_pxTetra pxt0; int i,flg; MMG5_int newtet[3]; - int8_t imin,firstxt,isxt[3]; - uint8_t tau[4]; + int8_t firstxt,isxt[3]; + uint8_t tau[4],imin; const uint8_t *taued; const int ne=3; @@ -2093,8 +2093,8 @@ int MMG5_split3cone_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx MMG5_pxTetra pxt0; int i; MMG5_int newtet[4]; - int8_t flg,firstxt,isxt[4],ia,ib; - uint8_t tau[4]; + int8_t flg,firstxt,isxt[4]; + uint8_t tau[4],ia,ib; const uint8_t *taued; const int ne=4; @@ -3813,8 +3813,8 @@ int MMG5_split4op_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6 MMG5_xTetra xt[6]; MMG5_pxTetra pxt0; MMG5_int newtet[6]; - int8_t flg,firstxt,isxt[6],i,j,imin01,imin23; - uint8_t tau[4]; + int8_t flg,firstxt,isxt[6],i,j; + uint8_t tau[4],imin01,imin23; const uint8_t *taued=NULL; const int ne=6; From e418bf28af69ff00d8c0dc7ed3ee1fcbaed45113 Mon Sep 17 00:00:00 2001 From: laetitia-m Date: Mon, 6 Nov 2023 15:24:26 +0100 Subject: [PATCH 19/19] Modify PR to take into account remarks and feedback --- src/common/hash.c | 90 ++-------------------------------- src/common/mmgcommon_private.h | 2 - src/mmg3d/libmmg3d_private.h | 1 - src/mmg3d/split_3d.c | 34 +++---------- 4 files changed, 11 insertions(+), 116 deletions(-) diff --git a/src/common/hash.c b/src/common/hash.c index cae177441..99d4af530 100644 --- a/src/common/hash.c +++ b/src/common/hash.c @@ -397,6 +397,8 @@ int MMG5_hashEdge(MMG5_pMesh mesh,MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_in * \return 1 if success, 0 if fail (edge is not found). * * Update the index of the point stored along the edge \f$[a;b]\f$ + * \note In ParMmg, hash_pmmg.c: PMMG_hashUpdate_all updates k and s at the same time; + * \note PMMG_hashUpdate_all might be moved here if needed one day in mmg. * */ int MMG5_hashUpdate(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { @@ -424,47 +426,6 @@ int MMG5_hashUpdate(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k) { return 0; } -/** - * \param mesh pointer toward the mesh structure. - * \param hash pointer toward the hash table of edges. - * \param a index of the first extremity of the edge. - * \param b index of the second extremity of the edge. - * \param k index of new point along the edge [a,b]. - * \param s If ls mode in ParMmg:: index of new point in internal edge communicator; - * otherwise, the value stored in variable s. - * \return 1 if success, 0 if fail (edge is not found). - * - * Update the index of the new point stored along the edge \f$[a;b]\f$ - * If ls mode in ParMmg:: update the index of the new point in internal edge communicator; - * otherwise, update the value stored in variable s. - * - */ -int MMG5_hashUpdate_all(MMG5_Hash *hash, MMG5_int a,MMG5_int b,MMG5_int k,MMG5_int s) { - MMG5_hedge *ph; - MMG5_int key; - MMG5_int ia,ib; - - ia = MG_MIN(a,b); - ib = MG_MAX(a,b); - key = (MMG5_KA*(int64_t)ia + MMG5_KB*(int64_t)ib) % hash->siz; - ph = &hash->item[key]; - - while ( ph->a ) { - if ( ph->a == ia && ph->b == ib ) { - ph->k = k; - ph->s = s; - return 1; - } - - if ( !ph->nxt ) return 0; - - ph = &hash->item[ph->nxt]; - - } - - return 0; -} - /** * \param mesh pointer toward the mesh structure. * \param hash pointer toward the hash table of edges. @@ -532,7 +493,9 @@ int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash, MMG5_int a,MMG5_int b,int1 * \param b index of the second extremity of the edge. * \return the index of point stored along \f$[a;b]\f$. * - * Find the index of point stored along \f$[a;b]\f$. + * Find the index of point stored along \f$[a;b]\f$. + * \note In ParMmg, hash_pmmg.c: PMMG_hashGet_all gets k and s at the same time; + * \note PMMG_hashGet_all might be moved here if needed one day in mmg. * */ MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { @@ -556,49 +519,6 @@ MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b) { return 0; } -/** - * \param hash pointer toward the hash table of edges. - * \param a index of the first extremity of the edge. - * \param b index of the second extremity of the edge. - * \param k index of new point along the edge [a,b]. - * \param s If ls mode in ParMmg:: index of new point in internal edge communicator; - * otherwise, the value stored in variable s. - * \return 1 if success, 0 if fail (edge is not found). - * - * Find the index of the new point stored along the edge \f$[a;b]\f$ - * If ls mode in ParMmg:: find the index of the new point in internal edge communicator; - * otherwise, find the value stored in variable s. - * - */ -MMG5_int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s) { - MMG5_hedge *ph; - MMG5_int key; - MMG5_int ia,ib; - - if ( !hash->item ) return 0; - - ia = MG_MIN(a,b); - ib = MG_MAX(a,b); - key = (MMG5_KA*(int64_t)ia + MMG5_KB*(int64_t)ib) % hash->siz; - ph = &hash->item[key]; - - if ( !ph->a ) return 0; - if ( ph->a == ia && ph->b == ib ) { - *k = ph->k; - *s = ph->s; - return 1; - } - while ( ph->nxt ) { - ph = &hash->item[ph->nxt]; - if ( ph->a == ia && ph->b == ib ) { - *k = ph->k; - *s = ph->s; - return 1; - } - } - return 0; -} - /** * \param mesh pointer toward the mesh structure. * \param hash pointer toward the hash table of edges. diff --git a/src/common/mmgcommon_private.h b/src/common/mmgcommon_private.h index abbb76690..1e139dbac 100644 --- a/src/common/mmgcommon_private.h +++ b/src/common/mmgcommon_private.h @@ -676,10 +676,8 @@ typedef struct MMG5_iNode_s { MMG5_int MMG5_hashFace(MMG5_pMesh,MMG5_Hash*,MMG5_int,MMG5_int,MMG5_int,MMG5_int); int MMG5_hashEdge(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); int MMG5_hashUpdate(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k); - int MMG5_hashUpdate_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int k,MMG5_int s); int MMG5_hashEdgeTag(MMG5_pMesh mesh,MMG5_Hash *hash,MMG5_int a,MMG5_int b,int16_t k); MMG5_int MMG5_hashGet(MMG5_Hash *hash,MMG5_int a,MMG5_int b); - MMG5_int MMG5_hashGet_all(MMG5_Hash *hash,MMG5_int a,MMG5_int b,MMG5_int *k,MMG5_int *s); int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash,MMG5_int hsiz,MMG5_int hmax); int MMG5_intmetsavedir(MMG5_pMesh mesh, double *m,double *n,double *mr); int MMG5_intridmet(MMG5_pMesh,MMG5_pSol,MMG5_int,MMG5_int,double,double*,double*); diff --git a/src/mmg3d/libmmg3d_private.h b/src/mmg3d/libmmg3d_private.h index 4bfd00c07..3da1f2465 100644 --- a/src/mmg3d/libmmg3d_private.h +++ b/src/mmg3d/libmmg3d_private.h @@ -317,7 +317,6 @@ int MMG3D_setMeshSize_alloc(MMG5_pMesh); void MMG3D_split1_cfg(MMG5_int flag,uint8_t *tau,const uint8_t **taued); int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]); int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp); -int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp); int MMG5_split1b(MMG5_pMesh,MMG5_pSol,int64_t*,int,MMG5_int,int,int8_t,int8_t); MMG5_int MMG5_splitedg(MMG5_pMesh mesh, MMG5_pSol met,MMG5_int iel, int iar, double crit); uint8_t MMG3D_split2sf_cfg(MMG5_int flag,MMG5_int v[4],uint8_t *tau,const uint8_t **taued); diff --git a/src/mmg3d/split_3d.c b/src/mmg3d/split_3d.c index 59ef81231..ad138fa7a 100644 --- a/src/mmg3d/split_3d.c +++ b/src/mmg3d/split_3d.c @@ -132,28 +132,6 @@ int MMG3D_split1_sim(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6]) { * */ int MMG5_split1(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t metRidTyp) { - MMG5_pTetra pt; - - /* Tetra to be split */ - pt = &mesh->tetra[k]; - - return MMG5_split1_globNum(mesh,met,k,vx,pt->v,metRidTyp); -} - -/** - * \param mesh pointer toward the mesh structure. - * \param met pointer toward the metric structure. - * \param k index of element to split. - * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. - * \param vGlobNum vertices indices of the tetra k. - * \param metRidTyp metric storage (classic or special) - * - * \return 0 if fail, 1 otherwise - * - * Split 1 edge of tetra \a k. - * - */ -int MMG5_split1_globNum(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],MMG5_int vGlobNum[4],int8_t metRidTyp) { MMG5_pTetra pt,pt1; MMG5_xTetra xt,xt1; MMG5_pxTetra pxt0; @@ -1013,7 +991,7 @@ int MMG5_split1b(MMG5_pMesh mesh, MMG5_pSol met,int64_t *list, int ret, MMG5_int /** * \param flag flag to detect the splitting configuration - * \param v indices of the tetra nodes + * \param v indices of the tetra nodes (global node indices if called from ParMmg in ls mode) * \param tau vertices permutation * \param taued edges permutation * @@ -1257,7 +1235,7 @@ int MMG5_split2sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * \param met pointer toward the metric structure. * \param k index of element to split. * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. - * \param vGlobNum vertices indices of the tetra k. + * \param vGlobNum vertices indices of the tetra k (global node indices if called from ParMmg in ls mode). * \param metRidTyp metric storage (classic or special) * * \return 0 if fail, 1 otherwise @@ -1818,7 +1796,7 @@ int MMG5_split3(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t m /** * \param flag initial tetra - * \param v indices of the tetra nodes + * \param v indices of the tetra nodes (global node indices if called from ParMmg in ls mode) * \param tau vertices permutation * \param taued edges permutation * \param ia first condition to choose the split @@ -2079,7 +2057,7 @@ int MMG5_split3cone(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8 * \param met pointer toward the metric structure. * \param k index of element to split. * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. - * \param vGlobNum vertices indices of the tetra k. + * \param vGlobNum vertices indices of the tetra k (global node indices if called from ParMmg in ls mode). * \param metRidTyp metric storage (classic or special) * * \return 0 if fail, 1 otherwise @@ -3620,7 +3598,7 @@ int MMG5_split4sf(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t /** * \param flag initial tetra - * \param v indices of tetra nodes + * \param v indices of tetra nodes (global node indices if called from ParMmg in ls mode) * \param tau vertices permutation * \param taued edges permutation * \param imin01 minimal index of vertices ip0 and ip1 @@ -3800,7 +3778,7 @@ int MMG5_split4op(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,MMG5_int vx[6],int8_t * \param met pointer toward the metric structure. * \param k index of element to split. * \param vx \f$vx[i]\f$ is the index of the point to add on the edge \a i. - * \param vGlobNum vertices indices of the tetra k. + * \param vGlobNum vertices indices of the tetra k (global node indices if called from ParMmg in ls mode). * \param metRidTyp metric storage (classic or special) * * \return 0 if fail, 1 otherwise