Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid exits from MMG5_coltet() #257

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 36 additions & 31 deletions src/mmg3d/boulep_3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,41 +748,47 @@

/**
* \param mesh pointer to the mesh structure.
* \param start index of the starting tetra.
* \param ip index in \a start of the looked point.
* \param start index of the starting tetrahedron.
* \param ip index in \a start of the desired vertex.
* \param iface index in \a start of the starting face.
* \param listv pointer to the computed volumic ball.
* \param ilistv pointer to the computed volumic ball size.
* \param lists pointer to the computed surfacic ball.
* \param ilists pointer to the computed surfacic ball size.
* \param refmin return the reference of one of the two subdomains in presence
* \param refplus return the reference of the other subdomain in presence
* \param isnm is the looked point \a ip non-manifold?
* \return -1 if fail, 1 otherwise.
* \param isnm is the vertex non-manifold?
* \return 1 if succesful, a negative value if the ball cannot be computed:
* -1 if a surface ball had too many elements,
* -2 if there are more than two references around,
* -3 if an edge cannot be found, and
* -4 if a volume ball had too many elements.
* Among these, -1, -3 and -4 can be taken as a sign that further remeshing
* is not possible, while -2 just mean the job could not be done.
*
* Compute the volumic ball of a SURFACE point \a p, as well as its surfacic
* ball, starting from tetra \a start, with point \a ip, and face \a if in tetra
* ball, starting from tetra \a start, with point \a ip, and face \a if in the
* volumic ball.
* \a listv[k] = 4*number of tet + index of point surfacic ball.
* \a lists[k] = 4*number of tet + index of face.
*
* \warning Don't work for a non-manifold point if \a start has an adjacent
* through \a iface (for example : a non-manifold subdomain). Thus, if \a ip is
* \warning Doesn't work for a non-manifold point if \a start has an adjacent
* through \a iface (for example: a non-manifold subdomain). Thus, if \a ip is
* non-manifold, must be called only if \a start has no adjacent through iface.
*
*/
int MMG5_boulesurfvolpNom(MMG5_pMesh mesh,MMG5_int start,int ip,int iface,
int64_t *listv,int *ilistv,MMG5_int *lists,int *ilists,
MMG5_int *refmin,MMG5_int *refplus,int isnm)
int MMG5_boulesurfvolpNom(MMG5_pMesh mesh, MMG5_int start, int ip, int iface,
int64_t *listv, int *ilistv, MMG5_int *lists, int *ilists,
MMG5_int *refmin, MMG5_int *refplus, int isnm)
{
MMG5_pTetra pt,pt1;
MMG5_pTetra pt, pt1;
MMG5_pxTetra pxt;
MMG5_int k,k1,nump,*adja,piv,na,nb,adj,cur,nvstart,fstart,aux,base;
int8_t iopp,ipiv,i,j,l,isface;
MMG5_int k, k1, nump, *adja, piv, na, nb, adj, cur, nvstart, fstart, aux, base;
int8_t iopp, ipiv, i, j, l, isface;
static int8_t mmgErr0=0, mmgErr1=0, mmgErr2=0;

if ( isnm ) assert(!mesh->adja[4*(start-1)+iface+1]);

base = ++mesh->base;
*ilists = 0;
*ilistv = 0;
Expand Down Expand Up @@ -814,16 +820,15 @@
MMG3D_indPt(mesh,nump));
mmgErr0 = 1;
}

return -1;
}

aux = nb;
nb = piv;
piv = aux;
nvstart = k;
adj = k;

/* Now unfold shell of edge (na,nb) starting from k (included)*/
do {
k = adj;
Expand All @@ -835,22 +840,22 @@
assert(i<4);
listv[(*ilistv)] = 4*k+i;
(*ilistv)++;

/* Identify references of both subdomains in presence */
if ( *refmin == -1 )
*refmin = pt->ref;
else {
if ( *refplus == -1 ) {
if ( pt->ref != *refmin ) *refplus = pt->ref;
}
else if ( pt->ref != *refmin && pt->ref != *refplus ) return -1;
else if ( pt->ref != *refmin && pt->ref != *refplus ) return -2;

Check warning on line 851 in src/mmg3d/boulep_3d.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/boulep_3d.c#L851

Added line #L851 was not covered by tests
}
pt->flag = base;
}

/* identification of edge number in tetra k */
if ( !MMG3D_findEdge(mesh,pt,k,na,nb,0,&mmgErr2,&i) ) return -1;
if ( !MMG3D_findEdge(mesh,pt,k,na,nb,0,&mmgErr2,&i) ) return -3;

/* set sense of travel */
if ( pt->v[ MMG5_ifar[i][0] ] == piv ) {
iopp = MMG5_ifar[i][0];
Expand Down Expand Up @@ -878,14 +883,14 @@
while ( adj && (adj != nvstart) && !isface );
}
while ( 4*k+iopp != fstart );

/* Now, surfacic ball is complete ; finish travel of volumic ball */
cur = 0; // Check numerotation
while ( cur < (*ilistv) ) {
k = listv[cur]/4;
i = listv[cur]%4; // index of point p in tetra k
adja = &mesh->adja[4*(k-1)+1];

for (l=0; l<3; l++) {
i = MMG5_inxt3[i];
k1 = adja[i];
Expand All @@ -894,11 +899,11 @@
pt1 = &mesh->tetra[k1];
if ( pt1->flag == base ) continue;
pt1->flag = base;

for (j=0; j<4; j++)
if ( pt1->v[j] == nump ) break;
assert(j<4);

/* overflow */
if ( *ilistv > MMG3D_LMAX-3 ) {
if ( !mmgErr1 ) {
Expand All @@ -909,24 +914,24 @@
" or/and the maximum mesh.\n");
mmgErr1 = 1;
}
return -1;
return -4;

Check warning on line 917 in src/mmg3d/boulep_3d.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/boulep_3d.c#L917

Added line #L917 was not covered by tests
}
listv[(*ilistv)] = 4*k1+j;
(*ilistv)++;

/* Identify references of both subdomains in presence */
if ( *refmin == -1 )
*refmin = pt1->ref;
else {
if ( *refplus == -1 ) {
if ( pt1->ref != *refmin ) *refplus = pt1->ref;
}
else if ( pt1->ref != *refmin && pt1->ref != *refplus ) return -1;
else if ( pt1->ref != *refmin && pt1->ref != *refplus ) return -2;

Check warning on line 929 in src/mmg3d/boulep_3d.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/boulep_3d.c#L929

Added line #L929 was not covered by tests
}
}
cur++;
}

return 1;
}

Expand Down
39 changes: 25 additions & 14 deletions src/mmg3d/mmg3d1.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,12 +880,12 @@
* \param mesh pointer to the mesh structure.
* \param met pointer to the metric structure.
* \param typchk type of checking permformed for edge length (hmin or LSHORT criterion).
* \return -1 if failed, number of collapsed points otherwise.
* \return a negative value in case of failure, number of collapsed points otherwise.
*
* Attempt to collapse small edges.
* Attempt to collapse short edges.
*
*/
static int MMG5_coltet(MMG5_pMesh mesh,MMG5_pSol met,int8_t typchk) {
static MMG5_int MMG5_coltet(MMG5_pMesh mesh,MMG5_pSol met,int8_t typchk) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well seen!

MMG5_pTetra pt,ptloc;
MMG5_pxTetra pxt;
MMG5_pPoint p0,p1;
Expand All @@ -897,7 +897,7 @@
int l,kk,isloc,ifac1;
int16_t tag,isnm,isnmint;
int8_t i,j,ip,iq;
int ier;
int ier, bsret; // function return values/error codes

nc = nnm = 0;

Expand Down Expand Up @@ -963,15 +963,21 @@
}
else {
if ( mesh->adja[4*(k-1)+1+i] ) continue;
if (MMG5_boulesurfvolpNom(mesh,k,ip,i,
list,&ilist,lists,&ilists,&refmin,&refplus,p0->tag & MG_NOM) < 0 )
return -1;

bsret = MMG5_boulesurfvolpNom(mesh,k,ip,i,
list,&ilist,lists,&ilists,&refmin,&refplus,p0->tag & MG_NOM);

Check warning on line 968 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L967-L968

Added lines #L967 - L968 were not covered by tests
if(bsret==-1 || bsret==-3 || bsret==-4){
return -3; // fatal
}else if(bsret==-2){
continue; // ball computation failed: cannot handle this vertex

Check warning on line 972 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L970-L972

Added lines #L970 - L972 were not covered by tests
}
assert(bsret==1 && "unexpected return value from MMG5_boulesurfvolpNom");

Check warning on line 974 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L974

Added line #L974 was not covered by tests
}
}
else {
if (MMG5_boulesurfvolp(mesh,k,ip,i,
list,&ilist,lists,&ilists,p0->tag & MG_NOM) < 0 )
return -1;
return -2;

Check warning on line 980 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L980

Added line #L980 was not covered by tests
}
}
else {
Expand Down Expand Up @@ -1094,15 +1100,20 @@
}
else {
if ( mesh->adja[4*(k-1)+1+i] ) continue;
if (MMG5_boulesurfvolpNom(mesh,k,ip,i,
list,&ilist,lists,&ilists,&refmin,&refplus,p0->tag & MG_NOM) < 0 )
return -1;
bsret = MMG5_boulesurfvolpNom(mesh,k,ip,i,
list,&ilist,lists,&ilists,&refmin,&refplus,p0->tag & MG_NOM);
if(bsret==-1 || bsret==-3 || bsret==-4){
return -3; // fatal

Check warning on line 1106 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L1106

Added line #L1106 was not covered by tests
}else if(bsret==-2){
continue; // ball computation failed: cannot handle this vertex

Check warning on line 1108 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L1108

Added line #L1108 was not covered by tests
}
assert(bsret==1 && "unexpected return value from MMG5_boulesurfvolpNom");

Check warning on line 1110 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L1110

Added line #L1110 was not covered by tests
}
}
else {
if (MMG5_boulesurfvolp(mesh,k,ip,i,
list,&ilist,lists,&ilists,p0->tag & MG_NOM) < 0 )
return -1;
return -4;

Check warning on line 1116 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L1116

Added line #L1116 was not covered by tests
}
}
else {
Expand Down Expand Up @@ -1134,13 +1145,13 @@

if ( ilist > 0 ) {
ier = MMG5_colver(mesh,met,list,ilist,iq,typchk);
if ( ier < 0 ) return -1;
if ( ier < 0 ) return -5;
else if ( ier ) {
MMG3D_delPt(mesh,ier);
break;
}
}
else if (ilist < 0 ) return -1;
else if (ilist < 0 ) return -6;

Check warning on line 1154 in src/mmg3d/mmg3d1.c

View check run for this annotation

Codecov / codecov/patch

src/mmg3d/mmg3d1.c#L1154

Added line #L1154 was not covered by tests
}
if ( ier ) {
p1->flag = base;
Expand Down
Loading