Skip to content

Commit

Permalink
Add checks for mesh consistency in CMake Debug mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
Algiane committed Oct 25, 2024
1 parent cd157e1 commit fe69e60
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/libparmmg1.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,16 @@ int PMMG_parmmglib1( PMMG_pParMesh parmesh )

/** Set inputMet flag */
parmesh->info.inputMet = 0;

#ifndef NDEBUG
for ( i=0; i<parmesh->ngrp; ++i ) {
if ( !MMG5_chkmsh(parmesh->listgrp[i].mesh,1,1) ) {
fprintf(stderr," ## Problem. Invalid mesh.\n");
return 0;
}
}
#endif

for ( i=0; i<parmesh->ngrp; ++i ) {
met = parmesh->listgrp[i].met;
if ( met && met->m ) {
Expand Down
34 changes: 32 additions & 2 deletions src/loadbalancing_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,29 @@ int PMMG_loadBalancing(PMMG_pParMesh parmesh,int partitioning_mode) {
for ( igrp=0; igrp < parmesh->ngrp; igrp++ )
ne += parmesh->listgrp[igrp].mesh->ne;

int k;
#ifndef NDEBUG
for (k=0; k<parmesh->ngrp; ++k ) {
if ( !MMG5_chkmsh(parmesh->listgrp[k].mesh,1,1) ) {
fprintf(stderr," ## Problem. Invalid mesh.\n");
return 0;
}
}
#endif

if ( ier ) {
/** Split the ngrp groups of listgrp into a higher number of groups */
ier = PMMG_split_n2mGrps(parmesh,PMMG_GRPSPL_DISTR_TARGET,1,partitioning_mode);
}

for (int k=0; k<parmesh->ngrp; ++k ) {
#ifndef NDEBUG
for ( k=0; k<parmesh->ngrp; ++k ) {
if ( !MMG5_chkmsh(parmesh->listgrp[k].mesh,1,1) ) {
fprintf(stderr," ## Problem. Invalid mesh.\n");
return 0;
}
}

#endif

/* There is mpi comms in distribute_grps thus we don't want that one proc
* enters the function and not the other proc */
Expand All @@ -119,6 +130,16 @@ int PMMG_loadBalancing(PMMG_pParMesh parmesh,int partitioning_mode) {
chrono(ON,&(ctim[tim]));
}

#ifndef NDEBUG
int i;
for ( i=0; i<parmesh->ngrp; ++i ) {
if ( !MMG5_chkmsh(parmesh->listgrp[i].mesh,1,1) ) {
fprintf(stderr," ## Problem. Invalid mesh.\n");
return 0;
}
}
#endif

ier = PMMG_distribute_grps(parmesh,partitioning_mode);

if ( ier <= 0 ) {
Expand All @@ -142,6 +163,15 @@ int PMMG_loadBalancing(PMMG_pParMesh parmesh,int partitioning_mode) {
chrono(ON,&(ctim[tim]));
}

#ifndef NDEBUG
for ( int i=0; i<parmesh->ngrp; ++i ) {
if ( !MMG5_chkmsh(parmesh->listgrp[i].mesh,1,1) ) {
fprintf(stderr," ## Problem. Invalid mesh.\n");
return 0;
}
}
#endif

if ( ier ) {
/** Redistribute the ngrp groups of listgrp into a lower number of groups */
ier = PMMG_split_n2mGrps(parmesh,PMMG_GRPSPL_MMG_TARGET,0,partitioning_mode);
Expand Down

0 comments on commit fe69e60

Please sign in to comment.