Skip to content

Commit

Permalink
Merge pull request #123 from laetitia-m/feature/overlap
Browse files Browse the repository at this point in the history
(1) Change tag type (int -> uint) and (2) creation of the overlap
  • Loading branch information
Algiane authored Oct 24, 2024
2 parents 8e03c1f + 57c0a6f commit d11d85c
Show file tree
Hide file tree
Showing 17 changed files with 986 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ IF ( DOWNLOAD_MMG )

EXTERNALPROJECT_ADD ( Mmg
GIT_REPOSITORY https://github.com/MmgTools/mmg.git
GIT_TAG 2263f92c
GIT_TAG 88d9d1ed6746a1e68713623859ca070224a5abbc
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}
Expand Down
111 changes: 111 additions & 0 deletions cmake/testing/pmmg_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,117 @@ IF( BUILD_TESTING )
${CI_DIR}/Cube/internaltriangles-P3.mesh -v 10
-out ${CI_DIR_RESULTS}/internaltriangles-P3.o.mesh)

###############################################################################
#####
##### Tests overlap
#####
###############################################################################
# Test if overlap is created
set(overlapCreation "## Create Overlap.")

add_test( NAME overlap-create
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-create.o.mesh)
set_property(TEST overlap-create
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCreation}")

# Test if overlap is deleted
set(overlapDelete "## Delete Overlap.")

add_test( NAME overlap-delete
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-delete.o.mesh)
set_property(TEST overlap-delete
PROPERTY PASS_REGULAR_EXPRESSION "${overlapDelete}")

# Tests if overlap is created correctly
set(overlapCheckP0P1 "OVERLAP - part 0 sends 74 pts and 257 tetra to part 1")
set(overlapCheckP0P2 "OVERLAP - part 0 sends 29 pts and 110 tetra to part 2")
set(overlapCheckP0P3 "OVERLAP - part 0 sends 61 pts and 204 tetra to part 3")
set(overlapCheckP0P4 "OVERLAP - part 0 sends 28 pts and 66 tetra to part 4")
set(overlapCheckP0 "OVERLAP - part 0 has 433 pts and 1492 tetras after overlap creation")

add_test( NAME overlap-check-P0P1
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-P0P1.o.mesh)
set_property(TEST overlap-check-P0P1
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckP0P1}")

add_test( NAME overlap-check-P0P2
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-P0P2.o.mesh)
set_property(TEST overlap-check-P0P2
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckP0P2}")

add_test( NAME overlap-check-P0P3
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-P0P3.o.mesh)
set_property(TEST overlap-check-P0P3
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckP0P3}")

add_test( NAME overlap-check-P0P4
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-P0P4.o.mesh)
set_property(TEST overlap-check-P0P4
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckP0P4}")

add_test( NAME overlap-check-P0
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-P0.o.mesh)
set_property(TEST overlap-check-P0
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckP0}")

add_test( NAME overlap-check-P0-met
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-met ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-metric.sol
-out ${CI_DIR_RESULTS}/overlap-check-P0-met.o.mesh)
set_property(TEST overlap-check-P0-met
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckP0}")

# Tests if overlap is deleted correctly
set(overlapCheckDelete "OVERLAP - part 0 has 282 pts and 882 tetras after overlap deletion")
add_test( NAME overlap-check-delete
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-delete.o.mesh)
set_property(TEST overlap-check-delete
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckDelete}")

add_test( NAME overlap-check-delete-met
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 5 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/5p_cubegeom/3D-cube.mesh -v 10 -nomove -noinsert -noswap -nobalance -niter 1
-ls 0.0
-sol ${CI_DIR}/LevelSet/5p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/overlap-check-delete-met.o.mesh)
set_property(TEST overlap-check-delete-met
PROPERTY PASS_REGULAR_EXPRESSION "${overlapCheckDelete}")

###############################################################################
#####
##### Test isovalue mode - ls discretization
Expand Down
24 changes: 12 additions & 12 deletions src/analys_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ typedef struct {
MMG5_pxTetra pxt;
MMG5_pPoint ppt;
double n[3];
int16_t tag;
uint16_t tag;
int ie,ifac,iloc,iadj;
int ip,ip1,ip2;
int updloc,updpar;
Expand All @@ -110,7 +110,7 @@ typedef struct {
*/
static inline
int PMMG_hGetOri( MMG5_HGeom *hash,int ip0,int ip1,int *ref,int16_t *color ) {
int16_t tag;
uint16_t tag;

/* Get edge from hash table */
if( !MMG5_hGet( hash,
Expand All @@ -137,7 +137,7 @@ int PMMG_hGetOri( MMG5_HGeom *hash,int ip0,int ip1,int *ref,int16_t *color ) {
*/
static inline
int PMMG_hTagOri( MMG5_HGeom *hash,int ip0,int ip1,int ref,int16_t color ) {
int16_t tag;
uint16_t tag;

/* Set bitwise tag from color */
if( color ) {
Expand Down Expand Up @@ -273,8 +273,8 @@ int PMMG_hashNorver_loop( PMMG_pParMesh parmesh,PMMG_hn_loopvar *var,int16_t ski
*/
static inline
int PMMG_hash_nearParEdges( PMMG_pParMesh parmesh,PMMG_hn_loopvar *var ) {
int ia[2],ip[2],j;
int16_t tag;
int ia[2],ip[2],j;
uint16_t tag;

/* Get points */
ia[0] = MMG5_iarf[var->ifac][MMG5_iprv2[var->iloc]];
Expand Down Expand Up @@ -312,8 +312,8 @@ int PMMG_hashNorver_edges( PMMG_pParMesh parmesh,PMMG_hn_loopvar *var ) {
double *doublevalues;
int ia[2],ip[2],gip;
int *intvalues,idx,d,edg,j,pos;
int16_t tag;
int8_t found;
uint16_t tag;
int8_t found;

doublevalues = parmesh->int_node_comm->doublevalues;
intvalues = parmesh->int_node_comm->intvalues;
Expand Down Expand Up @@ -383,7 +383,7 @@ static inline
int PMMG_hashNorver_switch( PMMG_pParMesh parmesh,PMMG_hn_loopvar *var ) {
int idx;
int ia[2],ip[2],j;
int16_t tag;
uint16_t tag;

/* Only process ridge points */
if( !(var->ppt->tag & MG_GEO ) ) return 1;
Expand Down Expand Up @@ -1207,7 +1207,7 @@ int PMMG_set_edge_owners( PMMG_pParMesh parmesh,MMG5_HGeom *hpar,MPI_Comm comm )
MMG5_pEdge pa;
int *intvalues,*itosend,*itorecv;
int idx,k,nitem,color,edg,ia,ie,ifac,ip[2],i;
int16_t tag;
uint16_t tag;
MPI_Status status;

assert( parmesh->ngrp == 1 );
Expand Down Expand Up @@ -1478,7 +1478,7 @@ int PMMG_hashNorver( PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HGeom *hash,
}

static inline
int MMG5_skip_nonOldParBdy ( int8_t tag ) {
uint16_t MMG5_skip_nonOldParBdy ( uint16_t tag ) {
return !(tag & MG_OLDPARBDY);
}

Expand Down Expand Up @@ -1561,7 +1561,7 @@ int PMMG_loopr(PMMG_pParMesh parmesh,PMMG_hn_loopvar *var ) {
MMG5_pPoint ppt[2];
double *doublevalues;
int *intvalues,ip[2],k,j,idx,ns0,edg,d;
int16_t tag;
uint16_t tag;
int8_t isEdg;

/* Get node communicator */
Expand Down Expand Up @@ -1960,7 +1960,7 @@ int PMMG_setdhd(PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HGeom *pHash,MPI_Comm
int k,ne,nr,nm,j;
int i,i1,i2;
int idx,edg,d;
int16_t tag;
uint16_t tag;
MPI_Status status;

assert( parmesh->ngrp == 1 );
Expand Down
2 changes: 1 addition & 1 deletion src/boulep_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int PMMG_boulen(PMMG_pParMesh parmesh,MMG5_pMesh mesh,int start,int ip,int iface
double dd,l0,l1;
int base,nump,nr,nnm,k,piv,na,nb,adj,nvstart,fstart,aux,ip0,ip1;
int *adja,color;
int16_t tag;
uint16_t tag;
int8_t iopp,ipiv,indb,inda,i,isface;
int8_t indedg[4][4] = { {-1,0,1,2}, {0,-1,3,4}, {1,3,-1,5}, {2,4,5,-1} };

Expand Down
4 changes: 2 additions & 2 deletions src/communicators_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ int PMMG_fillExtEdgeComm_fromFace( PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HG
PMMG_pExt_comm ext_edge_comm,MMG5_pTetra pt,int ifac,int iloc,int j,int color,int *item ) {
MMG5_pEdge pa;
int edg;
int16_t tag;
uint16_t tag;
int8_t i1,i2;

/* Take the edge opposite to vertex iloc+j on face ifac */
Expand Down Expand Up @@ -661,7 +661,7 @@ int PMMG_build_edgeComm( PMMG_pParMesh parmesh,MMG5_pMesh mesh,MMG5_HGeom *hpar,
MMG5_hgeom *ph;
int *nitems_ext_comm,color,k,i,idx,ie,ifac,iloc,j,item;
int edg;
int16_t tag;
uint16_t tag;
int8_t ia,i1,i2;

assert( parmesh->ngrp == 1 );
Expand Down
2 changes: 1 addition & 1 deletion src/debug_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ int PMMG_saveQual(MMG5_pMesh mesh, const char *filename) {
* Write group surface mesh and edges with given tag in medit format.
*
*/
int PMMG_grp_to_saveEdges( PMMG_pParMesh parmesh,int grpId,int16_t tag,char *basename ) {
int PMMG_grp_to_saveEdges( PMMG_pParMesh parmesh,int grpId,uint16_t tag,char *basename ) {
PMMG_pGrp grp;
MMG5_pMesh mesh;
MMG5_pTria ptr;
Expand Down
2 changes: 1 addition & 1 deletion src/debug_pmmg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void PMMG_grplst_meshes_to_txt( char *name, PMMG_pGrp grp, int ngrp );
void PMMG_tetras_of_mesh_to_txt( char *name, MMG5_pMesh mesh, int num );
void PMMG_find_tetras_referencing_null_points_to_txt( char *name, PMMG_pGrp grp, int nmsh );
void PMMG_listgrp_meshes_adja_of_tetras_to_txt( char *name, PMMG_pGrp grp, int ngrp );
int PMMG_grp_to_saveEdges( PMMG_pParMesh parmesh,int grpId,int16_t tag,char *basename );
int PMMG_grp_to_saveEdges( PMMG_pParMesh parmesh,int grpId,uint16_t tag,char *basename );
int PMMG_grp_to_saveMesh( PMMG_pParMesh parmesh, int grpId, char *basename );
int PMMG_listgrp_to_saveMesh( PMMG_pParMesh parmesh, char *basename );
int PMMG_listgrp_quality_to_saveMesh( PMMG_pParMesh parmesh, char *basename );
Expand Down
2 changes: 1 addition & 1 deletion src/hash_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ int PMMG_bdryUpdate( MMG5_pMesh mesh )
MMG5_pxTetra pxt;
MMG5_HGeom hash;
int k,edg;
int16_t tag;
uint16_t tag;
int8_t i,i1,i2;


Expand Down
6 changes: 5 additions & 1 deletion src/libparmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh )
if ( !PMMG_build_nodeCommFromFaces(parmesh,parmesh->info.read_comm) ) {
return PMMG_STRONGFAILURE;
}

break;

case PMMG_APIDISTRIB_nodes :
Expand Down Expand Up @@ -406,6 +407,7 @@ int PMMG_preprocessMesh_distributed( PMMG_pParMesh parmesh )
if ( !PMMG_ls(parmesh) ) {
return PMMG_STRONGFAILURE;
}

chrono(OFF,&(ctim[tim]));
printim(ctim[tim].gdif,stim);
if ( parmesh->info.imprim > PMMG_VERB_VERSION ) {
Expand Down Expand Up @@ -1103,6 +1105,7 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ){
/* Store owner in the point flag */
for( ip = 1; ip <= mesh->np; ip++ ) {
ppt = &mesh->point[ip];
if (ppt->tag & MG_OVERLAP) continue;
ppt->flag = parmesh->myrank;
}

Expand Down Expand Up @@ -1138,13 +1141,13 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ){
counter = 0;
for( ip = 1; ip <= mesh->np; ip++ ) {
ppt = &mesh->point[ip];
if (ppt->tag & MG_OVERLAP) continue;
if( ppt->flag != parmesh->myrank ) continue;
ppt->tmp = ++counter+offsets[parmesh->myrank];
assert(ppt->tmp);
}
assert( counter == nowned );


/** Step 2: Communicate global numbering */

/* Store numbering in the internal communicator */
Expand Down Expand Up @@ -1243,6 +1246,7 @@ int PMMG_Compute_verticesGloNum( PMMG_pParMesh parmesh,MPI_Comm comm ){
#ifndef NDEBUG
for( ip = 1; ip <= mesh->np; ip++ ) {
ppt = &mesh->point[ip];
if (ppt->tag & MG_OVERLAP) continue;
assert(ppt->tmp > 0);
assert(ppt->tmp <= offsets[parmesh->nprocs]);
}
Expand Down
20 changes: 19 additions & 1 deletion src/libparmmgtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,22 @@ typedef struct {
MPI_Comm read_comm; /*!< MPI comm containing the procs that read the mesh (HDF5 input) */
} PMMG_Info;

/**
* \struct PMMG_overlap
* \brief Overlap structure.
*/
typedef struct {
int color_in; /*!< Color of the hosting processor */
int color_out; /*!< Color of the remote processor */
int np_in2out; /*!< Nbr of points sends from color_in to color_out */
int np_out2in; /*!< Nbr of points receives on color_in from color_out */
int nt_in2out; /*!< Nbr of tetra sends from color_in to color_out */
int nt_out2in; /*!< Nbr of tetra receives on color_in from color_out */
int *hash_in2out; /*!< Hash table to find pts index on color_out from pts index on color_in */
int *hash_out2in; /*!< Hash table to find pts index on color_in from pts index on color_out */

} PMMG_Overlap;
typedef PMMG_Overlap * PMMG_pOverlap;

/**
* \struct PMMG_ParMesh
Expand Down Expand Up @@ -416,7 +432,6 @@ typedef struct {
int nold_grp; /*!< Number of old grp */
PMMG_pGrp old_listgrp; /*!< List of old grp */


/* internal communicators */
PMMG_pInt_comm int_node_comm; /*!< Internal node communicator (only one PMMG_Int_comm, it is not an array) */
PMMG_pInt_comm int_edge_comm; /*!< Internal edge communicator */
Expand All @@ -430,6 +445,9 @@ typedef struct {
int next_face_comm; /*!< Number of external face communicator */
PMMG_pExt_comm ext_face_comm; /*!< External communicators (in increasing order w.r. to the remote proc index) */

/* overlap variables */
PMMG_pOverlap overlap; /*!< Overlap variables */

/* global variables */
int ddebug; //! Debug level
int iter; //! Current adaptation iteration
Expand Down
Loading

0 comments on commit d11d85c

Please sign in to comment.