amdis_parallel.cmake 4.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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 107 108 109 110 111 112
if (ENABLE_PARALLEL_DOMAIN)
    option(ENABLE_ZOLTAN "Add support for the Parallel Partitioning suite Zoltan" false)
    option(ENABLE_PARALLEL_SOLVERS "Add some problem dependent solver, e.g. Feti, Navier-Stokes and Cahn-Hilliard" false)
    
    add_library(amdis_parallel
	${SOURCE_DIR}/parallel/BddcMlSolver.cc
	${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/ParallelDebug.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
	${SOURCE_DIR}/parallel/ZoltanPartitioner.cc
    )
    add_library(AMDiS::parallel ALIAS amdis_parallel)
  
    target_compile_definitions(amdis_parallel PUBLIC
	HAVE_PARALLEL_DOMAIN_AMDIS=1)
    target_link_libraries(amdis_parallel amdis_base)
  
    # MPI is required
    find_package(MPI REQUIRED)
    if (MPI_FOUND)
	target_include_directories(amdis_parallel PUBLIC
	    ${MPI_INCLUDE_PATH})
	target_compile_options(amdis_parallel PUBLIC
	    ${MPI_COMPILE_FLAGS})
    endif (MPI_FOUND)
  
    # PETSc library is required
    set(PETSC_EXECUTABLE_RUNS ON)
    include(find_petsc)
    if (PETSc_FOUND)
	target_include_directories(amdis_parallel PUBLIC
	    ${PETSC_DIR}/include 
	    ${PETSC_DIR}/${PETSC_ARCH}/include)
    
	# parmetis is required
	find_file(PARMETIS_HEADER_FILE "parmetis.h" HINTS ${PETSC_DIR}/include )
	if (PARMETIS_HEADER_FILE)
	    get_filename_component(PARMETIS_INCLUDE_PATH "${PARMETIS_HEADER_FILE}" PATH CACHE)
	    target_include_directories(amdis_parallel PUBLIC ${PARMETIS_INCLUDE_PATH})
	else()
	    message(FATAL_ERROR "Could not find ParMetis header file 'parmetis.h'!")
	endif (PARMETIS_HEADER_FILE)
	
	# add support for the zoltan library
	if (ENABLE_ZOLTAN)
	    find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${PETSC_DIR}/include)
	    if (ZOLTAN_HEADER_FILE)
		get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE)
		target_include_directories(amdis_parallel PRIVATE ${ZOLTAN_HEADER_DIR})
		target_compile_definitions(amdis_parallel PRIVATE HAVE_ZOLTAN=1)
	    else()
		message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!")
	    endif(ZOLTAN_HEADER_FILE)
	endif (ENABLE_ZOLTAN)
	
	# add some more source-files that need petsc
	target_sources(amdis_parallel 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
	)
	    
	if (ENABLE_PARALLEL_SOLVERS)
	target_sources(amdis_parallel 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
	)
	endif (ENABLE_PARALLEL_SOLVERS)
	    
	target_compile_definitions(amdis_parallel PUBLIC
	    HAVE_PARALLEL_PETSC=1
	    PETSC_VERSION=${PETSC_VERSION})
    endif (PETSc_FOUND)
    
    # specify how to install this target:
    # -----------------------------------
    
    file(GLOB AMDIS_PARALLEL_HEADERS "${SOURCE_DIR}/parallel/*.h")
    install(FILES ${AMDIS_PARALLEL_HEADERS} DESTINATION include/amdis/parallel/)
    install(TARGETS amdis_parallel DESTINATION lib/amdis/ )
    
    install(FILES 
	${BASE_DIR}/cmake3/ResolveCompilerPaths.cmake 
	${BASE_DIR}/cmake3/FindPackageMultipass.cmake 
	${BASE_DIR}/cmake3/find_petsc.cmake
	DESTINATION share/amdis/)
endif (ENABLE_PARALLEL_DOMAIN)