Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mosaic/software/parallel-computing/openfpm/openfpm_pdata
  • argupta/openfpm_pdata
2 results
Show changes
Showing
with 0 additions and 2724 deletions
# - Try to find PETSc
# Once done this will define
#
# PETSC_FOUND - system has PETSc
# PETSC_INCLUDES - the PETSc include directories
# PETSC_LIBRARIES - Link these to use PETSc
# PETSC_COMPILER - Compiler used by PETSc, helpful to find a compatible MPI
# PETSC_DEFINITIONS - Compiler switches for using PETSc
# PETSC_MPIEXEC - Executable for running MPI programs
# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR)
#
# Usage:
# find_package(PETSc COMPONENTS CXX) - required if build --with-clanguage=C++ --with-c-support=0
# find_package(PETSc COMPONENTS C) - standard behavior of checking build using a C compiler
# find_package(PETSc) - same as above
#
# Setting these changes the behavior of the search
# PETSC_DIR - directory in which PETSc resides
# PETSC_ARCH - build architecture
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
cmake_policy(VERSION 3.3)
set(PETSC_VALID_COMPONENTS
C
CXX)
if(NOT PETSc_FIND_COMPONENTS)
get_property (_enabled_langs GLOBAL PROPERTY ENABLED_LANGUAGES)
if ("C" IN_LIST _enabled_langs)
set(PETSC_LANGUAGE_BINDINGS "C")
else ()
set(PETSC_LANGUAGE_BINDINGS "CXX")
endif ()
else()
# Right now, this is designed for compatability with the --with-clanguage option, so
# only allow one item in the components list.
list(LENGTH ${PETSc_FIND_COMPONENTS} components_length)
if(${components_length} GREATER 1)
message(FATAL_ERROR "Only one component for PETSc is allowed to be specified")
endif()
# This is a stub for allowing multiple components should that time ever come. Perhaps
# to also test Fortran bindings?
foreach(component ${PETSc_FIND_COMPONENTS})
list(FIND PETSC_VALID_COMPONENTS ${component} component_location)
if(${component_location} EQUAL -1)
message(FATAL_ERROR "\"${component}\" is not a valid PETSc component.")
else()
list(APPEND PETSC_LANGUAGE_BINDINGS ${component})
endif()
endforeach()
endif()
function (petsc_get_version)
if (EXISTS "${PETSC_DIR}/include/petscversion.h")
file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ")
foreach (line ${vstrings})
string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define")
list (GET fields 1 var)
list (GET fields 2 val)
set (${var} ${val} PARENT_SCOPE)
set (${var} ${val}) # Also in local scope so we have access below
endforeach ()
if (PETSC_VERSION_RELEASE)
if ($(PETSC_VERSION_PATCH) GREATER 0)
set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" CACHE INTERNAL "PETSc version")
else ()
set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}" CACHE INTERNAL "PETSc version")
endif ()
else ()
# make dev version compare higher than any patch level of a released version
set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" CACHE INTERNAL "PETSc version")
endif ()
else ()
message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist")
endif ()
endfunction ()
# Debian uses versioned paths e.g /usr/lib/petscdir/3.5/
file (GLOB DEB_PATHS "/usr/lib/petscdir/*")
find_path (PETSC_DIR include/petsc.h
HINTS ENV PETSC_DIR
PATHS
/usr/lib/petsc
# Debian paths
${DEB_PATHS}
# Arch Linux path
/opt/petsc/linux-c-opt
# MacPorts path
/opt/local/lib/petsc
$ENV{HOME}/petsc
DOC "PETSc Directory")
find_program (MAKE_EXECUTABLE NAMES make gmake)
if (PETSC_DIR AND NOT PETSC_ARCH)
set (_petsc_arches
$ENV{PETSC_ARCH} # If set, use environment variable first
linux-gnu-c-debug linux-gnu-c-opt # Debian defaults
x86_64-unknown-linux-gnu i386-unknown-linux-gnu)
set (petscconf "NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
foreach (arch ${_petsc_arches})
if (NOT PETSC_ARCH)
find_path (petscconf petscconf.h
HINTS ${PETSC_DIR}
PATH_SUFFIXES ${arch}/include bmake/${arch}
NO_DEFAULT_PATH)
if (petscconf)
set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture")
endif (petscconf)
endif (NOT PETSC_ARCH)
endforeach (arch)
set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE)
endif (PETSC_DIR AND NOT PETSC_ARCH)
set (petsc_slaves LIBRARIES_SYS LIBRARIES_VEC LIBRARIES_MAT LIBRARIES_DM LIBRARIES_KSP LIBRARIES_SNES LIBRARIES_TS
INCLUDE_DIR INCLUDE_CONF)
include (FindPackageMultipass)
find_package_multipass (PETSc petsc_config_current
STATES DIR ARCH
DEPENDENTS INCLUDES LIBRARIES COMPILER MPIEXEC ${petsc_slaves})
# Determine whether the PETSc layout is old-style (through 2.3.3) or
# new-style (>= 3.0.0)
if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/petscvariables") # > 3.5
set (petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules")
set (petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
elseif (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3
set (petsc_conf_rules "${PETSC_DIR}/conf/rules")
set (petsc_conf_variables "${PETSC_DIR}/conf/variables")
elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3
set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules")
set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables")
elseif (PETSC_DIR)
message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation")
endif ()
if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current)
petsc_get_version()
# Put variables into environment since they are needed to get
# configuration (petscvariables) in the PETSc makefile
set (ENV{PETSC_DIR} "${PETSC_DIR}")
set (ENV{PETSC_ARCH} "${PETSC_ARCH}")
# A temporary makefile to probe the PETSc configuration
set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc")
file (WRITE "${petsc_config_makefile}"
"## This file was autogenerated by FindPETSc.cmake
# PETSC_DIR = ${PETSC_DIR}
# PETSC_ARCH = ${PETSC_ARCH}
include ${petsc_conf_rules}
include ${petsc_conf_variables}
show :
\t-@echo -n \${\${VARIABLE}}
")
macro (PETSC_GET_VARIABLE name var)
set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name}
OUTPUT_VARIABLE ${var}
RESULT_VARIABLE petsc_return)
endmacro (PETSC_GET_VARIABLE)
petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir)
petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external)
petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line)
petsc_get_variable (PETSC_INCLUDE petsc_include)
petsc_get_variable (PCC petsc_cc)
petsc_get_variable (PCC_FLAGS petsc_cc_flags)
petsc_get_variable (MPIEXEC petsc_mpiexec)
# We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid!
file (REMOVE ${petsc_config_makefile})
execute_process(COMMAND ${MPI_C_COMPILER} --showme:compile OUTPUT_VARIABLE mpi_compile_options ERROR_VARIABLE mpi_compile_error)
set(petsc_cpp_line ${petsc_cpp_line} ${mpi_compile_options})
include (ResolveCompilerPaths)
# Extract include paths and libraries from compile command line
resolve_includes (petsc_includes_all "${petsc_cpp_line}")
#on windows we need to make sure we're linking against the right
#runtime library
if (WIN32)
if (petsc_cc_flags MATCHES "-MT")
set(using_md False)
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
set(using_md True)
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
if(${using_md} MATCHES "True")
message(WARNING "PETSc was built with /MT, but /MD is currently set.
See http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F")
endif(${using_md} MATCHES "True")
endif (petsc_cc_flags MATCHES "-MT")
endif (WIN32)
include (CorrectWindowsPaths)
convert_cygwin_path(petsc_lib_dir)
message (STATUS "petsc_lib_dir ${petsc_lib_dir}")
macro (PETSC_FIND_LIBRARY suffix name)
set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again
if (WIN32)
set (libname lib${name}) #windows expects "libfoo", linux expects "foo"
else (WIN32)
set (libname ${name})
endif (WIN32)
find_library (PETSC_LIBRARY_${suffix} NAMES ${libname} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH)
set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}")
mark_as_advanced (PETSC_LIBRARY_${suffix})
endmacro (PETSC_FIND_LIBRARY suffix name)
# Look for petscvec first, if it doesn't exist, we must be using single-library
petsc_find_library (VEC petscvec)
if (PETSC_LIBRARY_VEC)
petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced)
petsc_find_library (MAT petscmat)
petsc_find_library (DM petscdm)
petsc_find_library (KSP petscksp)
petsc_find_library (SNES petscsnes)
petsc_find_library (TS petscts)
macro (PETSC_JOIN libs deps)
list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}})
endmacro (PETSC_JOIN libs deps)
petsc_join (VEC SYS)
petsc_join (MAT VEC)
petsc_join (DM MAT)
petsc_join (KSP DM)
petsc_join (SNES KSP)
petsc_join (TS SNES)
petsc_join (ALL TS)
else ()
set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec
petsc_find_library (SINGLE petsc)
# Debian 9/Ubuntu 16.04 uses _real and _complex extensions when using libraries in /usr/lib/petsc.
if (NOT PETSC_LIBRARY_SINGLE)
petsc_find_library (SINGLE petsc_real)
endif()
if (NOT PETSC_LIBRARY_SINGLE)
petsc_find_library (SINGLE petsc_complex)
endif()
foreach (pkg SYS VEC MAT DM KSP SNES TS ALL)
set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}")
endforeach ()
endif ()
if (PETSC_LIBRARY_TS)
message (STATUS "Recognized PETSc install with separate libraries for each package")
else ()
message (STATUS "Recognized PETSc install with single library for all packages")
endif ()
include(Check${PETSC_LANGUAGE_BINDINGS}SourceRuns)
macro (PETSC_TEST_RUNS includes libraries runs)
if (PETSC_VERSION VERSION_GREATER 3.1)
set (_PETSC_TSDestroy "TSDestroy(&ts)")
else ()
set (_PETSC_TSDestroy "TSDestroy(ts)")
endif ()
set(_PETSC_TEST_SOURCE "
static const char help[] = \"PETSc test program.\";
#include <petscts.h>
int main(int argc,char *argv[]) {
PetscErrorCode ierr;
TS ts;
ierr = PetscInitialize(&argc,&argv,0,help);CHKERRQ(ierr);
ierr = TSCreate(PETSC_COMM_WORLD,&ts);CHKERRQ(ierr);
ierr = TSSetFromOptions(ts);CHKERRQ(ierr);
ierr = ${_PETSC_TSDestroy};CHKERRQ(ierr);
ierr = PetscFinalize();CHKERRQ(ierr);
return 0;
}
")
multipass_source_runs ("${includes}" "${libraries}" "${_PETSC_TEST_SOURCE}" ${runs} "${PETSC_LANGUAGE_BINDINGS}")
if (${${runs}})
set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL
"Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE)
endif (${${runs}})
endmacro (PETSC_TEST_RUNS)
find_path (PETSC_INCLUDE_DIR petscts.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH)
find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH)
mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF)
set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR})
petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal)
if (petsc_works_minimal)
message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.")
set (petsc_includes_needed "${petsc_includes_minimal}")
else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it
petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes)
if (petsc_works_allincludes) # It does, we just need all the includes (
message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).")
set (petsc_includes_needed ${petsc_includes_all})
else (petsc_works_allincludes) # We are going to need to link the external libs explicitly
resolve_libraries (petsc_libraries_external "${petsc_libs_external}")
foreach (pkg SYS VEC MAT DM KSP SNES TS ALL)
list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external})
endforeach (pkg)
petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries)
if (petsc_works_alllibraries)
message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.")
set (petsc_includes_needed ${petsc_includes_minimal})
else (petsc_works_alllibraries)
# It looks like we really need everything, should have listened to Matt
set (petsc_includes_needed ${petsc_includes_all})
petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all)
if (petsc_works_all) # We fail anyways
message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.")
else (petsc_works_all) # We fail anyways
message (STATUS "PETSc could not be used, maybe the install is broken.")
endif (petsc_works_all)
endif (petsc_works_alllibraries)
endif (petsc_works_allincludes)
endif (petsc_works_minimal)
# We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous
if (${PETSC_VERSION} VERSION_LESS 3.1)
set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE)
else ()
set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE)
endif ()
# Sometimes this can be used to assist FindMPI.cmake
set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE)
set (PETSC_INCLUDES ${petsc_includes_needed} CACHE STRING "PETSc include path" FORCE)
set (PETSC_LIBRARIES ${PETSC_LIBRARIES_ALL} CACHE STRING "PETSc libraries" FORCE)
set (PETSC_COMPILER ${petsc_cc} CACHE FILEPATH "PETSc compiler" FORCE)
# Note that we have forced values for all these choices. If you
# change these, you are telling the system to trust you that they
# work. It is likely that you will end up with a broken build.
mark_as_advanced (PETSC_INCLUDES PETSC_LIBRARIES PETSC_COMPILER PETSC_DEFINITIONS PETSC_MPIEXEC PETSC_EXECUTABLE_RUNS)
endif ()
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (PETSc
REQUIRED_VARS PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS
VERSION_VAR PETSC_VERSION
FAIL_MESSAGE "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.")
# PackageMultipass - this module defines two macros
#
# FIND_PACKAGE_MULTIPASS (Name CURRENT
# STATES VAR0 VAR1 ...
# DEPENDENTS DEP0 DEP1 ...)
#
# This function creates a cache entry <UPPERCASED-Name>_CURRENT which
# the user can set to "NO" to trigger a reconfiguration of the package.
# The first time this function is called, the values of
# <UPPERCASED-Name>_VAR0, ... are saved. If <UPPERCASED-Name>_CURRENT
# is false or if any STATE has changed since the last time
# FIND_PACKAGE_MULTIPASS() was called, then CURRENT will be set to "NO",
# otherwise CURRENT will be "YES". IF not CURRENT, then
# <UPPERCASED-Name>_DEP0, ... will be FORCED to NOTFOUND.
# Example:
# find_path (FOO_DIR include/foo.h)
# FIND_PACKAGE_MULTIPASS (Foo foo_current
# STATES DIR
# DEPENDENTS INCLUDES LIBRARIES)
# if (NOT foo_current)
# # Make temporary files, run programs, etc, to determine FOO_INCLUDES and FOO_LIBRARIES
# endif (NOT foo_current)
#
# MULTIPASS_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS LANGUAGE)
# Always runs the given test, use this when you need to re-run tests
# because parent variables have made old cache entries stale. The LANGUAGE
# variable is either C or CXX indicating which compiler the test should
# use.
# MULTIPASS_C_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS)
# DEPRECATED! This is only included for backwards compatability. Use
# the more general MULTIPASS_SOURCE_RUNS instead.
# Always runs the given test, use this when you need to re-run tests
# because parent variables have made old cache entries stale.
macro (FIND_PACKAGE_MULTIPASS _name _current)
string (TOUPPER ${_name} _NAME)
set (_args ${ARGV})
list (REMOVE_AT _args 0 1)
set (_states_current "YES")
list (GET _args 0 _cmd)
if (_cmd STREQUAL "STATES")
list (REMOVE_AT _args 0)
list (GET _args 0 _state)
while (_state AND NOT _state STREQUAL "DEPENDENTS")
# The name of the stored value for the given state
set (_stored_var PACKAGE_MULTIPASS_${_NAME}_${_state})
if (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}")
set (_states_current "NO")
endif (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}")
set (${_stored_var} "${${_NAME}_${_state}}" CACHE INTERNAL "Stored state for ${_name}." FORCE)
list (REMOVE_AT _args 0)
list (GET _args 0 _state)
endwhile (_state AND NOT _state STREQUAL "DEPENDENTS")
endif (_cmd STREQUAL "STATES")
set (_stored ${_NAME}_CURRENT)
if (NOT ${_stored})
set (${_stored} "YES" CACHE BOOL "Is the configuration for ${_name} current? Set to \"NO\" to reconfigure." FORCE)
set (_states_current "NO")
endif (NOT ${_stored})
set (${_current} ${_states_current})
if (NOT ${_current} AND PACKAGE_MULTIPASS_${_name}_CALLED)
message (STATUS "Clearing ${_name} dependent variables")
# Clear all the dependent variables so that the module can reset them
list (GET _args 0 _cmd)
if (_cmd STREQUAL "DEPENDENTS")
list (REMOVE_AT _args 0)
foreach (dep ${_args})
set (${_NAME}_${dep} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
endforeach (dep)
endif (_cmd STREQUAL "DEPENDENTS")
set (${_NAME}_FOUND "NOTFOUND" CACHE INTERNAL "Cleared" FORCE)
endif ()
set (PACKAGE_MULTIPASS_${name}_CALLED YES CACHE INTERNAL "Private" FORCE)
endmacro (FIND_PACKAGE_MULTIPASS)
macro (MULTIPASS_SOURCE_RUNS includes libraries source runs language)
include (Check${language}SourceRuns)
# This is a ridiculous hack. CHECK_${language}_SOURCE_* thinks that if the
# *name* of the return variable doesn't change, then the test does
# not need to be re-run. We keep an internal count which we
# increment to guarantee that every test name is unique. If we've
# gotten here, then the configuration has changed enough that the
# test *needs* to be rerun.
if (NOT MULTIPASS_TEST_COUNT)
set (MULTIPASS_TEST_COUNT 00)
endif (NOT MULTIPASS_TEST_COUNT)
math (EXPR _tmp "${MULTIPASS_TEST_COUNT} + 1") # Why can't I add to a cache variable?
set (MULTIPASS_TEST_COUNT ${_tmp} CACHE INTERNAL "Unique test ID")
set (testname MULTIPASS_TEST_${MULTIPASS_TEST_COUNT}_${runs})
set (CMAKE_REQUIRED_INCLUDES ${includes})
set (CMAKE_REQUIRED_LIBRARIES ${libraries})
if(${language} STREQUAL "C")
check_c_source_runs ("${source}" ${testname})
elseif(${language} STREQUAL "CXX")
check_cxx_source_runs ("${source}" ${testname})
endif()
set (${runs} "${${testname}}")
endmacro (MULTIPASS_SOURCE_RUNS)
macro (MULTIPASS_C_SOURCE_RUNS includes libraries source runs)
multipass_source_runs("${includes}" "${libraries}" "${source}" ${runs} "C")
endmacro (MULTIPASS_C_SOURCE_RUNS)
# - Try to find ParMETIS
# Once done this will define
#
# PARMETIS_FOUND - system has ParMETIS
# PARMETIS_INCLUDE_DIRS - include directories for ParMETIS
# PARMETIS_LIBRARIES - libraries for ParMETIS
#
# Variables used by this module. They can change the default behaviour and
# need to be set before calling find_package:
#
# PARMETIS_DIR - Prefix directory of the ParMETIS installation
# PARMETIS_INCLUDE_DIR - Include directory of the ParMETIS installation
# (set only if different from ${PARMETIS_DIR}/include)
# PARMETIS_LIB_DIR - Library directory of the ParMETIS installation
# (set only if different from ${PARMETIS_DIR}/lib)
# PARMETIS_TEST_RUNS - Skip tests building and running a test
# executable linked against ParMETIS libraries
# PARMETIS_LIB_SUFFIX - Also search for non-standard library names with the
# given suffix appended
#=============================================================================
# Copyright (C) 2010-2012 Garth N. Wells, Anders Logg, Johannes Ring
# and Florian Rathgeber. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if(NOT PARMETIS_INCLUDE_DIR)
find_path(PARMETIS_INCLUDE_DIR parmetis.h
HINTS ${PARMETIS_INCLUDE_DIR} ENV PARMETIS_INCLUDE_DIR ${PARMETIS_DIR} ENV PARMETIS_DIR
PATH_SUFFIXES include
DOC "Directory where the ParMETIS header files are located"
)
endif()
if(NOT METIS_INCLUDE_DIR)
find_path(METIS_INCLUDE_DIR metis.h
HINTS ${METIS_INCLUDE_DIR} ENV METIS_INCLUDE_DIR ${METIS_DIR} ENV METIS_DIR
PATH_SUFFIXES include
DOC "Directory where the METIS header files are located"
)
endif()
if(PARMETIS_LIBRARIES)
set(PARMETIS_LIBRARY ${PARMETIS_LIBRARIES})
endif()
if(NOT PARMETIS_LIBRARY)
find_library(PARMETIS_LIBRARY
NAMES parmetis parmetis${PARMETIS_LIB_SUFFIX}
HINTS ${PARMETIS_LIB_DIR} ENV PARMETIS_LIB_DIR ${PARMETIS_DIR} ENV PARMETIS_DIR
PATH_SUFFIXES lib
DOC "Directory where the ParMETIS library is located"
)
endif()
if(METIS_LIBRARIES)
set(METIS_LIBRARY ${METIS_LIBRARIES})
endif()
if(NOT METIS_LIBRARY)
find_library(METIS_LIBRARY
NAMES metis metis${PARMETIS_LIB_SUFFIX}
HINTS ${PARMETIS_LIB_DIR} ENV PARMETIS_LIB_DIR ${PARMETIS_DIR} ENV PARMETIS_DIR
PATH_SUFFIXES lib
DOC "Directory where the METIS library is located"
)
endif()
# Get ParMETIS version
if(NOT PARMETIS_VERSION_STRING AND PARMETIS_INCLUDE_DIR AND EXISTS "${PARMETIS_INCLUDE_DIR}/parmetis.h")
set(version_pattern "^#define[\t ]+PARMETIS_(MAJOR|MINOR)_VERSION[\t ]+([0-9\\.]+)$")
file(STRINGS "${PARMETIS_INCLUDE_DIR}/parmetis.h" parmetis_version REGEX ${version_pattern})
foreach(match ${parmetis_version})
if(PARMETIS_VERSION_STRING)
set(PARMETIS_VERSION_STRING "${PARMETIS_VERSION_STRING}.")
endif()
string(REGEX REPLACE ${version_pattern} "${PARMETIS_VERSION_STRING}\\2" PARMETIS_VERSION_STRING ${match})
set(PARMETIS_VERSION_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
endforeach()
unset(parmetis_version)
unset(version_pattern)
endif()
# Try compiling and running test program
if(PARMETIS_INCLUDE_DIR AND METIS_INCLUDE_DIR AND
PARMETIS_LIBRARY AND METIS_LIBRARY)
# Test requires MPI
find_package(MPI QUIET REQUIRED)
# Set flags for building test program
set(CMAKE_REQUIRED_FLAGS "${MPI_C_COMPILE_FLAGS}")
# Ideally this would be used, but it unfortunately is not supported
#set(CMAKE_REQUIRED_LINKER_FLAGS "${MPI_C_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_REQUIRED_INCLUDES
${PARMETIS_INCLUDE_DIR} ${METIS_INCLUDE_DIR} ${MPI_C_INCLUDE_PATH})
set(CMAKE_REQUIRED_LIBRARIES
${PARMETIS_LIBRARY} ${METIS_LIBRARY} ${MPI_C_LIBRARIES})
# Build and run test program
include(CheckCSourceCompiles)
check_c_source_compiles("
#include \"mpi.h\"
#define METIS_EXPORT
#include \"parmetis.h\"
int main( int argc, char* argv[] )
{
// FIXME: Find a simple but sensible test for ParMETIS
MPI_Init( &argc, &argv );
MPI_Finalize();
return 0;
}
" PARMETIS_TEST_RUNS)
unset(CMAKE_REQUIRED_FLAGS)
#unset(CMAKE_REQUIRED_LINKER_FLAGS)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
endif()
# Standard package handling
include(FindPackageHandleStandardArgs)
if(CMAKE_VERSION VERSION_GREATER 2.8.2)
find_package_handle_standard_args(ParMETIS
REQUIRED_VARS PARMETIS_LIBRARY PARMETIS_INCLUDE_DIR PARMETIS_TEST_RUNS
VERSION_VAR PARMETIS_VERSION_STRING)
else()
find_package_handle_standard_args(ParMETIS
REQUIRED_VARS PARMETIS_LIBRARY PARMETIS_INCLUDE_DIR PARMETIS_TEST_RUNS)
endif()
if(PARMETIS_FOUND)
set(PARMETIS_LIBRARIES ${PARMETIS_LIBRARY} ${METIS_LIBRARY})
set(PARMETIS_INCLUDE_DIRS ${PARMETIS_INCLUDE_DIR} ${METIS_INCLUDE_DIR})
else()
unset(METIS_LIBRARY CACHE)
unset(METIS_INCLUDE_DIR CACHE)
endif()
mark_as_advanced(PARMETIS_INCLUDE_DIR METIS_INCLUDE_DIR
PARMETIS_LIBRARY METIS_LIBRARY)
# .. cmake_module::
#
# Find the SuiteSparse libraries like UMFPACK or SPQR.
#
# Example which tries to find Suite Sparse's UMFPack component:
#
# :code:`find_package(SuiteSparse OPTIONAL_COMPONENTS UMFPACK)`
#
# `OPTIONAL_COMPONENTS`
# A list of components. Components are:
# AMD, BTF, CAMD, CCOLAMD, CHOLMOD, COLAMD, CXSPARSE,
# KLU, LDL, RBIO, SPQR, UMFPACK
#
# :ref:`SuiteSparse_ROOT`
# Path list to search for SuiteSparse
#
# Sets the following variables:
#
# :code:`SuiteSparse_FOUND`
# True if SuiteSparse was found.
#
# :code:`SuiteSparse_INCLUDE_DIRS`
# Path to the SuiteSparse include dirs.
#
# :code:`SuiteSparse_LIBRARIES`
# Name of the SuiteSparse libraries.
#
# :code:`SuiteSparse_<COMPONENT>_FOUND`
# Whether <COMPONENT> was found as part of SuiteSparse.
#
# .. cmake_variable:: SuiteSparse_ROOT
#
# You may set this variable to have :ref:`FindSuiteSparse` look
# for SuiteSparse in the given path before inspecting
# system paths.
#
find_package(BLAS QUIET)
# look for desired componenents
set(SUITESPARSE_COMPONENTS ${SuiteSparse_FIND_COMPONENTS})
# resolve inter-component dependencies
list(FIND SUITESPARSE_COMPONENTS "UMFPACK" WILL_USE_UMFPACK)
if(NOT WILL_USE_UMFPACK EQUAL -1)
list(APPEND SUITESPARSE_COMPONENTS AMD CHOLMOD)
endif()
list(FIND SUITESPARSE_COMPONENTS "CHOLMOD" WILL_USE_CHOLMOD)
if(NOT WILL_USE_CHOLMOD EQUAL -1)
list(APPEND SUITESPARSE_COMPONENTS AMD CAMD COLAMD CCOLAMD)
endif()
if(SUITESPARSE_COMPONENTS)
list(REMOVE_DUPLICATES SUITESPARSE_COMPONENTS)
endif()
# find SuiteSparse config:
# look for library at positions given by the user
find_library(SUITESPARSE_CONFIG_LIB
NAMES "suitesparseconfig"
PATHS ${SuiteSparse_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "Lib"
NO_DEFAULT_PATH
)
# now also include the default paths
find_library(SUITESPARSE_CONFIG_LIB
NAMES "suitesparseconfig"
PATH_SUFFIXES "lib" "lib32" "lib64" "Lib"
)
#look for header files at positions given by the user
find_path(SUITESPARSE_INCLUDE_DIR
NAMES "SuiteSparse_config.h"
PATHS ${SuiteSparse_ROOT}
PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include"
NO_DEFAULT_PATH
)
#now also look for default paths
find_path(SUITESPARSE_INCLUDE_DIR
NAMES "SuiteSparse_config.h"
PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include"
)
foreach(_component ${SUITESPARSE_COMPONENTS})
string(TOLOWER ${_component} _componentLower)
#look for library at positions given by the user
find_library(${_component}_LIBRARY
NAMES "${_componentLower}"
PATHS ${SuiteSparse_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "${_component}" "${_component}/Lib"
NO_DEFAULT_PATH
)
#now also include the default paths
find_library(${_component}_LIBRARY
NAMES "${_componentLower}"
PATH_SUFFIXES "lib" "lib32" "lib64" "${_component}" "${_component}/Lib"
)
#look for header files at positions given by the user
find_path(${_component}_INCLUDE_DIR
NAMES "${_componentLower}.h"
PATHS ${SuiteSparse_ROOT}
PATH_SUFFIXES "${_componentLower}" "include/${_componentLower}" "suitesparse" "include" "src" "${_component}" "${_component}/Include"
NO_DEFAULT_PATH
)
#now also look for default paths
find_path(${_component}_INCLUDE_DIR
NAMES "${_componentLower}.h"
PATH_SUFFIXES "${_componentLower}" "include/${_componentLower}" "suitesparse" "include" "${_component}" "${_component}/Include"
)
endforeach()
# SPQR has different header file name SuiteSparseQR.hpp
#look for header files at positions given by the user
find_path(SPQR_INCLUDE_DIR
NAMES "SuiteSparseQR.hpp"
PATHS ${SuiteSparse_ROOT}
PATH_SUFFIXES "spqr" "include/spqr" "suitesparse" "include" "src" "SPQR" "SPQR/Include"
NO_DEFAULT_PATH
)
#now also look for default paths
find_path(SPQR_INCLUDE_DIR
NAMES "SuiteSparseQR.hpp"
PATH_SUFFIXES "spqr" "include/spqr" "suitesparse" "include" "SPQR" "SPQR/Include"
)
# resolve inter-modular dependencies
# CHOLMOD requires AMD, COLAMD; CAMD and CCOLAMD are optional
if(CHOLMOD_LIBRARY)
if(NOT (AMD_LIBRARY AND COLAMD_LIBRARY))
message(WARNING "CHOLMOD requires AMD and COLAMD which were not found, skipping the test.")
set(SuiteSparse_CHOLMOD_FOUND "CHOLMOD requires AMD and COLAMD-NOTFOUND")
endif()
list(APPEND CHOLMOD_LIBRARY ${AMD_LIBRARY} ${COLAMD_LIBRARY})
if(CAMD_LIBRARY)
list(APPEND CHOLMOD_LIBRARY ${CAMD_LIBRARY})
endif()
if(CCOLAMD_LIBRARY)
list(APPEND CHOLMOD_LIBRARY ${CCOLAMD_LIBRARY})
endif()
list(REVERSE CHOLMOD_LIBRARY)
# remove duplicates
list(REMOVE_DUPLICATES CHOLMOD_LIBRARY)
list(REVERSE CHOLMOD_LIBRARY)
endif()
# UMFPack requires AMD, can depend on CHOLMOD
if(UMFPACK_LIBRARY)
# check wether cholmod was found
if(CHOLMOD_LIBRARY)
list(APPEND UMFPACK_LIBRARY ${CHOLMOD_LIBRARY})
else()
list(APPEND UMFPACK_LIBRARY ${AMD_LIBRARY})
endif()
list(REVERSE UMFPACK_LIBRARY)
# remove duplicates
list(REMOVE_DUPLICATES UMFPACK_LIBRARY)
list(REVERSE UMFPACK_LIBRARY)
endif()
# check wether everything was found
foreach(_component ${SUITESPARSE_COMPONENTS})
# variable used for component handling
if(${_component}_LIBRARY AND ${_component}_INCLUDE_DIR)
set(SuiteSparse_${_component}_FOUND TRUE)
else()
set(SuiteSparse_${_component}_FOUND FALSE)
endif()
set(HAVE_SUITESPARSE_${_component} ${SuiteSparse_${_component}_FOUND})
if(SuiteSparse_${_component}_FOUND)
list(APPEND SUITESPARSE_INCLUDE_DIR "${${_component}_INCLUDE_DIR}")
list(APPEND SUITESPARSE_LIBRARY "${${_component}_LIBRARY}")
endif()
mark_as_advanced(
HAVE_SUITESPARSE_${_component}
SuiteSparse_${_component}_FOUND
${_component}_INCLUDE_DIR
${_component}_LIBRARY)
endforeach()
# check version, for SPQR we need at least SuiteSparse 4.3
if(SuiteSparse_SPQR_FOUND)
include(CheckCSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUITESPARSE_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUITESPARSE_LIBRARY})
# check whether version is at least 4.3
check_c_source_compiles("
#include <SuiteSparse_config.h>
int main(void)
{
#ifndef SUITESPARSE_HAS_VERSION_FUNCTION
#error SuiteSparse <= 4.2.0 too old, required version 4.3 or newer for SPQR.
#endif
#if SUITESPARSE_VERSION <= 4003
#error SuiteSparse too old, required version 4.3 or newer for SPQR.
#endif
return 0;
}"
SUITESPARSE_MIN_VERSION_4_3)
if(NOT SUITESPARSE_MIN_VERSION_4_3)
set(SuiteSparse_SPQR_FOUND FALSE)
set(HAVE_SUITESPARSE_SPQR FALSE)
endif()
cmake_pop_check_state()
endif()
list(APPEND SUITESPARSE_LIBRARY ${SUITESPARSE_CONFIG_LIB})
# make them unique
if(SUITESPARSE_INCLUDE_DIR)
list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIR)
endif()
if(SUITESPARSE_LIBRARY)
list(REVERSE SUITESPARSE_LIBRARY)
list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY)
list(REVERSE SUITESPARSE_LIBRARY)
endif()
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"SuiteSparse"
FOUND_VAR SuiteSparse_FOUND
REQUIRED_VARS
BLAS_FOUND
SUITESPARSE_INCLUDE_DIR
SUITESPARSE_LIBRARY
HANDLE_COMPONENTS
)
mark_as_advanced(
SUITESPARSE_INCLUDE_DIR
SUITESPARSE_LIBRARY
SUITESPARSE_CONFIG_LIB
SUITESPARSE_MIN_VERSION_4_3
WILL_USE_CHOLMOD
WILL_USE_UMFPACK)
# if both headers and library are found, store results
if(SuiteSparse_FOUND)
set(SuiteSparse_LIBRARIES ${SUITESPARSE_LIBRARY})
set(SuiteSparse_INCLUDE_DIRS ${SUITESPARSE_INCLUDE_DIR})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of SuiteSparse succeeded:\n"
"Include directory: ${SuiteSparse_INCLUDE_DIRS}\n"
"Library directory: ${SuiteSparse_LIBRARIES}\n\n")
set(SuiteSparse_COMPILER_FLAGS)
foreach(dir ${SuiteSparse_INCLUDE_DIRS})
set(SuiteSparse_COMPILER_FLAGS "${SuiteSparse_COMPILER_FLAGS} -I${dir}/")
endforeach()
else()
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log
"Determing location of SuiteSparse failed:\n"
"Include directory: ${SuiteSparse_INCLUDE_DIRS}\n"
"Library directory: ${SuiteSparse_LIBRARIES}\n\n")
endif()
#set HAVE_SUITESPARSE for config.h
set(HAVE_SUITESPARSE ${SuiteSparse_FOUND})
set(HAVE_UMFPACK ${SuiteSparse_UMFPACK_FOUND})
# - Try to find LibHilbert
# Once done this will define
#
# TINYOBJLOADER_FOUND - system has LibHilbert
# TINYOBJLOADER_INCLUDE_DIRS - include directories for PETSc
# TINYOBJLOADER_LIBRARY_DIRS - library directories for PETSc
# TINYOBJLOADER_LIBRARIES - libraries for PETSc
#
#=============================================================================
# Copyright (C) 2010-2016 Pietro Incardona
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
if (TINYOBJLOADER_FOUND OR TARGET tinyobjloader)
return()
endif()
add_library(tinyobjloader INTERFACE IMPORTED)
# Add libraries (static)
set(_libs "-L${TINYOBJLOADER_ROOT}/lib64 -ltinyobjloader")
set_property(TARGET tinyobjloader PROPERTY INTERFACE_LINK_LIBRARIES "${_libs}")
# Create LibHilbert test program
set(TINYOBJLOADER_TEST_LIB_CPP
"${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/tinyobjloader_test_lib.cpp")
file(WRITE ${TINYOBJLOADER_TEST_LIB_CPP} "
#define TINYOBJLOADER_IMPLEMENTATION
#include \"tiny_obj_loader.h\"
int main()
{
std::string inputfile = \"null.obj\";
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, inputfile.c_str());
return 0;
}
")
# Try to run test program (static linking)
try_run(
TINYOBJLOADER_TEST_LIB_EXITCODE
TINYOBJLOADER_TEST_LIB_COMPILED
${CMAKE_CURRENT_BINARY_DIR}
${TINYOBJLOADER_TEST_LIB_CPP}
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=${TINYOBJLOADER_ROOT}/include"
"-DLINK_LIBRARIES:STRING=${TINYOBJLOADER_ROOT}/lib"
LINK_LIBRARIES tinyobjloader
COMPILE_OUTPUT_VARIABLE TINYOBJLOADER_TEST_LIB_COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE TINYOBJLOADER_TEST_LIB_OUTPUT)
if (TINYOBJLOADER_TEST_LIB_COMPILED AND TINYOBJLOADER_TEST_LIB_EXITCODE EQUAL 0)
message(STATUS "Test TinyObjLoader_TEST_RUNS static linking - Success")
set(TINYOBJLOADER_TEST_RUNS TRUE)
set(TINYOBJLOADER_FOUND TRUE)
set(TINYOBJLOADER_INCLUDE_DIRS ${TINYOBJLOADER_ROOT}/include)
set(TINYOBJLOADER_LIBRARY_DIRS ${TINYOBJLOADER_ROOT}/lib64)
set(TINYOBJLOADER_LIBRARIES -ltinyobjloader)
else()
message(STATUS "Test TinyObjLoader_TEST_RUNS static linking - Failed")
set(TINYOBJLOADER_TEST_RUNS FALSE)
endif()
# ResolveCompilerPaths - this module defines two macros
#
# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE)
# This macro is intended to be used by FindXXX.cmake modules.
# It parses a compiler link line and resolves all libraries
# (-lfoo) using the library path contexts (-L/path) in scope.
# The result in XXX_LIBRARIES is the list of fully resolved libs.
# Example:
#
# RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld")
#
# will be resolved to
#
# FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so"
#
# if the filesystem looks like
#
# /A: liba.so libc.so
# /B: liba.so libb.so
# /usr/lib: liba.so libb.so libc.so libd.so
#
# and /usr/lib is a system directory.
#
# Note: If RESOLVE_LIBRARIES() resolves a link line differently from
# the native linker, there is a bug in this macro (please report it).
#
# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE)
# This macro is intended to be used by FindXXX.cmake modules.
# It parses a compile line and resolves all includes
# (-I/path/to/include) to a list of directories. Other flags are ignored.
# Example:
#
# RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B")
#
# will be resolved to
#
# FOO_INCLUDES:STRING="/A;/B"
#
# assuming both directories exist.
# Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry)
include (CorrectWindowsPaths)
macro (RESOLVE_LIBRARIES LIBS LINK_LINE)
string (REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))" _all_tokens "${LINK_LINE}")
set (_libs_found "")
set (_directory_list "")
foreach (token ${_all_tokens})
if (token MATCHES "-L([^\" ]+|\"[^\"]+\")")
# If it's a library path, add it to the list
string (REGEX REPLACE "^-L" "" token ${token})
string (REGEX REPLACE "//" "/" token ${token})
convert_cygwin_path(token)
list (APPEND _directory_list ${token})
elseif (token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))")
# It's a library, resolve the path by looking in the list and then (by default) in system directories
if (WIN32) #windows expects "libfoo", linux expects "foo"
string (REGEX REPLACE "^-l" "lib" token ${token})
else (WIN32)
string (REGEX REPLACE "^-l" "" token ${token})
endif (WIN32)
set (_root "")
if (token MATCHES "^/") # We have an absolute path
#separate into a path and a library name:
string (REGEX MATCH "[^/]*\\.(a|so|dll|lib)$" libname ${token})
string (REGEX MATCH ".*[^${libname}$]" libpath ${token})
convert_cygwin_path(libpath)
set (_directory_list ${_directory_list} ${libpath})
set (token ${libname})
endif (token MATCHES "^/")
set (_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE)
find_library (_lib ${token} HINTS ${_directory_list} ${_root})
if (_lib)
string (REPLACE "//" "/" _lib ${_lib})
list (APPEND _libs_found ${_lib})
else (_lib)
message (STATUS "Unable to find library ${token}")
endif (_lib)
endif (token MATCHES "-L([^\" ]+|\"[^\"]+\")")
endforeach (token)
set (_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE)
# only the LAST occurence of each library is required since there should be no circular dependencies
if (_libs_found)
list (REVERSE _libs_found)
list (REMOVE_DUPLICATES _libs_found)
list (REVERSE _libs_found)
endif (_libs_found)
set (${LIBS} "${_libs_found}")
endmacro (RESOLVE_LIBRARIES)
macro (RESOLVE_INCLUDES INCS COMPILE_LINE)
string (REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}")
set (_incs_found "")
foreach (token ${_all_tokens})
string (REGEX REPLACE "^-I" "" token ${token})
string (REGEX REPLACE "//" "/" token ${token})
convert_cygwin_path(token)
if (EXISTS ${token})
list (APPEND _incs_found ${token})
else (EXISTS ${token})
message (STATUS "Include directory ${token} does not exist")
endif (EXISTS ${token})
endforeach (token)
list (REMOVE_DUPLICATES _incs_found)
set (${INCS} "${_incs_found}")
endmacro (RESOLVE_INCLUDES)
#!/bin/sh
# configure script
#
#
# Because we moved to cmake this script emulate the configure script from autotools
conf_options=
# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits
# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
set +e
as_fn_set_status $1
exit $1
} # as_fn_exit
# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
return $1
} # as_fn_set_status
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
&& (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='print -r --'
as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
as_echo='printf %s\n'
as_echo_n='printf %s'
else
if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
as_echo_n='/usr/ucb/echo -n'
else
as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
as_echo_n_body='eval
arg=$1;
case $arg in #(
*"$as_nl"*)
expr "X$arg" : "X\\(.*\\)$as_nl";
arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
esac;
expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
'
export as_echo_n_body
as_echo_n='sh -c $as_echo_n_body as_echo'
fi
export as_echo_body
as_echo='sh -c $as_echo_body as_echo'
fi
ac_user_opts='
enable_option_checking
enable_silent_rules
enable_shared
enable_static
with_pic
enable_fast_install
with_aix_soname
enable_dependency_tracking
with_gnu_ld
with_sysroot
enable_libtool_lock
enable_debug
with_metis
with_hdf5
with_libhilbert
enable_scan_coverty
enable_test_performance
enable_test_coverage
with_parmetis
enable_se_class1
enable_se_class2
enable_se_class3
with_action_on_error
with_boost
with_boost_libdir
with_boost_unit_test_framework
with_boost_program_options
with_boost_iostreams
with_blas
with_lapack
with_suitesparse
with_petsc
with_eigen
enable_gpu
'
rm -rf build
if [ ! -d "build" ]; then
mkdir build
fi
##### Go over all options
for ac_option
do
# If the previous option needs an argument, assign it.
if test -n "$ac_prev"; then
eval $ac_prev=\$ac_option
ac_prev=
continue
fi
case $ac_option in
*=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
*=) ac_optarg= ;;
*) ac_optarg=yes ;;
esac
# Accept the important Cygnus configure options, so we can diagnose typos.
case $ac_dashdash$ac_option in
--)
ac_dashdash=yes ;;
-bindir | --bindir | --bindi | --bind | --bin | --bi)
ac_prev=bindir ;;
-bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
bindir=$ac_optarg ;;
-build | --build | --buil | --bui | --bu)
ac_prev=build_alias ;;
-build=* | --build=* | --buil=* | --bui=* | --bu=*)
build_alias=$ac_optarg ;;
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
cache_file=$ac_optarg ;;
--config-cache | -C)
cache_file=config.cache ;;
-datadir | --datadir | --datadi | --datad)
ac_prev=datadir ;;
-datadir=* | --datadir=* | --datadi=* | --datad=*)
datadir=$ac_optarg ;;
-datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
| --dataroo | --dataro | --datar)
ac_prev=datarootdir ;;
-datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
| --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
datarootdir=$ac_optarg ;;
-disable-* | --disable-*)
ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_useropt in
gpu)
conf_options="$conf_options -DENABLE_GPU=OFF"
;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval enable_$ac_useropt=no ;;
-docdir | --docdir | --docdi | --doc | --do)
ac_prev=docdir ;;
-docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
docdir=$ac_optarg ;;
-dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
ac_prev=dvidir ;;
-dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
dvidir=$ac_optarg ;;
-enable-* | --enable-*)
ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid feature name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_useropt in
debug)
conf_options="$conf_options -DCMAKE_BUILD_TYPE=Debug"
debug_mode=1
;;
se_class1)
conf_options="$conf_options -DSE_CLASS1=ON"
;;
se_class2)
conf_options="$conf_options -DSE_CLASS2=ON"
;;
se_class3)
conf_options="$conf_options -DSE_CLASS3=ON"
;;
gpu)
if [ x"$CXX" == x"" ]; then
conf_options="$conf_options"
else
conf_options="$conf_options -DCMAKE_CUDA_HOST_COMPILER=$(which $CXX)"
fi
conf_options="$conf_options -DENABLE_GPU=ON"
;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
ac_unrecognized_sep=', '
;;
esac
eval enable_$ac_useropt=\$ac_optarg ;;
-exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
| --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
| --exec | --exe | --ex)
ac_prev=exec_prefix ;;
-exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
| --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
| --exec=* | --exe=* | --ex=*)
exec_prefix=$ac_optarg ;;
-gas | --gas | --ga | --g)
# Obsolete; use --with-gas.
with_gas=yes ;;
-help | --help | --hel | --he | -h)
ac_init_help=long ;;
-help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
ac_init_help=recursive ;;
-help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
ac_init_help=short ;;
-host | --host | --hos | --ho)
ac_prev=host_alias ;;
-host=* | --host=* | --hos=* | --ho=*)
host_alias=$ac_optarg ;;
-htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
ac_prev=htmldir ;;
-htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
| --ht=*)
htmldir=$ac_optarg ;;
-includedir | --includedir | --includedi | --included | --include \
| --includ | --inclu | --incl | --inc)
ac_prev=includedir ;;
-includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
| --includ=* | --inclu=* | --incl=* | --inc=*)
includedir=$ac_optarg ;;
-infodir | --infodir | --infodi | --infod | --info | --inf)
ac_prev=infodir ;;
-infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
infodir=$ac_optarg ;;
-libdir | --libdir | --libdi | --libd)
ac_prev=libdir ;;
-libdir=* | --libdir=* | --libdi=* | --libd=*)
libdir=$ac_optarg ;;
-libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
| --libexe | --libex | --libe)
ac_prev=libexecdir ;;
-libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
| --libexe=* | --libex=* | --libe=*)
libexecdir=$ac_optarg ;;
-localedir | --localedir | --localedi | --localed | --locale)
ac_prev=localedir ;;
-localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
localedir=$ac_optarg ;;
-localstatedir | --localstatedir | --localstatedi | --localstated \
| --localstate | --localstat | --localsta | --localst | --locals)
ac_prev=localstatedir ;;
-localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
| --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
localstatedir=$ac_optarg ;;
-mandir | --mandir | --mandi | --mand | --man | --ma | --m)
ac_prev=mandir ;;
-mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
mandir=$ac_optarg ;;
-nfp | --nfp | --nf)
# Obsolete; use --without-fp.
with_fp=no ;;
-no-create | --no-create | --no-creat | --no-crea | --no-cre \
| --no-cr | --no-c | -n)
no_create=yes ;;
-no-recursion | --no-recursion | --no-recursio | --no-recursi \
| --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
no_recursion=yes ;;
-oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
| --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
| --oldin | --oldi | --old | --ol | --o)
ac_prev=oldincludedir ;;
-oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
| --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
| --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
oldincludedir=$ac_optarg ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
prefix=$ac_optarg
conf_options="$conf_options -DCMAKE_INSTALL_PREFIX=$ac_optarg"
echo "$prefix" > install_dir
;;
-program-prefix | --program-prefix | --program-prefi | --program-pref \
| --program-pre | --program-pr | --program-p)
ac_prev=program_prefix ;;
-program-prefix=* | --program-prefix=* | --program-prefi=* \
| --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
program_prefix=$ac_optarg ;;
-program-suffix | --program-suffix | --program-suffi | --program-suff \
| --program-suf | --program-su | --program-s)
ac_prev=program_suffix ;;
-program-suffix=* | --program-suffix=* | --program-suffi=* \
| --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
program_suffix=$ac_optarg ;;
-program-transform-name | --program-transform-name \
| --program-transform-nam | --program-transform-na \
| --program-transform-n | --program-transform- \
| --program-transform | --program-transfor \
| --program-transfo | --program-transf \
| --program-trans | --program-tran \
| --progr-tra | --program-tr | --program-t)
ac_prev=program_transform_name ;;
-program-transform-name=* | --program-transform-name=* \
| --program-transform-nam=* | --program-transform-na=* \
| --program-transform-n=* | --program-transform-=* \
| --program-transform=* | --program-transfor=* \
| --program-transfo=* | --program-transf=* \
| --program-trans=* | --program-tran=* \
| --progr-tra=* | --program-tr=* | --program-t=*)
program_transform_name=$ac_optarg ;;
-pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
ac_prev=pdfdir ;;
-pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
pdfdir=$ac_optarg ;;
-psdir | --psdir | --psdi | --psd | --ps)
ac_prev=psdir ;;
-psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
psdir=$ac_optarg ;;
-q | -quiet | --quiet | --quie | --qui | --qu | --q \
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
| --sbi=* | --sb=*)
sbindir=$ac_optarg ;;
-sharedstatedir | --sharedstatedir | --sharedstatedi \
| --sharedstated | --sharedstate | --sharedstat | --sharedsta \
| --sharedst | --shareds | --shared | --share | --shar \
| --sha | --sh)
ac_prev=sharedstatedir ;;
-sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
| --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
| --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
| --sha=* | --sh=*)
sharedstatedir=$ac_optarg ;;
-site | --site | --sit)
ac_prev=site ;;
-site=* | --site=* | --sit=*)
site=$ac_optarg ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
srcdir=$ac_optarg ;;
-sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
| --syscon | --sysco | --sysc | --sys | --sy)
ac_prev=sysconfdir ;;
-sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
| --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
sysconfdir=$ac_optarg ;;
-target | --target | --targe | --targ | --tar | --ta | --t)
ac_prev=target_alias ;;
-target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
target_alias=$ac_optarg ;;
-v | -verbose | --verbose | --verbos | --verbo | --verb)
verbose=yes ;;
-version | --version | --versio | --versi | --vers | -V)
ac_init_version=: ;;
-with-* | --with-*)
ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_useropt in
libhilbert)
conf_options="$conf_options -DLIBHILBERT_ROOT=$ac_optarg"
;;
metis)
conf_options="$conf_options -DMETIS_ROOT=$ac_optarg"
;;
parmetis)
conf_options="$conf_options -DPARMETIS_ROOT=$ac_optarg"
;;
hdf5)
conf_options="$conf_options -DHDF5_ROOT=$ac_optarg"
;;
petsc)
conf_options="$conf_options -DPETSC_ROOT=$ac_optarg"
;;
blas)
conf_options="$conf_options -DOPENBLAS_ROOT=$ac_optarg"
;;
suitesparse)
conf_options="$conf_options -DSUITESPARSE_ROOT=$ac_optarg"
;;
eigen)
conf_options="$conf_options -DEIGEN3_ROOT=$ac_optarg"
;;
boost)
conf_options="$conf_options -DBOOST_ROOT=$ac_optarg"
;;
mpivendor)
conf_options="$conf_options -DMPI_VENDOR=$ac_optarg"
;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=\$ac_optarg ;;
-without-* | --without-*)
ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
# Reject names that are not valid shell variable names.
expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
as_fn_error $? "invalid package name: $ac_useropt"
ac_useropt_orig=$ac_useropt
ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
case $ac_user_opts in
*"
"with_$ac_useropt"
"*) ;;
*) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
ac_unrecognized_sep=', ';;
esac
eval with_$ac_useropt=no ;;
--x)
# Obsolete; use --with-x.
with_x=yes ;;
-x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
| --x-incl | --x-inc | --x-in | --x-i)
ac_prev=x_includes ;;
-x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
| --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
x_includes=$ac_optarg ;;
-x-libraries | --x-libraries | --x-librarie | --x-librari \
| --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
ac_prev=x_libraries ;;
-x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
| --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
x_libraries=$ac_optarg ;;
-*) as_fn_error $? "unrecognized option: \`$ac_option'
Try \`$0 --help' for more information"
;;
*=*)
ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
# Reject names that are not valid shell variable names.
case $ac_envvar in #(
'' | [0-9]* | *[!_$as_cr_alnum]* )
as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
esac
eval $ac_envvar=\$ac_optarg
export $ac_envvar ;;
*)
# FIXME: should be removed in autoconf 3.0.
$as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
$as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
: "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
;;
esac
done
if [ x"$debug_mode" != x"1" ]; then
conf_options="$conf_options -DCMAKE_BUILD_TYPE=Release"
fi
cd build
## remove enerything
echo "Calling cmake ../. $conf_options"
rm ../error_code
cmake ../. $conf_options
if [ $? != 0 ]; then
#ok something went wrong the install script analyze the return code to potentially fix the problem automatically
# Read the error code and exit with that
if [ -f ../error_code ]; then
ecod=$(cat ../error_code)
if [ x"$ecod" == x"0" ]; then
exit 1
else
echo "Analyze error $ecod"
exit $ecod
fi
else
exit 1
fi
fi
cd ..
echo "all:
\$(MAKE) -C build \$@
clean:
\$(MAKE) -C build \$@
install:
\$(MAKE) -C build \$@
pdata:
\$(MAKE) -C build \$@
numerics:
\$(MAKE) -C build \$@
.PHONY: all clean install" > Makefile
echo "$0 $@" > config.log
include ../../example.mk
CC=mpic++
LDIR =
OBJ = main.o
%.o: %.cpp
$(CC) -O3 -g3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
se_classes: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: se_classes
run: all
.PHONY: clean all run
clean:
rm -f *.o *~ core se_classes
[pack]
files = main.cpp Makefile
/*
* ### WIKI 1 ###
*
* ## Security enhancement example
*
* This example show several basic functionalities of Security Enhancements
*
*/
#define SE_CLASS1
#define SE_CLASS2
#define SE_CLASS3
#define THROW_ON_ERROR
#include "Memleak_check.hpp"
#include "Vector/vector_dist.hpp"
#include "Decomposition/CartDecomposition.hpp"
#include "Point_test.hpp"
/*
* ### WIKI END ###
*/
int main(int argc, char* argv[])
{
//
// ### WIKI 2 ###
//
// With print_unalloc we can check how much memory has been allocated and which structure
// has been allocated, initially there are not
//
std::cout << "Allocated memory before initializing \n";
print_alloc();
std::cout << "\n";
std::cout << "\n";
std::cout << "\n";
//
// ### WIKI 3 ###
//
// Here we Initialize the library, than we create a uniform random generator between 0 and 1 to to generate particles
// randomly in the domain, we create a Box that define our domain, boundary conditions and ghost
//
openfpm_init(&argc,&argv);
Vcluster<> & v_cl = create_vcluster();
typedef Point<2,float> s;
Box<2,float> box({0.0,0.0},{1.0,1.0});
size_t bc[2]={NON_PERIODIC,NON_PERIODIC};
Ghost<2,float> g(0.01);
//
// ### WIKI 4 ###
//
// Here we ask again for the used memory, as we can see Vcluster and several other structures encapsulated inside
// Vcluster register itself
//
if (v_cl.getProcessUnitID() == 0)
{
std::cout << "Allocated memory after initialization \n";
print_alloc();
std::cout << "\n";
std::cout << "\n";
std::cout << "\n";
}
//
// ### WIKI 5 ###
//
// Here we are creating a distributed vector defined by the following parameters
//
// * Dimensionality of the space where the objects live 2D (1° template parameters)
// * Type of the space, float (2° template parameters)
// * Information stored by each object (3* template parameters), in this case a Point_test store 4 scalars
// 1 vector and an asymmetric tensor of rank 2
// * Strategy used to decompose the space
//
// The Constructor instead require:
//
// * Number of particles 4096 in this case
// * Domain where is defined this structure
//
// The following construct a vector where each processor has 4096 / N_proc (N_proc = number of processor)
// objects with an undefined position in space. This non-space decomposition is also called data-driven
// decomposition
//
{
vector_dist<2,float, Point_test<float> > vd(4096,box,bc,g);
//
// ### WIKI 6 ###
//
// we create a key that for sure overflow the local datastructure, 2048 with this program is started with more than 3
// processors, try and catch are optionals in case you want to recover from a buffer overflow
//
try
{
vect_dist_key_dx vt(5048);
auto it = vd.getPos(vt);
}
catch (size_t e)
{
std::cerr << "Error notification of overflow \n";
}
}
//
// ### WIKI 7 ###
//
// At this point the vector went out of the scope and if destroyed
// we create, now two of them using new
//
vector_dist<2,float, Point_test<float> > * vd1 = new vector_dist<2,float, Point_test<float>, CartDecomposition<2,float> >(4096,box,bc,g);
vector_dist<2,float, Point_test<float> > * vd2 = new vector_dist<2,float, Point_test<float>, CartDecomposition<2,float> >(4096,box,bc,g);
//
// ### WIKI 8 ###
//
// we can check that these two structure produce an explicit allocation checking
// for registered pointers and structures with print_alloc, in the list we see 2 additional
// entry for distributed vector in yellow, pdata to work use the data structures that register
// itself in magenta, the same things happen for the real memory allocation from devices in
// fully green
//
if (v_cl.getProcessUnitID() == 0)
{
std::cout << "Allocated memory with 2 vectors \n";
print_alloc();
std::cout << "\n";
std::cout << "\n";
std::cout << "\n";
}
//
// ### WIKI 9 ###
//
// we can also ask to the structure to identify their-self in the list
//
std::cout << "Vector id: " << vd1->who() << "\n";
std::cout << "Vector id: " << vd2->who() << "\n";
//
// ### WIKI 10 ###
//
// delete vd1 and print allocated memory, one distributed vector disappear
//
delete vd1;
if (v_cl.getProcessUnitID() == 0)
{
std::cout << "Allocated memory with 1 vector \n";
print_alloc();
std::cout << "\n";
std::cout << "\n";
std::cout << "\n";
}
//
// ### WIKI 11 ###
//
// delete vd2 and print allocated memory, all distributed vector de-register
//
delete vd2;
if (v_cl.getProcessUnitID() == 0)
{
std::cout << "Allocated memory with 1 vector \n";
print_alloc();
std::cout << "\n";
std::cout << "\n";
std::cout << "\n";
}
//
// ### WIKI 12 ###
//
// Try to use a deleted object
//
try
{
vect_dist_key_dx vt(0);
auto it = vd1->getPos(vt);
}
catch (std::exception & e)
{
std::cerr << "Error notification of invalid usage of deleted object \n";
}
//
// ### WIKI 13 ###
//
// Deinitialize the library
//
openfpm_finalize();
}
include ../../example.mk
CC=mpic++
LDIR =
OBJ = main.o
%.o: %.cpp
$(CC) -O3 -g3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
se_classes: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: se_classes
run: all
.PHONY: clean all run
clean:
rm -f *.o *~ core se_classes
[pack]
files = main.cpp Makefile
/*
* ### WIKI 1 ###
*
* ## Security enhancement example
*
* This example show how to see where an allocation or corruption happen offline and online.
* Every time an error occur, the library output where the detection happen filename and line,
* in order to debug, there is an online option and an offline option
*
* * online: put a breakpoint on the indicated line with your preferred debugger
* * offline: set ulimit -c unlimited to activate the core dump file and open the core dump with your debugger
*
*/
#define SE_CLASS1
#define SE_CLASS2
#define SE_CLASS3
#define THROW_ON_ERROR
#include "Memleak_check.hpp"
#include "Grid/grid_dist_id.hpp"
#include "Decomposition/CartDecomposition.hpp"
#include "Point_test.hpp"
/*
* ### WIKI END ###
*/
int main(int argc, char* argv[])
{
//
// ### WIKI 2 ###
//
// Here we Initialize the library,
// * message_on_allocation set a message to print when one allocation is reached, the filename and line number can be used to set a breakpoint and analyze the stacktrace.
// * throw_on_allocation throw when one allocation is reached, producing the termination of the program and a core dump (if no try catch is set-up)
//
openfpm_init(&argc,&argv);
Vcluster<> & v_cl = create_vcluster();
throw_on_alloc(10);
// message_on_alloc(10);
//
// ### WIKI 3 ###
//
// Create several object needed later, in particular
// * A 3D box that define the domain
// * an array of 3 unsigned integer that define the size of the grid on each dimension
// * A Ghost object that will define the extension of the ghost part for each sub-domain in physical units
Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
size_t sz[3];
sz[0] = 100;
sz[1] = 100;
sz[2] = 100;
// Ghost
Ghost<3,float> g(0.01);
//
// ### WIKI 4 ###
//
// Create a distributed grid in 3D (1° template parameter) defined in R^3 with float precision (2° template parameter)
// using a CartesianDecomposition strategy (3° parameter) (the parameter 1° and 2° inside CartDecomposition must match 1° and 2°
// of grid_dist_id)
//
// Constructor parameters:
//
// * sz: size of the grid on each dimension
// * domain: where the grid is defined
// * g: ghost extension
//
//
grid_dist_id<3, float, aggregate<float[3]>, CartDecomposition<3,float>> * g_dist = new grid_dist_id<3, float, aggregate<float[3]> >(sz,domain,g);
//
// ### WIKI 6 ###
//
// print allocated structures
//
if (v_cl.getProcessUnitID() == 0)
print_alloc();
//
// ### WIKI 5 ###
//
// delete g_dist
//
delete g_dist;
//
// ### WIKI 6 ###
//
// On purpose we try to access a deleted object
//
g_dist->getGridInfo();
//
// ### WIKI 13 ###
//
// Deinitialize the library
//
openfpm_finalize();
}
SUBDIRS := $(wildcard */.)
all clean run: $(SUBDIRS)
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
.PHONY: all clean $(SUBDIRS)
include ../../example.mk
CC=mpic++
LDIR =
OBJ = main.o
%.o: %.cpp
$(CC) -O3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
grid: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: grid
run: all
mpirun -np 2 ./grid
.PHONY: clean all run
clean:
rm -f *.o *~ core grid
[pack]
files = main.cpp Makefile
#include "Grid/grid_dist_id.hpp"
#include "data_type/aggregate.hpp"
/*! \page grid Grid
*
* \subpage grid_0_simple
* \subpage grid_1_save_load
* \subpage Grid_1_stencil
* \subpage Grid_2_solve_eq
* \subpage Grid_3_gs
* \subpage Grid_3_gs_3D
* \subpage Grid_3_gs_3D_vector
*
*/
/*! \page grid_0_simple Simple usage
[TOC]
# Simple grid example # {#simple_grid_example}
This example show several basic functionalities of the distributed grid
\htmlonly
<a href="#" onclick="if (document.getElementById('grid-video-1').style.display == 'none') {document.getElementById('grid-video-1').style.display = 'block'} else {document.getElementById('grid-video-1').style.display = 'none'}" >Video</a>
<div style="display:none" id="grid-video-1">
<video id="vid1" width="1200" height="576" controls> <source src="http://ppmcore.mpi-cbg.de/upload/video/Lesson1-1.mp4" type="video/mp4"></video><script>document.getElementById('vid1').addEventListener('loadedmetadata', function() {this.currentTime = 236;}, false);</script>
</div>
\endhtmlonly
*/
int main(int argc, char* argv[])
{
/*! \page grid_0_simple Simple usage
*
* ## Initialization ## {#e0_s_initialization}
*
* Here we:
* * Initialize the library
* * Create A 3D box that define our the domain
* * an array of 3 unsigned integer that will define the size of the grid on each dimensions
* * A Ghost object that will define the extension of the ghost part in physical units
*
* \snippet Grid/0_simple/main.cpp initialization
*
*/
//! \cond [initialization] \endcond
// Initialize the library
openfpm_init(&argc,&argv);
// 3D physical domain
Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
// Grid size on eaxh dimension
size_t sz[3] = {100,100,100};
// Ghost part
Ghost<3,float> g(0.1);
//! \cond [initialization] \endcond
/*! \page grid_0_simple Simple usage
*
* ## Grid instantiation ## {#e0_s_grid_inst}
*
* Here we are creating a distributed grid defined by the following parameters
*
* * 3 dimensionality of the grid
* * float type used for the spatial coordinates
* * each grid point contain a vector of dimension 3 (float[3]),
* * float[3] is the information stored by each grid point a float[3]
* the list of properties must be put into an aggregate data structure aggregate<prop1,prop2,prop3, ... >
*
* Constructor parameters:
*
* * sz: size of the grid on each dimension
* * domain: where the grid is defined
* * g: ghost extension
*
* \snippet Grid/0_simple/main.cpp grid instantiation
*
*/
//! \cond [grid instantiation] \endcond
grid_dist_id<3, float, aggregate<float[3]>> g_dist(sz,domain,g);
//! \cond [grid instantiation] \endcond
/*!
* \page grid_0_simple Simple usage
*
* ## Loop over grid points ## {#e0_s_loop_gp}
*
* Get an iterator that go through all the grid points. In this
* example we use iterators. Iterators are convenient way to explore/iterate data-structures.
*
* \snippet Grid/0_simple/main.cpp get iterator
* \snippet Grid/0_simple/main.cpp get iterator2
*
*/
//! \cond [get iterator] \endcond
// Get the iterator (No ghost)
auto dom = g_dist.getDomainIterator();
// Counter
size_t count = 0;
// Iterate over all the grid points
while (dom.isNext())
{
//! \cond [get iterator] \endcond
/*!
* \page grid_0_simple Simple usage
*
* ## Grid coordinates ## {#e0_s_grid_coord}
*
* Get the local grid key, one local grid key* identify one point in the grid and store the local grid coordinates of such point
*
* <sub><sup>(*)Internally a local grid store the sub-domain id (each sub-domain contain a grid) and the local grid point id identified by 2 integers in 2D 3 integer in 3D and so on. These two distinct elements are available with key.getSub() and key.getKey().</sup></sub>
*
* \snippet Grid/0_simple/main.cpp local grid
*
*/
//! \cond [local grid] \endcond
// local grid key from iterator
auto key = dom.get();
//! \cond [local grid] \endcond
/*!
* \page grid_0_simple Simple usage
*
* **Short explanation**
*
* In oder to get the real/global coordinates of the grid point we have to convert the object key with getGKey
*
*/
/*!
*
* \page grid_0_simple Simple usage
*
\htmlonly <a href="#" onclick="if (document.getElementById('long-explanation-div').style.display == 'none') {document.getElementById('long-explanation-div').style.display = 'block'} else {document.getElementById('long-explanation-div').style.display = 'none'}" >Long Explanation</a> \endhtmlonly
*
*
\htmlonly
<div style="display:none" id="long-explanation-div">
<p>Even if the local grid key identify an unique point in the grid, it does not store the real/global coordinates of the points in grid units.</p>
<p>Consider this scheme</p>
<pre class="fragment">
+-----+-----+--*--+-----+-----+-----+ (6,6)
| | P1,3 |
| P1,1 *--------------------*
| | P1,2 |
+ + + | + + + +
| *--------------------*
*--------------* |
| | |
+ + + | + + + +
| | |
| P0,2 | P1,0 |
| | |
+ + + | # + + +
| | |
*--------------* |
| *--------------------*
+ + + | + + + +
| | |
| P0,0 | P0,1 |
| | |
+-----+-----+--*--+-----+-----+-----+
(0,0) (6,0)
+,# = grid point
*--*
| | = uderline decomposition in sub-domain
*--*
PX,Y Processor X, sub-domain Y</pre><p>The point # has</p>
<ul>
<li>Global/Real coordinates (3,2)</li>
<li>Local grid coordinates are Sub-domain = 0, grid position = (0,0)</li>
</ul>
<p>Here we convert the local grid coordinates, into global coordinates. key_g internally store 3 integers that identify the position of the grid point in global coordinates</p>
<p>
</div>
\endhtmlonly
*/
/*! \page grid_0_simple Simple usage
*
* \snippet Grid/0_simple/main.cpp global coord
*
*/
//! \cond [global coord] \endcond
auto key_g = g_dist.getGKey(key);
//! \cond [global coord] \endcond
/*!
* \page grid_0_simple Simple usage
*
* ## Assign properties ## {#grid_assign}
*
* Each grid point has a vector property we write on the vector coordinates the global coordinate of the grid point.
* At the same time we also count the points
*
* \snippet Grid/0_simple/main.cpp assign
*
*/
//! \cond [assign] \endcond
g_dist.template get<0>(key)[0] = key_g.get(0);
g_dist.template get<0>(key)[1] = key_g.get(1);
g_dist.template get<0>(key)[2] = key_g.get(2);
// Count the points
count++;
//! \cond [assign] \endcond
//! \cond [get iterator2] \endcond
// next point
++dom;
}
//! \cond [get iterator2] \endcond
/*!
* \page grid_0_simple Simple usage
*
* Each sub-domain has an extended part, that is materially contained in
* another processor. The function ghost_get guarantee (after return) that this extended part
* is perfectly synchronized with the other processor.
*
* \snippet Grid/0_simple/main.cpp ghost get
*
*/
//! \cond [ghost get] \endcond
g_dist.template ghost_get<0>();
//! \cond [ghost get] \endcond
/*!
* \page grid_0_simple Simple usage
*
* count contain the number of points the local processor contain, if we are interested to count the total number across the processor
* we can use the function sum, to sum numbers across processors. First we have to get an instance of Vcluster, queue an operation of sum with
* the variable count and finally execute. All the operation are asynchronous, execute work like a barrier and ensure that all the
* queued operations are executed
*
* \snippet Grid/0_simple/main.cpp reduce
*
*/
//! \cond [reduce] \endcond
// Get the VCluster object
Vcluster<> & vcl = create_vcluster();
// queue an operation of sum for the counter count
vcl.sum(count);
// execute the operation
vcl.execute();
// only master output
if (vcl.getProcessUnitID() == 0)
std::cout << "Number of points: " << count << "\n";
//! \cond [reduce] \endcond
/*!
* \page grid_0_simple Simple usage
*
* ## VTK and visualization ## {#e0_s_VTK_vis}
*
* Finally we want a nice output to visualize the information stored by the distributed grid.
* The function write by default produce VTK files. One for each processor that can be visualized
* with the programs like paraview
*
* \htmlonly
* <img src="http://ppmcore.mpi-cbg.de/web/images/examples/0_simple_grid/0_simple_grid_init.jpg"/>
* \endhtmlonly
*
* \snippet Grid/0_simple/main.cpp write
*
*/
//! \cond [write] \endcond
g_dist.write("output");
//! \cond [write] \endcond
/*!
* \page grid_0_simple Simple usage
*
* ## Decomposition ## {#grid_dec}
*
* For debugging purpose and demonstration we also output the decomposition of the
* space across processor. This function produce VTK files that can be visualized with Paraview
*
* \snippet Grid/0_simple/main.cpp out_dec
*
* \htmlonly
* <img src="http://ppmcore.mpi-cbg.de/web/images/examples/0_simple_grid/0_simple_grid_dec.jpg"/>
* \endhtmlonly
*
* Here we see the decomposition in 3D for 2 processors. The red box in wire-frame is the processor 0
* subdomain. The blu one is the processor 1 sub-domain. The red solid box is the extended part for processor 0
* the blu solid part is the extended part for processor 1
*
*
*/
//! \cond [out_dec] \endcond
g_dist.getDecomposition().write("out_dec");
//! \cond [out_dec] \endcond
/*!
* \page grid_0_simple Simple usage
*
* ## Finalize ## {#finalize}
*
* At the very end of the program we have always to de-initialize the library
*
* \snippet Vector/0_simple/main.cpp finalize
*
*/
//! \cond [finalize] \endcond
openfpm_finalize();
//! \cond [finalize] \endcond
/*!
* \page grid_0_simple Simple usage
*
* # Full code # {#code}
*
* \include Grid/0_simple/main.cpp
*
*/
}
include ../../example.mk
CC=mpic++
LDIR =
OBJ = main.o
%.o: %.cpp
$(CC) -O3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
stencil: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: stencil
run: all
mpirun -np 3 ./stencil
.PHONY: clean all run
clean:
rm -f *.o *~ core stencil
[pack]
files = main.cpp Makefile
#include "Grid/grid_dist_id.hpp"
#include "data_type/aggregate.hpp"
#include "Decomposition/CartDecomposition.hpp"
/*!
* \page Grid_1_stencil Stencil example
*
*
* # Stencil example and ghost # {#e1_st}
*
* This example show how to move grid_key in order to create a Laplacian stencil,
* be careful, the function move is convenient, but not the fastest implementation.
* We also show how to do ghost communications
*
*/
/*!
* \page Grid_1_stencil Stencil example
*
* Define some convenient constants and types
*
* \snippet Grid/1_stencil/main.cpp useful constant
*
*/
//! \cond [useful constant] \endcond
constexpr size_t x = 0;
constexpr size_t y = 1;
constexpr size_t z = 2;
constexpr size_t A = 0;
constexpr size_t B = 0;
//! \cond [useful constant] \endcond
int main(int argc, char* argv[])
{
/*!
* \page Grid_1_stencil Stencil example
*
* ## Initialization ## {#e1_st_init}
*
* Initialize the library and several objects
*
* \see \ref e0_s_initialization
*
* \snippet Grid/1_stencil/main.cpp parameters
*
*
*/
//! \cond [parameters] \endcond
openfpm_init(&argc,&argv);
// domain
Box<3,float> domain({0.0,0.0,0.0},{1.0,1.0,1.0});
// grid sizes
size_t sz[3] = {100,100,100};
// ghost extension
Ghost<3,float> g(0.03);
//! \cond [parameters] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* ## Grid create ## {#e1_st_inst}
*
* Create a distributed grid in 3D. With typedef we create an alias name for aggregate<float[3],float[3]>.
* In practice the type of grid_point == aggregate<float[3],float[3]>
*
* \see \ref e0_s_grid_inst
*
* \snippet Grid/1_stencil/main.cpp grid
*
*/
//! \cond [grid] \endcond
// a convenient alias for aggregate<...>
typedef aggregate<float,float> grid_point;
grid_dist_id<3, float, grid_point> g_dist(sz,domain,g);
//! \cond [grid] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* ## Loop over grid points ## {#e1_s_loop_gp}
*
* Get an iterator that go through the point of the domain (No ghost)
*
* \see \ref e0_s_loop_gp
*
* \snippet Grid/1_stencil/main.cpp iterator
* \snippet Grid/1_stencil/main.cpp iterator2
*
*/
//! \cond [iterator] \endcond
auto dom = g_dist.getDomainIterator();
while (dom.isNext())
{
//! \cond [iterator] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* Inside the cycle we get the local grid key
*
* \see \ref e0_s_grid_coord
*
* \snippet Grid/1_stencil/main.cpp local key
*
*/
//! \cond [local key] \endcond
auto key = dom.get();
//! \cond [local key] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* We convert the local grid position, into global position, key_g contain 3 integers that identify the position
* of the grid point in global coordinates
*
* \see \ref e0_s_grid_coord
*
* \snippet Grid/1_stencil/main.cpp global key
*
*/
//! \cond [global key] \endcond
auto key_g = g_dist.getGKey(key);
//! \cond [global key] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* we write on the grid point of position (i,j,k) the value i*i + j*j + k*k on the property A.
* Mathematically is equivalent to the function
*
* \f$ f(x,y,z) = x^2 + y^2 + z^2 \f$
*
* \snippet Grid/1_stencil/main.cpp function
*
*/
//! \cond [function] \endcond
g_dist.template get<A>(key) = key_g.get(0)*key_g.get(0) + key_g.get(1)*key_g.get(1) + key_g.get(2)*key_g.get(2);
//! \cond [function] \endcond
//! \cond [iterator2] \endcond
++dom;
}
//! \cond [iterator2] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* ## Ghost ## {#e1_s_ghost}
*
* Each sub-domain has an extended part, that is materially contained into another processor.
* In general is not synchronized
* ghost_get<A> synchronize the property A in the ghost part
*
* \snippet Grid/1_stencil/main.cpp ghost
*
*/
//! \cond [ghost] \endcond
g_dist.template ghost_get<A>();
//! \cond [ghost] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* Get again another iterator, iterate across all the domain points, calculating a Laplace stencil. Write the
* result on B
*
* \snippet Grid/1_stencil/main.cpp laplacian
*
*/
//! \cond [laplacian] \endcond
auto dom2 = g_dist.getDomainIterator();
while (dom2.isNext())
{
auto key = dom2.get();
// Laplace stencil
g_dist.template get<B>(key) = g_dist.template get<A>(key.move(x,1)) + g_dist.template get<A>(key.move(x,-1)) +
g_dist.template get<A>(key.move(y,1)) + g_dist.template get<A>(key.move(y,-1)) +
g_dist.template get<A>(key.move(z,1)) + g_dist.template get<A>(key.move(z,-1)) -
6*g_dist.template get<A>(key);
++dom2;
}
//! \cond [laplacian] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
*
* Finally we want a nice output to visualize the information stored by the distributed grid
*
* \see \ref e0_s_VTK_vis
*
* \snippet Grid/1_stencil/main.cpp output
*
*/
//! \cond [output] \endcond
g_dist.write("output");
//! \cond [output] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* Deinitialize the library
*
* \snippet Grid/1_stencil/main.cpp finalize
*
*/
//! \cond [finalize] \endcond
openfpm_finalize();
//! \cond [finalize] \endcond
/*!
* \page Grid_1_stencil Stencil example
*
* # Full code # {#code}
*
* \include Grid/1_stencil/main.cpp
*
*/
}