From 73c1da7d97a609a720c2d1fdfd3f4f232efaeda3 Mon Sep 17 00:00:00 2001 From: maier Date: Mon, 17 Sep 2012 21:00:58 +0000 Subject: [PATCH] Add support for p4est git-svn-id: https://svn.dealii.org/branches/branch_cmake@26451 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/CMakeLists.txt | 8 ++- .../cmake/configure/configure_p4est.cmake | 71 +++++++++++++++++++ .../cmake/configure/configure_tbb.cmake | 17 +++-- deal.II/contrib/cmake/modules/FindP4EST.cmake | 26 +++++++ deal.II/contrib/cmake/modules/FindSC.cmake | 27 +++++++ deal.II/features.m4 | 55 +------------- deal.II/include/deal.II/base/config.h.in | 9 +++ deal.II/include/deal.II/base/config.h.in.old | 4 -- deal.II/source/dofs/dof_tools.cc | 2 +- 9 files changed, 153 insertions(+), 66 deletions(-) create mode 100644 deal.II/contrib/cmake/configure/configure_p4est.cmake create mode 100644 deal.II/contrib/cmake/modules/FindP4EST.cmake create mode 100644 deal.II/contrib/cmake/modules/FindSC.cmake diff --git a/deal.II/CMakeLists.txt b/deal.II/CMakeLists.txt index 19f9ee25be..fbc43305c4 100644 --- a/deal.II/CMakeLists.txt +++ b/deal.II/CMakeLists.txt @@ -123,6 +123,10 @@ OPTION(DEAL_II_WITH_NETCDF "Build deal.II with support for netcdf." OFF) +OPTION(DEAL_II_WITH_P4EST + "Build deal.II with support for P4EST." + OFF) + OPTION(DEAL_II_WITH_TBB "Build deal.II with support for tbb. This will enable thread support in deal.II." OFF) @@ -132,7 +136,7 @@ OPTION(DEAL_II_FORCE_CONTRIB_TBB OPTION(DEAL_II_WITH_TRILINOS "Build deal.II with support for trilinos." - ON) + OFF) OPTION(DEAL_II_WITH_UMFPACK "Build deal.II with support for UMFPACK." @@ -269,6 +273,8 @@ INCLUDE(configure_mpi) INCLUDE(configure_netcdf) +INCLUDE(configure_p4est) + INCLUDE(configure_tbb) INCLUDE(configure_trilinos) diff --git a/deal.II/contrib/cmake/configure/configure_p4est.cmake b/deal.II/contrib/cmake/configure/configure_p4est.cmake new file mode 100644 index 0000000000..d0f452ab6a --- /dev/null +++ b/deal.II/contrib/cmake/configure/configure_p4est.cmake @@ -0,0 +1,71 @@ +# +# Configuration for the umfpack and amd libraries: +# + + +SET(FEATURE_P4EST_DEPENDS + DEAL_II_WITH_MPI + ) + + +MACRO(FEATURE_P4EST_FIND_EXTERNAL var) + + FIND_PACKAGE(P4EST) + FIND_PACKAGE(SC) + + IF(P4EST_FOUND AND SC_FOUND) + SET(${var} TRUE) + ENDIF() + +ENDMACRO() + + +MACRO(FEATURE_P4EST_CONFIGURE_EXTERNAL var) + + INCLUDE_DIRECTORIES(${P4EST_INCLUDE_DIR} ${SC_INCLUDE_DIR}) + + IF (CMAKE_BUILD_TYPE MATCHES "Debug") + IF(P4EST_DEBUG_FOUND AND SC_DEBUG_FOUND) + LIST(APPEND deal_ii_external_libraries + ${P4EST_DEBUG_LIBRARY} ${SC_DEBUG_LIBRARY} + ) + ELSE() + MESSAGE(WARNING " +deal.II was configured with CMAKE_BUILD_TYPE=Debug but no debug p4est and +sc libraries were found. The regular p4est and sc libraries will be used +instead. + +") + LIST(APPEND deal_ii_external_libraries + ${P4EST_LIBRARY} ${SC_LIBRARY} + ) + ENDIF() + ELSE() + LIST(APPEND deal_ii_external_libraries + ${P4EST_LIBRARY} ${SC_LIBRARY} + ) + ENDIF() + + SET(DEAL_II_USE_P4EST TRUE) + + SET(${var} TRUE) + +ENDMACRO() + + +SET(FEATURE_P4EST_CUSTOM_ERROR_MESSAGE TRUE) + + +MACRO(FEATURE_P4EST_ERROR_MESSAGE) + MESSAGE(SEND_ERROR " +Could not find the p4est and sc libraries! + +Please ensure that the libraries are installed on your computer. +If the libraries are not at a default location, either provide some hints +for the autodetection, or set the relevant variables by hand in ccmake. + +") +ENDMACRO() + + +CONFIGURE_FEATURE(P4EST) diff --git a/deal.II/contrib/cmake/configure/configure_tbb.cmake b/deal.II/contrib/cmake/configure/configure_tbb.cmake index e8883da6e7..ea8e1672ff 100644 --- a/deal.II/contrib/cmake/configure/configure_tbb.cmake +++ b/deal.II/contrib/cmake/configure/configure_tbb.cmake @@ -88,11 +88,6 @@ MACRO(FEATURE_TBB_FIND_EXTERNAL var) FIND_PACKAGE(TBB) - # In case we don't have a debug library: - IF(NOT TBB_DEBUG_FOUND) - SET(TBB_DEBUG_LIBRARY ${TBB_LIBRARY}) - ENDIF() - IF(TBB_FOUND) SET(${var} TRUE) ENDIF() @@ -105,7 +100,17 @@ MACRO(FEATURE_TBB_CONFIGURE_EXTERNAL var) INCLUDE_DIRECTORIES(${TBB_INCLUDE_DIR}) IF (CMAKE_BUILD_TYPE MATCHES "Debug") - LIST(APPEND deal_ii_external_libraries ${TBB_DEBUG_LIBRARY}) + IF(TBB_DEBUG_FOUND) + LIST(APPEND deal_ii_external_libraries ${TBB_DEBUG_LIBRARY}) + ELSE() + MESSAGE(WARNING " +deal.II was configured with CMAKE_BUILD_TYPE=Debug but no debug tbb +library was found. The regular tbb library will be used instead. + +") + LIST(APPEND deal_ii_external_libraries ${TBB_LIBRARY}) + ENDIF() + ELSE() LIST(APPEND deal_ii_external_libraries ${TBB_LIBRARY}) ENDIF() diff --git a/deal.II/contrib/cmake/modules/FindP4EST.cmake b/deal.II/contrib/cmake/modules/FindP4EST.cmake new file mode 100644 index 0000000000..e8336b69d3 --- /dev/null +++ b/deal.II/contrib/cmake/modules/FindP4EST.cmake @@ -0,0 +1,26 @@ +# Try to find P4EST + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PATH(P4EST_INCLUDE_DIR p4est.h) + +FIND_LIBRARY(P4EST_LIBRARY + NAMES p4est + PATH_SUFFIXES lib64 lib +) + +FIND_LIBRARY(P4EST_DEBUG_LIBRARY + NAMES p4est_debug p4est.g + PATH_SUFFIXES lib64 lib +) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(P4EST DEFAULT_MSG P4EST_LIBRARY P4EST_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(P4EST_DEBUG DEFAULT_MSG P4EST_DEBUG_LIBRARY P4EST_INCLUDE_DIR) + +IF(P4EST_FOUND) + MARK_AS_ADVANCED( + P4EST_LIBRARY + P4EST_DEBUG_LIBRARY + P4EST_INCLUDE_DIR + ) +ENDIF() diff --git a/deal.II/contrib/cmake/modules/FindSC.cmake b/deal.II/contrib/cmake/modules/FindSC.cmake new file mode 100644 index 0000000000..702f55f132 --- /dev/null +++ b/deal.II/contrib/cmake/modules/FindSC.cmake @@ -0,0 +1,27 @@ +# Try to find SC + +INCLUDE(FindPackageHandleStandardArgs) + +FIND_PATH(SC_INCLUDE_DIR sc.h) + + +FIND_LIBRARY(SC_LIBRARY + NAMES sc + PATH_SUFFIXES lib64 lib +) + +FIND_LIBRARY(SC_DEBUG_LIBRARY + NAMES sc_debug sc.g + PATH_SUFFIXES lib64 lib +) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SC DEFAULT_MSG SC_LIBRARY SC_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SC_DEBUG DEFAULT_MSG SC_DEBUG_LIBRARY SC_INCLUDE_DIR) + +IF(SC_FOUND) + MARK_AS_ADVANCED( + SC_LIBRARY + SC_DEBUG_LIBRARY + SC_INCLUDE_DIR + ) +ENDIF() diff --git a/deal.II/features.m4 b/deal.II/features.m4 index 6e62f09557..57bad77cb0 100644 --- a/deal.II/features.m4 +++ b/deal.II/features.m4 @@ -749,63 +749,10 @@ dnl dnl Usage: DEAL_II_CONFIGURE_P4EST dnl dnl ------------------------------------------------------------ -AC_DEFUN(DEAL_II_CONFIGURE_P4EST, dnl -[ - AC_MSG_CHECKING(whether p4est will be used) - - AC_ARG_WITH(p4est, - [AS_HELP_STRING([--with-p4est=/path/to/p4est], - [Specify the path to the p4est installation; use this to distribute meshes on a cluster computer.])], - use_p4est=$withval, - use_p4est=no) - - if test "x$use_p4est" != "xno" ; then - AC_MSG_RESULT(yes) - dnl Verify that the p4est files are actually there - if test ! -d "${use_p4est}/DEBUG" -o ! -d "${use_p4est}/FAST" ; then - AC_MSG_ERROR([p4est directories $use_p4est/DEBUG or $use_p4est/FAST not found]) - fi dnl Make sure that we have also enabled MPI + if test "x${DEAL_II_COMPILER_SUPPORTS_MPI}" != "x1" ; then AC_MSG_ERROR([When using p4est you also need to enable MPI.]) fi - - dnl Right now, we always build p4est as shared lib, so make sure we - dnl have built deal.II as a shared lib as well - if test "x$enableshared" != "xyes" ; then - AC_MSG_ERROR([When using p4est with shared libraries, you need to build - deal.II with shared libraries as well.]) - fi - - AC_DEFINE(DEAL_II_USE_P4EST, 1, - [Defined if we are to use the p4est library to distribute - meshes on a cluster computer.]) - USE_CONTRIB_P4EST=yes - AC_SUBST(USE_CONTRIB_P4EST) - - DEAL_II_P4EST_DIR=${use_p4est} - AC_SUBST(DEAL_II_P4EST_DIR) - - CXXFLAGSG="$CXXFLAGSG -I$use_p4est/DEBUG/include" - CXXFLAGSO="$CXXFLAGSO -I$use_p4est/FAST/include" - - AC_MSG_CHECKING(for p4est library directory) - if test -d "$use_p4est/DEBUG/lib64" -a -d "$use_p4est/FAST/lib64" ; then - AC_MSG_RESULT(lib64) - DEAL_II_P4EST_LIBDIR_NAME=lib64 - else - if test -d "$use_p4est/DEBUG/lib" -a -d "$use_p4est/FAST/lib" ; then - AC_MSG_RESULT(lib) - DEAL_II_P4EST_LIBDIR_NAME=lib - else - AC_MSG_ERROR(could not determine whether p4est stores its library in lib/ or lib64/ directories) - fi - fi - AC_SUBST(DEAL_II_P4EST_LIBDIR_NAME) - - else - AC_MSG_RESULT(no) - fi -]) diff --git a/deal.II/include/deal.II/base/config.h.in b/deal.II/include/deal.II/base/config.h.in index da99e9328d..292363135d 100644 --- a/deal.II/include/deal.II/base/config.h.in +++ b/deal.II/include/deal.II/base/config.h.in @@ -211,6 +211,15 @@ #cmakedefine HAVE_LIBNETCDF +/***************************************** + * Configured in configure_p4est.cmake: * + *****************************************/ + +/* Defined if we are to use the p4est library to distribute meshes on a + cluster computer. */ +#cmakedefine DEAL_II_USE_P4EST + + /************************************** * Configured in configure_tbb.cmake: * **************************************/ diff --git a/deal.II/include/deal.II/base/config.h.in.old b/deal.II/include/deal.II/base/config.h.in.old index fbb87918cd..b381758f22 100644 --- a/deal.II/include/deal.II/base/config.h.in.old +++ b/deal.II/include/deal.II/base/config.h.in.old @@ -153,10 +153,6 @@ /* Defined if a MUMPS installation was found and is going to be used */ #cmakedefine DEAL_II_USE_MUMPS -/* Defined if we are to use the p4est library to distribute meshes on a - cluster computer. */ -#cmakedefine DEAL_II_USE_P4EST - /* Defined if a PETSc installation was found and is going to be used */ #cmakedefine DEAL_II_USE_PETSC diff --git a/deal.II/source/dofs/dof_tools.cc b/deal.II/source/dofs/dof_tools.cc index 6b7d727666..b5a834e0d3 100644 --- a/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/source/dofs/dof_tools.cc @@ -4954,7 +4954,7 @@ namespace DoFTools block); #ifdef DEAL_II_USE_P4EST -#if DEAL_II_COMPILER_SUPPORTS_MPI +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI // if we are working on a parallel // mesh, we now need to collect // this information from all -- 2.39.5