]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make Sacado an optional dependency 6906/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 10 Jul 2018 13:36:57 +0000 (13:36 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 10 Jul 2018 21:29:28 +0000 (21:29 +0000)
cmake/configure/configure_2_trilinos.cmake
cmake/modules/FindTRILINOS.cmake
examples/step-33/CMakeLists.txt
include/deal.II/base/config.h.in
include/deal.II/base/numbers.h
include/deal.II/differentiation/ad/sacado_math.h
include/deal.II/differentiation/ad/sacado_number_types.h
include/deal.II/differentiation/ad/sacado_product_types.h
source/differentiation/ad/sacado_number_types.cc
tests/sacado/CMakeLists.txt

index e8e5cff34920a2880c4768356fc22d2c2bebf349..4f1ecbea50b3dbe36bed66a64b802dd0bb5466fd 100644 (file)
@@ -42,7 +42,7 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
       )
 
     FOREACH(_module
-      Amesos Epetra Ifpack AztecOO Sacado Teuchos ML MueLu
+      Amesos Epetra Ifpack AztecOO Teuchos ML MueLu
       )
       ITEM_MATCHES(_module_found ${_module} ${Trilinos_PACKAGE_LIST})
       IF(_module_found)
@@ -66,6 +66,19 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
         )
     ENDIF()
 
+    IF (${var})
+      FOREACH(_optional_module ROL Sacado Zoltan)
+      ITEM_MATCHES(_module_found ${_optional_module} ${Trilinos_PACKAGE_LIST})
+      IF(_module_found)
+          MESSAGE(STATUS "Found ${_optional_module}")
+          STRING(TOUPPER "${_optional_module}" _optional_module_upper)
+          SET(DEAL_II_TRILINOS_WITH_${_optional_module_upper} ON)
+      ELSE()
+          MESSAGE(STATUS "Module ${_optional_module} not found!")
+      ENDIF()
+      ENDFOREACH()
+    ENDIF()
+
     #
     # We require at least Trilinos 12.4
     #
@@ -143,45 +156,63 @@ MACRO(FEATURE_TRILINOS_FIND_EXTERNAL var)
       SET(${var} FALSE)
     ENDIF()
 
-    #
-    # Some versions of Sacado_cmath.hpp do things that aren't compatible
-    # with the -std=c++0x flag of GCC, see deal.II FAQ.
-    # Test whether that is indeed the case
-    #
-    IF(NOT TRILINOS_SUPPORTS_CPP11)
-
-      IF(TRILINOS_HAS_C99_TR1_WORKAROUND)
-        LIST(APPEND TRILINOS_DEFINITIONS "HAS_C99_TR1_CMATH")
-        LIST(APPEND TRILINOS_USER_DEFINITIONS "HAS_C99_TR1_CMATH")
-      ELSE()
-        MESSAGE(STATUS "Could not find a sufficient Trilinos installation: "
-          "The installation is not compatible with the C++ standard selected for "
-          "this compiler."
-          )
-        SET(TRILINOS_ADDITIONAL_ERROR_STRING
-          ${TRILINOS_ADDITIONAL_ERROR_STRING}
-          "The Trilinos installation (found at \"${TRILINOS_DIR}\")\n"
-          "is not compatible with the C++ standard selected for\n"
-          "this compiler. See the deal.II FAQ page for a solution.\n\n"
+    IF(${DEAL_II_TRILINOS_WITH_SACADO})
+      #
+      # Look for Sacado_config.h - we'll query it to determine C++11 support:
+      #
+      DEAL_II_FIND_FILE(SACADO_CONFIG_H Sacado_config.h
+        HINTS ${Trilinos_INCLUDE_DIRS}
+        NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
+        NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
+        )
+      
+      IF(EXISTS ${SACADO_CONFIG_H})
+        #
+        # Determine whether Trilinos was configured with C++11 support and
+        # enabling C++11 in deal.II is mandatory.
+        #
+        FILE(STRINGS "${SACADO_CONFIG_H}" SACADO_CXX11_STRING
+          REGEX "#define HAVE_SACADO_CXX11")
+      ENDIF()
+      
+      #
+      # GCC 6.3.0 has a bug that prevents the creation of complex
+      # numbers templated on Sacado::Rad::ADvar types:
+      #
+      # include/c++/6.3.0/complex: In instantiation of 
+      # ‘struct std::complex<Sacado::Rad::ADvar<double> >’:
+      # include/c++/6.3.0/complex:206:16: error: ‘std::complex<_Tp>& std::complex<_Tp>::operator=(const std::complex<_Tp>&) [with _Tp = Sacado::Rad::ADvar<double>]’ declared to take const reference, but implicit declaration would take non-const
+      #
+      # Test whether the compiler hits this issue
+      #
+      DEAL_II_FIND_FILE(SACADO_TRAD_HPP Sacado_trad.hpp
+        HINTS ${Trilinos_INCLUDE_DIRS}
+        NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
+        NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
+        )
+      
+      IF(EXISTS ${SACADO_TRAD_HPP})
+        LIST(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
+        PUSH_CMAKE_REQUIRED("${DEAL_II_CXX_VERSION_FLAG}")
+      
+        CHECK_CXX_SOURCE_COMPILES(
+          "
+          #include <Sacado_trad.hpp>
+          int main ()
+          {
+            Sacado::Rad::ADvar<double> sacado_rad_double; // Works
+            std::complex<Sacado::Rad::ADvar<double> > complex_sacado_rad_double; // Doesn't work
+            return 0;
+          }
+          "
+          TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
           )
-        SET(${var} FALSE)
+        RESET_CMAKE_REQUIRED()
       ENDIF()
+
     ENDIF()
 
     CHECK_MPI_INTERFACE(TRILINOS ${var})
-
-    IF (${var})
-      FOREACH(_optional_module ROL Zoltan)
-      ITEM_MATCHES(_module_found ${_optional_module} ${Trilinos_PACKAGE_LIST})
-      IF(_module_found)
-          MESSAGE(STATUS "Found ${_optional_module}")
-          STRING(TOUPPER "${_optional_module}" _optional_module_upper)
-          SET(DEAL_II_TRILINOS_WITH_${_optional_module_upper} ON)
-      ELSE()
-          MESSAGE(STATUS "Module ${_optional_module} not found!")
-      ENDIF()
-      ENDFOREACH()
-    ENDIF()
   ENDIF()
 ENDMACRO()
 
@@ -194,24 +225,26 @@ MACRO(FEATURE_TRILINOS_CONFIGURE_EXTERNAL)
       "TrilinosWrappers::BlockSparseMatrix")
   SET(DEAL_II_EXPAND_TRILINOS_MPI_BLOCKVECTOR "TrilinosWrappers::MPI::BlockVector")
   SET(DEAL_II_EXPAND_TRILINOS_MPI_VECTOR "TrilinosWrappers::MPI::Vector")
-  # Note: Only CMake 3.0 and greater support line continuation with the "\" character
-  #       Elements of string lists are naturally separated by a ";"
-  SET(DEAL_II_EXPAND_TRILINOS_SACADO_TYPES_FAD
-      "Sacado::Fad::DFad<double>"
-      "Sacado::Fad::DFad<float>"
-      "Sacado::Fad::DFad<Sacado::Fad::DFad<double>>"
-      "Sacado::Fad::DFad<Sacado::Fad::DFad<float>>")
-  SET(DEAL_II_EXPAND_TRILINOS_SACADO_TYPES_RAD
-      "Sacado::Rad::ADvar<double>"
-      "Sacado::Rad::ADvar<float>"
-      "Sacado::Rad::ADvar<Sacado::Fad::DFad<double>>"
-      "Sacado::Rad::ADvar<Sacado::Fad::DFad<float>>")
-
   IF (TRILINOS_WITH_MPI)
     SET(DEAL_II_EXPAND_EPETRA_VECTOR "LinearAlgebra::EpetraWrappers::Vector")
   ENDIF()
-  IF (TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD)
-    SET(DEAL_II_TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD ${TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD})
+  IF(${DEAL_II_TRILINOS_WITH_SACADO})
+    # Note: Only CMake 3.0 and greater support line continuation with the "\" character
+    #       Elements of string lists are naturally separated by a ";"
+    SET(DEAL_II_EXPAND_TRILINOS_SACADO_TYPES_FAD
+        "Sacado::Fad::DFad<double>"
+        "Sacado::Fad::DFad<float>"
+        "Sacado::Fad::DFad<Sacado::Fad::DFad<double>>"
+        "Sacado::Fad::DFad<Sacado::Fad::DFad<float>>")
+    SET(DEAL_II_EXPAND_TRILINOS_SACADO_TYPES_RAD
+        "Sacado::Rad::ADvar<double>"
+        "Sacado::Rad::ADvar<float>"
+        "Sacado::Rad::ADvar<Sacado::Fad::DFad<double>>"
+        "Sacado::Rad::ADvar<Sacado::Fad::DFad<float>>")
+
+    IF (TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD)
+      SET(DEAL_II_TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD ${TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD})
+    ENDIF()
   ENDIF()
 ENDMACRO()
 
index ce656553db02153eb968195f9816b50500fe56a0..a0021b33986c69ac97c7bd822db3f1fceb6789db 100644 (file)
 #   TRILINOS_VERSION_MAJOR
 #   TRILINOS_VERSION_MINOR
 #   TRILINOS_VERSION_SUBMINOR
-#   TRILINOS_WITH_MANDATORY_CXX11
 #   TRILINOS_WITH_MPI
-#   TRILINOS_SUPPORTS_CPP11
-#   TRILINOS_HAS_C99_TR1_WORKAROUND
-#   TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
 #
 
 SET(TRILINOS_DIR "" CACHE PATH "An optional hint to a Trilinos installation")
@@ -114,99 +110,6 @@ IF(EXISTS ${EPETRA_CONFIG_H})
   ENDIF()
 ENDIF()
 
-#
-# Look for Sacado_config.h - we'll query it to determine C++11 support:
-#
-DEAL_II_FIND_FILE(SACADO_CONFIG_H Sacado_config.h
-  HINTS ${Trilinos_INCLUDE_DIRS}
-  NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
-  NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
-  )
-
-SET(TRILINOS_WITH_MANDATORY_CXX11 FALSE)
-IF(EXISTS ${SACADO_CONFIG_H})
-  #
-  # Determine whether Trilinos was configured with C++11 support and
-  # enabling C++11 in deal.II is mandatory.
-  #
-  FILE(STRINGS "${SACADO_CONFIG_H}" SACADO_CXX11_STRING
-    REGEX "#define HAVE_SACADO_CXX11")
-  IF(NOT "${SACADO_CXX11_STRING}" STREQUAL "")
-    SET(TRILINOS_WITH_MANDATORY_CXX11 TRUE)
-  ENDIF()
-ENDIF()
-
-#
-# Some versions of Sacado_cmath.hpp do things that aren't compatible
-# with the -std=c++0x flag of GCC, see deal.II FAQ.
-# Test whether that is indeed the case:
-#
-
-DEAL_II_FIND_FILE(SACADO_CMATH_HPP Sacado_cmath.hpp
-  HINTS ${Trilinos_INCLUDE_DIRS}
-  NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
-  NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
-  )
-
-IF(EXISTS ${SACADO_CMATH_HPP})
-  LIST(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
-  PUSH_CMAKE_REQUIRED("${DEAL_II_CXX_VERSION_FLAG}")
-
-  CHECK_CXX_SOURCE_COMPILES(
-    "
-    #include <Sacado_cmath.hpp>
-    int main(){ return 0; }
-    "
-    TRILINOS_SUPPORTS_CPP11
-    )
-
-  #
-  # Try whether exporting HAS_C99_TR1_CMATH helps:
-  #
-  PUSH_CMAKE_REQUIRED("-DHAS_C99_TR1_CMATH")
-  CHECK_CXX_SOURCE_COMPILES(
-    "
-    #include <Sacado_cmath.hpp>
-    int main(){ return 0; }
-    "
-    TRILINOS_HAS_C99_TR1_WORKAROUND
-    )
-  RESET_CMAKE_REQUIRED()
-ENDIF()
-
-#
-# GCC 6.3.0 has a bug that prevents the creation of complex
-# numbers templated on Sacado::Rad::ADvar types:
-#
-# include/c++/6.3.0/complex: In instantiation of ‘struct std::complex<Sacado::Rad::ADvar<double> >’:
-# include/c++/6.3.0/complex:206:16: error: ‘std::complex<_Tp>& std::complex<_Tp>::operator=(const std::complex<_Tp>&) [with _Tp = Sacado::Rad::ADvar<double>]’ declared to take const reference, but implicit declaration would take non-const
-#
-# Test whether the compiler hits this issue
-#
-DEAL_II_FIND_FILE(SACADO_TRAD_HPP Sacado_trad.hpp
-  HINTS ${Trilinos_INCLUDE_DIRS}
-  NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH
-  NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH
-  )
-
-IF(EXISTS ${SACADO_TRAD_HPP})
-  LIST(APPEND CMAKE_REQUIRED_INCLUDES ${Trilinos_INCLUDE_DIRS})
-  PUSH_CMAKE_REQUIRED("${DEAL_II_CXX_VERSION_FLAG}")
-
-  CHECK_CXX_SOURCE_COMPILES(
-    "
-    #include <Sacado_trad.hpp>
-    int main ()
-    {
-      Sacado::Rad::ADvar<double> sacado_rad_double; // Works
-      std::complex<Sacado::Rad::ADvar<double> > complex_sacado_rad_double; // Doesn't work
-      return 0;
-    }
-    "
-    TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
-    )
-  RESET_CMAKE_REQUIRED()
-ENDIF()
 
 #
 # *Boy* Sanitize variables that are exported by TrilinosConfig.cmake...
@@ -257,6 +160,6 @@ DEAL_II_PACKAGE_HANDLE(TRILINOS
     OPTIONAL Trilinos_TPL_INCLUDE_DIRS
   CLEAR
     TRILINOS_CONFIG_DIR EPETRA_CONFIG_H SACADO_CMATH_HPP ${_libraries}
-    TRILINOS_SUPPORTS_CPP11 TRILINOS_HAS_C99_TR1_WORKAROUND SACADO_CONFIG_H
+    SACADO_CONFIG_H
     TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
   )
index 59ae8864deddabc27fc68351f953648e36de3e53..a00a050041b9d2e51e377dc2e4872622e63cbda8 100644 (file)
@@ -40,12 +40,12 @@ ENDIF()
 #
 # Are all dependencies fulfilled?
 #
-IF(NOT DEAL_II_WITH_TRILINOS) # keep in one line
+IF(NOT DEAL_II_TRILINOS_WITH_SACADO) # keep in one line
   MESSAGE(FATAL_ERROR "
 Error! This tutorial requires a deal.II library that was configured with the following options:
-    DEAL_II_WITH_TRILINOS = ON
+    DEAL_II_TRILINOS_WITH_SACADO = ON
 However, the deal.II library found at ${DEAL_II_PATH} was configured with these options
-    DEAL_II_WITH_TRILINOS = ${DEAL_II_WITH_TRILINOS}
+    DEAL_II_TRILINOS_WITH_SACADO = ${DEAL_II_TRILINOS_WITH_SACADO}
 which conflict with the requirements."
     )
 ENDIF()
index 3b5609d1e7513b7ea41fa21acf5a62b4f139aed6..717ca8b89769c09d77ac2e252b590163be24dd3c 100644 (file)
 /* cmake/configure/configure_2_trilinos.cmake */
 #cmakedefine DEAL_II_TRILINOS_CXX_SUPPORTS_SACADO_COMPLEX_RAD
 #cmakedefine DEAL_II_TRILINOS_WITH_ROL
+#cmakedefine DEAL_II_TRILINOS_WITH_SACADO
 #cmakedefine DEAL_II_TRILINOS_WITH_ZOLTAN
 
 
index db7c151643b8d54153cb4a9f28b6ad9b3f259bf8..5123c9ed127470d18d6582420bf36caaf90a5f2f 100644 (file)
@@ -53,7 +53,7 @@ DEAL_II_NAMESPACE_CLOSE
 // but header indirectly references numbers.h. We therefore simply
 // import the whole Sacado header at this point to get the math
 // functions imported into the standard namespace.
-#ifdef DEAL_II_WITH_TRILINOS
+#ifdef DEAL_II_TRILINOS_WITH_SACADO
 #  include <Sacado.hpp>
 #endif
 
index 2b446c8f9fffe895d9b67317d85249fa097cfac0..53b6bedf9625480015520155bcc1b2c3ef7dcf96 100644 (file)
@@ -18,7 +18,7 @@
 
 #include <deal.II/base/config.h>
 
-#ifdef DEAL_II_WITH_TRILINOS
+#ifdef DEAL_II_TRILINOS_WITH_SACADO
 
 #  include <deal.II/base/numbers.h>
 
index 5139fce83089174f3f3278988b3dc88a98bb7740..44970b11177f91bd97f3e6be0d78167594b7a5ee 100644 (file)
@@ -71,7 +71,7 @@ DEAL_II_NAMESPACE_CLOSE
 
 
 
-#ifdef DEAL_II_WITH_TRILINOS
+#ifdef DEAL_II_TRILINOS_WITH_SACADO
 
 DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
 #  include <Sacado.hpp>
index e4faee351070764d39e1eb8b5f922a4d04bbc64a..cd8ea8bedcac7009588ad26c8abeba02f47642bd 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <deal.II/base/template_constraints.h>
 
-#ifdef DEAL_II_WITH_TRILINOS
+#ifdef DEAL_II_TRILINOS_WITH_SACADO
 
 #  include <Sacado.hpp>
 // It appears that some versions of Trilinos do not directly or indirectly
index ec2a10b5118da836a6dfc7fb909be86812d4a66c..582a74d6dbba8515b6de521b869c2fdc40583194 100644 (file)
@@ -16,7 +16,7 @@
 
 #include <deal.II/base/config.h>
 
-#ifdef DEAL_II_WITH_TRILINOS
+#ifdef DEAL_II_TRILINOS_WITH_SACADO
 
 #  include <deal.II/differentiation/ad/sacado_number_types.h>
 
index d2d115e8210f8bab0b75513290706841f11e8d1c..6186bb48d91129a025a9d0596effedfdc957164a 100644 (file)
@@ -1,6 +1,6 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
 INCLUDE(../setup_testsubproject.cmake)
 PROJECT(testsuite CXX)
-IF(DEAL_II_WITH_TRILINOS)
+IF(DEAL_II_WITH_TRILINOS AND DEAL_II_TRILINOS_WITH_SACADO)
   DEAL_II_PICKUP_TESTS()
 ENDIF()

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.