diff --git a/AMDiS/cmake3/AMDIS.cmake.in b/AMDiS/cmake3/AMDIS.cmake.in index 5f4aa43a8f3a983c10a6d7b9a9a03c72199987af..b98c63c2111eb848cdea932362d79726c83f9ad5 100644 --- a/AMDiS/cmake3/AMDIS.cmake.in +++ b/AMDiS/cmake3/AMDIS.cmake.in @@ -1,4 +1,3 @@ -set(AMDIS_NEED_CXX11 @ENABLE_CXX11@) set(AMDIS_NEED_UMFPACK @ENABLE_UMFPACK@) set(AMDIS_NEED_COMPRESSION @ENABLE_COMPRESSION@) set(AMDIS_NEED_EXTENSIONS @ENABLE_EXTENSIONS@) @@ -18,19 +17,17 @@ add_library(AMDiS ALIAS amdis_base) target_compile_definitions(amdis_base INTERFACE) -if (AMDIS_NEED_CXX11) - target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE) - if (NOT SUPPORTS_CXX14) - target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE) - endif () - - if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14) - message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!") - endif () - target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1) -else () - target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=0) -endif (AMDIS_NEED_CXX11) + +target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE) +if (NOT SUPPORTS_CXX14) + target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE) +endif () + +if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14) + message(FATAL_ERROR "AMDiS was compiled with c++11 support, but the current compiler does not support this feature!") +endif () +target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1) + # try to detect the AMDiS include directory diff --git a/AMDiS/cmake3/CMakeLists.txt b/AMDiS/cmake3/CMakeLists.txt index fb308342960b552f210091772440656a8429d487..11d5a09ec054cf44b7a41421be783ca0833fdd1c 100644 --- a/AMDiS/cmake3/CMakeLists.txt +++ b/AMDiS/cmake3/CMakeLists.txt @@ -23,12 +23,19 @@ add_library(AMDiS::base ALIAS amdis_base) target_include_directories(amdis_base INTERFACE ${SOURCE_DIR}) target_compile_definitions(amdis_base INTERFACE) -target_enable_cxx11(ENABLE_CXX11 amdis_base INTERFACE) -if (ENABLE_CXX11) - target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1) + +target_enable_cxx14(SUPPORTS_CXX14 amdis_base INTERFACE) +if (SUPPORTS_CXX14) + target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX14=1) else () - target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=0) -endif (ENABLE_CXX11) + target_enable_cxx11(SUPPORTS_CXX11 amdis_base INTERFACE) +endif () + +if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14) + message(FATAL_ERROR "AMDiS needs c++11 support, but the current compiler does not support this feature!") +endif () +target_compile_definitions(amdis_base INTERFACE AMDIS_HAS_CXX11=1) + target_enable_mtl4(amdis_base INTERFACE) target_enable_boost(amdis_base INTERFACE) diff --git a/AMDiS/cmake3/muparser.cmake b/AMDiS/cmake3/muparser.cmake index 016a16daa29203f7d13c8c04b4f736273dc8fca8..82910f8ce8c4d7d7049b88f4f3ea5acc0efb0773 100644 --- a/AMDiS/cmake3/muparser.cmake +++ b/AMDiS/cmake3/muparser.cmake @@ -17,10 +17,8 @@ add_library(muparser STATIC target_include_directories(muparser PUBLIC ${MUPARSER_INCLUDE_DIR}) set_property(TARGET muparser PROPERTY POSITION_INDEPENDENT_CODE ON) -if (ENABLE_CXX11) - target_enable_cxx11(MUPARSER_ENABLE_CXX11 muparser PRIVATE) - target_compile_definitions(muparser PRIVATE AMDIS_HAS_CXX11=1) -endif (ENABLE_CXX11) +target_enable_cxx11(MUPARSER_ENABLE_CXX11 muparser PRIVATE) +target_compile_definitions(muparser PRIVATE AMDIS_HAS_CXX11=1) # specify how to install this target: # ----------------------------------- diff --git a/AMDiS/cmake3/target_enable_boost.cmake b/AMDiS/cmake3/target_enable_boost.cmake index cdf5f05bb817750dd4d69c80e604c0958da804ea..5c41b01100c6d2f374298dcf47bc53ac51a0e2a3 100644 --- a/AMDiS/cmake3/target_enable_boost.cmake +++ b/AMDiS/cmake3/target_enable_boost.cmake @@ -13,7 +13,7 @@ macro(target_enable_boost _TARGET_ _SCOPE_) endif (BOOST_LIBRARYDIR) set(BOOST_VERSION "1.48") - set(BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time) + set(BOOST_LIBS_REQUIRED system iostreams filesystem program_options date_time thread) if (WIN32) list(APPEND BOOST_LIBS_REQUIRED zlib) if (ENABLE_COMPRESSION OR AMDIS_NEED_COMPRESSION) diff --git a/AMDiS/cmake3/target_enable_mtl4.cmake b/AMDiS/cmake3/target_enable_mtl4.cmake index b718b73b8f95f0684a2e057ccfaae973d12ae6f7..90d5e2c036d04555520fbc2335be3890080410fb 100644 --- a/AMDiS/cmake3/target_enable_mtl4.cmake +++ b/AMDiS/cmake3/target_enable_mtl4.cmake @@ -1,32 +1,29 @@ macro(target_enable_mtl4 _TARGET_ _SCOPE_) - if (${ARGC} GREATER 2) - set(LINK_EXECUTABLE ON) - else () - set(LINK_EXECUTABLE OFF) - endif () + if (${ARGC} GREATER 2) + set(LINK_EXECUTABLE ON) + else () + set(LINK_EXECUTABLE OFF) + endif () - if (LINK_EXECUTABLE) - target_include_directories(${_TARGET_} ${_SCOPE_} ${AMDIS_INCLUDE_DIR}/mtl4) - else () - target_include_directories(${_TARGET_} ${_SCOPE_} ${BASE_DIR}/lib/mtl4) - endif (LINK_EXECUTABLE) - target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_ASSERT_FOR_THROW=1) + if (LINK_EXECUTABLE) + target_include_directories(${_TARGET_} ${_SCOPE_} ${AMDIS_INCLUDE_DIR}/mtl4) + else () + target_include_directories(${_TARGET_} ${_SCOPE_} ${BASE_DIR}/lib/mtl4) + endif (LINK_EXECUTABLE) + target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_ASSERT_FOR_THROW=1) - if (ENABLE_CXX11) - set (CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL") - foreach (feature ${CXX_ELEVEN_FEATURE_LIST}) - target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_WITH_${feature}) - endforeach () - endif (ENABLE_CXX11) - - if (ENABLE_OPENMP) - find_package(OpenMP REQUIRED) - if (OPENMP_FOUND) - target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_WITH_OPENMP) - target_compile_options(${_TARGET_} ${_SCOPE_} ${OpenMP_CXX_FLAGS}) - else () - message(FATAL_ERROR "OpenMP not found") - endif (OPENMP_FOUND) - endif (ENABLE_OPENMP) + set (CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL") + foreach (feature ${CXX_ELEVEN_FEATURE_LIST}) + target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_WITH_${feature}) + endforeach () + if (ENABLE_OPENMP) + find_package(OpenMP REQUIRED) + if (OPENMP_FOUND) + target_compile_definitions(${_TARGET_} ${_SCOPE_} MTL_WITH_OPENMP) + target_compile_options(${_TARGET_} ${_SCOPE_} ${OpenMP_CXX_FLAGS}) + else () + message(FATAL_ERROR "OpenMP not found") + endif (OPENMP_FOUND) + endif (ENABLE_OPENMP) endmacro(target_enable_mtl4) diff --git a/AMDiS/src/DOFVector.hh b/AMDiS/src/DOFVector.hh index 4c229e78bc3fed3acf22cf7bb23774cc3f0c734e..b05af7cd9098074b3327e96387b628deac37bd08 100644 --- a/AMDiS/src/DOFVector.hh +++ b/AMDiS/src/DOFVector.hh @@ -124,8 +124,10 @@ namespace AMDiS { { this->name = n; this->feSpace = f; + if (this->feSpace && this->feSpace->getAdmin()) (this->feSpace->getAdmin())->addDOFIndexed(this); + this->boundaryManager = new BoundaryManager(f); #ifdef HAVE_PARALLEL_DOMAIN_AMDIS if (addToSynch && Parallel::MeshDistributor::globalMeshDistributor != NULL) @@ -140,6 +142,8 @@ namespace AMDiS { if ( Parallel::MeshDistributor::globalMeshDistributor != NULL) Parallel::MeshDistributor::globalMeshDistributor->removeInterchangeVector(this); #endif + + #pragma omp critical if (this->feSpace && this->feSpace->getAdmin()) (this->feSpace->getAdmin())->removeDOFIndexed(this); diff --git a/AMDiS/src/ElInfo1d.cc b/AMDiS/src/ElInfo1d.cc index e4836a0520c40c825737957ef49cd1f978eb4df4..71a21d1f98114cfd014eb5515d982e70f1f370f2 100644 --- a/AMDiS/src/ElInfo1d.cc +++ b/AMDiS/src/ElInfo1d.cc @@ -161,8 +161,6 @@ namespace AMDiS { double length = (coord[1][0] - a); int dim = mesh->getDim(); - static DimVec vec(dim, NO_INIT); - TEST_EXIT_DBG(lambda)("lambda must not be NULL\n"); TEST_EXIT_DBG(dim == 1)("dim!=1\n"); TEST_EXIT_DBG(dimOfWorld == dim)("not yet for DIM != DIM_OF_WORLD\n"); diff --git a/AMDiS/src/ElInfo2d.cc b/AMDiS/src/ElInfo2d.cc index 7d7e2119205023152506d350940a623b42dbef97..3bc7d64db20b327dcda9339faaa13ad825deaa37 100644 --- a/AMDiS/src/ElInfo2d.cc +++ b/AMDiS/src/ElInfo2d.cc @@ -679,7 +679,6 @@ namespace AMDiS { DimVec > edge(mesh->getDim(), NO_INIT); WorldVector x; - static DimVec vec(mesh->getDim(), NO_INIT); int dim = mesh->getDim(); @@ -875,4 +874,4 @@ namespace AMDiS { { return getSubElemCoordsMat(degree); } -} \ No newline at end of file +} diff --git a/AMDiS/src/ElInfo3d.cc b/AMDiS/src/ElInfo3d.cc index 87fd26af81825bb39a8b7f223b503bac608e9846..f029d67a6edb63d43c25b17d6d78b4d9c7a85545 100644 --- a/AMDiS/src/ElInfo3d.cc +++ b/AMDiS/src/ElInfo3d.cc @@ -336,8 +336,6 @@ namespace AMDiS { WorldVector x; double x0, det, det0, det1, det2; - static DimVec vec(mesh->getDim(), NO_INIT); - TEST_EXIT_DBG(lambda)("lambda must not be NULL\n"); int dim = mesh->getDim(); diff --git a/AMDiS/src/Global.cc b/AMDiS/src/Global.cc index 42fc8e60c8e485f2fe6ed453c6be8d21cbed23d6..8af28c5187a7fd859c5696d603aa6807bcedefa7 100644 --- a/AMDiS/src/Global.cc +++ b/AMDiS/src/Global.cc @@ -317,7 +317,6 @@ namespace AMDiS { int d = -1; // get dimension - TEST_EXIT(Parameters::initialized())("Parameters not initialized!\n"); Parameters::get("dimension of world",d,0); TEST_EXIT(d > 0)("Cannot initialize dimension!\n"); TEST_EXIT((d == 1) || (d == 2) || (d == 3))("Invalid world dimension %d!\n",d); diff --git a/AMDiS/src/Initfile.cc b/AMDiS/src/Initfile.cc index bd7976ba17066869320aeca8250bcdda71fa804d..222f7f6047261270b5cc3da6b546bb466ecc431a 100644 --- a/AMDiS/src/Initfile.cc +++ b/AMDiS/src/Initfile.cc @@ -67,17 +67,13 @@ namespace AMDiS { } } - Initfile* Initfile::singlett = NULL; - std::set Initfile::fn_include_list; - - /// initialize singleton object an global parameters + /// initialize singleton object and global parameters void Initfile::init(std::string in) { - initIntern(); - fn_include_list.clear(); - singlett->read(in); - singlett->getInternalParameters(); + getIncludeList().clear(); + singlett().read(in); + singlett().getInternalParameters(); } @@ -85,13 +81,13 @@ namespace AMDiS { void Initfile::read(std::string fn, bool force) { // read file if its not parsed already - if (fn_include_list.find(fn) == fn_include_list.end() || force) { + if (getIncludeList().find(fn) == getIncludeList().end() || force) { std::ifstream inputFile; inputFile.open(fn.c_str(), std::ios::in); if (!inputFile.is_open()) throw runtime_error("init-file '" + fn + "' cannot be opened for reading"); - fn_include_list.insert(fn); + getIncludeList().insert(fn); read(inputFile); } } @@ -233,8 +229,6 @@ namespace AMDiS { void Initfile::readArgv(std::string parameters, int debugInfo) { - initIntern(); - char seperator = ';'; typedef boost::escaped_list_separator TokenizerFunc; typedef boost::tokenizer Tokenizer; @@ -286,8 +280,7 @@ namespace AMDiS { /// print all parameters to std::cout void Initfile::printParameters() { - initIntern(); - for (Initfile::iterator it = singlett->begin(); it != singlett->end(); it++) + for (Initfile::iterator it = singlett().begin(); it != singlett().end(); it++) std::cout << (*it).first << " => " << (*it).second << std::endl; } diff --git a/AMDiS/src/Initfile.h b/AMDiS/src/Initfile.h index add610cf4912231d9597388678a3fa3b5629af84..4f2331b0502232c11cbf504cea8fdba7702febb1 100644 --- a/AMDiS/src/Initfile.h +++ b/AMDiS/src/Initfile.h @@ -37,6 +37,7 @@ #include #include +#include // requires c++14 #include @@ -422,18 +423,19 @@ namespace AMDiS { template static void get(const std::string tag, T& value, int debugInfo = -1) { - initIntern(); +// boost::shared_lock lock(singlett().mutex_); + if (debugInfo == -1) - debugInfo = singlett->getMsgInfo(); + debugInfo = singlett().getMsgInfo(); else { int swap(debugInfo); - debugInfo = singlett->getMsgInfo(); - singlett->msgInfo=swap; + debugInfo = singlett().getMsgInfo(); + singlett().msgInfo=swap; } std::string valStr; try { - int error_code = singlett->checkedGet(tag, valStr); + int error_code = singlett().checkedGet(tag, valStr); if (error_code == 0) { valStr = trim(valStr); detail::convert(valStr, value); @@ -454,7 +456,7 @@ namespace AMDiS { std::cout << "Parameter '" << tag << "'" << " initialized with: " << value << std::endl; } - singlett->msgInfo = debugInfo; + singlett().msgInfo = debugInfo; } @@ -471,8 +473,7 @@ namespace AMDiS { std::map &pm, int debugInfo = -1) { - initIntern(); - for (Initfile::iterator it = singlett->begin(); it != singlett->end(); it++){ + for (Initfile::iterator it = singlett().begin(); it != singlett().end(); it++){ std::string longTag= (*it).first ; std::string value=(*it).second; if(longTag.length()>tag.length() && @@ -497,10 +498,12 @@ namespace AMDiS { /// return InitEntry object for tag tag static InitEntry get(const std::string tag) { +// boost::shared_lock lock(singlett().mutex_); + InitEntry result; std::string valStr; - int error_code = singlett->checkedGet(tag, valStr); + int error_code = singlett().checkedGet(tag, valStr); if (error_code == 0) { valStr = trim(valStr); result = InitEntry(valStr); @@ -524,15 +527,16 @@ else if(error_code == TAG_NOT_FOUND_BREAK) template static void set(const std::string tag, T& value, int debugInfo= -1) { - initIntern(); +// boost::unique_lock lock(singlett().mutex_); + if (debugInfo == -1) - debugInfo = singlett->getMsgInfo(); + debugInfo = singlett().getMsgInfo(); std::string swap = ""; detail::convert(value, swap); - (*singlett)[trim(tag)] = swap; + singlett()[trim(tag)] = swap; // update msg parameters msgInfo, msgWait, paramInfo - singlett->getInternalParameters(); + singlett().getInternalParameters(); if (debugInfo == 2) std::cout << "Parameter '" << tag << "'" << " set to: " << value << std::endl; @@ -554,28 +558,14 @@ else if(error_code == TAG_NOT_FOUND_BREAK) /// Returns specified info level static int getMsgInfo() { - return (singlett != NULL) ? singlett->msgInfo : 0; + return singlett().msgInfo; } /// Returns specified wait value static int getMsgWait() { - return (singlett != NULL) ? singlett->msgWait : 0; - } - - - /// Checks whether parameters are initialized. if not, call init() - static bool initialized() - { - return (singlett != NULL); - } - - - /// return pointer to singleton - static Initfile *getSingleton() - { - return singlett; + return singlett().msgWait; } @@ -586,21 +576,24 @@ else if(error_code == TAG_NOT_FOUND_BREAK) /// clear data in singleton static void clearData() { - initIntern(); - singlett->clear(); + singlett().clear(); } - + /// save singlett-data to file with filename fn static void save(std::string fn) { - initIntern(); - singlett->write(fn); + singlett().write(fn); } + - static std::set< std::string > getIncludeList(){ - return fn_include_list; + // list of included filenames + static std::set< std::string >& getIncludeList() + { + static std::set< std::string > include_list; + return include_list; } + protected: Initfile() : msgInfo(0), @@ -609,22 +602,14 @@ protected: breakOnMissingTag(0) {} - - static void initIntern() + /// return reference to singleton + static Initfile& singlett() { - if (singlett == NULL) - singlett = new Initfile; + static Initfile singlett_{}; + return singlett_; } - /// list of processed files - static std::set< std::string > fn_include_list; - - - /// pointer to the singleton that contains the data - static Initfile* singlett; - - /// return the value of the given tag or throws an exception if the tag /// does not exist int checkedGet(const std::string& tag, std::string &valStr) const @@ -671,6 +656,8 @@ protected: void getInternalParameters(); int msgInfo, msgWait, paramInfo, breakOnMissingTag; + +// mutable boost::shared_mutex mutex_; }; typedef Initfile Parameters; diff --git a/configure.sh b/configure.sh index b3e18f4400e3022fbd7cd06920b73fd97c5e59c2..cd193f64aa7d447807b142d845c0011307375a9d 100755 --- a/configure.sh +++ b/configure.sh @@ -15,7 +15,7 @@ ENABLE_COMPRESSION="OFF" ENABLE_PARALLEL="OFF" BOOST_PREFIX="${BOOST_ROOT}" DOWNLOAD_BOOST="0" -BOOST_VERSION="1.62.0" +BOOST_VERSION="1.64.0" PETSC_PREFIX="${PETSC_DIR}" DOWNLOAD_PETSC="0" PETSC_VERSION="3.5.4" @@ -196,11 +196,11 @@ if [ "${DOWNLOAD_BOOST}" -eq "1" ]; then BOOST_PREFIX=${SRC_DIR}/packages/boost/${BOOST_VERSION} cd /tmp/src/boost - ./bootstrap.sh --prefix=${BOOST_PREFIX} --with-libraries=system,iostreams,filesystem,program_options,date_time,test + ./bootstrap.sh --prefix=${BOOST_PREFIX} --with-libraries=system,iostreams,filesystem,program_options,date_time,test,thread if [ "${ENABLE_COMPRESSION}" = "ON" ]; then - ./b2 -s cxxflags="-std=c++11" --build-type=minimal variant=release install + ./b2 -s cxxflags="-std=c++14" --build-type=minimal variant=release install else - ./b2 -s NO_BZIP2=1 -s NO_ZLIB=1 cxxflags="-std=c++11" --build-type=minimal variant=release install + ./b2 -s NO_BZIP2=1 -s NO_ZLIB=1 cxxflags="-std=c++14" --build-type=minimal variant=release install fi rm -rf /tmp/src/boost fi