Skip to content

Commit

Permalink
Merge pull request #285 from MmgTools/feature/pmmg-edge-tag-consistency
Browse files Browse the repository at this point in the history
Fix another issue with wrong edge tag update in `swap23`.
  • Loading branch information
coprigent authored Oct 24, 2024
2 parents 74fe1ce + 86de807 commit 37af05b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
19 changes: 11 additions & 8 deletions src/mmg3d/chkmsh_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ void MMG3D_chkmeshedgestags(MMG5_pMesh mesh) {
/* Travel mesh edges and hash boundary ones */
MMG5_hNew(mesh,&hash,nt,3*nt);

uint16_t ignored_tag = (~MG_PARBDYBDY) & (~MG_OLDPARBDY);

for (k=1; k<=mesh->ne; k++) {
pt = &mesh->tetra[k];
if ( !MG_EOK(pt) ) continue;
Expand All @@ -241,10 +243,11 @@ void MMG3D_chkmeshedgestags(MMG5_pMesh mesh) {

if ( !ier ) {
/* First time we meet the edge: store the its tag from the current
* tetra in the hash table. Ignore OLDPARBDY tag because it is not
* consistent through meshes inside ParMmg and forbid the use of the
* current function to check tag consistency if not ignored. */
int ier2 = MMG5_hEdge ( mesh,&hash,ip1,ip2,0,(pxt->tag[i] & ~MG_OLDPARBDY));
* tetra in the hash table. Ignore OLDPARBDY and PARBDYBDY tags
* because they are not consistent through meshes inside ParMmg and
* forbid the use of the current function to check tag consistency if
* not ignored. */
int ier2 = MMG5_hEdge ( mesh,&hash,ip1,ip2,0,(pxt->tag[i] & ignored_tag));
if ( !ier2 ) {
/* Realloc error */
fprintf(stderr,"Error: %s: %d: Unable to add to hash table the edge "
Expand All @@ -255,11 +258,11 @@ void MMG3D_chkmeshedgestags(MMG5_pMesh mesh) {
}
else {
/* Edge tag has been stored from another tet: check consistency.
Ignore OLDPARBDY tag because it is not
* consistent through meshes inside ParMmg and forbid the use of the
* current function to check tag consistency if not ignored.
Ignore OLDPARBDY and PARBDYBDY tags because they are not *
consistent through meshes inside ParMmg and forbid the use of the *
current function to check tag consistency if not ignored.
*/
if ( tag != (pxt->tag[i] & ~MG_OLDPARBDY) ) {
if ( tag != (pxt->tag[i] & ignored_tag) ) {
fprintf(stderr,"Error: %s: %d: Non consistency at tet %" MMG5_PRId
" (%" MMG5_PRId "), edge %d:%" MMG5_PRId "--%" MMG5_PRId "\n ",
__func__,__LINE__,k,MMG3D_indElt(mesh,k),i,ip1,ip2);
Expand Down
21 changes: 18 additions & 3 deletions src/mmg3d/swap_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,9 +744,9 @@ int MMG3D_swap23(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,int8_t metRidTyp,

np = pt1->v[tau1[0]];

MMG5_int ref[3] = {0};
uint16_t tag[3] = {0};
for (i=0;i<3;i++) {
MMG5_int ref[6] = {0};
uint16_t tag[6] = {0};
for (i=0;i<6;i++) {
if ( !MMG3D_get_shellEdgeTag(mesh,k1,taued1[i],&tag[i],&ref[i]) ) {
fprintf(stderr,"\n ## Error: %s: %d. unable to get edge info.\n",__func__,i);
return 0;
Expand Down Expand Up @@ -900,10 +900,15 @@ int MMG3D_swap23(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,int8_t metRidTyp,

xt[0].tag[taued0[3]] = tag[2];
xt[0].tag[taued0[4]] = tag[1];
/* As the edge tag of tetra 0 may be erroneous if the edge doesn't belong to
* a boundary face */
xt[0].tag[taued0[5]] = tag[5];


xt[0].edg[taued0[0]] = 0;
xt[0].edg[taued0[3]] = ref[2];
xt[0].edg[taued0[4]] = ref[1];
xt[0].edg[taued0[5]] = ref[5];

xt[0].ref[ tau0[0]] = pxt1->ref[tau1[1]];
xt[0].ref[ tau0[2]] = 0;
Expand All @@ -922,9 +927,14 @@ int MMG3D_swap23(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,int8_t metRidTyp,
xt[1].tag[taued0[3]] = tag[0];
xt[1].tag[taued0[5]] = tag[1];

/* As the edge tag of tetra 0 may be erroneous if the edge doesn't belong to
* a boundary face */
xt[1].tag[taued0[4]] = tag[3];

xt[1].edg[taued0[1]] = 0;
xt[1].edg[taued0[3]] = ref[0];
xt[1].edg[taued0[5]] = ref[1];
xt[1].edg[taued0[4]] = ref[3];

xt[1].ref[ tau0[0]] = pxt1->ref[tau1[3]];
xt[1].ref[ tau0[1]] = 0;
Expand All @@ -943,9 +953,14 @@ int MMG3D_swap23(MMG5_pMesh mesh,MMG5_pSol met,MMG5_int k,int8_t metRidTyp,
xt[2].tag[taued0[4]] = tag[0];
xt[2].tag[taued0[5]] = tag[2];

/* As the edge tag of tetra 0 may be erroneous if the edge doesn't belong to
* a boundary face */
xt[2].tag[taued0[3]] = tag[4];

xt[2].edg[taued0[2]] = 0;
xt[2].edg[taued0[4]] = ref[0];
xt[2].edg[taued0[5]] = ref[2];
xt[2].edg[taued0[3]] = ref[4];

xt[2].ref[ tau0[0]] = pxt1->ref[tau1[2]];
xt[2].ref[ tau0[1]] = 0;
Expand Down

0 comments on commit 37af05b

Please sign in to comment.