From b9bb3931611da6245fb2f505e7c03cafbd1cd8e7 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Fri, 26 Jul 2024 14:45:33 +0200 Subject: [PATCH 1/3] modified edge ownhership rules --- src/analys_pmmg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/analys_pmmg.c b/src/analys_pmmg.c index 55726673..c84a137c 100644 --- a/src/analys_pmmg.c +++ b/src/analys_pmmg.c @@ -1224,6 +1224,7 @@ int PMMG_set_edge_owners( PMMG_pParMesh parmesh,MMG5_HGeom *hpar,MPI_Comm comm ) if( !MG_EOK(pt) || !pt->xt ) continue; pxt = &mesh->xtetra[pt->xt]; for( ifac = 0; ifac < 4; ifac++ ) { + if( !MG_GET(pxt->ori,ifac) ) continue; tag = pxt->ftag[ifac]; /* Skip non-boundary faces */ if( !(tag & MG_BDY) || ( (tag & MG_PARBDY) && !(tag & MG_PARBDYBDY) ) ) From b4b69cde448f4542df39fb52e69bf96bf2fa8b45 Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Mon, 29 Jul 2024 15:33:17 +0200 Subject: [PATCH 2/3] add check function for edge owners --- src/analys_pmmg.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/src/analys_pmmg.c b/src/analys_pmmg.c index c84a137c..a55bbe93 100644 --- a/src/analys_pmmg.c +++ b/src/analys_pmmg.c @@ -1287,6 +1287,80 @@ int PMMG_set_edge_owners( PMMG_pParMesh parmesh,MMG5_HGeom *hpar,MPI_Comm comm ) return 1; } +/** + * \param parmesh pointer toward the parmesh structure + * \param hpar hash table parallel edges + * \param comm pointer toward the MPI communicator to use: when called before + * the first mesh balancing (at preprocessing stage) we have to use the + * read_comm communicator (i.e. the communicator used to provide the inputs). + * For all ather calls, comm has to be the communicator to use for computations. + * + * \return 0 if failure, 1 if success. + * + * Check that every edge has one and only one owner. + */ +int PMMG_check_edge_owners( PMMG_pParMesh parmesh,MMG5_HGeom *hpar,MPI_Comm comm ) { + PMMG_pInt_comm int_edge_comm; + PMMG_pExt_comm ext_edge_comm; + MMG5_pMesh mesh; + MMG5_pEdge pa; + int *intvalues, *itosend, *itorecv; + int i, idx, k, nitem, color, ia; + MPI_Status status; + + assert( parmesh->ngrp == 1 ); + mesh = parmesh->listgrp[0].mesh; + + int_edge_comm = parmesh->int_edge_comm; + intvalues = int_edge_comm->intvalues; + + /** Store list of parallel edge owners */ + for (ia=1;ia<=mesh->na;ia++) { + pa = &mesh->edge[ia]; + intvalues[ia-1] = pa->base; + if (pa->base == parmesh->nprocs) return 0; + } + + /** Exchange values on the interfaces among procs */ + for ( k = 0; k < parmesh->next_edge_comm; ++k ) { + ext_edge_comm = &parmesh->ext_edge_comm[k]; + nitem = ext_edge_comm->nitem; + color = ext_edge_comm->color_out; + + itosend = ext_edge_comm->itosend; + itorecv = ext_edge_comm->itorecv; + + /* Fill buffers */ + for ( i=0; iint_comm_index[i]; + itosend[i] = intvalues[idx]; + } + + /* Communication */ + MPI_CHECK( + MPI_Sendrecv(itosend,nitem,MPI_INT,color,MPI_ANALYS_TAG+2, + itorecv,nitem,MPI_INT,color,MPI_ANALYS_TAG+2, + comm,&status),return 0 ); + } + + /* Check that all edges have the same owner over the whole mesh */ + for ( k = 0; k < parmesh->next_edge_comm; ++k ) { + ext_edge_comm = &parmesh->ext_edge_comm[k]; + + itorecv = ext_edge_comm->itorecv; + + for ( i=0; initem; ++i ) { + idx = ext_edge_comm->int_comm_index[i]; + if (!(intvalues[idx] == itorecv[i])) { + fprintf(stderr,"Parallel edge has two different owners. \n"); + return 0; + } + } + } + + return 1; +} + /** * \param parmesh pointer toward the parmesh structure * \param mesh pointer toward the mesh structure @@ -2794,6 +2868,13 @@ int PMMG_analys(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MPI_Comm comm) { return 0; } +#ifndef NDEBUG + if (!PMMG_check_edge_owners(parmesh,&hpar,comm)) { + fprintf(stderr,"\n ## Parallel edge has no owner or too many owners. Exit program. \n"); + return 0; + } +#endif + /* identify singularities on parallel points. * No need to call a *_setVertexNmTag function, as it already takes into * account non-manifold configurations. */ From c1d49397cf6843994d361c688dfb4ca0075e740c Mon Sep 17 00:00:00 2001 From: Corentin Prigent Date: Tue, 30 Jul 2024 15:17:46 +0200 Subject: [PATCH 3/3] modified edge owner check function --- src/analys_pmmg.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/analys_pmmg.c b/src/analys_pmmg.c index a55bbe93..5e084eb0 100644 --- a/src/analys_pmmg.c +++ b/src/analys_pmmg.c @@ -1318,6 +1318,7 @@ int PMMG_check_edge_owners( PMMG_pParMesh parmesh,MMG5_HGeom *hpar,MPI_Comm comm for (ia=1;ia<=mesh->na;ia++) { pa = &mesh->edge[ia]; intvalues[ia-1] = pa->base; + if (!(pa->tag & MG_PARBDYBDY)) continue; if (pa->base == parmesh->nprocs) return 0; }