From e7a9da821ed033d709793146da87fafc788ec4c4 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Tue, 16 Apr 2024 16:12:40 +0200 Subject: [PATCH 01/11] Introduced function PMMG_chkBdryTria --- src/analys_pmmg.c | 4 ++-- src/communicators_pmmg.c | 4 ++-- src/hash_pmmg.c | 49 ++++++++++++++++++++++++++++++++++++++++ src/libparmmg.c | 8 ++++--- src/parmmg.h | 5 ++-- 5 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/analys_pmmg.c b/src/analys_pmmg.c index 55726673..666cb59f 100644 --- a/src/analys_pmmg.c +++ b/src/analys_pmmg.c @@ -2327,7 +2327,7 @@ int PMMG_setdhd(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HGeom *pHash,MPI_Comm * * Check all boundary triangles. */ -int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh) { +int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh, MMG5_int *permtria) { int ier; /**--- stage 1: data structures for surface */ @@ -2362,7 +2362,7 @@ int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh) { } /* identify surface mesh */ - if ( !MMG5_chkBdryTria(mesh) ) { + if ( !PMMG_chkBdryTria(mesh,permtria) ) { fprintf(stderr,"\n ## Boundary problem. Exit program.\n"); return 0; } diff --git a/src/communicators_pmmg.c b/src/communicators_pmmg.c index 0a8e3b46..0e47bd35 100644 --- a/src/communicators_pmmg.c +++ b/src/communicators_pmmg.c @@ -849,7 +849,7 @@ void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ) { * - Store the index triplet in group communicator index 1, * - Tag corresponding triangle edges and nodes as PARBDY. */ -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ) { +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) { PMMG_pGrp grp; MMG5_pMesh mesh; MMG5_pTria ptt; @@ -866,7 +866,7 @@ void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ) { /* Process tria stored in index1 */ for( i=0; initem_int_face_comm; i++ ) { kt = grp->face2int_face_comm_index1[i]; - ptt = &mesh->tria[kt]; + ptt = &mesh->tria[permtria[kt]]; ie = ptt->cc/4; ifac = ptt->cc%4; diff --git a/src/hash_pmmg.c b/src/hash_pmmg.c index fc30f658..641f4675 100644 --- a/src/hash_pmmg.c +++ b/src/hash_pmmg.c @@ -275,6 +275,55 @@ int PMMG_bdryUpdate( MMG5_pMesh mesh ) return PMMG_SUCCESS; } +/** + * \param mesh pointer to the mesh structure. + * \return 1 if success, 0 otherwise. + * + * - Remove double triangles from tria array. + * + * - Remove triangles that do not belong to a boundary (non opnbdy mode) from + * tria array. + * + * - Check the matching between actual and given number of faces in the mesh: + * Count the number of faces in mesh and compare this number to the number of + * given triangles. + * + * - If the founded number exceed the given one, add the missing + * boundary triangles (call to MMG5_bdryTria). Do nothing otherwise. + * + * - Fill the adjacency relationship between prisms and tetra (fill adjapr with + * a negative value to mark this special faces). + * + * - Set to required the triangles at interface betwen prisms and tet. + * + */ +int PMMG_chkBdryTria(MMG5_pMesh mesh, MMG5_int* permtria) { + MMG5_int ntmesh,ntpres; + int ier; + MMG5_Hash hashElt; + + /** Step 1: scan the mesh and count the boundaries */ + ier = MMG5_chkBdryTria_countBoundaries(mesh,&ntmesh,&ntpres); + + /** Step 2: detect the extra boundaries (that will be ignored) provided by the + * user */ + if ( mesh->nt ) { + ier = MMG5_chkBdryTria_hashBoundaries(mesh,ntmesh,&hashElt); + // Travel through the tria, flag those that are not in the hash tab or + // that are stored more that once. + ier = MMG5_chkBdryTria_flagExtraTriangles(mesh,&ntpres,&hashElt); + // Delete flagged triangles + ier = MMG5_chkBdryTria_deleteExtraTriangles(mesh, permtria); + } + ntmesh +=ntpres; + + /** Step 3: add the missing boundary triangles or, if the mesh contains + * prisms, set to required the triangles at interface betwen prisms and tet */ + ier = MMG5_chkBdryTria_addMissingTriangles(mesh,ntmesh,ntpres); + + return 1; +} + /** * \param mesh pointer toward the mesh structure. * \param hash pointer toward the hash table of edges. diff --git a/src/libparmmg.c b/src/libparmmg.c index 4c6a3310..586bfdf1 100644 --- a/src/libparmmg.c +++ b/src/libparmmg.c @@ -243,6 +243,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) int8_t tim; char stim[32]; mytime ctim[TIMEMAX]; + MMG5_int *permtria; int ier = PMMG_SUCCESS; /* Chrono initialization */ @@ -342,8 +343,9 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) /** Mesh analysis I: Needed to create communicators * Check triangles, create xtetras */ + PMMG_CALLOC(parmesh,permtria,mesh->nt+1,MMG5_int,"permtria",return 0); if ( parmesh->myrank < parmesh->info.npartin ) { - if ( !PMMG_analys_tria(parmesh,mesh) ) { + if ( !PMMG_analys_tria(parmesh,mesh,permtria) ) { return PMMG_STRONGFAILURE; } } @@ -358,7 +360,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) * each tria), and tag xtetra face as PARBDY before the tag is transmitted * to edges and nodes */ if ( parmesh->myrank < parmesh->info.npartin ) { - PMMG_tria2elmFace_coords( parmesh ); + PMMG_tria2elmFace_coords( parmesh, permtria ); } /* 2) Build node communicators from face ones (here because the mesh needs * to be unscaled) */ @@ -409,7 +411,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) /** Mesh analysis Ib : After LS discretization * Check triangles, create xtetras */ if ( parmesh->myrank < parmesh->info.npartin ) { - if ( !PMMG_analys_tria(parmesh,mesh) ) { + if ( !PMMG_analys_tria(parmesh,mesh,permtria) ) { return PMMG_STRONGFAILURE; } } diff --git a/src/parmmg.h b/src/parmmg.h index 88941a4b..962d1330 100644 --- a/src/parmmg.h +++ b/src/parmmg.h @@ -445,7 +445,8 @@ void PMMG_Analys_Init_SurfNormIndex( MMG5_pTetra pt ); int PMMG_Analys_Get_SurfNormalIndex( MMG5_pTetra pt,int ifac,int i ); int PMMG_boulernm(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_Hash *hash,int start,int ip,int *ng,int *nr); int PMMG_boulen(PMMG_pParMesh parmesh,MMG5_pMesh mesh,int start,int ip,int iface,double t[3]); -int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh); +int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_int *permtria); +int PMMG_chkBdryTria(MMG5_pMesh mesh, MMG5_int* permtria); int PMMG_analys(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MPI_Comm comm); int PMMG_update_analys(PMMG_pParMesh parmesh); int PMMG_hashPar( MMG5_pMesh mesh,MMG5_HGeom *pHash ); @@ -511,7 +512,7 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_Compute_trianglesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_color_commNodes( PMMG_pParMesh parmesh,MPI_Comm comm ); void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ); -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ); +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ); int PMMG_tria_highestcoord( MMG5_pMesh mesh, MMG5_int *v_t); int PMMG_build_nodeCommIndex( PMMG_pParMesh parmesh ); int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ); From e347012b2df68db70523e5848a7f8c141744ec73 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Thu, 18 Apr 2024 15:40:20 +0200 Subject: [PATCH 02/11] Take into account deletion of extra triangles when building internal communicators --- src/communicators_pmmg.c | 15 ++++++++++----- src/libparmmg.c | 10 +++++++--- src/parmmg.h | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/communicators_pmmg.c b/src/communicators_pmmg.c index 0e47bd35..49b62066 100644 --- a/src/communicators_pmmg.c +++ b/src/communicators_pmmg.c @@ -849,7 +849,7 @@ void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ) { * - Store the index triplet in group communicator index 1, * - Tag corresponding triangle edges and nodes as PARBDY. */ -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) { +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ) { PMMG_pGrp grp; MMG5_pMesh mesh; MMG5_pTria ptt; @@ -866,7 +866,7 @@ void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) { /* Process tria stored in index1 */ for( i=0; initem_int_face_comm; i++ ) { kt = grp->face2int_face_comm_index1[i]; - ptt = &mesh->tria[permtria[kt]]; + ptt = &mesh->tria[kt]; ie = ptt->cc/4; ifac = ptt->cc%4; @@ -1008,7 +1008,7 @@ int PMMG_build_nodeCommIndex( PMMG_pParMesh parmesh ) { * stored in the external face communicator. * */ -int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ) { +int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh, MMG5_int* permtria ) { PMMG_pGrp grp; PMMG_pInt_comm int_face_comm; PMMG_pExt_comm ext_face_comm; @@ -1038,7 +1038,12 @@ int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ) { for( iext_comm = 0; iext_comm < parmesh->next_face_comm; iext_comm++ ) { ext_face_comm = &parmesh->ext_face_comm[iext_comm]; for( iext = 0; iext < ext_face_comm->nitem; iext++ ) { - grp->face2int_face_comm_index1[iint] = ext_face_comm->int_comm_index[iext]; + if (permtria) { + grp->face2int_face_comm_index1[iint] = permtria[ext_face_comm->int_comm_index[iext]]; + } + else { + grp->face2int_face_comm_index1[iint] = ext_face_comm->int_comm_index[iext]; + } grp->face2int_face_comm_index2[iint] = iint; ext_face_comm->int_comm_index[iext] = iint++; } @@ -1214,7 +1219,7 @@ int PMMG_build_faceCommFromNodes( PMMG_pParMesh parmesh,MPI_Comm comm ) { } /** 6) Set communicators indexing, convert tria index into iel face index */ - ier = PMMG_build_faceCommIndex( parmesh ); + ier = PMMG_build_faceCommIndex( parmesh, NULL ); PMMG_tria2elmFace_flags( parmesh ); diff --git a/src/libparmmg.c b/src/libparmmg.c index 586bfdf1..59df5c73 100644 --- a/src/libparmmg.c +++ b/src/libparmmg.c @@ -344,23 +344,26 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) /** Mesh analysis I: Needed to create communicators * Check triangles, create xtetras */ PMMG_CALLOC(parmesh,permtria,mesh->nt+1,MMG5_int,"permtria",return 0); + MMG5_int k; + for (k=0;k<=mesh->nt+1;k++) { + permtria[k] = k; + } if ( parmesh->myrank < parmesh->info.npartin ) { if ( !PMMG_analys_tria(parmesh,mesh,permtria) ) { return PMMG_STRONGFAILURE; } } - /* For both API modes, build communicators indices and set xtetra as PARBDY */ switch( parmesh->info.API_mode ) { case PMMG_APIDISTRIB_faces : /* 1) Set face communicators indexing */ - if( !PMMG_build_faceCommIndex( parmesh ) ) return 0; + if( !PMMG_build_faceCommIndex( parmesh, permtria ) ) return 0; /* Convert tria index into iel face index (it needs a valid cc field in * each tria), and tag xtetra face as PARBDY before the tag is transmitted * to edges and nodes */ if ( parmesh->myrank < parmesh->info.npartin ) { - PMMG_tria2elmFace_coords( parmesh, permtria ); + PMMG_tria2elmFace_coords( parmesh ); } /* 2) Build node communicators from face ones (here because the mesh needs * to be unscaled) */ @@ -385,6 +388,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) if ( !PMMG_build_faceCommFromNodes(parmesh,parmesh->info.read_comm) ) return PMMG_STRONGFAILURE; break; } + MMG5_SAFE_FREE( permtria ); /** Discretization of the isovalue */ if (mesh->info.iso) { diff --git a/src/parmmg.h b/src/parmmg.h index 962d1330..bdad2bc5 100644 --- a/src/parmmg.h +++ b/src/parmmg.h @@ -512,10 +512,10 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_Compute_trianglesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_color_commNodes( PMMG_pParMesh parmesh,MPI_Comm comm ); void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ); -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ); +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ); int PMMG_tria_highestcoord( MMG5_pMesh mesh, MMG5_int *v_t); int PMMG_build_nodeCommIndex( PMMG_pParMesh parmesh ); -int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ); +int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh, MMG5_int* permtria ); int PMMG_build_nodeCommFromFaces( PMMG_pParMesh parmesh, MPI_Comm comm ); int PMMG_build_faceCommFromNodes( PMMG_pParMesh parmesh, MPI_Comm comm ); int PMMG_build_simpleExtNodeComm( PMMG_pParMesh parmesh ); From d7c21d121487e0dd07cf0159b9167aac483a9613 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Thu, 25 Apr 2024 11:26:14 +0200 Subject: [PATCH 03/11] modified GIT_TAG to suitable mmg commit --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3011a98d..8082dea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -252,7 +252,7 @@ IF ( DOWNLOAD_MMG ) EXTERNALPROJECT_ADD ( Mmg GIT_REPOSITORY https://github.com/MmgTools/mmg.git - GIT_TAG 5788cf5b872d6f2e627b4279260ac39706d2a7f6 + GIT_TAG e89f046ce10e969b5d46af9eb058ec6dc43af2d8 INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install CMAKE_ARGS ${MMG_ARGS} -DUSE_ELAS=OFF ${COMPILER_CFG} ${FLAGS_CFG} ${SCOTCH_CFG} ${VTK_CFG} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} From 483875d3a0111dd5e8e61ab9cebc15afebef047c Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Wed, 31 Jul 2024 16:58:05 +0200 Subject: [PATCH 04/11] deleted workflow --- .github/workflows/long-tests.yml | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 .github/workflows/long-tests.yml diff --git a/.github/workflows/long-tests.yml b/.github/workflows/long-tests.yml deleted file mode 100644 index be864006..00000000 --- a/.github/workflows/long-tests.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Long tests - -on: - # run tests on push events - push: - # run tests on PR events - pull_request: - types: [opened, synchronize] - - # run tests manually on a given branch (default is master) - workflow_dispatch: - # Inputs the workflow accepts. - inputs: - branch: - # branch to test - description: 'branch to test' - # Default value if no value is explicitly provided - default: 'master' - required: false - -# job -jobs: - parmmg-debug: - uses: ./.github/workflows/main-job.yml - with: - cmake_build_type: RelWithAssert - add_cmake_cfg_args: - branch_name: ${{github.event.inputs.branch}} - code_coverage: true - secrets: inherit From b8c09599563d479b290f3ebf46fd4ad94c7d0ca3 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Wed, 31 Jul 2024 16:59:22 +0200 Subject: [PATCH 05/11] copied workflow back --- .github/workflows/long-tests.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/long-tests.yml diff --git a/.github/workflows/long-tests.yml b/.github/workflows/long-tests.yml new file mode 100644 index 00000000..be864006 --- /dev/null +++ b/.github/workflows/long-tests.yml @@ -0,0 +1,30 @@ +name: Long tests + +on: + # run tests on push events + push: + # run tests on PR events + pull_request: + types: [opened, synchronize] + + # run tests manually on a given branch (default is master) + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + branch: + # branch to test + description: 'branch to test' + # Default value if no value is explicitly provided + default: 'master' + required: false + +# job +jobs: + parmmg-debug: + uses: ./.github/workflows/main-job.yml + with: + cmake_build_type: RelWithAssert + add_cmake_cfg_args: + branch_name: ${{github.event.inputs.branch}} + code_coverage: true + secrets: inherit From 7a7994fb416256ebeb8f007dd60c3ec40d306ebe Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Tue, 16 Apr 2024 16:12:40 +0200 Subject: [PATCH 06/11] Introduced function PMMG_chkBdryTria --- src/analys_pmmg.c | 4 ++-- src/communicators_pmmg.c | 4 ++-- src/hash_pmmg.c | 49 ++++++++++++++++++++++++++++++++++++++++ src/libparmmg.c | 8 ++++--- src/parmmg.h | 5 ++-- 5 files changed, 61 insertions(+), 9 deletions(-) diff --git a/src/analys_pmmg.c b/src/analys_pmmg.c index 5e084eb0..2a56c56b 100644 --- a/src/analys_pmmg.c +++ b/src/analys_pmmg.c @@ -2403,7 +2403,7 @@ int PMMG_setdhd(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HGeom *pHash,MPI_Comm * * Check all boundary triangles. */ -int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh) { +int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh, MMG5_int *permtria) { int ier; /**--- stage 1: data structures for surface */ @@ -2438,7 +2438,7 @@ int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh) { } /* identify surface mesh */ - if ( !MMG5_chkBdryTria(mesh) ) { + if ( !PMMG_chkBdryTria(mesh,permtria) ) { fprintf(stderr,"\n ## Boundary problem. Exit program.\n"); return 0; } diff --git a/src/communicators_pmmg.c b/src/communicators_pmmg.c index ad18fb13..8e3eec5e 100644 --- a/src/communicators_pmmg.c +++ b/src/communicators_pmmg.c @@ -849,7 +849,7 @@ void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ) { * - Store the index triplet in group communicator index 1, * - Tag corresponding triangle edges and nodes as PARBDY. */ -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ) { +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) { PMMG_pGrp grp; MMG5_pMesh mesh; MMG5_pTria ptt; @@ -866,7 +866,7 @@ void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ) { /* Process tria stored in index1 */ for( i=0; initem_int_face_comm; i++ ) { kt = grp->face2int_face_comm_index1[i]; - ptt = &mesh->tria[kt]; + ptt = &mesh->tria[permtria[kt]]; ie = ptt->cc/4; ifac = ptt->cc%4; diff --git a/src/hash_pmmg.c b/src/hash_pmmg.c index fc30f658..641f4675 100644 --- a/src/hash_pmmg.c +++ b/src/hash_pmmg.c @@ -275,6 +275,55 @@ int PMMG_bdryUpdate( MMG5_pMesh mesh ) return PMMG_SUCCESS; } +/** + * \param mesh pointer to the mesh structure. + * \return 1 if success, 0 otherwise. + * + * - Remove double triangles from tria array. + * + * - Remove triangles that do not belong to a boundary (non opnbdy mode) from + * tria array. + * + * - Check the matching between actual and given number of faces in the mesh: + * Count the number of faces in mesh and compare this number to the number of + * given triangles. + * + * - If the founded number exceed the given one, add the missing + * boundary triangles (call to MMG5_bdryTria). Do nothing otherwise. + * + * - Fill the adjacency relationship between prisms and tetra (fill adjapr with + * a negative value to mark this special faces). + * + * - Set to required the triangles at interface betwen prisms and tet. + * + */ +int PMMG_chkBdryTria(MMG5_pMesh mesh, MMG5_int* permtria) { + MMG5_int ntmesh,ntpres; + int ier; + MMG5_Hash hashElt; + + /** Step 1: scan the mesh and count the boundaries */ + ier = MMG5_chkBdryTria_countBoundaries(mesh,&ntmesh,&ntpres); + + /** Step 2: detect the extra boundaries (that will be ignored) provided by the + * user */ + if ( mesh->nt ) { + ier = MMG5_chkBdryTria_hashBoundaries(mesh,ntmesh,&hashElt); + // Travel through the tria, flag those that are not in the hash tab or + // that are stored more that once. + ier = MMG5_chkBdryTria_flagExtraTriangles(mesh,&ntpres,&hashElt); + // Delete flagged triangles + ier = MMG5_chkBdryTria_deleteExtraTriangles(mesh, permtria); + } + ntmesh +=ntpres; + + /** Step 3: add the missing boundary triangles or, if the mesh contains + * prisms, set to required the triangles at interface betwen prisms and tet */ + ier = MMG5_chkBdryTria_addMissingTriangles(mesh,ntmesh,ntpres); + + return 1; +} + /** * \param mesh pointer toward the mesh structure. * \param hash pointer toward the hash table of edges. diff --git a/src/libparmmg.c b/src/libparmmg.c index 4c6a3310..586bfdf1 100644 --- a/src/libparmmg.c +++ b/src/libparmmg.c @@ -243,6 +243,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) int8_t tim; char stim[32]; mytime ctim[TIMEMAX]; + MMG5_int *permtria; int ier = PMMG_SUCCESS; /* Chrono initialization */ @@ -342,8 +343,9 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) /** Mesh analysis I: Needed to create communicators * Check triangles, create xtetras */ + PMMG_CALLOC(parmesh,permtria,mesh->nt+1,MMG5_int,"permtria",return 0); if ( parmesh->myrank < parmesh->info.npartin ) { - if ( !PMMG_analys_tria(parmesh,mesh) ) { + if ( !PMMG_analys_tria(parmesh,mesh,permtria) ) { return PMMG_STRONGFAILURE; } } @@ -358,7 +360,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) * each tria), and tag xtetra face as PARBDY before the tag is transmitted * to edges and nodes */ if ( parmesh->myrank < parmesh->info.npartin ) { - PMMG_tria2elmFace_coords( parmesh ); + PMMG_tria2elmFace_coords( parmesh, permtria ); } /* 2) Build node communicators from face ones (here because the mesh needs * to be unscaled) */ @@ -409,7 +411,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) /** Mesh analysis Ib : After LS discretization * Check triangles, create xtetras */ if ( parmesh->myrank < parmesh->info.npartin ) { - if ( !PMMG_analys_tria(parmesh,mesh) ) { + if ( !PMMG_analys_tria(parmesh,mesh,permtria) ) { return PMMG_STRONGFAILURE; } } diff --git a/src/parmmg.h b/src/parmmg.h index 57c6dd39..f058070f 100644 --- a/src/parmmg.h +++ b/src/parmmg.h @@ -447,7 +447,8 @@ void PMMG_Analys_Init_SurfNormIndex( MMG5_pTetra pt ); int PMMG_Analys_Get_SurfNormalIndex( MMG5_pTetra pt,int ifac,int i ); int PMMG_boulernm(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_Hash *hash,int start,int ip,int *ng,int *nr); int PMMG_boulen(PMMG_pParMesh parmesh,MMG5_pMesh mesh,int start,int ip,int iface,double t[3]); -int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh); +int PMMG_analys_tria(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_int *permtria); +int PMMG_chkBdryTria(MMG5_pMesh mesh, MMG5_int* permtria); int PMMG_analys(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MPI_Comm comm); int PMMG_update_analys(PMMG_pParMesh parmesh); int PMMG_hashPar( MMG5_pMesh mesh,MMG5_HGeom *pHash ); @@ -513,7 +514,7 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_Compute_trianglesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_color_commNodes( PMMG_pParMesh parmesh,MPI_Comm comm ); void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ); -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ); +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ); int PMMG_tria_highestcoord( MMG5_pMesh mesh, MMG5_int *v_t); int PMMG_build_nodeCommIndex( PMMG_pParMesh parmesh ); int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ); From 95683ec7e0b4934fabcfbc0f45a1f39e192029d9 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Thu, 18 Apr 2024 15:40:20 +0200 Subject: [PATCH 07/11] Take into account deletion of extra triangles when building internal communicators --- src/communicators_pmmg.c | 15 ++++++++++----- src/libparmmg.c | 10 +++++++--- src/parmmg.h | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/communicators_pmmg.c b/src/communicators_pmmg.c index 8e3eec5e..94b9518c 100644 --- a/src/communicators_pmmg.c +++ b/src/communicators_pmmg.c @@ -849,7 +849,7 @@ void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ) { * - Store the index triplet in group communicator index 1, * - Tag corresponding triangle edges and nodes as PARBDY. */ -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) { +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ) { PMMG_pGrp grp; MMG5_pMesh mesh; MMG5_pTria ptt; @@ -866,7 +866,7 @@ void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) { /* Process tria stored in index1 */ for( i=0; initem_int_face_comm; i++ ) { kt = grp->face2int_face_comm_index1[i]; - ptt = &mesh->tria[permtria[kt]]; + ptt = &mesh->tria[kt]; ie = ptt->cc/4; ifac = ptt->cc%4; @@ -1008,7 +1008,7 @@ int PMMG_build_nodeCommIndex( PMMG_pParMesh parmesh ) { * stored in the external face communicator. * */ -int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ) { +int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh, MMG5_int* permtria ) { PMMG_pGrp grp; PMMG_pInt_comm int_face_comm; PMMG_pExt_comm ext_face_comm; @@ -1038,7 +1038,12 @@ int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ) { for( iext_comm = 0; iext_comm < parmesh->next_face_comm; iext_comm++ ) { ext_face_comm = &parmesh->ext_face_comm[iext_comm]; for( iext = 0; iext < ext_face_comm->nitem; iext++ ) { - grp->face2int_face_comm_index1[iint] = ext_face_comm->int_comm_index[iext]; + if (permtria) { + grp->face2int_face_comm_index1[iint] = permtria[ext_face_comm->int_comm_index[iext]]; + } + else { + grp->face2int_face_comm_index1[iint] = ext_face_comm->int_comm_index[iext]; + } grp->face2int_face_comm_index2[iint] = iint; ext_face_comm->int_comm_index[iext] = iint++; } @@ -1214,7 +1219,7 @@ int PMMG_build_faceCommFromNodes( PMMG_pParMesh parmesh,MPI_Comm comm ) { } /** 6) Set communicators indexing, convert tria index into iel face index */ - ier = PMMG_build_faceCommIndex( parmesh ); + ier = PMMG_build_faceCommIndex( parmesh, NULL ); PMMG_tria2elmFace_flags( parmesh ); diff --git a/src/libparmmg.c b/src/libparmmg.c index 586bfdf1..59df5c73 100644 --- a/src/libparmmg.c +++ b/src/libparmmg.c @@ -344,23 +344,26 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) /** Mesh analysis I: Needed to create communicators * Check triangles, create xtetras */ PMMG_CALLOC(parmesh,permtria,mesh->nt+1,MMG5_int,"permtria",return 0); + MMG5_int k; + for (k=0;k<=mesh->nt+1;k++) { + permtria[k] = k; + } if ( parmesh->myrank < parmesh->info.npartin ) { if ( !PMMG_analys_tria(parmesh,mesh,permtria) ) { return PMMG_STRONGFAILURE; } } - /* For both API modes, build communicators indices and set xtetra as PARBDY */ switch( parmesh->info.API_mode ) { case PMMG_APIDISTRIB_faces : /* 1) Set face communicators indexing */ - if( !PMMG_build_faceCommIndex( parmesh ) ) return 0; + if( !PMMG_build_faceCommIndex( parmesh, permtria ) ) return 0; /* Convert tria index into iel face index (it needs a valid cc field in * each tria), and tag xtetra face as PARBDY before the tag is transmitted * to edges and nodes */ if ( parmesh->myrank < parmesh->info.npartin ) { - PMMG_tria2elmFace_coords( parmesh, permtria ); + PMMG_tria2elmFace_coords( parmesh ); } /* 2) Build node communicators from face ones (here because the mesh needs * to be unscaled) */ @@ -385,6 +388,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) if ( !PMMG_build_faceCommFromNodes(parmesh,parmesh->info.read_comm) ) return PMMG_STRONGFAILURE; break; } + MMG5_SAFE_FREE( permtria ); /** Discretization of the isovalue */ if (mesh->info.iso) { diff --git a/src/parmmg.h b/src/parmmg.h index f058070f..49573519 100644 --- a/src/parmmg.h +++ b/src/parmmg.h @@ -514,10 +514,10 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_Compute_trianglesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ); int PMMG_color_commNodes( PMMG_pParMesh parmesh,MPI_Comm comm ); void PMMG_tria2elmFace_flags( PMMG_pParMesh parmesh ); -void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ); +void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh ); int PMMG_tria_highestcoord( MMG5_pMesh mesh, MMG5_int *v_t); int PMMG_build_nodeCommIndex( PMMG_pParMesh parmesh ); -int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh ); +int PMMG_build_faceCommIndex( PMMG_pParMesh parmesh, MMG5_int* permtria ); int PMMG_build_nodeCommFromFaces( PMMG_pParMesh parmesh, MPI_Comm comm ); int PMMG_build_faceCommFromNodes( PMMG_pParMesh parmesh, MPI_Comm comm ); int PMMG_build_simpleExtNodeComm( PMMG_pParMesh parmesh ); From 70c60773f55f1fd0a44ef8250360d49404210b0e Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Mon, 2 Sep 2024 15:28:25 +0200 Subject: [PATCH 08/11] Fixed wrong index range --- src/libparmmg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libparmmg.c b/src/libparmmg.c index 59df5c73..a54ec25b 100644 --- a/src/libparmmg.c +++ b/src/libparmmg.c @@ -345,7 +345,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh ) * Check triangles, create xtetras */ PMMG_CALLOC(parmesh,permtria,mesh->nt+1,MMG5_int,"permtria",return 0); MMG5_int k; - for (k=0;k<=mesh->nt+1;k++) { + for (k=0;k<=mesh->nt;k++) { permtria[k] = k; } if ( parmesh->myrank < parmesh->info.npartin ) { From b69a7870a1e776f390068fba122f275129b6f987 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Tue, 3 Sep 2024 15:15:36 +0200 Subject: [PATCH 09/11] Added CI test for validating PR --- cmake/testing/pmmg_tests.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/testing/pmmg_tests.cmake b/cmake/testing/pmmg_tests.cmake index 08e73f60..5798c845 100644 --- a/cmake/testing/pmmg_tests.cmake +++ b/cmake/testing/pmmg_tests.cmake @@ -434,6 +434,13 @@ IF( BUILD_TESTING ) ${CI_DIR}/LevelSet/2p_toygeom/cube-distributed-faces-nomat-1edge.mesh -v 10 -hsiz 0.1 -out ${CI_DIR_RESULTS}/update-ref-tag.o.mesh) + # Test to check that when not using -opnbdy option, internal triangles are correctly removed. + # See ParMmg PR#110 + add_test( NAME extrainternaltriangles + COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 3 $ + ${CI_DIR}/Cube/internaltriangles-P3.mesh -v 10 + -out ${CI_DIR_RESULTS}/internaltriangles-P3.o.mesh) + ############################################################################### ##### ##### Test isovalue mode - ls discretization From 48862c0720e552ff32b79ba33b7824e1f3a0f2b3 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Tue, 3 Sep 2024 16:27:56 +0200 Subject: [PATCH 10/11] Modified commit tag of testparmmg --- cmake/testing/pmmg_tests.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/testing/pmmg_tests.cmake b/cmake/testing/pmmg_tests.cmake index 5798c845..da85754f 100644 --- a/cmake/testing/pmmg_tests.cmake +++ b/cmake/testing/pmmg_tests.cmake @@ -21,7 +21,7 @@ IF( BUILD_TESTING ) ENDIF() EXECUTE_PROCESS( COMMAND ${GIT_EXECUTABLE} -C ${CI_DIR} fetch - COMMAND ${GIT_EXECUTABLE} -C ${CI_DIR} checkout 0b1fce5e92fd42514fd75e8542ff67adeb6d77f8 + COMMAND ${GIT_EXECUTABLE} -C ${CI_DIR} checkout a8b02c1196945bab072664f4f30f053dabb2639c TIMEOUT 20 WORKING_DIRECTORY ${CI_DIR} #COMMAND_ECHO STDOUT From 8668151935afcf8f1443964f64ab70539c4c9b84 Mon Sep 17 00:00:00 2001 From: Algiane Froehly Date: Thu, 12 Sep 2024 15:12:11 +0200 Subject: [PATCH 11/11] Remove ununsed function In a first place, Luca, that implemented the // analysis, guessed that some part of the analysis (such as the analysis of non-manifold situations) were not possible at the beginning of the process and have to be updated after interface migration. Finally, the non-manifold analysis is done during the pre-processing step and the 'update_nmgeom' function is not called anymore and can be removed. --- src/analys_pmmg.c | 109 ---------------------------------------------- 1 file changed, 109 deletions(-) diff --git a/src/analys_pmmg.c b/src/analys_pmmg.c index 5e084eb0..003b6b93 100644 --- a/src/analys_pmmg.c +++ b/src/analys_pmmg.c @@ -1477,115 +1477,6 @@ int PMMG_hashNorver( PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HGeom *hash, return 1; } -/** - * \param parmesh pointer to the parmesh structure - * \param mesh pointer to the mesh structure - * - * \return 1 if success, 0 if failure. - * - * Compute continuous geometric support (normal and tangent vectors) on - * non-manifold MG_OLDPARBDY points. - * - * \remark Analogous to the MMG3D_nmgeom function, but it only travels on - * old parallel points. - * \remark Normal and tangent vectors on these points are overwritten. - * - */ -int PMMG_update_nmgeom(PMMG_pParMesh parmesh,MMG5_pMesh mesh){ - MMG5_pTetra pt; - MMG5_pPoint p0; - MMG5_pxPoint pxp; - int k,base; - int *adja; - double n[3],t[3]; - int ip; - int8_t i,j,ier; - - for( ip = 1; ip <= mesh->np; ip++ ) { - mesh->point[ip].flag = mesh->base; - } - - base = ++mesh->base; - for (k=1; k<=mesh->ne; k++) { - pt = &mesh->tetra[k]; - if( !MG_EOK(pt) ) continue; - adja = &mesh->adja[4*(k-1)+1]; - for (i=0; i<4; i++) { - if ( adja[i] ) continue; - for (j=0; j<3; j++) { - ip = MMG5_idir[i][j]; - p0 = &mesh->point[pt->v[ip]]; - if ( p0->flag == base ) continue; - else if ( !(p0->tag & MG_OLDPARBDY) ) continue; - else if ( !(p0->tag & MG_NOM) ) continue; - - p0->flag = base; - ier = MMG5_boulenm(mesh,k,ip,i,n,t); - - if ( ier < 0 ) - return 0; - else if ( !ier ) { - p0->tag |= MG_REQ; - p0->tag &= ~MG_NOSURF; - } - else { - if ( !p0->xp ) { - ++mesh->xp; - if(mesh->xp > mesh->xpmax){ - MMG5_TAB_RECALLOC(mesh,mesh->xpoint,mesh->xpmax,MMG5_GAP,MMG5_xPoint, - "larger xpoint table", - mesh->xp--; - fprintf(stderr," Exit program.\n");return 0;); - } - p0->xp = mesh->xp; - } - pxp = &mesh->xpoint[p0->xp]; - memcpy(pxp->n1,n,3*sizeof(double)); - memcpy(p0->n,t,3*sizeof(double)); - } - } - } - } - /* Deal with the non-manifold points that do not belong to a surface - * tetra (a tetra that has a face without adjacent)*/ - for (k=1; k<=mesh->ne; k++) { - pt = &mesh->tetra[k]; - if( !MG_EOK(pt) ) continue; - - for (i=0; i<4; i++) { - p0 = &mesh->point[pt->v[i]]; - if ( !(p0->tag & MG_OLDPARBDY) ) continue; - else if ( p0->tag & MG_PARBDY || p0->tag & MG_REQ || !(p0->tag & MG_NOM) || p0->xp ) continue; - ier = MMG5_boulenmInt(mesh,k,i,t); - if ( ier ) { - ++mesh->xp; - if(mesh->xp > mesh->xpmax){ - MMG5_TAB_RECALLOC(mesh,mesh->xpoint,mesh->xpmax,MMG5_GAP,MMG5_xPoint, - "larger xpoint table", - mesh->xp--; - fprintf(stderr," Exit program.\n");return 0;); - } - p0->xp = mesh->xp; - pxp = &mesh->xpoint[p0->xp]; - memcpy(p0->n,t,3*sizeof(double)); - } - else { - p0->tag |= MG_REQ; - p0->tag &= ~MG_NOSURF; - } - } - } - - /*for (k=1; k<=mesh->np; k++) { - p0 = &mesh->point[k]; - if ( !(p0->tag & MG_NOM) || p0->xp ) continue; - p0->tag |= MG_REQ; - p0->tag &= ~MG_NOSURF; - }*/ - - return 1; -} - static inline int MMG5_skip_nonOldParBdy ( int8_t tag ) { return !(tag & MG_OLDPARBDY);