From 32fd7bcc576b8297ea208ae54115c8e1805e3678 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sat, 20 Feb 2016 12:50:19 +0000 Subject: [PATCH] CMakeLists changed - must be tested further --- AMDiS/CMakeLists.txt | 559 +---------------------- AMDiS/cmake/CMakeLists_2.8.txt | 548 ++++++++++++++++++++++ AMDiS/cmake/PETScConfig.cmake | 251 ++++++++++ AMDiS/cmake/enable_extensions.cmake | 3 + AMDiS/cmake/enable_parallel_domain.cmake | 2 +- AMDiS/cmake3/AMDISConfig.cmake.in | 199 ++++++++ AMDiS/cmake3/CMakeLists_3.0.txt | 219 +++++++++ AMDiS/cmake3/FindPackageMultipass.cmake | 91 ++++ AMDiS/cmake3/ResolveCompilerPaths.cmake | 93 ++++ AMDiS/cmake3/amdis_compositeFEM.cmake | 26 ++ AMDiS/cmake3/amdis_parallel.cmake | 112 +++++ AMDiS/cmake3/amdis_reinit.cmake | 19 + AMDiS/cmake3/find_boost.cmake | 7 + AMDiS/cmake3/find_mtl4.cmake | 48 ++ AMDiS/cmake3/find_petsc.cmake | 248 ++++++++++ AMDiS/cmake3/muparser.cmake | 32 ++ AMDiS/src/Config.h | 9 + AMDiS/src/Initfile.cc | 15 + AMDiS/src/Initfile.h | 16 +- AMDiS/src/parallel/MeshDistributor.h | 59 +++ demo/CMakeLists.txt | 12 +- 21 files changed, 2004 insertions(+), 564 deletions(-) create mode 100644 AMDiS/cmake/CMakeLists_2.8.txt create mode 100644 AMDiS/cmake/PETScConfig.cmake create mode 100644 AMDiS/cmake3/AMDISConfig.cmake.in create mode 100644 AMDiS/cmake3/CMakeLists_3.0.txt create mode 100644 AMDiS/cmake3/FindPackageMultipass.cmake create mode 100644 AMDiS/cmake3/ResolveCompilerPaths.cmake create mode 100644 AMDiS/cmake3/amdis_compositeFEM.cmake create mode 100644 AMDiS/cmake3/amdis_parallel.cmake create mode 100644 AMDiS/cmake3/amdis_reinit.cmake create mode 100644 AMDiS/cmake3/find_boost.cmake create mode 100644 AMDiS/cmake3/find_mtl4.cmake create mode 100644 AMDiS/cmake3/find_petsc.cmake create mode 100644 AMDiS/cmake3/muparser.cmake diff --git a/AMDiS/CMakeLists.txt b/AMDiS/CMakeLists.txt index b0a3da6c..15cb4acf 100644 --- a/AMDiS/CMakeLists.txt +++ b/AMDiS/CMakeLists.txt @@ -1,547 +1,12 @@ -project(AMDIS) - -cmake_minimum_required(VERSION 2.6) -cmake_policy(SET CMP0017 OLD) -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) -endif() -if(POLICY CMP0054) - cmake_policy(SET CMP0054 NEW) -endif() - -SET(LIB_DIR ${AMDIS_SOURCE_DIR}/lib) -SET(SOURCE_DIR ${AMDIS_SOURCE_DIR}/src) - -#TODO: use the cmake build type -SET(MTL_INCLUDE_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory") - -# set global compile_definitions for all target, depending on build-type -set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS - $<$:DEBUG=1> - $<$:DEBUG=0>) - -# find_package(Subversion QUIET) -# if(Subversion_FOUND) -# Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} svn_info) -# #message("svn-rev: ${svn_info_WC_REVISION}") -# set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}") -# endif() -set(CurrentRevision "0.9") -if(NOT AMDIS_MAJOR) - set(AMDIS_MAJOR "0") -endif() -if(NOT AMDIS_MINOR) - set(AMDIS_MINOR "9") -endif() -list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}") - -#define the build type, empty can be everything and nothing -if(CMAKE_BUILD_TYPE STREQUAL "") - set(CMAKE_BUILD_TYPE "Release") -endif() - -if(CMAKE_CXX_COMPILER MATCHES ".*icpc") - Message("Compiler: Intel") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable 654 -diag-disable 858") -endif() - - -SET(ENABLE_PARALLEL_DOMAIN "OFF" CACHE STRING "use parallel domain decomposition. please set to one of: PMTL, PETSC, OFF" ) -option(ENABLE_CXX11 "Enable C++11 compiler features" false) -option(ENABLE_SEQ_PETSC "Use sequential PETSc solvers" false) -option(ENABLE_UMFPACK "Use of UMFPACK solver" false) -option(ENABLE_HYPRE "Use HYPRE AMG solver" false) -option(ENABLE_PNG "use png reader/writer" false) -option(ENABLE_BDDCML "Use of BDDCML library" false) -mark_as_advanced(ENABLE_BDDCML) -option(ENABLE_EXTENSIONS "Use extensions" false) -option(ENABLE_OPENMP "Use OpenMP" false) -option(ENABLE_COMPRESSION "Use output compression" false) -option(ENABLE_OUTPUT "AMDiS output printing, disable only for debugging!" true) -mark_as_advanced(ENABLE_OUTPUT) - - -find_package(Boost 1.44 REQUIRED) -if (Boost_FOUND) - list(APPEND AMDIS_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) - message("boost lib-dirs: ${Boost_LIBRARY_DIRS}") - message("use the boost dir: ${Boost_INCLUDE_DIR}") - #if (WIN32) - #message("the windows find_boost does not set the boost library paths, please set it") - #SET(Boost_LIBRARY_DIRS CACHE PATH "The directory containing the boost libraries") - #endif (WIN32) - list(APPEND AMDIS_LINK_DIRS ${Boost_LIBRARY_DIRS}) -endif (Boost_FOUND) - - -SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc - ${SOURCE_DIR}/AdaptInfo.cc - ${SOURCE_DIR}/AdaptInstationary.cc - ${SOURCE_DIR}/AdaptStationary.cc - ${SOURCE_DIR}/AMDiS.cc - ${SOURCE_DIR}/Assembler.cc - ${SOURCE_DIR}/BasisFunction.cc - ${SOURCE_DIR}/Boundary.cc - ${SOURCE_DIR}/BoundaryManager.cc - ${SOURCE_DIR}/BoundaryObject.cc - ${SOURCE_DIR}/Bubble.cc - ${SOURCE_DIR}/Cholesky.cc - ${SOURCE_DIR}/CoarseningManager.cc - ${SOURCE_DIR}/CoarseningManager1d.cc - ${SOURCE_DIR}/CoarseningManager2d.cc - ${SOURCE_DIR}/CoarseningManager3d.cc - ${SOURCE_DIR}/ComponentTraverseInfo.cc - ${SOURCE_DIR}/CouplingIterationInterface.cc - ${SOURCE_DIR}/CreatorMap.cc - ${SOURCE_DIR}/DOFAdmin.cc - ${SOURCE_DIR}/DOFIndexed.cc - ${SOURCE_DIR}/DOFMatrix.cc - ${SOURCE_DIR}/DOFVector.cc - ${SOURCE_DIR}/Debug.cc - ${SOURCE_DIR}/DirichletBC.cc - ${SOURCE_DIR}/DualTraverse.cc - ${SOURCE_DIR}/ElInfo.cc - ${SOURCE_DIR}/ElInfo1d.cc - ${SOURCE_DIR}/ElInfo2d.cc - ${SOURCE_DIR}/ElInfo3d.cc - ${SOURCE_DIR}/ElInfoStack.cc - ${SOURCE_DIR}/Element.cc - ${SOURCE_DIR}/ElementData.cc - ${SOURCE_DIR}/ElementDofIterator.cc - ${SOURCE_DIR}/ElementRegion_ED.cc - ${SOURCE_DIR}/FiniteElemSpace.cc - ${SOURCE_DIR}/FirstOrderAssembler.cc - ${SOURCE_DIR}/FirstOrderTerm.cc - ${SOURCE_DIR}/FixVec.cc - ${SOURCE_DIR}/Global.cc - ${SOURCE_DIR}/GlobalDOFNumbering.cc - ${SOURCE_DIR}/GlobalElementNumbering.cc - ${SOURCE_DIR}/Initfile.cc - ${SOURCE_DIR}/Lagrange.cc - ${SOURCE_DIR}/LeafData.cc - ${SOURCE_DIR}/Line.cc - ${SOURCE_DIR}/MacroElement.cc - ${SOURCE_DIR}/Marker.cc - ${SOURCE_DIR}/MatrixVector.cc - ${SOURCE_DIR}/Mesh.cc - ${SOURCE_DIR}/MeshStructure.cc - ${SOURCE_DIR}/Operator.cc - ${SOURCE_DIR}/OperatorTerm.cc - ${SOURCE_DIR}/Parametric.cc - ${SOURCE_DIR}/PeriodicBC.cc - ${SOURCE_DIR}/ProblemInstat.cc - ${SOURCE_DIR}/ProblemInterpol.cc - ${SOURCE_DIR}/ProblemStat.cc - ${SOURCE_DIR}/ProblemStatDbg.cc - ${SOURCE_DIR}/Projection.cc - ${SOURCE_DIR}/QPInfo.cc - ${SOURCE_DIR}/QPsiPhi.cc - ${SOURCE_DIR}/Quadrature.cc - ${SOURCE_DIR}/RCNeighbourList.cc - ${SOURCE_DIR}/Recovery.cc - ${SOURCE_DIR}/RefinementManager.cc - ${SOURCE_DIR}/RefinementManager1d.cc - ${SOURCE_DIR}/RefinementManager2d.cc - ${SOURCE_DIR}/RefinementManager3d.cc - ${SOURCE_DIR}/RobinBC.cc - ${SOURCE_DIR}/ScalableQuadrature.cc - ${SOURCE_DIR}/SecondOrderAssembler.cc - ${SOURCE_DIR}/SecondOrderTerm.cc - ${SOURCE_DIR}/Serializer.cc - ${SOURCE_DIR}/StandardProblemIteration.cc - ${SOURCE_DIR}/SubAssembler.cc - ${SOURCE_DIR}/SubElInfo.cc - ${SOURCE_DIR}/SubQuadrature.cc - ${SOURCE_DIR}/SurfaceQuadrature.cc - ${SOURCE_DIR}/SurfaceRegion_ED.cc - ${SOURCE_DIR}/SystemVector.cc - ${SOURCE_DIR}/Tetrahedron.cc - ${SOURCE_DIR}/Timer.cc - ${SOURCE_DIR}/Traverse.cc - ${SOURCE_DIR}/Triangle.cc - ${SOURCE_DIR}/VertexVector.cc - ${SOURCE_DIR}/ZeroOrderAssembler.cc - ${SOURCE_DIR}/ZeroOrderTerm.cc - ${SOURCE_DIR}/est/Estimator.cc - ${SOURCE_DIR}/est/RecoveryEstimator.cc - ${SOURCE_DIR}/est/ResidualEstimator.cc - ${SOURCE_DIR}/est/SimpleResidualEstimator.cc - ${SOURCE_DIR}/io/ArhReader.cc - ${SOURCE_DIR}/io/detail/ArhReader.cc - ${SOURCE_DIR}/io/Arh2Reader.cc - ${SOURCE_DIR}/io/Arh2Writer.cc - ${SOURCE_DIR}/io/Arh3Reader.cc - ${SOURCE_DIR}/io/Arh3Writer.cc - ${SOURCE_DIR}/io/detail/Arh2Reader.cc - ${SOURCE_DIR}/io/detail/ArhWriter.cc - ${SOURCE_DIR}/io/detail/Arh2Writer.cc - ${SOURCE_DIR}/io/detail/Arh3Reader.cc - ${SOURCE_DIR}/io/detail/Arh3Writer.cc - ${SOURCE_DIR}/io/DofWriter.cc - ${SOURCE_DIR}/io/ElementFileWriter.cc - ${SOURCE_DIR}/io/FileWriterInterface.cc - ${SOURCE_DIR}/io/FileWriter.cc - ${SOURCE_DIR}/io/GNUPlotWriter.cc - ${SOURCE_DIR}/io/MacroInfo.cc - ${SOURCE_DIR}/io/MacroReader.cc - ${SOURCE_DIR}/io/MacroWriter.cc - ${SOURCE_DIR}/io/PngReader.cc - ${SOURCE_DIR}/io/PngWriter.cc - ${SOURCE_DIR}/io/PovrayWriter.cc - ${SOURCE_DIR}/io/Spreadsheet.cc - ${SOURCE_DIR}/io/ValueReader.cc - ${SOURCE_DIR}/io/ValueWriter.cc - ${SOURCE_DIR}/io/VtkWriter.cc - ${SOURCE_DIR}/io/VtkVectorWriter.cc - ${SOURCE_DIR}/io/detail/VtkWriter.cc - ${SOURCE_DIR}/nonlin/ProblemNonLin.cc - ${SOURCE_DIR}/solver/SolverMatrix.cc - ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc - ${SOURCE_DIR}/time/RosenbrockMethod.cc - ${SOURCE_DIR}/time/RosenbrockStationary.cc - ) - - -include(cmake/enable_cxx11.cmake) -include(cmake/enable_parallel_domain.cmake) -include(cmake/enable_seq_petsc.cmake) -include(cmake/enable_umfpack.cmake) -include(cmake/enable_hypre.cmake) -include(cmake/enable_png.cmake) -include(cmake/enable_bddcml.cmake) -include(cmake/enable_extensions.cmake) -include(cmake/enable_openmp.cmake) - -if(ENABLE_COMPRESSION) - list(APPEND COMPILEFLAGS "-DHAVE_COMPRESSION=1") -endif(ENABLE_COMPRESSION) - -if(NOT ENABLE_OUTPUT) - message(WARNING "AMDiS cout output disabled!") - list(APPEND COMPILEFLAGS "-DSUPPRESS_OUTPUT") -endif(NOT ENABLE_OUTPUT) - -if(ENABLE_MARMOT) - Message("please set marmotcc manually") -endif(ENABLE_MARMOT) - - -# composite fem includes -SET(COMPOSITE_SOURCE_DIR ${SOURCE_DIR}/compositeFEM) -SET(COMPOSITE_FEM_SRC ${COMPOSITE_SOURCE_DIR}/CFE_Integration.cc - ${COMPOSITE_SOURCE_DIR}/CFE_NormAndErrorFcts.cc - ${COMPOSITE_SOURCE_DIR}/CompositeFEMMethods.cc - ${COMPOSITE_SOURCE_DIR}/CompositeFEMOperator.cc - ${COMPOSITE_SOURCE_DIR}/LevelSetAdaptMesh.cc - ${COMPOSITE_SOURCE_DIR}/PenaltyOperator.cc - ${COMPOSITE_SOURCE_DIR}/ElementLevelSet.cc - ${COMPOSITE_SOURCE_DIR}/SubPolytope.cc - ${COMPOSITE_SOURCE_DIR}/SubElementAssembler.cc ) - -# reinit includes -set(REINIT_SOURCE_DIR ${SOURCE_DIR}/reinit) -file(GLOB REINIT_SRC ${REINIT_SOURCE_DIR}/*.cc) -list(APPEND AMDIS_INCLUDE_DIRS ${REINIT_SOURCE_DIR}) - -# muparser includes -set(MUPARSER_SOURCE_DIR ${AMDIS_SOURCE_DIR}/lib/muparser_v134) -file(GLOB MUPARSER_SRC ${MUPARSER_SOURCE_DIR}/src/*.cpp) -list(APPEND AMDIS_INCLUDE_DIRS ${MUPARSER_SOURCE_DIR}/include) - -# mtl4 includes -list(APPEND AMDIS_INCLUDE_DIRS ${MTL_INCLUDE_DIR}) -list(APPEND AMDIS_INCLUDE_DIRS ${SOURCE_DIR}) - - -include_directories(${AMDIS_INCLUDE_DIRS}) - -if(WIN32) - add_library(amdis STATIC ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC}) - add_library(compositeFEM STATIC ${COMPOSITE_FEM_SRC}) - add_library(reinit STATIC ${REINIT_SRC}) - add_library(muparser STATIC ${MUPARSER_SRC}) -else() - add_library(amdis SHARED ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC}) - add_library(compositeFEM SHARED ${COMPOSITE_FEM_SRC}) - add_library(reinit SHARED ${REINIT_SRC}) - add_library(muparser SHARED ${MUPARSER_SRC}) -endif() - - -list(APPEND AMDIS_LIBS amdis ${Boost_LIBRARIES}) - -# some special treatements for Windows systems -# -------------------------------------------- -if(WIN32) - list(APPEND COMPILEFLAGS "-D_SCL_SECURE_NO_WARNINGS" "-D_CRT_SECURE_NO_WARNINGS") -endif(WIN32) - -# some special treatements for MacOS Systems -# ------------------------------------------ -if(CMAKE_SYSTEM_NAME MATCHES Darwin) - if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup") - SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup") - - set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -bind_at_load -m64") - set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -bind_at_load -m64") - endif() -endif() - - -message("compileflags: ${COMPILEFLAGS}") -add_definitions(${COMPILEFLAGS}) - -#dont change this destination. the GUI depends on it to guess the buildsystem - -FILE(GLOB HEADERS "${SOURCE_DIR}/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/) -list(APPEND deb_add_dirs "include/amdis") - -FILE(GLOB HEADERS "${SOURCE_DIR}/config/*.h*") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/config/) -list(APPEND deb_add_dirs "include/amdis/config") - -FILE(GLOB HEADERS "${SOURCE_DIR}/*.hh") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/) - -FILE(GLOB HEADERS "${SOURCE_DIR}/*.hpp") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/) - -FILE(GLOB HEADERS "${SOURCE_DIR}/parallel/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/parallel/) -list(APPEND deb_add_dirs "include/amdis/parallel") - -FILE(GLOB HEADERS "${SOURCE_DIR}/nonlin/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/nonlin/) -list(APPEND deb_add_dirs "include/amdis/nonlin") - -FILE(GLOB HEADERS "${SOURCE_DIR}/est/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/est/) -list(APPEND deb_add_dirs "include/amdis/est") - -FILE(GLOB HEADERS "${SOURCE_DIR}/expressions/*.h*") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/expressions/) -list(APPEND deb_add_dirs "include/amdis/expressions") - -FILE(GLOB HEADERS "${SOURCE_DIR}/operations/*.h*") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/operations/) -list(APPEND deb_add_dirs "include/amdis/operations") - -FILE(GLOB HEADERS "${SOURCE_DIR}/traits/*.h*") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/traits/) -list(APPEND deb_add_dirs "include/amdis/traits") - -FILE(GLOB HEADERS "${SOURCE_DIR}/utility/*.h*") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/utility/) -list(APPEND deb_add_dirs "include/amdis/utility") - -FILE(GLOB HEADERS "${SOURCE_DIR}/time/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/time/) -list(APPEND deb_add_dirs "include/amdis/time") - -FILE(GLOB HEADERS "${SOURCE_DIR}/traits/*.h*") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/traits/) -list(APPEND deb_add_dirs "include/amdis/traits") - -FILE(GLOB HEADERS "${SOURCE_DIR}/solver/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/solver) -list(APPEND deb_add_dirs "include/amdis/solver") - -FILE(GLOB HEADERS "${SOURCE_DIR}/solver/*.hh") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/solver) -list(APPEND deb_add_dirs "include/amdis/solver") - -FILE(GLOB HEADERS "${SOURCE_DIR}/solver/details/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/solver/details) -list(APPEND deb_add_dirs "include/amdis/solver/details") - -FILE(GLOB HEADERS "${SOURCE_DIR}/solver/itl/*.hpp") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/solver/itl) -list(APPEND deb_add_dirs "include/amdis/solver/itl") - -FILE(GLOB HEADERS "${SOURCE_DIR}/solver/details/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/solver/details) -list(APPEND deb_add_dirs "include/amdis/solver/details") - - -FILE(GLOB HEADERS "${SOURCE_DIR}/io/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/io) -list(APPEND deb_add_dirs "include/amdis/io") - -FILE(GLOB HEADERS "${SOURCE_DIR}/io/*.hh") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/io) - -FILE(GLOB HEADERS "${SOURCE_DIR}/io/detail/*h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/io/detail) -list(APPEND deb_add_dirs "include/amdis/io/detail") - -FILE(GLOB HEADERS "${REINIT_SOURCE_DIR}/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/reinit) -list(APPEND deb_add_dirs "include/amdis/reinit") - -FILE(GLOB HEADERS "${COMPOSITE_SOURCE_DIR}/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/compositeFEM) -list(APPEND deb_add_dirs "include/amdis/compositeFEM") - -FILE(GLOB HEADERS "${MUPARSER_SOURCE_DIR}/include/*.h") -INSTALL(FILES ${HEADERS} - DESTINATION include/amdis/muparser) -list(APPEND deb_add_dirs "include/amdis/muparser") - -list(APPEND deb_add_dirs "lib/amdis") -install(TARGETS amdis compositeFEM reinit muparser - DESTINATION lib/amdis/ ) - -configure_file(${AMDIS_SOURCE_DIR}/cmake/AMDISConfig.cmake.in - ${AMDIS_BINARY_DIR}/AMDISConfig.cmake - @ONLY - ) - -INSTALL(FILES ${AMDIS_BINARY_DIR}/AMDISConfig.cmake - DESTINATION share/amdis/) -list(APPEND deb_add_dirs "share/amdis/") - -FILE(GLOB CMAKE_FILES "${AMDIS_SOURCE_DIR}/cmake/*.cmake") -INSTALL(FILES ${CMAKE_FILES} - DESTINATION share/amdis/) - -#install mtl -INSTALL(DIRECTORY ${AMDIS_SOURCE_DIR}/lib/mtl4/ - DESTINATION include/amdis/mtl4/ - FILES_MATCHING PATTERN "*.hpp" - PATTERN ".svn" EXCLUDE - PATTERN ".svn/*" EXCLUDE - PATTERN "mtl4/libs" EXCLUDE - PATTERN "mtl4/extern" EXCLUDE - ) -FILE(GLOB_RECURSE mtl4_files - RELATIVE ${AMDIS_SOURCE_DIR}/lib/mtl4/boost/ - ${AMDIS_SOURCE_DIR}/lib/mtl4/boost/*.hpp) -foreach(mtl4_file in ${mtl4_files}) - get_filename_component(mtl4File_path ${mtl4_file} PATH) - list(APPEND deb_add_dirs "include/amdis/mtl4/boost/${mtl4File_path}") -endforeach(mtl4_file) - -#install documentation -FILE(GLOB DOCS "${AMDIS_SOURCE_DIR}/doc/*.pdf") -INSTALL(FILES ${DOCS} DESTINATION share/amdis/doc) -list(APPEND deb_add_dirs "share/amdis/doc") - -list(REMOVE_DUPLICATES deb_add_dirs) - -ENABLE_TESTING() -INCLUDE(CTest) -INCLUDE(Dart) -if(NOT CTEST_MODEL) - set(CTEST_MODEL "Experimental") -endif() -if( NOT N_TEST_PROC) - set(N_TEST_PROC "8") -endif() -configure_file(cmake/myMake.sh.in myMake.sh @ONLY) -configure_file(cmake/CTestScript.cmake.in CTestScript.cmake @ONLY) - - -# PACKAGES -# ======================================================== -set(CPACK_PACKAGE_NAME "AMDIS") -set(CPACK_PACKAGE_CONTACT "Andreas.Naumann@tu-dresden.de") -set(CPACK_PACKAGE_VERSION "${CurrentRevision}") -set(CPACK_GENERATOR "RPM" "DEB" "TGZ") -set(CPACK_INSTALL_PREFIX "/usr/") -set(CPACK_RESOURCE_FILE_LICENSE "${AMDIS_SOURCE_DIR}/license.opensource.txt") - -# library depends on boost, but boost libraries have version-number in name on some systems. -# so we have to find a workaround to enforce allowed boost versions -set(boost_ver ${Boost_MINOR_VERSION}) -math(EXPR boost_ver_start "${Boost_MINOR_VERSION}+1") -math(EXPR boost_ver_stop "${Boost_MINOR_VERSION}+10") - -set(boost_depends "libboost${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") -set(boost_iostreams_depends "libboost-iostreams${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") -set(boost_system_depends "libboost-system${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") -set(boost_filesystem_depends "libboost-filesystem${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") - -foreach(boost_ver RANGE ${boost_ver_start} ${boost_ver_stop}) - set(boost_depends "${boost_depends} | libboost${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") - set(boost_iostreams_depends "${boost_iostreams_depends} | libboost-iostreams${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") - set(boost_system_depends "${boost_system_depends} | libboost-system${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") - set(boost_filesystem_depends "${boost_filesystem_depends} | libboost-filesystem${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") -endforeach(boost_ver) - -configure_file(${AMDIS_SOURCE_DIR}/cmake/preinst.in - ${AMDIS_BINARY_DIR}/preinst - @ONLY) - -configure_file(${AMDIS_SOURCE_DIR}/cmake/postrm.in - ${AMDIS_BINARY_DIR}/postrm - @ONLY) - -#----Test if clang setup works---------------------------------------------------------------------- -set(COMPILER_VERSION "") -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - exec_program(${CMAKE_C_COMPILER} ARGS "-v" OUTPUT_VARIABLE _clang_version_info) - string(REGEX REPLACE "^.*[ ]([0-9]+)\\.[0-9].*$" "\\1" CLANG_MAJOR "${_clang_version_info}") - string(REGEX REPLACE "^.*[ ][0-9]+\\.([0-9]).*$" "\\1" CLANG_MINOR "${_clang_version_info}") - set(COMPILER_VERSION "clang ${CLANG_MAJOR}.${CLANG_MINOR}") -endif() - -#---Obtain the major and minor version of the GNU compiler------------------------------------------- -if (CMAKE_COMPILER_IS_GNUCXX) - exec_program(${CMAKE_C_COMPILER} ARGS "-dumpversion" OUTPUT_VARIABLE _gcc_version_info) - string(REGEX REPLACE "^([0-9]+).*$" "\\1" GCC_MAJOR ${_gcc_version_info}) - string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*$" "\\1" GCC_MINOR ${_gcc_version_info}) - string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GCC_PATCH ${_gcc_version_info}) - - if(GCC_PATCH MATCHES "\\.+") - set(GCC_PATCH "") - endif() - if(GCC_MINOR MATCHES "\\.+") - set(GCC_MINOR "") - endif() - if(GCC_MAJOR MATCHES "\\.+") - set(GCC_MAJOR "") - endif() - set(COMPILER_VERSION "gcc ${_gcc_version_info}") -endif() - -set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}, ${RPM_DEPEND_STR}") -set(CPACK_DEBIAN_PACKAGE_DEPENDS "${boost_depends},\\n ${boost_iostreams_depends},\\n ${boost_system_depends},\\n ${boost_filesystem_depends}") -set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "AMDiS (Adaptive Multi-Dimensional Simulations) - a C++ library to solve partial differential equations using adaptive finite elements. The main features of AMDiS are: - . - - full adaptive meshes in 1D, 2D and 3D - - adaptive time stepping strategies for time dependent equations - - uses high performance Krylov subspace solvers from MTL4 and the direct solvers UMFPACK and Intel's Pardiso - - parallelization of the overall finite element method with excelent scaling up to several thounds of processors - - uses PETSc for solving parallel distributed linear systems - - easy to use interface, no additional effort to run code in parallel! - . - The library is compiled with ${COMPILER_VERSION} and compiled/linked with boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}.") - -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${AMDIS_BINARY_DIR}/preinst" "${AMDIS_BINARY_DIR}/postrm") - -include(CPack) +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +project(AMDiS) + +if (USE_NEW_CMAKE AND ${CMAKE_VERSION} VERSION_GREATER "3.0") + # Experimental implementation of new CMakeLists.txt + # Can be selected by calling cmake -DUSE_NEW_CMAKE=ON . + # Use only if you know what you are doing :-) + include(${AMDiS_SOURCE_DIR}/cmake3/CMakeLists_3.0.txt) +else () + # By defualt the classical CMakeLists file ist used + include(${AMDiS_SOURCE_DIR}/cmake/CMakeLists_2.8.txt) +endif () diff --git a/AMDiS/cmake/CMakeLists_2.8.txt b/AMDiS/cmake/CMakeLists_2.8.txt new file mode 100644 index 00000000..43444ccc --- /dev/null +++ b/AMDiS/cmake/CMakeLists_2.8.txt @@ -0,0 +1,548 @@ +cmake_minimum_required(VERSION 2.8.10) +project(AMDIS) +cmake_policy(SET CMP0017 OLD) +if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) +endif() +if(POLICY CMP0054) + cmake_policy(SET CMP0054 NEW) +endif() + +SET(LIB_DIR ${AMDIS_SOURCE_DIR}/lib) +SET(SOURCE_DIR ${AMDIS_SOURCE_DIR}/src) + +#TODO: use the cmake build type +SET(MTL_INCLUDE_DIR ${LIB_DIR}/mtl4/ CACHE PATH "mtl4 directory") + +# set global compile_definitions for all target, depending on build-type +set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS + $<$:DEBUG=1> + $<$:DEBUG=0>) + +# find_package(Subversion QUIET) +# if(Subversion_FOUND) +# Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} svn_info) +# #message("svn-rev: ${svn_info_WC_REVISION}") +# set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}") +# endif() +set(CurrentRevision "0.9") +if(NOT AMDIS_MAJOR) + set(AMDIS_MAJOR "0") +endif() +if(NOT AMDIS_MINOR) + set(AMDIS_MINOR "9") +endif() +list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}") + +#define the build type, empty can be everything and nothing +if(CMAKE_BUILD_TYPE STREQUAL "") + set(CMAKE_BUILD_TYPE "Release") +endif() + +if(CMAKE_CXX_COMPILER MATCHES ".*icpc") + Message("Compiler: Intel") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -diag-disable 654 -diag-disable 858") +endif() + + +SET(ENABLE_PARALLEL_DOMAIN "OFF" CACHE STRING "use parallel domain decomposition. please set to one of: PMTL, PETSC, OFF" ) +option(ENABLE_CXX11 "Enable C++11 compiler features" false) +option(ENABLE_SEQ_PETSC "Use sequential PETSc solvers" false) +option(ENABLE_UMFPACK "Use of UMFPACK solver" false) +option(ENABLE_HYPRE "Use HYPRE AMG solver" false) +option(ENABLE_PNG "use png reader/writer" false) +option(ENABLE_BDDCML "Use of BDDCML library" false) +mark_as_advanced(ENABLE_BDDCML) +option(ENABLE_EXTENSIONS "Use extensions" false) +option(ENABLE_OPENMP "Use OpenMP" false) +option(ENABLE_COMPRESSION "Use output compression" false) +option(ENABLE_OUTPUT "AMDiS output printing, disable only for debugging!" true) +mark_as_advanced(ENABLE_OUTPUT) + + +find_package(Boost 1.44 REQUIRED) +if (Boost_FOUND) + list(APPEND AMDIS_INCLUDE_DIRS ${Boost_INCLUDE_DIR}) + message("boost lib-dirs: ${Boost_LIBRARY_DIRS}") + message("use the boost dir: ${Boost_INCLUDE_DIR}") + #if (WIN32) + #message("the windows find_boost does not set the boost library paths, please set it") + #SET(Boost_LIBRARY_DIRS CACHE PATH "The directory containing the boost libraries") + #endif (WIN32) + list(APPEND AMDIS_LINK_DIRS ${Boost_LIBRARY_DIRS}) +endif (Boost_FOUND) + + +SET(AMDIS_SRC ${SOURCE_DIR}/AdaptBase.cc + ${SOURCE_DIR}/AdaptInfo.cc + ${SOURCE_DIR}/AdaptInstationary.cc + ${SOURCE_DIR}/AdaptStationary.cc + ${SOURCE_DIR}/AMDiS.cc + ${SOURCE_DIR}/Assembler.cc + ${SOURCE_DIR}/BasisFunction.cc + ${SOURCE_DIR}/Boundary.cc + ${SOURCE_DIR}/BoundaryManager.cc + ${SOURCE_DIR}/BoundaryObject.cc + ${SOURCE_DIR}/Bubble.cc + ${SOURCE_DIR}/Cholesky.cc + ${SOURCE_DIR}/CoarseningManager.cc + ${SOURCE_DIR}/CoarseningManager1d.cc + ${SOURCE_DIR}/CoarseningManager2d.cc + ${SOURCE_DIR}/CoarseningManager3d.cc + ${SOURCE_DIR}/ComponentTraverseInfo.cc + ${SOURCE_DIR}/CouplingIterationInterface.cc + ${SOURCE_DIR}/CreatorMap.cc + ${SOURCE_DIR}/DOFAdmin.cc + ${SOURCE_DIR}/DOFIndexed.cc + ${SOURCE_DIR}/DOFMatrix.cc + ${SOURCE_DIR}/DOFVector.cc + ${SOURCE_DIR}/Debug.cc + ${SOURCE_DIR}/DirichletBC.cc + ${SOURCE_DIR}/DualTraverse.cc + ${SOURCE_DIR}/ElInfo.cc + ${SOURCE_DIR}/ElInfo1d.cc + ${SOURCE_DIR}/ElInfo2d.cc + ${SOURCE_DIR}/ElInfo3d.cc + ${SOURCE_DIR}/ElInfoStack.cc + ${SOURCE_DIR}/Element.cc + ${SOURCE_DIR}/ElementData.cc + ${SOURCE_DIR}/ElementDofIterator.cc + ${SOURCE_DIR}/ElementRegion_ED.cc + ${SOURCE_DIR}/FiniteElemSpace.cc + ${SOURCE_DIR}/FirstOrderAssembler.cc + ${SOURCE_DIR}/FirstOrderTerm.cc + ${SOURCE_DIR}/FixVec.cc + ${SOURCE_DIR}/Global.cc + ${SOURCE_DIR}/GlobalDOFNumbering.cc + ${SOURCE_DIR}/GlobalElementNumbering.cc + ${SOURCE_DIR}/Initfile.cc + ${SOURCE_DIR}/Lagrange.cc + ${SOURCE_DIR}/LeafData.cc + ${SOURCE_DIR}/Line.cc + ${SOURCE_DIR}/MacroElement.cc + ${SOURCE_DIR}/Marker.cc + ${SOURCE_DIR}/MatrixVector.cc + ${SOURCE_DIR}/Mesh.cc + ${SOURCE_DIR}/MeshStructure.cc + ${SOURCE_DIR}/Operator.cc + ${SOURCE_DIR}/OperatorTerm.cc + ${SOURCE_DIR}/Parametric.cc + ${SOURCE_DIR}/PeriodicBC.cc + ${SOURCE_DIR}/ProblemInstat.cc + ${SOURCE_DIR}/ProblemInterpol.cc + ${SOURCE_DIR}/ProblemStat.cc + ${SOURCE_DIR}/ProblemStatDbg.cc + ${SOURCE_DIR}/Projection.cc + ${SOURCE_DIR}/QPInfo.cc + ${SOURCE_DIR}/QPsiPhi.cc + ${SOURCE_DIR}/Quadrature.cc + ${SOURCE_DIR}/RCNeighbourList.cc + ${SOURCE_DIR}/Recovery.cc + ${SOURCE_DIR}/RefinementManager.cc + ${SOURCE_DIR}/RefinementManager1d.cc + ${SOURCE_DIR}/RefinementManager2d.cc + ${SOURCE_DIR}/RefinementManager3d.cc + ${SOURCE_DIR}/RobinBC.cc + ${SOURCE_DIR}/ScalableQuadrature.cc + ${SOURCE_DIR}/SecondOrderAssembler.cc + ${SOURCE_DIR}/SecondOrderTerm.cc + ${SOURCE_DIR}/Serializer.cc + ${SOURCE_DIR}/StandardProblemIteration.cc + ${SOURCE_DIR}/SubAssembler.cc + ${SOURCE_DIR}/SubElInfo.cc + ${SOURCE_DIR}/SubQuadrature.cc + ${SOURCE_DIR}/SurfaceQuadrature.cc + ${SOURCE_DIR}/SurfaceRegion_ED.cc + ${SOURCE_DIR}/SystemVector.cc + ${SOURCE_DIR}/Tetrahedron.cc + ${SOURCE_DIR}/Timer.cc + ${SOURCE_DIR}/Traverse.cc + ${SOURCE_DIR}/Triangle.cc + ${SOURCE_DIR}/VertexVector.cc + ${SOURCE_DIR}/ZeroOrderAssembler.cc + ${SOURCE_DIR}/ZeroOrderTerm.cc + ${SOURCE_DIR}/est/Estimator.cc + ${SOURCE_DIR}/est/RecoveryEstimator.cc + ${SOURCE_DIR}/est/ResidualEstimator.cc + ${SOURCE_DIR}/est/SimpleResidualEstimator.cc + ${SOURCE_DIR}/io/ArhReader.cc + ${SOURCE_DIR}/io/detail/ArhReader.cc + ${SOURCE_DIR}/io/Arh2Reader.cc + ${SOURCE_DIR}/io/Arh2Writer.cc + ${SOURCE_DIR}/io/Arh3Reader.cc + ${SOURCE_DIR}/io/Arh3Writer.cc + ${SOURCE_DIR}/io/detail/Arh2Reader.cc + ${SOURCE_DIR}/io/detail/ArhWriter.cc + ${SOURCE_DIR}/io/detail/Arh2Writer.cc + ${SOURCE_DIR}/io/detail/Arh3Reader.cc + ${SOURCE_DIR}/io/detail/Arh3Writer.cc + ${SOURCE_DIR}/io/DofWriter.cc + ${SOURCE_DIR}/io/ElementFileWriter.cc + ${SOURCE_DIR}/io/FileWriterInterface.cc + ${SOURCE_DIR}/io/FileWriter.cc + ${SOURCE_DIR}/io/GNUPlotWriter.cc + ${SOURCE_DIR}/io/MacroInfo.cc + ${SOURCE_DIR}/io/MacroReader.cc + ${SOURCE_DIR}/io/MacroWriter.cc + ${SOURCE_DIR}/io/PngReader.cc + ${SOURCE_DIR}/io/PngWriter.cc + ${SOURCE_DIR}/io/PovrayWriter.cc + ${SOURCE_DIR}/io/Spreadsheet.cc + ${SOURCE_DIR}/io/ValueReader.cc + ${SOURCE_DIR}/io/ValueWriter.cc + ${SOURCE_DIR}/io/VtkWriter.cc + ${SOURCE_DIR}/io/VtkVectorWriter.cc + ${SOURCE_DIR}/io/detail/VtkWriter.cc + ${SOURCE_DIR}/nonlin/ProblemNonLin.cc + ${SOURCE_DIR}/solver/SolverMatrix.cc + ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc + ${SOURCE_DIR}/time/RosenbrockMethod.cc + ${SOURCE_DIR}/time/RosenbrockStationary.cc + ) + + +include(cmake/enable_cxx11.cmake) +include(cmake/enable_parallel_domain.cmake) +include(cmake/enable_seq_petsc.cmake) +include(cmake/enable_umfpack.cmake) +include(cmake/enable_hypre.cmake) +include(cmake/enable_png.cmake) +include(cmake/enable_bddcml.cmake) +include(cmake/enable_extensions.cmake) +include(cmake/enable_openmp.cmake) + +if(ENABLE_COMPRESSION) + list(APPEND COMPILEFLAGS "-DHAVE_COMPRESSION=1") +endif(ENABLE_COMPRESSION) + +if(NOT ENABLE_OUTPUT) + message(WARNING "AMDiS cout output disabled!") + list(APPEND COMPILEFLAGS "-DSUPPRESS_OUTPUT") +endif(NOT ENABLE_OUTPUT) + +if(ENABLE_MARMOT) + Message("please set marmotcc manually") +endif(ENABLE_MARMOT) + +# TODO: make composidte-fem and reinit a subproject +# add_subdirectory(${SOURCE_DIR}/compositeFEM [binarydir]) + +# composite fem includes +SET(COMPOSITE_SOURCE_DIR ${SOURCE_DIR}/compositeFEM) +SET(COMPOSITE_FEM_SRC ${COMPOSITE_SOURCE_DIR}/CFE_Integration.cc + ${COMPOSITE_SOURCE_DIR}/CFE_NormAndErrorFcts.cc + ${COMPOSITE_SOURCE_DIR}/CompositeFEMMethods.cc + ${COMPOSITE_SOURCE_DIR}/CompositeFEMOperator.cc + ${COMPOSITE_SOURCE_DIR}/LevelSetAdaptMesh.cc + ${COMPOSITE_SOURCE_DIR}/PenaltyOperator.cc + ${COMPOSITE_SOURCE_DIR}/ElementLevelSet.cc + ${COMPOSITE_SOURCE_DIR}/SubPolytope.cc + ${COMPOSITE_SOURCE_DIR}/SubElementAssembler.cc ) + +# reinit includes +set(REINIT_SOURCE_DIR ${SOURCE_DIR}/reinit) +file(GLOB REINIT_SRC ${REINIT_SOURCE_DIR}/*.cc) +list(APPEND AMDIS_INCLUDE_DIRS ${REINIT_SOURCE_DIR}) + +# muparser includes +set(MUPARSER_SOURCE_DIR ${AMDIS_SOURCE_DIR}/lib/muparser_v134) +file(GLOB MUPARSER_SRC ${MUPARSER_SOURCE_DIR}/src/*.cpp) +list(APPEND AMDIS_INCLUDE_DIRS ${MUPARSER_SOURCE_DIR}/include) + +# mtl4 includes +list(APPEND AMDIS_INCLUDE_DIRS ${MTL_INCLUDE_DIR}) +list(APPEND AMDIS_INCLUDE_DIRS ${SOURCE_DIR}) + + +include_directories(${AMDIS_INCLUDE_DIRS}) + +if(WIN32) + add_library(amdis STATIC ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC}) + add_library(compositeFEM STATIC ${COMPOSITE_FEM_SRC}) + add_library(reinit STATIC ${REINIT_SRC}) + add_library(muparser STATIC ${MUPARSER_SRC}) +else() + add_library(amdis SHARED ${AMDIS_SRC} ${PARALLEL_DOMAIN_AMDIS_SRC}) + add_library(compositeFEM SHARED ${COMPOSITE_FEM_SRC}) + add_library(reinit SHARED ${REINIT_SRC}) + add_library(muparser SHARED ${MUPARSER_SRC}) +endif() + + +list(APPEND AMDIS_LIBS amdis ${Boost_LIBRARIES}) + +# some special treatements for Windows systems +# -------------------------------------------- +if(WIN32) + list(APPEND COMPILEFLAGS "-D_SCL_SECURE_NO_WARNINGS" "-D_CRT_SECURE_NO_WARNINGS") +endif(WIN32) + +# some special treatements for MacOS Systems +# ------------------------------------------ +if(CMAKE_SYSTEM_NAME MATCHES Darwin) + if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup") + SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup") + + set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -bind_at_load -m64") + set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -bind_at_load -m64") + endif() +endif() + + +message("compileflags: ${COMPILEFLAGS}") +add_definitions(${COMPILEFLAGS}) + +#dont change this destination. the GUI depends on it to guess the buildsystem + +FILE(GLOB HEADERS "${SOURCE_DIR}/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/) +list(APPEND deb_add_dirs "include/amdis") + +FILE(GLOB HEADERS "${SOURCE_DIR}/config/*.h*") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/config/) +list(APPEND deb_add_dirs "include/amdis/config") + +FILE(GLOB HEADERS "${SOURCE_DIR}/*.hh") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/) + +FILE(GLOB HEADERS "${SOURCE_DIR}/*.hpp") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/) + +FILE(GLOB HEADERS "${SOURCE_DIR}/parallel/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/parallel/) +list(APPEND deb_add_dirs "include/amdis/parallel") + +FILE(GLOB HEADERS "${SOURCE_DIR}/nonlin/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/nonlin/) +list(APPEND deb_add_dirs "include/amdis/nonlin") + +FILE(GLOB HEADERS "${SOURCE_DIR}/est/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/est/) +list(APPEND deb_add_dirs "include/amdis/est") + +FILE(GLOB HEADERS "${SOURCE_DIR}/expressions/*.h*") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/expressions/) +list(APPEND deb_add_dirs "include/amdis/expressions") + +FILE(GLOB HEADERS "${SOURCE_DIR}/operations/*.h*") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/operations/) +list(APPEND deb_add_dirs "include/amdis/operations") + +FILE(GLOB HEADERS "${SOURCE_DIR}/traits/*.h*") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/traits/) +list(APPEND deb_add_dirs "include/amdis/traits") + +FILE(GLOB HEADERS "${SOURCE_DIR}/utility/*.h*") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/utility/) +list(APPEND deb_add_dirs "include/amdis/utility") + +FILE(GLOB HEADERS "${SOURCE_DIR}/time/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/time/) +list(APPEND deb_add_dirs "include/amdis/time") + +FILE(GLOB HEADERS "${SOURCE_DIR}/traits/*.h*") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/traits/) +list(APPEND deb_add_dirs "include/amdis/traits") + +FILE(GLOB HEADERS "${SOURCE_DIR}/solver/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/solver) +list(APPEND deb_add_dirs "include/amdis/solver") + +FILE(GLOB HEADERS "${SOURCE_DIR}/solver/*.hh") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/solver) +list(APPEND deb_add_dirs "include/amdis/solver") + +FILE(GLOB HEADERS "${SOURCE_DIR}/solver/details/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/solver/details) +list(APPEND deb_add_dirs "include/amdis/solver/details") + +FILE(GLOB HEADERS "${SOURCE_DIR}/solver/itl/*.hpp") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/solver/itl) +list(APPEND deb_add_dirs "include/amdis/solver/itl") + +FILE(GLOB HEADERS "${SOURCE_DIR}/solver/details/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/solver/details) +list(APPEND deb_add_dirs "include/amdis/solver/details") + + +FILE(GLOB HEADERS "${SOURCE_DIR}/io/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/io) +list(APPEND deb_add_dirs "include/amdis/io") + +FILE(GLOB HEADERS "${SOURCE_DIR}/io/*.hh") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/io) + +FILE(GLOB HEADERS "${SOURCE_DIR}/io/detail/*h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/io/detail) +list(APPEND deb_add_dirs "include/amdis/io/detail") + +FILE(GLOB HEADERS "${REINIT_SOURCE_DIR}/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/reinit) +list(APPEND deb_add_dirs "include/amdis/reinit") + +FILE(GLOB HEADERS "${COMPOSITE_SOURCE_DIR}/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/compositeFEM) +list(APPEND deb_add_dirs "include/amdis/compositeFEM") + +FILE(GLOB HEADERS "${MUPARSER_SOURCE_DIR}/include/*.h") +INSTALL(FILES ${HEADERS} + DESTINATION include/amdis/muparser) +list(APPEND deb_add_dirs "include/amdis/muparser") + +list(APPEND deb_add_dirs "lib/amdis") +install(TARGETS amdis compositeFEM reinit muparser + DESTINATION lib/amdis/ ) + +configure_file(${AMDIS_SOURCE_DIR}/cmake/AMDISConfig.cmake.in + ${AMDIS_BINARY_DIR}/AMDISConfig.cmake + @ONLY + ) + +INSTALL(FILES ${AMDIS_BINARY_DIR}/AMDISConfig.cmake + DESTINATION share/amdis/) +list(APPEND deb_add_dirs "share/amdis/") + +FILE(GLOB CMAKE_FILES "${AMDIS_SOURCE_DIR}/cmake/*.cmake") +INSTALL(FILES ${CMAKE_FILES} + DESTINATION share/amdis/) + +#install mtl +INSTALL(DIRECTORY ${AMDIS_SOURCE_DIR}/lib/mtl4/ + DESTINATION include/amdis/mtl4/ + FILES_MATCHING PATTERN "*.hpp" + PATTERN ".svn" EXCLUDE + PATTERN ".svn/*" EXCLUDE + PATTERN "mtl4/libs" EXCLUDE + PATTERN "mtl4/extern" EXCLUDE + ) +FILE(GLOB_RECURSE mtl4_files + RELATIVE ${AMDIS_SOURCE_DIR}/lib/mtl4/boost/ + ${AMDIS_SOURCE_DIR}/lib/mtl4/boost/*.hpp) +foreach(mtl4_file in ${mtl4_files}) + get_filename_component(mtl4File_path ${mtl4_file} PATH) + list(APPEND deb_add_dirs "include/amdis/mtl4/boost/${mtl4File_path}") +endforeach(mtl4_file) + +#install documentation +FILE(GLOB DOCS "${AMDIS_SOURCE_DIR}/doc/*.pdf") +INSTALL(FILES ${DOCS} DESTINATION share/amdis/doc) +list(APPEND deb_add_dirs "share/amdis/doc") + +list(REMOVE_DUPLICATES deb_add_dirs) + +ENABLE_TESTING() +INCLUDE(CTest) +INCLUDE(Dart) +if(NOT CTEST_MODEL) + set(CTEST_MODEL "Experimental") +endif() +if( NOT N_TEST_PROC) + set(N_TEST_PROC "8") +endif() +configure_file(cmake/myMake.sh.in myMake.sh @ONLY) +configure_file(cmake/CTestScript.cmake.in CTestScript.cmake @ONLY) + + +# PACKAGES +# ======================================================== +set(CPACK_PACKAGE_NAME "AMDIS") +set(CPACK_PACKAGE_CONTACT "Andreas.Naumann@tu-dresden.de") +set(CPACK_PACKAGE_VERSION "${CurrentRevision}") +set(CPACK_GENERATOR "RPM" "DEB" "TGZ") +set(CPACK_INSTALL_PREFIX "/usr/") +set(CPACK_RESOURCE_FILE_LICENSE "${AMDIS_SOURCE_DIR}/license.opensource.txt") + +# library depends on boost, but boost libraries have version-number in name on some systems. +# so we have to find a workaround to enforce allowed boost versions +set(boost_ver ${Boost_MINOR_VERSION}) +math(EXPR boost_ver_start "${Boost_MINOR_VERSION}+1") +math(EXPR boost_ver_stop "${Boost_MINOR_VERSION}+10") + +set(boost_depends "libboost${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") +set(boost_iostreams_depends "libboost-iostreams${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") +set(boost_system_depends "libboost-system${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") +set(boost_filesystem_depends "libboost-filesystem${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") + +foreach(boost_ver RANGE ${boost_ver_start} ${boost_ver_stop}) + set(boost_depends "${boost_depends} | libboost${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") + set(boost_iostreams_depends "${boost_iostreams_depends} | libboost-iostreams${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") + set(boost_system_depends "${boost_system_depends} | libboost-system${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") + set(boost_filesystem_depends "${boost_filesystem_depends} | libboost-filesystem${Boost_MAJOR_VERSION}.${boost_ver}-dev (>= ${Boost_MAJOR_VERSION}.${boost_ver})") +endforeach(boost_ver) + +configure_file(${AMDIS_SOURCE_DIR}/cmake/preinst.in + ${AMDIS_BINARY_DIR}/preinst + @ONLY) + +configure_file(${AMDIS_SOURCE_DIR}/cmake/postrm.in + ${AMDIS_BINARY_DIR}/postrm + @ONLY) + +#----Test if clang setup works---------------------------------------------------------------------- +set(COMPILER_VERSION "") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + exec_program(${CMAKE_C_COMPILER} ARGS "-v" OUTPUT_VARIABLE _clang_version_info) + string(REGEX REPLACE "^.*[ ]([0-9]+)\\.[0-9].*$" "\\1" CLANG_MAJOR "${_clang_version_info}") + string(REGEX REPLACE "^.*[ ][0-9]+\\.([0-9]).*$" "\\1" CLANG_MINOR "${_clang_version_info}") + set(COMPILER_VERSION "clang ${CLANG_MAJOR}.${CLANG_MINOR}") +endif() + +#---Obtain the major and minor version of the GNU compiler------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS "-dumpversion" OUTPUT_VARIABLE _gcc_version_info) + string(REGEX REPLACE "^([0-9]+).*$" "\\1" GCC_MAJOR ${_gcc_version_info}) + string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*$" "\\1" GCC_MINOR ${_gcc_version_info}) + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GCC_PATCH ${_gcc_version_info}) + + if(GCC_PATCH MATCHES "\\.+") + set(GCC_PATCH "") + endif() + if(GCC_MINOR MATCHES "\\.+") + set(GCC_MINOR "") + endif() + if(GCC_MAJOR MATCHES "\\.+") + set(GCC_MAJOR "") + endif() + set(COMPILER_VERSION "gcc ${_gcc_version_info}") +endif() + +set(CPACK_RPM_PACKAGE_REQUIRES "boost-devel >= ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}, ${RPM_DEPEND_STR}") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "${boost_depends},\\n ${boost_iostreams_depends},\\n ${boost_system_depends},\\n ${boost_filesystem_depends}") +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "AMDiS (Adaptive Multi-Dimensional Simulations) - a C++ library to solve partial differential equations using adaptive finite elements. The main features of AMDiS are: + . + - full adaptive meshes in 1D, 2D and 3D + - adaptive time stepping strategies for time dependent equations + - uses high performance Krylov subspace solvers from MTL4 and the direct solvers UMFPACK and Intel's Pardiso + - parallelization of the overall finite element method with excelent scaling up to several thounds of processors + - uses PETSc for solving parallel distributed linear systems + - easy to use interface, no additional effort to run code in parallel! + . + The library is compiled with ${COMPILER_VERSION} and compiled/linked with boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}.") + +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${AMDIS_BINARY_DIR}/preinst" "${AMDIS_BINARY_DIR}/postrm") + +include(CPack) diff --git a/AMDiS/cmake/PETScConfig.cmake b/AMDiS/cmake/PETScConfig.cmake new file mode 100644 index 00000000..a082857a --- /dev/null +++ b/AMDiS/cmake/PETScConfig.cmake @@ -0,0 +1,251 @@ +# - Try to find PETSc +# Once done this will define +# source: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake +# +# PETSC_FOUND - system has PETSc +# PETSC_INCLUDES - the PETSc include directories +# PETSC_LIBRARIES - Link these to use PETSc +# PETSC_COMPILER - Compiler used by PETSc, helpful to find a compatible MPI +# PETSC_DEFINITIONS - Compiler switches for using PETSc +# PETSC_MPIEXEC - Executable for running MPI programs +# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR) +# +# Hack: PETSC_VERSION currently decides on the version based on the +# layout. Otherwise we need to run C code to determine the version. +# +# Setting these changes the behavior of the search +# PETSC_DIR - directory in which PETSc resides +# PETSC_ARCH - build architecture +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +function (petsc_get_version) + if (EXISTS "${PETSC_DIR}/include/petscversion.h") + file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") + foreach (line ${vstrings}) + string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define") + list (GET fields 1 var) + list (GET fields 2 val) + set (${var} ${val} PARENT_SCOPE) + set (${var} ${val}) # Also in local scope so we have access below + endforeach () + if (PETSC_VERSION_RELEASE) + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE) + else () + # make dev version compare higher than any patch level of a released version + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE) + endif () + else () + message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist") + endif () +endfunction () + +find_path (PETSC_DIR include/petsc.h + HINTS ENV PETSC_DIR + PATHS + /usr/lib/petscdir/3.1 /usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2 # Debian + $ENV{HOME}/petsc + DOC "PETSc Directory") + +if (PETSC_DIR AND NOT PETSC_ARCH) + set (_petsc_arches + $ENV{PETSC_ARCH} # If set, use environment variable first + linux-gnu-c-debug linux-gnu-c-opt # Debian defaults + x86_64-unknown-linux-gnu i386-unknown-linux-gnu) + set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + foreach (arch ${_petsc_arches}) + if (NOT PETSC_ARCH) + find_path (petscconf petscconf.h + HINTS ${PETSC_DIR} + PATH_SUFFIXES ${arch}/include bmake/${arch} + NO_DEFAULT_PATH) + if (petscconf) + set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") + endif (petscconf) + endif (NOT PETSC_ARCH) + endforeach (arch) + set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) +endif (PETSC_DIR AND NOT PETSC_ARCH) + +set (petsc_slaves LIBRARIES_SYS LIBRARIES_VEC LIBRARIES_MAT LIBRARIES_DM LIBRARIES_KSP LIBRARIES_SNES LIBRARIES_TS + INCLUDE_DIR INCLUDE_CONF) +include (cmake/FindPackageMultipass.cmake) +find_package_multipass (PETSc petsc_config_current + STATES DIR ARCH + DEPENDENTS INCLUDES LIBRARIES COMPILER MPIEXEC ${petsc_slaves}) + +# Determine whether the PETSc layout is old-style (through 2.3.3) or +# new-style (>= 3.0.0) +if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/conf/rules") + set (petsc_conf_variables "${PETSC_DIR}/conf/variables") +elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules") + set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables") +elseif (PETSC_DIR) + message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation") +else () + message (FATAL_ERROR "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.") +endif () +petsc_get_version() + +if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current) + # Put variables into environment since they are needed to get + # configuration (petscvariables) in the PETSc makefile + set (ENV{PETSC_DIR} "${PETSC_DIR}") + set (ENV{PETSC_ARCH} "${PETSC_ARCH}") + + # A temporary makefile to probe the PETSc configuration + set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc") + file (WRITE "${petsc_config_makefile}" +"## This file was autogenerated by FindPETSc.cmake +# PETSC_DIR = ${PETSC_DIR} +# PETSC_ARCH = ${PETSC_ARCH} +include ${petsc_conf_rules} +include ${petsc_conf_variables} +show : + -@echo -n \${\${VARIABLE}} +") + + macro (PETSC_GET_VARIABLE name var) + set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + execute_process (COMMAND ${CMAKE_MAKE_PROGRAM} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name} + OUTPUT_VARIABLE ${var} + RESULT_VARIABLE petsc_return) + endmacro (PETSC_GET_VARIABLE) + petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir) + petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external) + petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line) + petsc_get_variable (PETSC_INCLUDE petsc_include) + petsc_get_variable (PCC petsc_cc) + petsc_get_variable (MPIEXEC petsc_mpiexec) + # We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid! + file (REMOVE ${petsc_config_makefile}) + + include (cmake/ResolveCompilerPaths.cmake) + # Extract include paths and libraries from compile command line + resolve_includes (petsc_includes_all "${petsc_cpp_line}") + + message (STATUS "petsc_lib_dir ${petsc_lib_dir}") + + macro (PETSC_FIND_LIBRARY suffix name) + set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again + find_library (PETSC_LIBRARY_${suffix} NAMES ${name} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH) + set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}") + mark_as_advanced (PETSC_LIBRARY_${suffix}) + endmacro (PETSC_FIND_LIBRARY suffix name) + + # Look for petscvec first, if it doesn't exist, we must be using single-library + petsc_find_library (VEC petscvec) + if (PETSC_LIBRARY_VEC) + petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced) + petsc_find_library (MAT petscmat) + petsc_find_library (DM petscdm) + petsc_find_library (KSP petscksp) + petsc_find_library (SNES petscsnes) + petsc_find_library (TS petscts) + macro (PETSC_JOIN libs deps) + list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}}) + endmacro (PETSC_JOIN libs deps) + petsc_join (VEC SYS) + petsc_join (MAT VEC) + petsc_join (DM MAT) + petsc_join (KSP DM) + petsc_join (SNES KSP) + petsc_join (TS SNES) + petsc_join (ALL TS) + else () + set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec + petsc_find_library (SINGLE petsc) + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}") + endforeach () + endif () + if (PETSC_LIBRARY_TS) + message (STATUS "Recognized PETSc install with separate libraries for each package") + else () + message (STATUS "Recognized PETSc install with single library for all packages") + endif () + + include (CheckCSourceRuns) + macro (PETSC_TEST_RUNS includes libraries runs) + multipass_c_source_runs ("${includes}" "${libraries}" " +static const char help[] = \"PETSc test program.\"; +#include \"petscts.h\" +int main(int argc,char *argv[]) { + PetscErrorCode ierr; + TS ts; + + ierr = PetscInitialize(&argc,&argv,0,help);CHKERRQ(ierr); + ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr); + ierr = TSSetFromOptions(ts);CHKERRQ(ierr); + ierr = TSDestroy(ts);CHKERRQ(ierr); + ierr = PetscFinalize();CHKERRQ(ierr); + return 0; +} +" ${runs}) + if (${${runs}}) + set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL + "Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE) + endif (${${runs}}) + endmacro (PETSC_TEST_RUNS) + + find_path (PETSC_INCLUDE_DIR petscts.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH) + find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH) + mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF) + set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR}) + + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal) + if (petsc_works_minimal) + message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.") + set (petsc_includes_needed "${petsc_includes_minimal}") + else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes) + if (petsc_works_allincludes) # It does, we just need all the includes ( + message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).") + set (petsc_includes_needed ${petsc_includes_all}) + else (petsc_works_allincludes) # We are going to need to link the external libs explicitly + resolve_libraries (petsc_libraries_external "${petsc_libs_external}") + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external}) + endforeach (pkg) + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries) + if (petsc_works_alllibraries) + message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.") + set (petsc_includes_needed ${petsc_includes_minimal}) + else (petsc_works_alllibraries) + # It looks like we really need everything, should have listened to Matt + set (petsc_includes_needed ${petsc_includes_all}) + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all) + if (petsc_works_all) # We fail anyways + message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.") + else (petsc_works_all) # We fail anyways + message (STATUS "PETSc could not be used, maybe the install is broken.") + endif (petsc_works_all) + endif (petsc_works_alllibraries) + endif (petsc_works_allincludes) + endif (petsc_works_minimal) + + # We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous + if (${PETSC_VERSION} VERSION_LESS 3.1) + set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE) + else () + set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE) + endif () + # Sometimes this can be used to assist FindMPI.cmake + set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE) + set (PETSC_INCLUDES ${petsc_includes_needed} CACHE STRING "PETSc include path" FORCE) + set (PETSC_LIBRARIES ${PETSC_LIBRARIES_ALL} CACHE STRING "PETSc libraries" FORCE) + set (PETSC_COMPILER ${petsc_cc} CACHE FILEPATH "PETSc compiler" FORCE) + # Note that we have forced values for all these choices. If you + # change these, you are telling the system to trust you that they + # work. It is likely that you will end up with a broken build. + mark_as_advanced (PETSC_INCLUDES PETSC_LIBRARIES PETSC_COMPILER PETSC_DEFINITIONS PETSC_MPIEXEC PETSC_EXECUTABLE_RUNS) +endif () + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (PETSc + "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH." + PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS) diff --git a/AMDiS/cmake/enable_extensions.cmake b/AMDiS/cmake/enable_extensions.cmake index ef6f09be..16d9d077 100644 --- a/AMDiS/cmake/enable_extensions.cmake +++ b/AMDiS/cmake/enable_extensions.cmake @@ -1,4 +1,7 @@ +# TODO: make extensions a subproject +# add_subdirectory(${SOURCE_DIR}/compositeFEM [binarydir]) + if (ENABLE_EXTENSIONS) option(ENABLE_BASE_PROBLEMS "Use base_problems" true) find_path(EXTENSIONS_DIR NAMES Helpers.h diff --git a/AMDiS/cmake/enable_parallel_domain.cmake b/AMDiS/cmake/enable_parallel_domain.cmake index 7d1b0705..562ff0ac 100644 --- a/AMDiS/cmake/enable_parallel_domain.cmake +++ b/AMDiS/cmake/enable_parallel_domain.cmake @@ -108,7 +108,7 @@ if (ENABLE_PARALLEL_DOMAIN) message(SEND_ERROR "Set the domain-decomposition version correctly.") endif() - INSTALL(FILES ResolveCompilerPaths.cmake FindPackageMultipass.cmake FindPETSc.cmake + INSTALL(FILES cmake/ResolveCompilerPaths.cmake cmake/FindPackageMultipass.cmake cmake/FindPETSc.cmake DESTINATION share/amdis/) if(USE_PETSC_DEV) list(APPEND COMPILEFLAGS "-DHAVE_PETSC_DEV") diff --git a/AMDiS/cmake3/AMDISConfig.cmake.in b/AMDiS/cmake3/AMDISConfig.cmake.in new file mode 100644 index 00000000..58ce23b3 --- /dev/null +++ b/AMDiS/cmake3/AMDISConfig.cmake.in @@ -0,0 +1,199 @@ +# This configuration file is shipped with the great FEM-Toolbox AMDiS. +# It simplifies the configure of different amdis-versions. +# +# In order to compile an amdis-project and link against the amdis +# (and subsequent) libraries simply add 'AMDiS' to the target_link_libraries +# of your executable target. All include-paths and additional libraries are +# automatically added. +# +# For a fast start, you use this package in the following way +# simply look for it, possibly set the AMDiS directory +# +# find_package(AMDiS REQUIRED) +# add_executable(yourTarget ) +# target_link_libraries(yourTarget AMDiS) +# + +if (${CMAKE_VERSION} VERSION_LESS "3.0") + message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.0") +endif () + +list(APPEND CMAKE_MODULE_PATH ${AMDIS_DIR}) + +set(AMDIS_NEED_ZOLTAN @ENABLE_ZOLTAN@) +set(AMDIS_NEED_CXX11 @ENABLE_CXX11@) +set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@) +set(AMDIS_HAS_PARALLEL_DOMAIN @ENABLE_PARALLEL_DOMAIN@) +set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@) + + +add_library(amdis_base INTERFACE) +add_library(AMDiS ALIAS amdis_base) + +target_compile_definitions(amdis_base INTERFACE + $<$:DEBUG=1> + $<$:DEBUG=0>) + +if (AMDIS_NEED_CXX11) + target_compile_features(amdis_base INTERFACE + cxx_alias_templates + cxx_auto_type + cxx_lambdas + cxx_override + cxx_range_for + cxx_static_assert + cxx_variadic_templates) + target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1) +else () + target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0) +endif (AMDIS_NEED_CXX11) + + +# try to detect the AMDiS include directory +# ------------------------------------------- +find_file(_AMDIS_H AMDiS.h PATHS ${AMDIS_DIR}/../../include/amdis/) +if (_AMDIS_H) + get_filename_component(AMDIS_INCLUDE_DIR ${_AMDIS_H} PATH CACHE) + target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}) + target_include_directories(amdis_base INTERFACE ${AMDIS_INCLUDE_DIR}/mtl4) +else () + message(ERROR "Could not detect the AMDiS include directory. Please set the variable AMDIS_INCLUDE_DIR to the directory containing the AMDiS headers.") +endif () +unset(_AMDIS_H CACHE) + + +# AMDiS base libraries +# -------------------- +find_library(_AMDIS_LIB amdis PATHS ${AMDIS_DIR}/../../lib/amdis/) +if (_AMDIS_LIB) + target_link_libraries(amdis_base INTERFACE ${_AMDIS_LIB}) +else () + message(ERROR "Could not detect the AMDiS library. Please set the variable _AMDIS_LIB to the AMDiS library.") +endif () +unset(_AMDIS_LIB CACHE) + + +# Boost libraries +# --------------- +set(BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time) +if (WIN32) + list(APPEND BOOST_LIBS_REQUIRED zlib) + if (AMDIS_NEED_COMPRESSION) + list(APPEND BOOST_LIBS_REQUIRED bzip2) + endif () +endif () + +set(BOOST_VERSION "1.48") +find_package(Boost ${BOOST_VERSION} REQUIRED ${BOOST_LIBS_REQUIRED}) + +if (Boost_FOUND) + target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}) + target_link_libraries(amdis_base INTERFACE ${Boost_LIBRARIES}) +else () + message(ERROR "Boost libraries not found") +endif(Boost_FOUND) + + +# umfpack library +# -------------------- +if (AMDIS_NEED_UMFPACK) + set(AMDIS_UMFPACK_INCLUDE_DIR @UMFPACK_INCLUDE_DIRS@) + set(AMDIS_UMFPACK_LIB_DIR ${AMDIS_UMFPACK_INCLUDE_DIR}/../lib) + find_file(UMFPACK_H umfpack.h HINTS ${AMDIS_UMFPACK_INCLUDE_DIR}) + find_library(UMFPACK_LIBRARY umfpack HINTS ${AMDIS_UMFPACK_LIB_DIR}) + if (UMFPACK_H AND UMFPACK_LIBRARY) + get_filename_component(UMFPACK_INCLUDE_DIRS ${UMFPACK_H} PATH) + target_include_directories(amdis_base INTERFACE ${UMFPACK_INCLUDE_DIRS}) + + find_library(AMD_LIBRARY amd HINTS ${AMDIS_UMFPACK_LIB_DIR}) + find_library(BLAS_LIBRARY blas HINTS ${AMDIS_UMFPACK_LIB_DIR}) + if (AMD_LIBRARY AND BLAS_LIBRARY) + target_link_libraries(amdis_base INTERFACE + ${UMFPACK_LIBRARY} + ${AMD_LIBRARY} + ${BLAS_LIBRARY}) + # TODO: add test whether umfpack is configured successfully + endif() + else() + message(FATAL_ERROR "Could not find the UMFPACK library") + endif() +endif (AMDIS_NEED_UMFPACK) + + +# Parallel amdis +# -------------- +if (AMDIS_HAS_PARALLEL_DOMAIN) + find_package(MPI REQUIRED) + if (MPI_FOUND) + target_include_directories(amdis_base INTERFACE ${MPI_INCLUDE_PATH}) + target_compile_options(amdis_base INTERFACE ${MPI_COMPILE_FLAGS}) + target_link_libraries(amdis_base INTERFACE ${MPI_LIBRARIES}) + endif (MPI_FOUND) + + set(PETSC_EXECUTABLE_RUNS ON) + set(AMDIS_PETSC_DIR @PETSC_DIR@) + include(find_petsc) + if (PETSc_FOUND) + target_include_directories(amdis_base INTERFACE ${PETSC_INCLUDES}) + target_link_libraries(amdis_base INTERFACE + ${PETSC_LIBRARY_SYS} + ${PETSC_LIBRARIES}) + else() + message(FATAL_ERROR "Could not find PETSc!") + endif (PETSc_FOUND) + + find_library(_AMDIS_PARALLEL_LIB amdis_parallel PATHS ${AMDIS_DIR}/../../lib/amdis/) + if (_AMDIS_PARALLEL_LIB) + target_link_libraries(amdis_base INTERFACE ${_AMDIS_PARALLEL_LIB}) + else () + message(ERROR "Could not detect the AMDiS::parallel library. Please set the variable _AMDIS_PARALLEL_LIB to this library.") + endif () + unset(_AMDIS_PARALLEL_LIB CACHE) +endif (AMDIS_HAS_PARALLEL_DOMAIN) + + +# reinit library +# -------------- +find_library(_REINIT_LIB amdis_reinit PATHS ${AMDIS_DIR}/../../lib/amdis/) +if (_REINIT_LIB) + target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}/reinit) + target_link_libraries(amdis_base INTERFACE ${_REINIT_LIB}) +else () + message(ERROR "Reinit library not found") +endif () +unset(_REINIT_LIB CACHE) + + +# compositeFEM library +# -------------------- +find_library(_COMPOSITE_FEM_LIB amdis_compositeFEM PATHS ${AMDIS_DIR}/../../lib/amdis/) +if (_COMPOSITE_FEM_LIB) + target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}/compositeFEM) + target_link_libraries(amdis_base INTERFACE ${_COMPOSITE_FEM_LIB}) +else () + message(ERROR "CompositeFEM library not found") +endif () +unset(_COMPOSITE_FEM_LIB CACHE) + + +# muparser library +# -------------------- +find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_DIR}/../../lib/amdis/) +if (_MUPARSER_LIB) + target_include_directories(amdis_base INTERFACE ${Boost_INCLUDE_DIR}/muparser) + target_link_libraries(amdis_base INTERFACE ${_MUPARSER_LIB}) +else () + message(ERROR "MuParser library not found") +endif () +unset(_MUPARSER_LIB CACHE) + +# Zoltan library +# -------------- +if (AMDIS_NEED_ZOLTAN) + find_library(ZOLTAN_LIB zoltan HINTS ENV LIBRARY_PATH DOC "Full path to the zoltan library") + if (ZOLTAN_LIB) + target_link_libraries(amdis_base INTERFACE ${ZOLTAN_LIB}) + else() + message(FATAL_ERROR "Could not find zoltan library!") + endif() +endif () diff --git a/AMDiS/cmake3/CMakeLists_3.0.txt b/AMDiS/cmake3/CMakeLists_3.0.txt new file mode 100644 index 00000000..1431a75a --- /dev/null +++ b/AMDiS/cmake3/CMakeLists_3.0.txt @@ -0,0 +1,219 @@ +cmake_minimum_required(VERSION 3.2 FATAL_ERROR) +project(AMDiS VERSION 0.9 LANGUAGES CXX) + +set(BASE_DIR ${AMDiS_SOURCE_DIR}) +set(SOURCE_DIR ${BASE_DIR}/src) +list(APPEND CMAKE_MODULE_PATH ${BASE_DIR}/cmake3) + +option(BUILD_SHARED_LIBS "Build all libraries as shared or static, default: shared" true) +option(ENABLE_CXX11 "Enable C++11 compiler features" false) +option(ENABLE_PARALLEL_DOMAIN "Use parallel domain decomposition" false) +option(ENABLE_UMFPACK "Use of UMFPACK solver" false) +option(ENABLE_COMPRESSION "Use output compression" false) + + +add_library(amdis_base INTERFACE) +add_library(AMDiS::base ALIAS amdis_base) + +target_include_directories(amdis_base INTERFACE ${SOURCE_DIR}) +target_compile_definitions(amdis_base INTERFACE + $<$:DEBUG=1> + $<$:DEBUG=0>) + +if (ENABLE_CXX11) + target_compile_features(amdis_base INTERFACE + cxx_alias_templates + cxx_auto_type + cxx_lambdas + cxx_override + cxx_range_for + cxx_static_assert + cxx_variadic_templates) + target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1) +else () + target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0) +endif (ENABLE_CXX11) + +# ------------------------------------------------------------------------------ + +include(find_mtl4) # -> target mtl4 +include(find_boost) # -> target boost + +# ------------------------------------------------------------------------------ + +add_library(amdis + ${SOURCE_DIR}/AdaptBase.cc + ${SOURCE_DIR}/AdaptInfo.cc + ${SOURCE_DIR}/AdaptInstationary.cc + ${SOURCE_DIR}/AdaptStationary.cc + ${SOURCE_DIR}/AMDiS.cc + ${SOURCE_DIR}/Assembler.cc + ${SOURCE_DIR}/BasisFunction.cc + ${SOURCE_DIR}/Boundary.cc + ${SOURCE_DIR}/BoundaryManager.cc + ${SOURCE_DIR}/BoundaryObject.cc + ${SOURCE_DIR}/Bubble.cc + ${SOURCE_DIR}/Cholesky.cc + ${SOURCE_DIR}/CoarseningManager.cc + ${SOURCE_DIR}/CoarseningManager1d.cc + ${SOURCE_DIR}/CoarseningManager2d.cc + ${SOURCE_DIR}/CoarseningManager3d.cc + ${SOURCE_DIR}/ComponentTraverseInfo.cc + ${SOURCE_DIR}/CouplingIterationInterface.cc + ${SOURCE_DIR}/CreatorMap.cc + ${SOURCE_DIR}/DOFAdmin.cc + ${SOURCE_DIR}/DOFIndexed.cc + ${SOURCE_DIR}/DOFMatrix.cc + ${SOURCE_DIR}/DOFVector.cc + ${SOURCE_DIR}/Debug.cc + ${SOURCE_DIR}/DirichletBC.cc + ${SOURCE_DIR}/DualTraverse.cc + ${SOURCE_DIR}/ElInfo.cc + ${SOURCE_DIR}/ElInfo1d.cc + ${SOURCE_DIR}/ElInfo2d.cc + ${SOURCE_DIR}/ElInfo3d.cc + ${SOURCE_DIR}/ElInfoStack.cc + ${SOURCE_DIR}/Element.cc + ${SOURCE_DIR}/ElementData.cc + ${SOURCE_DIR}/ElementDofIterator.cc + ${SOURCE_DIR}/ElementRegion_ED.cc + ${SOURCE_DIR}/FiniteElemSpace.cc + ${SOURCE_DIR}/FirstOrderAssembler.cc + ${SOURCE_DIR}/FirstOrderTerm.cc + ${SOURCE_DIR}/FixVec.cc + ${SOURCE_DIR}/Global.cc + ${SOURCE_DIR}/GlobalDOFNumbering.cc + ${SOURCE_DIR}/GlobalElementNumbering.cc + ${SOURCE_DIR}/Initfile.cc + ${SOURCE_DIR}/Lagrange.cc + ${SOURCE_DIR}/LeafData.cc + ${SOURCE_DIR}/Line.cc + ${SOURCE_DIR}/MacroElement.cc + ${SOURCE_DIR}/Marker.cc + ${SOURCE_DIR}/MatrixVector.cc + ${SOURCE_DIR}/Mesh.cc + ${SOURCE_DIR}/MeshStructure.cc + ${SOURCE_DIR}/Operator.cc + ${SOURCE_DIR}/OperatorTerm.cc + ${SOURCE_DIR}/Parametric.cc + ${SOURCE_DIR}/PeriodicBC.cc + ${SOURCE_DIR}/ProblemInstat.cc + ${SOURCE_DIR}/ProblemInterpol.cc + ${SOURCE_DIR}/ProblemStat.cc + ${SOURCE_DIR}/ProblemStatDbg.cc + ${SOURCE_DIR}/Projection.cc + ${SOURCE_DIR}/QPInfo.cc + ${SOURCE_DIR}/QPsiPhi.cc + ${SOURCE_DIR}/Quadrature.cc + ${SOURCE_DIR}/RCNeighbourList.cc + ${SOURCE_DIR}/Recovery.cc + ${SOURCE_DIR}/RefinementManager.cc + ${SOURCE_DIR}/RefinementManager1d.cc + ${SOURCE_DIR}/RefinementManager2d.cc + ${SOURCE_DIR}/RefinementManager3d.cc + ${SOURCE_DIR}/RobinBC.cc + ${SOURCE_DIR}/ScalableQuadrature.cc + ${SOURCE_DIR}/SecondOrderAssembler.cc + ${SOURCE_DIR}/SecondOrderTerm.cc + ${SOURCE_DIR}/Serializer.cc + ${SOURCE_DIR}/StandardProblemIteration.cc + ${SOURCE_DIR}/SubAssembler.cc + ${SOURCE_DIR}/SubElInfo.cc + ${SOURCE_DIR}/SubQuadrature.cc + ${SOURCE_DIR}/SurfaceQuadrature.cc + ${SOURCE_DIR}/SurfaceRegion_ED.cc + ${SOURCE_DIR}/SystemVector.cc + ${SOURCE_DIR}/Tetrahedron.cc + ${SOURCE_DIR}/Timer.cc + ${SOURCE_DIR}/Traverse.cc + ${SOURCE_DIR}/Triangle.cc + ${SOURCE_DIR}/VertexVector.cc + ${SOURCE_DIR}/ZeroOrderAssembler.cc + ${SOURCE_DIR}/ZeroOrderTerm.cc + ${SOURCE_DIR}/est/Estimator.cc + ${SOURCE_DIR}/est/RecoveryEstimator.cc + ${SOURCE_DIR}/est/ResidualEstimator.cc + ${SOURCE_DIR}/est/SimpleResidualEstimator.cc + ${SOURCE_DIR}/io/ArhReader.cc + ${SOURCE_DIR}/io/detail/ArhReader.cc + ${SOURCE_DIR}/io/Arh2Reader.cc + ${SOURCE_DIR}/io/Arh2Writer.cc + ${SOURCE_DIR}/io/Arh3Reader.cc + ${SOURCE_DIR}/io/Arh3Writer.cc + ${SOURCE_DIR}/io/detail/Arh2Reader.cc + ${SOURCE_DIR}/io/detail/ArhWriter.cc + ${SOURCE_DIR}/io/detail/Arh2Writer.cc + ${SOURCE_DIR}/io/detail/Arh3Reader.cc + ${SOURCE_DIR}/io/detail/Arh3Writer.cc + ${SOURCE_DIR}/io/DofWriter.cc + ${SOURCE_DIR}/io/ElementFileWriter.cc + ${SOURCE_DIR}/io/FileWriterInterface.cc + ${SOURCE_DIR}/io/FileWriter.cc + ${SOURCE_DIR}/io/GNUPlotWriter.cc + ${SOURCE_DIR}/io/MacroInfo.cc + ${SOURCE_DIR}/io/MacroReader.cc + ${SOURCE_DIR}/io/MacroWriter.cc + ${SOURCE_DIR}/io/PngReader.cc + ${SOURCE_DIR}/io/PngWriter.cc + ${SOURCE_DIR}/io/PovrayWriter.cc + ${SOURCE_DIR}/io/Spreadsheet.cc + ${SOURCE_DIR}/io/ValueReader.cc + ${SOURCE_DIR}/io/ValueWriter.cc + ${SOURCE_DIR}/io/VtkWriter.cc + ${SOURCE_DIR}/io/VtkVectorWriter.cc + ${SOURCE_DIR}/io/detail/VtkWriter.cc + ${SOURCE_DIR}/nonlin/ProblemNonLin.cc + ${SOURCE_DIR}/solver/SolverMatrix.cc + ${SOURCE_DIR}/time/RosenbrockAdaptInstationary.cc + ${SOURCE_DIR}/time/RosenbrockMethod.cc + ${SOURCE_DIR}/time/RosenbrockStationary.cc + ) + +if (ENABLE_COMPRESSION) + target_compile_definitions(amdis PRIVATE HAVE_COMPRESSION=1) +endif (ENABLE_COMPRESSION) + +include(amdis_parallel) # -> target AMDiS::parallel +include(amdis_reinit) # -> target AMDiS::reinit +include(amdis_compositeFEM) # -> target AMDiS::compositeFEM +include(muparser) # -> target muparser + + +if (MSVC) + target_compile_definitions(amdis PRIVATE + _SCL_SECURE_NO_WARNINGS + _CRT_SECURE_NO_WARNINGS) +endif (MSVC) + +target_link_libraries(amdis AMDiS::base AMDiS::reinit AMDiS::compositeFEM muparser) +if (ENABLE_PARALLEL_DOMAIN) + target_link_libraries(amdis AMDiS::parallel) +endif (ENABLE_PARALLEL_DOMAIN) + + +# specify how to install this target: +# ----------------------------------- + +set(INSTALL_SUBDIRS . config nonlin est expressions operations traits + utility time solver solver/details solver/itl io io/detail) + +foreach (SUBDIR ${INSTALL_SUBDIRS}) + file(GLOB HEADERS "${SOURCE_DIR}/${SUBDIR}/*.h*") + install(FILES ${HEADERS} DESTINATION include/amdis/${SUBDIR}/) +endforeach () + +install(TARGETS amdis DESTINATION lib/amdis/ ) + +# generate configuration file: +# ---------------------------- + +configure_file(${BASE_DIR}/cmake3/AMDISConfig.cmake.in + ${AMDiS_BINARY_DIR}/AMDISConfig.cmake + @ONLY +) + +install(FILES ${AMDiS_BINARY_DIR}/AMDISConfig.cmake DESTINATION share/amdis/) + +# file(GLOB CMAKE_FILES "${BASE_DIR}/cmake3/*.cmake") +# install(FILES ${CMAKE_FILES} DESTINATION share/amdis/) + diff --git a/AMDiS/cmake3/FindPackageMultipass.cmake b/AMDiS/cmake3/FindPackageMultipass.cmake new file mode 100644 index 00000000..7199e026 --- /dev/null +++ b/AMDiS/cmake3/FindPackageMultipass.cmake @@ -0,0 +1,91 @@ +# PackageMultipass - this module defines two macros +# +# FIND_PACKAGE_MULTIPASS (Name CURRENT +# STATES VAR0 VAR1 ... +# DEPENDENTS DEP0 DEP1 ...) +# +# This function creates a cache entry _CURRENT which +# the user can set to "NO" to trigger a reconfiguration of the package. +# The first time this function is called, the values of +# _VAR0, ... are saved. If _CURRENT +# is false or if any STATE has changed since the last time +# FIND_PACKAGE_MULTIPASS() was called, then CURRENT will be set to "NO", +# otherwise CURRENT will be "YES". IF not CURRENT, then +# _DEP0, ... will be FORCED to NOTFOUND. +# Example: +# find_path (FOO_DIR include/foo.h) +# FIND_PACKAGE_MULTIPASS (Foo foo_current +# STATES DIR +# DEPENDENTS INCLUDES LIBRARIES) +# if (NOT foo_current) +# # Make temporary files, run programs, etc, to determine FOO_INCLUDES and FOO_LIBRARIES +# endif (NOT foo_current) +# +# MULTIPASS_C_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS) +# Always runs the given test, use this when you need to re-run tests +# because parent variables have made old cache entries stale. + +macro (FIND_PACKAGE_MULTIPASS _name _current) + string (TOUPPER ${_name} _NAME) + set (_args ${ARGV}) + list (REMOVE_AT _args 0 1) + + set (_states_current "YES") + list (GET _args 0 _cmd) + if (_cmd STREQUAL "STATES") + list (REMOVE_AT _args 0) + list (GET _args 0 _state) + while (_state AND NOT _state STREQUAL "DEPENDENTS") + # The name of the stored value for the given state + set (_stored_var PACKAGE_MULTIPASS_${_NAME}_${_state}) + if (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") + set (_states_current "NO") + endif (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") + set (${_stored_var} "${${_NAME}_${_state}}" CACHE INTERNAL "Stored state for ${_name}." FORCE) + list (REMOVE_AT _args 0) + list (GET _args 0 _state) + endwhile (_state AND NOT _state STREQUAL "DEPENDENTS") + endif (_cmd STREQUAL "STATES") + + set (_stored ${_NAME}_CURRENT) + if (NOT ${_stored}) + set (${_stored} "YES" CACHE BOOL "Is the configuration for ${_name} current? Set to \"NO\" to reconfigure." FORCE) + set (_states_current "NO") + endif (NOT ${_stored}) + + set (${_current} ${_states_current}) + if (NOT ${_current} AND PACKAGE_MULTIPASS_${_name}_CALLED) + message (STATUS "Clearing ${_name} dependent variables") + # Clear all the dependent variables so that the module can reset them + list (GET _args 0 _cmd) + if (_cmd STREQUAL "DEPENDENTS") + list (REMOVE_AT _args 0) + foreach (dep ${_args}) + set (${_NAME}_${dep} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + endforeach (dep) + endif (_cmd STREQUAL "DEPENDENTS") + set (${_NAME}_FOUND "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + endif () + set (PACKAGE_MULTIPASS_${name}_CALLED YES CACHE INTERNAL "Private" FORCE) +endmacro (FIND_PACKAGE_MULTIPASS) + + +macro (MULTIPASS_C_SOURCE_RUNS includes libraries source runs) + include (CheckCSourceRuns) + # This is a ridiculous hack. CHECK_C_SOURCE_* thinks that if the + # *name* of the return variable doesn't change, then the test does + # not need to be re-run. We keep an internal count which we + # increment to guarantee that every test name is unique. If we've + # gotten here, then the configuration has changed enough that the + # test *needs* to be rerun. + if (NOT MULTIPASS_TEST_COUNT) + set (MULTIPASS_TEST_COUNT 00) + endif (NOT MULTIPASS_TEST_COUNT) + math (EXPR _tmp "${MULTIPASS_TEST_COUNT} + 1") # Why can't I add to a cache variable? + set (MULTIPASS_TEST_COUNT ${_tmp} CACHE INTERNAL "Unique test ID") + set (testname MULTIPASS_TEST_${MULTIPASS_TEST_COUNT}_${runs}) + set (CMAKE_REQUIRED_INCLUDES ${includes}) + set (CMAKE_REQUIRED_LIBRARIES ${libraries}) + check_c_source_runs ("${source}" ${testname}) + set (${runs} "${${testname}}") +endmacro (MULTIPASS_C_SOURCE_RUNS) diff --git a/AMDiS/cmake3/ResolveCompilerPaths.cmake b/AMDiS/cmake3/ResolveCompilerPaths.cmake new file mode 100644 index 00000000..b398025e --- /dev/null +++ b/AMDiS/cmake3/ResolveCompilerPaths.cmake @@ -0,0 +1,93 @@ +# ResolveCompilerPaths - this module defines two macros +# +# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE) +# This macro is intended to be used by FindXXX.cmake modules. +# It parses a compiler link line and resolves all libraries +# (-lfoo) using the library path contexts (-L/path) in scope. +# The result in XXX_LIBRARIES is the list of fully resolved libs. +# Example: +# +# RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld") +# +# will be resolved to +# +# FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so" +# +# if the filesystem looks like +# +# /A: liba.so libc.so +# /B: liba.so libb.so +# /usr/lib: liba.so libb.so libc.so libd.so +# +# and /usr/lib is a system directory. +# +# Note: If RESOLVE_LIBRARIES() resolves a link line differently from +# the native linker, there is a bug in this macro (please report it). +# +# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE) +# This macro is intended to be used by FindXXX.cmake modules. +# It parses a compile line and resolves all includes +# (-I/path/to/include) to a list of directories. Other flags are ignored. +# Example: +# +# RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B") +# +# will be resolved to +# +# FOO_INCLUDES:STRING="/A;/B" +# +# assuming both directories exist. +# Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry) + +macro (RESOLVE_LIBRARIES LIBS LINK_LINE) + string (REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|/[^\" ]+(a|so|dll))" _all_tokens "${LINK_LINE}") + set (_libs_found) + set (_directory_list) + foreach (token ${_all_tokens}) + if (token MATCHES "-L([^\" ]+|\"[^\"]+\")") + # If it's a library path, add it to the list + string (REGEX REPLACE "^-L" "" token ${token}) + string (REGEX REPLACE "//" "/" token ${token}) + list (APPEND _directory_list ${token}) + elseif (token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|/[^\" ]+(a|so|dll))") + # It's a library, resolve the path by looking in the list and then (by default) in system directories + string (REGEX REPLACE "^-l" "" token ${token}) + set (_root) + if (token MATCHES "^/") # We have an absolute path, add root to the search path + set (_root "/") + endif (token MATCHES "^/") + set (_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library (_lib ${token} HINTS ${_directory_list} ${_root}) + if (_lib) + string (REPLACE "//" "/" _lib ${_lib}) + list (APPEND _libs_found ${_lib}) + else (_lib) + message (STATUS "Unable to find library ${token}") + endif (_lib) + endif (token MATCHES "-L([^\" ]+|\"[^\"]+\")") + endforeach (token) + set (_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) + # only the LAST occurence of each library is required since there should be no circular dependencies + if (_libs_found) + list (REVERSE _libs_found) + list (REMOVE_DUPLICATES _libs_found) + list (REVERSE _libs_found) + endif (_libs_found) + set (${LIBS} "${_libs_found}") +endmacro (RESOLVE_LIBRARIES) + +macro (RESOLVE_INCLUDES INCS COMPILE_LINE) + string (REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}") + set (_incs_found) + foreach (token ${_all_tokens}) + string (REGEX REPLACE "^-I" "" token ${token}) + string (REGEX REPLACE "//" "/" token ${token}) + if (EXISTS ${token}) + list (APPEND _incs_found ${token}) + else (EXISTS ${token}) + message (STATUS "Include directory ${token} does not exist") + endif (EXISTS ${token}) + endforeach (token) + list (REMOVE_DUPLICATES _incs_found) + set (${INCS} "${_incs_found}") +endmacro (RESOLVE_INCLUDES) diff --git a/AMDiS/cmake3/amdis_compositeFEM.cmake b/AMDiS/cmake3/amdis_compositeFEM.cmake new file mode 100644 index 00000000..33a6e340 --- /dev/null +++ b/AMDiS/cmake3/amdis_compositeFEM.cmake @@ -0,0 +1,26 @@ +# specify the target and requirements for the composite fem library + +SET(COMPOSITE_SOURCE_DIR ${SOURCE_DIR}/compositeFEM) +add_library(amdis_compositeFEM + ${COMPOSITE_SOURCE_DIR}/CFE_Integration.cc + ${COMPOSITE_SOURCE_DIR}/CFE_NormAndErrorFcts.cc + ${COMPOSITE_SOURCE_DIR}/CompositeFEMMethods.cc + ${COMPOSITE_SOURCE_DIR}/CompositeFEMOperator.cc + ${COMPOSITE_SOURCE_DIR}/LevelSetAdaptMesh.cc + ${COMPOSITE_SOURCE_DIR}/PenaltyOperator.cc + ${COMPOSITE_SOURCE_DIR}/ElementLevelSet.cc + ${COMPOSITE_SOURCE_DIR}/SubPolytope.cc + ${COMPOSITE_SOURCE_DIR}/SubElementAssembler.cc) +add_library(AMDiS::compositeFEM ALIAS amdis_compositeFEM) + +target_compile_definitions(amdis_compositeFEM PUBLIC + HAVE_COMPOSITE_FEM=1) +target_include_directories(amdis_compositeFEM PRIVATE ${COMPOSITE_SOURCE_DIR}) +target_link_libraries(amdis_compositeFEM amdis_base) + +# specify how to install this target: +# ----------------------------------- + +file(GLOB COMPOSITE_HEADERS "${COMPOSITE_SOURCE_DIR}/*.h*") +install(FILES ${COMPOSITE_HEADERS} DESTINATION include/amdis/compositeFEM) +install(TARGETS amdis_compositeFEM DESTINATION lib/amdis/ ) \ No newline at end of file diff --git a/AMDiS/cmake3/amdis_parallel.cmake b/AMDiS/cmake3/amdis_parallel.cmake new file mode 100644 index 00000000..60c9a588 --- /dev/null +++ b/AMDiS/cmake3/amdis_parallel.cmake @@ -0,0 +1,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) diff --git a/AMDiS/cmake3/amdis_reinit.cmake b/AMDiS/cmake3/amdis_reinit.cmake new file mode 100644 index 00000000..862cb62a --- /dev/null +++ b/AMDiS/cmake3/amdis_reinit.cmake @@ -0,0 +1,19 @@ +# specify the target and requirements for the reinit library + +SET(COMPOSITE_SOURCE_DIR ${SOURCE_DIR}/reinit) +set(REINIT_SOURCE_DIR ${SOURCE_DIR}/reinit) +file(GLOB REINIT_SRC ${REINIT_SOURCE_DIR}/*.cc) +add_library(amdis_reinit ${REINIT_SRC}) +add_library(AMDiS::reinit ALIAS amdis_reinit) + +target_compile_definitions(amdis_reinit PUBLIC + HAVE_REINIT=1) +target_include_directories(amdis_reinit PRIVATE ${REINIT_SOURCE_DIR}) +target_link_libraries(amdis_reinit amdis_base) + +# specify how to install this target: +# ----------------------------------- + +file(GLOB RINIT_HEADERS "${REINIT_SOURCE_DIR}/*.h*") +install(FILES ${RINIT_HEADERS} DESTINATION include/amdis/reinit) +install(TARGETS amdis_reinit DESTINATION lib/amdis/ ) \ No newline at end of file diff --git a/AMDiS/cmake3/find_boost.cmake b/AMDiS/cmake3/find_boost.cmake new file mode 100644 index 00000000..19eb347e --- /dev/null +++ b/AMDiS/cmake3/find_boost.cmake @@ -0,0 +1,7 @@ +find_package(Boost 1.44 REQUIRED) +if (Boost_FOUND) + add_library(boost INTERFACE) + target_include_directories(boost INTERFACE ${Boost_INCLUDE_DIR}) + + target_link_libraries(amdis_base INTERFACE boost) +endif (Boost_FOUND) diff --git a/AMDiS/cmake3/find_mtl4.cmake b/AMDiS/cmake3/find_mtl4.cmake new file mode 100644 index 00000000..bf5b4867 --- /dev/null +++ b/AMDiS/cmake3/find_mtl4.cmake @@ -0,0 +1,48 @@ +find_package(MTL REQUIRED HINTS ${BASE_DIR}/lib/mtl4) +# hide options of MTL4 and use the AMDiS replacement +mark_as_advanced(ENABLE_CXX_ELEVEN) +mark_as_advanced(ENABLE_SHORT_ELE_PROD) +mark_as_advanced(ENABLE_VAMPIR) +if (MTL_FOUND) + add_library(mtl4 INTERFACE) + + target_include_directories(mtl4 INTERFACE + $ + $) + + if (ENABLE_CXX11) + string (REPLACE "-std=c++0x" "" MTL_CXX_DEFINITIONS "${MTL_CXX_DEFINITIONS}") + string (REPLACE "-std=c++11" "" MTL_CXX_DEFINITIONS "${MTL_CXX_DEFINITIONS}") + string (REPLACE "-std=gnu++0x" "" MTL_CXX_DEFINITIONS "${MTL_CXX_DEFINITIONS}") + string (REPLACE "-std=gnu++11" "" MTL_CXX_DEFINITIONS "${MTL_CXX_DEFINITIONS}") + target_compile_features(mtl4 INTERFACE + cxx_rvalue_references + cxx_auto_type + cxx_range_for + cxx_generalized_initializers + cxx_static_assert + cxx_defaulted_functions) + set(ENABLE_CXX_ELEVEN true) + else () + set(ENABLE_CXX_ELEVEN false) + endif () + + if (ENABLE_UMFPACK) + target_compile_definitions(mtl4 INTERFACE HAVE_UMFPACK=1) + endif (ENABLE_UMFPACK) + + target_compile_options(mtl4 INTERFACE ${MTL_CXX_DEFINITIONS}) + target_link_libraries(mtl4 INTERFACE ${MTL_LIBRARIES}) + + # specify how to install this target: + # ----------------------------------- + install(DIRECTORY ${MTL_DIR}/ + DESTINATION include/amdis/mtl4/ + FILES_MATCHING PATTERN "*.hpp" + PATTERN ".svn" EXCLUDE + PATTERN ".svn/*" EXCLUDE + PATTERN "mtl4/libs" EXCLUDE + PATTERN "mtl4/extern" EXCLUDE) + + target_link_libraries(amdis_base INTERFACE mtl4) +endif (MTL_FOUND) diff --git a/AMDiS/cmake3/find_petsc.cmake b/AMDiS/cmake3/find_petsc.cmake new file mode 100644 index 00000000..9b168384 --- /dev/null +++ b/AMDiS/cmake3/find_petsc.cmake @@ -0,0 +1,248 @@ +# - Try to find PETSc +# Once done this will define +# source: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake +# +# PETSC_FOUND - system has PETSc +# PETSC_INCLUDES - the PETSc include directories +# PETSC_LIBRARIES - Link these to use PETSc +# PETSC_COMPILER - Compiler used by PETSc, helpful to find a compatible MPI +# PETSC_DEFINITIONS - Compiler switches for using PETSc +# PETSC_MPIEXEC - Executable for running MPI programs +# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR) +# +# Hack: PETSC_VERSION currently decides on the version based on the +# layout. Otherwise we need to run C code to determine the version. +# +# Setting these changes the behavior of the search +# PETSC_DIR - directory in which PETSc resides +# PETSC_ARCH - build architecture +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +function (petsc_get_version) + if (EXISTS "${PETSC_DIR}/include/petscversion.h") + file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") + foreach (line ${vstrings}) + string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define") + list (GET fields 1 var) + list (GET fields 2 val) + set (${var} ${val} PARENT_SCOPE) + set (${var} ${val}) # Also in local scope so we have access below + endforeach () + if (PETSC_VERSION_RELEASE) + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE) + else () + # make dev version compare higher than any patch level of a released version + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE) + endif () + else () + message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist") + endif () +endfunction () + +find_path (PETSC_DIR include/petsc.h + HINTS ${AMDIS_PETSC_DIR} $ENV{HOME}/petsc ENV PETSC_DIR + DOC "PETSc Directory") + +if (PETSC_DIR AND NOT PETSC_ARCH) + set (_petsc_arches + $ENV{PETSC_ARCH} # If set, use environment variable first + linux-gnu-c-debug linux-gnu-c-opt # Debian defaults + x86_64-unknown-linux-gnu i386-unknown-linux-gnu) + set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + foreach (arch ${_petsc_arches}) + if (NOT PETSC_ARCH) + find_path (petscconf petscconf.h + HINTS ${PETSC_DIR} + PATH_SUFFIXES ${arch}/include bmake/${arch} + NO_DEFAULT_PATH) + if (petscconf) + set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") + endif (petscconf) + endif (NOT PETSC_ARCH) + endforeach (arch) + set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) +endif (PETSC_DIR AND NOT PETSC_ARCH) + +set (petsc_slaves LIBRARIES_SYS LIBRARIES_VEC LIBRARIES_MAT LIBRARIES_DM LIBRARIES_KSP LIBRARIES_SNES LIBRARIES_TS + INCLUDE_DIR INCLUDE_CONF) +include (FindPackageMultipass) +find_package_multipass (PETSc petsc_config_current + STATES DIR ARCH + DEPENDENTS INCLUDES LIBRARIES COMPILER MPIEXEC ${petsc_slaves}) + +# Determine whether the PETSc layout is old-style (through 2.3.3) or +# new-style (>= 3.0.0) +if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/conf/rules") + set (petsc_conf_variables "${PETSC_DIR}/conf/variables") +elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules") + set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables") +elseif (PETSC_DIR) + message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation") +else () + message (FATAL_ERROR "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.") +endif () +petsc_get_version() + +if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current) + # Put variables into environment since they are needed to get + # configuration (petscvariables) in the PETSc makefile + set (ENV{PETSC_DIR} "${PETSC_DIR}") + set (ENV{PETSC_ARCH} "${PETSC_ARCH}") + + # A temporary makefile to probe the PETSc configuration + set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc") + file (WRITE "${petsc_config_makefile}" +"## This file was autogenerated by FindPETSc.cmake +# PETSC_DIR = ${PETSC_DIR} +# PETSC_ARCH = ${PETSC_ARCH} +include ${petsc_conf_rules} +include ${petsc_conf_variables} +show : + -@echo -n \${\${VARIABLE}} +") + + macro (PETSC_GET_VARIABLE name var) + set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + execute_process (COMMAND ${CMAKE_MAKE_PROGRAM} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name} + OUTPUT_VARIABLE ${var} + RESULT_VARIABLE petsc_return) + endmacro (PETSC_GET_VARIABLE) + petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir) + petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external) + petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line) + petsc_get_variable (PETSC_INCLUDE petsc_include) + petsc_get_variable (PCC petsc_cc) + petsc_get_variable (MPIEXEC petsc_mpiexec) + # We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid! + file (REMOVE ${petsc_config_makefile}) + + include (ResolveCompilerPaths) + # Extract include paths and libraries from compile command line + resolve_includes (petsc_includes_all "${petsc_cpp_line}") + + message (STATUS "petsc_lib_dir ${petsc_lib_dir}") + + macro (PETSC_FIND_LIBRARY suffix name) + set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again + find_library (PETSC_LIBRARY_${suffix} NAMES ${name} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH) + set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}") + mark_as_advanced (PETSC_LIBRARY_${suffix}) + endmacro (PETSC_FIND_LIBRARY suffix name) + + # Look for petscvec first, if it doesn't exist, we must be using single-library + petsc_find_library (VEC petscvec) + if (PETSC_LIBRARY_VEC) + petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced) + petsc_find_library (MAT petscmat) + petsc_find_library (DM petscdm) + petsc_find_library (KSP petscksp) + petsc_find_library (SNES petscsnes) + petsc_find_library (TS petscts) + macro (PETSC_JOIN libs deps) + list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}}) + endmacro (PETSC_JOIN libs deps) + petsc_join (VEC SYS) + petsc_join (MAT VEC) + petsc_join (DM MAT) + petsc_join (KSP DM) + petsc_join (SNES KSP) + petsc_join (TS SNES) + petsc_join (ALL TS) + else () + set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec + petsc_find_library (SINGLE petsc) + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}") + endforeach () + endif () + if (PETSC_LIBRARY_TS) + message (STATUS "Recognized PETSc install with separate libraries for each package") + else () + message (STATUS "Recognized PETSc install with single library for all packages") + endif () + + include (CheckCSourceRuns) + macro (PETSC_TEST_RUNS includes libraries runs) + multipass_c_source_runs ("${includes}" "${libraries}" " +static const char help[] = \"PETSc test program.\"; +#include \"petscts.h\" +int main(int argc,char *argv[]) { + PetscErrorCode ierr; + TS ts; + + ierr = PetscInitialize(&argc,&argv,0,help);CHKERRQ(ierr); + ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr); + ierr = TSSetFromOptions(ts);CHKERRQ(ierr); + ierr = TSDestroy(ts);CHKERRQ(ierr); + ierr = PetscFinalize();CHKERRQ(ierr); + return 0; +} +" ${runs}) + if (${${runs}}) + set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL + "Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE) + endif (${${runs}}) + endmacro (PETSC_TEST_RUNS) + + find_path (PETSC_INCLUDE_DIR petscts.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH) + find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH) + mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF) + set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR}) + + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal) + if (petsc_works_minimal) + message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.") + set (petsc_includes_needed "${petsc_includes_minimal}") + else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes) + if (petsc_works_allincludes) # It does, we just need all the includes ( + message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).") + set (petsc_includes_needed ${petsc_includes_all}) + else (petsc_works_allincludes) # We are going to need to link the external libs explicitly + resolve_libraries (petsc_libraries_external "${petsc_libs_external}") + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external}) + endforeach (pkg) + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries) + if (petsc_works_alllibraries) + message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.") + set (petsc_includes_needed ${petsc_includes_minimal}) + else (petsc_works_alllibraries) + # It looks like we really need everything, should have listened to Matt + set (petsc_includes_needed ${petsc_includes_all}) + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all) + if (petsc_works_all) # We fail anyways + message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.") + else (petsc_works_all) # We fail anyways + message (STATUS "PETSc could not be used, maybe the install is broken.") + endif (petsc_works_all) + endif (petsc_works_alllibraries) + endif (petsc_works_allincludes) + endif (petsc_works_minimal) + + # We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous + if (${PETSC_VERSION} VERSION_LESS 3.1) + set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE) + else () + set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE) + endif () + # Sometimes this can be used to assist FindMPI.cmake + set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE) + set (PETSC_INCLUDES ${petsc_includes_needed} CACHE STRING "PETSc include path" FORCE) + set (PETSC_LIBRARIES ${PETSC_LIBRARIES_ALL} CACHE STRING "PETSc libraries" FORCE) + set (PETSC_COMPILER ${petsc_cc} CACHE FILEPATH "PETSc compiler" FORCE) + # Note that we have forced values for all these choices. If you + # change these, you are telling the system to trust you that they + # work. It is likely that you will end up with a broken build. + mark_as_advanced (PETSC_INCLUDES PETSC_LIBRARIES PETSC_COMPILER PETSC_DEFINITIONS PETSC_MPIEXEC PETSC_EXECUTABLE_RUNS) +endif () + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (PETSc + "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH." + PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS) diff --git a/AMDiS/cmake3/muparser.cmake b/AMDiS/cmake3/muparser.cmake new file mode 100644 index 00000000..b6751cb6 --- /dev/null +++ b/AMDiS/cmake3/muparser.cmake @@ -0,0 +1,32 @@ +# specify the target and requirements for the muparser library + +set(MUPARSER_SOURCE_DIR ${BASE_DIR}/lib/muparser_v134/src) +set(MUPARSER_INCLUDE_DIR ${BASE_DIR}/lib/muparser_v134/include) +add_library(muparser + ${MUPARSER_SOURCE_DIR}/muParser.cpp + ${MUPARSER_SOURCE_DIR}/muParserBase.cpp + ${MUPARSER_SOURCE_DIR}/muParserBytecode.cpp + ${MUPARSER_SOURCE_DIR}/muParserCallback.cpp + ${MUPARSER_SOURCE_DIR}/muParserComplex.cpp + ${MUPARSER_SOURCE_DIR}/muParserDLL.cpp + ${MUPARSER_SOURCE_DIR}/muParserError.cpp + ${MUPARSER_SOURCE_DIR}/muParserInt.cpp + ${MUPARSER_SOURCE_DIR}/muParserTest.cpp + ${MUPARSER_SOURCE_DIR}/muParserTokenReader.cpp) + +target_include_directories(muparser PUBLIC ${MUPARSER_INCLUDE_DIR}) + +if (ENABLE_CXX11) + set_property(TARGET muparser PROPERTY CXX_STANDARD 11) + set_property(TARGET muparser PROPERTY CXX_STANDARD_REQUIRED ON) + target_compile_definitions(muparser PRIVATE HAS_CXX11=1) +endif (ENABLE_CXX11) + +# specify how to install this target: +# ----------------------------------- + +file(GLOB MUPARSER_HEADERS "${MUPARSER_SOURCE_DIR}/include/*.h") +install(FILES ${MUPARSER_HEADERS} + DESTINATION include/amdis/muparser) +install(TARGETS muparser + DESTINATION lib/amdis/ ) \ No newline at end of file diff --git a/AMDiS/src/Config.h b/AMDiS/src/Config.h index 5e52b3bc..1e52cdd5 100644 --- a/AMDiS/src/Config.h +++ b/AMDiS/src/Config.h @@ -29,6 +29,15 @@ #define AMDIS_VERSION "AMDiS: Version 0.9.1" #endif +#ifdef DEBUG +#undef DEBUG +#endif +#ifdef NDEBUG +#define DEBUG 0 +#else +#define DEBUG 1 +#endif + #include #define CACHE_LINE 16 diff --git a/AMDiS/src/Initfile.cc b/AMDiS/src/Initfile.cc index 3ae5752b..e91fe37a 100644 --- a/AMDiS/src/Initfile.cc +++ b/AMDiS/src/Initfile.cc @@ -25,6 +25,9 @@ #include #include +// a parser for arithmetic expressions +#include "muParser.h" + using namespace std; namespace AMDiS { @@ -50,7 +53,19 @@ namespace AMDiS { string name; string value; }; + + namespace detail + { + double mu_parser_eval(std::string const& valStr) + { + mu::Parser parser; + parser.DefineConst(_T("M_PI"), m_pi); + parser.DefineConst(_T("M_E"), m_e); + parser.SetExpr(valStr); + return parser.Eval(); + } + } Initfile* Initfile::singlett = NULL; std::set Initfile::fn_include_list; diff --git a/AMDiS/src/Initfile.h b/AMDiS/src/Initfile.h index 57e406f6..723b5777 100644 --- a/AMDiS/src/Initfile.h +++ b/AMDiS/src/Initfile.h @@ -40,9 +40,6 @@ #include -// a parser for arithmetic expressions -#include "muParser.h" - namespace AMDiS { namespace detail { @@ -127,6 +124,9 @@ namespace AMDiS { // throw NoDelim("cannot detect the delimiter in " + value); return 0; } + + + double mu_parser_eval(std::string const& valStr); /// convert string to string @@ -149,13 +149,7 @@ namespace AMDiS { using boost::lexical_cast; using boost::numeric_cast; - mu::Parser parser; - parser.DefineConst(_T("M_PI"), m_pi); - parser.DefineConst(_T("M_E"), m_e); - - // try { - parser.SetExpr(valStr); - value = numeric_cast< T >(parser.Eval()); + value = numeric_cast< T >(mu_parser_eval(valStr)); /* } catch (boost::bad_lexical_cast e) { */ /* throw WrongValueFormat< T >(valStr); */ /* } catch (boost::bad_numeric_cast e) { */ @@ -452,7 +446,7 @@ namespace AMDiS { } else throw std::runtime_error("unknown error_code (" + boost::lexical_cast(error_code) + ") returned for tag '" + tag + "'"); - } catch(mu::ParserError& e) { + } catch(...) { std::string parser_error = "Could not parse: " + tag; throw std::runtime_error(parser_error); } diff --git a/AMDiS/src/parallel/MeshDistributor.h b/AMDiS/src/parallel/MeshDistributor.h index 14deb45f..26ae9194 100644 --- a/AMDiS/src/parallel/MeshDistributor.h +++ b/AMDiS/src/parallel/MeshDistributor.h @@ -491,6 +491,65 @@ void synchMultiVector(DOFVector &vec, std::vector*> additionalVe synchVector(allDOFVectors); } + + /** \brief + * Synchronize \p vec using indicator vector \p additionalVecs, e.g. let + * additionalVecs[0] be 1 on all dofs the value should be taken from my rank + * and 0 elsewhere. + */ + // op(std::vector& out, std::vector const& in) + template + void synchMultiVector(DOFVector &vec, std::vector*> additionalVecs, Operator op) + { + // get FE space and check equal FE space + const FiniteElemSpace *fe = vec.getFeSpace(); + MultiLevelDofComm& dofComm = dofComms[fe->getMesh()]; + + typedef typename std::vector*>::iterator Iterator; + + int nLevels = levelData.getNumberOfLevels(); + for (int level = nLevels - 1; level >= 0; level--) + { + StdMpi < std::vector > > stdMpi(levelData.getMpiComm(level)); + + for (DofComm::Iterator it(dofComm[level].getRecvDofs(), fe); !it.end(); it.nextRank()) + { + std::vector > dofs; + dofs.reserve(it.getDofs().size()); + for (; !it.endDofIter(); it.nextDof()) + { + std::vector values; + values.reserve(additionalVecs.size() + 1); + values.push_back( vec[it.getDofIndex()] ); + for (Iterator vecIt = additionalVecs.begin(); vecIt != additionalVecs.end(); ++vecIt ) + values.push_back( (**vecIt)[it.getDofIndex()] ); + dofs.push_back( values ); + } + stdMpi.send(it.getRank(), dofs); + } + + for (DofComm::Iterator it(dofComm[level].getSendDofs(), fe); !it.end(); it.nextRank()) + stdMpi.recv(it.getRank()); + + stdMpi.startCommunication(); + + for (DofComm::Iterator it(dofComm[level].getSendDofs(), fe); + !it.end(); it.nextRank()) { + for (; !it.endDofIter(); it.nextDof()) { + std::vector values; + values.reserve(additionalVecs.size() + 1); + values.push_back( vec[it.getDofIndex()] ); + for (Iterator vecIt = additionalVecs.begin(); vecIt != additionalVecs.end(); ++vecIt ) + values.push_back( (**vecIt)[it.getDofIndex()] ); + + op(values, stdMpi.getRecvData(it.getRank())[it.getDofCounter()]); + } + } + } + + synchVector(vec); + } + /** \brief * This function must be used if the values of a DOFVector must be * synchronised over all ranks. That means, that each rank sends the diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 98c2184e..3c5aee98 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -4,11 +4,13 @@ cmake_minimum_required(VERSION 2.8) #find_package(AMDIS REQUIRED COMPONENTS umfpack ) find_package(AMDIS REQUIRED) -if(AMDIS_FOUND) - message(STATUS "AMDiS was found.") - include(${AMDIS_USE_FILE}) - SET(BASIS_LIBS ${AMDIS_LIBRARIES}) -endif(AMDIS_FOUND) +if (AMDIS_FOUND) + message(STATUS "AMDiS was found.") +# include(${AMDIS_USE_FILE}) + set(BASIS_LIBS AMDiS) + get_target_property(AMDIS_INCLUDE_DIRS AMDiS INTERFACE_INCLUDE_DIRECTORIES) + message("AMDiS-Include-Dirs: ${AMDIS_INCLUDE_DIRS}") +endif (AMDIS_FOUND) set(ball src/ball.cc) set(bunny src/bunny.cc) -- GitLab