make the tests compile using OPM's shiny new CMake based build system

This commit is contained in:
Andreas Lauser
2013-05-30 18:44:10 +02:00
parent 83f255651d
commit d6e18d6038
178 changed files with 11699 additions and 311 deletions

726
CMakeCache.txt Normal file
View File

@@ -0,0 +1,726 @@
# This is the CMakeCache file.
# For build in directory: /home/and/src/opm-material
# It was generated by CMake: /usr/bin/cmake
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUI's for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.
########################
# EXTERNAL cache entries
########################
//Path to a library.
BLAS_Accelerate_LIBRARY:FILEPATH=BLAS_Accelerate_LIBRARY-NOTFOUND
//Path to a library.
BLAS_acml_LIBRARY:FILEPATH=BLAS_acml_LIBRARY-NOTFOUND
//Path to a library.
BLAS_acml_mp_LIBRARY:FILEPATH=BLAS_acml_mp_LIBRARY-NOTFOUND
//Path to a library.
BLAS_blas_LIBRARY:FILEPATH=/usr/lib/libblas.so
//Path to a library.
BLAS_complib.sgimath_LIBRARY:FILEPATH=BLAS_complib.sgimath_LIBRARY-NOTFOUND
//Path to a library.
BLAS_cxml_LIBRARY:FILEPATH=BLAS_cxml_LIBRARY-NOTFOUND
//Path to a library.
BLAS_dxml_LIBRARY:FILEPATH=BLAS_dxml_LIBRARY-NOTFOUND
//Path to a library.
BLAS_essl_LIBRARY:FILEPATH=BLAS_essl_LIBRARY-NOTFOUND
//Path to a library.
BLAS_f77blas_LIBRARY:FILEPATH=BLAS_f77blas_LIBRARY-NOTFOUND
//Path to a library.
BLAS_goto2_LIBRARY:FILEPATH=BLAS_goto2_LIBRARY-NOTFOUND
//Path to a library.
BLAS_scsl_LIBRARY:FILEPATH=BLAS_scsl_LIBRARY-NOTFOUND
//Path to a library.
BLAS_sgemm_LIBRARY:FILEPATH=BLAS_sgemm_LIBRARY-NOTFOUND
//Path to a library.
BLAS_sunperf_LIBRARY:FILEPATH=BLAS_sunperf_LIBRARY-NOTFOUND
//Path to a library.
BLAS_vecLib_LIBRARY:FILEPATH=BLAS_vecLib_LIBRARY-NOTFOUND
//Build the testing tree.
BUILD_TESTING:BOOL=ON
//Path to a program.
BZRCOMMAND:FILEPATH=BZRCOMMAND-NOTFOUND
//Path to a program.
CMAKE_AR:FILEPATH=/usr/bin/ar
//No help, variable specified on the command line.
CMAKE_BINARY_DIR:UNINITIALIZED=/home/and/build/opm-material
//Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
// CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.
CMAKE_BUILD_TYPE:STRING=
//Enable/Disable color output during build.
CMAKE_COLOR_MAKEFILE:BOOL=ON
//CXX compiler.
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
//Flags used by the compiler during all build types.
CMAKE_CXX_FLAGS:STRING=
//Flags used by the compiler during debug builds.
CMAKE_CXX_FLAGS_DEBUG:STRING=-g
//Flags used by the compiler during release minsize builds.
CMAKE_CXX_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_CXX_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
//Flags used by the compiler during Release with Debug Info builds.
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
//C compiler.
CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
//Flags used by the compiler during all build types.
CMAKE_C_FLAGS:STRING=
//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=-g
//Flags used by the compiler during release minsize builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=-Os -DNDEBUG
//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_C_FLAGS_RELEASE:STRING=-O3 -DNDEBUG
//Flags used by the compiler during Release with Debug Info builds.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=-O2 -g -DNDEBUG
//Flags used by the linker.
CMAKE_EXE_LINKER_FLAGS:STRING=' '
//Flags used by the linker during debug builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Enable/Disable output of compile commands during generation.
CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=OFF
//Read-only arch.-indep. data root
CMAKE_INSTALL_DATAROOTDIR:STRING=share
//Documentation root
CMAKE_INSTALL_DOCDIR:STRING=share/doc/opm-material
//Object code libraries
CMAKE_INSTALL_LIBDIR:PATH=lib/x86_64-linux-gnu
//Architecture-independent library files
CMAKE_INSTALL_LIBDIR_NOARCH:PATH=lib
//Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=/usr/local
//Path to a program.
CMAKE_LINKER:FILEPATH=/usr/bin/ld
//Path to a program.
CMAKE_MAKE_PROGRAM:FILEPATH=/usr/bin/make
//Flags used by the linker during the creation of modules.
CMAKE_MODULE_LINKER_FLAGS:STRING=' '
//Flags used by the linker during debug builds.
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//Path to a program.
CMAKE_NM:FILEPATH=/usr/bin/nm
//Path to a program.
CMAKE_OBJCOPY:FILEPATH=/usr/bin/objcopy
//Path to a program.
CMAKE_OBJDUMP:FILEPATH=/usr/bin/objdump
//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=opm-material
//Path to a program.
CMAKE_RANLIB:FILEPATH=/usr/bin/ranlib
//Flags used by the linker during the creation of dll's.
CMAKE_SHARED_LINKER_FLAGS:STRING=' '
//Flags used by the linker during debug builds.
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=
//Flags used by the linker during release minsize builds.
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=
//Flags used by the linker during release builds.
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=
//Flags used by the linker during Release with Debug Info builds.
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=
//If set, runtime paths are not added when installing shared libraries,
// but are added when building.
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO
//If set, runtime paths are not added when using shared libraries.
CMAKE_SKIP_RPATH:BOOL=NO
//Path to a program.
CMAKE_STRIP:FILEPATH=/usr/bin/strip
//If true, cmake will use relative paths in makefiles and projects.
CMAKE_USE_RELATIVE_PATHS:BOOL=OFF
//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make. This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE
//Path to the coverage program that CTest uses for performing coverage
// inspection
COVERAGE_COMMAND:FILEPATH=/usr/bin/gcov
//Extra command line flags to pass to the coverage tool
COVERAGE_EXTRA_FLAGS:STRING=-l
//How many times to retry timed-out CTest submissions.
CTEST_SUBMIT_RETRY_COUNT:STRING=3
//How long to wait between timed-out CTest submissions.
CTEST_SUBMIT_RETRY_DELAY:STRING=5
//Path to a program.
CVSCOMMAND:FILEPATH=/usr/bin/cvs
//Options passed to the cvs update command.
CVS_UPDATE_OPTIONS:STRING=-d -A -P
//Maximum time allowed before CTest will kill the test.
DART_TESTING_TIMEOUT:STRING=1500
//GDB debug file directory
DEBUG_FILE_DIRECTORY:STRING=/usr/lib/debug
//Graphviz Dot tool for using Doxygen
DOXYGEN_DOT_EXECUTABLE:FILEPATH=/usr/bin/dot
DOXYGEN_DOT_PATH:FILEPATH=/usr/bin
//Doxygen documentation generation tool (http://www.doxygen.org)
DOXYGEN_EXECUTABLE:FILEPATH=/usr/bin/doxygen
//Path to a program.
GITCOMMAND:FILEPATH=/usr/bin/git
//git command line client
GIT_EXECUTABLE:FILEPATH=/usr/bin/git
//Path to a program.
HGCOMMAND:FILEPATH=HGCOMMAND-NOTFOUND
//Path to a library.
LAPACK_Accelerate_LIBRARY:FILEPATH=LAPACK_Accelerate_LIBRARY-NOTFOUND
//Path to a library.
LAPACK_goto2_LIBRARY:FILEPATH=LAPACK_goto2_LIBRARY-NOTFOUND
//Path to a library.
LAPACK_lapack_LIBRARY:FILEPATH=/usr/lib/liblapack.so
//Path to a library.
LAPACK_vecLib_LIBRARY:FILEPATH=LAPACK_vecLib_LIBRARY-NOTFOUND
//Command to build the project
MAKECOMMAND:STRING=/usr/bin/make -i
//Path to the memory checking command, used for memory error detection.
MEMORYCHECK_COMMAND:FILEPATH=/usr/bin/valgrind
//File that contains suppressions for the memory checker
MEMORYCHECK_SUPPRESSIONS_FILE:FILEPATH=
//Path to a program.
OBJCOPY:FILEPATH=/usr/bin/objcopy
//The directory containing a CMake configuration file for OPM_MATERIAL_DEPENDS_LIST.
OPM_MATERIAL_DEPENDS_LIST_DIR:PATH=OPM_MATERIAL_DEPENDS_LIST_DIR-NOTFOUND
//pkg-config executable
PKG_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/pkg-config
//Precompile common headers for speed.
PRECOMPILE_HEADERS:BOOL=OFF
//Path to scp command, used by CTest for submitting results to
// a Dart server
SCPCOMMAND:FILEPATH=/usr/bin/scp
//Name of the computer/site where compile is being run
SITE:STRING=singularius
//Path to the SLURM sbatch executable
SLURM_SBATCH_COMMAND:FILEPATH=SLURM_SBATCH_COMMAND-NOTFOUND
//Path to the SLURM srun executable
SLURM_SRUN_COMMAND:FILEPATH=SLURM_SRUN_COMMAND-NOTFOUND
//Path to a file.
SUPERLU_INCLUDE_DIR:PATH=SUPERLU_INCLUDE_DIR-NOTFOUND
//Path to a library.
SUPERLU_LIBRARY:FILEPATH=SUPERLU_LIBRARY-NOTFOUND
//Human readable string containing SuperLU version information.
SUPERLU_WITH_VERSION:STRING=SuperLU <= 4.2, post 2005
//Path to a program.
SVNCOMMAND:FILEPATH=/usr/bin/svn
//Put .debug files in GDB debug file directory
SYSTEM_DEBUG:BOOL=OFF
//Use native instruction set
WITH_NATIVE:BOOL=ON
//Path to a file.
dune-common_INCLUDE_DIR:PATH=/usr/include
//Path to a library.
dune-common_LIBRARY:FILEPATH=/usr/lib/x86_64-linux-gnu/libdunecommon.so
//Path to a file.
dune-istl_INCLUDE_DIR:PATH=/usr/include
//Location of libtool
libtool_MAIN:FILEPATH=/usr/share/libtool/config/ltmain.sh
//Value Computed by CMake
opm-material_BINARY_DIR:STATIC=/home/and/src/opm-material
//Value Computed by CMake
opm-material_SOURCE_DIR:STATIC=/home/and/src/opm-material
########################
# INTERNAL cache entries
########################
//ADVANCED property for variable: BLAS_Accelerate_LIBRARY
BLAS_Accelerate_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_acml_LIBRARY
BLAS_acml_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_acml_mp_LIBRARY
BLAS_acml_mp_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_blas_LIBRARY
BLAS_blas_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_blas_WORKS
BLAS_blas_WORKS-ADVANCED:INTERNAL=1
//Have function sgemm_
BLAS_blas_WORKS:INTERNAL=1
//ADVANCED property for variable: BLAS_complib.sgimath_LIBRARY
BLAS_complib.sgimath_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_cxml_LIBRARY
BLAS_cxml_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_dxml_LIBRARY
BLAS_dxml_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_essl_LIBRARY
BLAS_essl_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_f77blas_LIBRARY
BLAS_f77blas_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_goto2_LIBRARY
BLAS_goto2_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_scsl_LIBRARY
BLAS_scsl_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_sgemm_LIBRARY
BLAS_sgemm_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_sunperf_LIBRARY
BLAS_sunperf_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BLAS_vecLib_LIBRARY
BLAS_vecLib_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: BZRCOMMAND
BZRCOMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_AR
CMAKE_AR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_BUILD_TOOL
CMAKE_BUILD_TOOL-ADVANCED:INTERNAL=1
//What is the target build tool cmake is generating for.
CMAKE_BUILD_TOOL:INTERNAL=/usr/bin/make
//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=/home/and/src/opm-material
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=2
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=8
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=10
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=/usr/bin/cmake
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=/usr/bin/cpack
//ADVANCED property for variable: CMAKE_CTEST_COMMAND
CMAKE_CTEST_COMMAND-ADVANCED:INTERNAL=1
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=/usr/bin/ctest
//ADVANCED property for variable: CMAKE_CXX_COMPILER
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_COMPILER
CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Path to cache edit program executable.
CMAKE_EDIT_COMMAND:INTERNAL=/usr/bin/ccmake
//Executable file format
CMAKE_EXECUTABLE_FORMAT:INTERNAL=ELF
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXPORT_COMPILE_COMMANDS
CMAKE_EXPORT_COMPILE_COMMANDS-ADVANCED:INTERNAL=1
//Name of generator.
CMAKE_GENERATOR:INTERNAL=Unix Makefiles
//Have symbol pthread_create
CMAKE_HAVE_LIBC_CREATE:INTERNAL=
//Have library pthreads
CMAKE_HAVE_PTHREADS_CREATE:INTERNAL=
//Have library pthread
CMAKE_HAVE_PTHREAD_CREATE:INTERNAL=1
//Have include pthread.h
CMAKE_HAVE_PTHREAD_H:INTERNAL=1
//Start directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=/home/and/src/opm-material
//ADVANCED property for variable: CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_LIBDIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_INSTALL_LIBDIR_NOARCH
CMAKE_INSTALL_LIBDIR_NOARCH-ADVANCED:INTERNAL=1
//Install .so files without execute permission.
CMAKE_INSTALL_SO_NO_EXE:INTERNAL=1
//ADVANCED property for variable: CMAKE_LINKER
CMAKE_LINKER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_NM
CMAKE_NM-ADVANCED:INTERNAL=1
//number of local generators
CMAKE_NUMBER_OF_LOCAL_GENERATORS:INTERNAL=1
//ADVANCED property for variable: CMAKE_OBJCOPY
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_OBJDUMP
CMAKE_OBJDUMP-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RANLIB
CMAKE_RANLIB-ADVANCED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=/usr/share/cmake-2.8
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_RPATH
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STRIP
CMAKE_STRIP-ADVANCED:INTERNAL=1
//Suppress Warnings that are meant for the author of the CMakeLists.txt
// files.
CMAKE_SUPPRESS_DEVELOPER_WARNINGS:INTERNAL=FALSE
//uname command
CMAKE_UNAME:INTERNAL=/bin/uname
//ADVANCED property for variable: CMAKE_USE_RELATIVE_PATHS
CMAKE_USE_RELATIVE_PATHS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: COVERAGE_COMMAND
COVERAGE_COMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: COVERAGE_EXTRA_FLAGS
COVERAGE_EXTRA_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CTEST_SUBMIT_RETRY_COUNT
CTEST_SUBMIT_RETRY_COUNT-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CTEST_SUBMIT_RETRY_DELAY
CTEST_SUBMIT_RETRY_DELAY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CVSCOMMAND
CVSCOMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CVS_UPDATE_OPTIONS
CVS_UPDATE_OPTIONS-ADVANCED:INTERNAL=1
//Result of TRY_COMPILE
CXX_FLAG_CXX11:INTERNAL=TRUE
//ADVANCED property for variable: DART_TESTING_TIMEOUT
DART_TESTING_TIMEOUT-ADVANCED:INTERNAL=1
//ADVANCED property for variable: DEBUG_FILE_DIRECTORY
DEBUG_FILE_DIRECTORY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: DOXYGEN_DOT_EXECUTABLE
DOXYGEN_DOT_EXECUTABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: DOXYGEN_DOT_PATH
DOXYGEN_DOT_PATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: DOXYGEN_EXECUTABLE
DOXYGEN_EXECUTABLE-ADVANCED:INTERNAL=1
//Details about finding C99
FIND_PACKAGE_MESSAGE_DETAILS_C99:INTERNAL=[-std=c99][v()]
//Details about finding Doxygen
FIND_PACKAGE_MESSAGE_DETAILS_Doxygen:INTERNAL=[/usr/bin/doxygen][v1.8.3.1()]
//Details about finding Git
FIND_PACKAGE_MESSAGE_DETAILS_Git:INTERNAL=[/usr/bin/git][v1.8.1.2()]
//Details about finding PkgConfig
FIND_PACKAGE_MESSAGE_DETAILS_PkgConfig:INTERNAL=[/usr/bin/pkg-config][v0.26()]
//Details about finding Threads
FIND_PACKAGE_MESSAGE_DETAILS_Threads:INTERNAL=[TRUE][v()]
//Details about finding dune-common
FIND_PACKAGE_MESSAGE_DETAILS_dune-common:INTERNAL=[/usr/include][/usr/lib/x86_64-linux-gnu/libdunecommon.so][1][v()]
//Details about finding dune-istl
FIND_PACKAGE_MESSAGE_DETAILS_dune-istl:INTERNAL=[/usr/include][1][v()]
//ADVANCED property for variable: GITCOMMAND
GITCOMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: GIT_EXECUTABLE
GIT_EXECUTABLE-ADVANCED:INTERNAL=1
//Test HAS_ATTRIBUTE_DEPRECATED
HAS_ATTRIBUTE_DEPRECATED:INTERNAL=1
//Test HAS_ATTRIBUTE_DEPRECATED_MSG
HAS_ATTRIBUTE_DEPRECATED_MSG:INTERNAL=1
//Test HAS_ATTRIBUTE_UNUSED
HAS_ATTRIBUTE_UNUSED:INTERNAL=1
//Test HAVE_ARRAY
HAVE_ARRAY:INTERNAL=1
//Test HAVE_ATTRIBUTE_ALWAYS_INLINE
HAVE_ATTRIBUTE_ALWAYS_INLINE:INTERNAL=1
//Test HAVE_C99
HAVE_C99:INTERNAL=1
//Test HAVE_CONSTEXPR
HAVE_CONSTEXPR:INTERNAL=1
//Test HAVE_DUNE_COMMON
HAVE_DUNE_COMMON:INTERNAL=1
//Test HAVE_DUNE_ISTL
HAVE_DUNE_ISTL:INTERNAL=1
//Test HAVE_INTEGRAL_CONSTANT
HAVE_INTEGRAL_CONSTANT:INTERNAL=1
//Result of TRY_COMPILE
HAVE_LINK_OPTS:INTERNAL=TRUE
//Test HAVE_MEM_USAGE_T_EXPANSIONS
HAVE_MEM_USAGE_T_EXPANSIONS:INTERNAL=
//Result of TRY_COMPILE
HAVE_MTUNE:INTERNAL=TRUE
//Test HAVE_NULLPTR
HAVE_NULLPTR:INTERNAL=1
//Test HAVE_RVALUE_REFERENCES
HAVE_RVALUE_REFERENCES:INTERNAL=1
//Test HAVE_STATIC_ASSERT
HAVE_STATIC_ASSERT:INTERNAL=1
//Have include tr1/tuple
HAVE_TR1_TUPLE:INTERNAL=1
//Have include tr1/type_traits
HAVE_TR1_TYPE_TRAITS:INTERNAL=1
//Have include tuple
HAVE_TUPLE:INTERNAL=1
//Have include type_traits
HAVE_TYPE_TRAITS:INTERNAL=1
//Test HAVE_VARIADIC_CONSTRUCTOR_SFINAE
HAVE_VARIADIC_CONSTRUCTOR_SFINAE:INTERNAL=1
//Test HAVE_VARIADIC_TEMPLATES
HAVE_VARIADIC_TEMPLATES:INTERNAL=1
//ADVANCED property for variable: HGCOMMAND
HGCOMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: LAPACK_Accelerate_LIBRARY
LAPACK_Accelerate_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: LAPACK_goto2_LIBRARY
LAPACK_goto2_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: LAPACK_lapack_LIBRARY
LAPACK_lapack_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: LAPACK_lapack_WORKS
LAPACK_lapack_WORKS-ADVANCED:INTERNAL=1
//Have function cheev_
LAPACK_lapack_WORKS:INTERNAL=1
//ADVANCED property for variable: LAPACK_vecLib_LIBRARY
LAPACK_vecLib_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: MAKECOMMAND
MAKECOMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: MEMORYCHECK_COMMAND
MEMORYCHECK_COMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: MEMORYCHECK_SUPPRESSIONS_FILE
MEMORYCHECK_SUPPRESSIONS_FILE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: OBJCOPY
OBJCOPY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PKG_CONFIG_EXECUTABLE
PKG_CONFIG_EXECUTABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PRECOMPILE_HEADERS
PRECOMPILE_HEADERS-ADVANCED:INTERNAL=1
PkgConf_dune-common_CFLAGS:INTERNAL=
PkgConf_dune-common_CFLAGS_I:INTERNAL=
PkgConf_dune-common_CFLAGS_OTHER:INTERNAL=
PkgConf_dune-common_FOUND:INTERNAL=1
PkgConf_dune-common_INCLUDEDIR:INTERNAL=/usr/include
PkgConf_dune-common_INCLUDE_DIRS:INTERNAL=
PkgConf_dune-common_LDFLAGS:INTERNAL=-ldunecommon
PkgConf_dune-common_LDFLAGS_OTHER:INTERNAL=
PkgConf_dune-common_LIBDIR:INTERNAL=/usr/lib/x86_64-linux-gnu
PkgConf_dune-common_LIBRARIES:INTERNAL=dunecommon
PkgConf_dune-common_LIBRARY_DIRS:INTERNAL=
PkgConf_dune-common_LIBS:INTERNAL=
PkgConf_dune-common_LIBS_L:INTERNAL=
PkgConf_dune-common_LIBS_OTHER:INTERNAL=
PkgConf_dune-common_LIBS_PATHS:INTERNAL=
PkgConf_dune-common_PREFIX:INTERNAL=/usr
PkgConf_dune-common_STATIC_CFLAGS:INTERNAL=
PkgConf_dune-common_STATIC_CFLAGS_I:INTERNAL=
PkgConf_dune-common_STATIC_CFLAGS_OTHER:INTERNAL=
PkgConf_dune-common_STATIC_INCLUDE_DIRS:INTERNAL=
PkgConf_dune-common_STATIC_LDFLAGS:INTERNAL=-ldunecommon
PkgConf_dune-common_STATIC_LDFLAGS_OTHER:INTERNAL=
PkgConf_dune-common_STATIC_LIBDIR:INTERNAL=
PkgConf_dune-common_STATIC_LIBRARIES:INTERNAL=dunecommon
PkgConf_dune-common_STATIC_LIBRARY_DIRS:INTERNAL=
PkgConf_dune-common_STATIC_LIBS:INTERNAL=
PkgConf_dune-common_STATIC_LIBS_L:INTERNAL=
PkgConf_dune-common_STATIC_LIBS_OTHER:INTERNAL=
PkgConf_dune-common_STATIC_LIBS_PATHS:INTERNAL=
PkgConf_dune-common_VERSION:INTERNAL=2.2.0
PkgConf_dune-common_dune-common_INCLUDEDIR:INTERNAL=
PkgConf_dune-common_dune-common_LIBDIR:INTERNAL=
PkgConf_dune-common_dune-common_PREFIX:INTERNAL=
PkgConf_dune-common_dune-common_VERSION:INTERNAL=
PkgConf_dune-istl_CFLAGS:INTERNAL=
PkgConf_dune-istl_CFLAGS_I:INTERNAL=
PkgConf_dune-istl_CFLAGS_OTHER:INTERNAL=
PkgConf_dune-istl_FOUND:INTERNAL=1
PkgConf_dune-istl_INCLUDEDIR:INTERNAL=/usr/include
PkgConf_dune-istl_INCLUDE_DIRS:INTERNAL=
PkgConf_dune-istl_LDFLAGS:INTERNAL=-ldunecommon
PkgConf_dune-istl_LDFLAGS_OTHER:INTERNAL=
PkgConf_dune-istl_LIBDIR:INTERNAL=/usr/lib
PkgConf_dune-istl_LIBRARIES:INTERNAL=dunecommon
PkgConf_dune-istl_LIBRARY_DIRS:INTERNAL=
PkgConf_dune-istl_LIBS:INTERNAL=
PkgConf_dune-istl_LIBS_L:INTERNAL=
PkgConf_dune-istl_LIBS_OTHER:INTERNAL=
PkgConf_dune-istl_LIBS_PATHS:INTERNAL=
PkgConf_dune-istl_PREFIX:INTERNAL=/usr
PkgConf_dune-istl_STATIC_CFLAGS:INTERNAL=
PkgConf_dune-istl_STATIC_CFLAGS_I:INTERNAL=
PkgConf_dune-istl_STATIC_CFLAGS_OTHER:INTERNAL=
PkgConf_dune-istl_STATIC_INCLUDE_DIRS:INTERNAL=
PkgConf_dune-istl_STATIC_LDFLAGS:INTERNAL=-ldunecommon
PkgConf_dune-istl_STATIC_LDFLAGS_OTHER:INTERNAL=
PkgConf_dune-istl_STATIC_LIBDIR:INTERNAL=
PkgConf_dune-istl_STATIC_LIBRARIES:INTERNAL=dunecommon
PkgConf_dune-istl_STATIC_LIBRARY_DIRS:INTERNAL=
PkgConf_dune-istl_STATIC_LIBS:INTERNAL=
PkgConf_dune-istl_STATIC_LIBS_L:INTERNAL=
PkgConf_dune-istl_STATIC_LIBS_OTHER:INTERNAL=
PkgConf_dune-istl_STATIC_LIBS_PATHS:INTERNAL=
PkgConf_dune-istl_VERSION:INTERNAL=2.2.0
PkgConf_dune-istl_dune-istl_INCLUDEDIR:INTERNAL=
PkgConf_dune-istl_dune-istl_LIBDIR:INTERNAL=
PkgConf_dune-istl_dune-istl_PREFIX:INTERNAL=
PkgConf_dune-istl_dune-istl_VERSION:INTERNAL=
//ADVANCED property for variable: SCPCOMMAND
SCPCOMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: SITE
SITE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: SLURM_SBATCH_COMMAND
SLURM_SBATCH_COMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: SLURM_SRUN_COMMAND
SLURM_SRUN_COMMAND-ADVANCED:INTERNAL=1
//ADVANCED property for variable: SUPERLU_INCLUDE_DIR
SUPERLU_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: SUPERLU_LIBRARY
SUPERLU_LIBRARY-ADVANCED:INTERNAL=1
//Test SUPERLU_MIN_VERSION_4_3
SUPERLU_MIN_VERSION_4_3:INTERNAL=
//Test SUPERLU_POST_2005_VERSION
SUPERLU_POST_2005_VERSION:INTERNAL=
//ADVANCED property for variable: SVNCOMMAND
SVNCOMMAND-ADVANCED:INTERNAL=1
__pkg_config_checked_PkgConf_dune-common:INTERNAL=1
__pkg_config_checked_PkgConf_dune-istl:INTERNAL=1
//ADVANCED property for variable: dune-common_INCLUDE_DIR
dune-common_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: dune-common_LIBRARY
dune-common_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: dune-istl_INCLUDE_DIR
dune-istl_INCLUDE_DIR-ADVANCED:INTERNAL=1
//ADVANCED property for variable: libtool_MAIN
libtool_MAIN-ADVANCED:INTERNAL=1

182
CMakeLists.txt Normal file
View File

@@ -0,0 +1,182 @@
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# retrieve the meta info about the project from the dune.module file
set(project "opm-material")
string(TOUPPER "${project}" PROJECT)
string(REPLACE "-" "_" PROJECT "${PROJECT}")
set(${project}_MODULE_DIR "${CMAKE_SOURCE_DIR}/cmake/Modules")
set(PROJECT_BINARY_DIR "${CMAKE_BINARY_DIR}")
set(PROJECT_SOURCE_DIR "${CMAKE_SOURCE_DIR}")
list(APPEND CMAKE_MODULE_PATH ${${project}_MODULE_DIR})
include(OpmParseDuneModule)
OpmParseDuneModule("${project}" FILE_NAME "${CMAKE_SOURCE_DIR}/dune.module")
set (doxy_dir "doc/doxygen")
# defines that must be present in config.h for our headers
set (${project}_CONFIG_VAR
HAVE_NULLPTR
HAVE_ARRAY
HAVE_ATTRIBUTE_ALWAYS_INLINE
HAS_ATTRIBUTE_UNUSED
HAS_ATTRIBUTE_DEPRECATED
HAS_ATTRIBUTE_DEPRECATED_MSG
HAVE_CONSTEXPR
HAVE_INTEGRAL_CONSTANT
HAVE_STATIC_ASSERT
HAVE_VARIADIC_TEMPLATES
HAVE_VARIADIC_CONSTRUCTOR_SFINAE
HAVE_RVALUE_REFERENCES
HAVE_TUPLE
HAVE_TR1_TUPLE
)
# convert string with dependencies to a list. TODO: recursive and
# optional dependencies
string(REPLACE " " ";" ${PROJECT}_DEPENDS_LIST ${${PROJECT}_DEPENDS})
# dependencies
set (${project}_DEPS
# compile with C99 support if available
"C99"
# needs a C++0x/11 compiler
"CXX11Features REQUIRED"
# dependencies
${${PROJECT}_DEPENDS_LIST}
)
# C++ project
cmake_minimum_required (VERSION 2.8)
project(${${project}_NAME})
enable_language (C)
enable_language (CXX)
# print system information to better pinpoint issues from log alone
include (UseSystemInfo)
system_info ()
# very early try to print repo id (to pinpoint version if something goes wrong)
include (UseVCSInfo)
vcs_info ()
# print toolchain information to identify compilers with potential bugs
include (UseCompVer)
compiler_info ()
# include special
if (CMAKE_VERSION VERSION_LESS "2.8.7")
message (STATUS "Enabling backward compatibility modules for CMake ${CMAKE_VERSION}")
list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.7")
endif (CMAKE_VERSION VERSION_LESS "2.8.7")
# default settings: build static debug library
include (OpmDefaults)
opm_defaults (${project})
message (STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# use tricks to do faster builds
include (UseFastBuilds)
# precompiled headers
include (UsePrecompHeaders)
# optimize full if we're not doing a debug build
include (UseOptimization)
# turn on all warnings; this must be done before adding any
# dependencies, in case they alter the list of warnings
include (UseWarnings)
# macro to set standard variables (INCLUDE_DIRS, LIBRARIES etc.)
include (OpmFind)
find_and_append_package_list_to (${project} ${${project}_DEPS})
# put debug information into every executable
include (UseDebugSymbols)
# needed for Debian installation scheme
include (UseMultiArch)
# this module contains code to figure out which file is where
include (OpmFiles)
opm_auto_dirs ()
# put libraries in lib/
opm_out_dirs ()
# identify the compilation units in the library; sources in opm/,
# tests files in tests/
opm_sources (${project})
# create configuration header which describes available features
# necessary to compile this library. singular version is the names that
# is required by this project alone, plural version transitively
# includes the necessary defines by the dependencies
include (ConfigVars)
list (APPEND ${project}_CONFIG_VARS ${${project}_CONFIG_VAR})
# write configuration variables to this file. note that it is a temporary.
message (STATUS "Writing config file \"${PROJECT_BINARY_DIR}/config.h\"...")
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h.tmp")
configure_vars (
FILE CXX ${CONFIG_H}
WRITE ${${project}_CONFIG_VARS}
)
# overwrite the config.h that is used by the code only if we have some
# real changes. thus, we don't have to recompile if a reconfigure is run
# due to some files being added, for instance
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different ${CONFIG_H} ${PROJECT_BINARY_DIR}/config.h
)
# compile main library; pull in all required includes and libraries
include (OpmCompile)
opm_compile (${project})
# installation target: copy the library together with debug and
# configuration files to system directories
include (OpmInstall)
opm_install (${project})
message (STATUS "This build defaults to installing in ${CMAKE_INSTALL_PREFIX}")
# installation of CMake modules to help user programs locate the library
include (OpmProject)
opm_cmake_config (${project})
# routines to build satellites such as tests, tutorials and samples
include (OpmSatellites)
# example programs are found in the tutorials/ and examples/ directory
opm_compile_satellites (${project} examples "" "")
# infrastructure for testing
enable_testing ()
include (CTest)
# make datafiles necessary for tests available in output directory
opm_data (tests datafiles "${tests_DIR}")
opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
# use this target to run all tests
add_custom_target (check
COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS tests
COMMENT "Checking if tests work"
VERBATIM
)
# generate documentation from source code with Doxygen;
# setup install target for this documentation
include (OpmDoc)
opm_doc (${project} ${doxy_dir})
# provide compatibility with using this build in dunecontrol
include (DuneCompat)
include (LibtoolArchives)
configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE)
### clean in-source builds ###
include (OpmDistClean)
opm_dist_clean (${project})

57
CMakeLists_files.cmake Normal file
View File

@@ -0,0 +1,57 @@
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# This file sets up five lists:
# MAIN_SOURCE_FILES List of compilation units which will be included in
# the library. If it isn't on this list, it won't be
# part of the library. Please try to keep it sorted to
# maintain sanity.
#
# TEST_SOURCE_FILES List of programs that will be run as unit tests.
#
# TEST_DATA_FILES Files from the source three that should be made
# available in the corresponding location in the build
# tree in order to run tests there.
#
# EXAMPLE_SOURCE_FILES Other programs that will be compiled as part of the
# build, but which is not part of the library nor is
# run as tests.
#
# PUBLIC_HEADER_FILES List of public header files that should be
# distributed together with the library. The source
# files can of course include other files than these;
# you should only add to this list if the *user* of
# the library needs it.
# originally generated with the command:
# find opm -name '*.c*' -printf '\t%p\n' | sort
#list (APPEND MAIN_SOURCE_FILES)
# originally generated with the command:
# find tests -name '*.cc' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_SOURCE_FILES
tests/material/pengrobinson/test_pengrobinson.cc
tests/material/ncpflash/test_ncpflash.cc
tests/material/tabulation/test_tabulation.cc
tests/material/fluidsystems/test_fluidsystems.cc
tests/material/immiscibleflash/test_immiscibleflash.cc
)
# originally generated with the command:
# find tests -name '*.xml' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_DATA_FILES
)
# originally generated with the command:
# find tutorials examples -name '*.c*' -printf '\t%p\n' | sort
list (APPEND EXAMPLE_SOURCE_FILES
)
# programs listed here will not only be compiled, but also marked for
# installation
list (APPEND PROGRAM_SOURCE_FILES)
# for OPM-material we do not list all headers explicitly. instead we
# glob through the source tree...
file(GLOB_RECURSE TMP RELATIVE "${CMAKE_SOURCE_DIR}/opm" "*.hh")
list (APPEND PUBLIC_HEADER_FILES ${TMP})

View File

@@ -0,0 +1,61 @@
# - Add options without repeating them on the command line
#
# Synopsis:
#
# add_options (lang build opts)
#
# where:
#
# lang Name of the language whose compiler should receive the
# options, e.g. CXX. If a comma-separated list is received
# then the option is added for all those languages. Use the
# special value ALL_LANGUAGES for these languages: CXX, C
# and Fortran
#
# build Kind of build to which this options should apply,
# such as DEBUG and RELEASE. This can also be a comma-
# separated list. Use the special value ALL_BUILDS to apply
# to all builds.
#
# opts List of options to add. Each should be quoted.
#
# Example:
#
# add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall")
function (add_options langs builds)
# special handling of empty language specification
if ("${langs}" STREQUAL "ALL_LANGUAGES")
set (langs CXX C Fortran)
endif ("${langs}" STREQUAL "ALL_LANGUAGES")
foreach (lang IN LISTS langs)
# prepend underscore if necessary
foreach (build IN LISTS builds)
if (NOT ("${build}" STREQUAL "ALL_BUILDS"))
set (_bld "_${build}")
string (TOUPPER "${_bld}" _bld)
else (NOT ("${build}" STREQUAL "ALL_BUILDS"))
set (_bld "")
endif (NOT ("${build}" STREQUAL "ALL_BUILDS"))
foreach (_opt IN LISTS ARGN)
set (_var "CMAKE_${lang}_FLAGS${_bld}")
#message (STATUS "Adding \"${_opt}\" to \${${_var}}")
# remove it first
string (REPLACE "${_opt}" "" _without "${${_var}}")
string (STRIP "${_without}" _without)
# we need to strip this one as well, so they are comparable
string (STRIP "${${_var}}" _stripped)
# if it wasn't there, then add it at the end
if ("${_without}" STREQUAL "${_stripped}")
# don't add any extra spaces if no options yet are set
if (NOT ${_stripped} STREQUAL "")
set (${_var} "${_stripped} ${_opt}")
else (NOT ${_stripped} STREQUAL "")
set (${_var} "${_opt}")
endif (NOT ${_stripped} STREQUAL "")
set (${_var} "${${_var}}" PARENT_SCOPE)
endif ("${_without}" STREQUAL "${_stripped}")
endforeach (_opt)
endforeach (build)
endforeach (lang)
endfunction (add_options lang build)

View File

@@ -0,0 +1,109 @@
# - Create config.h based on a list of variables
#
# Synopsis:
# configure_vars (FILE syntax filename verb varlist)
# where
# syntax CXX or CMAKE, depending on target
# filename Full path (including name) of config.h
# verb WRITE or APPEND if truncating or not
# varlist List of variable names that has been defined
#
# In addition, this function will define HAVE_CONFIG_H for the
# following compilations, (only) if the filename is "config.h".
#
# Example:
# list (APPEND FOO_CONFIG_VARS
# "/* bar library */"
# "HAVE_BAR"
# "HAVE_BAR_VERSION_2"
# )
# configure_vars (
# FILE CXX ${PROJECT_BINARY_DIR}/config.h
# WRITE ${FOO_CONFIG_VARS}
# )
# Copyright (C) 2012 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
function (configure_vars obj syntax filename verb)
# this is just to make the syntax look like the build-in commands
if (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
message (FATAL_ERROR "Syntax error in argument list")
endif (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
message (FATAL_ERROR "Invalid target syntax \"${syntax}\"")
endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
# truncate the file if the verb was "WRITE"
if (verb STREQUAL "WRITE")
file (WRITE "${filename}" "")
endif (verb STREQUAL "WRITE")
# whenever we use this, we also signal to the header files that we
# have "config.h". add this before any other files (known till now)
# to avoid confusion from other configuration files.
get_filename_component (_config_path "${filename}" PATH)
get_filename_component (_config_file "${filename}" NAME)
if ("${_config_file}" MATCHES "config\\.h(\\..+)?")
add_definitions (-DHAVE_CONFIG_H=1)
include_directories (BEFORE "${_config_path}")
endif ("${_config_file}" MATCHES "config\\.h(\\..+)?")
# only write the current value of each variable once
set (_args ${ARGN})
if (_args)
list (REMOVE_DUPLICATES _args)
endif (_args)
# process each variable
set (_prev_verbatim TRUE)
foreach (_var IN LISTS _args)
# massage the name to remove source code formatting
string (REGEX REPLACE "^[\\n\\t\\ ]+" "" _var "${_var}")
string (REGEX REPLACE "[\\n\\t\\ ]+$" "" _var "${_var}")
# if the name of a variable has the syntax of a comments, write it
# verbatim to the file; this can be used to create headings
if ("${_var}" MATCHES "^/[/*]")
if (NOT _prev_verbatim)
file (APPEND "${filename}" "\n")
endif (NOT _prev_verbatim)
file (APPEND "${filename}" "${_var}\n")
set (_prev_verbatim TRUE)
else ("${_var}" MATCHES "^/[/*]")
# check for empty variable; variables that are explicitly set to false
# is not included in this clause
if ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
if ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "set (${_var})\n")
else ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "/* #undef ${_var} */\n")
endif ("${syntax}" STREQUAL "CMAKE")
else ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
# integer variables (specifically 0 and 1) are written as they are,
# whereas everything else (including version numbers, which could
# be interpreted as floats) are quoted as strings
if (${_var} MATCHES "[0-9]+")
set (_quoted "${${_var}}")
else (${_var} MATCHES "[0-9]+")
set (_quoted "\"${${_var}}\"")
endif (${_var} MATCHES "[0-9]+")
# write to file using the correct syntax
if ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "set (${_var} ${_quoted})\n")
else ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "#define ${_var} ${_quoted}\n")
endif ("${syntax}" STREQUAL "CMAKE")
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
set (_prev_verbatim FALSE)
endif ("${_var}" MATCHES "^/[/*]")
endforeach(_var)
endfunction (configure_vars obj syntax filename verb)

View File

@@ -0,0 +1,31 @@
# - Dunecontrol compatibility
#
# Enables this build to be a part of a dunecontrol chain. The
# DUNE_CHECK_MODULES macro greps the top-level Makefile for the
# presence of the abs_top_srcdir variable (!) and uses that as
# the include directory of a module. Also, the contents are not
# checked so if the variable is not present, it generates an
# invalid command line (-I without argument) which causes the
# autoconf probe to fail. This module patches our Makefile (!!)
# so the necessary string will be there; in itself this string
# has no use for us, it is solemnly to satisfy the M4 scripts.
if (CMAKE_GENERATOR MATCHES "Unix Makefiles")
# we need an up-to-date, patched Makefile. this is always checked when
# the makefile is run, thus the need for a marker file to keep a
# timestamp to see when it was last patched (by us)
# amazingly, nothing depends on the generated Makefile, so this can be
# run whenever in the build without trigging a compile of e.g. config.h
add_custom_target (dune-compat ALL
COMMAND ${CMAKE_COMMAND} -DCMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY} -P ${PROJECT_SOURCE_DIR}/cmake/Scripts/DuneCompat2.cmake
COMMENT "Patching Makefile to be DUNE compatible"
)
endif (CMAKE_GENERATOR MATCHES "Unix Makefiles")
# dunecontrol refuses to use a build tree as module directory unless
# there is a dune.module in it
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dune.module ${PROJECT_BINARY_DIR}/dune.module
)
endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)

View File

@@ -0,0 +1,44 @@
# - Remove duplicate library declarations
#
# Synopsis:
#
# remove_duplicate_libraries (module)
#
# where
# module Name of the module whose libraries should be pruned
# Copyright (C) 2013 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
# libraries should always be trimmed from the beginning, so that also
# missing functions in those later in the list will be resolved
macro (remove_duplicate_libraries module)
if (DEFINED ${module}_LIBRARIES)
list (REVERSE ${module}_LIBRARIES)
list (REMOVE_DUPLICATES ${module}_LIBRARIES)
list (REVERSE ${module}_LIBRARIES)
endif (DEFINED ${module}_LIBRARIES)
endmacro (remove_duplicate_libraries module)
# headers can be trimmed from the end, since adding a directory to
# the list is an idempotent action
macro (remove_duplicate_headers module)
if (DEFINED ${module}_INCLUDE_DIRS)
list (REMOVE_DUPLICATES ${module}_INCLUDE_DIRS)
endif (DEFINED ${module}_INCLUDE_DIRS)
endmacro (remove_duplicate_headers module)
# linker flags may not be specified at all
macro (remove_duplicate_flags module)
if (DEFINED ${module}_LINKER_FLAGS)
list (REMOVE_DUPLICATES ${module}_LINKER_FLAGS)
endif (DEFINED ${module}_LINKER_FLAGS)
endmacro (remove_duplicate_flags module)
# fix up both headers and libraries, in case two dependencies have
# included the same second-level library independently
macro (remove_dup_deps module)
remove_duplicate_headers (${module})
remove_duplicate_libraries (${module})
remove_duplicate_flags (${module})
endmacro (remove_dup_deps module)

View File

@@ -0,0 +1,44 @@
# - Find Notay's Algebraic Multigrid Solver
#
# Set the path to the source directory of AGMG in the cache variable
# AGMG_ROOT.
#
# Note the difference between AGMG_DIR and AGMG_ROOT. The former will
# cause find_package to switch to config mode and search for a file
# named agmg-config.cmake, thereby bypassing this module altogether,
# whereas the latter communicates the location of the library to this
# module.
#
# When found, add the contents of AGMG_SOURCES to your own list of
# sources to compile and link for the target.
#
# Use define_fc_func from UseFortranWrappers to write FC_FUNC to your
# own config.h, and declare the function dagmg using this macro.
find_file (AGMG_SOURCES
dagmg.f90
PATHS ${AGMG_ROOT}
PATH_SUFFIXES SRC
DOC "Yvan Notay's Algebraic Multigrid Solver, Double Precision version"
NO_DEFAULT_PATH
)
# make sure that we can compile Fortran code
if (AGMG_SOURCES)
enable_language (Fortran)
endif (AGMG_SOURCES)
# set value for config.h
if (AGMG_SOURCES)
set (HAVE_AGMG 1)
else (AGMG_SOURCES)
set (HAVE_AGMG 0)
endif (AGMG_SOURCES)
# handle REQUIRED and QUIET standard options
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (AGMG
DEFAULT_MSG
AGMG_SOURCES
CMAKE_Fortran_COMPILER_SUPPORTS_F90
)

View File

@@ -0,0 +1,25 @@
# - Module that checks for supported C99 features.
# macro to only add option once
include (AddOptions)
# try to use compiler flag -std=c99
set (C_STD99_FLAGS "-std=c99")
# incidently, the C++ test is so simple that it can be used to compile C as well
include (CheckCCompilerFlag)
check_c_compiler_flag (${C_STD99_FLAGS} HAVE_C99)
# add option if we are capable
if (HAVE_C99)
add_options (C ALL_BUILDS "${C_STD99_FLAGS}")
else (HAVE_C99)
set (C_STD99_FLAGS)
endif (HAVE_C99)
# handle quiet and required
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (C99
DEFAULT_MSG
C_STD99_FLAGS
)

View File

@@ -0,0 +1,282 @@
#
# Module that checks for supported C++11 (former C++0x) features.
#
# Sets the follwing variable:
#
# HAVE_NULLPTR True if nullptr is available
# HAVE_ARRAY True if header <array> and fill() are available
# HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported
# HAS_ATTRIBUTE_UNUSED True if attribute unused is supported
# HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported
# HAS_ATTRIBUTE_DEPRECATED_MSG True if attribute deprecated("msg") is supported
# HAVE_CONSTEXPR True if constexpr attribute is available
# HAVE_INTEGRAL_CONSTANT True if compiler supports integral_constant
# HAVE_STATIC_ASSERT True if static_assert is available
# HAVE_VARIADIC_TEMPLATES True if variadic templates are supprt
# HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported
# HAVE_RVALUE_REFERENCES True if rvalue references are supported
# HAVE_TUPLE True if std::tuple is available
# HAVE_TR1_TUPLE True if std::tr1::tuple is available
# test for C++11 flags
include(TestCXXAcceptsFlag)
include(CheckIncludeFileCXX)
# macro to only add option once
include(AddOptions)
# try to use compiler flag -std=c++11
CHECK_CXX_ACCEPTS_FLAG("-std=c++11" CXX_FLAG_CXX11)
if(CXX_FLAG_CXX11)
add_options (CXX ALL_BUILDS "-std=c++11")
set(CXX_STD0X_FLAGS "-std=c++11")
else()
# try to use compiler flag -std=c++0x for older compilers
CHECK_CXX_ACCEPTS_FLAG("-std=c++0x" CXX_FLAG_CXX0X)
if(CXX_FLAG_CXX0X)
add_options (CXX ALL_BUILDS "-std=c++0x")
set(CXX_STD0X_FLAGS "-std=c++0x")
endif(CXX_FLAG_CXX0X)
endif(CXX_FLAG_CXX11)
# perform tests
include(CheckCXXSourceCompiles)
# nullptr
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
char* ch = nullptr;
return 0;
}
" HAVE_NULLPTR
)
# constexpr
CHECK_CXX_SOURCE_COMPILES("
template <class T>
inline constexpr int foo(T bar) { return bar*2; }
int main(void)
{
constexpr int foobar = foo(100);
return 0;
}
" HAVE_CONSTEXPR
)
# array and fill
CHECK_CXX_SOURCE_COMPILES("
#include <array>
int main(void)
{
std::array<int,2> a;
a.fill(9);
return 0;
}
" HAVE_ARRAY
)
# Check whether if std::integral_constant< T, v > is supported and casts into T
CHECK_CXX_SOURCE_COMPILES("
#include <type_traits>
void f( int ){}
int main(void){
f( std::integral_constant< int, 42 >() );
}
" HAVE_INTEGRAL_CONSTANT
)
# Check whether if <tuple> is available
check_include_file_cxx("tuple" HAVE_TUPLE)
# Check whether if <tr1/tuple> is available
check_include_file_cxx("tr1/tuple" HAVE_TR1_TUPLE)
# __attribute__((always_inline))
CHECK_CXX_SOURCE_COMPILES("
void __attribute__((always_inline)) foo(void) {}
int main(void)
{
foo();
return 0;
};
" HAVE_ATTRIBUTE_ALWAYS_INLINE
)
# __attribute__((unused))
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
int __attribute__((unused)) foo;
return 0;
};
" HAS_ATTRIBUTE_UNUSED
)
# __attribute__((deprecated))
CHECK_CXX_SOURCE_COMPILES("
#define DEP __attribute__((deprecated))
class bar
{
bar() DEP;
};
class peng { } DEP;
template <class T>
class t_bar
{
t_bar() DEP;
};
template <class T>
class t_peng {
t_peng() {};
} DEP;
void foo() DEP;
void foo() {};
int main(void)
{
return 0;
};
" HAS_ATTRIBUTE_DEPRECATED
)
# __attribute__((deprecated("msg")))
CHECK_CXX_SOURCE_COMPILES("
#define DEP __attribute__((deprecated(\"message\")))
class bar {
bar() DEP;
};
class peng { } DEP;
template <class T>
class t_bar
{
t_bar() DEP;
};
template <class T>
class t_peng
{
t_peng() {};
} DEP;
void foo() DEP;
void foo() {};
int main(void)
{
return 0;
};
" HAS_ATTRIBUTE_DEPRECATED_MSG
)
# static assert
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
static_assert(true,\"MSG\");
return 0;
}
" HAVE_STATIC_ASSERT
)
# variadic template support
CHECK_CXX_SOURCE_COMPILES("
#include <cassert>
template<typename... T>
int addints(T... x);
int add_ints()
{
return 0;
}
template<typename T1, typename... T>
int add_ints(T1 t1, T... t)
{
return t1 + add_ints(t...);
}
int main(void)
{
assert( 5 == add_ints(9,3,-5,-2) );
return 0;
}
" HAVE_VARIADIC_TEMPLATES
)
# SFINAE on variadic template constructors within template classes
CHECK_CXX_SOURCE_COMPILES("
#include <functional>
template<typename... U>
struct A
{
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
>
A(T... t)
: i(1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
typename = void
>
A(T... t)
: i(-1)
{}
A()
: i(1)
{}
int i;
};
int main(void)
{
return (A<int>().i + A<int>(2).i + A<int>(\"foo\",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1);
}
" HAVE_VARIADIC_CONSTRUCTOR_SFINAE
)
# rvalue references
CHECK_CXX_SOURCE_COMPILES("
#include <cassert>
#include <utility>
int foo(int&& x) { return 1; }
int foo(const int& x) { return -1; }
template<typename T>
int forward(T&& x)
{
return foo(std::forward<T>(x));
}
int main(void)
{
int i = 0;
assert( forward(i) + forward(int(2)) == 0);
return 0;
}
" HAVE_RVALUE_REFERENCES
)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
# Search for some tr1 headers
foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits)
string(REPLACE "/" "_" _HEADER_VAR ${_HEADER})
string(TOUPPER ${_HEADER_VAR} _HEADER_VAR )
check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}")
endforeach(_HEADER tuple tr1/tuple tr1/type_traits)

201
cmake/Modules/FindERT.cmake Normal file
View File

@@ -0,0 +1,201 @@
# - Find the Ensemble-based Reservoir Tool (ERT)
#
# Set the cache variable ERT_ROOT to the install location of the ERT
# libraries and header files.
#
# If found, it sets these variables:
#
# ERT_INCLUDE_DIRS Header file directories
# ERT_LIBRARIES Archives and shared objects
# ERT_CONFIG_VARS Definitions that goes in config.h
# ERT_LINKER_FLAGS Options that must be passed to linker
#
# It will also add to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS if necessary to
# link with the ERT libraries.
# variables to pass on to other packages
if (FIND_QUIETLY)
set (ERT_QUIET "QUIET")
else (FIND_QUIETLY)
set (ERT_QUIET "")
endif (FIND_QUIETLY)
# ERT doesn't have any config-mode file, so we need to specify the root
# directory in its own variable
find_path (ERT_ECL_INCLUDE_DIR
NAMES "ert/ecl/ecl_util.h"
HINTS "${ERT_ROOT}"
PATHS "../ert"
PATH_SUFFIXES "devel/libecl/include/" "include"
DOC "Path to ERT Eclipse library header files"
)
find_path (ERT_UTIL_INCLUDE_DIR
NAMES "ert/util/stringlist.h"
HINTS "${ERT_ROOT}"
PATHS "../ert"
PATH_SUFFIXES "devel/libert_util/include/" "include"
DOC "Path to ERT Eclipse library header files"
)
find_path (ERT_GEN_INCLUDE_DIR
NAMES "ert/util/int_vector.h"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "libert_util/include/" "include"
DOC "Path to ERT generated library header files"
)
# need all of these libraries
find_library (ERT_LIBRARY_ECL
NAMES "ecl"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib64" "lib32" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse library archive/shared object files"
)
find_library (ERT_LIBRARY_GEOMETRY
NAMES "ert_geometry"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib64" "lib32" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Geometry library archive/shared object files"
)
find_library (ERT_LIBRARY_UTIL
NAMES "ert_util"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib64" "lib32" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Utilities library archive/shared object files"
)
# the "library" found here is actually a list of several files
list (APPEND ERT_INCLUDE_DIR
${ERT_ECL_INCLUDE_DIR}
${ERT_UTIL_INCLUDE_DIR}
${ERT_GEN_INCLUDE_DIR}
)
list (APPEND ERT_LIBRARY
${ERT_LIBRARY_ECL}
${ERT_LIBRARY_GEOMETRY}
${ERT_LIBRARY_UTIL}
)
list (APPEND ERT_LIBRARIES ${ERT_LIBRARY})
list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR})
# if we didn't find any files, then don't proceed through the entire dependency list
include (FindPackageHandleStandardArgs)
if (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
find_package_handle_standard_args (ERT
DEFAULT_MSG
ERT_INCLUDE_DIR ERT_LIBRARY
)
# write unsuccessful result to the cache, as the check_c_source_compiles
# would do if it failed
set (HAVE_ERT)
set (HAVE_ERT "${HAVE_ERT}" CACHE INTERNAL "Did an ERT sample program compile?")
return ()
endif (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
# these system variables are probed for, and used in HEADER files (sic)
list (APPEND ERT_CONFIG_VARS
HAVE_ISFINITE
HAVE_GLOB
HAVE_FORK
HAVE_GETUID
HAVE_LOCKF
HAVE_OPENDIR
HAVE_PROC
HAVE_READLINKAT
HAVE_SYMLINK
HAVE_VA_COPY
)
include (CheckSymbolExists)
include (CheckFunctionExists)
check_symbol_exists (isfinite math.h HAVE_ISFINITE)
check_function_exists (glob HAVE_GLOB)
check_function_exists (fork HAVE_FORK)
check_function_exists (getuid HAVE_GETUID)
check_function_exists (lockf HAVE_LOCKF)
check_function_exists (opendir HAVE_OPENDIR)
check_function_exists (readlinkat HAVE_READLINKAT)
check_function_exists (symlink HAVE_SYMLINK)
check_symbol_exists (va_copy stdarg.h HAVE_VA_COPY)
if (UNIX)
set (HAVE_PROC 1)
else (UNIX)
set (HAVE_PROC)
endif (UNIX)
# dependencies
# parallel programming
include (UseOpenMP)
find_openmp (ERT)
# compression library
find_package (ZLIB ${ERT_QUIET})
if (ZLIB_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
list (APPEND ERT_LIBRARIES ${ZLIB_LIBRARIES})
endif (ZLIB_FOUND)
# numerics
find_package (BLAS ${ERT_QUIET})
if (BLAS_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS})
list (APPEND ERT_LIBRARIES ${BLAS_LIBRARIES})
list (APPEND ERT_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
endif (BLAS_FOUND)
find_package (LAPACK ${ERT_QUIET})
if (LAPACK_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS})
list (APPEND ERT_LIBRARIES ${LAPACK_LIBRARIES})
list (APPEND ERT_LINKER_FLAGS ${LAPACK_LINKER_FLAGS})
endif (LAPACK_FOUND)
# math library (should exist on all unices; automatically linked on Windows)
if (UNIX)
find_library (MATH_LIBRARY
NAMES "m"
)
list (APPEND ERT_LIBRARIES ${MATH_LIBRARY})
endif (UNIX)
# since OpenMP often implies pthreads, we need to tidy up
# (last instance of library must be left standing, thus reversing that
# list before removing duplicates)
include (Duplicates)
remove_dup_deps (ERT)
# see if we can compile a minimum example
# CMake logical test doesn't handle lists (sic)
if (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${ERT_INCLUDE_DIR})
set (CMAKE_REQUIRED_LIBRARIES ${ERT_LIBRARIES})
check_c_source_compiles (
"#include <ert/ecl/ecl_util.h>
int main (void) {
int sz;
sz = ecl_util_get_sizeof_ctype (ECL_INT_TYPE);
return 0;
}" HAVE_ERT)
cmake_pop_check_state ()
else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
# write unsuccessful result to the cache, as the check_c_source_compiles
# would do if it failed
set (HAVE_ERT)
set (HAVE_ERT "${HAVE_ERT}" CACHE INTERNAL "Did an ERT sample program compile?")
endif (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
# if the test program didn't compile, but was required to do so, bail
# out now and display an error; otherwise limp on
find_package_handle_standard_args (ERT
DEFAULT_MSG
ERT_INCLUDE_DIR ERT_LIBRARY HAVE_ERT
)

View File

@@ -0,0 +1,162 @@
#
# Module that checks whether SuperLU is available and usable.
# SuperLU must be a version released after the year 2005.
#
# Variables used by this module which you may want to set:
# SUPERLU_ROOT Path list to search for SuperLU
#
# Sets the follwing variable:
#
# SUPERLU_FOUND True if SuperLU available and usable.
# SUPERLU_MIN_VERSION_4_3 True if SuperLU version >= 4.3.
# SUPERLU_POST_2005_VERSION True if SuperLU is from post-2005
# SUPERLU_WITH_VERSION Human readable string containing version information.
# SUPERLU_INCLUDE_DIRS Path to the SuperLU include dirs.
# SUPERLU_LIBRARIES Name to the SuperLU library.
#
# adds SuperLU flags to the targets
function(add_dune_superlu_flags _targets)
if(SUPERLU_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} ${SUPERLU_DUNE_LIBRARIES})
get_target_property(_props ${_target} COMPILE_FLAGS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS
"${_props} ${SUPERLU_DUNE_COMPILE_FLAGS} -DENABLE_SUPERLU=1")
endforeach(_target ${_targets})
endif(SUPERLU_FOUND)
endfunction(add_dune_superlu_flags)
# look for BLAS
find_package(BLAS QUIET REQUIRED)
if(NOT BLAS_FOUND)
message(WARNING "SuperLU requires BLAS which was not found, skipping the test.")
return()
endif(NOT BLAS_FOUND)
# look for header files, only at positions given by the user
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
NO_DEFAULT_PATH
)
# look for header files, including default paths
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
)
# look for library, only at positions given by the user
find_library(SUPERLU_LIBRARY
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
NO_DEFAULT_PATH
)
# look for library files, including default paths
find_library(SUPERLU_LIBRARY
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
PATH_SUFFIXES "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
)
# check version specific macros
include(CheckCSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
# we need if clauses here because variable is set variable-NOTFOUND
# if the searches above were not successful
# Without them CMake print errors like:
# "CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
# Please set them or make sure they are set and tested correctly in the CMake files:"
#
if(SUPERLU_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUPERLU_INCLUDE_DIR})
endif(SUPERLU_INCLUDE_DIR)
if(SUPERLU_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUPERLU_LIBRARY})
endif(SUPERLU_LIBRARY)
if(BLAS_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES})
endif(BLAS_LIBRARIES)
# check whether "mem_usage_t.expansions" was found in "slu_ddefs.h"
CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h>
int main(void)
{
mem_usage_t mem;
return mem.expansions;
}"
HAVE_MEM_USAGE_T_EXPANSIONS)
# check whether version is at least 4.3
CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h>
int main(void)
{
return SLU_DOUBLE;
}"
SUPERLU_MIN_VERSION_4_3)
# check whether version is at least post-2005
CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h>
int main(void)
{
GlobalLU_t g;
return 0;
}"
SUPERLU_POST_2005_VERSION)
cmake_pop_check_state()
if(SUPERLU_MIN_VERSION_4_3)
set(SUPERLU_WITH_VERSION "SuperLU >= 4.3" CACHE STRING
"Human readable string containing SuperLU version information.")
else()
set(SUPERLU_WITH_VERSION "SuperLU <= 4.2, post 2005" CACHE STRING
"Human readable string containing SuperLU version information.")
endif(SUPERLU_MIN_VERSION_4_3)
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"SuperLU"
DEFAULT_MSG
SUPERLU_INCLUDE_DIR
SUPERLU_LIBRARY
)
mark_as_advanced(SUPERLU_INCLUDE_DIR SUPERLU_LIBRARY)
# if both headers and library are found, store results
if(SUPERLU_FOUND)
set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR})
set(SUPERLU_LIBRARIES ${SUPERLU_LIBRARY} ${BLAS_LIBRARIES})
set(SUPERLU_DEFINITIONS "-DENABLE_SUPERLU=1")
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of ${SUPERLU_WITH_VERSION} succeded:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
set(SUPERLU_DUNE_COMPILE_FLAGS "-I${SUPERLU_INCLUDE_DIRS}"
CACHE STRING "Compile flags used by DUNE when compiling SuperLU programs")
set(SUPERLU_DUNE_LIBRARIES ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking SuperLU programs")
else(SUPERLU_FOUND)
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determing location of SuperLU failed:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
endif(SUPERLU_FOUND)
# set HAVE_SUPERLU for config.h
if(SUPERLU_FOUND)
set(HAVE_SUPERLU 1)
else(SUPERLU_FOUND)
set(HAVE_SUPERLU 0)
endif(SUPERLU_FOUND)

View File

@@ -0,0 +1,259 @@
# - Find Tim Davis' SuiteSparse collection of sparse matrix libraries
#
# Synopsis:
# find_package (SuiteSparse COMPONENTS <list-of-components>)
#
# Components are:
# amd Approximate Minimum Degree ordering
# camd Constrained Approximate Minimum Degree ordering
# colamd COLumn Approximate Minimum Degree ordering
# ccolamd Constrained COLumn Approximate Minimum Degree ordering
# cholmod Supernodal sparse Cholesky factorization and update
# umfpack Unsymmetric MultiFrontal sparse LU factorization
#
# The following variables will be set:
#
# SuiteSparse_FOUND True if all dependencies are satisfied
# SuiteSparse_Xxx_FOUND True if module Xxx is found
# HAVE_SUITESPARSE_Xxx_H Binary value indicating presence of header
# SuiteSparse_INCLUDE_DIRS Paths containing the SuiteSparse header files
# SuiteSparse_LIBRARIES Name of the libraries which must be linked
# SuiteSparse_DEFINITIONS Defines that must be passed to the compiler
# SuiteSparse_LINKER_FLAGS Options that must be passed when linking
#
# See <http://www.cise.ufl.edu/research/sparse/SuiteSparse>.
# Copyright (C) 2012 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
function (try_compile_umfpack varname)
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${UMFPACK_INCLUDE_DIRS})
set (CMAKE_REQUIRED_LIBRARIES ${UMFPACK_LIBRARY} ${ARGN} ${SuiteSparse_EXTRA_LIBS})
check_c_source_compiles (
"#include <umfpack.h>
int main (void) {
void *Symbolic, *Numeric;
double Info[UMFPACK_INFO], Control[UMFPACK_CONTROL];
umfpack_dl_defaults(Control);
umfpack_dl_symbolic(0, 0, 0, 0, 0,
&Symbolic, Control, Info);
umfpack_dl_numeric (0, 0, 0,
Symbolic, &Numeric, Control, Info);
umfpack_dl_free_symbolic(&Symbolic);
umfpack_dl_solve(UMFPACK_A, 0, 0, 0, 0, 0,
Numeric, Control, Info);
umfpack_dl_free_numeric(&Numeric);
umfpack_timer ();
return 0;
}" ${varname})
cmake_pop_check_state ()
set (${varname} "${${varname}}" PARENT_SCOPE)
endfunction (try_compile_umfpack varname)
# variables to pass on to other packages
if (FIND_QUIETLY)
set (SuiteSparse_QUIET "QUIET")
else (FIND_QUIETLY)
set (SuiteSparse_QUIET "")
endif (FIND_QUIETLY)
# we need to link to BLAS and LAPACK
if (NOT BLAS_FOUND)
find_package (BLAS ${SuiteSparse_QUIET} REQUIRED)
endif (NOT BLAS_FOUND)
if (NOT LAPACK_FOUND)
find_package (LAPACK ${SuiteSparse_QUIET} REQUIRED)
endif (NOT LAPACK_FOUND)
set (SuiteSparse_EXTRA_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
# search paths for the library outside of standard system paths. these are the
# paths in which the package managers on various distros put the files
list (APPEND SuiteSparse_SEARCH_PATH "/usr") # Linux
list (APPEND SuiteSparse_SEARCH_PATH "/opt/local") # MacOS X
# pick up paths from the environment if specified there; these replace the
# pre-defined paths so that we don't accidentially pick up old stuff
if (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_DIR}")
endif (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
if (${SuiteSparse_DIR})
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_DIR}")
endif (${SuiteSparse_DIR})
# CMake uses _DIR suffix as default for config-mode files; it is unlikely
# that we are building SuiteSparse ourselves; use _ROOT suffix to specify
# location to pre-canned binaries
if (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_ROOT}")
endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
if (${SuiteSparse_ROOT})
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}")
endif (${SuiteSparse_ROOT})
# transitive closure of dependencies; after this SuiteSparse_MODULES is the
# full list of modules that must be found to satisfy the user's link demands
set (SuiteSparse_MODULES ${SuiteSparse_FIND_COMPONENTS})
list (FIND SuiteSparse_MODULES "umfpack" UMFPACK_DESIRED)
if (NOT UMFPACK_DESIRED EQUAL -1)
list (APPEND SuiteSparse_MODULES amd cholmod)
endif (NOT UMFPACK_DESIRED EQUAL -1)
list (FIND SuiteSparse_MODULES "cholmod" CHOLMOD_DESIRED)
if (NOT CHOLMOD_DESIRED EQUAL -1)
list (APPEND SuiteSparse_MODULES amd camd colamd)
endif (NOT CHOLMOD_DESIRED EQUAL -1)
if (SuiteSparse_MODULES)
list (REMOVE_DUPLICATES SuiteSparse_MODULES)
endif (SuiteSparse_MODULES)
# if someone else already have found all the packages for us, then don't do anything
set (SuiteSparse_EVERYTHING_FOUND TRUE)
foreach (module IN LISTS SuiteSparse_MODULES)
string (TOUPPER ${module} MODULE)
if (NOT SuiteSparse_${MODULE}_FOUND)
set (SuiteSparse_EVERYTHING_FOUND FALSE)
break ()
endif (NOT SuiteSparse_${MODULE}_FOUND)
endforeach (module)
if (SuiteSparse_EVERYTHING_FOUND)
return ()
endif (SuiteSparse_EVERYTHING_FOUND)
# if SuiteSparse >= 4.0 we must also link with libsuitesparseconfig
# assume that this is the case if we find the library; otherwise just
# ignore it (older versions don't have a file named like this)
find_library (config_LIBRARY
NAMES suitesparseconfig
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES ".libs" "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
)
if (config_LIBRARY)
list (APPEND SuiteSparse_EXTRA_LIBS ${config_LIBRARY})
# POSIX.1-2001 REALTIME portion require us to link this library too for
# clock_gettime() which is used by suitesparseconfig
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
list (APPEND SuiteSparse_EXTRA_LIBS "-lrt")
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
endif (config_LIBRARY)
# search filesystem for each of the module individually
foreach (module IN LISTS SuiteSparse_MODULES)
string (TOUPPER ${module} MODULE)
# search for files which implements this module
find_path (${MODULE}_INCLUDE_DIR
NAMES ${module}.h
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES "include" "include/suitesparse" "include/ufsparse"
)
find_library (${MODULE}_LIBRARY
NAMES ${module}
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
)
# start out by including the module itself; other dependencies will be added later
set (${MODULE}_INCLUDE_DIRS ${${MODULE}_INCLUDE_DIR})
set (${MODULE}_LIBRARIES ${${MODULE}_LIBRARY})
endforeach (module)
# insert any inter-modular dependencies here
if (CHOLMOD_LIBRARY)
list (APPEND CHOLMOD_LIBRARIES ${AMD_LIBRARIES} ${COLAMD_LIBRARIES})
# optional libraries; don't insert any -NOT_FOUND paths
if (CAMD_LIBRARY)
list (APPEND CHOLMOD_LIBRARIES ${CAMD_LIBRARIES})
endif (CAMD_LIBRARY)
if (CCOLAMD_LIBRARY)
list (APPEND CHOLMOD_LIBRARIES ${CCOLAMD_LIBRARIES})
endif (CCOLAMD_LIBRARY)
list (REVERSE CHOLMOD_LIBRARIES)
# always remove the *first* library from the list
list (REMOVE_DUPLICATES CHOLMOD_LIBRARIES)
list (REVERSE CHOLMOD_LIBRARIES)
endif (CHOLMOD_LIBRARY)
if (UMFPACK_LIBRARY)
set (UMFPACK_EXTRA_LIBS)
# test if umfpack is usable with only amd and not cholmod
try_compile_umfpack (HAVE_UMFPACK_WITHOUT_CHOLMOD ${AMD_LIBRARIES})
if (HAVE_UMFPACK_WITHOUT_CHOLMOD)
list (APPEND UMFPACK_EXTRA_LIBS ${AMD_LIBRARIES})
else (HAVE_UMFPACK_WITHOUT_CHOLMOD)
try_compile_umfpack (HAVE_UMFPACK_WITH_CHOLMOD ${CHOLMOD_LIBRARIES})
if (HAVE_UMFPACK_WITH_CHOLMOD)
list (APPEND UMFPACK_EXTRA_LIBS ${CHOLMOD_LIBRARIES})
else (HAVE_UMFPACK_WITH_CHOLMOD)
set (UMFPACK_EXTRA_LIBS "-NOTFOUND")
endif (HAVE_UMFPACK_WITH_CHOLMOD)
endif (HAVE_UMFPACK_WITHOUT_CHOLMOD)
# test if umfpack is underlinked (CentOS 5.9), i.e. doesn't specify
# that it depends on amd. in that case, force amd to be linked
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
try_compile_umfpack (HAVE_UMFPACK_NOT_UNDERLINKED "-Wl,--as-needed" ${UMFPACK_EXTRA_LIBS})
if (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
list (APPEND UMFPACK_LINKER_FLAGS "-Wl,--no-as-needed")
endif (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
list (APPEND UMFPACK_LIBRARIES ${UMFPACK_EXTRA_LIBS})
list (REVERSE UMFPACK_LIBRARIES)
list (REMOVE_DUPLICATES UMFPACK_LIBRARIES)
list (REVERSE UMFPACK_LIBRARIES)
endif (UMFPACK_LIBRARY)
# don't reset these sets; if two packages request SuiteSparse with
# different modules, we want the sets to be merged
#set (SuiteSparse_LIBRARIES "")
#set (SuiteSparse_INCLUDE_DIRS "")
# determine which modules were found based on whether all dependencies
# were satisfied; create a list of ALL modules (specified) that was found
# (to be included in one swoop in CMakeLists.txt)
set (SuiteSparse_FOUND TRUE)
foreach (module IN LISTS SuiteSparse_FIND_COMPONENTS)
string (TOUPPER ${module} MODULE)
set (SuiteSparse_${MODULE}_FOUND TRUE)
foreach (file IN LISTS ${MODULE}_INCLUDE_DIRS ${MODULE}_LIBRARIES)
if (NOT EXISTS ${file})
set (SuiteSparse_${MODULE}_FOUND FALSE)
endif (NOT EXISTS ${file})
endforeach (file)
if (NOT SuiteSparse_${MODULE}_FOUND)
set (SuiteSparse_FOUND FALSE)
set (HAVE_SUITESPARSE_${MODULE}_H 0 CACHE INT "Is ${module} header present?")
else (NOT SuiteSparse_${MODULE}_FOUND)
set (HAVE_SUITESPARSE_${MODULE}_H 1 CACHE INT "Is ${module} header present?")
list (APPEND SuiteSparse_LIBRARIES "${${MODULE}_LIBRARIES}")
list (APPEND SuiteSparse_LINKER_FLAGS "${${MODULE}_LINKER_FLAGS}")
list (APPEND SuiteSparse_INCLUDE_DIRS "${${MODULE}_INCLUDE_DIRS}")
endif (NOT SuiteSparse_${MODULE}_FOUND)
mark_as_advanced (HAVE_SUITESPARSE_${MODULE}_H)
mark_as_advanced (${MODULE}_INCLUDE_DIR)
mark_as_advanced (${MODULE}_LIBRARY)
endforeach (module)
if (SuiteSparse_INCLUDE_DIRS)
list (REMOVE_DUPLICATES SuiteSparse_INCLUDE_DIRS)
endif (SuiteSparse_INCLUDE_DIRS)
if (SuiteSparse_LIBRARIES)
list (REVERSE SuiteSparse_LIBRARIES)
list (REMOVE_DUPLICATES SuiteSparse_LIBRARIES)
list (REVERSE SuiteSparse_LIBRARIES)
endif (SuiteSparse_LIBRARIES)
# on MacOS X the libraries are in a framework directory and an option must be
# added on the compile line to relate headers to that directory
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list (APPEND SuiteSparse_DEFINITIONS "-framework Accelerate")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (SuiteSparse
DEFAULT_MSG
SuiteSparse_LIBRARIES
SuiteSparse_INCLUDE_DIRS
)
# add these after checking to not pollute the message output (checking for
# BLAS and LAPACK is REQUIRED so if they are not found, we'll have failed
# already; suitesparseconfig is "optional" anyway)
list (APPEND SuiteSparse_LIBRARIES ${SuiteSparse_EXTRA_LIBS})

View File

@@ -0,0 +1,37 @@
# - Find TinyXML library
#
# Defines the following variables:
# TinyXML_INCLUDE_DIRS Directory of header files
# TinyXML_LIBRARIES Directory of shared object files
# TinyXML_DEFINITIONS Defines that must be set to compile
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (OpmPackage)
find_opm_package (
# module name
"TinyXML"
# dependencies
""
# header to search for
"tinyxml.h"
# library to search for
"tinyxml"
# defines to be added to compilations
""
# test program
"#include <tinyxml.h>
int main (void) {
TiXmlDocument doc;
return 0;
}
"
# config variables
"")

View File

@@ -0,0 +1,57 @@
# - Find DUNE common library
#
# Defines the following variables:
# dune-common_INCLUDE_DIRS Directory of header files
# dune-common_LIBRARIES Directory of shared object files
# dune-common_DEFINITIONS Defines that must be set to compile
# dune-common_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_COMMON Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-common"
# dependencies
"CXX11Features REQUIRED;
BLAS REQUIRED;
LAPACK REQUIRED
"
# header to search for
"dune/common/fvector.hh"
# library to search for
"dunecommon"
# defines to be added to compilations
"DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD=1"
# test program
"#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
int main (void) {
Dune::FieldVector<double,1> v;
Dune::FieldMatrix<double,1,1> m;
m[0][0] = 1.0;
v[0] = 1.0;
Dune::FieldVector<double,1> w = m*v;
return 0;
}
"
# config variables
"HAVE_ARRAY;
HAVE_BOOST_MAKE_SHARED_HPP;
HAVE_BOOST_SHARED_PTR_HPP;
HAVE_GMP;
HAVE_MAKE_SHARED;
HAVE_MPI;
HAVE_NULLPTR;
HAVE_STATIC_ASSERT;
HAVE_TR1_TUPLE;
HAVE_TYPE_TRAITS;
HAVE_TUPLE
")
#debug_find_vars ("dune-common")

View File

@@ -0,0 +1,42 @@
# - Find OPM corner-point grid library
#
# Defines the following variables:
# dune-cornerpoint_INCLUDE_DIRS Directory of header files
# dune-cornerpoint_LIBRARIES Directory of shared object files
# dune-cornerpoint_DEFINITIONS Defines that must be set to compile
# dune-cornerpoint_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_CORNERPOINT Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-cornerpoint"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
opm-core REQUIRED
"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"dunecornerpoint"
# defines to be added to compilations
""
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"")
#debug_find_vars ("dune-cornerpoint")

View File

@@ -0,0 +1,47 @@
# - Find DUNE geometry library
#
# Defines the following variables:
# dune-geometry_INCLUDE_DIRS Directory of header files
# dune-geometry_LIBRARIES Directory of shared object files
# dune-geometry_DEFINITIONS Defines that must be set to compile
# dune-geometry_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_GEOMETRY Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-geometry"
# dependencies
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-common REQUIRED
"
# header to search for
"dune/geometry/quadraturerules.hh"
# library to search for
"dunegeometry"
# defines to be added to compilations
""
# test program
"#include <dune/geometry/quadraturerules.hh>
int main (void) {
Dune::GeometryType gt;
gt.makeQuadrilateral();
Dune::QuadratureRules<double, 2>::rule(gt, 2).size();
return 0;
}
"
# config variables
"HAVE_ALGLIB
")
#debug_find_vars ("dune-geometry")

View File

@@ -0,0 +1,58 @@
# - Find DUNE grid library
#
# Defines the following variables:
# dune-grid_INCLUDE_DIRS Directory of header files
# dune-grid_LIBRARIES Directory of shared object files
# dune-grid_DEFINITIONS Defines that must be set to compile
# dune-grid_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_GRID Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-grid"
# dependencies
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-common REQUIRED;
dune-geometry REQUIRED
"
# header to search for
"dune/grid/onedgrid.hh"
# library to search for
"dunegrid"
# defines to be added to compilations
""
# test program
"#include <dune/grid/onedgrid.hh>
#include <vector>
int main (void) {
std::vector<Dune::OneDGrid::ctype> coords;
Dune::OneDGrid grid(coords);
return grid.lbegin<0>(0) == grid.lend<0>(0);
return 0;
}
"
# config variables
"HAVE_MPI;
HAVE_UG;
HAVE_DUNE_FEM;
HAVE_ALUGRID;
HAVE_GRIDTYPE;
HAVE_GRAPE;
HAVE_PSURFACE;
HAVE_AMIRAMESH;
HAVE_ALBERTA;
HAVE_STDINT_H
")
#debug_find_vars ("dune-grid")

View File

@@ -0,0 +1,62 @@
# - Find DUNE ISTL library
#
# Defines the following variables:
# dune-istl_INCLUDE_DIRS Directory of header files
# dune-istl_LIBRARIES Directory of shared object files
# dune-istl_DEFINITIONS Defines that must be set to compile
# dune-istl_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_ISTL Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# dune-common is only required if dune-istl is; the "required-ness" is
# not transitive as far as CMake is concerned (i.e. if an optional package
# requests a package to be required, the build will fail if it's not found)
if (dune-istl_FIND_REQUIRED)
set (_require_dune_common "REQUIRED")
endif (dune-istl_FIND_REQUIRED)
include (OpmPackage)
find_opm_package (
# module name
"dune-istl"
# required dependencies
"dune-common ${_require_dune_common};
SUPERLU
"
# header to search for
"dune/istl/bcrsmatrix.hh"
# library to search for
""
# defines to be added to compilations
""
# test program
"#include <dune/common/deprecated.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/common/fmatrix.hh>
int main (void) {
typedef Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > Matrix;
Matrix matrix( 3, 3, Matrix::random );
for (int i = 0; i < 3; ++i) matrix.setrowsize(i, 2);
matrix.endrowsizes();
return 0;
}
"
# config variables
"HAVE_BOOST_FUSION;
HAVE_MEM_USAGE_T_EXPANSIONS;
HAVE_PARDISO;
HAVE_BOOST;
HAVE_MPI;
HAVE_PARMETIS;
HAVE_SUPERLU;
SUPERLU_MIN_VERSION_4_3;
SUPERLU_POST_2005_VERSION
")
#debug_find_vars ("dune-istl")

View File

@@ -0,0 +1,60 @@
# - Find OPM core library
#
# Defines the following variables:
# opm-core_INCLUDE_DIRS Directory of header files
# opm-core_LIBRARIES Directory of shared object files
# opm-core_DEFINITIONS Defines that must be set to compile
# opm-core_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_CORE Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (OpmPackage)
find_opm_package (
# module name
"opm-core"
# dependencies
"C99;
CXX11Features;
Boost 1.39.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED;
BLAS REQUIRED;
LAPACK REQUIRED;
SuiteSparse COMPONENTS umfpack;
SUPERLU;
TinyXML;
ERT;
dune-istl
"
# header to search for
"opm/core/grid.h"
# library to search for
"opmcore"
# defines to be added to compilations
""
# test program
"#include <opm/core/grid.h>
int main (void) {
struct UnstructuredGrid *g;
g = create_grid_empty ();
destroy_grid (g);
return 0;
}
"
# config variables
"HAVE_AGMG;
HAVE_DUNE_ISTL;
HAVE_DYNAMIC_BOOST_TEST;
HAVE_ERT;
HAVE_SUITESPARSE_UMFPACK_H;
HAVE_NULLPTR;
HAVE_STATIC_ASSERT
")
include (UseDynamicBoost)
#debug_find_vars ("opm-core")

View File

@@ -0,0 +1,41 @@
# - Find OPM polymer library
#
# Defines the following variables:
# opm-polymer_INCLUDE_DIRS Directory of header files
# opm-polymer_LIBRARIES Directory of shared object files
# opm-polymer_DEFINITIONS Defines that must be set to compile
# opm-polymer_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_POLYMER Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"opm-polymer"
# dependencies
"ERT;
opm-core REQUIRED
"
# header to search for
"opm/polymer/PolymerState.hpp"
# library to search for
"opmpolymer"
# defines to be added to compilations
""
# test program
"#include <opm/polymer/PolymerState.hpp>
int main (void) {
Opm::PolymerState s;
return 0;
}
"
# config variables
"HAVE_ERT")
#debug_find_vars ("opm-polymer")

View File

@@ -0,0 +1,43 @@
# - Find OPM porous media solver library
#
# Defines the following variables:
# opm-porsol_INCLUDE_DIRS Directory of header files
# opm-porsol_LIBRARIES Directory of shared object files
# opm-porsol_DEFINITIONS Defines that must be set to compile
# opm-porsol_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_PORSOL Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"opm-porsol"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
dune-istl REQUIRED;
opm-core REQUIRED;
dune-cornerpoint REQUIRED
"
# header to search for
"opm/porsol/mimetic/IncompFlowSolverHybrid.hpp"
# library to search for
"opmporsol"
# defines to be added to compilations
""
# test program
"#include <opm/porsol/mimetic/IncompFlowSolverHybrid.hpp>
int main (void) {
return 0;
}
"
# config variables
"HAVE_VALGRIND")
#debug_find_vars ("opm-porsol")

View File

@@ -0,0 +1,44 @@
# - Find OPM upscaling grid library
#
# Defines the following variables:
# opm-upscaling_INCLUDE_DIRS Directory of header files
# opm-upscaling_LIBRARIES Directory of shared object files
# opm-upscaling_DEFINITIONS Defines that must be set to compile
# opm-upscaling_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_UPSCALING Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"opm-upscaling"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
dune-istl REQUIRED;
opm-core REQUIRED;
dune-cornerpoint REQUIRED;
opm-porsol REQUIRED;
"
# header to search for
"opm/upscaling/SinglePhaseUpscaler.hpp"
# library to search for
"opmupscaling"
# defines to be added to compilations
""
# test program
"#include <opm/upscaling/SinglePhaseUpscaler.hpp>
int main (void) {
return 0;
}
"
# config variables
"HAVE_SUPERLU")
#debug_find_vars ("opm-upscaling")

View File

@@ -0,0 +1,150 @@
function (configure_la name target)
if (NOT (UNIX OR MSYS OR MINGW))
return ()
endif (NOT (UNIX OR MSYS OR MINGW))
# these generic variables are initialized from the project info
set (current "${${name}_VERSION_MAJOR}")
set (age "${${name}_VERSION_MINOR}")
set (inherited_linker_flags "${${name}_LINKER_FLAGS}")
set (dependency_libs "${${name}_LIBRARIES}")
# if we are going to put these in regexps, we must escape period
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")
string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}")
# CMake loves absolute paths, whereas libtool won't have any of it!
# (you get an error message about argument not parsed). translate each
# of the libraries into a linker option
set (deplib_list "")
foreach (deplib IN LISTS dependency_libs)
# starts with a hyphen already? then just add it
string (SUBSTRING ${deplib} 0 1 dash)
if (${dash} STREQUAL "-")
list (APPEND deplib_list ${deplib})
else (${dash} STREQUAL "-")
# otherwise, parse the name into a directory and a name
get_filename_component (deplib_dir ${deplib} PATH)
get_filename_component (deplib_orig ${deplib} NAME)
string (REGEX REPLACE
"^${esc_dl_pref}(.*)${esc_dl_suff}$"
"\\1"
deplib_name
${deplib_orig}
)
string (REGEX REPLACE
"^${esc_ar_pref}(.*)${esc_ar_suff}$"
"\\1"
deplib_name
${deplib_name}
)
# directory and name each on their own; this is somewhat
# unsatisfactory because it may be that a system dir is specified
# by an earlier directory and you start picking up libraries from
# there instead of the "closest" path here. also, the soversion
# is more or less lost. remove system default path, to lessen the
# chance that we pick the wrong library
if (NOT ((deplib_dir STREQUAL "/usr/lib") OR
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
list (APPEND deplib_list "-L${deplib_dir}")
endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
# if there was no translation of the name, the library is named
# unconventionally (.so.3gf, I'm looking at you), so pass this
# name unmodified to the linker switch
if (deplib_orig STREQUAL deplib_name)
list (APPEND deplib_list "-l:${deplib_orig}")
else (deplib_orig STREQUAL deplib_name)
list (APPEND deplib_list "-l${deplib_name}")
endif (deplib_orig STREQUAL deplib_name)
endif (${dash} STREQUAL "-")
endforeach (deplib)
set (dependency_libs ${deplib_list})
# convert from CMake list (i.e. semi-colon separated)
string (REPLACE ";" " " inherited_linker_flags "${inherited_linker_flags}")
string (REPLACE ";" " " dependency_libs "${dependency_libs}")
# this is the preferred installation path
set (libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# ${name}_LIBRARY_TYPE is either SHARED or STATIC
if (${name}_LIBRARY_TYPE STREQUAL "SHARED")
set (libprefix "${CMAKE_SHARED_LIBRARY_PREFIX}")
set (libsuffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set (libname "${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX}")
# only Unix has soversion in library names
if (UNIX)
set (dlname "${libname}.${current}")
set (library_names "${libname}.${current}.${age} ${libname}.${current} ${libname}")
else (UNIX)
set (dlname "${libname}")
set (library_names "${libname}")
endif (UNIX)
set (old_library "")
else (${name}_LIBRARY_TYPE STREQUAL "SHARED")
set (dlname "")
set (library_names "")
set (old_library "${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif (${name}_LIBRARY_TYPE STREQUAL "SHARED")
# get the version of libtool installed on the system; this is
# necessary because libtool checks that the file contains its own
# signature(!)
if (NOT libtool_MAIN)
find_file (
libtool_MAIN
ltmain.sh
PATHS /usr
PATH_SUFFIXES share/libtool/config/
DOC "Location of libtool"
)
mark_as_advanced (libtool_MAIN)
# notify the user if it not found after we explicitly searched
if (NOT libtool_MAIN)
message (STATUS "Libtool not found!")
endif (NOT libtool_MAIN)
endif (NOT libtool_MAIN)
if (libtool_MAIN)
file (STRINGS
${libtool_MAIN}
ltversion_STRING
REGEX "^VERSION=\".*\""
)
endif (libtool_MAIN)
if (ltversion_STRING)
string (REGEX REPLACE
"^VERSION=\"?(.*)\"?"
"\\1"
ltversion
${ltversion_STRING}
)
endif (ltversion_STRING)
# assume that we are in cmake/Modules, and that the template have been
# put in cmake/Templates. we cannot use CMAKE_CURRENT_LIST_DIR because
# this is in a function, and we cannot know who's calling us
set (templ_dir "${PROJECT_SOURCE_DIR}/cmake/Templates")
# only write an .la if libtool is found; otherwise we have no use
# for it.
if (ltversion)
set (la_file "lib${target}.la")
message (STATUS "Writing libtool archive for ${target}")
configure_file (
${templ_dir}/la.in
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${la_file}
@ONLY@
)
else (ltversion)
set (la_file "")
endif (ltversion)
# return this variable to the caller
if (ARGV2)
set (${ARGV2} "${la_file}" PARENT_SCOPE)
endif (ARGV2)
endfunction (configure_la target)

View File

@@ -0,0 +1,56 @@
# - Compile main library target
macro (opm_compile opm)
# some CMake properties do not do list expansion
string (REPLACE ";" " " ${opm}_LINKER_FLAGS_STR "${${opm}_LINKER_FLAGS}")
# all public header files are together with the source
set (${opm}_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
list (APPEND ${opm}_INCLUDE_DIRS "${${opm}_INCLUDE_DIR}")
# create this library
include_directories (${${opm}_INCLUDE_DIRS})
link_directories (${${opm}_LIBRARY_DIRS})
add_definitions (${${opm}_DEFINITIONS})
if(${opm}_SOURCES)
# name of the library should not contain dashes, as CMake will
# define a symbol with that name, and those cannot contain dashes
string (REPLACE "-" "" ${opm}_TARGET "${${opm}_NAME}")
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES})
set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}")
set_target_properties (${${opm}_TARGET} PROPERTIES
SOVERSION ${${opm}_VERSION_MAJOR}
VERSION ${${opm}_VERSION}
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
)
target_link_libraries (${${opm}_TARGET} ${${opm}_LIBRARIES})
endif()
# queue this executable to be stripped
strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG)
# pre-compile common headers; this is setup *after* the library to pick
# up extra options set there
if (PRECOMPILE_HEADERS)
get_target_property (_type ${${opm}_TARGET} TYPE)
precompile_header (CXX ${_type}
HEADER "${${opm}_PRECOMP_CXX_HEADER}"
TARGET ${opm}_CXX_pch
FLAGS ${opm}_PRECOMP_CXX_FLAGS
)
# must set property on source files instead of entire target, because
# it only applies to C++ modules (and cannot be used for C)
set_source_files_properties (${${opm}_CXX_SOURCES} PROPERTIES
OBJECT_DEPENDS "${${opm}_CXX_pch}"
COMPILE_FLAGS "${${opm}_PRECOMP_CXX_FLAGS}"
)
message (STATUS "Precompiled headers: ${${opm}_CXX_pch}")
endif (PRECOMPILE_HEADERS)
if (${opm}_TARGET)
# we need to know the name of the library which is generated
get_target_property (${opm}_LIBRARY ${${opm}_TARGET} LOCATION)
endif()
endmacro (opm_compile opm)

View File

@@ -0,0 +1,50 @@
# - Default settings for the build
include (UseCompVer)
macro (opm_defaults opm)
# build debug by default
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Debug")
endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
# default to building a static library, but let user override
if (DEFINED BUILD_SHARED_LIBS)
if (BUILD_SHARED_LIBS)
set (${opm}_LIBRARY_TYPE SHARED)
else (BUILD_SHARED_LIBS)
set (${opm}_LIBRARY_TYPE STATIC)
endif (BUILD_SHARED_LIBS)
else (DEFINED BUILD_SHARED_LIBS)
set (${opm}_LIBRARY_TYPE STATIC)
endif (DEFINED BUILD_SHARED_LIBS)
# precompile standard headers to speed up compilation
# unfortunately, this functionality is buggy and tends to segfault at
# least up to version 4.7.2, so it should be disabled by default there
get_gcc_version (CXX GCC_VERSION)
if (GCC_VERSION VERSION_LESS "4.7.2")
set (_precomp_def OFF)
else (GCC_VERSION VERSION_LESS "4.7.2")
set (_precomp_def ON)
endif (GCC_VERSION VERSION_LESS "4.7.2")
option (PRECOMPILE_HEADERS "Precompile common headers for speed." ${_precomp_def})
mark_as_advanced (PRECOMPILE_HEADERS)
if (NOT PRECOMPILE_HEADERS)
message (STATUS "Precompiled headers: disabled")
endif(NOT PRECOMPILE_HEADERS)
# Use of OpenMP is considered experimental
set (USE_OPENMP_DEFAULT OFF)
# if we are on a system where CMake 2.6 is the default (Hi RHEL 6!),
# the configuration files for Boost will trip up the library paths
# (look for /usr/lib64/lib64/ in the log) when used with FindBoost
# module bundled with CMake 2.8. this can be circumvented by turning
# off config mode probing if we have not explicitly specified a
# directory to look for it. for more details, see
# <http://stackoverflow.com/questions/9948375/cmake-find-package-succeeds-but-returns-wrong-path>
if (NOT BOOST_ROOT)
set (Boost_NO_BOOST_CMAKE ON)
endif (NOT BOOST_ROOT)
endmacro (opm_defaults opm)

View File

@@ -0,0 +1,63 @@
# - Cleanup configuration files
#
# Remove files generated by the configuration (not by the build); the
# purpose is to get back a clean directory with no build artifacts
# (some empty directories may be left behind, though)
#
# The following suffices are supported:
# _NAME Name of the project
# _STYLESHEET_COPIED Stylesheet that was copied for the documentation
# _LIBTOOL_ARCHIVE Libtool archive file generated for library
# _DEBUG Debug information extracted from library
macro (opm_dist_clean opm)
set (DISTCLEAN_FILES
CMakeCache.txt
cmake_install.cmake
Makefile
config.h
config.h.tmp
${${opm}_NAME}-config.cmake
${${opm}_NAME}-config-version.cmake
${${opm}_NAME}-install.cmake
${${opm}_NAME}.pc
${${opm}_NAME}-install.pc
${doxy_dir}/Doxyfile
${doxy_dir}/Doxyfile.in
CTestTestfile.cmake
DartConfiguration.tcl
lib/${${opm}_LIBTOOL_ARCHIVE}
${${opm}_DEBUG}
${tests_DEBUG}
${examples_DEBUG}
${tutorial_DEBUG}
install_manifest.txt
${${opm}_STYLESHEET_COPIED}
${tests_INPUT_FILES}
)
# only remove these files if they were actually copied
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
list (APPEND DISTCLEAN_FILES
dune.module
)
endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# script to remove empty directories (can't believe this isn't included!)
set (rmdir "${PROJECT_SOURCE_DIR}/cmake/Scripts/RemoveEmptyDir.cmake")
add_custom_target (distclean
COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES}
COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles/
COMMAND ${CMAKE_COMMAND} -E remove_directory Testing/
COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -P ${rmdir}
COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} -P ${rmdir}
COMMAND ${CMAKE_COMMAND} -DDIR:LOCATION=${doxy_dir} -P ${rmdir}
COMMAND ${CMAKE_COMMAND} -DDIR:LOCATION=${tests_DIR} -P ${rmdir}
# cannot depend on clean because it is only defined in the master Makefile
# not in CMakeFiles/Makefile where this target will end up
# DEPENDS clean
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT Removing CMake-generated files
VERBATIM
)
endmacro (opm_dist_clean opm)

View File

@@ -0,0 +1,81 @@
# - Setup documentation
#
# Assumes that a Doxyfile template is located in the project root
# directory, and that all documentation is going to be generated
# into its own Documentation/ directory. It will also generate an
# installation target for the documentation (not built by default)
#
# Requires the following variables to be set:
# ${opm}_NAME Name of the project
#
# Output the following variables:
# ${opm}_STYLESHEET_COPIED Location of stylesheet to be removed in distclean
macro (opm_doc opm doxy_dir)
# combine the template with local customization
file (READ ${PROJECT_SOURCE_DIR}/cmake/Templates/Doxyfile _doxy_templ)
string (REPLACE ";" "\\;" _doxy_templ "${_doxy_templ}")
if (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
file (READ ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal _doxy_local)
string (REPLACE ";" "\\;" _doxy_local "${_doxy_local}")
else (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
set (_doxy_local)
endif (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${doxy_dir})
file (WRITE ${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile.in ${_doxy_templ} ${_doxy_local})
# set this generically named variable so even the custom file can be shared
set (src_DIR "${${opm}_DIR}")
# replace variables in this combined file
configure_file (
${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile.in
${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile
@ONLY
)
find_package (Doxygen)
if (DOXYGEN_FOUND)
add_custom_target (doc
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile
SOURCES ${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${doxy_dir}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
# distributions have various naming conventions; this enables the packager
# to direct where the install target should put the documentation. the names
# here are taken from GNUInstallDirs.cmake
set (CMAKE_INSTALL_DATAROOTDIR "share" CACHE STRING "Read-only arch.-indep. data root")
set (CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${${opm}_NAME}" CACHE STRING "Documentation root")
set (_formats html)
foreach (format IN LISTS _formats)
string (TOUPPER ${format} FORMAT)
install (
DIRECTORY ${PROJECT_BINARY_DIR}/${doxy_dir}/${format}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT ${format}
OPTIONAL
)
# target to install just HTML documentation
add_custom_target (install-${format}
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${format} -P cmake_install.cmake
COMMENT Installing ${FORMAT} documentation
VERBATIM
)
# since the documentation is optional, it is not automatically built
add_dependencies (install-${format} doc)
endforeach (format)
endif (DOXYGEN_FOUND)
# stylesheets must be specified with relative path in Doxyfile, or the
# full path (to the source directory!) will be put in the output HTML.
# thus, we'll need to copy the stylesheet to this path relative to where
# Doxygen will be run (in the output tree)
if ((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css))
file (COPY ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css
DESTINATION ${PROJECT_BINARY_DIR}/${doxy_dir}
)
set (${opm}_STYLESHEET_COPIED "${doxy_dir}/style.css")
else ((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css))
set (${opm}_STYLESHEET_COPIED "")
endif ((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css))
endmacro (opm_doc opm)

View File

@@ -0,0 +1,87 @@
# - Identify source code
macro (opm_out_dirs)
# put libraries in lib/ (no multi-arch support in build tree)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set (CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles")
endmacro (opm_out_dirs)
# support for some of the variables that are used in Autotools
# template files
macro (opm_auto_dirs)
set (abs_top_builddir "${PROJECT_BINARY_DIR}")
set (abs_top_srcdir "${PROJECT_SOURCE_DIR}")
endmacro (opm_auto_dirs)
macro (opm_sources opm)
# this is necessary to set so that we know where we are going to
# execute the test programs (and make datafiles available)
set (tests_DIR "tests")
# how to retrieve the "fancy" name from the filename
set (tests_REGEXP
"^test_([^/]*)$"
"^([^/]*)_test$"
)
# start out with defined, empty lists which will be specified externally
set (MAIN_SOURCE_FILES)
set (EXAMPLE_SOURCE_FILES)
set (TEST_SOURCE_FILES)
set (TEST_DATA_FILES)
set (PUBLIC_HEADER_FILES)
# read the list of components from this file; it should set the above
# lists (which are generic names)
include (${PROJECT_SOURCE_DIR}/CMakeLists_files.cmake)
# rename from "friendly" names to ones that fit the "almost-structural"
# scheme used in the .cmake modules, converting them to absolute file
# names in the process
foreach (_file IN LISTS MAIN_SOURCE_FILES)
list (APPEND ${opm}_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS PUBLIC_HEADER_FILES)
list (APPEND ${opm}_HEADERS ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS TEST_SOURCE_FILES)
list (APPEND tests_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS TEST_DATA_FILES)
list (APPEND tests_DATA ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS EXAMPLE_SOURCE_FILES)
list (APPEND examples_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
# identify pre-compile header; if the project is called opm-foobar,
# then it should be in opm/foobar/opm-foobar-pch.hpp
string (REPLACE "-" "/" opm_NAME_AS_DIR ${${opm}_NAME})
set (${opm}_PRECOMP_CXX_HEADER "${opm_NAME_AS_DIR}/${${opm}_NAME}-pch.hpp")
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER})
set (${opm}_PRECOMP_CXX_HEADER "")
endif (NOT EXISTS ${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER})
endmacro (opm_sources opm)
# disable an entire directory from sources
macro (opm_disable_source opm)
foreach (_exp IN ITEMS ${ARGN})
# regexp or directory?
if (IS_ABSOLUTE "${_exp}")
set (_prefix "")
else (IS_ABSOLUTE "${_exp}")
set (_prefix "${PROJECT_SOURCE_DIR}/")
endif (IS_ABSOLUTE "${_exp}")
if (IS_DIRECTORY "${_prefix}${_exp}")
set (_glob "/*")
else (IS_DIRECTORY "${_prefix}${_exp}")
set (_glob "")
endif (IS_DIRECTORY "${_prefix}${_exp}")
file (GLOB_RECURSE _disabled RELATIVE ${PROJECT_SOURCE_DIR} "${_prefix}${_exp}${_glob}")
foreach (_file IN ITEMS ${_disabled})
list (REMOVE_ITEM ${opm}_SOURCES "${PROJECT_SOURCE_DIR}/${_file}")
endforeach (_file)
endforeach (_exp)
endmacro (opm_disable_source opm reldir)

122
cmake/Modules/OpmFind.cmake Normal file
View File

@@ -0,0 +1,122 @@
# - Generic inclusion of packages
#
# Synopsis:
#
# find_and_append_package (name args)
#
# where
#
# name Name of the package, e.g. Boost
# args Other arguments, e.g. COMPONENTS, REQUIRED, QUIET etc.
#
# This macro will append the list of standard variables found by the
# package to this project's standard variables
#
########################################################################
#
# - Generic inclusion of a list of packages
#
# Synopsis:
#
# find_and_append_package_list (args)
#
# where
#
# args List of package strings. Each string must be quoted if
# it contains more than one word.
#
# Example:
#
# find_and_append_package_list (
# "Boost COMPONENTS filesystem REQUIRED"
# SUPERLU
# )
include (Duplicates)
# list of suffixes for all the project variables
set (_opm_proj_vars
LINKER_FLAGS
LIBRARIES
DEFINITIONS
INCLUDE_DIRS
LIBRARY_DIRS
CONFIG_VARS
)
# ensure that they are at least the empty list after we're done
foreach (name IN LISTS _opm_proj_vars)
if (NOT DEFINED ${CMAKE_PROJECT_NAME}_${name})
set (${CMAKE_PROJECT_NAME}_${name} "")
endif (NOT DEFINED ${CMAKE_PROJECT_NAME}_${name})
endforeach (name)
# insert this boilerplate whenever we are going to find a new package
macro (find_and_append_package_to prefix name)
# if we have specified a directory, don't revert to searching the
# system default paths afterwards
string (TOUPPER "${name}" NAME)
string (REPLACE "-" "_" NAME "${NAME}")
# the documentation says that if *-config.cmake files are not found,
# find_package will revert to doing a full search, but that is not
# true, so unconditionally setting ${name}_DIR is not safe. however,
# if the directory given to us contains a config file, then copy the
# value over to this variable to switch to config mode (CMake will
# always use config mode if *_DIR is defined)
if (NOT DEFINED ${name}_DIR AND (DEFINED ${name}_ROOT OR DEFINED ${NAME}_ROOT))
if (EXISTS ${${name}_ROOT}/${name}-config.cmake OR EXISTS ${${name}_ROOT}/${name}Config.cmake)
set (${name}_DIR "${${name}_ROOT}")
endif (EXISTS ${${name}_ROOT}/${name}-config.cmake OR EXISTS ${${name}_ROOT}/${name}Config.cmake)
if (EXISTS ${${NAME}_ROOT}/${name}-config.cmake OR EXISTS ${${NAME}_ROOT}/${name}Config.cmake)
set (${name}_DIR "${${NAME}_ROOT}")
endif (EXISTS ${${NAME}_ROOT}/${name}-config.cmake OR EXISTS ${${NAME}_ROOT}/${name}Config.cmake)
endif (NOT DEFINED ${name}_DIR AND (DEFINED ${name}_ROOT OR DEFINED ${NAME}_ROOT))
# using config mode is better than using module (aka. find) mode
# because then the package has already done all its probes and
# stored them in the config file for us
if (${name}_DIR)
message (STATUS "Finding package ${name} using config mode")
find_package (${name} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH)
else (${name}_DIR)
message (STATUS "Finding package ${name} using module mode")
find_package (${name} ${ARGN})
endif (${name}_DIR)
if (${name}_FOUND)
foreach (var IN LISTS _opm_proj_vars)
if (DEFINED ${name}_${var})
list (APPEND ${prefix}_${var} ${${name}_${var}})
# cleanup lists
if ("${var}" STREQUAL "LIBRARIES")
remove_duplicate_libraries (${prefix})
else ("${var}" STREQUAL "LIBRARIES")
list (REMOVE_DUPLICATES ${prefix}_${var})
endif ("${var}" STREQUAL "LIBRARIES")
endif (DEFINED ${name}_${var})
endforeach (var)
# some libraries only define xxx_FOUND and not a corresponding HAVE_xxx
if (NOT DEFINED HAVE_${NAME})
set (HAVE_${NAME} 1)
endif (NOT DEFINED HAVE_${NAME})
endif (${name}_FOUND)
endmacro (find_and_append_package_to prefix name)
# append to the list of variables associated with the project
macro (find_and_append_package name)
find_and_append_package_to (${CMAKE_PROJECT_NAME} ${name} ${ARGN})
endmacro (find_and_append_package name)
# find a list of dependencies, adding each one of them
macro (find_and_append_package_list_to prefix)
# setting and separating is necessary to work around apparent bugs
# in CMake's parser (sic)
set (_deps ${ARGN})
foreach (_dep IN LISTS _deps)
separate_arguments (_args UNIX_COMMAND ${_dep})
find_and_append_package_to (${prefix} ${_args})
endforeach (_dep)
endmacro (find_and_append_package_list_to prefix)
# convenience method to supply the project name as prefix
macro (find_and_append_package_list)
find_and_append_package_list_to (${CMAKE_PROJECT_NAME} ${ARGN})
endmacro (find_and_append_package_list)

View File

@@ -0,0 +1,81 @@
# - Recreate grid selection macros from DUNE
#
# If anyone requires Dune::GridSelector::GridType, they must call this
# macro in *their* project, to add this information to config.h. (In
# the autotools version, dunecontrol will automatically include m4
# scripts that does this).
#
# Example:
# opm_cornerpoint_grid (${CONFIG_H})
include (CMakeParseArguments)
function (opm_grid_type)
cmake_parse_arguments (a "" "FILENAME;SYMBOL;TYPE;CONDITION" "HEADERS" ${ARGN})
# write prelude of a condition to use this particular grid, an inclusion guard,
# and checks to see if the number of dimensions fits for this type of grid
file (APPEND ${a_FILENAME}
"/* add GRIDTYPE typedef for grid implementation ${a_TYPE}:
defining ${a_SYMBOL} during compilation typedefs this grid implementation as GridType
in namespace Dune::GridSelector;
also integer constants dimgrid and dimworld are set in this namespace.
The required headers for this grid implementation are also included.
*/
#if defined ${a_SYMBOL} && ! defined USED_${a_SYMBOL}_GRIDTYPE
/* someone else has already defined a gridtype */
#if HAVE_GRIDTYPE
#error \"Ambigious definition of GRIDTYPE\"
#endif
#ifndef WORLDDIM
#define WORLDDIM GRIDDIM
#endif
#if not (WORLDDIM >= GRIDDIM)
#error \"WORLDDIM < GRIDDIM does not make sense.\"
#endif
#if ! (${a_CONDITION})
#error \"Preprocessor assertion ${a_CONDITION} failed.\"
#endif
")
# write headers which are capable of defining the type. this should
# really just have consisted of a forward declaration, but the damage
# is done: clients expect to just pull in config.h and have the
# proper type available.
foreach (header IN LISTS a_HEADERS)
file (APPEND ${a_FILENAME}
"#include <${header}>\n"
)
endforeach (header)
# main part which does the typedef and then a postlude which marks
# the grid as "taken" and make sure that no one else does the same
file (APPEND ${a_FILENAME}
"
namespace Dune {
namespace GridSelector {
const int dimgrid = GRIDDIM;
const int worldgrid = WORLDDIM;
typedef ${a_TYPE} GridType;
}
}
#define HAVE_GRIDTYPE 1
#define USED_${a_SYMBOL}_GRIDTYPE 1
#endif
")
endfunction (opm_grid_type)
# write the grid type for dune-cornerpoint
function (opm_cornerpoint_grid config_h)
opm_grid_type (
FILENAME ${CONFIG_H}
SYMBOL CPGRID
HEADERS "dune/grid/CpGrid.hpp" "dune/grid/cpgrid/dgfparser.hh"
TYPE Dune::CpGrid
CONDITION "(GRIDDIM == 3) && (WORLDDIM == 3)"
)
endfunction (opm_cornerpoint_grid config_h)

View File

@@ -0,0 +1,57 @@
# - Installation macro
#
# Set up installation targets for the binary library. The following
# suffices must be defined for the prefix passed as parameter:
#
# _NAME Name of the library
# _HEADERS List of header files to install
# _TARGET CMake target which builds the library
# _LIBRARY_TYPE Static or shared library
# _DEBUG File containing debug symbols
macro (opm_install opm)
foreach (_hdr IN LISTS ${opm}_HEADERS)
get_filename_component (_dir ${_hdr} PATH)
file (RELATIVE_PATH _rel_dir "${PROJECT_SOURCE_DIR}" "${_dir}")
install (
FILES ${_hdr}
DESTINATION include/${_rel_dir}
)
endforeach (_hdr)
if (${opm}_TARGET)
install (
TARGETS ${${opm}_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()
# only /usr/lib/debug seems to be searched for debug info; if we have
# write access to that directory (package installation), then default
# to use it; otherwise put the debug files together with the library
# (local installation). everything can be overridden by the option.
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
set (_sys_dbg_def ON)
else (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
set (_sys_dbg_def OFF)
endif (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
option (SYSTEM_DEBUG "Put .debug files in GDB debug file directory" ${_sys_dbg_def})
set (DEBUG_FILE_DIRECTORY /usr/lib/debug CACHE LOCATION "GDB debug file directory")
mark_as_advanced (DEBUG_FILE_DIRECTORY)
if (SYSTEM_DEBUG)
set (_dbg_prefix "${DEBUG_FILE_DIRECTORY}/")
else (SYSTEM_DEBUG)
set (_dbg_prefix "")
endif (SYSTEM_DEBUG)
# static libraries don't have their debug info stripped, so there is
# only a separate file when we are building shared objects
if (${opm}_LIBRARY_TYPE STREQUAL "SHARED")
install (
FILES ${PROJECT_BINARY_DIR}/${${opm}_DEBUG}
DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED")
install (
FILES ${PROJECT_SOURCE_DIR}/dune.module
DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/dunecontrol/${${opm}_NAME}
)
endmacro (opm_install opm)

View File

@@ -0,0 +1,256 @@
# - Find routine for OPM-like modules
#
# Synopsis:
#
# find_opm_package (module deps header lib defs prog conf)
#
# where
#
# module Name of the module, e.g. "dune-common"; this will be the
# stem of all variables defined (see below).
# deps Semi-colon-separated list of dependent modules which must
# be present; those that are required must be marked as such
# explicitly. Quote if more than one word is necessary to
# describe the dependency.
# header Name of the header file to probe for, e.g.
# "dune/common/fvector.hh". Note that you should have to same
# relative path here as is used in the header files.
# lib Name of the library to probe for, e.g. "dunecommon"
# defs Symbols that should be passed to compilations
# prog Program that should compile if library is present
# conf Symbols that should be present in config.h
#
# It will provide these standard Find-module variables:
#
# ${module}_INCLUDE_DIRS Directory of header files
# ${module}_LIBRARIES Directory of shared object files
# ${module}_DEFINITIONS Defines that must be set to compile
# ${module}_CONFIG_VARS List of defines that should be in config.h
# ${module}_QUIET Verbosity of last find of this module
# HAVE_${MODULE} Binary value to use in config.h
#
# Note: Arguments should be quoted, otherwise a list will spill into the
# next argument!
# Copyright (C) 2012 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
# <http://www.vtk.org/Wiki/CMake:How_To_Find_Libraries>
include (Duplicates)
# append all items from src into dst; both must be *names* of lists
macro (append_found src dst)
foreach (_item IN LISTS ${src})
if (NOT "${_item}" MATCHES "-NOTFOUND$")
list (APPEND ${dst} ${_item})
endif (NOT "${_item}" MATCHES "-NOTFOUND$")
endforeach (_item)
endmacro (append_found src dst)
function (find_opm_package module deps header lib defs prog conf)
# variables to pass on to other packages
if (FIND_QUIETLY)
set (${module}_QUIET "QUIET")
else (FIND_QUIETLY)
set (${module}_QUIET "")
endif (FIND_QUIETLY)
# if someone else has included this test, don't do it again
if (${${module}_FOUND})
return ()
endif (${${module}_FOUND})
# dependencies on other packages; underscore version only contains the
# name of the other package
set (_deps)
foreach (_dep IN LISTS deps)
separate_arguments (_args UNIX_COMMAND ${_dep})
find_package (${_args} QUIET)
list (GET _args 0 _name_only)
list (APPEND _deps ${_name_only})
endforeach (_dep)
# see if there is a pkg-config entry for this package, and use those
# settings as a starting point
find_package (PkgConfig)
pkg_check_modules (PkgConf_${module} QUIET ${module})
# these variables have non-standard names in FindPkgConfig (sic)
set (${module}_DEFINITIONS ${PkgConf_${module}_CFLAGS_OTHER})
set (${module}_LINKER_FLAG ${PkgConf_${module}_LDFLAGS_OTHER})
# in addition to accepting mod-ule_ROOT, we also accept the somewhat
# more idiomatic MOD_ULE_ROOT variant
string (TOUPPER ${module} MODULE_UPPER)
string (REPLACE "-" "_" MODULE ${MODULE_UPPER})
# if the user hasn't specified any location, and it isn't found
# in standard system locations either, then start to wander
# about and look for it in proximity to ourself. Qt Creator likes
# to put the build-directories as siblings to the source trees,
# but with a -build suffix
if (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
string (TOLOWER "${module}" _module_lower)
set (_guess
"../${module}"
"../${module}-build"
"../${_module_lower}"
"../${_module_lower}-build"
)
set (_guess_bin)
foreach (_item IN ITEMS ${_guess})
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
endforeach (_item)
endif (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
# search for this include and library file to get the installation
# directory of the package; hints are searched before the system locations,
# paths are searched afterwards
find_path (${module}_INCLUDE_DIR
NAMES "${header}"
PATHS ${_guess}
HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_INCLUDE_DIRS}
PATH_SUFFIXES "include"
)
# some modules are all in headers
if (NOT "${lib}" STREQUAL "")
find_library (${module}_LIBRARY
NAMES "${lib}"
PATHS ${_guess_bin}
HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS}
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
)
else (NOT "${lib}" STREQUAL "")
set (${module}_LIBRARY "")
endif (NOT "${lib}" STREQUAL "")
# add dependencies so that our result variables are complete
# list of necessities to build with the software
set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIR}")
set (${module}_LIBRARIES "${${module}_LIBRARY}")
foreach (_dep IN LISTS _deps)
# only add those packages we actually found (find_package will show
# an error if it was marked as REQUIRED)
if (${_dep}_FOUND)
list (APPEND ${module}_INCLUDE_DIRS ${${_dep}_INCLUDE_DIRS})
list (APPEND ${module}_LIBRARIES ${${_dep}_LIBRARIES})
list (APPEND ${module}_DEFINITIONS ${${_dep}_DEFINITIONS})
list (APPEND ${module}_CONFIG_VARS ${${_dep}_CONFIG_VARS})
list (APPEND ${module}_LINKER_FLAGS ${${_dep}_LINKER_FLAGS})
endif (${_dep}_FOUND)
endforeach (_dep)
# compile with this option to avoid avalanche of warnings
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}")
foreach (_def IN LISTS defs)
list (APPEND ${module}_DEFINITIONS "-D${_def}")
endforeach (_def)
# tidy the lists before returning them
list (REMOVE_DUPLICATES ${module}_INCLUDE_DIRS)
remove_duplicate_libraries (${module})
list (REMOVE_DUPLICATES ${module}_DEFINITIONS)
# these defines are used in dune/${module} headers, and should be put
# in config.h when we include those
foreach (_var IN LISTS conf)
# massage the name to remove source code formatting
string (REGEX REPLACE "^[\n\t\ ]+" "" _var "${_var}")
string (REGEX REPLACE "[\n\t\ ]+$" "" _var "${_var}")
list (APPEND ${module}_CONFIG_VARS ${_var})
endforeach (_var)
foreach (_dep in _deps)
if (DEFINED ${_dep}_CONFIG_VARS)
list (APPEND ${module}_CONFIG_VARS ${_dep}_CONFIG_VARS)
endif (DEFINED ${_dep}_CONFIG_VARS)
endforeach (_dep)
if (${module}_CONFIG_VARS)
list (REMOVE_DUPLICATES ${module}_CONFIG_VARS)
endif (${module}_CONFIG_VARS)
# these are the defines that should be set when compiling
# without config.h
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
# check that we can compile a small test-program
include (CMakePushCheckState)
cmake_push_check_state ()
include (CheckCXXSourceCompiles)
# only add these if they are actually found; otherwise it won't
# compile and the variable won't be set
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
# since we don't have any config.h yet
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
cmake_pop_check_state ()
# write status message in the same manner as everyone else
include (FindPackageHandleStandardArgs)
if ("${lib}" STREQUAL "")
set (_lib_var "")
else ("${lib}" STREQUAL "")
set (_lib_var "${module}_LIBRARY")
endif ("${lib}" STREQUAL "")
find_package_handle_standard_args (
${module}
DEFAULT_MSG
${module}_INCLUDE_DIR ${_lib_var} HAVE_${MODULE}
)
# allow the user to override these from user interface
mark_as_advanced (${module}_INCLUDE_DIR)
mark_as_advanced (${module}_LIBRARY)
# some genius that coded the FindPackageHandleStandardArgs figured out
# that the module name should be in uppercase (?!)
set (${module}_FOUND "${${MODULE_UPPER}_FOUND}" PARENT_SCOPE)
# return these variables to the caller
set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIRS}" PARENT_SCOPE)
set (${module}_LIBRARIES "${${module}_LIBRARIES}" PARENT_SCOPE)
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}" PARENT_SCOPE)
set (${module}_CONFIG_VARS "${${module}_CONFIG_VARS}" PARENT_SCOPE)
set (${module}_LINKER_FLAGS "${${module}_LINKER_FLAGS}" PARENT_SCOPE)
set (${module}_QUIET "${${module}_QUIET}" PARENT_SCOPE)
set (HAVE_${MODULE} "${HAVE_${MODULE}}" PARENT_SCOPE)
endfunction (find_opm_package module deps header lib defs prog conf)
# print all variables defined by the above macro
function (debug_find_vars module)
message (STATUS "${module}_FOUND = ${${module}_FOUND}")
message (STATUS "${module}_INCLUDE_DIRS = ${${module}_INCLUDE_DIRS}")
message (STATUS "${module}_LIBRARIES = ${${module}_LIBRARIES}")
message (STATUS "${module}_DEFINITIONS = ${${module}_DEFINITIONS}")
message (STATUS "${module}_CONFIG_VARS = ${${module}_CONFIG_VARS}")
message (STATUS "${module}_LINKER_FLAGS = ${${module}_LINKER_FLAGS}")
message (STATUS "${module}_QUIET = ${${module}_QUIET}")
string (TOUPPER ${module} MODULE)
string (REPLACE "-" "_" MODULE ${MODULE})
message (STATUS "HAVE_${MODULE} = ${HAVE_${MODULE}}")
endfunction (debug_find_vars module)
# generate a command-line that can be used to pass variables before
# config.h is available (such as probe tests). varname is the *name*
# of the variable to receive the result, defs is a list of the *names*
# which should be passed
function (config_cmd_line varname defs)
# process each variable
foreach (_var IN LISTS ${defs})
# only generate an entry if the define was actually set
if ((DEFINED ${_var}) AND (NOT "${${_var}}" STREQUAL ""))
# numbers are not quoted, strings are
if (${_var} MATCHES "[0-9]+")
set (_quoted "${${_var}}")
else (${_var} MATCHES "[0-9]+")
set (_quoted "\"${${_var}}\"")
endif (${_var} MATCHES "[0-9]+")
# add command-line option to define this variable
list (APPEND _cmdline "-D${_var}=${_quoted}")
endif ((DEFINED ${_var}) AND (NOT "${${_var}}" STREQUAL ""))
endforeach (_var)
# return the resulting command-line options for defining vars
set (${varname} "${_cmdline}" PARENT_SCOPE)
endfunction (config_cmd_line)

View File

@@ -0,0 +1,106 @@
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
include(CMakeParseArguments)
# helper macro to retrieve a single field of a dune.module file
macro(OpmGetDuneModuleDirective_ FieldName OutputVariable DuneModuleContents)
string(REGEX MATCH ".*${FieldName}:[ ]*([^\n]+).*" ${OutputVariable} "${DuneModuleContents}")
string(REGEX REPLACE ".*${FieldName}:[ ]*([^\n]+).*" "\\1" "${OutputVariable}" "${${OutputVariable}}")
endmacro()
# This macro parses the dune.module file of a Dune module.
#
# Usage:
#
# OpmParseDuneModuleInfo(DuneModuleName
# [FILE_NAME "PathTo/dune.module"])
#
# This function sets the following variables:
#
# ${MODULE_NAME}_NAME: The name of the module which ought to be used when referencing it in texts
# ${MODULE_NAME}_DESCRIPTION: A textual description of the module
# ${MODULE_NAME}_DEPENDS: The dependencies of the module
# ${MODULE_NAME}_URL: The URL of the module's website
# ${MODULE_NAME}_MAINTAINER_NAME: The real name of the module maintainer(s)
# ${MODULE_NAME}_MAINTAINER_EMAIL: The e-mail address of the module maintainer(s)
# ${MODULE_NAME}_VERSION: version string of the dune module
# ${MODULE_NAME}_VERSION_MAJOR: major version of the dune module
# ${MODULE_NAME}_VERSION_MINOR: minor version of the dune module
# ${MODULE_NAME}_VERSION_REVISION: revision of the dune module
# ${MODULE_NAME}_CODENAME: code name for the version of the module
function(OpmParseDuneModule ModuleName)
CMAKE_PARSE_ARGUMENTS(
CURMOD # prefix
"" # flags
"FILE_NAME" # one value args
"" # multi-value args
${ARGN})
# create an uppercase, underscore version of the given module name
string(TOUPPER "${ModuleName}" MODULE_NAME)
string(REPLACE "-" "_" MODULE_NAME "${MODULE_NAME}")
if (NOT CURMOD_FILE_NAME)
set(CURMOD_FILE_NAME "${${MODULE_NAME}_DIR}/dune.module")
endif()
# read the dune.module file
file(READ "${CURMOD_FILE_NAME}" DUNE_MODULE)
# set the module name
OpmGetDuneModuleDirective_("Module" ${MODULE_NAME}_NAME "${DUNE_MODULE}")
# set the module description
OpmGetDuneModuleDirective_("Description" ${MODULE_NAME}_DESCRIPTION "${DUNE_MODULE}")
# set the dependencies
OpmGetDuneModuleDirective_("Depends" ${MODULE_NAME}_DEPENDS "${DUNE_MODULE}")
# set the URL of the module's website
OpmGetDuneModuleDirective_("Url" ${MODULE_NAME}_URL "${DUNE_MODULE}")
# set the project version. also split the version string into MAJOR.MINOR.REVISON
OpmGetDuneModuleDirective_("Version" ${MODULE_NAME}_VERSION "${DUNE_MODULE}")
string(REGEX REPLACE "^([0-9]*)\\..*\$" "\\1" ${MODULE_NAME}_VERSION_MAJOR "${${MODULE_NAME}_VERSION}")
string(REGEX REPLACE "^[0-9]*\\.([0-9]*).*\$" "\\1" ${MODULE_NAME}_VERSION_MINOR "${${MODULE_NAME}_VERSION}")
string(REGEX REPLACE "^[0-9]*\\.[0-9]*\\.([0-9]*).*\$" "\\1" ${MODULE_NAME}_VERSION_REVISION "${${MODULE_NAME}_VERSION}")
# if the regular expression for the revision did not match, we use "0"
# as the revision number. (we silently assume, that the regexps for
# the major and minor version match.)
if ("${${MODULE_NAME}_VERSION_REVISION}" STREQUAL "${${MODULE_NAME}_VERSION}")
set(${MODULE_NAME}_VERSION_REVISION "0")
endif()
# set the maintainer email (the default Dune autotools build system
# assumes that dune.module's 'Maintainer' field only contains the
# email address of the maintainer. Using the format 'Maintainer:
# Maintainer Name <maintainer@address.org>' makes the DUNE autotools
# build system choke, so we introduce a new field 'MaintainerName'
# which is ignored by the DUNE autotools build system.)
OpmGetDuneModuleDirective_("MaintainerName" ${MODULE_NAME}_MAINTAINER_NAME "${DUNE_MODULE}")
OpmGetDuneModuleDirective_("Maintainer" ${MODULE_NAME}_MAINTAINER_EMAIL "${DUNE_MODULE}")
# find codename string
OpmGetDuneModuleDirective_("Codename" ${MODULE_NAME}_CODENAME "${DUNE_MODULE}")
################
# export all output variables
################
# needed for some other OPM CMake modules: Variable without dashes
# replaced by underscores and non-uppercase
set(${ModuleName}_NAME "${${MODULE_NAME}_NAME}" PARENT_SCOPE)
set(${MODULE_NAME}_NAME "${${MODULE_NAME}_NAME}" PARENT_SCOPE)
set(${MODULE_NAME}_DESCRIPTION "${${MODULE_NAME}_DESCRIPTION}" PARENT_SCOPE)
set(${MODULE_NAME}_DEPENDS "${${MODULE_NAME}_DEPENDS}" PARENT_SCOPE)
set(${MODULE_NAME}_URL "${${MODULE_NAME}_URL}" PARENT_SCOPE)
set(${MODULE_NAME}_VERSION "${${MODULE_NAME}_VERSION}" PARENT_SCOPE)
set(${MODULE_NAME}_VERSION_MAJOR "${${MODULE_NAME}_VERSION_MAJOR}" PARENT_SCOPE)
set(${MODULE_NAME}_VERSION_MINOR "${${MODULE_NAME}_VERSION_MINOR}" PARENT_SCOPE)
set(${MODULE_NAME}_VERSION_REVISION "${${MODULE_NAME}_VERSION_REVISION}" PARENT_SCOPE)
set(${MODULE_NAME}_MAINTAINER_NAME "${${MODULE_NAME}_MAINTAINER_NAME}" PARENT_SCOPE)
set(${MODULE_NAME}_MAINTAINER_EMAIL "${${MODULE_NAME}_MAINTAINER_EMAIL}" PARENT_SCOPE)
set(${MODULE_NAME}_CODENAME "${${MODULE_NAME}_CODENAME}" PARENT_SCOPE)
endfunction()

View File

@@ -0,0 +1,142 @@
# - Helper routines for opm-core like projects
# convert a list back to a command-line string
function (unseparate_args var_name prefix value)
separate_arguments (value)
foreach (item IN LISTS value)
set (prefixed_item "${prefix}${item}")
if (${var_name})
set (${var_name} "${${var_name}} ${prefixed_item}")
else (${var_name})
set (${var_name} "${prefixed_item}")
endif (${var_name})
endforeach (item)
set (${var_name} "${${var_name}}" PARENT_SCOPE)
endfunction (unseparate_args var_name prefix value)
# wrapper to set variables in pkg-config file
function (configure_pc_file name source dest prefix libdir includedir)
# escape set of standard strings
unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}")
unseparate_args (libs "-l" "${${name}_LIBRARIES}")
unseparate_args (defs "" "${${name}_DEFINITIONS}")
# necessary to make these variables visible to configure_file
set (name "${${name}_NAME}")
set (description "${${name}_DESCRIPTION}")
set (target "${${name}_LIBRARY}")
set (major "${${name}_VERSION_MAJOR}")
set (minor "${${name}_VERSION_MINOR}")
configure_file (${source} ${dest} @ONLY)
endfunction (configure_pc_file name source dist prefix libdir includedir)
function (configure_cmake_file name variant version)
# declarative list of the variable names that are used in the template
# and that must be defined in the project to be exported
set (variable_suffices
DESCRIPTION
VERSION
DEFINITIONS
INCLUDE_DIRS
LIBRARY_DIRS
LINKER_FLAGS
CONFIG_VARS
LIBRARY
LIBRARIES
TARGET
)
# set these variables temporarily (this is in a function scope) so
# they are available to the template (only)
foreach (suffix IN LISTS variable_suffices)
set (opm-project_${suffix} "${${name}_${suffix}}")
endforeach (suffix)
set (opm-project_NAME "${${name}_NAME}")
# make the file substitutions
configure_file (
${template_dir}/opm-project-config${version}.cmake.in
${PROJECT_BINARY_DIR}/${${name}_NAME}-${variant}${version}.cmake
@ONLY
)
endfunction (configure_cmake_file name)
# installation of CMake modules to help user programs locate the library
function (opm_cmake_config name)
# assume that the template is located in cmake/Templates (cannot use
# the current directory since this is in a function and the directory
# at runtime not at definition will be used
set (template_dir "${PROJECT_SOURCE_DIR}/cmake/Templates")
# write configuration file to locate library
configure_cmake_file (${name} "config" "")
configure_cmake_file (${name} "config" "-version")
configure_vars (
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-config.cmake"
APPEND "${${name}_CONFIG_VARS}"
)
# config-mode .pc file; use this to find the build tree
configure_pc_file (
${name}
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}.pc
${PROJECT_BINARY_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
${PROJECT_SOURCE_DIR}
)
# replace the build directory with the target directory in the
# variables that contains build paths
string (REPLACE
"${PROJECT_SOURCE_DIR}"
"${CMAKE_INSTALL_PREFIX}/include"
${name}_INCLUDE_DIRS
"${${name}_INCLUDE_DIRS}"
)
string (REPLACE
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
${name}_LIBRARY
"${${name}_LIBRARY}"
)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
)
# create a config mode file which targets the install directory instead
# of the build directory (using the same input template)
configure_cmake_file (${name} "install" "")
configure_vars (
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake"
APPEND "${${name}_CONFIG_VARS}"
)
# this file gets copied to the final installation directory
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake
DESTINATION share/cmake/${${name}_NAME}
RENAME ${${name}_NAME}-config.cmake
)
# assume that there exists a version file already
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
DESTINATION share/cmake/${${name}_NAME}
)
# find-mode .pc file; use this to locate system installation
configure_pc_file (
${name}
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
${CMAKE_INSTALL_PREFIX}/include
)
# put this in the right system location; assume that we have binaries
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/
RENAME ${${name}_NAME}.pc
)
endfunction (opm_cmake_config name)

View File

@@ -0,0 +1,148 @@
# - Build satellites that are dependent of main library
#
# Enumerate all source code in a "satellite" directory such as tests/,
# compile each of them and optionally set them as a test for CTest to
# run. They will be linked to the main library created by the project.
#
# The following suffices must be defined for the opm prefix passed as
# parameter:
#
# _LINKER_FLAGS Necessary flags to link with this library
# _TARGET CMake target which creates the library
# _LIBRARIES Other dependencies that must also be linked
# Synopsis:
# opm_compile_satellites (opm satellite excl_all test_regexp)
#
# Parameters:
# opm Prefix of the variable which contain information
# about the library these satellites depends on, e.g.
# pass "opm-core" if opm-core_TARGET is the name of
# the target the builds this library. Variables with
# suffixes _TARGET and _LIBRARIES must exist.
#
# satellite Prefix of variable which contain the names of the
# files, e.g. pass "tests" if the files are in the
# variable tests_SOURCES. Variables with suffixes
# _DATAFILES, _SOURCES and _DIR should exist. This
# name is also used as name of the target that builds
# all these files.
#
# excl_all EXCLUDE_ALL if these targets should not be built by
# default, otherwise empty string.
#
# test_regexp Regular expression which picks the name of a test
# out of the filename, or blank if no test should be
# setup.
#
# Example:
# opm_compile_satellites (opm-core test "" "^test_([^/]*)$")
#
macro (opm_compile_satellites opm satellite excl_all test_regexp)
# if we are going to build the tests always, then make sure that
# the datafiles are present too
if (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
set (_incl_all "ALL")
else (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
set (_incl_all "")
endif (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
# if a set of datafiles has been setup, pull those in
add_custom_target (${satellite} ${_incl_all})
if (${satellite}_DATAFILES)
add_dependencies (${satellite} ${${satellite}_DATAFILES})
endif (${satellite}_DATAFILES)
# compile each of these separately
foreach (_sat_FILE IN LISTS ${satellite}_SOURCES)
get_filename_component (_sat_NAME "${_sat_FILE}" NAME_WE)
add_executable (${_sat_NAME} ${excl_all} ${_sat_FILE})
add_dependencies (${satellite} ${_sat_NAME})
set_target_properties (${_sat_NAME} PROPERTIES
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
)
# are we building a test? luckily, the testing framework doesn't
# require anything else, so we don't have to figure out where it
# should go in the library list
if (NOT "${test_regexp}" STREQUAL "")
set (_test_lib "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
else (NOT "${test_regexp}" STREQUAL "")
set (_test_lib "")
endif (NOT "${test_regexp}" STREQUAL "")
target_link_libraries (${_sat_NAME} ${${opm}_TARGET} ${${opm}_LIBRARIES} ${_test_lib})
strip_debug_symbols (${_sat_NAME} _sat_DEBUG)
list (APPEND ${satellite}_DEBUG ${_sat_DEBUG})
# variable with regular expression doubles as a flag for
# whether tests should be setup or not
if (NOT "${test_regexp}" STREQUAL "")
foreach (_regexp IN ITEMS ${test_regexp})
if ("${_sat_NAME}" MATCHES "${_regexp}")
string (REGEX REPLACE "${_regexp}" "\\1" _sat_FANCY "${_sat_NAME}")
endif ("${_sat_NAME}" MATCHES "${_regexp}")
endforeach (_regexp)
get_target_property (_sat_LOC ${_sat_NAME} LOCATION)
if (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (
NAME ${_sat_FANCY}
COMMAND ${CMAKE_COMMAND} -E chdir "${PROJECT_BINARY_DIR}/${${satellite}_DIR}" ${_sat_LOC}
)
else (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (${_sat_FANCY} ${_sat_LOC})
# run the test in the directory where the data files are
set_tests_properties (${_sat_FANCY} PROPERTIES
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${${satellite}_DIR}
)
endif (CMAKE_VERSION VERSION_LESS "2.8.4")
endif(NOT "${test_regexp}" STREQUAL "")
endforeach (_sat_FILE)
endmacro (opm_compile_satellites opm prefix)
# Synopsis:
# opm_data (satellite target dirname files)
#
# provides these output variables:
#
# ${satellite}_INPUT_FILES List of all files that are copied
# ${satellite}_DATAFILES Name of target which copies these files
#
# Example:
#
# opm_data (tests datafiles "tests/")
#
macro (opm_data satellite target dirname)
# even if there are no datafiles, create the directory so the
# satellite programs have a homedir to run in
execute_process (
COMMAND ${CMAKE_COMMAND} -E make_directory ${dirname}
)
# if ever huge test datafiles are necessary, then change this
# into "create_symlink" (on UNIX only, apparently)
set (make_avail "copy")
# provide datafiles as inputs for the tests, by copying them
# to a tests/ directory in the output tree (if different)
set (${satellite}_INPUT_FILES)
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
foreach (input_datafile IN LISTS ${satellite}_DATA)
file (RELATIVE_PATH rel_datafile "${PROJECT_SOURCE_DIR}" ${input_datafile})
set (output_datafile "${PROJECT_BINARY_DIR}/${rel_datafile}")
add_custom_command (
OUTPUT ${output_datafile}
COMMAND ${CMAKE_COMMAND}
ARGS -E ${make_avail} ${input_datafile} ${output_datafile}
DEPENDS ${input_datafile}
VERBATIM
)
list (APPEND ${satellite}_INPUT_FILES "${output_datafile}")
endforeach (input_datafile)
endif(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# setup a target which does all the copying
set (${satellite}_DATAFILES "${target}")
add_custom_target (${${satellite}_DATAFILES}
DEPENDS ${${satellite}_INPUT_FILES}
COMMENT "Making \"${satellite}\" data available in output tree"
)
endmacro (opm_data satellite target dirname files)

View File

@@ -0,0 +1,47 @@
# - Get compiler version
# probe the GCC version, returns empty string if GCC is not compiler
function (get_gcc_version language ver_name)
if(CMAKE_${language}_COMPILER_ID STREQUAL GNU)
# exec_program is deprecated, but execute_process does't work :-(
exec_program (${CMAKE_${language}_COMPILER}
ARGS ${CMAKE_${language}_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE _version
)
set (${ver_name} ${_version} PARENT_SCOPE)
else (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
set (${ver_name} "" PARENT_SCOPE)
endif (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
endfunction (get_gcc_version ver_name)
# less reliable, but includes the patch number
function (get_gcc_patch language ver_name)
if(CMAKE_${language}_COMPILER_ID STREQUAL GNU)
# exec_program is deprecated, but execute_process does't work :-(
exec_program (${CMAKE_${language}_COMPILER}
ARGS ${CMAKE_${language}_COMPILER_ARG1} --version
OUTPUT_VARIABLE _version
)
# split multi-line string into list
if (WIN32)
string (REPLACE "\r\n" ";" _version "${_version}")
else (WIN32)
string (REPLACE "\n" ";" _version "${_version}")
endif (WIN32)
# only keep first line
list (GET _version 0 _version)
# extract version number from it (this is the fragile part)
string (REGEX REPLACE "^[^\\(]+(\\([^\\)]*\\))?[\ \t]*([0-9]+\\.[0-9]+\\.[0-9]+)(.*\\(.*\\))?" "\\2" _version "${_version}")
# return this to the caller
set (${ver_name} ${_version} PARENT_SCOPE)
else (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
set (${ver_name} "" PARENT_SCOPE)
endif (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
endfunction (get_gcc_patch language ver_name)
function (compiler_info)
if (CMAKE_COMPILER_IS_GNUCXX)
get_gcc_patch (CXX version)
message (STATUS "GNU C++ compiler version: ${version}")
endif (CMAKE_COMPILER_IS_GNUCXX)
endfunction (compiler_info)

View File

@@ -0,0 +1,96 @@
# - Generate debug symbols in a separate file
#
# (1) Include this file in your CMakeLists.txt; it will setup everything
# to compile WITH debug symbols in any case.
#
# (2) Run the strip_debug_symbols function on every target that you want
# to strip.
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (AddOptions)
# only debugging using the GNU toolchain is supported for now
if (CMAKE_COMPILER_IS_GNUCXX)
# add debug symbols to *all* targets, regardless. there WILL come a
# time when you need to find a bug which only manifests itself in a
# release target on a production system!
message (STATUS "Generating debug symbols: -ggdb3")
add_options (ALL_LANGUAGES ALL_BUILDS "-ggdb3")
# extracting the debug info is done by a separate utility in the GNU
# toolchain. check that this is actually installed.
message (STATUS "Looking for strip utility")
find_program (OBJCOPY
objcopy
${CYGWIN_INSTALL_PATH}/bin /usr/bin /usr/local/bin
)
mark_as_advanced (OBJCOPY)
if (OBJCOPY)
message (STATUS "Looking for strip utility - found")
else (OBJCOPY)
message (WARNING "Looking for strip utility - not found")
endif (OBJCOPY)
endif (CMAKE_COMPILER_IS_GNUCXX)
# command to separate the debug information from the executable into
# its own file; this must be called for each target; optionally takes
# the name of a variable to receive the list of .debug files
function (strip_debug_symbols targets)
if (CMAKE_COMPILER_IS_GNUCXX AND OBJCOPY)
foreach (target IN LISTS targets)
# libraries must retain the symbols in order to link to them, but
# everything can be stripped in an executable
get_target_property (_kind ${target} TYPE)
# don't strip static libraries
if ("${_kind}" STREQUAL "STATIC_LIBRARY")
return ()
endif ("${_kind}" STREQUAL "STATIC_LIBRARY")
# don't strip public symbols in shared objects
if ("${_kind}" STREQUAL "EXECUTABLE")
set (_strip_args "--strip-all")
else ("${_kind}" STREQUAL "EXECUTABLE")
set (_strip_args "--strip-debug")
endif ("${_kind}" STREQUAL "EXECUTABLE")
# add_custom_command doesn't support generator expressions in the
# working_directory argument (sic; that's what you get when you do
# ad hoc programming all the time), so we need to extract the
# location up front (the location on the other hand should not be
# used for libraries as it does not include the soversion -- sic
# again)
get_target_property (_full ${target} LOCATION)
get_filename_component (_dir ${_full} PATH)
get_filename_component (_name ${_full} NAME)
# only libraries have soversion property attached
get_target_property (_target_soversion ${target} SOVERSION)
get_target_property (_target_version ${target} VERSION)
if (_target_soversion)
set (_target_file "${_full}.${_target_version}")
set (_target_file_name "${_name}.${_target_version}")
else (_target_soversion)
set (_target_file "${_full}")
set (_target_file_name "${_name}")
endif (_target_soversion)
# do without generator expressions (which doesn't work everywhere)
add_custom_command (TARGET ${target}
POST_BUILD
WORKING_DIRECTORY ${_dir}
COMMAND ${OBJCOPY} ARGS --only-keep-debug ${_target_file} ${_target_file}.debug
COMMAND ${OBJCOPY} ARGS ${_strip_args} ${_target_file}
COMMAND ${OBJCOPY} ARGS --add-gnu-debuglink=${_target_file_name}.debug ${_target_file}
VERBATIM
)
# add this .debug file to the list
set (_debug_files ${_debug_files} ${_this_debug_file})
endforeach (target)
# if optional debug list was requested, then copy to output parameter
if (ARGV1)
set (${ARGV1} ${_debug_files} PARENT_SCOPE)
endif (ARGV1)
endif (CMAKE_COMPILER_IS_GNUCXX AND OBJCOPY)
endfunction (strip_debug_symbols targets)

View File

@@ -0,0 +1,33 @@
# be sure that this component is searched for
find_package (Boost COMPONENTS unit_test_framework QUIET)
if (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
# setup to do a test compile
include (CMakePushCheckState)
cmake_push_check_state ()
include (CheckCXXSourceCompiles)
list (APPEND CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS})
list (APPEND CMAKE_REQUIRED_LIBRARIES ${Boost_LIBRARIES})
check_cxx_source_compiles("
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE DYNLINK_TEST
#include <boost/test/unit_test.hpp>
int f(int x) { return 2 * x; }
BOOST_AUTO_TEST_CASE(DynlinkConfigureTest) {
BOOST_CHECK_MESSAGE(f(2) == 4,
\"Apparently, multiplication doesn't \"
\"work: f(2) = \" << f(2));
}" HAVE_DYNAMIC_BOOST_TEST)
cmake_pop_check_state ()
else (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
# no Boost, no compile
set (HAVE_DYNAMIC_BOOST_TEST 0)
endif (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
# save this for later
set (HAVE_DYNAMIC_BOOST_TEST "${HAVE_DYNAMIC_BOOST_TEST}"
CACHE BOOL "Whether Boost::Test is dynamically linked or not"
)

View File

@@ -0,0 +1,8 @@
# - Try to build faster depending on the compiler
# faster builds by using a pipe instead of temp files
include (AddOptions)
if (CMAKE_COMPILER_IS_GNUCXX)
add_options (ALL_LANGUAGES ALL_BUILDS "-pipe")
endif (CMAKE_COMPILER_IS_GNUCXX)

View File

@@ -0,0 +1,78 @@
# - Provide C wrappers for Fortran code
#
# Synopsis:
# define_fc_func (APPEND config.h IF HAVE_BLAS)
function (define_fc_func verb file)
# check that we are being called correctly
if (NOT (("${verb}" STREQUAL "APPEND") OR
("${verb}" STREQUAL "WRITE")))
message (FATAL_ERROR
"Unknown verb \"${verb}\" passed as first argument."
)
endif (NOT (("${verb}" STREQUAL "APPEND") OR
("${verb}" STREQUAL "WRITE")))
# check under which conditions we should do our work
if (NOT "${ARGN}" STREQUAL "")
set (args ${ARGN})
list (GET args 0 keyword)
if (NOT "${keyword}" STREQUAL "IF")
message (FATAL_ERROR
"Unknown conditional \"${keyword}\" passed as third argument."
)
endif (NOT "${keyword}" STREQUAL "IF")
list (REMOVE_AT args 0)
set (needed FALSE)
foreach (condition IN LISTS args)
if (${${condition}})
set (needed TRUE)
break ()
endif (${${condition}})
endforeach (condition)
else (NOT "${ARGN}" STREQUAL "")
# if called unconditionally, then always include the wrapper
set (needed TRUE)
endif (NOT "${ARGN}" STREQUAL "")
# only do something if we actually have some components which requires
# the interaction -- don't load the Fortran compiler just to write
# this macro (which apparently nobody uses then)
if (needed)
# enable languages needed
if (NOT CMAKE_C_COMPILER_LOADED)
enable_language (C)
endif (NOT CMAKE_C_COMPILER_LOADED)
if (NOT CMAKE_Fortran_COMPILER_LOADED)
enable_language (Fortran)
endif (NOT CMAKE_Fortran_COMPILER_LOADED)
# get a temporary file
set (_tmp_hdr ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/config_f.h)
# write a small config file that contains the proper convention for
# calling Fortran from C
include (FortranCInterface)
fortrancinterface_header (${_tmp_hdr})
# read the definition back in from the file
file (STRINGS
${_tmp_hdr}
_str
REGEX "^#define FortranCInterface_GLOBAL\\(name,NAME\\) .*$"
)
# massage it to look like the one AC_FC_WRAPPERS provide
string (REPLACE "FortranCInterface_GLOBAL" "FC_FUNC" _str ${_str})
# write this definition to the end of our own configuration file
file (${verb} ${file}
"\n/* Define to a macro mangling the given C identifier (in lower and upper
case), which must not contain underscores, for linking with Fortran. */\n"
${_str}
"\n"
)
else (needed)
message (STATUS "Fortran/C interface not activated")
endif (needed)
endfunction (define_fc_func)

View File

@@ -0,0 +1,42 @@
# - Multiarch support in object code library directories
#
# This module sets the following variable
# CMAKE_INSTALL_LIBDIR to lib, lib64 or lib/x86_64-linux-gnu
# depending on the platform; use this path
# for platform-specific binaries.
#
# CMAKE_INSTALL_LIBDIR_NOARCH to lib or lib64 depending on the platform;
# use this path for architecture-independent
# files.
#
# Note that it will override the results of GNUInstallDirs if included after
# that module.
# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu;
# Fedora put module files in lib64/ too, but Debian uses lib/ for that
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# Debian or Ubuntu?
if (EXISTS "/etc/debian_version")
set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
set (_libdir_noarch "lib")
else (EXISTS "/etc/debian_version")
# 64-bit system?
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_noarch "lib64")
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_noarch "lib")
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_def "${_libdir_noarch}")
endif (EXISTS "/etc/debian_version")
else ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set (_libdir_def "lib")
set (_libdir_noarch "lib")
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# let the user override if somewhere else is desirable
set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries")
set (CMAKE_INSTALL_LIBDIR_NOARCH "${_libdir_noarch}" CACHE PATH "Architecture-independent library files")
mark_as_advanced (
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_LIBDIR_NOARCH
)

View File

@@ -0,0 +1,36 @@
# - Use only needed imports from libraries
#
# Add the -Wl,--as-needed flag to the default linker flags on Linux
# in order to get only the minimal set of dependencies.
function (prepend var_name value)
if (${var_name})
set (${var_name} "${value} ${${var_name}}" PARENT_SCOPE)
else (${var_name})
set (${var_name} "${value}")
endif (${var_name})
endfunction (prepend var_name value)
# only ELF shared objects can be underlinked, and only GNU will accept
# these parameters; otherwise just leave it to the defaults
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
# these are the modules whose probes will turn up incompatible
# flags on some systems
set (_maybe_underlinked
SuiteSparse
)
# check if any modules actually reported problems (by setting an
# appropriate linker flag)
set (_underlinked FALSE)
foreach (_module IN LISTS _maybe_underlinked)
if ("${${_module}_LINKER_FLAGS}" MATCHES "-Wl,--no-as-needed")
set (_underlinked TRUE)
endif ("${${_module}_LINKER_FLAGS}" MATCHES "-Wl,--no-as-needed")
endforeach (_module)
# if we didn't have any problems, then go ahead and add
if (NOT _underlinked)
prepend (CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
prepend (CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed")
prepend (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
endif (NOT _underlinked)
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)

View File

@@ -0,0 +1,60 @@
# - Use OpenMP features
#
# Synopsis:
#
# find_openmp (module)
#
# where:
#
# module Name of the module to which OpenMP libraries
# etc. should be added, e.g. "opm-core".
#
# Note: Compiler flags are always added globally, to avoid ABI
# incompatibility problems.
#
# It is assumed that the following variables are available
#
# ${module}_QUIET Verbosity level of the parent's find module
# ${module}_LIBRARIES List of libraries to which OpenMP will be added
#
# Example:
# find_openmp (opm-core)
# remove_dup_deps (opm-core)
include (AddOptions)
macro (find_openmp opm)
# user code can be conservative by setting USE_OPENMP_DEFAULT
if (NOT DEFINED USE_OPENMP_DEFAULT)
set (USE_OPENMP_DEFAULT ON)
endif (NOT DEFINED USE_OPENMP_DEFAULT)
option (USE_OPENMP "Enable OpenMP for parallelization" ${USE_OPENMP_DEFAULT})
if (USE_OPENMP)
# enabling OpenMP is supposedly enough to make the compiler link with
# the appropriate libraries
find_package (OpenMP ${${opm}_QUIET})
list (APPEND ${opm}_LIBRARIES ${OpenMP_LIBRARIES})
if (OPENMP_FOUND)
add_options (C ALL_BUILDS "${OpenMP_C_FLAGS}")
add_options (CXX ALL_BUILDS "${OpenMP_CXX_FLAGS}")
endif (OPENMP_FOUND)
# threading library (search for this *after* OpenMP
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (Threads ${${opm}_QUIET})
if (CMAKE_USE_PTHREADS_INIT)
list (APPEND ${opm}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif (CMAKE_USE_PTHREADS_INIT)
else (USE_OPENMP)
message (STATUS "OpenMP: disabled")
# if we don't have OpenMP support, then don't show warnings that these
# pragmas are unknown
if (CMAKE_COMPILER_IS_GNUCXX)
add_options (ALL_LANGUAGES ALL_BUILDS "-Wno-unknown-pragmas")
elseif (MSVC)
add_options (ALL_LANGUAGES ALL_BUILDS "-wd4068")
endif(CMAKE_COMPILER_IS_GNUCXX)
endif (USE_OPENMP)
endmacro (find_openmp opm)

View File

@@ -0,0 +1,41 @@
# - Turn on optimizations based on build type
include(TestCXXAcceptsFlag)
include (AddOptions)
# if we are building a debug target, then disable all optimizations
# otherwise, turn them on. indicate to the code what we have done
# so it can turn on assertions etc.
if (CMAKE_COMPILER_IS_GNUCXX)
# use these options for debug builds - no optimizations
add_options (
ALL_LANGUAGES
"Debug"
"-O0" "-DDEBUG"
)
# extra flags passed for optimization
set (_opt_flags "")
# link-time (a.k.a. global) optimizations
check_cxx_accepts_flag ("-flto" HAVE_LINK_OPTS)
if (HAVE_LINK_OPTS)
list (APPEND _opt_flags "-flto")
endif (HAVE_LINK_OPTS)
# native instruction set tuning
option (WITH_NATIVE "Use native instruction set" ON)
if (WITH_NATIVE)
check_cxx_accepts_flag ("-mtune=native" HAVE_MTUNE)
if (HAVE_MTUNE)
list (APPEND _opt_flags "-mtune=native")
endif (HAVE_MTUNE)
endif (WITH_NATIVE)
# use these options for release builds - full optimization
add_options (
ALL_LANGUAGES
"Release;RelWithDebInfo;MinSizeRel"
"-O3" "-DNDEBUG" ${_opt_flags}
)
endif (CMAKE_COMPILER_IS_GNUCXX)

View File

@@ -0,0 +1,157 @@
# - Use precompiled headers
#
# precompile_header takes these parameters
#
# language Language in which the header is written; C or CXX.
#
# type Type of target being build, SHARED_LIBRARY, STATIC_LIBRARY
# or EXECUTABLE.
#
# header Relative path within the source tree to the header
# that contains the list of includes to be precompiled.
# This header should not be added to the installation,
# as it will be specific for this project.
#
# target Name of target to be created. All targets that
# use the precompiled header should depend on this target
# so that it is built before them. A variable with this
# name will also be created which contains the file name.
#
# flags_name Name of variable to receive the flags that should be
# added to the command-line.
#
# Example:
# get_target_property (type opmcore TYPE)
# precompile_header (CXX ${type}
# HEADER "opm/core/opm-core-pch.hpp"
# TARGET opmcore_CXX_pch
# FLAGS opmcore_PRECOMP_CXX_FLAGS
# )
# set_source_files_properties (${opmcore_CXX_SOURCES} PROPERTIES
# OBJECT_DEPENDS "${opmcore_CXX_pch}"
# COMPILE_FLAGS "${opmcore_PRECOMP_CXX_FLAGS}"
# )
# get compiler version
include (UseCompVer)
# reconstruct the compiler command line; this does NOT include the
# DEFINE_SYMBOL that is added for shared libraries. type is the TYPE
# target property.
# see larsch's PrecompiledHeader.cmake: <https://gist.github.com/573926>
# and <https://github.com/loaden/qtcreator/blob/wip/cmake/cmake/PrecompiledHeader.cmake>
function (compiler_cmdline language type cmd_name args_name)
# get the compiler for this particular language
set (${cmd_name} "${CMAKE_${language}_COMPILER}" PARENT_SCOPE)
# in case someone has overridden the compiler (e.g. ccache)
set (_args "${CMAKE_${language}_COMPILER_ARG1}")
# macro definitions
get_directory_property (_defs DEFINITIONS)
list (APPEND _args "${_defs}")
# global flags (such as -std=c++11); notice that there are both
# release-dependent and non-release-dependent ones
string (TOUPPER "CMAKE_${language}_FLAGS" _flags)
list (APPEND _args "${${_flags}}")
string (TOUPPER "CMAKE_${language}_FLAGS_${CMAKE_BUILD_TYPE}" _flags)
list (APPEND _args "${${_flags}}")
# assume that we are always generating position-independent code
# when compiling for a shared library
if (type STREQUAL "SHARED_LIBRARY")
list (APPEND _args "${CMAKE_SHARED_LIBRARY_${language}_FLAGS}")
endif (type STREQUAL "SHARED_LIBRARY")
# directories included
get_directory_property (_dirs INCLUDE_DIRECTORIES)
foreach (_dir ${_dirs})
list (APPEND _args "-I${_dir}")
endforeach (_dir)
# make arguments a real list, and write to output variable
separate_arguments (_args)
set (${args_name} "${_args}" PARENT_SCOPE)
endfunction (compiler_cmdline language type cmd_name args_name)
function (precompile_header
language type hdr_kw header tgt_kw target flgs_kw flags_name)
# check "syntax"
if (NOT hdr_kw STREQUAL "HEADER")
message (FATAL "Third token to precompile_header shoulde be \"HEADER\"")
endif (NOT hdr_kw STREQUAL "HEADER")
if (NOT tgt_kw STREQUAL "TARGET")
message (FATAL "Fifth token to precompile_header should be \"TARGET\"")
endif (NOT tgt_kw STREQUAL "TARGET")
if (NOT flgs_kw STREQUAL "FLAGS")
message (FATAL "Seventh token to precompile_header should be \"FLAGS\"")
endif (NOT flgs_kw STREQUAL "FLAGS")
# check language
if (language STREQUAL "CXX")
set (gcc_lang "c++-header")
elseif (language STREQUAL "C")
set (gcc_lang "c-header")
else (language STREQUAL "CXX")
message (FATAL "Only C or C++ can have precompiled headers")
endif (language STREQUAL "CXX")
# if no precompiled header was found, then we shouldn't do anything here
if (NOT header)
return ()
endif (NOT header)
# only support precompiled headers if the compiler is gcc >= 3.4
get_gcc_version (${language} GCC_VERSION)
if (GCC_VERSION)
if (GCC_VERSION VERSION_EQUAL 3.4 OR GCC_VERSION VERSION_GREATER 3.4)
# command-line used to compile modules in this kind of target
compiler_cmdline (${language} ${type} _cmd _args)
# gcc will include any configurations which are in a directory
# with the same name as the header included
set (_pch_dir "CMakeFiles/pch")
set (_pch_file "${_pch_dir}/${header}.gch/${target}")
# make sure that output directory exists
get_filename_component (_outdir "${PROJECT_BINARY_DIR}/${_pch_file}" PATH)
file (MAKE_DIRECTORY ${_outdir})
# we need to generate the precompiled header in the output tree, but
# at the same time prevent the compiler to pick up the header from the
# source tree. getting the order of the include paths right is fragile
# in CMake. by copying the header, we can put the precompile dump
# right next to it and have the compiler pick it up there
add_custom_command (
OUTPUT "${_pch_dir}/${header}"
COMMAND ${CMAKE_COMMAND}
ARGS -E copy "${PROJECT_SOURCE_DIR}/${header}" "${_pch_dir}/${header}"
DEPENDS "${PROJECT_SOURCE_DIR}/${header}"
)
# add a makefile rule to create the precompiled header
add_custom_command (
OUTPUT ${PROJECT_BINARY_DIR}/${_pch_file}
COMMAND ${_cmd}
ARGS ${_args} "-o" "${_pch_file}" "-x" "${gcc_lang}" "-c" "${_pch_dir}/${header}"
DEPENDS "${_pch_dir}/${header}"
COMMENT "Precompiling headers ${_pch_file}"
)
# create a phony target that is always built, but which only checks
# if the header file is OK (i.e. the header only gets rebuilt if
# necessary)
add_custom_target (${target} ALL
DEPENDS ${PROJECT_BINARY_DIR}/${_pch_file}
)
# these flags need to be added to the target
set (${target} "${_pch_file}" PARENT_SCOPE)
set (${flags_name} "-Winvalid-pch -include ${_pch_dir}/${header}" PARENT_SCOPE)
endif (GCC_VERSION VERSION_EQUAL 3.4 OR GCC_VERSION VERSION_GREATER 3.4)
endif (GCC_VERSION)
endfunction (precompile_header
language type header tgt_kw target flgs_kw flags_name)

View File

@@ -0,0 +1,50 @@
# - Print CMake and OS distribution version
#
function (system_info)
message (STATUS "CMake version: ${CMAKE_VERSION}")
if (CMAKE_SYSTEM MATCHES "Linux")
distro_name (DISTRO_NAME)
message (STATUS "Linux distribution: ${DISTRO_NAME}")
else (CMAKE_SYSTEM MATCHES "Linux")
message (STATUS "Operating system: ${CMAKE_SYSTEM}")
endif (CMAKE_SYSTEM MATCHES "Linux")
endfunction (system_info)
# probe various system files that may be found
function (distro_name varname)
file (GLOB has_os_release /etc/os-release)
file (GLOB has_lsb_release /etc/lsb-release)
file (GLOB has_sys_release /etc/system-release)
# start with /etc/os-release,
# see <http://0pointer.de/blog/projects/os-release.html>
if (NOT has_os_release STREQUAL "")
read_release (PRETTY_NAME FROM /etc/os-release INTO _descr)
# previous "standard", used on older Ubuntu and Debian
elseif (NOT has_lsb_release STREQUAL "")
read_release (DISTRIB_DESCRIPTION FROM /etc/lsb-release INTO _descr)
# RHEL/CentOS etc. has just a text-file
elseif (NOT has_sys_release STREQUAL "")
file (READ /etc/system-release _descr)
else (NOT has_lsb_release STREQUAL "")
# no yet known release file found
set (_descr "unknown")
endif (NOT has_os_release STREQUAL "")
# return from function (into appropriate variable)
string (STRIP "${_descr}" _descr)
set (${varname} "${_descr}" PARENT_SCOPE)
endfunction (distro_name varname)
# read property from the newer /etc/os-release
function (read_release valuename FROM filename INTO varname)
file (STRINGS ${filename} _distrib
REGEX "^${valuename}="
)
string (REGEX REPLACE
"^${valuename}=\"?\(.*\)" "\\1" ${varname} ${_distrib}
)
# remove trailing quote that got globbed by the wildcard (greedy match)
string (REGEX REPLACE
"\"$" "" ${varname} "${${varname}}"
)
set (${varname} "${${varname}}" PARENT_SCOPE)
endfunction (read_release valuename FROM filename INTO varname)

View File

@@ -0,0 +1,102 @@
# - Get version control information from source tree
#
# Sets the following variables
#
# VCS_SYSTEM Currently, this will only be "git", or empty if
# no source code control system is found.
#
# VCS_SHA1 Hash code of the last commit. If this is empty,
# then no source code repository was found.
#
# VCS_DECOR Characters that denotes any local modifications:
# "*" - Unstaged local changes
# "+" - Staged, but not committed, local changes
# "%" - Untracked local files
function (vcs_info)
# if we haven't located git yet, then do it now
if (NOT GIT_FOUND)
find_package (Git)
endif (NOT GIT_FOUND)
# if git is not installed (unpacked tarball), then just state that
# the version practically is unknown
set (VCS_DECOR "")
if (GIT_FOUND)
set (VCS_SYSTEM "git")
# assume that we have a .git subdirectory under the source directory;
# if we have a bare repository, then we won't be able to build in there
# and we won't be able to identify the git dir to use from only a work
# tree, so we handle that like a regular unpacked tarball
# exec_program is used because execute_process is buggy on common
# platforms (notable CMake 2.8.7 in Ubuntu Precise 12.04)
# get hash code
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS rev-parse --short --verify HEAD
OUTPUT_VARIABLE VCS_SHA1
RETURN_VALUE has_sha
)
# exec_program mashes together output and error
if (NOT ${has_sha} EQUAL 0)
set (VCS_SHA1 "")
endif (NOT ${has_sha} EQUAL 0)
# only proceed if we actually found a source tree in there
if (VCS_SHA1)
# check for unstaged local changes
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS diff --no-ext-diff --quiet --exit-code
RETURN_VALUE dirty
OUTPUT_VARIABLE _dummy
)
if (NOT ${dirty} EQUAL 0)
list (APPEND VCS_DECOR "*")
endif (NOT ${dirty} EQUAL 0)
# check for staged local changes
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS diff-index --no-ext-diff --cached --quiet --exit-code HEAD --
RETURN_VALUE staged
OUTPUT_VARIABLE _dummy
)
if (NOT ${staged} EQUAL 0)
list (APPEND VCS_DECOR "+")
endif (NOT ${staged} EQUAL 0)
# check for untracked files
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS ls-files --others --exclude-standard
OUTPUT_VARIABLE untracked
)
if (untracked)
list (APPEND VCS_DECOR "%")
endif (untracked)
# convert list to regular string
string (REPLACE ";" "" VCS_DECOR "${VCS_DECOR}")
endif (VCS_SHA1)
else (GIT_FOUND)
set (VCS_SYSTEM "")
set (VCS_SHA1 "")
set (VCS_DECOR "")
endif (GIT_FOUND)
# diagnostic output
if (VCS_SYSTEM AND VCS_SHA1)
message (STATUS "Source code repository: ${VCS_SYSTEM} ${VCS_SHA1}${VCS_DECOR}")
else (VCS_SYSTEM AND VCS_SHA1)
message (STATUS "Source code repository: not found!")
endif (VCS_SYSTEM AND VCS_SHA1)
# export to parent context
set (VCS_SYSTEM "${VCS_SYSTEM}" PARENT_SCOPE)
set (VCS_SHA1 "${VCS_SHA1}" PARENT_SCOPE)
set (VCS_DECOR "${VCS_DECOR}" PARENT_SCOPE)
endfunction (vcs_info)

View File

@@ -0,0 +1,7 @@
# - Turn on warnings when compiling
include (AddOptions)
if (CMAKE_COMPILER_IS_GNUCXX)
message (STATUS "All warnings enabled: -Wall")
add_options (ALL_LANGUAGES ALL_BUILDS "-Wall")
endif (CMAKE_COMPILER_IS_GNUCXX)

View File

@@ -0,0 +1,61 @@
# This module defines two macros:
# CMAKE_PUSH_CHECK_STATE()
# and
# CMAKE_POP_CHECK_STATE()
# These two macros can be used to save and restore the state of the variables
# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES
# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake,
# like e.g. check_function_exists() etc.
# The variable contents are pushed on a stack, pushing multiple times is supported.
# This is useful e.g. when executing such tests in a Find-module, where they have to be set,
# but after the Find-module has been executed they should have the same value
# as they had before.
#
# Usage:
# cmake_push_check_state()
# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
# check_function_exists(...)
# cmake_pop_check_state()
#=============================================================================
# Copyright 2006-2011 Alexander Neundorf, <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
MACRO(CMAKE_PUSH_CHECK_STATE)
IF(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER)
SET(_CMAKE_PUSH_CHECK_STATE_COUNTER 0)
ENDIF()
MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
ENDMACRO(CMAKE_PUSH_CHECK_STATE)
MACRO(CMAKE_POP_CHECK_STATE)
# don't pop more than we pushed
IF("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
ENDIF()
ENDMACRO(CMAKE_POP_CHECK_STATE)

View File

@@ -0,0 +1,624 @@
# - Find BLAS library
# This module finds an installed fortran library that implements the BLAS
# linear-algebra interface (see http://www.netlib.org/blas/).
# The list of libraries searched for is taken
# from the autoconf macro file, acx_blas.m4 (distributed at
# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
#
# This module sets the following variables:
# BLAS_FOUND - set to true if a library implementing the BLAS interface
# is found
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -L).
# BLAS_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use BLAS
# BLAS95_LIBRARIES - uncached list of libraries (using full path name)
# to link against to use BLAS95 interface
# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
# is found
# BLA_STATIC if set on this determines what kind of linkage we do (static)
# BLA_VENDOR if set checks only the specified vendor, if not set checks
# all the possibilities
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
##########
### List of vendors (BLA_VENDOR) valid in this module
## Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model),
## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic
# C/CXX should be enabled to use Intel mkl
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CheckFunctionExists)
include(CheckFortranFunctionExists)
set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
# Check the language being used
get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES )
if( _LANGUAGES_ MATCHES Fortran )
set( _CHECK_FORTRAN TRUE )
elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) )
set( _CHECK_FORTRAN FALSE )
else()
if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
else(BLAS_FIND_REQUIRED)
message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)")
return()
endif(BLAS_FIND_REQUIRED)
endif( )
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the
# Check_Fortran_Function_Exists macro) whether can link against that library
# combination using the name of a routine given by _name using the linker
# flags given by _flags. If the combination of libraries is found and passes
# the link test, LIBRARIES is set to the list of complete library paths that
# have been found. Otherwise, LIBRARIES is set to FALSE.
# N.B. _prefix is the prefix applied to the names of all cached variables that
# are generated internally and marked advanced by this macro.
set(_libdir ${ARGN})
set(_libraries_work TRUE)
set(${LIBRARIES})
set(_combined_name)
if (NOT _libdir)
if (WIN32)
set(_libdir ENV LIB)
elseif (APPLE)
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
else ()
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
endif ()
endif ()
foreach(_library ${_list})
set(_combined_name ${_combined_name}_${_library})
if(_libraries_work)
if (BLA_STATIC)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif ( WIN32 )
if (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif (APPLE)
else (BLA_STATIC)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# for ubuntu's libblas3gf and liblapack3gf packages
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
endif ()
endif (BLA_STATIC)
find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS ${_libdir}
)
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
endif(_libraries_work)
endforeach(_library ${_list})
if(_libraries_work)
# Test this combination of libraries.
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads})
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
if (_CHECK_FORTRAN)
check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
else()
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
endif()
set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
endif(_libraries_work)
if(NOT _libraries_work)
set(${LIBRARIES} FALSE)
endif(NOT _libraries_work)
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endmacro(Check_Fortran_Libraries)
set(BLAS_LINKER_FLAGS)
set(BLAS_LIBRARIES)
set(BLAS95_LIBRARIES)
if ($ENV{BLA_VENDOR} MATCHES ".+")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else ($ENV{BLA_VENDOR} MATCHES ".+")
if(NOT BLA_VENDOR)
set(BLA_VENDOR "All")
endif(NOT BLA_VENDOR)
endif ($ENV{BLA_VENDOR} MATCHES ".+")
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"goto2"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
""
"f77blas;atlas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"sgemm;dgemm;blas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
# BLAS in Alpha CXML library?
if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"cxml"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
# BLAS in Alpha DXML library? (now called CXML, see above)
if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"dxml"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
# BLAS in Sun Performance library?
if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
"-xlic_lib=sunperf"
"sunperf;sunmath"
""
)
if(BLAS_LIBRARIES)
set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
endif(BLAS_LIBRARIES)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
# BLAS in SCSL library? (SGI/Cray Scientific Library)
if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"scsl"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
# BLAS in SGIMATH library?
if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"complib.sgimath"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"essl;blas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
#BLAS in acml library?
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
)
# try to find acml in "standard" paths
if( WIN32 )
file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" )
else()
file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" )
endif()
if( WIN32 )
file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" )
else()
file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" )
endif()
list(GET _ACML_ROOT 0 _ACML_ROOT)
list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
if( _ACML_ROOT )
get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH )
if( SIZEOF_INTEGER EQUAL 8 )
set( _ACML_PATH_SUFFIX "_int64" )
else()
set( _ACML_PATH_SUFFIX "" )
endif()
if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
set( _ACML_COMPILER32 "ifort32" )
set( _ACML_COMPILER64 "ifort64" )
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
set( _ACML_COMPILER32 "sun32" )
set( _ACML_COMPILER64 "sun64" )
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
set( _ACML_COMPILER32 "pgi32" )
if( WIN32 )
set( _ACML_COMPILER64 "win64" )
else()
set( _ACML_COMPILER64 "pgi64" )
endif()
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
# 32 bit builds not supported on Open64 but for code simplicity
# We'll just use the same directory twice
set( _ACML_COMPILER32 "open64_64" )
set( _ACML_COMPILER64 "open64_64" )
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
set( _ACML_COMPILER32 "nag32" )
set( _ACML_COMPILER64 "nag64" )
else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
set( _ACML_COMPILER32 "gfortran32" )
set( _ACML_COMPILER64 "gfortran64" )
endif()
if( BLA_VENDOR STREQUAL "ACML_MP" )
set(_ACML_MP_LIB_DIRS
"${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
"${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
else() #if( _BLAS_VENDOR STREQUAL "ACML" )
set(_ACML_LIB_DIRS
"${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
"${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
endif()
endif()
elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
endif()
if( BLA_VENDOR STREQUAL "ACML_MP" )
foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
check_fortran_libraries (
BLAS_LIBRARIES
BLAS
sgemm
"" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
)
if( BLAS_LIBRARIES )
break()
endif()
endforeach()
elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
check_fortran_libraries (
BLAS_LIBRARIES
BLAS
sgemm
"" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
)
if( BLAS_LIBRARIES )
break()
endif()
endforeach()
else() #if( _BLAS_VENDOR STREQUAL "ACML" )
foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} )
check_fortran_libraries (
BLAS_LIBRARIES
BLAS
sgemm
"" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
)
if( BLAS_LIBRARIES )
break()
endif()
endforeach()
endif()
# Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"acml;acml_mv"
""
)
endif(NOT BLAS_LIBRARIES)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"acml_mp;acml_mv"
""
)
endif(NOT BLAS_LIBRARIES)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"acml;acml_mv;CALBLAS"
""
)
endif(NOT BLAS_LIBRARIES)
endif () # ACML
# Apple BLAS library?
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
""
"Accelerate"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT BLAS_LIBRARIES )
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
""
"vecLib"
""
)
endif ( NOT BLAS_LIBRARIES )
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
# Generic BLAS library?
if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"blas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
#BLAS in intel mkl 10 library? (em64t 64bit)
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if (NOT WIN32)
set(LM "-lm")
endif ()
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
find_package(Threads)
else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
find_package(Threads REQUIRED)
endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
if (WIN32)
if(BLA_F95)
if(NOT BLAS95_LIBRARIES)
check_fortran_libraries(
BLAS95_LIBRARIES
BLAS
sgemm
""
"mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40"
""
)
endif(NOT BLAS95_LIBRARIES)
else(BLA_F95)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
SGEMM
""
"mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40"
""
)
endif(NOT BLAS_LIBRARIES)
endif(BLA_F95)
else(WIN32)
if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
if(BLA_F95)
if(NOT BLAS95_LIBRARIES)
check_fortran_libraries(
BLAS95_LIBRARIES
BLAS
sgemm
""
"mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS95_LIBRARIES)
else(BLA_F95)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_intel;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT}"
"${LM}"
)
endif(NOT BLAS_LIBRARIES)
endif(BLA_F95)
endif (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
if(BLA_F95)
if(NOT BLAS95_LIBRARIES)
check_fortran_libraries(
BLAS95_LIBRARIES
BLAS
sgemm
""
"mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS95_LIBRARIES)
else(BLA_F95)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
endif(BLA_F95)
endif (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
endif (WIN32)
#older vesions of intel mkl libs
# BLAS in intel mkl library? (shared)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
#BLAS in intel mkl library? (static, 32bit)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_ia32;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
#BLAS in intel mkl library? (static, em64t 64bit)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_em64t;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if(BLA_F95)
if(BLAS95_LIBRARIES)
set(BLAS95_FOUND TRUE)
else(BLAS95_LIBRARIES)
set(BLAS95_FOUND FALSE)
endif(BLAS95_LIBRARIES)
if(NOT BLAS_FIND_QUIETLY)
if(BLAS95_FOUND)
message(STATUS "A library with BLAS95 API found.")
else(BLAS95_FOUND)
if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with BLAS95 API not found. Please specify library location.")
else(BLAS_FIND_REQUIRED)
message(STATUS
"A library with BLAS95 API not found. Please specify library location.")
endif(BLAS_FIND_REQUIRED)
endif(BLAS95_FOUND)
endif(NOT BLAS_FIND_QUIETLY)
set(BLAS_FOUND TRUE)
set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
else(BLA_F95)
if(BLAS_LIBRARIES)
set(BLAS_FOUND TRUE)
else(BLAS_LIBRARIES)
set(BLAS_FOUND FALSE)
endif(BLAS_LIBRARIES)
if(NOT BLAS_FIND_QUIETLY)
if(BLAS_FOUND)
message(STATUS "A library with BLAS API found.")
else(BLAS_FOUND)
if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with BLAS API not found. Please specify library location."
)
else(BLAS_FIND_REQUIRED)
message(STATUS
"A library with BLAS API not found. Please specify library location."
)
endif(BLAS_FIND_REQUIRED)
endif(BLAS_FOUND)
endif(NOT BLAS_FIND_QUIETLY)
endif(BLA_F95)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})

View File

@@ -0,0 +1,307 @@
# - Find LAPACK library
# This module finds an installed fortran library that implements the LAPACK
# linear-algebra interface (see http://www.netlib.org/lapack/).
#
# The approach follows that taken for the autoconf macro file, acx_lapack.m4
# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
#
# This module sets the following variables:
# LAPACK_FOUND - set to true if a library implementing the LAPACK interface
# is found
# LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -L).
# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK
# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK95
# LAPACK95_FOUND - set to true if a library implementing the LAPACK f95
# interface is found
# BLA_STATIC if set on this determines what kind of linkage we do (static)
# BLA_VENDOR if set checks only the specified vendor, if not set checks
# all the possibilities
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
### List of vendors (BLA_VENDOR) valid in this module
## Intel(mkl), ACML,Apple, NAS, Generic
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
if (NOT _LANGUAGES_ MATCHES Fortran)
include(CheckFunctionExists)
else (NOT _LANGUAGES_ MATCHES Fortran)
include(CheckFortranFunctionExists)
endif (NOT _LANGUAGES_ MATCHES Fortran)
set(LAPACK_FOUND FALSE)
set(LAPACK95_FOUND FALSE)
# TODO: move this stuff to separate module
macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the
# Check_Fortran_Function_Exists macro) whether can link against that library
# combination using the name of a routine given by _name using the linker
# flags given by _flags. If the combination of libraries is found and passes
# the link test, LIBRARIES is set to the list of complete library paths that
# have been found. Otherwise, LIBRARIES is set to FALSE.
# N.B. _prefix is the prefix applied to the names of all cached variables that
# are generated internally and marked advanced by this macro.
set(_libraries_work TRUE)
set(${LIBRARIES})
set(_combined_name)
if (NOT _libdir)
if (WIN32)
set(_libdir ENV LIB)
elseif (APPLE)
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
else ()
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
endif ()
endif ()
foreach(_library ${_list})
set(_combined_name ${_combined_name}_${_library})
if(_libraries_work)
if (BLA_STATIC)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif ( WIN32 )
if (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif (APPLE)
else (BLA_STATIC)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# for ubuntu's libblas3gf and liblapack3gf packages
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
endif ()
endif (BLA_STATIC)
find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS ${_libdir}
)
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
endif(_libraries_work)
endforeach(_library ${_list})
if(_libraries_work)
# Test this combination of libraries.
if(UNIX AND BLA_STATIC)
set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads})
else(UNIX AND BLA_STATIC)
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads})
endif(UNIX AND BLA_STATIC)
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
if (NOT _LANGUAGES_ MATCHES Fortran)
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
else (NOT _LANGUAGES_ MATCHES Fortran)
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
endif (NOT _LANGUAGES_ MATCHES Fortran)
set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endif(_libraries_work)
if(_libraries_work)
set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
else(_libraries_work)
set(${LIBRARIES} FALSE)
endif(_libraries_work)
endmacro(Check_Lapack_Libraries)
set(LAPACK_LINKER_FLAGS)
set(LAPACK_LIBRARIES)
set(LAPACK95_LIBRARIES)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(BLAS)
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(BLAS REQUIRED)
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if(BLAS_FOUND)
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
if ($ENV{BLA_VENDOR} MATCHES ".+")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else ($ENV{BLA_VENDOR} MATCHES ".+")
if(NOT BLA_VENDOR)
set(BLA_VENDOR "All")
endif(NOT BLA_VENDOR)
endif ($ENV{BLA_VENDOR} MATCHES ".+")
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"goto2"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
#acml lapack
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
if (BLAS_LIBRARIES MATCHES ".+acml.+")
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif ()
endif ()
# Apple LAPACK library?
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"Accelerate"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"vecLib"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
# Generic LAPACK library?
if (BLA_VENDOR STREQUAL "Generic" OR
BLA_VENDOR STREQUAL "ATLAS" OR
BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"lapack"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif ()
#intel lapack
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_PACKAGE(Threads)
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(Threads REQUIRED)
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if (BLA_F95)
if(NOT LAPACK95_LIBRARIES)
check_lapack_libraries(
LAPACK95_LIBRARIES
LAPACK
cheev
""
"mkl_lapack95"
"${BLAS95_LIBRARIES}"
"${CMAKE_THREAD_LIBS_INIT}"
)
endif(NOT LAPACK95_LIBRARIES)
else(BLA_F95)
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"mkl_lapack"
"${BLAS_LIBRARIES}"
"${CMAKE_THREAD_LIBS_INIT}"
)
endif(NOT LAPACK_LIBRARIES)
endif(BLA_F95)
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
endif(BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
else(BLAS_FOUND)
message(STATUS "LAPACK requires BLAS")
endif(BLAS_FOUND)
if(BLA_F95)
if(LAPACK95_LIBRARIES)
set(LAPACK95_FOUND TRUE)
else(LAPACK95_LIBRARIES)
set(LAPACK95_FOUND FALSE)
endif(LAPACK95_LIBRARIES)
if(NOT LAPACK_FIND_QUIETLY)
if(LAPACK95_FOUND)
message(STATUS "A library with LAPACK95 API found.")
else(LAPACK95_FOUND)
if(LAPACK_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with LAPACK95 API not found. Please specify library location."
)
else(LAPACK_FIND_REQUIRED)
message(STATUS
"A library with LAPACK95 API not found. Please specify library location."
)
endif(LAPACK_FIND_REQUIRED)
endif(LAPACK95_FOUND)
endif(NOT LAPACK_FIND_QUIETLY)
set(LAPACK_FOUND "${LAPACK95_FOUND}")
set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
else(BLA_F95)
if(LAPACK_LIBRARIES)
set(LAPACK_FOUND TRUE)
else(LAPACK_LIBRARIES)
set(LAPACK_FOUND FALSE)
endif(LAPACK_LIBRARIES)
if(NOT LAPACK_FIND_QUIETLY)
if(LAPACK_FOUND)
message(STATUS "A library with LAPACK API found.")
else(LAPACK_FOUND)
if(LAPACK_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with LAPACK API not found. Please specify library location."
)
else(LAPACK_FIND_REQUIRED)
message(STATUS
"A library with LAPACK API not found. Please specify library location."
)
endif(LAPACK_FIND_REQUIRED)
endif(LAPACK_FOUND)
endif(NOT LAPACK_FIND_QUIETLY)
endif(BLA_F95)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})

View File

@@ -0,0 +1,25 @@
# - Emulate a rule to patch the Makefile, adding a line to the source
# tree and write a marker file indicating it is done.
set (base_dir ".")
set (marker_file "${base_dir}/CMakeFiles/marker")
set (makefile "${base_dir}/Makefile")
# if the Makefile has changed, then update it
if ("${makefile}" IS_NEWER_THAN "${marker_file}")
# only add the string once, so it does not return multiple
# results for the command line (will lead to syntax error)
file (STRINGS "${makefile}" abs_top_srcdir_FOUND
REGEX "^abs_top_srcdir = "
)
if (NOT abs_top_srcdir_FOUND)
file (APPEND "${makefile}"
"abs_top_srcdir = ${CMAKE_HOME_DIRECTORY}\n"
)
endif (NOT abs_top_srcdir_FOUND)
# touch the marker so that we won't update the Makefile again
execute_process (COMMAND
${CMAKE_COMMAND} -E touch "${marker_file}"
)
endif ("${makefile}" IS_NEWER_THAN "${marker_file}")

View File

@@ -0,0 +1,15 @@
# - Remove a directory if and only if it contains no files
#
# Pass the name of the directory as the DIR variable
if (DIR)
# check if empty
file (GLOB_RECURSE files "${DIR}/*")
# remove only if
if (NOT files)
execute_process (COMMAND
${CMAKE_COMMAND} -E remove_directory "${DIR}"
)
endif (NOT files)
endif (DIR)

1663
cmake/Templates/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

41
cmake/Templates/la.in Normal file
View File

@@ -0,0 +1,41 @@
# lib@target@.la - a libtool library file
# Generated by libtool (GNU libtool) @ltversion@
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='@dlname@'
# Names of this library.
library_names='@library_names@'
# The name of the static archive.
old_library='@old_library@'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags='@inherited_linker_flags@'
# Libraries that this one depends upon.
dependency_libs='@dependency_libs@'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for lib@target@.
current=@current@
age=@age@
revision=0
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='@libdir@'

View File

@@ -0,0 +1,28 @@
# - CMake version file for @opm-project_NAME@
#
# Determine if requested version matches exactly or is compatible with
# the installed package. It sets the following variables:
#
# PACKAGE_VERSION Full provided version string
# PACKAGE_VERSION_COMPATIBLE True if version is compatible
# PACKAGE_VERSION_EXACT True if version is exact match
# This file is used by find_package to see if the installed version of a
# package can be used by the client, before the main -config.cmake file
# is loaded.
# see <http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Package_Version_Files>
# this is the version that is installed
set (PACKAGE_VERSION @opm-project_VERSION@)
# if we wanted this exact version, then everything's fine
if (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
set (PACKAGE_VERSION_EXACT TRUE)
endif (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
# in general, we assume that there is going to be API breakage between
# released versions; this will hopefully change in the future
## compatible versions
#if (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
# set (PACKAGE_VERSION_COMPATIBLE TRUE)
#endif (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)

View File

@@ -0,0 +1,62 @@
# - @opm-project_DESCRIPTION@ config mode
#
# Defines the following variables:
# @opm-project_NAME@_FOUND - true
# @opm-project_NAME@_VERSION - version of the @opm-project_NAME@ library found, e.g. 0.2
# @opm-project_NAME@_DEFINITIONS - defines to be made on the command line
# @opm-project_NAME@_INCLUDE_DIRS - header directories with which to compile
# @opm-project_NAME@_LINKER_FLAGS - flags that must be passed to the linker
# @opm-project_NAME@_LIBRARIES - names of the libraries with which to link
# @opm-project_NAME@_LIBRARY_DIRS - directories in which the libraries are situated
#
# You should put lines like this in your CMakeLists.txt
# set (@opm-project_NAME@_DIR "${PROJECT_BINARY_DIR}/../@opm-project_NAME@" CACHE LOCATION "Build tree of @opm-project_NAME@")
# find_package (@opm-project_NAME@)
# configure_vars (
# FILE CXX "${PROJECT_BINARY_DIR}/config.h"
# WRITE ${@opm-project_NAME@_CONFIG_VARS}
# )
# <http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file>
# propagate these properties from one build system to the other
set (@opm-project_NAME@_VERSION "@opm-project_VERSION@")
set (@opm-project_NAME@_DEFINITIONS "@opm-project_DEFINITIONS@")
set (@opm-project_NAME@_INCLUDE_DIRS "@opm-project_INCLUDE_DIRS@")
set (@opm-project_NAME@_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
set (@opm-project_NAME@_LINKER_FLAGS "@opm-project_LINKER_FLAGS@")
set (@opm-project_NAME@_CONFIG_VARS "@opm-project_CONFIG_VARS@")
# libraries come from the build tree where this file was generated
set (@opm-project_NAME@_LIBRARY "@opm-project_LIBRARY@")
set (@opm-project_NAME@_LIBRARIES ${@opm-project_NAME@_LIBRARY} "@opm-project_LIBRARIES@")
mark_as_advanced (@opm-project_NAME@_LIBRARY)
# add the library as a target, so that other things in the project including
# this file may depend on it and get rebuild if this library changes.
add_library (@opm-project_TARGET@ UNKNOWN IMPORTED)
set_property (TARGET @opm-project_TARGET@ PROPERTY IMPORTED_LOCATION "${@opm-project_NAME@_LIBRARY}")
# ensure that we build with support for C++11 to preserve ABI
string (REPLACE "@CXX_STD0X_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
set (CMAKE_CXX_FLAGS "@CXX_STD0X_FLAGS@ ${CMAKE_CXX_FLAGS}")
# same as above, but for C99
string (REPLACE "@C_STD99_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
set (CMAKE_C_FLAG "@C_STD99_FLAGS@ ${CMAKE_C_FLAGS}")
# build with OpenMP if that was found
if (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
string (REPLACE "@OpenMP_C_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
set (CMAKE_C_FLAG "@OpenMP_C_FLAGS@ ${CMAKE_C_FLAGS}")
endif (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
if (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
string (REPLACE "@OpenMP_CXX_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
set (CMAKE_C_FLAG "@OpenMP_CXX_FLAGS@ ${CMAKE_CXX_FLAGS}")
endif (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
# this is the contents of config.h as far as our probes can tell:

View File

@@ -0,0 +1,13 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
CXX=@CMAKE_CXX_COMPILER@ @CXX_STD0X_FLAGS@ @OpenMP_CXX_FLAGS@
CC=@CMAKE_C_COMPILER@ @C_STD99_FLAGS@ @OpenMP_C_FLAGS@
DEPENDENCIES=
Name: @name@
Description: @description@ @major@.@minor@
Version: @major@.@minor@
URL: http://opm-project.org
Libs: -l@target@ @libs@
Cflags: @includes@ @defs@

261
configure vendored Executable file
View File

@@ -0,0 +1,261 @@
#!/bin/bash
# where is the source tree located
srcdir=$(dirname "$0")
# display help text
usage () {
cat <<EOF
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]. Note: set DESTDIR=PATH when doing
\`make install' to install to a different sysroot.
Optional Features:
--disable-FEATURE do not include FEATURE
--disable-gxx11check do not try flag -std=c++11 to enable C++11 features
--enable-shared build a shared library [default=yes]
--enable-static build a static library [default=no]. Note: only one
of the options shared and static may be built.
--disable-debug build a release version of the library [default=no]
--disable-pch do not use precompiled headers (if buggy compiler)
--disable-silent-rules print every compilation statement as executed
--enable-system-debug put .debug files in global GDB debug dir
[default=yes if prefix=/usr, no otherwise]
--disable-option-checking ignore unrecognized --enable/--with options
Optional Packages:
--with-boost=PATH use Boost library from a specified location
--with-dune-MODULE=PATH use given DUNE module from a specified location
--with-opm-MODULE=PATH use given OPM module from a specified location
--with-cmake=PROGRAM use this program instead of \`cmake' to configure
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CXXCPP C++ preprocessor
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
FC Fortran compiler command
FCFLAGS Fortran compiler flags
CMAKE_COMMAND Executable used to run cmake scripts
Use these variables to override the choices made by \`configure' or to help
it to find libraries and programs with nonstandard names/locations.
EOF
}
# report an error regarding the arguments
invalid_arg () {
cat <<EOF
configure: error: unrecognized option: \`$1'
Try \`$0 --help' for more information
EOF
}
# notify the user that this argument is not known
unknown_arg () {
cat <<EOF
configure: warning: unrecognized option: \`$1'
EOF
}
# warn only if option checking is enabled
invalid_opt () {
if [ "${option_check}" = "yes" ]; then
unknown_arg $@
fi
}
# default values
prefix=/usr/local
buildtype=Debug
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
pch_use=
#use_openmp=" -DUSE_OPENMP=OFF"
use_openmp=
use_mpi=
#silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=OFF"
silent_rules=
#debug_loc=" -DSYSTEM_DEBUG=OFF"
debug_loc=
# default is to warn for unknown options, but this can be disabled
option_check=yes
# this variable will get feature options
FEATURES=
# this array will get all variable assignments from command-line
VARS=()
# command that launches cmake; look for 2.8 if available
if [ "${CMAKE_COMMAND}" = "" ]; then
if which cmake28 >/dev/null 2>&1; then
CMAKE_COMMAND=cmake28
else
CMAKE_COMMAND=cmake
fi
fi
for OPT in "$@"; do
case "$OPT" in
--*)
OPTARG=${OPT#--}
# OPTARG now contains everything after double dashes
case "${OPTARG}" in
prefix=*)
# remove prefix consisting of everything up to equal sign
prefix=${OPTARG#*=}
;;
help)
usage
exit 0
;;
with-*)
# get the name of the package; everything before equal sign
pkgname=${OPTARG%=*}
pkgname=${pkgname#with-}
# get the location of the package; everyhing after equal sign
pkgloc=${OPTARG#*=}
# the parameter to this option is an executable program, so
# skip the directory test in that case
if [ "${pkgname}" = "cmake" ]; then
CMAKE_COMMAND="${pkgloc}"
break
fi
# tilde expansion; quote safely before running eval on it
eval pkgloc=$(printf "%q" "${pkgloc}")
# expand to full path since CMake changes to source directory (!)
# this also normalize the path name wrt. not having a trailing slash
test -d "${pkgloc}" && pkgloc=$(sh -c "cd \"${pkgloc}\"; pwd")
# add this to the list of existing features
test -n "${rootvar}" && \
FEATURES="${FEATURES} \"-D${rootvar}=${pkgloc}\""
;;
without-* | \
disable-*)
# get the name of the package
pkgname=$OPTARG
pkgname=${pkgname#disable-}
pkgname=${pkgname#without-}
# casing is of course different
case "${pkgname}" in
option-checking)
option_check=no
# special flag: don't disable any particular package
pkgname=""
;;
debug)
buildtype=Release
# special flag: don't disable any particular package
pkgname=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF"
pkgname=""
;;
silent-rules)
silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=ON"
pkgname=""
;;
system-debug)
debug_loc=" -DSYSTEM_DEBUG=OFF"
pkgname=""
;;
gxx11check)
pkgname="CXX11Features"
;;
*)
invalid_opt --disable-${pkgname}
pkgname=""
;;
esac
# only disable packages if the flag refers to a proper one
test -n "${pkgname}" && \
FEATURES="${FEATURES} -DCMAKE_DISABLE_FIND_PACKAGE_${pkgname}=TRUE"
;;
enable-*)
# what kind of library are we building; shared or static?
kind=${OPTARG#enable-}
case "${kind}" in
system-debug)
debug_loc=" -DSYSTEM_DEBUG=ON"
# special flag; don't set shared/static
shared=""
;;
openmp)
use_openmp=" -DUSE_OPENMP=ON"
# special flag; don't set shared/static
shared=""
;;
parallel)
use_openmp=" -DUSE_MPI=ON"
# special flag; don't set shared/static
shared=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
shared=""
;;
# this flag is just for compatibility with the deprecation
# flag in DUNE, so we can build without warnings
fieldvector-size-is-method)
shared=""
;;
shared)
shared="ON"
;;
static)
shared="OFF"
;;
*)
invalid_opt --enable-${kind}
shared=""
;;
esac
test -n "${shared}" && \
FEATURES="${FEATURES} -DBUILD_SHARED_LIBS:BOOL=${shared}"
;;
*)
# remove everything *after* the equal sign
arg=${OPTARG%=*}
invalid_arg --$arg
exit 1
;;
esac
;;
[A-Za-z0-9_]*=*)
# collect for further processing later
VARS+=("$OPT")
;;
*)
invalid_arg $OPT
exit 1
;;
esac
done
# remove all arguments processed by getopts
shift $((OPTIND-1))
# remove Autotools-specific variables. notice the usage of a quoted
# array: each element will be returned even with spaces.
for a in "${VARS[@]}"; do
a="${a/ACLOCAL_*=*/}"
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
done
# pass everything on to CMake
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi} ${FEATURES}"
echo --- calling CMake ---
echo ${CMDLINE}
eval exec ${CMDLINE}

15
dune.module Normal file
View File

@@ -0,0 +1,15 @@
################################
# Dune module information file: This file gets parsed by dunecontrol
# and by the CMake build scripts.
################################
#Name of the module
Module: opm-material
Description: This module contains the thermodynamic framework used by OPM
Version: 0.1
Url: http://opm-project.org
Maintainer: opm@opm-project.org
MaintainerName: The Open Porous Media Initiative
# the material laws need the tri-diagonal matrix from dune-istl.
# TODO: add this kind of code to a new module (e.g., 'opm-common')
Depends: dune-common dune-istl

View File

@@ -0,0 +1,162 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \copydoc Opm::DynamicTabulated2DFunction
*/
#ifndef OPM_DYNAMIC_TABULATED_2D_FUNCTION_HH
#define OPM_DYNAMIC_TABULATED_2D_FUNCTION_HH
#include <opm/common/exceptions.hh>
#include <opm/common/tabulated2dfunction.hh>
#include <vector>
#include <assert.h>
namespace Opm {
/*!
* \copydoc Opm::Tabulated2DFunction
*
* This class can be used when the sampling points are calculated at
* run time.
*/
template <class Scalar>
class DynamicTabulated2DFunction
: public Tabulated2DFunction<Scalar, DynamicTabulated2DFunction<Scalar> >
{
public:
DynamicTabulated2DFunction()
{ }
/*!
* \brief Constructor where the tabulation parameters are already
* provided.
*/
DynamicTabulated2DFunction(Scalar xMin, Scalar xMax, int m,
Scalar yMin, Scalar yMax, int n)
{
resize(xMin, xMax, m, yMin, yMax, n);
}
/*!
* \brief Resize the tabulation to a new range.
*/
void resize(Scalar xMin, Scalar xMax, int m,
Scalar yMin, Scalar yMax, int n)
{
samples_.resize(m*n);
m_ = m;
n_ = n;
xMin_ = xMin;
xMax_ = xMax;
yMin_ = yMin;
yMax_ = yMax;
}
/*!
* \brief Returns the minimum of the X coordinate of the sampling points.
*/
Scalar xMin() const
{ return xMin_; }
/*!
* \brief Returns the maximum of the X coordinate of the sampling points.
*/
Scalar xMax() const
{ return xMax_; }
/*!
* \brief Returns the minimum of the Y coordinate of the sampling points.
*/
Scalar yMin() const
{ return yMin_; }
/*!
* \brief Returns the maximum of the Y coordinate of the sampling points.
*/
Scalar yMax() const
{ return yMax_; }
/*!
* \brief Returns the number of sampling points in X direction.
*/
int numX() const
{ return m_; }
/*!
* \brief Returns the number of sampling points in Y direction.
*/
int numY() const
{ return n_; }
/*!
* \brief Get the value of the sample point which is at the
* intersection of the \f$i\f$-th interval of the x-Axis
* and the \f$j\f$-th of the y-Axis.
*/
Scalar getSamplePoint(int i, int j) const
{
assert(0 <= i && i < m_);
assert(0 <= j && j < n_);
return samples_[j*m_ + i];
}
/*!
* \brief Set the value of the sample point which is at the
* intersection of the \f$i\f$-th interval of the x-Axis
* and the \f$j\f$-th of the y-Axis.
*/
void setSamplePoint(int i, int j, Scalar value)
{
assert(0 <= i && i < m_);
assert(0 <= j && j < n_);
samples_[j*m_ + i] = value;
}
private:
// the vector which contains the values of the sample points
// f(x_i, y_j). don't use this directly, use getSamplePoint(i,j)
// instead!
std::vector<Scalar> samples_;
// the number of sample points in x direction
int m_;
// the number of sample points in y direction
int n_;
// the range of the tabulation on the x axis
Scalar xMin_;
Scalar xMax_;
// the range of the tabulation on the y axis
Scalar yMin_;
Scalar yMax_;
};
}
#endif

77
opm/common/exceptions.hh Normal file
View File

@@ -0,0 +1,77 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2008-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Some exceptions thrown by opm-material.
*/
#ifndef OPM_EXCEPTIONS_HH
#define OPM_EXCEPTIONS_HH
#include <dune/common/exceptions.hh>
#include <string>
namespace Opm {
/*!
* \ingroup Exception
* \brief Exception thrown if a fixable numerical problem occurs.
*
* (e.g. time step too big, etc.)
*/
class NumericalProblem : public Dune::Exception
{
public:
// copy constructor
NumericalProblem(const NumericalProblem &v)
: Dune::Exception(v)
{}
// default constructor
NumericalProblem()
{}
// constructor with error message
NumericalProblem(const std::string &s)
{ this->message(s); }
};
/*!
* \ingroup Exception
* \brief Exception thrown if a run-time parameter is not specified correctly.
*/
class ParameterException : public Dune::Exception
{
public:
// copy constructor
ParameterException(const ParameterException &v)
: Dune::Exception(v)
{}
// default constructor
ParameterException()
{}
// constructor with error message
ParameterException(const std::string &s)
{ this->message(s); }
};
} // namespace Opm
#endif

View File

@@ -0,0 +1,412 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2010-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \copydoc Opm::FixedLengthSpline_
*/
#ifndef OPM_FIXED_LENGTH_SPLINE_HH
#define OPM_FIXED_LENGTH_SPLINE_HH
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/btdmatrix.hh>
#include "splinecommon_.hh"
namespace Opm
{
/*!
* \brief The common code for all 3rd order polynomial splines with
* more than two sampling points.
*/
template<class ScalarT, int nSamples>
class FixedLengthSpline_
: public SplineCommon_<ScalarT,
FixedLengthSpline_<ScalarT, nSamples> >
{
friend class SplineCommon_<ScalarT, FixedLengthSpline_<ScalarT, nSamples> >;
typedef ScalarT Scalar;
typedef Dune::FieldVector<Scalar, nSamples> Vector;
typedef Dune::BlockVector<Dune::FieldVector<Scalar, 1> > BlockVector;
typedef Dune::BTDMatrix<Dune::FieldMatrix<Scalar, 1, 1> > BTDMatrix;
protected:
FixedLengthSpline_()
: m_(nSamples)
{}
public:
/*!
* \brief Returns the number of sampling points.
*/
size_t numSamples() const
{ return nSamples; }
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
// Full splines //
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using C-style arrays.
*
* This method uses separate array-like objects for the values of
* the X and Y coordinates. In this context 'array-like' means
* that an access to the members is provided via the []
* operator. (e.g. C arrays, std::vector, std::array, etc.) Each
* array must be of size 'numberSamples' at least. Also, the number of
* sampling points must be larger than 1.
*/
template <class ScalarArrayX, class ScalarArrayY>
void setXYArrays(size_t numberSamples,
const ScalarArrayX &x,
const ScalarArrayY &y,
Scalar m0, Scalar m1)
{
assert(numberSamples == numSamples());
for (size_t i = 0; i < numberSamples; ++i) {
xPos_[i] = x[i];
yPos_[i] = y[i];
}
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using STL-compatible containers.
*
* This method uses separate STL-compatible containers for the
* values of the sampling points' X and Y
* coordinates. "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class ScalarContainerX, class ScalarContainerY>
void setXYContainers(const ScalarContainerX &x,
const ScalarContainerY &y,
Scalar m0, Scalar m1)
{
assert(x.size() == y.size());
assert(x.size() == numSamples());
std::copy(x.begin(), x.end(), xPos_.begin());
std::copy(y.begin(), y.end(), yPos_.begin());
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using a C-style array.
*
* This method uses a single array of sampling points, which are
* seen as an array-like object which provides access to the X and
* Y coordinates. In this context 'array-like' means that an
* access to the members is provided via the [] operator. (e.g. C
* arrays, std::vector, std::array, etc.) The array containing
* the sampling points must be of size 'numberSamples' at least. Also,
* the number of sampling points must be larger than 1.
*/
template <class PointArray>
void setArrayOfPoints(size_t numberSamples,
const PointArray &points,
Scalar m0,
Scalar m1)
{
// a spline with no or just one sampling points? what an
// incredible bad idea!
assert(numberSamples == numSamples());
for (size_t i = 0; i < numberSamples; ++i) {
xPos_[i] = points[i][0];
yPos_[i] = points[i][1];
}
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using a STL-compatible container of
* array-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be array-like objects storing the
* X and Y coordinates. "STL-compatible" means that the container
* provides access to iterators using the begin(), end() methods
* and also provides a size() method. Also, the number of entries
* in the X and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfPoints(const XYContainer &points,
Scalar m0,
Scalar m1)
{
assert(points.size() == numSamples());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++i, ++it) {
xPos_[i] = (*it)[0];
yPos_[i] = (*it)[1];
}
// make a full spline
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using a STL-compatible container of
* tuple-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be tuple-like objects storing the
* X and Y coordinates. "tuple-like" means that the objects
* provide access to the x values via std::get<0>(obj) and to the
* y value via std::get<1>(obj) (e.g. std::tuple or
* std::pair). "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfTuples(const XYContainer &points,
Scalar m0,
Scalar m1)
{
assert(points.size() == numSamples());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++i, ++it) {
xPos_[i] = std::get<0>(*it);
yPos_[i] = std::get<1>(*it);
}
// make a full spline
makeFullSpline_(m0, m1);
}
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
// Natural splines //
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
/*!
* \brief Set the sampling points natural spline using C-style arrays.
*
* This method uses separate array-like objects for the values of
* the X and Y coordinates. In this context 'array-like' means
* that an access to the members is provided via the []
* operator. (e.g. C arrays, std::vector, std::array, etc.) Each
* array must be of size 'numberSamples' at least. Also, the number of
* sampling points must be larger than 1.
*/
template <class ScalarArrayX, class ScalarArrayY>
void setXYArrays(size_t numberSamples,
const ScalarArrayX &x,
const ScalarArrayY &y)
{
assert(numberSamples == numSamples());
for (size_t i = 0; i < numberSamples; ++i) {
xPos_[i] = x[i];
yPos_[i] = y[i];
}
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using
* STL-compatible containers.
*
* This method uses separate STL-compatible containers for the
* values of the sampling points' X and Y
* coordinates. "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class ScalarContainerX, class ScalarContainerY>
void setXYContainers(const ScalarContainerX &x,
const ScalarContainerY &y)
{
assert(x.size() == y.size());
assert(x.size() > 1);
setNumSamples_(x.size());
std::copy(x.begin(), x.end(), xPos_.begin());
std::copy(y.begin(), y.end(), yPos_.begin());
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using a
* C-style array.
*
* This method uses a single array of sampling points, which are
* seen as an array-like object which provides access to the X and
* Y coordinates. In this context 'array-like' means that an
* access to the members is provided via the [] operator. (e.g. C
* arrays, std::vector, std::array, etc.) The array containing
* the sampling points must be of size 'numberSamples' at least. Also,
* the number of sampling points must be larger than 1.
*/
template <class PointArray>
void setArrayOfPoints(int numberSamples,
const PointArray &points)
{
assert(numberSamples == numSamples());
for (int i = 0; i < numberSamples; ++i) {
xPos_[i] = points[i][0];
yPos_[i] = points[i][1];
}
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using a
* STL-compatible container of array-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be array-like objects storing the
* X and Y coordinates. "STL-compatible" means that the container
* provides access to iterators using the begin(), end() methods
* and also provides a size() method. Also, the number of entries
* in the X and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfPoints(const XYContainer &points)
{
assert(points.size() == numSamples());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++ i, ++it) {
xPos_[i] = (*it)[0];
yPos_[i] = (*it)[1];
}
// make a natural spline
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using a
* STL-compatible container of tuple-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be tuple-like objects storing the
* X and Y coordinates. "tuple-like" means that the objects
* provide access to the x values via std::get<0>(obj) and to the
* y value via std::get<1>(obj) (e.g. std::tuple or
* std::pair). "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfTuples(const XYContainer &points)
{
assert(points.size() == numSamples());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++i, ++it) {
xPos_[i] = std::get<0>(*it);
yPos_[i] = std::get<1>(*it);
}
// make a natural spline
makeNaturalSpline_();
}
protected:
/*!
* \brief Create a full spline from the already set sampling points.
*
* Also creates temporary matrix and right hand side vector.
*/
void makeFullSpline_(Scalar m0, Scalar m1)
{
BTDMatrix M(numSamples());
BlockVector d(numSamples());
// create linear system of equations
this->makeFullSystem_(M, d, m0, m1);
// solve for the moments
M.solve(m_, d);
}
/*!
* \brief Create a natural spline from the already set sampling points.
*
* Also creates temporary matrix and right hand side vector.
*/
void makeNaturalSpline_()
{
BTDMatrix M(numSamples());
BlockVector d(numSamples());
// create linear system of equations
this->makeNaturalSystem_(M, d);
// solve for the moments
M.solve(m_, d);
}
/*!
* \brief Returns the x coordinate of the i-th sampling point.
*/
Scalar x_(int i) const
{ return xPos_[i]; }
/*!
* \brief Returns the y coordinate of the i-th sampling point.
*/
Scalar y_(int i) const
{ return yPos_[i]; }
/*!
* \brief Returns the moment (i.e. second derivative) of the
* spline at the i-th sampling point.
*/
Scalar moment_(int i) const
{ return m_[i]; }
Vector xPos_;
Vector yPos_;
BlockVector m_;
};
}
#endif

392
opm/common/math.hh Normal file
View File

@@ -0,0 +1,392 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2010-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Define some often used mathematical functions
*/
#ifndef OPM_MATH_HH
#define OPM_MATH_HH
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <cmath>
#include <algorithm>
namespace Opm
{
/*!
* \ingroup Math
* \brief Calculate the harmonic mean of two scalar values.
*
* \param x The first input value
* \param y The second input value
*/
template <class Scalar>
Scalar harmonicMean(Scalar x, Scalar y)
{
if (x*y <= 0)
return 0;
return (2*x*y)/(x + y);
}
/*!
* \ingroup Math
* \brief Calculate the geometric mean of two scalar values.
*
* \param x The first input value
* \param y The second input value
*/
template <class Scalar>
Scalar geometricMean(Scalar x, Scalar y)
{
if (x*y <= 0)
return 0;
return std::sqrt(x*y)*((x < 0)?-1:1);
}
/*!
* \ingroup Math
* \brief Calculate the harmonic mean of a fixed-size matrix.
*
* This is done by calculating the harmonic mean for each entry
* individually. The result is stored the first argument.
*
* \param K The matrix for storing the result
* \param Ki The first input matrix
* \param Kj The second input matrix
*/
template <class Scalar, int m, int n>
void harmonicMeanMatrix(Dune::FieldMatrix<Scalar, m, n> &K,
const Dune::FieldMatrix<Scalar, m, n> &Ki,
const Dune::FieldMatrix<Scalar, m, n> &Kj)
{
for (int rowIdx=0; rowIdx < m; rowIdx++){
for (int colIdx=0; colIdx< n; colIdx++){
if (Ki[rowIdx][colIdx] != Kj[rowIdx][colIdx]) {
K[rowIdx][colIdx] =
harmonicMean(Ki[rowIdx][colIdx],
Kj[rowIdx][colIdx]);
}
else
K[rowIdx][colIdx] = Ki[rowIdx][colIdx];
}
}
}
/*!
* \ingroup Math
* \brief Invert a linear polynomial analytically
*
* The polynomial is defined as
* \f[ p(x) = a\; x + b \f]
*
* This method Returns the number of solutions which are in the real
* numbers, i.e. 1 except if the slope of the line is 0.
*
* \param sol Container into which the solutions are written
* \param a The coefficient for the linear term
* \param b The coefficient for the constant term
*/
template <class Scalar, class SolContainer>
int invertLinearPolynomial(SolContainer &sol,
Scalar a,
Scalar b)
{
if (a == 0.0)
return 0;
sol[0] = -b/a;
return 1;
}
/*!
* \ingroup Math
* \brief Invert a quadratic polynomial analytically
*
* The polynomial is defined as
* \f[ p(x) = a\; x^2 + + b\;x + c \f]
*
* This method teturns the number of solutions which are in the real
* numbers. The "sol" argument contains the real roots of the parabola
* in order with the smallest root first.
*
* \param sol Container into which the solutions are written
* \param a The coefficient for the quadratic term
* \param b The coefficient for the linear term
* \param c The coefficient for the constant term
*/
template <class Scalar, class SolContainer>
int invertQuadraticPolynomial(SolContainer &sol,
Scalar a,
Scalar b,
Scalar c)
{
// check for a line
if (a == 0.0)
return invertLinearPolynomial(sol, b, c);
// discriminant
Scalar Delta = b*b - 4*a*c;
if (Delta < 0)
return 0; // no real roots
Delta = std::sqrt(Delta);
sol[0] = (- b + Delta)/(2*a);
sol[1] = (- b - Delta)/(2*a);
// sort the result
if (sol[0] > sol[1])
std::swap(sol[0], sol[1]);
return 2; // two real roots
}
//! \cond SKIP_THIS
template <class Scalar, class SolContainer>
void invertCubicPolynomialPostProcess_(SolContainer &sol,
int numSol,
Scalar a,
Scalar b,
Scalar c,
Scalar d)
{
// do one Newton iteration on the analytic solution if the
// precision is increased
for (int i = 0; i < numSol; ++i) {
Scalar x = sol[i];
Scalar fOld = d + x*(c + x*(b + x*a));
Scalar fPrime = c + x*(2*b + x*3*a);
if (fPrime == 0.0)
continue;
x -= fOld/fPrime;
Scalar fNew = d + x*(c + x*(b + x*a));
if (std::abs(fNew) < std::abs(fOld))
sol[i] = x;
}
}
//! \endcond
/*!
* \ingroup Math
* \brief Invert a cubic polynomial analytically
*
* The polynomial is defined as
* \f[ p(x) = a\; x^3 + + b\;x^3 + c\;x + d \f]
*
* This method teturns the number of solutions which are in the real
* numbers. The "sol" argument contains the real roots of the cubic
* polynomial in order with the smallest root first.
*
* \param sol Container into which the solutions are written
* \param a The coefficient for the cubic term
* \param b The coefficient for the quadratic term
* \param c The coefficient for the linear term
* \param d The coefficient for the constant term
*/
template <class Scalar, class SolContainer>
int invertCubicPolynomial(SolContainer *sol,
Scalar a,
Scalar b,
Scalar c,
Scalar d)
{
// reduces to a quadratic polynomial
if (a == 0)
return invertQuadraticPolynomial(sol, b, c, d);
// normalize the polynomial
b /= a;
c /= a;
d /= a;
a = 1;
// get rid of the quadratic term by subsituting x = t - b/3
Scalar p = c - b*b/3;
Scalar q = d + (2*b*b*b - 9*b*c)/27;
if (p != 0.0 && q != 0.0) {
// At this point
//
// t^3 + p*t + q = 0
//
// with p != 0 and q != 0 holds. Introducing the variables u and v
// with the properties
//
// u + v = t and 3*u*v + p = 0
//
// leads to
//
// u^3 + v^3 + q = 0 .
//
// multiplying both sides with u^3 and taking advantage of the
// fact that u*v = -p/3 leads to
//
// u^6 + q*u^3 - p^3/27 = 0
//
// Now, substituting u^3 = w yields
//
// w^2 + q*w - p^3/27 = 0
//
// This is a quadratic equation with the solutions
//
// w = -q/2 + sqrt(q^2/4 + p^3/27) and
// w = -q/2 - sqrt(q^2/4 + p^3/27)
//
// Since w is equivalent to u^3 it is sufficient to only look at
// one of the two cases. Then, there are still 2 cases: positive
// and negative discriminant.
Scalar wDisc = q*q/4 + p*p*p/27;
if (wDisc >= 0) { // the positive discriminant case:
// calculate the cube root of - q/2 + sqrt(q^2/4 + p^3/27)
Scalar u = - q/2 + std::sqrt(wDisc);
if (u < 0) u = - std::pow(-u, 1.0/3);
else u = std::pow(u, 1.0/3);
// at this point, u != 0 since p^3 = 0 is necessary in order
// for u = 0 to hold, so
sol[0] = u - p/(3*u) - b/3;
// does not produce a division by zero. the remaining two
// roots of u are rotated by +- 2/3*pi in the complex plane
// and thus not considered here
invertCubicPolynomialPostProcess_(sol, 1, a, b, c, d);
return 1;
}
else { // the negative discriminant case:
Scalar uCubedRe = - q/2;
Scalar uCubedIm = std::sqrt(-wDisc);
// calculate the cube root of - q/2 + sqrt(q^2/4 + p^3/27)
Scalar uAbs = std::pow(std::sqrt(uCubedRe*uCubedRe + uCubedIm*uCubedIm), 1.0/3);
Scalar phi = std::atan2(uCubedIm, uCubedRe)/3;
// calculate the length and the angle of the primitive root
// with the definitions from above it follows that
//
// x = u - p/(3*u) - b/3
//
// where x and u are complex numbers. Rewritten in polar form
// this is equivalent to
//
// x = |u|*e^(i*phi) - p*e^(-i*phi)/(3*|u|) - b/3 .
//
// Factoring out the e^ terms and subtracting the additional
// terms, yields
//
// x = (e^(i*phi) + e^(-i*phi))*(|u| - p/(3*|u|)) - y - b/3
//
// with
//
// y = - |u|*e^(-i*phi) + p*e^(i*phi)/(3*|u|) .
//
// The crucial observation is the fact that y is the conjugate
// of - x + b/3. This means that after taking advantage of the
// relation
//
// e^(i*phi) + e^(-i*phi) = 2*cos(phi)
//
// the equation
//
// x = 2*cos(phi)*(|u| - p / (3*|u|)) - conj(x) - 2*b/3
//
// holds. Since |u|, p, b and cos(phi) are real numbers, it
// follows that Im(x) = - Im(x) and thus Im(x) = 0. This
// implies
//
// Re(x) = x = cos(phi)*(|u| - p / (3*|u|)) - b/3 .
//
// Considering the fact that u is a cubic root, we have three
// values for phi which differ by 2/3*pi. This allows to
// calculate the three real roots of the polynomial:
for (int i = 0; i < 3; ++i) {
sol[i] = std::cos(phi)*(uAbs - p/(3*uAbs)) - b/3;
phi += 2*M_PI/3;
}
// post process the obtained solution to increase numerical
// precision
invertCubicPolynomialPostProcess_(sol, 3, a, b, c, d);
// sort the result
std::sort(sol, sol + 3);
return 3;
}
}
// Handle some (pretty unlikely) special cases required to avoid
// divisions by zero in the code above...
else if (p == 0.0 && q == 0.0) {
// t^3 = 0, i.e. triple root at t = 0
sol[0] = sol[1] = sol[2] = 0.0 - b/3;
return 3;
}
else if (p == 0.0 && q != 0.0) {
// t^3 + q = 0,
//
// i. e. single real root at t=curt(q)
Scalar t;
if (-q > 0) t = std::pow(-q, 1./3);
else t = - std::pow(q, 1./3);
sol[0] = t - b/3;
return 1;
}
assert(p != 0.0 && q == 0.0);
// t^3 + p*t = 0 = t*(t^2 + p),
//
// i. e. roots at t = 0, t^2 + p = 0
if (p > 0) {
sol[0] = 0.0 - b/3;
return 1; // only a single real root at t=0
}
// two additional real roots at t = sqrt(-p) and t = -sqrt(-p)
sol[0] = -std::sqrt(-p) - b/3;;
sol[1] = 0.0 - b/3;
sol[2] = std::sqrt(-p) - b/3;
return 3;
}
/*!
* \brief Cross product of two vectors in three-dimensional Euclidean space
*
* \param vec1 The first vector
* \param vec2 The second vector
*/
template <class Scalar>
Dune::FieldVector<Scalar, 3> crossProduct(const Dune::FieldVector<Scalar, 3> &vec1,
const Dune::FieldVector<Scalar, 3> &vec2)
{
Dune::FieldVector<Scalar, 3> result;
result[0] = vec1[1]*vec2[2] - vec1[2]*vec2[1];
result[1] = vec1[2]*vec2[0] - vec1[0]*vec2[2];
result[2] = vec1[0]*vec2[1] - vec1[1]*vec2[0];
return result;
}
}
#endif

532
opm/common/spline.hh Normal file
View File

@@ -0,0 +1,532 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2010-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \copydoc Opm::Spline
*/
#ifndef OPM_SPLINE_HH
#define OPM_SPLINE_HH
#include "fixedlengthspline_.hh"
#include "variablelengthspline_.hh"
#include "splinecommon_.hh"
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
namespace Opm
{
/*!
* \ingroup Spline
* \brief A 3rd order polynomial spline.
* This class implements a spline \f$s(x)\f$ for which, given \f$n\f$ sampling
* points \f$x_1, \dots, x_n\f$, the following conditions hold
*\f{align*}{
s(x_i) & = y_i \quad \forall i \in \{1, \dots, n \}\\
s'(x_1) & = m_1 \\
s'(x_n) & = m_n
\f}
*
* for any given boundary slopes \f$m_1\f$ and \f$m_n\f$. Alternatively, natural
* splines are supported which are defined by
*\f{align*}{
s(x_i) & = y_i \quad \forall i \in \{1, \dots, n \} \\
s''(x_1) & = 0 \\
s''(x_n) & = 0
\f}
*/
template<class Scalar, int numSamples = 2>
class Spline : public FixedLengthSpline_<Scalar, numSamples>
{
public:
/*!
* \brief Default constructor for a spline.
*
* To specfiy the acutal curve, use one of the set() methods.
*/
Spline()
{ }
/*!
* \brief Convenience constructor for a full spline
*
* \param x An array containing the \f$x\f$ values of the spline's sampling points
* \param y An array containing the \f$y\f$ values of the spline's sampling points
*/
template <class ScalarArray>
Spline(const ScalarArray &x,
const ScalarArray &y)
{ this->setXYArrays(numSamples, x, y); }
/*!
* \brief Convenience constructor for a full spline
*
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points
*/
template <class PointArray>
Spline(const PointArray &points)
{ this->setArrayOfPoints(numSamples, points); }
/*!
* \brief Convenience constructor for a full spline
*
* \param x An array containing the \f$x\f$ values of the spline's sampling points
* \param y An array containing the \f$y\f$ values of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class ScalarArray>
Spline(const ScalarArray &x,
const ScalarArray &y,
Scalar m0,
Scalar m1)
{ this->setXYArrays(numSamples, x, y, m0, m1); }
/*!
* \brief Convenience constructor for a full spline
*
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class PointArray>
Spline(const PointArray &points,
Scalar m0,
Scalar m1)
{ this->setArrayOfPoints(numSamples, points, m0, m1); }
};
/*!
* \brief Specialization of a spline with the number of sampling
* points only known at run time.
*
* This class implements a spline \f$s(x)\f$ for which, given \f$n\f$ sampling
* points \f$x_1, \dots, x_n\f$, the following conditions hold
*\f{align*}{
s(x_i) & = y_i \quad \forall i \in \{1, \dots, n \}\\
s'(x_1) & = m_1 \\
s'(x_n) & = m_n
\f}
*
* for any given boundary slopes \f$m_1\f$ and \f$m_n\f$. Alternatively, natural
* splines are supported which are defined by
*\f{align*}{
s(x_i) & = y_i \quad \forall i \in \{1, \dots, n \} \\
s''(x_1) & = 0 \\
s''(x_n) & = 0
\f}
*/
template<class Scalar>
class Spline<Scalar, /*numSamples=*/-1> : public VariableLengthSpline_<Scalar>
{
public:
/*!
* \brief Default constructor for a spline.
*
* To specfiy the acutal curve, use one of the set() methods.
*/
Spline()
{ }
/*!
* \brief Convenience constructor for a natural spline
*
* \param nSamples The number of sampling points (must be > 2)
* \param x An array containing the \f$x\f$ values of the spline's sampling points
* \param y An array containing the \f$y\f$ values of the spline's sampling points
*/
template <class ScalarArrayX, class ScalarArrayY>
Spline(int nSamples,
const ScalarArrayX &x,
const ScalarArrayY &y)
{ this->setXYArrays(nSamples, x, y); }
/*!
* \brief Convenience constructor for a natural spline
*
* \param nSamples The number of sampling points (must be > 2)
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points
*/
template <class PointArray>
Spline(int nSamples,
const PointArray &points)
{ this->setArrayOfPoints(nSamples, points); }
/*!
* \brief Convenience constructor for a natural spline
*
* \param x An array containing the \f$x\f$ values of the spline's sampling points (must have a size() method)
* \param y An array containing the \f$y\f$ values of the spline's sampling points (must have a size() method)
*/
template <class ScalarContainer>
Spline(const ScalarContainer &x,
const ScalarContainer &y)
{ this->setXYContainers(x, y); }
/*!
* \brief Convenience constructor for a natural spline
*
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points (must have a size() method)
*/
template <class PointContainer>
Spline(const PointContainer &points)
{ this->setContainerOfPoints(points); }
/*!
* \brief Convenience constructor for a full spline
*
* \param nSamples The number of sampling points (must be >= 2)
* \param x An array containing the \f$x\f$ values of the spline's sampling points
* \param y An array containing the \f$y\f$ values of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class ScalarArray>
Spline(int nSamples,
const ScalarArray &x,
const ScalarArray &y,
Scalar m0,
Scalar m1)
{ this->setXYArrays(nSamples, x, y, m0, m1); }
/*!
* \brief Convenience constructor for a full spline
*
* \param nSamples The number of sampling points (must be >= 2)
* \param points An array containing the \f$x\f$ and \f$x\f$ values of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class PointArray>
Spline(int nSamples,
const PointArray &points,
Scalar m0,
Scalar m1)
{ this->setArrayOfPoints(nSamples, points, m0, m1); }
/*!
* \brief Convenience constructor for a full spline
*
* \param x An array containing the \f$x\f$ values of the spline's sampling points (must have a size() method)
* \param y An array containing the \f$y\f$ values of the spline's sampling points (must have a size() method)
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class ScalarContainerX, class ScalarContainerY>
Spline(const ScalarContainerX &x,
const ScalarContainerY &y,
Scalar m0,
Scalar m1)
{ this->setXYContainers(x, y, m0, m1); }
/*!
* \brief Convenience constructor for a full spline
*
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points (must have a size() method)
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class PointContainer>
Spline(const PointContainer &points,
Scalar m0,
Scalar m1)
{ this->setContainerOfPoints(points, m0, m1); }
};
/*!
* \brief Do not allow splines with zero sampling points
*/
template<class Scalar>
class Spline<Scalar, /*numSamples=*/0>
// Splines with zero sampling points do not make sense!
{ private: Spline() { } };
/*!
* \brief Do not allow splines with one sampling point
*/
template<class Scalar>
class Spline<Scalar, /*numSamples=*/1>
// Splines with one sampling point do not make sense!
{ private: Spline() { } };
/*!
* \brief Spline for two sampling points.
*
* For this type of spline there is no natural spline.
*/
template<class Scalar>
class Spline<Scalar, 2> : public SplineCommon_<Scalar, Spline<Scalar, 2> >
{
friend class SplineCommon_<Scalar, Spline<Scalar, 2> >;
typedef Dune::FieldVector<Scalar, 2> Vector;
typedef Dune::FieldMatrix<Scalar, 2, 2> Matrix;
public:
Spline()
{}
/*!
* \brief Convenience constructor for a full spline
*
* \param x An array containing the \f$x\f$ values of the spline's sampling points
* \param y An array containing the \f$y\f$ values of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class ScalarArrayX, class ScalarArrayY>
Spline(const ScalarArrayX &x,
const ScalarArrayY &y,
Scalar m0, Scalar m1)
{ setXYArrays(2, x, y, m0, m1); }
/*!
* \brief Convenience constructor for a full spline
*
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
template <class PointArray>
Spline(const PointArray &points,
Scalar m0,
Scalar m1)
{ this->setArrayOfPoints(2, points, m0, m1); }
/*!
* \brief Convenience constructor for a full spline
*
* \param x0 The \f$x\f$ value of the first sampling point
* \param x1 The \f$x\f$ value of the second sampling point
* \param y0 The \f$y\f$ value of the first sampling point
* \param y1 The \f$y\f$ value of the second sampling point
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_n\f$
*/
Spline(Scalar x0, Scalar x1,
Scalar y0, Scalar y1,
Scalar m0, Scalar m1)
{
set(x0, x1,
y0, y1,
m0, m1);
}
/*!
* \brief Returns the number of sampling points.
*/
int numSamples() const
{ return 2; }
/*!
* \brief Set the sampling points and the boundary slopes of the
* spline.
*
* \param x0 The \f$x\f$ value of the first sampling point
* \param x1 The \f$x\f$ value of the second sampling point
* \param y0 The \f$y\f$ value of the first sampling point
* \param y1 The \f$y\f$ value of the second sampling point
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_1\f$
*/
void set(Scalar x0, Scalar x1,
Scalar y0, Scalar y1,
Scalar m0, Scalar m1)
{
Matrix M(numSamples());
Vector d;
assignXY_(x0, x1, y0, y1);
this->makeFullSystem_(M, d, m0, m1);
// solve for the moments
M.solve(m_, d);
}
/*!
* \brief Set the sampling points and the boundary slopes of the
* spline.
*
* \param nSamples The number of sampling points (must be >= 2)
* \param x An array containing the \f$x\f$ values of the sampling points
* \param y An array containing the \f$y\f$ values of the sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_1\f$
*/
template <class ScalarContainer>
void setXYArrays(int nSamples,
const ScalarContainer &x,
const ScalarContainer &y,
Scalar m0, Scalar m1)
{
assert(nSamples == 2);
set(x[0], x[1], y[0], y[1], m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of the
* spline.
*
* \param x An array containing the \f$x\f$ values of the sampling points
* \param y An array containing the \f$y\f$ values of the sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_1\f$
*/
template <class ScalarContainerX, class ScalarContainerY>
void setXYContainers(const ScalarContainerX &x,
const ScalarContainerY &y,
Scalar m0, Scalar m1)
{
assert(x.size() == y.size());
assert(x.size() == 2);
Matrix M(numSamples());
Vector d;
typename ScalarContainerX::const_iterator xIt0 = x.begin();
typename ScalarContainerX::const_iterator xIt1 = xIt0;
++xIt1;
typename ScalarContainerY::const_iterator yIt0 = y.begin();
typename ScalarContainerY::const_iterator yIt1 = yIt0;
++yIt1;
set(*xIt0, *xIt1, *yIt0, *yIt1);
}
/*!
* \brief Set the sampling points and the boundary slopes of the
* spline.
*
* \param nSamples The number of sampling points (must be >= 2)
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_1\f$
*/
template <class PointArray>
void setArrayOfPoints(int nSamples,
const PointArray &points,
Scalar m0,
Scalar m1)
{
assert(nSamples == 2);
set(points[0][0],
points[1][0],
points[0][1],
points[1][1],
m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes from an
* STL-like container of points.
*
* \param points An array of \f$(x,y)\f$ tuples of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_1\f$
*/
template <class PointContainer>
void setContainerOfPoints(const PointContainer &points,
Scalar m0,
Scalar m1)
{
assert(points.size() == 2);
Matrix M;
Vector d;
typename PointContainer::const_iterator it0 = points.begin();
typename PointContainer::const_iterator it1 = it0;
++it1;
set((*it0)[0],
(*it0)[1],
(*it1)[0],
(*it1)[1],
m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes from an
* STL-like container of tuples.
*
* \param tuples An array of \f$(x,y)\f$ tuples of the spline's sampling points
* \param m0 The slope of the spline at \f$x_0\f$
* \param m1 The slope of the spline at \f$x_1\f$
*/
template <class TupleContainer>
void setContainerOfTuples(const TupleContainer &tuples,
Scalar m0,
Scalar m1)
{
assert(tuples.size() == 2);
typename TupleContainer::const_iterator it0 = tuples.begin();
typename TupleContainer::const_iterator it1 = it0;
++it1;
set(std::get<0>(*it0),
std::get<1>(*it0),
std::get<0>(*it1),
std::get<1>(*it1),
m0, m1);
}
protected:
void assignXY_(Scalar x0, Scalar x1,
Scalar y0, Scalar y1)
{
if (x0 > x1) {
xPos_[0] = x1;
xPos_[1] = x0;
yPos_[0] = y1;
yPos_[1] = y0;
}
else {
xPos_[0] = x0;
xPos_[1] = x1;
yPos_[0] = y0;
yPos_[1] = y1;
}
}
/*!
* \brief Returns the x coordinate of the i-th sampling point.
*/
Scalar x_(int i) const
{ return xPos_[i]; }
/*!
* \brief Returns the y coordinate of the i-th sampling point.
*/
Scalar y_(int i) const
{ return yPos_[i]; }
/*!
* \brief Returns the moment (i.e. second derivative) of the
* spline at the i-th sampling point.
*/
Scalar moment_(int i) const
{ return m_[i]; }
Vector xPos_;
Vector yPos_;
Vector m_;
};
}
#endif

685
opm/common/splinecommon_.hh Normal file
View File

@@ -0,0 +1,685 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2010-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \copydoc Opm::SplineCommon_
*/
#ifndef OPM_SPLINE_COMMON__HH
#define OPM_SPLINE_COMMON__HH
#include "valgrind.hh"
#include "math.hh"
#include <dune/common/exceptions.hh>
#include <tuple>
#include <algorithm>
#include <iostream>
#include <cassert>
namespace Opm
{
/*!
* \brief The common code for all 3rd order polynomial splines.
*/
template<class ScalarT, class ImplementationT>
class SplineCommon_
{
typedef ScalarT Scalar;
typedef ImplementationT Implementation;
Implementation &asImp_()
{ return *static_cast<Implementation*>(this); }
const Implementation &asImp_() const
{ return *static_cast<const Implementation*>(this); }
public:
/*!
* \brief Return true iff the given x is in range [x1, xn].
*/
bool applies(Scalar x) const
{
return x_(0) <= x && x <= x_(numSamples_() - 1);
}
/*!
* \brief Return the x value of the leftmost sampling point.
*/
Scalar xMin() const
{ return x_(0); }
/*!
* \brief Return the x value of the rightmost sampling point.
*/
Scalar xMax() const
{ return x_(numSamples_() - 1); }
/*!
* \brief Prints k tuples of the format (x, y, dx/dy, isMonotonic)
* to stdout.
*
* If the spline does not apply for parts of [x0, x1] it is
* extrapolated using a straight line. The result can be inspected
* using the following commands:
*
----------- snip -----------
./yourProgramm > spline.csv
gnuplot
gnuplot> plot "spline.csv" using 1:2 w l ti "Curve", \
"spline.csv" using 1:3 w l ti "Derivative", \
"spline.csv" using 1:4 w p ti "Monotonic"
----------- snap -----------
*/
void printCSV(Scalar xi0, Scalar xi1, int k) const
{
Scalar x0 = std::min(xi0, xi1);
Scalar x1 = std::max(xi0, xi1);
const int n = numSamples_() - 1;
for (int i = 0; i <= k; ++i) {
double x = i*(x1 - x0)/k + x0;
double x_p1 = x + (x1 - x0)/k;
double y;
double dy_dx;
double mono = 1;
if (!applies(x)) {
if (x < 0) {
dy_dx = evalDerivative(x_(0));
y = (x - x_(0))*dy_dx + y_(0);
mono = (dy_dx>0)?1:-1;
}
else if (x > x_(n)) {
dy_dx = evalDerivative(x_(n));
y = (x - x_(n))*dy_dx + y_(n);
mono = (dy_dx>0)?1:-1;
}
else {
DUNE_THROW(Dune::InvalidStateException,
"The sampling points given to a spline must be sorted by their x value!");
}
}
else {
y = eval(x);
dy_dx = evalDerivative(x);
mono = monotonic(std::max<Scalar>(x_(0), x), std::min<Scalar>(x_(n), x_p1));
}
std::cout << x << " " << y << " " << dy_dx << " " << mono << "\n";
}
}
/*!
* \brief Evaluate the spline at a given position.
*
* \param x The value on the abscissa where the spline ought to be
* evaluated
* \param extrapolate If this parameter is set to true, the spline
* will be extended beyond its range by
* straight lines, if false calling extrapolate
* for \f$ x \not [x_{min}, x_{max}]\f$ will
* cause a failed assertation.
*/
Scalar eval(Scalar x, bool extrapolate=false) const
{
assert(extrapolate || applies(x));
// handle extrapolation
if (extrapolate) {
if (x < xMin()) {
Scalar m = evalDerivative(xMin(), /*segmentIdx=*/0);
Scalar y0 = y_(0);
return y0 + m*(x - xMin());
}
else if (x > xMax()) {
Scalar m = evalDerivative(xMax(), /*segmentIdx=*/numSamples_()-2);
Scalar y0 = y_(numSamples_() - 1);
return y0 + m*(x - xMax());
}
}
return eval_(x, segmentIdx_(x));
}
/*!
* \brief Evaluate the spline's derivative at a given position.
*
* \param x The value on the abscissa where the spline's
* derivative ought to be evaluated
*
* \param extrapolate If this parameter is set to true, the spline
* will be extended beyond its range by
* straight lines, if false calling extrapolate
* for \f$ x \not [x_{min}, x_{max}]\f$ will
* cause a failed assertation.
*/
Scalar evalDerivative(Scalar x, bool extrapolate=false) const
{
assert(extrapolate || applies(x));
if (extrapolate) {
if (x < xMin())
evalDerivative_(xMin(), 0);
else if (x > xMax())
evalDerivative_(xMax(), numSamples_() - 2);
}
return evalDerivative_(x, segmentIdx_(x));
}
/*!
* \brief Find the intersections of the spline with a cubic
* polynomial in the whole intervall, throws
* Dune::MathError exception if there is more or less than
* one solution.
*/
Scalar intersect(Scalar a, Scalar b, Scalar c, Scalar d) const
{
return intersectIntervall(xMin(), xMax(), a, b, c, d);
}
/*!
* \brief Find the intersections of the spline with a cubic
* polynomial in a sub-intervall of the spline, throws
* Dune::MathError exception if there is more or less than
* one solution.
*/
Scalar intersectInterval(Scalar x0, Scalar x1,
Scalar a, Scalar b, Scalar c, Scalar d) const
{
assert(applies(x0) && applies(x1));
Scalar tmpSol[3];
int nSol = 0;
int iFirst = segmentIdx_(x0);
int iLast = segmentIdx_(x1);
for (int i = iFirst; i <= iLast; ++i)
{
nSol += intersectSegment_(tmpSol, i, a, b, c, d, x0, x1);
if (nSol > 1) {
DUNE_THROW(Dune::MathError,
"Spline has more than one intersection"); //<<a<<"x^3 + "<<b<"x^2 + "<<c<"x + "<<d);
}
}
if (nSol != 1)
DUNE_THROW(Dune::MathError,
"Spline has no intersection"); //<<a<"x^3 + " <<b<"x^2 + "<<c<"x + "<<d<<"!");
return tmpSol[0];
}
/*!
* \brief Returns 1 if the spline is monotonically increasing, -1
* if the spline is mononously decreasing and 0 if the
* spline is not monotonous in the interval (x0, x1).
*
* In the corner case where the whole spline is flat, it returns
* 2.
*/
int monotonic(Scalar x0, Scalar x1) const
{
assert(applies(x0));
assert(applies(x1));
assert(x0 != x1);
// make sure that x0 is smaller than x1
if (x0 > x1)
std::swap(x0, x1);
assert(x0 < x1);
// corner case where the whole spline is a constant
if (moment_(0) == 0 &&
moment_(1) == 0 &&
y_(0) == y_(1))
{
// actually the is monotonically increasing as well as
// monotonously decreasing
return 2;
}
int i = segmentIdx_(x0);
if (x_(i) <= x0 && x1 <= x_(i+1)) {
// the interval to check is completely included in a
// single segment
return monotonic_(i, x0, x1);
}
// make sure that the segments which are completly in the
// interval [x0, x1] all exhibit the same monotonicity.
int iEnd = segmentIdx_(x1);
int r = monotonic_(i, x0, x_(1));
for (; i < iEnd - 1; ++i)
if (r != monotonic_(i, x_(i), x_(i + 1)))
return 0;
// check for the last segment
if (x_(iEnd) < x1 && r != monotonic_(iEnd, x_(iEnd), x1))
{ return 0; }
return r;
}
/*!
* \brief Same as monotonic(x0, x1), but with the entire range of the
* spline as interval.
*/
int monotonic() const
{ return monotonic(xMin(), xMax()); }
protected:
// this is an internal class, so everything is protected!
SplineCommon_()
{ Valgrind::SetUndefined(asImp_()); }
/*!
* \brief Set the sampling point vectors.
*
* This takes care that the order of the x-values is ascending,
* although the input must be ordered already!
*/
template <class DestVector, class SourceVector>
void assignSamplingPoints_(DestVector &destX,
DestVector &destY,
const SourceVector &srcX,
const SourceVector &srcY,
int numSamples)
{
assert(numSamples >= 2);
// copy sample points, make sure that the first x value is
// smaller than the last one
for (int i = 0; i < numSamples; ++i) {
int idx = i;
if (srcX[0] > srcX[numSamples - 1])
idx = numSamples - i - 1;
destX[i] = srcX[idx];
destY[i] = srcY[idx];
}
}
template <class DestVector, class ListIterator>
void assignFromArrayList_(DestVector &destX,
DestVector &destY,
const ListIterator &srcBegin,
const ListIterator &srcEnd,
int numSamples)
{
assert(numSamples >= 2);
// find out wether the x values are in reverse order
ListIterator it = srcBegin;
++it;
bool reverse = false;
if ((*srcBegin)[0] > (*it)[0])
reverse = true;
--it;
// loop over all sampling points
for (int i = 0; it != srcEnd; ++i, ++it) {
int idx = i;
if (reverse)
idx = numSamples - i - 1;
destX[i] = (*it)[0];
destY[i] = (*it)[1];
}
}
/*!
* \brief Set the sampling points.
*
* Here we assume that the elements of the source vector have an
* [] operator where v[0] is the x value and v[1] is the y value
* if the sampling point.
*/
template <class DestVector, class ListIterator>
void assignFromTupleList_(DestVector &destX,
DestVector &destY,
ListIterator srcBegin,
ListIterator srcEnd,
int numSamples)
{
assert(numSamples >= 2);
// copy sample points, make sure that the first x value is
// smaller than the last one
// find out wether the x values are in reverse order
ListIterator it = srcBegin;
++it;
bool reverse = false;
if (std::get<0>(*srcBegin) > std::get<0>(*it))
reverse = true;
--it;
// loop over all sampling points
for (int i = 0; it != srcEnd; ++i, ++it) {
int idx = i;
if (reverse)
idx = numSamples - i - 1;
destX[i] = std::get<0>(*it);
destY[i] = std::get<1>(*it);
}
}
/*!
* \brief Make the linear system of equations Mx = d which results
* in the moments of the periodic spline.
*
* When solving Mx = d, it should be noted that x[0] is trash and
* needs to be set to x[n-1]
*/
template <class Vector, class Matrix>
void makePeriodicSystem_(Matrix &M, Vector &d)
{
// a periodic spline only makes sense if the first and the
// last sampling point have the same y value
assert(y_(0) == y_(numSamples_() - 1));
makeNaturalSystem(M, d);
int n = numSamples_() - 1;
Scalar lambda_n = h_(1)/(h_(n) + h_(1));
Scalar lambda_1 = M[1][2];
Scalar mu_1 = 1 - lambda_1;
Scalar mu_n = 1 - lambda_n;
Scalar d_n =
6 / (h_(n) + h_(1))
*
( (y_(1) - y_(n))/h_(1) - (y_(n) - y_(n-1))/h_(n));
// insert lambda_n and mu_1
M[1][n] = mu_1;
M[n][1] = lambda_n;
M[n][n-1] = mu_n;
d[n] = d_n;
}
/*!
* \brief Make the linear system of equations Mx = d which results
* in the moments of the full spline.
*/
template <class Vector, class Matrix>
void makeFullSystem_(Matrix &M, Vector &d, Scalar m0, Scalar m1)
{
makeNaturalSystem_(M, d);
int n = numSamples_() - 1;
// first row
M[0][1] = 1;
d[0] = 6/h_(1) * ( (y_(1) - y_(0))/h_(1) - m0);
// last row
M[n][n - 1] = 1;
// right hand side
d[n] =
6/h_(n)
*
(m1 - (y_(n) - y_(n - 1))/h_(n));
}
/*!
* \brief Make the linear system of equations Mx = d which results
* in the moments of the natural spline.
*/
template <class Vector, class Matrix>
void makeNaturalSystem_(Matrix &M, Vector &d)
{
M = 0;
d = 0;
// See: J. Stoer: "Numerische Mathematik 1", 9th edition,
// Springer, 2005, p. 111
const int n = numSamples_() - 1;
// second to next to last rows
for (int i = 1; i < n; ++i) {
const Scalar lambda_i = h_(i + 1) / (h_(i) + h_(i+1));
const Scalar mu_i = 1 - lambda_i;
const Scalar d_i =
6 / (h_(i) + h_(i+1))
*
( (y_(i+1) - y_(i))/h_(i+1) - (y_(i) - y_(i-1))/h_(i));
M[i][i-1] = mu_i;
M[i][i] = 2;
M[i][i + 1] = lambda_i;
d[i] = d_i;
};
// first row
M[0][0] = 2;
// last row
M[n][n] = 2;
// right hand side
d[0] = 0.0;
d[n] = 0.0;
}
// evaluate the spline at a given the position and given the
// segment index
Scalar eval_(Scalar x, int i) const
{
// See: J. Stoer: "Numerische Mathematik 1", 9th edition,
// Springer, 2005, p. 109
Scalar h_i1 = h_(i + 1);
Scalar x_i = x - x_(i);
Scalar x_i1 = x_(i+1) - x;
Scalar A_i =
(y_(i+1) - y_(i))/h_i1
-
h_i1/6*(moment_(i+1) - moment_(i));
Scalar B_i = y_(i) - moment_(i)* (h_i1*h_i1) / 6;
return
moment_(i)* x_i1*x_i1*x_i1 / (6 * h_i1)
+
moment_(i + 1)* x_i*x_i*x_i / (6 * h_i1)
+
A_i*x_i
+
B_i;
}
// evaluate the derivative of a spline given the actual position
// and the segment index
Scalar evalDerivative_(Scalar x, int i) const
{
// See: J. Stoer: "Numerische Mathematik 1", 9th edition,
// Springer, 2005, p. 109
Scalar h_i1 = h_(i + 1);
Scalar x_i = x - x_(i);
Scalar x_i1 = x_(i+1) - x;
Scalar A_i =
(y_(i+1) - y_(i))/h_i1
-
h_i1/6*(moment_(i+1) - moment_(i));
return
-moment_(i) * x_i1*x_i1 / (2 * h_i1)
+
moment_(i + 1) * x_i*x_i / (2 * h_i1)
+
A_i;
}
// returns the monotonicality of an interval of a spline segment
//
// The return value have the following meaning:
//
// 1: spline is monotonously increasing in the specified interval
// 0: spline is not monotonic in the specified interval
// -1: spline is monotonously decreasing in the specified interval
int monotonic_(int i, Scalar x0, Scalar x1) const
{
// shift the interval so that it is consistent with the
// definitions by Stoer
x0 = x0 - x_(i);
x1 = x1 - x_(i);
Scalar a = a_(i);
Scalar b = b_(i);
Scalar c = c_(i);
Scalar disc = 4*b*b - 12*a*c;
if (disc < 0) {
// discriminant is smaller than 0, i.e. the segment does
// not exhibit any extrema.
return (x0*(x0*3*a + 2*b) + c > 0) ? 1 : -1;
}
disc = std::sqrt(disc);
Scalar xE1 = (-2*b + disc)/(6*a);
Scalar xE2 = (-2*b - disc)/(6*a);
if (disc == 0) {
// saddle point -> no extrema
if (xE1 == x0)
// make sure that we're not picking the saddle point
// to determine whether we're monotonically increasing
// or decreasing
x0 = x1;
return (x0*(x0*3*a + 2*b) + c > 0) ? 1 : -1;
};
if ((x0 < xE1 && xE1 < x1) ||
(x0 < xE2 && xE2 < x1))
{
// there is an extremum in the range (x0, x1)
return 0;
}
// no extremum in range (x0, x1)
x0 = (x0 + x1)/2; // pick point in the middle of the interval
// to avoid extrema on the boundaries
return (x0*(x0*3*a + 2*b) + c > 0) ? 1 : -1;
}
/*!
* \brief Find all the intersections of a segment of the spline
* with a cubic polynomial within a specified interval.
*/
int intersectSegment_(Scalar *sol,
int segIdx,
Scalar a, Scalar b, Scalar c, Scalar d,
Scalar x0 = -1e100, Scalar x1 = 1e100) const
{
int n = Opm::invertCubicPolynomial(sol,
a_(segIdx) - a,
b_(segIdx) - b,
c_(segIdx) - c,
d_(segIdx) - d);
x0 = std::max(x_(segIdx), x0);
x1 = std::max(x_(segIdx+1), x1);
// filter the intersections outside of the specified intervall
int k = 0;
for (int j = 0; j < n; ++j) {
sol[j] += x_(segIdx); // add the offset of the intervall. For details see Stoer
if (x0 <= sol[j] && sol[j] <= x1) {
sol[k] = sol[j];
++k;
}
}
return k;
}
// find the segment index for a given x coordinate
int segmentIdx_(Scalar x) const
{
// bisection
int iLow = 0;
int iHigh = numSamples_() - 1;
while (iLow + 1 < iHigh) {
int i = (iLow + iHigh) / 2;
if (x_(i) > x)
iHigh = i;
else
iLow = i;
};
return iLow;
}
/*!
* \brief Returns x[i] - x[i - 1]
*/
Scalar h_(int i) const
{
assert(x_(i) > x_(i-1)); // the sampling points must be given
// in ascending order
return x_(i) - x_(i - 1);
}
/*!
* \brief Returns the y coordinate of the i-th sampling point.
*/
Scalar x_(int i) const
{ return asImp_().x_(i); }
/*!
* \brief Returns the y coordinate of the i-th sampling point.
*/
Scalar y_(int i) const
{ return asImp_().y_(i); }
/*!
* \brief Returns the moment (i.e. second derivative) of the
* spline at the i-th sampling point.
*/
Scalar moment_(int i) const
{ return asImp_().moment_(i); }
// returns the coefficient in front of the x^0 term. In Stoer this
// is delta.
Scalar a_(int i) const
{ return (moment_(i+1) - moment_(i))/(6*h_(i+1)); }
// returns the coefficient in front of the x^2 term In Stoer this
// is gamma.
Scalar b_(int i) const
{ return moment_(i)/2; }
// returns the coefficient in front of the x^1 term. In Stoer this
// is beta.
Scalar c_(int i) const
{ return (y_(i+1) - y_(i))/h_(i + 1) - h_(i+1)/6*(2*moment_(i) + moment_(i+1)); }
// returns the coefficient in front of the x^0 term. In Stoer this
// is alpha.
Scalar d_(int i) const
{ return y_(i); }
/*!
* \brief Returns the number of sampling points.
*/
int numSamples_() const
{ return asImp_().numSamples(); }
};
}
#endif

View File

@@ -0,0 +1,108 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \copydoc Opm::StaticTabulated2DFunction
*/
#ifndef OPM_STATIC_TABULATED_2D_FUNCTION_HH
#define OPM_STATIC_TABULATED_2D_FUNCTION_HH
#include <opm/common/exceptions.hh>
#include <opm/common/tabulated2dfunction.hh>
#include <assert.h>
namespace Opm {
/*!
* \copydoc Opm::Tabulated2DFunction
*
* This class can be used when the sampling points are calculated at
* compile time.
*/
template <class Traits>
class StaticTabulated2DFunction
: public Tabulated2DFunction<typename Traits::Scalar, StaticTabulated2DFunction<Traits> >
{
typedef typename Traits::Scalar Scalar;
public:
StaticTabulated2DFunction()
{ }
/*!
* \brief Returns the minimum of the X coordinate of the sampling points.
*/
Scalar xMin() const
{ return Traits::xMin; }
/*!
* \brief Returns the maximum of the X coordinate of the sampling points.
*/
Scalar xMax() const
{ return Traits::xMax; }
/*!
* \brief Returns the minimum of the Y coordinate of the sampling points.
*/
Scalar yMin() const
{ return Traits::yMin; }
/*!
* \brief Returns the maximum of the Y coordinate of the sampling points.
*/
Scalar yMax() const
{ return Traits::yMax; }
/*!
* \brief Returns the number of sampling points in X direction.
*/
int numX() const
{ return Traits::numX; }
/*!
* \brief Returns the number of sampling points in Y direction.
*/
int numY() const
{ return Traits::numY; }
/*!
* \brief Get the value of the sample point which is at the
* intersection of the \f$i\f$-th interval of the x-Axis
* and the \f$j\f$-th of the y-Axis.
*/
Scalar getSamplePoint(int i, int j) const
{
#if !defined NDEBUG
if (i < 0 || i >= Traits::numX ||
j < 0 || j >= Traits::numY) {
DUNE_THROW(NumericalProblem,
"Attempt to access element ("
<< i << ", " << j
<< ") on a " << Traits::name << " table of size ("
<< Traits::numX << ", " << Traits::numY
<< ")\n");
};
#endif
return Traits::vals[i][j];
}
};
}
#endif

View File

@@ -0,0 +1,143 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2011-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \copydoc Opm::Tabulated2DFunction
*/
#ifndef OPM_TABULATED_2D_FUNCTION_HH
#define OPM_TABULATED_2D_FUNCTION_HH
#include <opm/common/exceptions.hh>
#include <assert.h>
namespace Opm {
/*!
* \brief A generic class that represents tabulated 2 dimensional functions
*
* This class can be used to tabulate a two dimensional function
* \f$f(x, y)\f$ over the range \f$[x_{min}, x_{max}] \times [y_{min},
* y_{max}]\f$. For this, the ranges of the \f$x\f$ and \f$y\f$ axes are
* divided into \f$m\f$ and \f$n\f$ sub-intervals and the values of
* \f$f(x_i, y_j)\f$ need to be provided. Here, \f$x_i\f$ and
* \f$y_j\f$ are the largest positions of the \f$i\f$-th and
* \f$j\f$-th intervall. Between these sampling points this tabulation
* class uses linear interpolation.
*
* If the class is queried for a value outside of the tabulated range,
* a \c Opm::NumericalProblem exception is thrown.
*/
template <class Scalar, class Implementation>
class Tabulated2DFunction
{
public:
Tabulated2DFunction()
{ }
/*!
* \brief Return the position on the x-axis of the i-th interval.
*/
Scalar iToX(int i) const
{
assert(0 <= i && i < asImp_().numX());
return asImp_().xMin() + i*(asImp_().xMax() - asImp_().xMin())/(asImp_().numX() - 1);
}
/*!
* \brief Return the position on the y-axis of the j-th interval.
*/
Scalar jToY(int j) const
{
assert(0 <= j && j < asImp_().numY());
return asImp_().yMin() + j*(asImp_().yMax() - asImp_().yMin())/(asImp_().numY() - 1);
}
/*!
* \brief Return the interval index of a given position on the x-axis.
*
* This method returns a *floating point* number. The integer part
* should be interpreted as interval, the decimal places are the
* position of the x value between the i-th and the (i+1)-th
* sample point.
*/
Scalar xToI(Scalar x) const
{ return (x - asImp_().xMin())/(asImp_().xMax() - asImp_().xMin())*(asImp_().numX() - 1); }
/*!
* \brief Return the interval index of a given position on the y-axis.
*
* This method returns a *floating point* number. The integer part
* should be interpreted as interval, the decimal places are the
* position of the y value between the j-th and the (j+1)-th
* sample point.
*/
Scalar yToJ(Scalar y) const
{ return (y - asImp_().yMin())/(asImp_().yMax() - asImp_().yMin())*(asImp_().numY() - 1); }
/*!
* \brief Returns true iff a coordinate lies in the tabulated range
*/
bool applies(Scalar x, Scalar y) const
{ return asImp_().xMin() <= x && x <= asImp_().xMax() && asImp_().yMin() <= y && y <= asImp_().yMax(); }
/*!
* \brief Evaluate the function at a given (x,y) position.
*
* If this method is called for a value outside of the tabulated
* range, a \c Opm::NumericalProblem exception is thrown.
*/
Scalar eval(Scalar x, Scalar y) const
{
#ifndef NDEBUG
if (!applies(x,y))
{
DUNE_THROW(NumericalProblem,
"Attempt to get tabulated value for ("
<< x << ", " << y
<< ") on a table of extend "
<< asImp_().xMin() << " to " << asImp_().xMax() << " times "
<< asImp_().yMin() << " to " << asImp_().yMax());
};
#endif
Scalar alpha = xToI(x);
Scalar beta = yToJ(y);
int i = std::max(0, std::min(asImp_().numX(), static_cast<int>(alpha)));
int j = std::max(0, std::min(asImp_().numY(), static_cast<int>(beta)));
alpha -= i;
beta -= j;
// bi-linear interpolation
Scalar s1 = asImp_().getSamplePoint(i, j)*(1.0 - alpha) + asImp_().getSamplePoint(i + 1, j)*alpha;
Scalar s2 = asImp_().getSamplePoint(i, j + 1)*(1.0 - alpha) + asImp_().getSamplePoint(i + 1, j + 1)*alpha;
return s1*(1.0 - beta) + s2*beta;
}
private:
const Implementation &asImp_() const
{ return *static_cast<const Implementation*>(this); }
};
}
#endif

285
opm/common/valgrind.hh Normal file
View File

@@ -0,0 +1,285 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2010-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \brief Some templates to wrap the valgrind macros
*/
#ifndef OPM_VALGRIND_HH
#define OPM_VALGRIND_HH
#if ! HAVE_VALGRIND && ! defined(DOXYGEN)
namespace Valgrind
{
bool boolBlubb(bool value) { return value; }
void voidBlubb() { }
#define SetUndefined(t) voidBlubb()
#define SetDefined(t) voidBlubb()
#define CheckDefined(t) boolBlubb(true)
#define SetNoAccess(t) voidBlubb()
#define IsRunning() boolBlubb(false)
}
#else
#include <valgrind/memcheck.h>
namespace Valgrind
{
/*!
* \ingroup Valgrind
* \brief Returns whether the program is running under Valgrind or not.
*/
inline bool IsRunning()
{
#if !defined NDEBUG && HAVE_VALGRIND
return RUNNING_ON_VALGRIND;
#else
return false;
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if any of the memory occupied by an object
* is undefined.
*
* Please note that this does not check whether the destinations of an
* object's pointers or references are defined. Also, for performance
* reasons the compiler might insert "padding bytes" between within
* the objects which leads to false positives.
*
* Example:
*
* \code
* int i;
* Opm::Valgrind::CheckDefined(i); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be checked
*
* \param value the object which valgrind should check
*
* \return true iff there are no undefined bytes in the memory
* occupied by the object.
*/
template <class T>
inline bool CheckDefined(const T &value)
{
#if !defined NDEBUG && HAVE_VALGRIND
unsigned int tmp = VALGRIND_CHECK_MEM_IS_DEFINED(&value, sizeof(T));
return tmp == 0;
#else
return true;
#endif
}
/*!
* \ingroup Valgrind
*
* * \brief Make valgrind complain if any of the the memory occupied
* by a C-style array objects is undefined.
*
* Please note that this does not check whether the destinations of an
* object's pointers or references are defined. Also, for performance
* reasons the compiler might insert "padding bytes" between within
* the objects which leads to false positives.
*
* Example:
*
* \code
* int i[2];
* Opm::Valgrind::CheckDefined(i, 2); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be checked
*
* \param value Pointer to the first object of the array.
* \param size The size of the array in number of objects
*
* \return true iff there are no undefined bytes in the memory
* occupied by the array.
*/
template <class T>
inline bool CheckDefined(const T *value, int size)
{
#if !defined NDEBUG && HAVE_VALGRIND
unsigned int tmp = VALGRIND_CHECK_MEM_IS_DEFINED(value, size*sizeof(T));
return tmp == 0;
#else
return true;
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which an object resides undefined in
* valgrind runs.
*
* Example:
*
* \code
* int i = 0;
* Opm::Valgrind::SetUndefined(i);
* Opm::Valgrind::CheckDefined(i); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be set to undefined
*
* \param value The object which's memory valgrind should be told is undefined
*/
template <class T>
inline void SetUndefined(const T &value)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto DUNE_UNUSED result = VALGRIND_MAKE_MEM_UNDEFINED(&value, sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which an array of object resides
* undefined in valgrind runs.
*
* Example:
*
* \code
* int i[3] = {0, 1, 3};
* Opm::Valgrind::SetUndefined(&i[1], 2);
* Opm::Valgrind::CheckDefined(i, 3); // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which ought to be set to undefined
*
* \param value Pointer to the first object of the array.
* \param size The size of the array in number of objects
*/
template <class T>
inline void SetUndefined(const T *value, int size)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto DUNE_UNUSED result = VALGRIND_MAKE_MEM_UNDEFINED(value, size*sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which an object resides defined.
*
* Example:
*
* \code
* int i;
* Opm::Valgrind::SetDefined(i);
* Opm::Valgrind::CheckDefined(i); // Valgrind does not complain!
* \endcode
*
* \tparam T The type of the object which valgrind should consider as defined
*
* \param value The object which's memory valgrind should consider as defined
*/
template <class T>
inline void SetDefined(const T &value)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto DUNE_UNUSED result = VALGRIND_MAKE_MEM_DEFINED(&value, sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make the memory on which a C-style array of objects resides
* defined.
*
* Example:
*
* \code
* int i[3];
* Opm::Valgrind::SetDefined(i, 3);
* Opm::Valgrind::CheckDefined(i, 3); // Valgrind does not complain!
* \endcode
*
* \tparam T The type of the object which valgrind should consider as defined
*
* \param value Pointer to the first object of the array.
* \param n The size of the array in number of objects
*/
template <class T>
inline void SetDefined(const T *value, int n)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto DUNE_UNUSED result = VALGRIND_MAKE_MEM_DEFINED(value, n*sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if an object's memory is accessed.
*
* Example:
*
* \code
* int i = 1;
* Opm::Valgrind::SetNoAccess(i);
* int j = i; // Valgrind complains!
* \endcode
*
* \tparam T The type of the object which valgrind should complain if accessed
*
* \param value The object which's memory valgrind should complain if accessed
*/
template <class T>
inline void SetNoAccess(const T &value)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto DUNE_UNUSED result = VALGRIND_MAKE_MEM_NOACCESS(&value, sizeof(T));
#endif
}
/*!
* \ingroup Valgrind
* \brief Make valgrind complain if the memory of a C-style array of
* objects is accessed.
*
* Example:
*
* \code
* int i[3] = {0, 1, 2};
* Opm::Valgrind::SetNoAccess(i, 2);
* int j = i[1]; // Valgrind complains!
* \endcode
*
* \param value Pointer to the first object of the array.
* \param size The size of the array in number of objects
*
* \param value The object which's memory valgrind should complain if accessed
*/
template <class T>
inline void SetNoAccess(const T *value, int size)
{
#if !defined NDEBUG && HAVE_VALGRIND
auto DUNE_UNUSED result = VALGRIND_MAKE_MEM_NOACCESS(value, size*sizeof(T));
#endif
}
}
#endif
#endif

View File

@@ -0,0 +1,479 @@
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* Copyright (C) 2010-2012 by Andreas Lauser *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \copydoc Opm::VariableLengthSpline_
*/
#ifndef OPM_VARIABLE_LENGTH_SPLINE_HH
#define OPM_VARIABLE_LENGTH_SPLINE_HH
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/istl/bvector.hh>
#include <dune/istl/btdmatrix.hh>
#include "splinecommon_.hh"
namespace Opm
{
/*!
* \brief The common code for all 3rd order polynomial splines with
* where the number of sampling points only known at run-time.
*/
template<class ScalarT>
class VariableLengthSpline_
: public SplineCommon_<ScalarT,
VariableLengthSpline_<ScalarT> >
{
friend class SplineCommon_<ScalarT, VariableLengthSpline_<ScalarT> >;
typedef ScalarT Scalar;
typedef Dune::BlockVector<Dune::FieldVector<Scalar, 1> > Vector;
typedef Dune::BTDMatrix<Dune::FieldMatrix<Scalar, 1, 1> > BTDMatrix;
public:
/*!
* \brief Returns the number of sampling points.
*/
int numSamples() const
{ return xPos_.size(); }
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
// Full splines //
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using C-style arrays.
*
* This method uses separate array-like objects for the values of
* the X and Y coordinates. In this context 'array-like' means
* that an access to the members is provided via the []
* operator. (e.g. C arrays, std::vector, std::array, etc.) Each
* array must be of size 'nSamples' at least. Also, the number of
* sampling points must be larger than 1.
*/
template <class ScalarArrayX, class ScalarArrayY>
void setXYArrays(int nSamples,
const ScalarArrayX &x,
const ScalarArrayY &y,
Scalar m0, Scalar m1)
{
assert(nSamples > 1);
setNumSamples_(nSamples);
for (int i = 0; i < nSamples; ++i) {
xPos_[i] = x[i];
yPos_[i] = y[i];
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using STL-compatible containers.
*
* This method uses separate STL-compatible containers for the
* values of the sampling points' X and Y
* coordinates. "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class ScalarContainerX, class ScalarContainerY>
void setXYContainers(const ScalarContainerX &x,
const ScalarContainerY &y,
Scalar m0, Scalar m1)
{
assert(x.size() == y.size());
assert(x.size() > 1);
setNumSamples_(x.size());
std::copy(x.begin(), x.end(), xPos_.begin());
std::copy(y.begin(), y.end(), yPos_.begin());
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using a C-style array.
*
* This method uses a single array of sampling points, which are
* seen as an array-like object which provides access to the X and
* Y coordinates. In this context 'array-like' means that an
* access to the members is provided via the [] operator. (e.g. C
* arrays, std::vector, std::array, etc.) The array containing
* the sampling points must be of size 'nSamples' at least. Also,
* the number of sampling points must be larger than 1.
*/
template <class PointArray>
void setArrayOfPoints(int nSamples,
const PointArray &points,
Scalar m0,
Scalar m1)
{
// a spline with no or just one sampling points? what an
// incredible bad idea!
assert(nSamples > 1);
setNumSamples_(nSamples);
for (int i = 0; i < nSamples; ++i) {
xPos_[i] = points[i][0];
yPos_[i] = points[i][1];
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using a STL-compatible container of
* array-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be array-like objects storing the
* X and Y coordinates. "STL-compatible" means that the container
* provides access to iterators using the begin(), end() methods
* and also provides a size() method. Also, the number of entries
* in the X and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfPoints(const XYContainer &points,
Scalar m0,
Scalar m1)
{
// a spline with no or just one sampling points? what an
// incredible bad idea!
assert(points.size() > 1);
setNumSamples_(points.size());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++i, ++it) {
xPos_[i] = (*it)[0];
yPos_[i] = (*it)[1];
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
// make a full spline
makeFullSpline_(m0, m1);
}
/*!
* \brief Set the sampling points and the boundary slopes of a
* full spline using a STL-compatible container of
* tuple-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be tuple-like objects storing the
* X and Y coordinates. "tuple-like" means that the objects
* provide access to the x values via std::get<0>(obj) and to the
* y value via std::get<1>(obj) (e.g. std::tuple or
* std::pair). "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfTuples(const XYContainer &points,
Scalar m0,
Scalar m1)
{
// resize internal arrays
setNumSamples_(points.size());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++i, ++it) {
xPos_[i] = std::get<0>(*it);
yPos_[i] = std::get<1>(*it);
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
// make a full spline
makeFullSpline_(m0, m1);
}
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
// Natural splines //
///////////////////////////////////////
///////////////////////////////////////
///////////////////////////////////////
/*!
* \brief Set the sampling points natural spline using C-style arrays.
*
* This method uses separate array-like objects for the values of
* the X and Y coordinates. In this context 'array-like' means
* that an access to the members is provided via the []
* operator. (e.g. C arrays, std::vector, std::array, etc.) Each
* array must be of size 'nSamples' at least. Also, the number of
* sampling points must be larger than 1.
*/
template <class ScalarArrayX, class ScalarArrayY>
void setXYArrays(int nSamples,
const ScalarArrayX &x,
const ScalarArrayY &y)
{
assert(nSamples > 1);
setNumSamples_(nSamples);
for (int i = 0; i < nSamples; ++i) {
xPos_[i] = x[i];
yPos_[i] = y[i];
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using
* STL-compatible containers.
*
* This method uses separate STL-compatible containers for the
* values of the sampling points' X and Y
* coordinates. "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class ScalarContainerX, class ScalarContainerY>
void setXYContainers(const ScalarContainerX &x,
const ScalarContainerY &y)
{
assert(x.size() == y.size());
assert(x.size() > 1);
setNumSamples_(x.size());
std::copy(x.begin(), x.end(), xPos_.begin());
std::copy(y.begin(), y.end(), yPos_.begin());
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using a
* C-style array.
*
* This method uses a single array of sampling points, which are
* seen as an array-like object which provides access to the X and
* Y coordinates. In this context 'array-like' means that an
* access to the members is provided via the [] operator. (e.g. C
* arrays, std::vector, std::array, etc.) The array containing
* the sampling points must be of size 'nSamples' at least. Also,
* the number of sampling points must be larger than 1.
*/
template <class PointArray>
void setArrayOfPoints(int nSamples,
const PointArray &points)
{
// a spline with no or just one sampling points? what an
// incredible bad idea!
assert(nSamples > 1);
setNumSamples_(nSamples);
for (int i = 0; i < nSamples; ++i) {
xPos_[i] = points[i][0];
yPos_[i] = points[i][1];
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using a
* STL-compatible container of array-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be array-like objects storing the
* X and Y coordinates. "STL-compatible" means that the container
* provides access to iterators using the begin(), end() methods
* and also provides a size() method. Also, the number of entries
* in the X and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfPoints(const XYContainer &points)
{
// a spline with no or just one sampling points? what an
// incredible bad idea!
assert(points.size() > 1);
setNumSamples_(points.size());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++ i, ++it) {
xPos_[i] = (*it)[0];
yPos_[i] = (*it)[1];
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
// make a natural spline
makeNaturalSpline_();
}
/*!
* \brief Set the sampling points of a natural spline using a
* STL-compatible container of tuple-like objects.
*
* This method uses a single STL-compatible container of sampling
* points, which are assumed to be tuple-like objects storing the
* X and Y coordinates. "tuple-like" means that the objects
* provide access to the x values via std::get<0>(obj) and to the
* y value via std::get<1>(obj) (e.g. std::tuple or
* std::pair). "STL-compatible" means that the container provides
* access to iterators using the begin(), end() methods and also
* provides a size() method. Also, the number of entries in the X
* and the Y containers must be equal and larger than 1.
*/
template <class XYContainer>
void setContainerOfTuples(const XYContainer &points)
{
// resize internal arrays
setNumSamples_(points.size());
typename XYContainer::const_iterator it = points.begin();
typename XYContainer::const_iterator endIt = points.end();
for (int i = 0; it != endIt; ++i, ++it) {
xPos_[i] = std::get<0>(*it);
yPos_[i] = std::get<1>(*it);
}
if (xPos_[0] > xPos_[numSamples() - 1])
reverseSamplingPoints_();
// make a natural spline
makeNaturalSpline_();
}
protected:
/*!
* \brief Reverse order of the elements in the arrays which
* contain the sampling points.
*/
void reverseSamplingPoints_()
{
// reverse the arrays
int n = numSamples();
for (int i = 0; i <= (n - 1)/2; ++i) {
std::swap(xPos_[i], xPos_[n - i - 1]);
std::swap(yPos_[i], yPos_[n - i - 1]);
}
}
/*!
* \brief Resizes the internal vectors to store the sample points.
*/
void setNumSamples_(int nSamples)
{
xPos_.resize(nSamples);
yPos_.resize(nSamples);
m_.resize(nSamples);
}
/*!
* \brief Create a natural spline from the already set sampling points.
*
* Also creates temporary matrix and right hand side vector.
*/
void makeFullSpline_(Scalar m0, Scalar m1)
{
BTDMatrix M(numSamples());
Vector d(numSamples());
// create linear system of equations
this->makeFullSystem_(M, d, m0, m1);
// solve for the moments
M.solve(m_, d);
}
/*!
* \brief Create a natural spline from the already set sampling points.
*
* Also creates temporary matrix and right hand side vector.
*/
void makeNaturalSpline_()
{
BTDMatrix M(numSamples());
Vector d(numSamples());
// create linear system of equations
this->makeNaturalSystem_(M, d);
// solve for the moments
M.solve(m_, d);
}
/*!
* \brief Returns the x coordinate of the i-th sampling point.
*/
Scalar x_(int i) const
{ return xPos_[i]; }
/*!
* \brief Returns the y coordinate of the i-th sampling point.
*/
Scalar y_(int i) const
{ return yPos_[i]; }
/*!
* \brief Returns the moment (i.e. second derivative) of the
* spline at the i-th sampling point.
*/
Scalar moment_(int i) const
{ return m_[i]; }
Vector xPos_;
Vector yPos_;
Vector m_;
};
}
#endif

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::BinaryCoeff::Air_Mesitylene
*/
#ifndef EWOMS_BINARY_COEFF_AIR_MESITYLENE_HH
#define EWOMS_BINARY_COEFF_AIR_MESITYLENE_HH
#ifndef OPM_BINARY_COEFF_AIR_MESITYLENE_HH
#define OPM_BINARY_COEFF_AIR_MESITYLENE_HH
#include <opm/material/components/air.hh>
#include <opm/material/components/mesitylene.hh>

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::BinaryCoeff::Air_Xylene
*/
#ifndef EWOMS_BINARY_COEFF_AIR_XYLENE_HH
#define EWOMS_BINARY_COEFF_AIR_XYLENE_HH
#ifndef OPM_BINARY_COEFF_AIR_XYLENE_HH
#define OPM_BINARY_COEFF_AIR_XYLENE_HH
#include <opm/material/components/air.hh>
#include <opm/material/components/xylene.hh>

View File

@@ -21,8 +21,8 @@
*
* \copydoc Opm::BinaryCoeff::Brine_CO2
*/
#ifndef EWOMS_BINARY_COEFF_BRINE_CO2_HH
#define EWOMS_BINARY_COEFF_BRINE_CO2_HH
#ifndef OPM_BINARY_COEFF_BRINE_CO2_HH
#define OPM_BINARY_COEFF_BRINE_CO2_HH
#include <opm/material/components/brine.hh>
#include <opm/material/components/h2o.hh>

View File

@@ -20,8 +20,8 @@
* \file
* \copydoc Opm::BinaryCoeff::fullerMethod
*/
#ifndef EWOMS_FULLERMETHOD_HH
#define EWOMS_FULLERMETHOD_HH
#ifndef OPM_FULLERMETHOD_HH
#define OPM_FULLERMETHOD_HH
#include <opm/common/math.hh>

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::BinaryCoeff::H2O_Air
*/
#ifndef EWOMS_BINARY_COEFF_H2O_AIR_HH
#define EWOMS_BINARY_COEFF_H2O_AIR_HH
#ifndef OPM_BINARY_COEFF_H2O_AIR_HH
#define OPM_BINARY_COEFF_H2O_AIR_HH
#include <cmath>

View File

@@ -21,8 +21,8 @@
*
* \copydoc Opm::BinaryCoeff::H2O_CO2
*/
#ifndef EWOMS_BINARY_COEFF_H2O_CO2_HH
#define EWOMS_BINARY_COEFF_H2O_CO2_HH
#ifndef OPM_BINARY_COEFF_H2O_CO2_HH
#define OPM_BINARY_COEFF_H2O_CO2_HH
#include <opm/material/binarycoefficients/henryiapws.hh>
#include <opm/material/binarycoefficients/fullermethod.hh>

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::BinaryCoeff::H2O_Mesitylene
*/
#ifndef EWOMS_BINARY_COEFF_H2O_MESITYLENE_HH
#define EWOMS_BINARY_COEFF_H2O_MESITYLENE_HH
#ifndef OPM_BINARY_COEFF_H2O_MESITYLENE_HH
#define OPM_BINARY_COEFF_H2O_MESITYLENE_HH
#include <opm/material/components/h2o.hh>
#include <opm/material/components/mesitylene.hh>
@@ -51,9 +51,9 @@ public:
// after Sanders
Scalar sanderH = 1.7e-1; // [M/atm]
//conversion to our Henry definition
Scalar ewomsH = sanderH / 101.325; // has now [(mol/m^3)/Pa]
ewomsH *= 18.02e-6; // multiplied by molar volume of reference phase = water
return 1.0/ewomsH; // [Pa]
Scalar opmH = sanderH / 101.325; // has now [(mol/m^3)/Pa]
opmH *= 18.02e-6; // multiplied by molar volume of reference phase = water
return 1.0/opmH; // [Pa]
}
/*!

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::BinaryCoeff::H2O_N2
*/
#ifndef EWOMS_BINARY_COEFF_H2O_N2_HH
#define EWOMS_BINARY_COEFF_H2O_N2_HH
#ifndef OPM_BINARY_COEFF_H2O_N2_HH
#define OPM_BINARY_COEFF_H2O_N2_HH
#include "henryiapws.hh"
#include "fullermethod.hh"

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::BinaryCoeff::H2O_Xylene
*/
#ifndef EWOMS_BINARY_COEFF_H2O_XYLENE_HH
#define EWOMS_BINARY_COEFF_H2O_XYLENE_HH
#ifndef OPM_BINARY_COEFF_H2O_XYLENE_HH
#define OPM_BINARY_COEFF_H2O_XYLENE_HH
#include <opm/material/components/h2o.hh>
#include <opm/material/components/xylene.hh>
@@ -52,9 +52,9 @@ public:
// after Sanders
Scalar sanderH = 1.5e-1; //[M/atm]
//conversion to our Henry definition
Scalar ewomsH = sanderH / 101.325; // has now [(mol/m^3)/Pa]
ewomsH *= 18.02e-6; //multiplied by molar volume of reference phase = water
return 1.0/ewomsH; // [Pa]
Scalar opmH = sanderH / 101.325; // has now [(mol/m^3)/Pa]
opmH *= 18.02e-6; //multiplied by molar volume of reference phase = water
return 1.0/opmH; // [Pa]
}
/*!

View File

@@ -21,8 +21,8 @@
*
* \brief The IAPWS formulation of Henry coefficients in water.
*/
#ifndef EWOMS_HENRY_IAPWS_HH
#define EWOMS_HENRY_IAPWS_HH
#ifndef OPM_HENRY_IAPWS_HH
#define OPM_HENRY_IAPWS_HH
#include <opm/material/components/h2o.hh>
@@ -81,4 +81,4 @@ inline Scalar henryIAPWS(Scalar E,
}
}
#endif // EWOMS_HENRY_IAPWS_HH
#endif // OPM_HENRY_IAPWS_HH

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::Air
*/
#ifndef EWOMS_AIR_HH
#define EWOMS_AIR_HH
#ifndef OPM_AIR_HH
#define OPM_AIR_HH
#include <dune/common/exceptions.hh>
#include <opm/material/components/component.hh>

View File

@@ -21,8 +21,8 @@
*
* \copydoc Opm::Brine
*/
#ifndef EWOMS_BRINE_HH
#define EWOMS_BRINE_HH
#ifndef OPM_BRINE_HH
#define OPM_BRINE_HH
#include <opm/material/components/component.hh>

View File

@@ -21,8 +21,8 @@
*
* \copydoc Opm::CO2
*/
#ifndef EWOMS_CO2_HH
#define EWOMS_CO2_HH
#ifndef OPM_CO2_HH
#define OPM_CO2_HH
#include <opm/common/exceptions.hh>
#include <opm/material/components/component.hh>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::Component
*/
#ifndef EWOMS_COMPONENT_HH
#define EWOMS_COMPONENT_HH
#ifndef OPM_COMPONENT_HH
#define OPM_COMPONENT_HH
#include <dune/common/stdstreams.hh>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::DNAPL
*/
#ifndef EWOMS_DNAPL_HH
#define EWOMS_DNAPL_HH
#ifndef OPM_DNAPL_HH
#define OPM_DNAPL_HH
#include <opm/material/idealgas.hh>
#include "component.hh"

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::H2O
*/
#ifndef EWOMS_H2O_HH
#define EWOMS_H2O_HH
#ifndef OPM_H2O_HH
#define OPM_H2O_HH
#include <cmath>
#include <cassert>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::IAPWS::Common
*/
#ifndef EWOMS_IAPWS_COMMON_HH
#define EWOMS_IAPWS_COMMON_HH
#ifndef OPM_IAPWS_COMMON_HH
#define OPM_IAPWS_COMMON_HH
#include <opm/material/constants.hh>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::IAPWS::Region1
*/
#ifndef EWOMS_IAPWS_REGION1_HH
#define EWOMS_IAPWS_REGION1_HH
#ifndef OPM_IAPWS_REGION1_HH
#define OPM_IAPWS_REGION1_HH
#include <cmath>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::IAPWS::Region2
*/
#ifndef EWOMS_IAPWS_REGION2_HH
#define EWOMS_IAPWS_REGION2_HH
#ifndef OPM_IAPWS_REGION2_HH
#define OPM_IAPWS_REGION2_HH
#include <cmath>

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::IAPWS::Region4
*/
#ifndef EWOMS_IAPWS_REGION4_HH
#define EWOMS_IAPWS_REGION4_HH
#ifndef OPM_IAPWS_REGION4_HH
#define OPM_IAPWS_REGION4_HH
#include <cmath>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::LNAPL
*/
#ifndef EWOMS_LNAPL_HH
#define EWOMS_LNAPL_HH
#ifndef OPM_LNAPL_HH
#define OPM_LNAPL_HH
#include "component.hh"

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::Mesitylene
*/
#ifndef EWOMS_MESITYLENE_HH
#define EWOMS_MESITYLENE_HH
#ifndef OPM_MESITYLENE_HH
#define OPM_MESITYLENE_HH
#include <opm/material/idealgas.hh>
#include <opm/material/components/component.hh>

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::N2
*/
#ifndef EWOMS_N2_HH
#define EWOMS_N2_HH
#ifndef OPM_N2_HH
#define OPM_N2_HH
#include <opm/material/idealgas.hh>

View File

@@ -20,8 +20,8 @@
* \file
* \copydoc Opm::NullComponent
*/
#ifndef EWOMS_NULL_COMPONENT_HH
#define EWOMS_NULL_COMPONENT_HH
#ifndef OPM_NULL_COMPONENT_HH
#define OPM_NULL_COMPONENT_HH
#include "component.hh"

View File

@@ -23,8 +23,8 @@
*
* \copydoc Opm::SimpleCO2
*/
#ifndef EWOMS_SIMPLE_CO2_HH
#define EWOMS_SIMPLE_CO2_HH
#ifndef OPM_SIMPLE_CO2_HH
#define OPM_SIMPLE_CO2_HH
#include <opm/material/idealgas.hh>
#include <opm/material/components/component.hh>

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::SimpleH2O
*/
#ifndef EWOMS_SIMPLE_H2O_HH
#define EWOMS_SIMPLE_H2O_HH
#ifndef OPM_SIMPLE_H2O_HH
#define OPM_SIMPLE_H2O_HH
#include <opm/material/idealgas.hh>

View File

@@ -23,8 +23,8 @@
*
* \copydoc Opm::TabulatedComponent
*/
#ifndef EWOMS_TABULATED_COMPONENT_HH
#define EWOMS_TABULATED_COMPONENT_HH
#ifndef OPM_TABULATED_COMPONENT_HH
#define OPM_TABULATED_COMPONENT_HH
#include <cmath>
#include <limits>

View File

@@ -21,8 +21,8 @@
* \file
* \copydoc Opm::Unit
*/
#ifndef EWOMS_UNIT_HH
#define EWOMS_UNIT_HH
#ifndef OPM_UNIT_HH
#define OPM_UNIT_HH
#include "component.hh"

View File

@@ -22,8 +22,8 @@
* \file
* \copydoc Opm::Xylene
*/
#ifndef EWOMS_XYLENE_HH
#define EWOMS_XYLENE_HH
#ifndef OPM_XYLENE_HH
#define OPM_XYLENE_HH
#include <cmath>
#include <opm/material/idealgas.hh>

Some files were not shown because too many files have changed in this diff Show More