Skip to content

Commit

Permalink
Merge pull request #134 from MmgTools/feature/ls-partitioning
Browse files Browse the repository at this point in the history
Feature/ls partitioning
  • Loading branch information
Algiane authored Oct 31, 2024
2 parents 1b12dbc + 5bd4d08 commit 0105859
Show file tree
Hide file tree
Showing 14 changed files with 588 additions and 84 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 1e303f8cea3b9fcbcaf9f1b8625de7e9b434b1aa
GIT_TAG v5.8.0
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
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,13 @@ To get and build ParMmg, you will need:

If you don't have internet access and/or want to use your own installation of
Mmg (resp. Metis), you can disable the automatic download of Mmg setting the
`DOWNLOAD_MMG` (resp. `DOWNLOAD_METIS`) CMake variable to `OFF`. In this case,
you can help CMake to find Mmg (resp. Metis) by specifying the source
directory of Mmg in the `MMG_DIR` variable and the build directory of Mmg in
the `MMG_BUILDDIR` variable (resp. the installation directory of Metis in the
`METIS_DIR` variable).
`DOWNLOAD_MMG` (resp. `DOWNLOAD_METIS`) CMake variable to `OFF`. In this case:

- Mmg has to be built with the private header installation enabled (turn `ON` the ` MMG_INSTALL_PRIVATE_HEADERS` CMake variable in Mmg at cmake configuration step);
- you can help CMake to find Mmg by specifying the installation
directory of Mmg in the `MMG_DIR` variable;
- you can help CMake to find Metis by specifying the installation directory of Metis in the
`METIS_DIR` variable.

Example:
```Shell
Expand Down
113 changes: 112 additions & 1 deletion cmake/testing/pmmg_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ IF( BUILD_TESTING )
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/InterpolationFields-withMet-withFields-4-out.mesh
-field ${CI_DIR}/Interpolation/sol-fields-coarse.sol
-sol field3_iso-coarse.sol
-sol ${CI_DIR}/Interpolation/field3_iso-coarse.sol
-mesh-size 60000 ${myargs} )

add_test( NAME InterpolationFields-hsiz-4
Expand All @@ -363,6 +363,116 @@ IF( BUILD_TESTING )
-out ${CI_DIR_RESULTS}/InterpolationFields-refinement-4-out.mesh
-field ${CI_DIR}/Interpolation/cube-unit-coarse-field.sol ${myargs} )

###############################################################################
#####
##### Tests pure-partitioning option
#####
###############################################################################
add_test( NAME PurePartitioning-CenIn-DisOut-withMetAndFields
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-metAndFields-4-out.mesh
-field ${CI_DIR}/Interpolation/sol-fields-coarse.sol
-sol ${CI_DIR}/Interpolation/field3_iso-coarse.sol
-pure-partitioning
-distributed-output )

add_test( NAME PurePartitioning-CenIn-CenOut-withMetAndFields
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-CenOut-metAndFields-4-out.mesh
-field ${CI_DIR}/Interpolation/sol-fields-coarse.sol
-sol ${CI_DIR}/Interpolation/field3_iso-coarse.sol
-pure-partitioning
-centralized-output )

add_test( NAME PurePartitioning-CenIn-CenOut
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-CenOut-4-out.mesh
-pure-partitioning
-centralized-output )

add_test( NAME PurePartitioning-CenIn-DisOut
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-4-out.mesh
-pure-partitioning
-distributed-output )

add_test( NAME PurePartitioning-CenIn-DisOut-withMet
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-met-4-out.mesh
-sol ${CI_DIR}/Interpolation/field3_iso-coarse.sol
-pure-partitioning
-distributed-output )

add_test( NAME PurePartitioning-CenIn-CenOut-withMet
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-CenOut-met-4-out.mesh
-sol ${CI_DIR}/Interpolation/field3_iso-coarse.sol
-pure-partitioning
-centralized-output )

add_test( NAME PurePartitioning-CenIn-h5-withMetAndFields
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 4 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/Interpolation/coarse.meshb
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-h5-metAndFields-4-out.h5
-field ${CI_DIR}/Interpolation/sol-fields-coarse.sol
-sol ${CI_DIR}/Interpolation/field3_iso-coarse.sol
-pure-partitioning )

add_test( NAME PurePartitioning-CenIn-DisOut-withMetAndLs-2
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/1p_cubegeom/3D-cube.mesh
-ls
-pure-partitioning
-distributed-output
-sol ${CI_DIR}/LevelSet/1p_cubegeom/3D-cube-ls.sol
-met ${CI_DIR}/LevelSet/1p_cubegeom/3D-cube-metric.sol
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-withMetAndLs-2.o.mesh)

add_test( NAME PurePartitioning-CenIn-h5-withMetAndLs-2
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/1p_cubegeom/3D-cube.mesh
-ls
-pure-partitioning
-sol ${CI_DIR}/LevelSet/1p_cubegeom/3D-cube-ls.sol
-met ${CI_DIR}/LevelSet/1p_cubegeom/3D-cube-metric.sol
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-withMetAndLs-2.o.h5)

add_test( NAME PurePartitioning-CenIn-DisOut-withLs-2
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/1p_cubegeom/3D-cube.mesh
-ls
-pure-partitioning
-distributed-output
-sol ${CI_DIR}/LevelSet/1p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-withLs-2.o.mesh)

add_test( NAME PurePartitioning-CenIn-h5-withLs-2
COMMAND ${MPIEXEC} ${MPI_ARGS} ${MPIEXEC_NUMPROC_FLAG} 2 $<TARGET_FILE:${PROJECT_NAME}>
${CI_DIR}/LevelSet/1p_cubegeom/3D-cube.mesh
-ls
-pure-partitioning
-sol ${CI_DIR}/LevelSet/1p_cubegeom/3D-cube-ls.sol
-out ${CI_DIR_RESULTS}/PurePartitioning-CenIn-DisOut-withLs-2.o.h5)


IF ( (NOT HDF5_FOUND) OR USE_HDF5 MATCHES OFF )
SET(expr "HDF5 library not found")
SET_PROPERTY(
TEST
PurePartitioning-CenIn-h5-withMetAndFields
PurePartitioning-CenIn-h5-withMetAndLs-2
PurePartitioning-CenIn-h5-withLs-2
PROPERTY PASS_REGULAR_EXPRESSION "${expr}")
ENDIF ( )



###############################################################################
#####
##### Tests distributed surface adaptation
Expand Down Expand Up @@ -426,6 +536,7 @@ IF( BUILD_TESTING )
ENDFOREACH()
ENDFOREACH()


# Test to verify the patch on update MG_REF tag.
# This test fail if the tag MG_REF is not updated by PMMG_updateTagRef_node in PMMG_update_analys.
# See ParMmg PR#103
Expand Down
77 changes: 77 additions & 0 deletions src/API_functions_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,77 @@ int PMMG_Set_outputSolsName(PMMG_pParMesh parmesh, const char* solout) {
return ier;
}

int PMMG_Set_outputLsName(PMMG_pParMesh parmesh, const char* lsout) {
MMG5_pMesh mesh;
MMG5_pSol ls;
int k,ier,pathlen,baselen;
char *basename,*path,*nopath;

/* If \a lsout is not provided we want to use the basename of the input ls
* name and the path of the output mesh name */
if ( parmesh->lsout ) {
PMMG_DEL_MEM(parmesh,parmesh->lsout,char,"lsout unalloc");
}

if ( (!lsout) || (!*lsout) ) {

if ( (!parmesh->meshout) || (!*parmesh->meshout) ) {
fprintf(stderr, " ## Error: %s: please, provide an output mesh"
" name before calling this function without string.\n",
__func__);
return 0;
}

/* Get input ls base name and remove .mesh extension */
if ( (!parmesh->lsin) || (!*parmesh->lsin) ) {
fprintf(stderr, " ## Error: %s: please, provide an input ls"
" name before calling this function without string.\n",
__func__);
return 0;
}

path = MMG5_Get_path(parmesh->meshout);
nopath = MMG5_Get_basename(parmesh->lsin);
basename = MMG5_Remove_ext ( nopath,".sol" );

pathlen = baselen = 0;
if ( path ) pathlen = strlen(path)+1;
if ( basename ) baselen = strlen(basename);
PMMG_MALLOC(parmesh,parmesh->lsout,pathlen+baselen+1,char,"lsout",return 0);
if ( pathlen ) {
strncpy(parmesh->lsout,path,pathlen-1);
parmesh->lsout[pathlen-1] = MMG5_PATHSEP;
}
if ( baselen ) {
strncpy(parmesh->lsout+pathlen,basename,baselen);
parmesh->lsout[pathlen+baselen] = '\0';
}

if ( parmesh->lsout ) {
/* Add .o.sol extension */
PMMG_REALLOC(parmesh,parmesh->lsout,strlen(parmesh->lsout)+7,
strlen(parmesh->lsout)+1,char,"lsout",return 0);
strncat ( parmesh->lsout,".o.sol",7 );
}

MMG5_SAFE_FREE ( path );
free ( nopath ); nopath = NULL;
MMG5_SAFE_FREE ( basename );
}
else {
PMMG_MALLOC(parmesh,parmesh->lsout,strlen(lsout)+1,char,"lsout",return 0);
strcpy(parmesh->lsout,lsout);
}

for ( k=0; k<parmesh->ngrp; ++k ) {
mesh = parmesh->listgrp[k].mesh;
ls = parmesh->listgrp[k].ls;
ier = MMG3D_Set_outputSolName(mesh,ls,parmesh->lsout);
}
return ier;
}


int PMMG_Set_outputMetName(PMMG_pParMesh parmesh, const char* metout) {
MMG5_pMesh mesh;
MMG5_pSol met;
Expand Down Expand Up @@ -627,6 +698,11 @@ int PMMG_Set_iparameter(PMMG_pParMesh parmesh, int iparam,int val) {
parmesh->ddebug = val;
break;

case PMMG_IPARAM_purePartitioning :

parmesh->info.pure_partitioning = val;
break;

case PMMG_IPARAM_distributedOutput :

if ( val == 1 ) {
Expand Down Expand Up @@ -2795,6 +2871,7 @@ int PMMG_Free_names(PMMG_pParMesh parmesh)
PMMG_DEL_MEM ( parmesh, parmesh->metin,char,"metin" );
PMMG_DEL_MEM ( parmesh, parmesh->metout,char,"metout" );
PMMG_DEL_MEM ( parmesh, parmesh->lsin,char,"lsin" );
PMMG_DEL_MEM ( parmesh, parmesh->lsout,char,"lsout" );
PMMG_DEL_MEM ( parmesh, parmesh->dispin,char,"dispin" );
PMMG_DEL_MEM ( parmesh, parmesh->fieldin,char,"fieldin" );
PMMG_DEL_MEM ( parmesh, parmesh->fieldout,char,"fieldout" );
Expand Down
38 changes: 38 additions & 0 deletions src/API_functionsf_pmmg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,44 @@ FORTRAN_NAME(PMMG_SAVEMET_DISTRIBUTED,pmmg_savemet_distributed,
return;
}

/**
* See \ref PMMG_saveLs_centralized function in \ref libparmmg.h file.
*/
FORTRAN_NAME(PMMG_SAVELS_CENTRALIZED,pmmg_savels_centralized,
(PMMG_pParMesh *parmesh,char* filename, int *strlen,int* retval),
(parmesh,filename,strlen,retval)){
char *tmp = NULL;

MMG5_SAFE_MALLOC(tmp,(*strlen+1),char,);
strncpy(tmp,filename,*strlen);
tmp[*strlen] = '\0';

*retval = PMMG_saveLs_centralized(*parmesh,tmp);

MMG5_SAFE_FREE(tmp);

return;
}

/**
* See \ref PMMG_saveLs_distributed function in \ref libparmmg.h file.
*/
FORTRAN_NAME(PMMG_SAVELS_DISTRIBUTED,pmmg_savels_distributed,
(PMMG_pParMesh *parmesh,char* filename, int *strlen,int* retval),
(parmesh,filename,strlen,retval)){
char *tmp = NULL;

MMG5_SAFE_MALLOC(tmp,(*strlen+1),char,);
strncpy(tmp,filename,*strlen);
tmp[*strlen] = '\0';

*retval = PMMG_saveLs_distributed(*parmesh,tmp);

MMG5_SAFE_FREE(tmp);

return;
}

/**
* See \ref PMMG_saveAllSols_centralized function in \ref libparmmg.h file.
*/
Expand Down
Loading

0 comments on commit 0105859

Please sign in to comment.