diff --git a/cmake/modules/AmdisMacros.cmake b/cmake/modules/AmdisMacros.cmake index b670bfcd309a3eb030325317e7b43ffa1b1c17e8..89f2aa55095eef4947fcf1b255f943eac65b84ca 100644 --- a/cmake/modules/AmdisMacros.cmake +++ b/cmake/modules/AmdisMacros.cmake @@ -23,18 +23,18 @@ endif (NOT BACKEND) if (BACKEND STREQUAL "MTL" OR BACKEND STREQUAL "MTL4") find_package(MTL REQUIRED) - set(HAVE_MTL TRUE) + set(AMDIS_HAS_MTL TRUE) message(STATUS " Found MTL, version: ${MTL_VERSION}") dune_register_package_flags(LIBRARIES MTL::MTL COMPILE_DEFINITIONS "ENABLE_MTL=1") find_package(HYPRE) if (HYPRE_FOUND) - set(HAVE_HYPRE TRUE) + set(AMDIS_HAS_HYPRE TRUE) dune_register_package_flags(LIBRARIES HYPRE::HYPRE COMPILE_DEFINITIONS "ENABLE_HYPRE=1") endif(HYPRE_FOUND) elseif (BACKEND STREQUAL "EIGEN" OR BACKEND STREQUAL "EIGEN3") find_package(Eigen3 REQUIRED 3.3.5) - set(HAVE_EIGEN TRUE) + set(AMDIS_HAS_EIGEN TRUE) if (EIGEN3_FOUND) message(STATUS " Found Eigen3, version: ${Eigen3_VERSION}") dune_register_package_flags(LIBRARIES Eigen3::Eigen COMPILE_DEFINITIONS "ENABLE_EIGEN=1") @@ -42,7 +42,7 @@ elseif (BACKEND STREQUAL "EIGEN" OR BACKEND STREQUAL "EIGEN3") elseif (BACKEND STREQUAL "PETSC") find_package(PETSc REQUIRED) if (PETSc_FOUND) - set(HAVE_PETSC TRUE) + set(AMDIS_HAS_PETSC TRUE) dune_register_package_flags(LIBRARIES PETSc::PETSc COMPILE_DEFINITIONS "ENABLE_PETSC=1") endif (PETSc_FOUND) elseif (BACKEND STREQUAL "ISTL") diff --git a/cmake/modules/FindHYPRE.cmake b/cmake/modules/FindHYPRE.cmake index f3fbf34ad47106e00798e3397db8ba41e0add0ed..4aec0766f31e19a9b869d6c94bb026cb6885cd6d 100644 --- a/cmake/modules/FindHYPRE.cmake +++ b/cmake/modules/FindHYPRE.cmake @@ -45,19 +45,20 @@ if (HYPRE_LIBRARY) set(HYPRE_LIBRARIES ${HYPRE_LIBRARY}) get_filename_component(HYPRE_LIBRARY_DIR ${HYPRE_LIBRARY} DIRECTORY) - foreach(_lib_name "HYPRE_FEI" "HYPRE_core") - find_library(_lib ${_lib_name} HINTS ${HYPRE_LIBRARY_DIR} NO_DEFAULT_PATH) - if (_lib) - list(APPEND HYPRE_LIBRARIES ${_lib}) - endif (_lib) - unset(_lib) + file(GLOB HYPRE_LIB_NAMES LIST_DIRECTORIES false RELATIVE ${HYPRE_LIBRARY_DIR} "${HYPRE_LIBRARY_DIR}/*HYPRE_*.*") + foreach(_lib_name_long ${HYPRE_LIB_NAMES}) + string(REGEX REPLACE "^(lib)?HYPRE_([a-zA-Z_]+)([0-9.-]*)[.][a-zA-Z]+$" "\\2" _lib_name "${_lib_name_long}") + set(LIB_VAR "_lib_${_lib_name}") + find_library(${LIB_VAR} "HYPRE_${_lib_name}" HINTS ${HYPRE_LIBRARY_DIR} NO_DEFAULT_PATH) + if (${LIB_VAR}) + list(APPEND HYPRE_LIBRARIES ${${LIB_VAR}}) + endif () endforeach() - unset(_lib_name) endif (HYPRE_LIBRARY) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HYPRE - REQUIRED_VARS HYPRE_INCLUDE_DIR HYPRE_LIBRARY + REQUIRED_VARS HYPRE_INCLUDE_DIR HYPRE_LIBRARIES ) # text for feature summary diff --git a/config.h.cmake b/config.h.cmake index 9317b1e2b2a8e976ecb3ef4dd1e5123a714febe0..dec89319b54084202d35a8b5fdeab9443f3b56cd 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -41,16 +41,16 @@ #define AMDIS_VERSION_REVISION @AMDIS_VERSION_REVISION@ /* Define to true if the MTL library is available */ -#cmakedefine HAVE_MTL 1 +#cmakedefine AMDIS_HAS_MTL 1 /* Define to true if the HYPRE library is available */ -#cmakedefine HAVE_HYPRE ENABLE_HYPRE +#cmakedefine AMDIS_HAS_HYPRE ENABLE_HYPRE /* Define to true if the Eigen3 library is available */ -#cmakedefine HAVE_EIGEN 1 +#cmakedefine AMDIS_HAS_EIGEN 1 /* Define to true if the PETSc library is available */ -#cmakedefine HAVE_PETSC 1 +#cmakedefine AMDIS_HAS_PETSC 1 /* some detected compiler features may be used in AMDiS */ #cmakedefine AMDIS_HAS_CXX_FOLD_EXPRESSIONS 1 diff --git a/doc/doxygen/Doxylocal b/doc/doxygen/Doxylocal index 619234870f219886a490645697249b2dd7f8d96f..5c018991998633379d1da6ae6c39af5a6a1feabe 100644 --- a/doc/doxygen/Doxylocal +++ b/doc/doxygen/Doxylocal @@ -20,7 +20,8 @@ EXCLUDE_SYMBOLS = AMDiS::Impl \ PREDEFINED += HAVE_UMFPACK \ HAVE_ALBERTA \ HAVE_UG \ - HAVE_MTL + AMDIS_HAS_MTL \ + AMDIS_HAS_HYPRE # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or diff --git a/src/amdis/LinearAlgebra.hpp b/src/amdis/LinearAlgebra.hpp index ce3ef3fe6f8e403c49b43ef8209175371db8f64f..f8c5d4deab283229e1b032572e5793f8d15e5af6 100644 --- a/src/amdis/LinearAlgebra.hpp +++ b/src/amdis/LinearAlgebra.hpp @@ -1,6 +1,6 @@ #pragma once -#if HAVE_MTL +#if AMDIS_HAS_MTL #include #include @@ -9,7 +9,7 @@ #include #include -#elif HAVE_EIGEN +#elif AMDIS_HAS_EIGEN #include #include @@ -17,7 +17,7 @@ #include #include -#elif HAVE_PETSC +#elif AMDIS_HAS_PETSC #include #include diff --git a/src/amdis/common/StaticSize.hpp b/src/amdis/common/StaticSize.hpp index dca6423424c990a521a9c62de63814ba0b14e087..0745ba91f3ce4ddbeb5d99dfa6e2efe0961d14f4 100644 --- a/src/amdis/common/StaticSize.hpp +++ b/src/amdis/common/StaticSize.hpp @@ -7,7 +7,7 @@ #include #include -#if HAVE_MTL +#if AMDIS_HAS_MTL #include #endif @@ -18,7 +18,7 @@ namespace AMDiS template struct SizeImpl { -#if HAVE_MTL +#if AMDIS_HAS_MTL // MTL4: Try if a mtl::static_size is specialized for class template static constexpr auto eval(T const&, Dune::PriorityTag<6>) @@ -117,7 +117,7 @@ namespace AMDiS template struct NumRowsImpl { -#if HAVE_MTL +#if AMDIS_HAS_MTL // MTL4: Try if a mtl::static_num_rows is specialized for class template static constexpr auto eval(T const&, Dune::PriorityTag<4>) @@ -199,7 +199,7 @@ namespace AMDiS template struct NumColsImpl { -#if HAVE_MTL +#if AMDIS_HAS_MTL // MTL4: Try if a mtl::static_num_cols is specialized for class template static constexpr auto eval(T const&, Dune::PriorityTag<4>) diff --git a/src/amdis/linearalgebra/Traits.hpp b/src/amdis/linearalgebra/Traits.hpp index 30f08052c2bf61bd583a9ab464e82dc5d68d86d1..600643fd95e7d0272537dbdc77ca680ea69e674a 100644 --- a/src/amdis/linearalgebra/Traits.hpp +++ b/src/amdis/linearalgebra/Traits.hpp @@ -1,12 +1,12 @@ #pragma once -#if HAVE_MTL +#if AMDIS_HAS_MTL #include -#elif HAVE_EIGEN +#elif AMDIS_HAS_EIGEN #include -#elif HAVE_PETSC +#elif AMDIS_HAS_PETSC #include #else // ISTL @@ -33,6 +33,7 @@ namespace AMDiS using Comm = implementation_defined; //< The communication type using CoefficientType = T; //< The type of the matrix/vector entries + using SparsityPattern = implementation_defined; //< The SparsityPattern for the matrix type using PartitionSet = Dune::Partitions::All; //< The dune partition set where to assemble operators }; #endif diff --git a/src/amdis/linearalgebra/mtl/HyprePrecon.hpp b/src/amdis/linearalgebra/mtl/HyprePrecon.hpp index fb6935196b37201b75976a1bf7fd912ed9704067..c3dee76cdb1d97fad7233808221766228f2d6d08 100644 --- a/src/amdis/linearalgebra/mtl/HyprePrecon.hpp +++ b/src/amdis/linearalgebra/mtl/HyprePrecon.hpp @@ -1,8 +1,11 @@ #pragma once -#if HAVE_HYPRE +#if AMDIS_HAS_HYPRE && HAVE_MPI + +#include #include +#include #include namespace AMDiS @@ -150,4 +153,4 @@ namespace AMDiS } // end namespace AMDiS -#endif // HAVE_HYPRE +#endif // AMDIS_HAS_HYPRE && HAVE_MPI diff --git a/src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp b/src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp index 1bb2a41312f86be043bb8902deb8cb6387407629..6e345e85e270d699a0fadea4cc0fac0ced96808f 100644 --- a/src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp +++ b/src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp @@ -7,15 +7,12 @@ #include #include +#include #include #include #include #include -#if HAVE_HYPRE -#include -#endif - namespace AMDiS { /** @@ -116,12 +113,18 @@ namespace AMDiS auto pc_solver = new typename SolverPrecon::Creator; Map::addCreator("solver", pc_solver); -#if HAVE_HYPRE + Map::addCreator("default", pc_id); + + init_hypre(std::is_same::real_type, double>{}); + } + + static void init_hypre(std::false_type) {} + static void init_hypre(std::true_type) + { +#if AMDIS_HAS_HYPRE && HAVE_MPI auto pc_hypre = new typename HyprePrecon::Creator; Map::addCreator("hypre", pc_hypre); #endif - - Map::addCreator("default", pc_id); } }; diff --git a/src/amdis/linearalgebra/mtl/itl/hypre.hpp b/src/amdis/linearalgebra/mtl/itl/hypre.hpp index 0c4540708dda77e139552147051abeca23908d13..aa3398674ac90a7eb340faec98299953331343c9 100644 --- a/src/amdis/linearalgebra/mtl/itl/hypre.hpp +++ b/src/amdis/linearalgebra/mtl/itl/hypre.hpp @@ -1,6 +1,6 @@ #pragma once -#if MTL_HAS_HYPRE && HAVE_MPI +#if AMDIS_HAS_HYPRE && HAVE_MPI #include #include @@ -255,4 +255,4 @@ namespace mtl } // end namespace mtl -#endif // MTL_HAS_HYPRE +#endif // AMDIS_HAS_HYPRE && HAVE_MPI diff --git a/test/DOFMappingTest.cpp b/test/DOFMappingTest.cpp index ee8e361e1e77a95ebea9c194ec1b68f3afd4ea2f..5a0fe9ccde02d4ae7683c0432489ad5b4baeae8b 100644 --- a/test/DOFMappingTest.cpp +++ b/test/DOFMappingTest.cpp @@ -11,7 +11,7 @@ #include -#if HAVE_PETSC +#if AMDIS_HAS_PETSC #include #endif @@ -118,7 +118,7 @@ int main(int argc, char** argv) } } -#if HAVE_PETSC +#if AMDIS_HAS_PETSC Vec v; VecCreateMPI(comm, mapping.localSize(), mapping.globalSize(), &v); VecSet(v,0.0); diff --git a/test/StaticSizeTest.cpp b/test/StaticSizeTest.cpp index 9ef7284e6c092eae4a295a9518d5233e092adaa0..119dcb79dfd150a6765e53ecfb0c270ad93d7b39 100644 --- a/test/StaticSizeTest.cpp +++ b/test/StaticSizeTest.cpp @@ -6,7 +6,7 @@ #include #include -#if HAVE_EIGEN +#if AMDIS_HAS_EIGEN #include #endif @@ -47,7 +47,7 @@ int main(int argc, char** argv) static_assert(static_num_rows_v == 2, ""); static_assert(static_num_cols_v == 2, ""); -#if HAVE_EIGEN +#if AMDIS_HAS_EIGEN using Vec6 = Eigen::Vector2d; using Vec7 = Eigen::Matrix; using Vec8 = Eigen::Matrix;