Skip to content

Commit

Permalink
Make mmg2d robust to the case where all triangles have been deleted.
Browse files Browse the repository at this point in the history
  • Loading branch information
Algiane committed Dec 5, 2023
1 parent 41b2e77 commit dd7dab0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/mmg2d/analys_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ int MMG2D_setadj(MMG5_pMesh mesh, int8_t init_cc) {
int16_t tag;
int8_t i,ii,i1,i2;

if ( !mesh->nt ) {
return 1;
}

if ( abs(mesh->info.imprim) > 5 || mesh->info.ddebug )
fprintf(stdout," ** SETTING TOPOLOGY\n");

Expand Down
4 changes: 2 additions & 2 deletions src/mmg2d/hash_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* \param mesh pointer toward the mesh
* \return 1 if success, 0 if fail
*
* Create adjacency relations between the triangles dein the mesh
* Create adjacency relations between the triangles in the mesh
*
*/
int MMG2D_hashTria(MMG5_pMesh mesh) {
Expand All @@ -40,7 +40,7 @@ int MMG2D_hashTria(MMG5_pMesh mesh) {
unsigned int key;

if ( mesh->adja ) return 1;
if ( !mesh->nt ) return 0;
if ( !mesh->nt ) return 1;

/* memory alloc */
MMG5_SAFE_CALLOC(hcode,mesh->nt+1,MMG5_int,return 0);
Expand Down
4 changes: 4 additions & 0 deletions src/mmg2d/length_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ int MMG2D_prilen(MMG5_pMesh mesh,MMG5_pSol sol) {
ibmax = 0;
nullEdge = 0;

if ( !mesh->nt ) {
return 0;
}

for (k=0; k<9; k++) hl[k] = 0;

for (k=1; k<=mesh->nt; k++) {
Expand Down
4 changes: 4 additions & 0 deletions src/mmg2d/quality_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ int MMG2D_outqua(MMG5_pMesh mesh,MMG5_pSol met) {
MMG5_int k,iel,ok,nex;
static int8_t mmgWarn0;

if ( !mesh->nt ) {
return 1;
}

/* Compute triangle quality*/
for (k=1; k<=mesh->nt; k++) {
pt = &mesh->tria[k];
Expand Down

0 comments on commit dd7dab0

Please sign in to comment.