diff --git a/.clang-format b/.clang-format index bfa91604a..4c59aaa02 100644 --- a/.clang-format +++ b/.clang-format @@ -1,57 +1,57 @@ --- Language: Cpp BasedOnStyle: LLVM -Standard: Cpp11 +Standard: Cpp14 IndentWidth: 2 TabWidth: 4 UseTab: Never ColumnLimit: 80 AccessModifierOffset: -2 PointerAlignment: Middle NamespaceIndentation: Inner ContinuationIndentWidth: 4 # ConstructorInitializerIndentWidth: 4 # AlignEscapedNewlinesLeft: false # AlignTrailingComments: true # AllowAllParametersOfDeclarationOnNextLine: true # AllowShortBlocksOnASingleLine: false # AllowShortIfStatementsOnASingleLine: false # AllowShortLoopsOnASingleLine: false # AllowShortFunctionsOnASingleLine: All # AlwaysBreakTemplateDeclarations: false # AlwaysBreakBeforeMultilineStrings: false # BreakBeforeBinaryOperators: false # BreakBeforeTernaryOperators: true # BreakConstructorInitializersBeforeComma: false # BinPackParameters: true # ConstructorInitializerAllOnOneLineOrOnePerLine: false # DerivePointerAlignment: false # ExperimentalAutoDetectBinPacking: false # IndentCaseLabels: false # IndentWrappedFunctionNames: false # IndentFunctionDeclarationAfterType: false # MaxEmptyLinesToKeep: 1 # KeepEmptyLinesAtTheStartOfBlocks: true # ObjCSpaceAfterProperty: false # ObjCSpaceBeforeProtocolList: true # PenaltyBreakBeforeFirstCallParameter: 19 # PenaltyBreakComment: 300 # PenaltyBreakString: 1000 # PenaltyBreakFirstLessLess: 120 # PenaltyExcessCharacter: 1000000 # PenaltyReturnTypeOnItsOwnLine: 60 # SpacesBeforeTrailingComments: 1 # Cpp11BracedListStyle: true # BreakBeforeBraces: Attach # SpacesInParentheses: false # SpacesInAngles: false # SpaceInEmptyParentheses: false # SpacesInCStyleCastParentheses: false # SpacesInContainerLiterals: true # SpaceBeforeAssignmentOperators: true # CommentPragmas: '^ IWYU pragma:' # ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] # SpaceBeforeParens: ControlStatements # DisableFormat: false ... diff --git a/CMakeLists.txt b/CMakeLists.txt index cfb70d1dd..82e0a425c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,183 +1,183 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jun 14 2010 # @date last modification: Fri Jan 22 2016 # # @brief main configuration file # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # # @section DESCRIPTION #------------------------------------------------------------------------------- # _ _ # | | | | # __ _| | ____ _ _ __ | |_ _ _ # / _` | |/ / _` | '_ \| __| | | | # | (_| | < (_| | | | | |_| |_| | # \__,_|_|\_\__,_|_| |_|\__|\__,_| # #=============================================================================== #=============================================================================== # CMake Project #=============================================================================== -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1.3) # add this options before PROJECT keyword set(CMAKE_DISABLE_SOURCE_CHANGES ON) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) project(Akantu) enable_language(CXX) #=============================================================================== # Misc. config for cmake #=============================================================================== set(AKANTU_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules") set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") mark_as_advanced(BUILD_SHARED_LIBS) if(NOT AKANTU_TARGETS_EXPORT) set(AKANTU_TARGETS_EXPORT AkantuLibraryDepends) endif() include(CMakeVersionGenerator) include(CMakePackagesSystem) include(CMakeFlagsHandling) include(AkantuPackagesSystem) include(AkantuMacros) include(AkantuCleaning) #cmake_activate_debug_message() #=============================================================================== # Version Number #=============================================================================== # AKANTU version number. An even minor number corresponds to releases. set(AKANTU_MAJOR_VERSION 3) set(AKANTU_MINOR_VERSION 0) set(AKANTU_PATCH_VERSION 0) define_project_version() #=============================================================================== # Options #=============================================================================== # Debug set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DAKANTU_NDEBUG" CACHE STRING "Flags used by the compiler during release builds" FORCE) #add_flags(cxx "-Wall -Wextra -pedantic -Werror") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_flags(cxx "-Wall -Wextra -pedantic") else() add_flags(cxx "-Wall") endif() include(AkantuExtraCompilationProfiles) #=============================================================================== # Dependencies #=============================================================================== declare_akantu_types() package_list_packages(${PROJECT_SOURCE_DIR}/packages EXTRA_PACKAGES_FOLDER ${PROJECT_SOURCE_DIR}/extra_packages NO_AUTO_COMPILE_FLAGS) ## meta option \todo better way to do it when multiple package give enable the ## same feature if(AKANTU_SCOTCH) set(AKANTU_PARTITIONER ON) else() set(AKANTU_PARTITIONER OFF) endif() if(AKANTU_MUMPS) set(AKANTU_SOLVER ON) else() set(AKANTU_SOLVER OFF) endif() #=============================================================================== # Akantu library #=============================================================================== add_subdirectory(src) #=============================================================================== # Documentation #=============================================================================== if(AKANTU_DOCUMENTATION_DOXYGEN OR AKANTU_DOCUMENTATION_MANUAL) add_subdirectory(doc) else() set(AKANTU_DOC_EXCLUDE_FILES "${PROJECT_SOURCE_DIR}/doc/manual" CACHE INTERNAL "") endif() #=============================================================================== # Examples and tests #=============================================================================== option(AKANTU_EXAMPLES "Activate examples" OFF) option(AKANTU_TESTS "Activate tests" OFF) include(AkantuTestsMacros) include(AkantuExampleMacros) if(AKANTU_TESTS) option(AKANTU_BUILD_ALL_TESTS "Build all tests" ON) find_package(GMSH REQUIRED) endif() if(AKANTU_EXAMPLES) find_package(GMSH REQUIRED) add_subdirectory(examples) endif() # tests add_test_tree(test) #=============================================================================== # Python interface #=============================================================================== package_is_activated(python_interface _python_act) if(_python_act) if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") set(AKANTU_PYTHON_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) else() set(AKANTU_PYTHON_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") endif() add_subdirectory(python) endif() #=============================================================================== # Install and Packaging #=============================================================================== include(AkantuInstall) option(AKANTU_DISABLE_CPACK "This option commands the generation of extra info for the \"make package\" target" ON) mark_as_advanced(AKANTU_DISABLE_CPACK) if(NOT AKANTU_DISABLE_CPACK) include(AkantuCPack) endif() diff --git a/cmake/AkantuConfig.cmake.in b/cmake/AkantuConfig.cmake.in index a1c8a82db..738ea8cda 100644 --- a/cmake/AkantuConfig.cmake.in +++ b/cmake/AkantuConfig.cmake.in @@ -1,68 +1,65 @@ #=============================================================================== # @file AkantuConfig.cmake.in # # @author Nicolas Richart # # @date creation: Thu Dec 01 2011 # @date last modification: Mon Jan 18 2016 # # @brief CMake file for the library # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== # Compute paths get_filename_component(AKANTU_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) set(AKANTU_USE_FILE "${AKANTU_CMAKE_DIR}/AkantuUse.cmake") include(${AKANTU_USE_FILE}) if(EXISTS "${AKANTU_CMAKE_DIR}/CMakeCache.txt") # In build tree include("${AKANTU_CMAKE_DIR}/AkantuBuildTreeSettings.cmake") include(AkantuSimulationMacros) else() # In install tree set(AKANTU_INCLUDE_DIRS "${AKANTU_CMAKE_DIR}/../../include/akantu") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${AKANTU_CMAKE_DIR}") include(AkantuSimulationMacros) endif() include("${AKANTU_CMAKE_DIR}/AkantuLibraryDepends.cmake") # Dependencies include("${AKANTU_CMAKE_DIR}/AkantuConfigInclude.cmake") set(AKANTU_BUILD_TYPE @CMAKE_BUILD_TYPE@) # find_akantu_dependencies() set(AKANTU_LIBRARY akantu) -if(AKANTU_HAS_CORE_CXX11) - add_definitions(${AKANTU_CORE_CXX11_COMPILE_CXX_FLAGS}) -endif() list(APPEND AKANTU_LIBRARIES ${AKANTU_LIBRARY} ${AKANTU_EXTRA_LIBRARIES}) list(APPEND AKANTU_INCLUDE_DIRS ${AKANTU_EXTRA_INCLUDE_DIR}) # set(AKANTU_VERSION @AKANTU_VERSION@) # @PACKAGE_INIT@ # set_and_check(AKANTU_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") # check_required_components(Akantu) diff --git a/cmake/AkantuMacros.cmake b/cmake/AkantuMacros.cmake index 0262c9f7c..25964e647 100644 --- a/cmake/AkantuMacros.cmake +++ b/cmake/AkantuMacros.cmake @@ -1,367 +1,288 @@ #=============================================================================== # @file AkantuMacros.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Fri Oct 22 2010 # @date last modification: Tue Jan 19 2016 # # @brief Set of macros used by akantu cmake files # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== #=============================================================================== function(set_third_party_shared_libirary_name _var _lib) set(${_var} ${PROJECT_BINARY_DIR}/third-party/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${_lib}${CMAKE_SHARED_LIBRARY_SUFFIX} CACHE FILEPATH "" FORCE) endfunction() # ============================================================================== function(get_target_list_of_associated_files tgt files) get_target_property(_type ${tgt} TYPE) if(_type STREQUAL "SHARED_LIBRARY" OR _type STREQUAL "STATIC_LIBRARY" OR _type STREQUAL "MODULE_LIBRARY" OR _type STREQUAL "EXECUTABLE") get_target_property(_srcs ${tgt} SOURCES) set(_dep_ressources) foreach(_file ${_srcs}) list(APPEND _dep_ressources ${CMAKE_CURRENT_SOURCE_DIR}/${_file}) endforeach() else() get_target_property(_dep_ressources ${tgt} RESSOURCES) endif() set(${files} ${_dep_ressources} PARENT_SCOPE) endfunction() #=============================================================================== # Generate the list of currently loaded materials function(generate_material_list) message(STATUS "Determining the list of recognized materials...") package_get_all_include_directories( AKANTU_LIBRARY_INCLUDE_DIRS ) package_get_all_external_informations( AKANTU_EXTERNAL_INCLUDE_DIR AKANTU_EXTERNAL_LIBRARIES ) set(_include_dirs ${AKANTU_INCLUDE_DIRS} ${AKANTU_EXTERNAL_INCLUDE_DIR}) try_run(_material_list_run _material_list_compile ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/material_lister.cc CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}" COMPILE_DEFINITIONS "-DAKANTU_CMAKE_LIST_MATERIALS" COMPILE_OUTPUT_VARIABLE _compile_results RUN_OUTPUT_VARIABLE _result_material_list) if(_material_list_compile AND "${_material_list_run}" EQUAL 0) message(STATUS "Materials included in Akantu:") string(REPLACE "\n" ";" _material_list "${_result_material_list}") foreach(_mat ${_material_list}) string(REPLACE ":" ";" _mat_key "${_mat}") list(GET _mat_key 0 _key) list(GET _mat_key 1 _class) list(LENGTH _mat_key _l) if("${_l}" GREATER 2) list(REMOVE_AT _mat_key 0 1) set(_opt " -- options: [") foreach(_o ${_mat_key}) set(_opt "${_opt} ${_o}") endforeach() set(_opt "${_opt} ]") else() set(_opt "") endif() message(STATUS " ${_class} -- key: ${_key}${_opt}") endforeach() else() message(STATUS "Could not determine the list of materials.") message("${_compile_results}") endif() endfunction() #=============================================================================== # Declare the options for the types and defines the approriate typedefs function(declare_akantu_types) - - if(CMAKE_VERSION VERSION_LESS 3.1) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag (-std=c++11 HAVE_CPP_11) - unset(_cpp_11_flag) - if(HAVE_CPP_11) - set(_cpp_11_flag "-std=c++11") - else() - check_cxx_compiler_flag (-std=c++0x HAVE_CPP_0X) - if(HAVE_CPP_0X) - set(_cpp_11_flag "-std=c++0x") - endif() - endif() - set(AKANTU_CXX11_FLAGS "${_cpp_11_flag}" CACHE INTERNAL "") - else() - unset(AKANTU_CXX11_FLAGS) - endif() - set(AKANTU_TYPE_FLOAT "double (64bit)" CACHE STRING "Precision force floating point types") mark_as_advanced(AKANTU_TYPE_FLOAT) set_property(CACHE AKANTU_TYPE_FLOAT PROPERTY STRINGS "quadruple (128bit)" "double (64bit)" "float (32bit)" ) set(AKANTU_TYPE_INTEGER "int (32bit)" CACHE STRING "Size of the integer types") mark_as_advanced(AKANTU_TYPE_INTEGER) set_property(CACHE AKANTU_TYPE_INTEGER PROPERTY STRINGS "int (32bit)" "long int (64bit)" ) include(CheckTypeSize) # ---------------------------------------------------------------------------- # Floating point types # ---------------------------------------------------------------------------- if(AKANTU_TYPE_FLOAT STREQUAL "float (32bit)") set(AKANTU_FLOAT_TYPE "float" CACHE INTERNAL "") set(AKANTU_FLOAT_SIZE 4 CACHE INTERNAL "") elseif(AKANTU_TYPE_FLOAT STREQUAL "double (64bit)") set(AKANTU_FLOAT_TYPE "double" CACHE INTERNAL "") set(AKANTU_FLOAT_SIZE 8 CACHE INTERNAL "") elseif(AKANTU_TYPE_FLOAT STREQUAL "quadruple (128bit)") check_type_size("long double" LONG_DOUBLE) if(HAVE_LONG_DOUBLE) set(AKANTU_FLOAT_TYPE "long double" CACHE INTERNAL "") set(AKANTU_FLOAT_SIZE 16 CACHE INTERNAL "") message("This feature is not tested and will most probably not compile") else() message(FATAL_ERROR "The type long double is not defined on your system") endif() else() message(FATAL_ERROR "The float type is not defined") endif() include(CheckIncludeFileCXX) include(CheckCXXSourceCompiles) # ---------------------------------------------------------------------------- # Integer types # ---------------------------------------------------------------------------- check_include_file_cxx(cstdint HAVE_CSTDINT) if(NOT HAVE_CSTDINT) check_include_file_cxx(stdint.h HAVE_STDINT_H) if(HAVE_STDINT_H) list(APPEND _int_include stdint.h) endif() else() list(APPEND _int_include cstdint) endif() check_include_file_cxx(cstddef HAVE_CSTDDEF) if(NOT HAVE_CSTDINT) check_include_file_cxx(stddef.h HAVE_STDDEF_H) if(HAVE_STDINT_H) list(APPEND _int_include stddef.h) endif() else() list(APPEND _int_include cstddef) endif() if(AKANTU_TYPE_INTEGER STREQUAL "int (32bit)") set(AKANTU_INTEGER_SIZE 4 CACHE INTERNAL "") check_type_size("int" INT) if(INT EQUAL 4) set(AKANTU_SIGNED_INTEGER_TYPE "int" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned int" CACHE INTERNAL "") else() check_type_size("int32_t" INT32_T LANGUAGE CXX) if(HAVE_INT32_T) set(AKANTU_SIGNED_INTEGER_TYPE "int32_t" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "uint32_t" CACHE INTERNAL "") list(APPEND _extra_includes ${_int_include}) endif() endif() elseif(AKANTU_TYPE_INTEGER STREQUAL "long int (64bit)") set(AKANTU_INTEGER_SIZE 8 CACHE INTERNAL "") check_type_size("long int" LONG_INT) if(LONG_INT EQUAL 8) set(AKANTU_SIGNED_INTEGER_TYPE "long int" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned long int" CACHE INTERNAL "") else() check_type_size("long long int" LONG_LONG_INT) if(HAVE_LONG_LONG_INT AND LONG_LONG_INT EQUAL 8) set(AKANTU_SIGNED_INTEGER_TYPE "long long int" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned long long int" CACHE INTERNAL "") else() check_type_size("int64_t" INT64_T) if(HAVE_INT64_T) set(AKANTU_SIGNED_INTEGER_TYPE "int64_t" CACHE INTERNAL "") set(AKANTU_UNSIGNED_INTEGER_TYPE "uint64_t" CACHE INTERNAL "") list(APPEND _extra_includes ${_int_include}) endif() endif() endif() else() message(FATAL_ERROR "The integer type is not defined") endif() - # ---------------------------------------------------------------------------- - # unordered map type - # ---------------------------------------------------------------------------- - check_include_file_cxx(unordered_map HAVE_UNORDERED_MAP) - set(AKANTU_UNORDERED_MAP_IS_CXX11 TRUE CACHE INTERNAL "") - if(HAVE_UNORDERED_MAP) - list(APPEND _extra_includes unordered_map) - set(AKANTU_UNORDERED_MAP_TYPE "std::unordered_map" CACHE INTERNAL "") - set(AKANTU_UNORDERED_MAP_NAMESPACE_BEGIN "namespace std {" CACHE INTERNAL "") - set(AKANTU_UNORDERED_MAP_NAMESPACE_END "}" CACHE INTERNAL "") - else() - check_include_file_cxx(tr1/unordered_map HAVE_TR1_UNORDERED_MAP) - if(HAVE_TR1_UNORDERED_MAP) - list(APPEND _extra_includes tr1/unordered_map) - set(AKANTU_UNORDERED_MAP_TYPE "std::tr1::unordered_map" CACHE INTERNAL "") - set(AKANTU_UNORDERED_MAP_NAMESPACE_BEGIN "namespace std { namespace tr1 {" CACHE INTERNAL "") - set(AKANTU_UNORDERED_MAP_NAMESPACE_END "}}" CACHE INTERNAL "") - else() - list(APPEND _extra_includes map) - set(AKANTU_UNORDERED_MAP_TYPE "std::map" CACHE INTERNAL "") - set(AKANTU_UNORDERED_MAP_IS_CXX11 FALSE CACHE INTERNAL "") - endif() - endif() - - # ---------------------------------------------------------------------------- - # hash function - # ---------------------------------------------------------------------------- - unset(AKANTU_HASH_TYPE CACHE) - check_include_file_cxx(functional HAVE_FUNCTIONAL) - set(AKANTU_HASH_IS_CXX11 TRUE CACHE INTERNAL "") - if(HAVE_FUNCTIONAL) - list(APPEND _extra_includes functional) - check_cxx_source_compiles(" -#include -template -std::size_t hash(const T & t) { - typedef typename std::hash hash_type; - return hash_type()(t); -}; - -int main() { return 0; } -" HAVE_HASH) - if(HAVE_HASH) - set(AKANTU_HASH_TYPE "std::hash" CACHE INTERNAL "") - endif() - endif() - - if(NOT AKANTU_HASH_TYPE) - check_include_file_cxx(tr1/functional HAVE_TR1_HASH) - if(HAVE_TR1_HASH) - list(APPEND _extra_includes tr1/functional) - set(AKANTU_HASH_TYPE "std::tr1::hash" CACHE INTERNAL "") - else() - check_include_file_cxx(boost/functional/hash.hpp HAVE_BOOST_HASH) - list(APPEND _extra_includes boost/functional/hash.hpp) - set(AKANTU_HASH_TYPE "boost::hash" CACHE INTERNAL "") - set(AKANTU_HASH_IS_CXX11 FALSE CACHE INTERNAL "") - endif() - endif() - - # ---------------------------------------------------------------------------- # includes # ---------------------------------------------------------------------------- foreach(_inc ${_extra_includes}) set(_incs "#include <${_inc}>\n${_incs}") endforeach() set(AKANTU_TYPES_EXTRA_INCLUDES ${_incs} CACHE INTERNAL "") endfunction() #=============================================================================== if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) return() endif() set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) # first set all result variables to empty/FALSE foreach(arg_name ${_singleArgNames} ${_multiArgNames}) set(${prefix}_${arg_name}) endforeach(arg_name) foreach(option ${_optionNames}) set(${prefix}_${option} FALSE) endforeach(option) set(${prefix}_UNPARSED_ARGUMENTS) set(insideValues FALSE) set(currentArgName) # now iterate over all arguments and fill the result variables foreach(currentArg ${ARGN}) list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) if(insideValues) if("${insideValues}" STREQUAL "SINGLE") set(${prefix}_${currentArgName} ${currentArg}) set(insideValues FALSE) elseif("${insideValues}" STREQUAL "MULTI") list(APPEND ${prefix}_${currentArgName} ${currentArg}) endif() else(insideValues) list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) endif(insideValues) else() if(NOT ${optionIndex} EQUAL -1) set(${prefix}_${currentArg} TRUE) set(insideValues FALSE) elseif(NOT ${singleArgIndex} EQUAL -1) set(currentArgName ${currentArg}) set(${prefix}_${currentArgName}) set(insideValues "SINGLE") elseif(NOT ${multiArgIndex} EQUAL -1) set(currentArgName ${currentArg}) set(${prefix}_${currentArgName}) set(insideValues "MULTI") endif() endif() endforeach(currentArg) # propagate the result variables to the caller: foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) endforeach(arg_name) set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/packages/boost.cmake b/packages/boost.cmake index ac61ea588..7d5470574 100644 --- a/packages/boost.cmake +++ b/packages/boost.cmake @@ -1,68 +1,68 @@ #=============================================================================== # @file boost.cmake # # @author Nicolas Richart # # @date creation: Fri Sep 03 2010 # @date last modification: Wed Jan 20 2016 # # @brief package handling the dependencies to boost # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== set(Boost_NO_BOOST_CMAKE ON CACHE BOOL "" FORCE) package_declare(Boost EXTERNAL NOT_OPTIONAL DESCRIPTION "Package handling boost components" EXTRA_PACKAGE_OPTIONS PREFIX Boost ) mark_as_advanced(Boost_DIR) package_on_enabled_script(Boost "if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER \"4.8\") set(_boost_version \${Boost_MAJOR_VERSION}.\${Boost_MINOR_VERSION}) - if(AKANTU_CORE_CXX11 AND _boost_version VERSION_LESS 1.58 AND _boost_version VERSION_GREATER 1.53) + if(_boost_version VERSION_LESS 1.58 AND _boost_version VERSION_GREATER 1.53) package_set_compile_flags(Boost CXX -DBOOST_SPIRIT_USE_PHOENIX_V3) else() package_unset_compile_flags(Boost CXX) endif() endif() ") package_declare_documentation(Boost "Akantu uses Boost header only for preprocessor and Spirit" "" "Under Ubuntu (14.04 LTS) the installation can be performed using the commands:" "\\begin{command}" " > sudo apt-get install libboost" "\\end{command}" "" ) package_set_package_system_dependency(Boost deb-src libboost-dev) # only build dependency # package_set_package_system_dependency(Boost deb libboost) # package_set_package_system_dependency(Boost rmp boost) diff --git a/packages/mpi.cmake b/packages/mpi.cmake index ec96df20a..145addc2b 100644 --- a/packages/mpi.cmake +++ b/packages/mpi.cmake @@ -1,171 +1,169 @@ #=============================================================================== # @file mpi.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Nov 21 2011 # @date last modification: Wed Jan 20 2016 # # @brief package description for mpi # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== package_declare(MPI EXTERNAL DESCRIPTION "Add MPI support in akantu" EXTRA_PACKAGE_OPTIONS PREFIX MPI_C MPI DEPENDS scotch) package_declare_sources(MPI synchronizer/mpi_type_wrapper.hh synchronizer/static_communicator_mpi.cc synchronizer/static_communicator_mpi_inline_impl.hh synchronizer/static_communicator_mpi.hh ) function(add_extra_mpi_options) unset(MPI_ID CACHE) package_get_include_dir(MPI _include_dir) foreach(_inc_dir ${_include_dir}) if(EXISTS "${_inc_dir}/mpi.h") if(NOT MPI_ID) file(STRINGS "${_inc_dir}/mpi.h" _mpi_version REGEX "#define MPI_(SUB)?VERSION .*") foreach(_ver ${_mpi_version}) string(REGEX MATCH "MPI_(VERSION|SUBVERSION) *([0-9]+)" _tmp "${_ver}") set(_mpi_${CMAKE_MATCH_1} ${CMAKE_MATCH_2}) endforeach() set(MPI_STD_VERSION "${_mpi_VERSION}.${_mpi_SUBVERSION}" CACHE INTERNAL "") endif() if(NOT MPI_ID) # check if openmpi file(STRINGS "${_inc_dir}/mpi.h" _ompi_version REGEX "#define OMPI_.*_VERSION .*") if(_ompi_version) set(MPI_ID "OpenMPI" CACHE INTERNAL "") foreach(_version ${_ompi_version}) string(REGEX MATCH "OMPI_(.*)_VERSION (.*)" _tmp "${_version}") if(_tmp) set(MPI_VERSION_${CMAKE_MATCH_1} ${CMAKE_MATCH_2}) endif() endforeach() set(MPI_ID_VERSION "${MPI_VERSION_MAJOR}.${MPI_VERSION_MINOR}.${MPI_VERSION_RELEASE}" CACHE INTERNAL "") endif() endif() if(NOT MPI_ID) # check if intelmpi file(STRINGS "${_inc_dir}/mpi.h" _impi_version REGEX "#define I_MPI_VERSION .*") if(_impi_version) set(MPI_ID "IntelMPI" CACHE INTERNAL "") string(REGEX MATCH "I_MPI_VERSION \"(.*)\"" _tmp "${_impi_version}") if(_tmp) set(MPI_ID_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "") endif() endif() endif() if(NOT MPI_ID) # check if mvapich2 file(STRINGS "${_inc_dir}/mpi.h" _mvapich2_version REGEX "#define MVAPICH2_VERSION .*") if(_mvapich2_version) set(MPI_ID "MPVAPICH2" CACHE INTERNAL "") string(REGEX MATCH "MVAPICH2_VERSION \"(.*)\"" _tmp "${_mvapich2_version}") if(_tmp) set(MPI_ID_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "") endif() endif() endif() if(NOT MPI_ID) # check if mpich (mpich as to be checked after all the mpi that derives from it) file(STRINGS "${_inc_dir}/mpi.h" _mpich_version REGEX "#define MPICH_VERSION .*") if(_mpich_version) set(MPI_ID "MPICH" CACHE INTERNAL "") string(REGEX MATCH "I_MPI_VERSION \"(.*)\"" _tmp "${_mpich_version}") if(_tmp) set(MPI_ID_VERSION "${CMAKE_MATCH_1}" CACHE INTERNAL "") endif() endif() endif() endif() endforeach() if(MPI_ID STREQUAL "IntelMPI" OR MPI_ID STREQUAL "MPICH" OR MPI_ID STREQUAL "MVAPICH2") set(_flags "-DMPICH_IGNORE_CXX_SEEK") elseif(MPI_ID STREQUAL "OpenMPI") set(_flags "-DOMPI_SKIP_MPICXX") - package_is_activated(core_cxx11 _act) - if(_act) - if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set( _flags "${_flags} -Wno-literal-suffix") - endif() + + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set( _flags "${_flags} -Wno-literal-suffix") endif() endif() include(FindPackageMessage) if(MPI_FOUND) find_package_message(MPI "MPI ID: ${MPI_ID} ${MPI_ID_VERSION} (MPI standard ${MPI_STD_VERSION})" "${MPI_STD_VERSION}") endif() set(MPI_EXTRA_COMPILE_FLAGS "${_flags}" CACHE STRING "Extra flags for MPI" FORCE) mark_as_advanced(MPI_EXTRA_COMPILE_FLAGS) #package_get_source_files(MPI _srcs _pub _priv) #list(APPEND _srcs "common/aka_error.cc") #set_property(SOURCE ${_srcs} PROPERTY COMPILE_FLAGS "${_flags}") package_set_compile_flags(MPI CXX ${_flags}) endfunction() package_on_enabled_script(MPI " add_extra_mpi_options() get_cmake_property(_all_vars VARIABLES) foreach(_var \${_all_vars}) if(_var MATCHES \"^MPI_.*\") mark_as_advanced(\${_var}) endif() endforeach() " ) package_declare_documentation(MPI "This is a meta package providing access to MPI." "" "Under Ubuntu (14.04 LTS) the installation can be performed using the commands:" "\\begin{command}" " > sudo apt-get install libopenmpi-dev" "\\end{command}" "" "Under Mac OS X the installation requires the following steps:" "\\begin{command}" " > sudo port install mpich-devel" "\\end{command}" ) package_set_package_system_dependency(MPI deb mpi-default-bin) package_set_package_system_dependency(MPI deb-src mpi-default-dev) diff --git a/packages/python_interface.cmake b/packages/python_interface.cmake index bb06880b2..bdd6535ca 100644 --- a/packages/python_interface.cmake +++ b/packages/python_interface.cmake @@ -1,62 +1,62 @@ #=============================================================================== # @file python_interface.cmake # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Tue Nov 29 2011 # @date last modification: Fri Jan 22 2016 # # @brief package description for the python interface # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== package_declare(python_interface DESCRIPTION "Akantu's python interface" - DEPENDS PythonLibs core_cxx11) + DEPENDS PythonLibs) package_declare_sources(python_interface python/python_functor.cc python/python_functor.hh python/python_functor_inline_impl.cc model/boundary_condition_python_functor.hh model/boundary_condition_python_functor.cc model/solid_mechanics/materials/material_python/material_python.cc model/solid_mechanics/materials/material_python/material_python.hh ) package_set_package_system_dependency(python_interface deb-src swig3.0) package_declare_documentation(python_interface "This package enables the python interface of Akantu. It relies on swig3.0 to generate the code" "" "Under Ubuntu (14.04 LTS) the installation can be performed using the commands:" "\\begin{command}" " > sudo apt-get install swig3.0" "\\end{command}" "" ) package_declare_documentation_files(python_interface manual-python.tex ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 16681851a..6eb20d0c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,221 +1,221 @@ #=============================================================================== # @file CMakeLists.txt # # @author Guillaume Anciaux # @author Nicolas Richart # # @date creation: Mon Jun 14 2010 # @date last modification: Wed Jan 20 2016 # # @brief CMake file for the library # # @section LICENSE # # Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de # Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des # Solides) # # Akantu is free software: you can redistribute it and/or modify it under the # terms of the GNU Lesser General Public License as published by the Free # Software Foundation, either version 3 of the License, or (at your option) any # later version. # # Akantu 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 Lesser General Public License for more # details. # # You should have received a copy of the GNU Lesser General Public License # along with Akantu. If not, see . # #=============================================================================== #=============================================================================== # Package Management #=============================================================================== package_get_all_source_files( AKANTU_LIBRARY_SRCS AKANTU_LIBRARY_PUBLIC_HDRS AKANTU_LIBRARY_PRIVATE_HDRS ) package_get_all_include_directories( AKANTU_LIBRARY_INCLUDE_DIRS ) package_get_all_external_informations( AKANTU_EXTERNAL_INCLUDE_DIR AKANTU_EXTERNAL_LIBRARIES ) package_get_all_compilation_flags(CXX _cxx_flags) set(AKANTU_EXTRA_CXX_FLAGS "${_cxx_flags}" CACHE STRING "Extra flags defined by loaded packages" FORCE) mark_as_advanced(AKANTU_EXTRA_CXX_FLAGS) #=========================================================================== # header for blas/lapack (any other fortran libraries) #=========================================================================== package_is_activated(BLAS _blas_activated) package_is_activated(LAPACK _lapack_activated) if(_blas_activated OR _lapack_activated) if(CMAKE_Fortran_COMPILER) # ugly hack set(CMAKE_Fortran_COMPILER_LOADED TRUE) endif() include(FortranCInterface) FortranCInterface_HEADER( "${CMAKE_CURRENT_BINARY_DIR}/aka_fortran_mangling.hh" MACRO_NAMESPACE "AKA_FC_") mark_as_advanced(CDEFS) list(APPEND AKANTU_LIBRARY_PUBLIC_HDRS "${CMAKE_CURRENT_BINARY_DIR}/aka_fortran_mangling.hh") endif() #=========================================================================== # configurations #=========================================================================== package_get_all_material_includes(AKANTU_MATERIAL_INCLUDES) package_get_all_material_lists(AKANTU_MATERIAL_LISTS) configure_file(model/solid_mechanics/material_list.hh.in "${CMAKE_CURRENT_BINARY_DIR}/material_list.hh" @ONLY) package_get_element_lists() configure_file(common/aka_element_classes_info.hh.in "${CMAKE_CURRENT_BINARY_DIR}/aka_element_classes_info.hh" @ONLY) configure_file(common/aka_config.hh.in "${CMAKE_CURRENT_BINARY_DIR}/aka_config.hh" @ONLY) list(APPEND AKANTU_LIBRARY_PUBLIC_HDRS "${CMAKE_CURRENT_BINARY_DIR}/aka_config.hh" "${CMAKE_CURRENT_BINARY_DIR}/aka_element_classes_info.hh" "${CMAKE_CURRENT_BINARY_DIR}/material_list.hh") list(APPEND AKANTU_LIBRARY_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}") #=========================================================================== # header precompilation #=========================================================================== set(AKANTU_COMMON_HDR_TO_PRECOMPILE common/aka_vector.hh common/aka_math.hh common/aka_types.hh fem/element_class.hh ) set(AKANTU_PRECOMPILE_HDR_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/common/ ${CMAKE_CURRENT_BINARY_DIR}/fem/ ) set(AKANTU_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${AKANTU_LIBRARY_INCLUDE_DIRS} ${AKANTU_PRECOMPILE_HDR_INCLUDE_DIRS} CACHE INTERNAL "Internal include directories to link with Akantu as a subproject") include_directories(${AKANTU_INCLUDE_DIRS} ${AKANTU_EXTERNAL_INCLUDE_DIR}) if(CMAKE_COMPILER_IS_GNUCXX) include(PCHgcc) foreach(_header ${AKANTU_COMMON_HDR_TO_PRECOMPILE}) add_pch_rule(${_header} AKANTU_LIBRARY_SRCS) endforeach() elseif(CMAKE_COMPILER_IS_GNUCXX) endif() #=============================================================================== # Debug infos #=============================================================================== set(AKANTU_GDB_DIR ${PROJECT_SOURCE_DIR}/cmake) if(UNIX) string(TOUPPER "${CMAKE_BUILD_TYPE}" _u_build_type) if(_u_build_type STREQUAL "DEBUG" OR _u_build_type STREQUAL "RELWITHDEBINFO") configure_file(${PROJECT_SOURCE_DIR}/cmake/libakantu-gdb.py.in "${PROJECT_BINARY_DIR}/libakantu-gdb.py" @ONLY) configure_file(${PROJECT_SOURCE_DIR}/cmake/akantu-debug.cc.in "${PROJECT_BINARY_DIR}/akantu-debug.cc" @ONLY) list(APPEND AKANTU_LIBRARY_SRCS ${PROJECT_BINARY_DIR}/akantu-debug.cc) endif() else() find_program(GDB_EXECUTABLE gdb) if(GDB_EXECUTABLE) execute_process(COMMAND ${GDB_EXECUTABLE} --batch -x "${PROJECT_SOURCE_DIR}/cmake/gdb_python_path" OUTPUT_VARIABLE AKANTU_PYTHON_GDB_DIR ERROR_QUIET RESULT_VARIABLE _res) if(_res EQUAL 0 AND UNIX) set(GDB_USER_CONFIG $ENV{HOME}/.gdb/auto-load) file(MAKE_DIRECTORY ${GDB_USER_CONFIG}) configure_file(${PROJECT_SOURCE_DIR}/cmake/libakantu-gdb.py.in "${GDB_USER_CONFIG}/${CMAKE_SHARED_LIBRARY_PREFIX}akantu${CMAKE_SHARED_LIBRARY_SUFFIX}.${AKANTU_VERSION}-gdb.py" @ONLY) endif() endif() endif() #=============================================================================== # Library generation #=============================================================================== add_library(akantu ${AKANTU_LIBRARY_SRCS}) # the repetition is ugly but works for static libraries target_link_libraries(akantu ${AKANTU_EXTERNAL_LIBRARIES} ${AKANTU_EXTERNAL_LIBRARIES}) set_target_properties(akantu PROPERTIES ${AKANTU_LIBRARY_PROPERTIES} # this contains the version PUBLIC_HEADER "${AKANTU_LIBRARY_PUBLIC_HDRS}" COMPILE_FLAGS "${_cxx_flags}" - LINK_INTERFACE_MULTIPLICITY 2) + CXX_STANDARD 14) if(NOT CMAKE_VERSION VERSION_LESS 3.1) package_get_all_features_public(_public_features) if(_public_features) target_compile_features(akantu PUBLIC ${_public_features}) endif() package_get_all_features_public(_private_features) if(_private_features) target_compile_features(akantu PRIVATE ${_private_features}) endif() endif() package_get_all_extra_dependencies(_extra_target_dependencies) if(_extra_target_dependencies) # This only adding todo: find a solution for when a dependency was add the is removed... add_dependencies(akantu ${_extra_target_dependencies}) endif() list(APPEND AKANTU_EXPORT_LIST akantu) # TODO separate public from private headers install(TARGETS akantu EXPORT ${AKANTU_TARGETS_EXPORT} LIBRARY DESTINATION lib COMPONENT lib ARCHIVE DESTINATION lib COMPONENT lib RUNTIME DESTINATION bin COMPONENT bin PUBLIC_HEADER DESTINATION include/akantu/ COMPONENT dev ) if("${AKANTU_TARGETS_EXPORT}" STREQUAL "AkantuLibraryDepends") install(EXPORT AkantuLibraryDepends DESTINATION lib/akantu COMPONENT dev) endif() #Export for build tree export(TARGETS ${AKANTU_EXPORT_LIST} FILE "${CMAKE_BINARY_DIR}/AkantuLibraryDepends.cmake") export(PACKAGE Akantu) # print out the list of materials generate_material_list() register_target_to_tidy(akantu) diff --git a/src/common/aka_common.hh b/src/common/aka_common.hh index 6451b4654..1e2cf4d15 100644 --- a/src/common/aka_common.hh +++ b/src/common/aka_common.hh @@ -1,450 +1,447 @@ /** * @file aka_common.hh * * @author Nicolas Richart * * @date creation: Mon Jun 14 2010 * @date last modification: Thu Jan 21 2016 * * @brief common type descriptions for akantu * * @section LICENSE * * Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de * Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des * Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * * @section DESCRIPTION * * All common things to be included in the projects files * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_COMMON_HH__ #define __AKANTU_COMMON_HH__ /* -------------------------------------------------------------------------- */ #include #include #include #if __cplusplus < 201402L namespace std { template< bool B, class T = void > using enable_if_t = typename enable_if::type; } #endif /* -------------------------------------------------------------------------- */ #define __BEGIN_AKANTU__ namespace akantu { #define __END_AKANTU__ } /* -------------------------------------------------------------------------- */ #define __BEGIN_AKANTU_DUMPER__ namespace dumper { #define __END_AKANTU_DUMPER__ } /* -------------------------------------------------------------------------- */ #if defined(WIN32) #define __attribute__(x) #endif /* -------------------------------------------------------------------------- */ #include "aka_config.hh" #include "aka_error.hh" #include "aka_safe_enum.hh" /* -------------------------------------------------------------------------- */ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* Common types */ /* -------------------------------------------------------------------------- */ typedef std::string ID; #ifdef AKANTU_NDEBUG static const Real REAL_INIT_VALUE = Real(0.); #else static const Real REAL_INIT_VALUE = std::numeric_limits::quiet_NaN(); #endif /* -------------------------------------------------------------------------- */ /* Memory types */ /* -------------------------------------------------------------------------- */ typedef UInt MemoryID; typedef std::string Surface; typedef std::pair SurfacePair; typedef std::list SurfacePairList; /* -------------------------------------------------------------------------- */ extern const UInt _all_dimensions; /* -------------------------------------------------------------------------- */ /* Mesh/FEM/Model types */ /* -------------------------------------------------------------------------- */ __END_AKANTU__ #include "aka_element_classes_info.hh" __BEGIN_AKANTU__ /// small help to use names for directions enum SpacialDirection { _x = 0, _y = 1, _z = 2 }; /// enum MeshIOType type of mesh reader/writer enum MeshIOType { _miot_auto, ///< Auto guess of the reader to use based on the extension _miot_gmsh, ///< Gmsh files _miot_gmsh_struct, ///< Gsmh reader with reintpretation of elements has /// structures elements _miot_diana, ///< TNO Diana mesh format _miot_abaqus ///< Abaqus mesh format }; /// enum AnalysisMethod type of solving method used to solve the equation of /// motion enum AnalysisMethod { _static = 0, _implicit_dynamic = 1, _explicit_lumped_mass = 2, _explicit_lumped_capacity = 2, _explicit_consistent_mass = 3 }; /// enum DOFSupportType defines which kind of dof that can exists enum DOFSupportType { _dst_nodal, _dst_generic }; /// Type of non linear resolution available in akantu enum NonLinearSolverType { _nls_linear, ///< No non linear convergence loop _nls_newton_raphson, ///< Regular Newton-Raphson _nls_newton_raphson_modified, ///< Newton-Raphson with initial tangent _nls_lumped, ///< Case of lumped mass or equivalent matrix _nls_auto ///< This will take a default value that make sense in case of /// model::getNewSolver }; /// Define the node/dof type enum NodeType : Int { _nt_pure_gost = -3, _nt_master = -2, _nt_normal = -1 }; /// Type of time stepping solver enum TimeStepSolverType { _tsst_static, ///< Static solution _tsst_dynamic, ///< Dynamic solver _tsst_dynamic_lumped, ///< Dynamic solver with lumped mass }; /// Type of integration scheme enum IntegrationSchemeType { _ist_pseudo_time, ///< Pseudo Time _ist_forward_euler, ///< GeneralizedTrapezoidal(0) _ist_trapezoidal_rule_1, ///< GeneralizedTrapezoidal(1/2) _ist_backward_euler, ///< GeneralizedTrapezoidal(1) _ist_central_difference, ///< NewmarkBeta(0, 1/2) _ist_fox_goodwin, ///< NewmarkBeta(1/6, 1/2) _ist_trapezoidal_rule_2, ///< NewmarkBeta(1/2, 1/2) _ist_linear_acceleration, ///< NewmarkBeta(1/3, 1/2) _ist_newmark_beta, ///< generic NewmarkBeta with user defined /// alpha and beta _ist_generalized_trapezoidal ///< generic GeneralizedTrapezoidal with user /// defined alpha }; /// enum SolveConvergenceCriteria different convergence criteria enum SolveConvergenceCriteria { _scc_residual, ///< Use residual to test the convergence _scc_solution, ///< Use solution to test the convergence _scc_residual_mass_wgh ///< Use residual weighted by inv. nodal mass to testb }; /// enum CohesiveMethod type of insertion of cohesive elements enum CohesiveMethod { _intrinsic, _extrinsic }; /// @enum SparseMatrixType type of sparse matrix used enum MatrixType { _unsymmetric, _symmetric }; /* -------------------------------------------------------------------------- */ /* Ghosts handling */ /* -------------------------------------------------------------------------- */ typedef ID SynchronizerID; /// @enum CommunicatorType type of communication method to use enum CommunicatorType { _communicator_mpi, _communicator_dummy }; /// @enum SynchronizationTag type of synchronizations enum SynchronizationTag { //--- Generic tags --- _gst_whatever, _gst_update, _gst_size, //--- SolidMechanicsModel tags --- _gst_smm_mass, ///< synchronization of the SolidMechanicsModel.mass _gst_smm_for_gradu, ///< synchronization of the /// SolidMechanicsModel.displacement _gst_smm_boundary, ///< synchronization of the boundary, forces, velocities /// and displacement _gst_smm_uv, ///< synchronization of the nodal velocities and displacement _gst_smm_res, ///< synchronization of the nodal residual _gst_smm_init_mat, ///< synchronization of the data to initialize materials _gst_smm_stress, ///< synchronization of the stresses to compute the internal /// forces _gst_smmc_facets, ///< synchronization of facet data to setup facet synch _gst_smmc_facets_conn, ///< synchronization of facet global connectivity _gst_smmc_facets_stress, ///< synchronization of facets' stress to setup facet /// synch _gst_smmc_damage, ///< synchronization of damage // --- GlobalIdsUpdater tags --- _gst_giu_global_conn, ///< synchronization of global connectivities // --- CohesiveElementInserter tags --- _gst_ce_groups, ///< synchronization of cohesive element insertion depending /// on facet groups // --- GroupManager tags --- _gst_gm_clusters, ///< synchronization of clusters // --- HeatTransfer tags --- _gst_htm_capacity, ///< synchronization of the nodal heat capacity _gst_htm_temperature, ///< synchronization of the nodal temperature _gst_htm_gradient_temperature, ///< synchronization of the element gradient /// temperature // --- LevelSet tags --- _gst_htm_phi, ///< synchronization of the nodal level set value phi _gst_htm_gradient_phi, ///< synchronization of the element gradient phi //--- Material non local --- _gst_mnl_for_average, ///< synchronization of data to average in non local /// material _gst_mnl_weight, ///< synchronization of data for the weight computations // --- NeighborhoodSynchronization tags --- _gst_nh_criterion, // --- General tags --- _gst_test, ///< Test tag _gst_user_1, ///< tag for user simulations _gst_user_2, ///< tag for user simulations _gst_material_id, ///< synchronization of the material ids _gst_for_dump, ///< everything that needs to be synch before dump // --- Contact & Friction --- _gst_cf_nodal, ///< synchronization of disp, velo, and current position _gst_cf_incr, ///< synchronization of increment // --- Solver tags --- _gst_solver_solution ///< synchronization of the solution obained with the /// PETSc solver }; /// standard output stream operator for SynchronizationTag inline std::ostream & operator<<(std::ostream & stream, SynchronizationTag type); /// @enum GhostType type of ghost enum GhostType { _not_ghost, _ghost, _casper // not used but a real cute ghost }; /* -------------------------------------------------------------------------- */ struct GhostType_def { typedef GhostType type; static const type _begin_ = _not_ghost; static const type _end_ = _casper; }; typedef safe_enum ghost_type_t; extern ghost_type_t ghost_types; /// standard output stream operator for GhostType inline std::ostream & operator<<(std::ostream & stream, GhostType type); /// @enum SynchronizerOperation reduce operation that the synchronizer can /// perform enum SynchronizerOperation { _so_sum, _so_min, _so_max, _so_prod, _so_land, _so_band, _so_lor, _so_bor, _so_lxor, _so_bxor, _so_min_loc, _so_max_loc, _so_null }; /* -------------------------------------------------------------------------- */ /* Global defines */ /* -------------------------------------------------------------------------- */ #define AKANTU_MIN_ALLOCATION 2000 #define AKANTU_INDENT " " #define AKANTU_INCLUDE_INLINE_IMPL /* -------------------------------------------------------------------------- */ template struct is_scalar { enum { value = false }; }; #define AKANTU_SPECIFY_IS_SCALAR(type) \ template <> struct is_scalar { \ enum { value = true }; \ } AKANTU_SPECIFY_IS_SCALAR(Real); AKANTU_SPECIFY_IS_SCALAR(UInt); AKANTU_SPECIFY_IS_SCALAR(Int); AKANTU_SPECIFY_IS_SCALAR(bool); template struct is_same { enum { value = false }; // is_same represents a bool. }; template struct is_same { enum { value = true }; }; /* -------------------------------------------------------------------------- */ #define AKANTU_SET_MACRO(name, variable, type) \ inline void set##name(type variable) { this->variable = variable; } #define AKANTU_GET_MACRO(name, variable, type) \ inline type get##name() const { return variable; } #define AKANTU_GET_MACRO_NOT_CONST(name, variable, type) \ inline type get##name() { return variable; } #define AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, support, con) \ inline con Array & get##name( \ const support & el_type, const GhostType & ghost_type = _not_ghost) \ con { \ return variable(el_type, ghost_type); \ } #define AKANTU_GET_MACRO_BY_ELEMENT_TYPE(name, variable, type) \ AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, ElementType, ) #define AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(name, variable, type) \ AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, ElementType, const) #define AKANTU_GET_MACRO_BY_GEOMETRIE_TYPE(name, variable, type) \ AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, GeometricalType, ) #define AKANTU_GET_MACRO_BY_GEOMETRIE_TYPE_CONST(name, variable, type) \ AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, GeometricalType, const) /* -------------------------------------------------------------------------- */ /// initialize the static part of akantu void initialize(int & argc, char **& argv); /// initialize the static part of akantu and read the global input_file void initialize(const std::string & input_file, int & argc, char **& argv); /* -------------------------------------------------------------------------- */ /// finilize correctly akantu and clean the memory void finalize(); /* -------------------------------------------------------------------------- */ /// Read an new input file void readInputFile(const std::string & input_file); /* -------------------------------------------------------------------------- */ /* * For intel compiler annoying remark */ // #if defined(__INTEL_COMPILER) // /// remark #981: operands are evaluated in unspecified order // #pragma warning(disable : 981) // /// remark #383: value copied to temporary, reference to temporary used // #pragma warning(disable : 383) // #endif // defined(__INTEL_COMPILER) /* -------------------------------------------------------------------------- */ /* string manipulation */ /* -------------------------------------------------------------------------- */ inline std::string to_lower(const std::string & str); /* -------------------------------------------------------------------------- */ inline std::string trim(const std::string & to_trim); /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /// give a string representation of the a human readable size in bit template std::string printMemorySize(UInt size); /* -------------------------------------------------------------------------- */ __END_AKANTU__ #include "aka_fwd.hh" __BEGIN_AKANTU__ /// get access to the internal argument parser cppargparse::ArgumentParser & getStaticArgumentParser(); /// get access to the internal input file parser Parser & getStaticParser(); /// get access to the user part of the internal input file parser const ParserSection & getUserParser(); __END_AKANTU__ #include "aka_common_inline_impl.cc" /* -------------------------------------------------------------------------- */ -#if defined(AKANTU_UNORDERED_MAP_IS_CXX11) - -__BEGIN_AKANTU_UNORDERED_MAP__ #if AKANTU_INTEGER_SIZE == 4 #define AKANTU_HASH_COMBINE_MAGIC_NUMBER 0x9e3779b9 #elif AKANTU_INTEGER_SIZE == 8 #define AKANTU_HASH_COMBINE_MAGIC_NUMBER 0x9e3779b97f4a7c13LL #endif +namespace std { /** * Hashing function for pairs based on hash_combine from boost The magic number * is coming from the golden number @f[\phi = \frac{1 + \sqrt5}{2}@f] * @f[\frac{2^32}{\phi} = 0x9e3779b9@f] * http://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine * http://burtleburtle.net/bob/hash/doobs.html */ template struct hash > { public: hash() : ah(), bh() {} size_t operator()(const std::pair & p) const { size_t seed = ah(p.first); return bh(p.second) + AKANTU_HASH_COMBINE_MAGIC_NUMBER + (seed << 6) + (seed >> 2); } private: const hash ah; const hash bh; }; -__END_AKANTU_UNORDERED_MAP__ +} //std -#endif #endif /* __AKANTU_COMMON_HH__ */ diff --git a/src/common/aka_config.hh.in b/src/common/aka_config.hh.in index e06f19a6f..505ec52cc 100644 --- a/src/common/aka_config.hh.in +++ b/src/common/aka_config.hh.in @@ -1,128 +1,115 @@ /** * @file aka_config.hh.in * * @author Nicolas Richart * * @date creation: Sun Sep 26 2010 * @date last modification: Thu Jan 21 2016 * * @brief Compilation time configuration of Akantu * * @section LICENSE * * Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de * Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des * Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ #ifndef __AKANTU_AKA_CONFIG_HH__ #define __AKANTU_AKA_CONFIG_HH__ #define AKANTU_VERSION_MAJOR @AKANTU_MAJOR_VERSION@ #define AKANTU_VERSION_MINOR @AKANTU_MINOR_VERSION@ #define AKANTU_VERSION_PATCH @AKANTU_PATCH_VERSION@ #define AKANTU_VERSION (AKANTU_VERSION_MAJOR * 100000 \ + AKANTU_VERSION_MINOR * 1000 \ + AKANTU_VERSION_PATCH) @AKANTU_TYPES_EXTRA_INCLUDES@ namespace akantu { typedef @AKANTU_FLOAT_TYPE@ Real; typedef @AKANTU_SIGNED_INTEGER_TYPE@ Int; typedef @AKANTU_UNSIGNED_INTEGER_TYPE@ UInt; - template - struct unordered_map { - typedef typename @AKANTU_UNORDERED_MAP_TYPE@ type; - }; - - template - std::size_t hash(const T & t) { - typedef typename @AKANTU_HASH_TYPE@ hash_type; - return hash_type()(t); - } + // template + // struct unordered_map { + // typedef typename @AKANTU_UNORDERED_MAP_TYPE@ type; + // }; + + // template + // std::size_t hash(const T & t) { + // typedef typename @AKANTU_HASH_TYPE@ hash_type; + // return hash_type()(t); + // } } #define AKANTU_INTEGER_SIZE @AKANTU_INTEGER_SIZE@ #define AKANTU_FLOAT_SIZE @AKANTU_FLOAT_SIZE@ -#cmakedefine AKANTU_UNORDERED_MAP_IS_CXX11 -#define __BEGIN_AKANTU_UNORDERED_MAP__ \ - @AKANTU_UNORDERED_MAP_NAMESPACE_BEGIN@ -#define __END_AKANTU_UNORDERED_MAP__ \ - @AKANTU_UNORDERED_MAP_NAMESPACE_END@ - #cmakedefine AKANTU_HAS_STRDUP #cmakedefine AKANTU_USE_BLAS #cmakedefine AKANTU_USE_LAPACK #cmakedefine AKANTU_PARALLEL #cmakedefine AKANTU_USE_MPI #cmakedefine AKANTU_USE_SCOTCH #cmakedefine AKANTU_USE_PTSCOTCH #cmakedefine AKANTU_SCOTCH_NO_EXTERN #cmakedefine AKANTU_IMPLICIT #cmakedefine AKANTU_USE_MUMPS #cmakedefine AKANTU_USE_PETSC #cmakedefine AKANTU_USE_IOHELPER #cmakedefine AKANTU_USE_QVIEW #cmakedefine AKANTU_USE_BLACKDYNAMITE #cmakedefine AKANTU_USE_NLOPT #cmakedefine AKANTU_USE_CPPARRAY #cmakedefine AKANTU_USE_OBSOLETE_GETTIMEOFDAY #cmakedefine AKANTU_EXTRA_MATERIALS #cmakedefine AKANTU_STUDENTS_EXTRA_PACKAGE #cmakedefine AKANTU_DAMAGE_NON_LOCAL #cmakedefine AKANTU_STRUCTURAL_MECHANICS #cmakedefine AKANTU_HEAT_TRANSFER #cmakedefine AKANTU_PYTHON_INTERFACE #cmakedefine AKANTU_COHESIVE_ELEMENT #cmakedefine AKANTU_PARALLEL_COHESIVE_ELEMENT #cmakedefine AKANTU_IGFEM #cmakedefine AKANTU_USE_CGAL #cmakedefine AKANTU_EMBEDDED -// BOOST Section -#cmakedefine AKANTU_BOOST_CHRONO -#cmakedefine AKANTU_BOOST_SYSTEM - -// Experimental part -#cmakedefine AKANTU_CORE_CXX11 - // Debug tools //#cmakedefine AKANTU_NDEBUG #cmakedefine AKANTU_DEBUG_TOOLS #cmakedefine READLINK_COMMAND @READLINK_COMMAND@ #cmakedefine ADDR2LINE_COMMAND @ADDR2LINE_COMMAND@ #define __aka_inline__ inline #endif /* __AKANTU_AKA_CONFIG_HH__ */ diff --git a/src/common/aka_random_generator.hh b/src/common/aka_random_generator.hh index 5a2c20951..8b756c20f 100644 --- a/src/common/aka_random_generator.hh +++ b/src/common/aka_random_generator.hh @@ -1,382 +1,376 @@ /** * @file aka_random_generator.hh * * @author Nicolas Richart * * @date creation: Thu Feb 21 2013 * @date last modification: Wed Nov 11 2015 * * @brief generic random generator * * @section LICENSE * * Copyright (©) 2014, 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) * * Akantu is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * Akantu 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 Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public License * along with Akantu. If not, see . * */ /* -------------------------------------------------------------------------- */ #include "aka_array.hh" #include "aka_common.hh" -#if defined(AKANTU_USE_CXX11) -#define __CONST_EXPR constexpr -#else -#define __CONST_EXPR -#endif - #ifndef __AKANTU_AKA_RANDOM_GENERATOR_HH__ #define __AKANTU_AKA_RANDOM_GENERATOR_HH__ __BEGIN_AKANTU__ /* -------------------------------------------------------------------------- */ /* List of available distributions */ /* -------------------------------------------------------------------------- */ #define AKANTU_RANDOM_DISTRIBUTION_TYPES \ ((uniform, UniformDistribution))((weibull, WeibullDistribution)) #define AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX(elem) BOOST_PP_CAT(_rdt_, elem) #define AKANTU_RANDOM_DISTRIBUTION_PREFIX(s, data, elem) \ AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX(BOOST_PP_TUPLE_ELEM(2, 0, elem)) enum RandomDistributionType { BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM(AKANTU_RANDOM_DISTRIBUTION_PREFIX, _, AKANTU_RANDOM_DISTRIBUTION_TYPES)), _rdt_not_defined }; /* -------------------------------------------------------------------------- */ /* Distribution */ /* -------------------------------------------------------------------------- */ /// Empty base to be able to store a distribution template class RandomDistributionBase { public: virtual ~RandomDistributionBase() {} virtual void printself(std::ostream & stream, int indent = 0) const = 0; }; /* -------------------------------------------------------------------------- */ /* Uniform distribution */ /* -------------------------------------------------------------------------- */ template class UniformDistribution : public RandomDistributionBase { public: UniformDistribution(T min = T(0.), T max = T(1.)) : min(min), max(max){}; /* ------------------------------------------------------------------------ */ template