diff --git a/CMakeLists.txt b/CMakeLists.txt index f7c53ff..b7671cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,11 +39,19 @@ set(pluginName Util) set(SOURCES domain_util.cpp util_plugin.cpp) -set (CMAKE_CXX_STANDARD 17) +set (CMAKE_CXX_STANDARD 14) + +# Note: +# In C++ 17, std::unary_function has been removed. Unfortunately, UG4's boost is outdated... +# FYI Starting with 1.76.0 Configure boost: +# https://www.boost.org/doc/libs/1_76_0/libs/config/doc/html/boost_config/boost_macro_reference.html +# set (CMAKE_CXX_STANDARD 17) +# add_compile_definitions(BOOST_NO_CXX98_FUNCTION_BASE) + ################################################################################ # The code below doesn't have to be changed (usually) ################################################################################ -cmake_minimum_required(VERSION 2.6) +# cmake_minimum_required(VERSION 2.6) project(UG_PLUGIN_${pluginName}) @@ -74,12 +82,18 @@ if(USE_PYBIND11) add_library(${pluginName} STATIC ${SOURCES}) SET(myPluginSources util_plugin_pybind.cpp) - # SET(myLibraries ug4 SuperLU6) + SET(myLibraries ${pluginName} ${targetLibraryName}) # targetLibraryName is either ug4 or ug4_s # First argument must match module name in PYBIND11_MODULE call python_add_library(pyutil MODULE ${myPluginSources} ${SOURCES} WITH_SOABI) # ug4pybind_add_module(pyutil ${myPluginSources} ${myLibraries}) - target_link_libraries (pyutil PRIVATE ${pluginName} ug4_s) - set_target_properties(pyutil PROPERTIES INSTALL_RPATH "$ORIGIN/..:$ORIGIN/../../../lib") + target_link_libraries (pyutil PRIVATE ${myLibraries}) + if(APPLE) + set_target_properties(pyutil PROPERTIES + INSTALL_RPATH "@loader_path;@loader_path/../lib" + BUILD_WITH_INSTALL_RPATH TRUE) + elseif(LINUX AND NOT APPLE) + set_target_properties(pyutil PROPERTIES INSTALL_RPATH "$ORIGIN:$ORIGIN/../lib") + endif() install(TARGETS pyutil LIBRARY DESTINATION ug4py COMPONENT pymodules) endif(USE_PYBIND11) diff --git a/solver_util.h b/solver_util.h index 0bba410..218d053 100644 --- a/solver_util.h +++ b/solver_util.h @@ -5,6 +5,9 @@ #ifndef UG4_SOLVER_UTIL_H #define UG4_SOLVER_UTIL_H +#ifdef UG_USE_JSON + + #include #include "common/common.h" @@ -311,16 +314,16 @@ namespace Util { //TODO:Tim create sgs } else if(type == "egs"){ - // create egs + //TODO:Lukas } else if(type == "cgs"){ - // create cgs + //TODO:Myrto } else if(type == "ssc"){ //TODO:Duy create ssc } else if(type == "gmg"){ - // create gmg + //TODO: Julian } else if(type == "schur"){ //TODO:Duy create schur @@ -438,4 +441,6 @@ class SolverUtilFunctionProvider{ }; } //namespace util } //namespace ug + +#endif // UG_USE_JSON #endif //UG4_SOLVER_UTIL_H diff --git a/util_plugin.cpp b/util_plugin.cpp index 719726e..00bbe73 100644 --- a/util_plugin.cpp +++ b/util_plugin.cpp @@ -138,7 +138,7 @@ static void DomainAlgebra(TRegistry& reg, string grp) string suffix = GetDomainAlgebraSuffix(); string tag = GetDomainAlgebraTag(); - +#ifdef UG_USE_JSON { typedef SolverUtilFunctionProvider T; @@ -150,6 +150,7 @@ static void DomainAlgebra(TRegistry& reg, string grp) .set_construct_as_smart_pointer(true); reg.add_class_to_group(name, "SolverUtilFunctionProvider", tag); } +#endif /*{ // This is more complicated, as the return type should be included in name. std::string grpname = std::string("CreatePreconditioner"); @@ -163,6 +164,7 @@ static void DomainAlgebra(TRegistry& reg, string grp) // reg.add_function(grpname.append(suffix), // static_cast(*)(const std::string&, int, const std::vector &)> // (&CreateDomain), grpname); +#ifdef UG_USE_JSON { //typedef Domain domain_type; typedef SolverUtil T; @@ -173,6 +175,7 @@ static void DomainAlgebra(TRegistry& reg, string grp) .set_construct_as_smart_pointer(true); reg.add_class_to_group(name, "SolverUtil", tag); } +#endif } @@ -251,23 +254,26 @@ static void Dimension(TRegistry& reg, string grp) * @param reg registry * @param parentGroup group for sorting of functionality */ -template -static void Algebra(Registry& reg, string grp) +template +static void Algebra(TRegistry& reg, string grp) { -// useful defines + // useful defines string suffix = GetAlgebraSuffix(); string tag = GetAlgebraTag(); - typedef typename TAlgebra::vector_type vector_type; - { - // This is more complicated, as the return type should be included in name. - { - std::string grpname = std::string("CreateConvCheck"); - reg.add_function(grpname.append(suffix), - static_cast>(*)(nlohmann::json &)> - (&CreateConvCheck < TAlgebra > ), grpname); - } + typedef typename TAlgebra::vector_type vector_type; - } +#ifdef UG_USE_JSON + { + // This is more complicated, as the return type should be included in name. + { + std::string grpname = std::string("CreateConvCheck"); + reg.add_function(grpname.append(suffix), + static_cast>(*)(nlohmann::json &)> + (&CreateConvCheck < TAlgebra > ), grpname); + } + + } +#endif } @@ -296,7 +302,7 @@ static void Common(Registry& reg, string grp) template -void RegisterBridge_Util(TRegistry& reg, string grp) +void RegisterBridge_Util_(TRegistry* reg, string grp) { grp.append("/Util"); typedef Util::Functionality Functionality; @@ -305,16 +311,16 @@ void RegisterBridge_Util(TRegistry& reg, string grp) #ifndef UG_USE_PYBIND11 //RegisterCommon(*reg,grp); //RegisterDimensionDependent(*reg,grp); - RegisterDomainAlgebraDependent(reg,grp); - RegisterDomainDependent(reg,grp); - RegisterAlgebraDependent(reg,grp); + RegisterDomainAlgebraDependent(*reg,grp); + RegisterDomainDependent(*reg,grp); + RegisterAlgebraDependent(*reg,grp); #else //RegisterCommon(*reg,grp); //RegisterDimensionDependent(*reg,grp); - RegisterDomainDependent(reg,grp); - RegisterAlgebraDependent(*reg,grp); - RegisterDomainAlgebraDependent(*reg,grp); + RegisterDomainDependent(*reg,grp); + RegisterAlgebraDependent(*reg,grp); + RegisterDomainAlgebraDependent(*reg,grp); #endif } @@ -328,7 +334,7 @@ void RegisterBridge_Util(TRegistry& reg, string grp) extern "C" void InitUGPlugin_Util(Registry* reg, string grp) { - RegisterBridge_Util(*reg, grp); + RegisterBridge_Util_(reg, grp); } extern "C" UG_API void @@ -337,10 +343,10 @@ FinalizeUGPlugin_Util() #ifdef UG_USE_PYBIND11 // Expose for pybind11. -namespace UtilBridge{ +namespace Util { void InitUGPlugin(ug::pybind::Registry* reg, string grp) { - RegisterBridge_Util(*reg, grp); + RegisterBridge_Util_(reg, grp); } } #endif diff --git a/util_plugin.h b/util_plugin.h index b29da89..a377d37 100644 --- a/util_plugin.h +++ b/util_plugin.h @@ -13,12 +13,10 @@ extern "C" void FinalizeUGPlugin_Util(); #include "bindings/pybind/ug_pybind.h" namespace ug { -namespace bridge { -namespace UtilBridge{ +namespace Util{ void InitUGPlugin(ug::pybind::Registry* reg, std::string grp); } } -} #endif diff --git a/util_plugin_pybind.cpp b/util_plugin_pybind.cpp index 544feaa..6c13bb4 100644 --- a/util_plugin_pybind.cpp +++ b/util_plugin_pybind.cpp @@ -13,7 +13,7 @@ PYBIND11_MODULE(pyutil, m) ug::pybind::Registry registry(m); std::string name("Utilities"); - ug::bridge::UtilBridge::InitUGPlugin(®istry, name); + ug::Util::InitUGPlugin(®istry, name); } #endif