Skip to content

Commit

Permalink
Take into account deletion of extra triangles when building internal …
Browse files Browse the repository at this point in the history
…communicators
  • Loading branch information
Corentin Prigent authored and Algiane committed Aug 21, 2024
1 parent 7a7994f commit 95683ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
15 changes: 10 additions & 5 deletions src/communicators_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -866,7 +866,7 @@ void PMMG_tria2elmFace_coords( PMMG_pParMesh parmesh, MMG5_int *permtria ) {
/* Process tria stored in index1 */
for( i=0; i<grp->nitem_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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
}
Expand Down Expand Up @@ -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 );


Expand Down
10 changes: 7 additions & 3 deletions src/libparmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) */
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/parmmg.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 95683ec

Please sign in to comment.