]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Support for petsc #2
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 24 Sep 2012 15:56:22 +0000 (15:56 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 24 Sep 2012 15:56:22 +0000 (15:56 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26671 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/configure/configure_petsc.cmake
deal.II/cmake/modules/FindPETSC.cmake
deal.II/cmake/petsc.m4 [deleted file]
deal.II/include/deal.II/base/config.h.in
deal.II/include/deal.II/base/config.h.in.old

index a6eb563494e0d1f38e72a527817c6b50438cefca..21024c2b9453a0a682e9806db761ffa1876384fa 100644 (file)
@@ -15,7 +15,7 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var)
     #
     # We support petsc from version 3.x.x onwards
     #
-    IF(PETSC_MAJOR LESS 3)
+    IF(PETSC_VERSION_MAJOR LESS 3)
       MESSAGE(STATUS
         "Could not find a sufficient modern petsc installation: "
         "Version >=3.0.0 required!"
@@ -31,14 +31,6 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var)
     # _NOT_ enabled.
     # So we check for this:
     #
-    FILE(STRINGS "${PETSC_PETSCCONF_H}" PETSC_RELEASE_STRING
-      REGEX "#define.*PETSC_HAVE_MPIUNI 1")
-    IF("${PETSC_RELEASE_STRING}" STREQUAL "")
-      SET(PETSC_WITH_MPIUNI FALSE)
-    ELSE()
-      SET(PETSC_WITH_MPIUNI TRUE)
-    ENDIF()
-
     IF( (PETSC_WITH_MPIUNI AND DEAL_II_COMPILER_SUPPORTS_MPI)
          OR
          (NOT PETSC_WITH_MPIUNI AND NOT DEAL_II_COMPILER_SUPPORTS_MPI))
@@ -49,13 +41,48 @@ MACRO(FEATURE_PETSC_FIND_EXTERNAL var)
       SET(${var} FALSE)
     ENDIF()
 
-
-
   ENDIF()
+
 ENDMACRO()
 
 
 MACRO(FEATURE_PETSC_CONFIGURE_EXTERNAL var)
+
+  INCLUDE_DIRECTORIES(${PETSC_INCLUDE_DIRS})
+
+  # The user has to know the location of the petsc headers as well: # TODO
+  # LIST(APPEND DEAL_II_EXTERNAL_INCLUDE_DIRS ${PETSC_INCLUDE_DIRS})
+
+  LIST(APPEND DEAL_II_EXTERNAL_LIBRARIES
+    ${PETSC_LIBRARIES}
+    )
+
+  SET(DEAL_II_USE_PETSC TRUE)
+
+  #
+  # Work around a stupidity in PETSc that makes sure it interferes in
+  # a completely obnoxious way with boost.
+  # TODO: Obosolete?
+  #
+  ADD_DEFINITIONS(-DPETSC_SKIP_UNDERSCORE_CHKERR)
+
+  #
+  # Set some definitions for config.h:
+  #
+
+  IF(NOT PETSC_RELEASE)
+    SET(DEAL_II_USE_PETSC_DEV TRUE)
+  ENDIF()
+
+  IF(PETSC_COMPLEX)
+    SET(DEAL_II_USE_PETSC_COMPLEX TRUE)
+  ENDIF()
+
+  SET(DEAL_II_EXPAND_PETSC_VECTOR "PETScWrappers::Vector")
+  SET(DEAL_II_EXPAND_PETSC_MPI_VECTOR "PETScWrappers::MPI::Vector")
+  SET(DEAL_II_EXPAND_PETSC_BLOCKVECTOR "PETScWrappers::BlockVector")
+  SET(DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR "PETScWrappers::MPI::BlockVector")
+
   SET(${var} TRUE)
 ENDMACRO()
 
index f8688998d6f376079590673227348a581bf0f626..3c05f4dfc81f89d69b3e3898f0a0c32ecb196a35 100644 (file)
@@ -1,6 +1,21 @@
 #
 # Try to find the petsc library
 #
+# This module exports:
+#
+#     PETSC_FOUND
+#     PETSC_LIBRARIES
+#     PETSC_INCLUDE_DIRS
+#     PETSC_PETSCCONF_H
+#     PETSC_PETSCVERSION_H
+#     PETSC_VERSION
+#     PETSC_VERSION_MAJOR
+#     PETSC_VERSION_MINOR
+#     PETSC_VERSION_SUBMINOR
+#     PETSC_VERSION_PATCH
+#     PETSC_RELEASE
+#     PETSC_COMPLEX
+#
 
 INCLUDE(FindPackageHandleStandardArgs)
 
@@ -18,7 +33,7 @@ FIND_PATH(PETSC_INCLUDE_DIRS petscconf.h
   PATH_SUFFIXES petsc
 )
 
-FIND_LIBRARY(PETSC_LIBRARY
+FIND_LIBRARY(PETSC_LIBRARIES
   NAMES petsc
   HINTS
     # petsc is special. Account for that
@@ -41,6 +56,7 @@ IF("${PETSC_INCLUDE_DIRS}" STREQUAL "${PETSC_DIR}/${PETSC_ARCH}/include")
   LIST(APPEND PETSC_INCLUDE_DIRS "${PETSC_DIR}/include")
 ENDIF()
 
+
 #
 # Let's see whether we are able to find petscversion.h and petscconf.h:
 #
@@ -66,8 +82,43 @@ FIND_FILE(PETSC_PETSCCONF_H petscconf.h
     NO_CMAKE_FIND_ROOT_PATH
   )
 
+
+IF(NOT PETSC_PETSCCONF_H MATCHES "-NOTFOUND")
+
+  #
+  # Is petsc compiled with support for MPIUNI?
+  #
+  FILE(STRINGS "${PETSC_PETSCCONF_H}" PETSC_MPIUNI_STRING
+    REGEX "#define.*PETSC_HAVE_MPIUNI 1")
+  IF("${PETSC_MPIUNI_STRING}" STREQUAL "")
+    SET(PETSC_WITH_MPIUNI FALSE)
+  ELSE()
+    SET(PETSC_WITH_MPIUNI TRUE)
+  ENDIF()
+
+  IF(PETSC_WITH_MPIUNI)
+    #
+    # If yes, add libmpiuni.so/a (if available)
+    # We need to link with it on some systems where PETSc is built without
+    # a real MPI and we need to handle trivial (one process) MPI
+    # functionality.
+    #
+    FIND_LIBRARY(PETSC_LIBMPIUNI
+      NAMES mpiuni
+      HINTS
+        ${PETSC_DIR}/${PETSC_ARCH}
+      PATH_SUFFIXES lib${LIB_SUFFIX} lib64 lib
+      )
+    IF(NOT PETSC_LIBMPIUNI MATCHES "-NOTFOUND")
+      LIST(APPEND PETSC_LIBRARIES "${PETSC_LIBMPIUNI}")
+    ENDIF()
+    MARK_AS_ADVANCED(PETSC_LIBMPIUNI)
+  ENDIF()
+
+ENDIF()
+
 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
-  PETSC_LIBRARY
+  PETSC_LIBRARIES
   PETSC_INCLUDE_DIRS
   PETSC_PETSCCONF_H
   PETSC_PETSCVERSION_H
@@ -75,17 +126,31 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PETSC DEFAULT_MSG
 
 IF(PETSC_FOUND)
 
-  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_MAJOR_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_MAJOR_STRING
     REGEX "#define.*PETSC_VERSION_MAJOR")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_MAJOR.*([0-9]+).*" "\\1" PETSC_MAJOR "${PETSC_MAJOR_STRING}")
+  STRING(REGEX REPLACE "^.*PETSC_VERSION_MAJOR.*([0-9]+).*" "\\1"
+    PETSC_VERSION_MAJOR "${PETSC_VERSION_MAJOR_STRING}"
+    )
 
-  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_MINOR_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_MINOR_STRING
     REGEX "#define.*PETSC_VERSION_MINOR")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_MINOR.*([0-9]+).*" "\\1" PETSC_MINOR "${PETSC_MINOR_STRING}")
+  STRING(REGEX REPLACE "^.*PETSC_VERSION_MINOR.*([0-9]+).*" "\\1"
+    PETSC_VERSION_MINOR "${PETSC_VERSION_MINOR_STRING}"
+    )
 
-  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_SUBMINOR_STRING
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_SUBMINOR_STRING
     REGEX "#define.*PETSC_VERSION_SUBMINOR")
-  STRING(REGEX REPLACE "^.*PETSC_VERSION_SUBMINOR.*([0-9]+).*" "\\1" PETSC_SUBMINOR "${PETSC_SUBMINOR_STRING}")
+  STRING(REGEX REPLACE "^.*PETSC_VERSION_SUBMINOR.*([0-9]+).*" "\\1"
+    PETSC_VERSION_SUBMINOR "${PETSC_VERSION_SUBMINOR_STRING}"
+    )
+
+  FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_VERSION_PATCH_STRING
+    REGEX "#define.*PETSC_VERSION_PATCH")
+  STRING(REGEX REPLACE "^.*PETSC_VERSION_PATCH.*([0-9]+).*" "\\1"
+    PETSC_VERSION_PATCH "${PETSC_VERSION_PATCH_STRING}"
+    )
+
+  SET(PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}")
 
   FILE(STRINGS "${PETSC_PETSCVERSION_H}" PETSC_RELEASE_STRING
     REGEX "#define.*PETSC_VERSION_RELEASE.*1")
@@ -95,11 +160,19 @@ IF(PETSC_FOUND)
     SET(PETSC_RELEASE TRUE)
   ENDIF()
 
-  SET(PETSC_VERSION "${PETSC_MAJOR}.${PETSC_MINOR}.${PETSC_SUBMINOR}")
+  FILE(STRINGS "${PETSC_PETSCCONF_H}" PETSC_COMPLEX_STRING
+    REGEX "#define.*PETSC_USE_COMPLEX.*1")
+  IF("${PETSC_COMPLEX_STRING}" STREQUAL "")
+    SET(PETSC_COMPLEX FALSE)
+  ELSE()
+    SET(PETSC_COMPLEX TRUE)
+  ENDIF()
 
   MARK_AS_ADVANCED(
-    PETSC_LIBRARY
-    PETSC_INCLUDE_DIR
+    PETSC_LIBRARIES
+    PETSC_INCLUDE_DIRS
+    PETSC_PETSCCONF_H
+    PETSC_PETSCVERSION_H
   )
 ENDIF()
 
diff --git a/deal.II/cmake/petsc.m4 b/deal.II/cmake/petsc.m4
deleted file mode 100644 (file)
index 03813cf..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-
-    dnl Set an additional variable (not via AC_DEFINE, since we don't want
-    dnl to have it in config.h) which we can use in doc/doxygen/options.dox.in.
-    dnl If we have PETSc, then the value of this variable expands to
-    dnl defining the string "DEAL_II_USE_PETSC" for the preprocessor. If
-    dnl we don't have no PETSc, then it does not define this string.
-    DEAL_II_DEFINE_DEAL_II_USE_PETSC=DEAL_II_USE_PETSC
-
-
-
-    dnl Also work around a stupidity in PETSc that makes sure it interferes in
-    dnl a completely obnoxious way with boost.
-    AC_DEFINE([PETSC_SKIP_UNDERSCORE_CHKERR], [1],
-              [Make sure PETSc doesn't re-define the underscore through the preprocessor, since this interferes with boost. PETSc redefines the underscore to be "__gterr =", but then forgets to undef this thing. Boost simply wants to concatenate the underscore with another string to form a class name, which then of course isn't valid any more. See mails in early Feb 2006.])
-  fi
-
-
-
-    DEAL_II_EXPAND_PETSC_VECTOR="PETScWrappers::Vector"
-    DEAL_II_EXPAND_PETSC_MPI_VECTOR="PETScWrappers::MPI::Vector"
-    DEAL_II_EXPAND_PETSC_BLOCKVECTOR="PETScWrappers::BlockVector"
-    DEAL_II_EXPAND_PETSC_MPI_BLOCKVECTOR="PETScWrappers::MPI::BlockVector"
-
-    AC_DEFINE([DEAL_II_USE_PETSC_DEV], [1],
-              [Defined if a PETSc installation was found and is not a release])
-
-
-
-dnl ------------------------------------------------------------
-dnl See if there is a library libmpiuni.a/so available. We need
-dnl to link with it on some systems where PETSc is built without
-dnl a real MPI and we need to handle trivial (one process) MPI
-dnl functionality.
-dnl
-dnl Usage: DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB
-dnl
-dnl ------------------------------------------------------------
-AC_DEFUN(DEAL_II_CONFIGURE_PETSC_MPIUNI_LIB, dnl
-[
-  AC_MSG_CHECKING([for PETSc libmpiuni library])
-  case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in
-    3.*) dnl
-      if test -f $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib/libmpiuni.a ; then
-        DEAL_II_PETSC_MPIUNI_LIB="$DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/lib/libmpiuni.a"
-      fi
-      ;;
-    *)    dnl
-      AC_MSG_ERROR([Unknown PETSc version ${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}])
-    ;;
-  esac
-
-  if test "$DEAL_II_PETSC_MPIUNI_LIB" = "" ; then
-     AC_MSG_RESULT([not found])
-  else
-     AC_MSG_RESULT($DEAL_II_PETSC_MPIUNI_LIB)
-  fi
-])
-
-
-dnl ------------------------------------------------------------
-dnl Figure out PETSc was compiled with --scalar-type=complex by
-dnl scanning PETSc configuration file.
-dnl
-dnl Warning: Up tp now, PETSc>3.0.0 is being supported and
-dnl deal.II will not safely compile if this option is "yes".
-dnl
-dnl Usage: DEAL_II_CONFIGURE_PETSC_COMPLEX
-dnl
-dnl ------------------------------------------------------------
-AC_DEFUN(DEAL_II_CONFIGURE_PETSC_COMPLEX, dnl
-[
-  case "${DEAL_II_PETSC_VERSION_MAJOR}.${DEAL_II_PETSC_VERSION_MINOR}.${DEAL_II_PETSC_VERSION_SUBMINOR}" in
-    3.3*)
-      AC_MSG_CHECKING([for PETSc scalar complex])
-      DEAL_II_PETSC_COMPLEX=`cat $DEAL_II_PETSC_DIR/$DEAL_II_PETSC_ARCH/include/petscconf.h \
-                               | grep "#define PETSC_USE_COMPLEX" \
-                               | perl -pi -e 's/.*COMPLEX\s+//g;'`
-      if test "$DEAL_II_PETSC_COMPLEX" = "1" ; then
-         AC_MSG_RESULT(yes)
-      else
-         AC_MSG_RESULT(no)
-      fi
-
-      dnl If we have previously found PETSc and here with a complex
-      dnl scalar type then set the DEAL_II_USE_COMPLEX macro
-      if test "$USE_CONTRIB_PETSC" = "yes" ; then
-        if test "$DEAL_II_PETSC_COMPLEX" = "1" ; then
-        AC_DEFINE([DEAL_II_USE_PETSC_COMPLEX], [1],
-                  [Defined if a PETSc installation was found with complex scalar type and is going to be used])
-      fi fi
-    ;;
-  esac
-])
-
index 960501db684d26fd8a83e78d4e4fda8663d09a0c..a4c45ea68321674319ed29ba8a75681022bdac5c 100644 (file)
 #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_petsc.cmake: *
+ ****************************************/
+
+/* Defined if a PETSc installation was found and is going to be used */
+#cmakedefine DEAL_II_USE_PETSC
+
+/* Define the PETSC version number: */
+#cmakedefine PETSC_VERSION_MAJOR @PETSC_VERSION_MAJOR@
+#cmakedefine PETSC_VERSION_MINOR @PETSC_VERSION_MINOR@
+#cmakedefine PETSC_VERSION_SUBMINOR @PETSC_VERSION_SUBMINOR@
+#cmakedefine PETSC_VERSION_SUBMINOR @PETSC_VERSION_SUBMINOR@
+
+/* Defined if a PETSc installation was found with complex scalar type and is
+ * going to be used
+ */
+#cmakedefine DEAL_II_USE_PETSC_COMPLEX
+
+/* Defined if a PETSc installation was found and is not a release */
+#cmakedefine DEAL_II_USE_PETSC_DEV
+
+/* Make sure PETSc doesn't re-define the underscore through the preprocessor,
+ * since this interferes with boost. PETSc redefines the underscore to be
+ * "__gterr =", but then forgets to undef this thing. Boost simply wants to
+ * concatenate the underscore with another string to form a class name, which
+ * then of course isn't valid any more. See mails in early Feb 2006.
+ */
+#cmakedefine PETSC_SKIP_UNDERSCORE_CHKERR
+
+/**
+ * These macros are defined to make testing for PETSc versions within
+ * the deal.II main code as simple as possible. In brief they are used
+ * like this: (i) DEAL_II_PETSC_VERSION_LT is used to advance the
+ * PETScWrappers to newer versions of PETSc while preserving backward
+ * compatibility; and (ii) DEAL_II_PETSC_VERSION_GTE is used to add
+ * functionality to the PETScWrappers that does not exist in previous
+ * versions of PETSc.  Examples of usage can be found in
+ * lac/source/petsc_matrix_base.h.  Note: SLEPcWrappers do not need
+ * their own analogical macros, since SLEPc and PETSc must have
+ * identical version numbers anyways.
+ */
+#define DEAL_II_PETSC_VERSION_LT(major,minor,subminor) \
+  ((PETSC_VERSION_MAJOR * 10000 + \
+    PETSC_VERSION_MINOR * 100 + \
+    PETSC_VERSION_SUBMINOR) \
+    <  \
+    (major)*10000 + (minor)*100 + (subminor))
+
+#define DEAL_II_PETSC_VERSION_GTE(major,minor,subminor) \
+  ((PETSC_VERSION_MAJOR * 10000 + \
+    PETSC_VERSION_MINOR * 100 + \
+    PETSC_VERSION_SUBMINOR) \
+    >=  \
+    (major)*10000 + (minor)*100 + (subminor))
+
+
 /**************************************
  * Configured in configure_tbb.cmake: *
  **************************************/
index 3dfa5c252f3e9edff5d0558ace2edaa7a0543551..221195a5dcacd388db085f0e2b329d185a2c6a30 100644 (file)
@@ -187,16 +187,6 @@ BUGS:
 /* Defined if a MUMPS installation was found and is going to be used */
 #cmakedefine DEAL_II_USE_MUMPS
 
-/* Defined if a PETSc installation was found and is going to be used */
-#cmakedefine DEAL_II_USE_PETSC
-
-/* Defined if a PETSc installation was found with complex scalar type and is
-   going to be used */
-#cmakedefine DEAL_II_USE_PETSC_COMPLEX
-
-/* Defined if a PETSc installation was found and is not a release */
-#cmakedefine DEAL_II_USE_PETSC_DEV
-
 /* Defined if a SLEPc installation was found and is going to be used */
 #cmakedefine DEAL_II_USE_SLEPC
 
@@ -287,14 +277,6 @@ TODO:
 /* Availability of the MA47 algorithm from HSL */
 #cmakedefine HAVE_HSL_MA47
 
-/* Make sure PETSc doesn't re-define the underscore through the preprocessor,
-   since this interferes with boost. PETSc redefines the underscore to be
-   "__gterr =", but then forgets to undef this thing. Boost simply wants to
-   concatenate the underscore with another string to form a class name, which
-   then of course isn't valid any more. See mails in early Feb 2006. */
-#cmakedefine PETSC_SKIP_UNDERSCORE_CHKERR
-
-
 /**
  * A #define that indicates whether we are using the Microsoft
  * Windows Visual C/C++ compiler. We currently do not run ./configure
@@ -315,31 +297,6 @@ TODO:
 #  endif
 #endif
 
-/**
- * These macros are defined to make testing for PETSc versions within
- * the deal.II main code as simple as possible. In brief they are used
- * like this: (i) DEAL_II_PETSC_VERSION_LT is used to advance the
- * PETScWrappers to newer versions of PETSc while preserving backward
- * compatibility; and (ii) DEAL_II_PETSC_VERSION_GTE is used to add
- * functionality to the PETScWrappers that does not exist in previous
- * versions of PETSc.  Examples of usage can be found in
- * lac/source/petsc_matrix_base.h.  Note: SLEPcWrappers do not need
- * their own analogical macros, since SLEPc and PETSc must have
- * identical version numbers anyways.
- */
-#define DEAL_II_PETSC_VERSION_LT(major,minor,subminor) \
-  ((PETSC_VERSION_MAJOR * 10000 + \
-    PETSC_VERSION_MINOR * 100 + \
-    PETSC_VERSION_SUBMINOR) \
-    <  \
-    (major)*10000 + (minor)*100 + (subminor))
-
-#define DEAL_II_PETSC_VERSION_GTE(major,minor,subminor) \
-  ((PETSC_VERSION_MAJOR * 10000 + \
-    PETSC_VERSION_MINOR * 100 + \
-    PETSC_VERSION_SUBMINOR) \
-    >=  \
-    (major)*10000 + (minor)*100 + (subminor))
 
 #include <deal.II/base/numbers.h>
 #include <deal.II/base/types.h>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.