From 7e8a2ddfc185d6eec979a8a049acdffb366e2a3c Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Tue, 29 Oct 2024 21:26:46 +0100 Subject: [PATCH] Fix memory issue in permutation array with scotch renum. --- cmake/testing/pmmg_tests.cmake | 6 ++++-- src/libparmmg1.c | 20 +++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cmake/testing/pmmg_tests.cmake b/cmake/testing/pmmg_tests.cmake index 13433163..d44979f8 100644 --- a/cmake/testing/pmmg_tests.cmake +++ b/cmake/testing/pmmg_tests.cmake @@ -788,13 +788,15 @@ IF( BUILD_TESTING ) foreach( MODE faces ) - # Toy geom nosplit: 2 procs, ls_val=0.0 + remesh hsiz 0.1 + 5 iter + multimat nosplit + # Toy geom nosplit: 2 procs, ls_val=0.0 + remesh hsiz 0.1 + 4 iter + multimat nosplit + ## Remark : FAIL inside mmg3d scotch renum of iter 5 if niter = 5 + SET( NP 2 ) add_test( NAME ls-DisIn-toygeom-nosplit-${MODE}-${NP} COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} ${NP} $ ${CI_DIR}/LevelSet/${NP}p_toygeom/cube-distributed-${MODE}-mat-edges.mesh -v 5 -f ${CI_DIR}/LevelSet/${NP}p_toygeom/nosplit.mmg3d - -hsiz 0.1 -niter 5 + -hsiz 0.1 -niter 4 -ls 0.0 -sol ${CI_DIR}/LevelSet/${NP}p_toygeom/cube-ls.sol -out ${CI_DIR_RESULTS}/ls-DisIn-toygeom-nosplit-${MODE}-${NP}.o.mesh) diff --git a/src/libparmmg1.c b/src/libparmmg1.c index 7439f97a..8fb56c50 100644 --- a/src/libparmmg1.c +++ b/src/libparmmg1.c @@ -630,6 +630,9 @@ int PMMG_parmmglib1( PMMG_pParMesh parmesh ) /** Reset the boundary fields between the old mesh size and the new one (Mmg * uses this fields assiming they are setted to 0)/ */ + + permNodGlob = NULL; + for ( i=0; ingrp; ++i ) { mesh = parmesh->listgrp[i].mesh; @@ -719,7 +722,13 @@ int PMMG_parmmglib1( PMMG_pParMesh parmesh ) #ifdef USE_SCOTCH /* Allocation of the array that will store the node permutation */ - PMMG_MALLOC(parmesh,permNodGlob,mesh->np+1,int,"node permutation", + // npi stores the number of points when we enter Mmg, np stores the + // number of points after adatptation. + // In theorie, here np == npi + + assert ( mesh->np == mesh->npi ); + + PMMG_MALLOC(parmesh,permNodGlob,mesh->npi+1,int,"node permutation", PMMG_scotch_message(&warnScotch) ); if ( permNodGlob ) { for ( k=1; k<=mesh->np; ++k ) { @@ -832,14 +841,15 @@ int PMMG_parmmglib1( PMMG_pParMesh parmesh ) goto strong_failed; } +#ifdef USE_SCOTCH + PMMG_DEL_MEM(parmesh,permNodGlob,int,"node permutation"); +#endif + if ( !ier ) { break; } + } /* Reset the mesh->gap field in case Mmg have modified it */ mesh->gap = MMG5_GAP; - -#ifdef USE_SCOTCH - PMMG_DEL_MEM(parmesh,permNodGlob,int,"node permutation"); -#endif } MPI_Allreduce( &ier, &ieresult, 1, MPI_INT, MPI_MIN, parmesh->comm );