amdis_parallel.cmake 6.82 KB
Newer Older
1 2
if (ENABLE_PARALLEL_DOMAIN)
    option(ENABLE_ZOLTAN "Add support for the Parallel Partitioning suite Zoltan" false)
3 4
    option(ENABLE_PARALLEL_SOLVERS "Add some problem dependent solver, e.g. Feti, Navier-Stokes and Cahn-Hilliard" true)
    mark_as_advanced(ENABLE_PARALLEL_SOLVERS)
5

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    add_library(amdis_parallel INTERFACE)
    target_sources(amdis PRIVATE
        ${SOURCE_DIR}/parallel/DofComm.cc
        ${SOURCE_DIR}/parallel/CheckerPartitioner.cc
        ${SOURCE_DIR}/parallel/ElementObjectDatabase.cc
        ${SOURCE_DIR}/parallel/InteriorBoundary.cc
        ${SOURCE_DIR}/parallel/MeshDistributor.cc
        ${SOURCE_DIR}/parallel/MeshLevelData.cc
        ${SOURCE_DIR}/parallel/MeshManipulation.cc
        ${SOURCE_DIR}/parallel/MeshPartitioner.cc
        ${SOURCE_DIR}/parallel/MpiHelper.cc
        ${SOURCE_DIR}/parallel/ParallelDofMapping.cc
        ${SOURCE_DIR}/parallel/ParallelProblemStat.cc
        ${SOURCE_DIR}/parallel/ParallelSolver.cc
        ${SOURCE_DIR}/parallel/PeriodicMap.cc
        ${SOURCE_DIR}/parallel/ParMetisPartitioner.cc
        ${SOURCE_DIR}/parallel/StdMpi.cc
    )
24

25 26
    target_sources(amdis_debug INTERFACE
        ${SOURCE_DIR}/parallel/ParallelDebug.cc
27
    )
28

29 30
    target_compile_definitions(amdis_parallel INTERFACE
	   HAVE_PARALLEL_DOMAIN_AMDIS=1)
31

32 33
    # MPI is required
    find_package(MPI REQUIRED)
34 35 36 37 38 39 40
    target_include_directories(amdis_parallel INTERFACE
        ${MPI_CXX_INCLUDE_PATH})
    target_compile_options(amdis_parallel INTERFACE
        ${MPI_CXX_COMPILE_FLAGS})
    string(STRIP " ${MPI_CXX_LINK_FLAGS} " MPI_CXX_LINK_FLAGS_)
    target_link_libraries(amdis_parallel INTERFACE
      ${MPI_CXX_LINK_FLAGS_} ${MPI_CXX_LIBRARIES})
41

42
    # PETSc library is required
43
    find_package(petsc QUIET)
44
    if (PETSc_FOUND)
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
      set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDES})
      set(PETSC_LIBRARY_DIRS ${PETSC_LIB_DIR})
      message(STATUS "  Found PETSc, version ${PETSC_VERSION}")
    else (PETSc_FOUND)
      include(FindPkgConfig)
      find_file(PETSC_PKG_CONFIG "PETSc.pc"
        HINTS ${PETSC_DIR}/lib/pkgconfig
              ${PETSC_ROOT}/lib/pkgconfig
              /usr/lib/petsc/lib/pkgconfig
              /usr/lib/petsc/linux-gnu-cxx-opt/lib/pkgconfig
              /usr/lib/petsc/linux-gnu-c-opt/lib/pkgconfig)
      if (PETSC_PKG_CONFIG-NOTFOUND)
        message(FATAL_ERROR "PETSc PKG-Config file 'PETSc.pc' could not be found. Set variable PETSC_DIR to the directory where this file is located!")
      endif (PETSC_PKG_CONFIG-NOTFOUND)

      get_filename_component(PETSC_PKG_CONFIG_PATH "${PETSC_PKG_CONFIG}" PATH CACHE)
      set(ENV{PKG_CONFIG_PATH} ${PETSC_PKG_CONFIG_PATH})
      pkg_check_modules(PETSC REQUIRED PETSc>=3.3)

      set(PETSC_DEFINITIONS ${PETSC_CFLAGS} ${PETSC_CFLAGS_OTHER})
    endif (PETSc_FOUND)


    target_include_directories(amdis_parallel INTERFACE
        ${PETSC_INCLUDE_DIRS})

    # parmetis is required
    find_file(PARMETIS_HEADER_FILE "parmetis.h"
      HINTS ${PARMETIS_DIR}/include ${PETSC_INCLUDE_DIRS})
    if (PARMETIS_HEADER_FILE)
        get_filename_component(PARMETIS_INCLUDE_PATH "${PARMETIS_HEADER_FILE}" PATH CACHE)
        target_include_directories(amdis_parallel INTERFACE ${PARMETIS_INCLUDE_PATH})
    else()
        message(FATAL_ERROR "Could not find ParMetis header file 'parmetis.h'!")
    endif (PARMETIS_HEADER_FILE)

    # blas library is required
    find_library(BLAS_LIB
      NAMES blas fblas openblas
      HINTS ${BLAS_DIR}/lib ${PETSC_LIBRARY_DIRS} /usr/lib/openblas-base /usr/lib/atlas-base)
    if (BLAS_LIB)
      set(BLAS_LIBRARIES ${BLAS_LIB})
    else (BLAS_LIB)
      find_package(BLAS REQUIRED)
    endif (BLAS_LIB)

    # lapack library is required
    find_library(LAPACK_LIB
      NAMES lapack flapack
      HINTS ${LAPACK_DIR}/lib ${PETSC_LIBRARY_DIRS} ${PETSC_DIR}/lib)
    if (LAPACK_LIB)
      set(LAPACK_LIBRARIES ${LAPACK_LIB})
    else (LAPACK_LIB)
      find_package(LAPACK REQUIRED)
    endif (LAPACK_LIB)

    # add support for the zoltan library
    if (ENABLE_ZOLTAN)
        find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${ZOLTAN_DIR}/include ${PETSC_INCLUDE_DIRS})
        if (ZOLTAN_HEADER_FILE)
            get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE)
            target_include_directories(amdis_parallel INTERFACE ${ZOLTAN_HEADER_DIR})
107
        else()
108 109 110 111
            message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!")
        endif(ZOLTAN_HEADER_FILE)

        target_compile_definitions(amdis_parallel INTERFACE HAVE_ZOLTAN=1)
112
        target_sources(amdis PRIVATE
113 114 115 116 117 118 119 120
            ${SOURCE_DIR}/parallel/ZoltanPartitioner.cc)
    endif (ENABLE_ZOLTAN)

    if (ENABLE_BDDCML)
        target_compile_definitions(amdis_parallel INTERFACE HAVE_BDDCML=1)
        target_sources(amdis PRIVATE
            ${SOURCE_DIR}/parallel/BddcMlSolver.cc)
    endif (ENABLE_BDDCML)
121

122 123 124 125 126 127 128 129 130 131
    # add some more source-files that need petsc
    target_sources(amdis PRIVATE
        ${SOURCE_DIR}/parallel/MatrixNnzStructure.cc
        ${SOURCE_DIR}/parallel/ParallelCoarseSpaceSolver.cc
        ${SOURCE_DIR}/parallel/PetscHelper.cc
        ${SOURCE_DIR}/parallel/PetscSolver.cc
        ${SOURCE_DIR}/parallel/PetscSolverGlobalMatrix.cc
        ${SOURCE_DIR}/parallel/PetscSolverGlobalBlockMatrix.cc
        ${SOURCE_DIR}/solver/PetscTypes.cc
    )
132

133 134 135 136 137 138 139 140 141 142 143 144 145
    if (ENABLE_PARALLEL_SOLVERS)
        target_sources(amdis PRIVATE
            ${SOURCE_DIR}/parallel/PetscSolverFeti.cc
            ${SOURCE_DIR}/parallel/PetscSolverFetiDebug.cc
            ${SOURCE_DIR}/parallel/PetscSolverFetiMonitor.cc
            ${SOURCE_DIR}/parallel/PetscSolverFetiOperators.cc
            ${SOURCE_DIR}/parallel/PetscSolverFetiTimings.cc
            ${SOURCE_DIR}/parallel/PetscSolverNavierStokes.cc
            ${SOURCE_DIR}/parallel/PetscSolverNSCH.cc
            ${SOURCE_DIR}/parallel/PetscSolverCahnHilliard2.cc
            ${SOURCE_DIR}/parallel/PetscSolverCahnHilliard.cc
            ${SOURCE_DIR}/parallel/PetscSolverSchur.cc
        )
146
        target_compile_definitions(amdis_parallel INTERFACE
147 148
            HAVE_PARALLEL_SOLVERS=1)
    endif (ENABLE_PARALLEL_SOLVERS)
149

150 151 152 153 154 155 156
    target_compile_definitions(amdis_parallel INTERFACE
        HAVE_PARALLEL_PETSC=1
        PETSC_VERSION=${PETSC_VERSION})
    target_compile_options(amdis_parallel INTERFACE
        ${PETSC_DEFINITIONS})

    target_link_libraries(amdis amdis_parallel ${PETSC_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
157

158 159
    # specify how to install this target:
    # -----------------------------------
160

161 162
    file(GLOB AMDIS_PARALLEL_HEADERS "${SOURCE_DIR}/parallel/*.h")
    install(FILES ${AMDIS_PARALLEL_HEADERS} DESTINATION include/amdis/parallel/)
163 164 165 166

    install(FILES
        ${BASE_DIR}/cmake3/ResolveCompilerPaths.cmake
        ${BASE_DIR}/cmake3/FindPackageMultipass.cmake
167 168
        ${BASE_DIR}/cmake3/CorrectWindowsPaths.cmake
        ${BASE_DIR}/cmake3/FindPETSc.cmake
169
        DESTINATION share/amdis/)
170
endif (ENABLE_PARALLEL_DOMAIN)