diff --git a/CMakeLists.txt b/CMakeLists.txt index 551be4a6c8baa0946cc28a6d7ce9685dd04d7256..93d9cb1f68eb373fe455d9b37bfaa658e4bd9b9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ execute_process(COMMAND ${CMAKE_SOURCE_DIR}/getRevision.sh include(DunePybindxiInstallPythonPackage) # this symlinks all files in python/ to the binary dir and install into the virtualenv from there thereby making the # compiled extensions directly usable from the venv +make_dependent_modules_sys_included() dune_pybindxi_install_python_package(PATH python) include_dependent_binary_python_dirs() # do not change order here diff --git a/dune/xt/common/cblas.cc b/dune/xt/common/cblas.cc index 63545f4b544c2edb50e8c3174360da4c9e9c3725..c9c8167fa7058bcaf35ca8f459ca2b9980d20659 100644 --- a/dune/xt/common/cblas.cc +++ b/dune/xt/common/cblas.cc @@ -13,7 +13,7 @@ #include <cmath> -// Due to probles with old cblas versions, we only use the MKL cblas for the moment. See also +// Due to problems with old cblas versions, we only use the MKL cblas for the moment. See also // https://github.com/dune-community/dune-xt/pull/198. #if HAVE_MKL # include <mkl.h> diff --git a/dune/xt/common/type_traits.hh b/dune/xt/common/type_traits.hh index 9142766517165bb8e5bd2237fec5ef6a2492fcde..8839a1c17cf8f2de30b52db78078dd170b472cf2 100644 --- a/dune/xt/common/type_traits.hh +++ b/dune/xt/common/type_traits.hh @@ -25,6 +25,7 @@ #include <dune/common/typetraits.hh> #include <dune/common/unused.hh> +#include <dune/xt/common/exceptions.hh> /** use this to define Typename specializations in the GLOBAL namespace ONLY **/ #define DUNE_XT_COMMON_TYPENAME(NAME) \ diff --git a/dune/xt/la/container/vector-interface.hh b/dune/xt/la/container/vector-interface.hh index 7724103f69ef0f750bf039b8705ad6e0ef6d3942..20862bbd5e33ffd9b6a9b579fb71630e777227f6 100644 --- a/dune/xt/la/container/vector-interface.hh +++ b/dune/xt/la/container/vector-interface.hh @@ -229,7 +229,7 @@ public: */ virtual std::pair<size_t, RealType> amax() const { - using std::abs; + using XT::Common::abs; auto result = std::make_pair(size_t(0), RealType(0)); for (size_t ii = 0; ii < size(); ++ii) { const auto value = abs(get_unchecked_ref(ii)); @@ -297,7 +297,7 @@ public: */ virtual RealType l1_norm() const { - using std::abs; + using XT::Common::abs; RealType result = 0; for (size_t ii = 0; ii < size(); ++ii) result += abs(get_unchecked_ref(ii)); @@ -317,8 +317,8 @@ public: */ virtual RealType l2_norm() const { - using std::abs; using std::sqrt; + using XT::Common::abs; return sqrt(abs(dot(this->as_imp()))); // std::abs is only needed for the right return type: // v.dot(v) should always be a ScalarType with zero imaginary part } diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 5311985771f392b33dcd1eae1ee2bdde53bc4967..9b3209225507644b91ba2d117beb56b8fde9c7ff 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,6 +11,10 @@ # Tobias Leibner (2018, 2020) # ~~~ +# Currently, the python libraries do not have access to the config.h variables, see +# https://github.com/dune-community/dune-xt-common/issues/120 +# The following silences all the resulting -Wundef warnings in this directory +add_compile_options(-Wno-undef) add_subdirectory(dune) add_subdirectory(scripts) add_subdirectory(wrapper) diff --git a/python/dune/xt/functions/checkerboard.hh b/python/dune/xt/functions/checkerboard.hh index d8df4ac16f86a300b4432fd2529a4ec72a468171..1b1df6c9f932193dea66143f970537fc209f6f8f 100644 --- a/python/dune/xt/functions/checkerboard.hh +++ b/python/dune/xt/functions/checkerboard.hh @@ -41,7 +41,8 @@ static const constexpr size_t d = G::dimension; template <class G, size_t d, size_t r, size_t rC> typename std::enable_if< Grid::is_grid<G>::value, - pybind11::class_<CheckerboardFunction<typename G::template Codim<0>::Entity, r, rC, double>>>::type + pybind11::class_<CheckerboardFunction<typename G::template Codim<0>::Entity, r, rC, double>, + GridFunctionInterface<typename G::template Codim<0>::Entity, r, rC, double>>>::type bind_CheckerboardFunction(pybind11::module& m, const std::string& grid_id) { namespace py = pybind11; diff --git a/python/dune/xt/functions/constant.hh b/python/dune/xt/functions/constant.hh index d76a41a8d8ccb4c2c0a879e3d8de397f30681206..439f64ea3b62ff3e35a262c0dad6f5280ef4d464 100644 --- a/python/dune/xt/functions/constant.hh +++ b/python/dune/xt/functions/constant.hh @@ -38,7 +38,8 @@ static const constexpr size_t d = G::dimension; * but this triggers a bug in gcc-4.9, see e.g.: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59937 */ template <size_t d, size_t r, size_t rC> -typename pybind11::class_<ConstantFunction<d, r, rC, double>> bind_ConstantFunction(pybind11::module& m) +typename pybind11::class_<ConstantFunction<d, r, rC, double>, FunctionInterface<d, r, rC, double>> +bind_ConstantFunction(pybind11::module& m) { namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/functions/expression.hh b/python/dune/xt/functions/expression.hh index 922a73e145475a4101598d82d18fa0a7aa689a54..9fb741bf714cc839dcc19cd0d02f1d5df9e182a2 100644 --- a/python/dune/xt/functions/expression.hh +++ b/python/dune/xt/functions/expression.hh @@ -79,8 +79,8 @@ static const constexpr size_t d = G::dimension; * everywhere: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59937 */ template <size_t d, size_t r> -pybind11::class_<ExpressionFunction<d, r, 3, double>> bind_ExpressionFunction(pybind11::module& m, - std::integral_constant<int, 3>) +pybind11::class_<ExpressionFunction<d, r, 3, double>, FunctionInterface<d, r, 3, double>> +bind_ExpressionFunction(pybind11::module& m, std::integral_constant<int, 3>) { namespace py = pybind11; using namespace pybind11::literals; @@ -141,8 +141,8 @@ pybind11::class_<ExpressionFunction<d, r, 3, double>> bind_ExpressionFunction(py } // ... bind_ExpressionFunction(...) template <size_t d, size_t r> -pybind11::class_<ExpressionFunction<d, r, 2, double>> bind_ExpressionFunction(pybind11::module& m, - std::integral_constant<int, 2>) +pybind11::class_<ExpressionFunction<d, r, 2, double>, FunctionInterface<d, r, 2, double>> +bind_ExpressionFunction(pybind11::module& m, std::integral_constant<int, 2>) { namespace py = pybind11; using namespace pybind11::literals; @@ -204,8 +204,8 @@ pybind11::class_<ExpressionFunction<d, r, 2, double>> bind_ExpressionFunction(py } // ... bind_ExpressionFunction(...) template <size_t d, size_t r> -pybind11::class_<ExpressionFunction<d, r, 1, double>> bind_ExpressionFunction(pybind11::module& m, - std::integral_constant<int, 1>) +pybind11::class_<ExpressionFunction<d, r, 1, double>, FunctionInterface<d, r, 1, double>> +bind_ExpressionFunction(pybind11::module& m, std::integral_constant<int, 1>) { namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/functions/function-interface.hh b/python/dune/xt/functions/function-interface.hh index a12e8fd8508109e2afd018a7d17a09cecf142c9f..ddfcac249cb032161ffe246d4ef761a7ff8d8754 100644 --- a/python/dune/xt/functions/function-interface.hh +++ b/python/dune/xt/functions/function-interface.hh @@ -113,10 +113,15 @@ struct get_combined<L, R, CombinationType::product> } // namespace internal -template <size_t d, CombinationType comb, size_t lr, size_t lrC, size_t rr, size_t rrC> -pybind11::class_<typename internal::get_combined<FunctionInterface<d, lr, lrC, double>, - FunctionInterface<d, rr, rrC, double>, - comb>::type> +template <size_t d, + CombinationType comb, + size_t lr, + size_t lrC, + size_t rr, + size_t rrC, + class C = typename internal:: + get_combined<FunctionInterface<d, lr, lrC, double>, FunctionInterface<d, rr, rrC, double>, comb>::type> +pybind11::class_<C, FunctionInterface<d, C::range_dim, C::range_dim_cols, double>> bind_combined_Function(pybind11::module& m) { namespace py = pybind11; @@ -124,7 +129,6 @@ bind_combined_Function(pybind11::module& m) typedef double R; typedef FunctionInterface<d, lr, lrC, R> Left; typedef FunctionInterface<d, rr, rrC, R> Right; - typedef typename internal::get_combined<Left, Right, comb>::type C; static const size_t r = C::range_dim; static const size_t rC = C::range_dim_cols; const std::string id = internal::get_combined<Left, Right, comb>::id(); diff --git a/python/dune/xt/functions/indicator.hh b/python/dune/xt/functions/indicator.hh index 7f59a3239df6430ebe55198ba8c7ff2ae35e06e3..3d6e155d99b3c2313c62da72452a688dc6b41d19 100644 --- a/python/dune/xt/functions/indicator.hh +++ b/python/dune/xt/functions/indicator.hh @@ -32,7 +32,8 @@ namespace Functions { template <class G, size_t d, size_t r, size_t rC> typename std::enable_if< Grid::is_grid<G>::value, - pybind11::class_<IndicatorGridFunction<typename G::template Codim<0>::Entity, r, rC, double>>>::type + pybind11::class_<IndicatorGridFunction<typename G::template Codim<0>::Entity, r, rC, double>, + GridFunctionInterface<typename G::template Codim<0>::Entity, r, rC, double>>>::type bind_IndicatorGridFunction(pybind11::module& m, const std::string& grid_id) { namespace py = pybind11; @@ -76,7 +77,8 @@ bind_IndicatorGridFunction(pybind11::module& m, const std::string& grid_id) template <size_t d, size_t r, size_t rC> -typename pybind11::class_<IndicatorFunction<d, r, rC, double>> bind_IndicatorFunction(pybind11::module& m) +typename pybind11::class_<IndicatorFunction<d, r, rC, double>, FunctionInterface<d, r, rC, double>> +bind_IndicatorFunction(pybind11::module& m) { namespace py = pybind11; using namespace pybind11::literals; diff --git a/python/dune/xt/functions/spe10.hh b/python/dune/xt/functions/spe10.hh index 9b073659da771ca202437ddfda14b41f7860fc67..447d1af7250fbf080f4b86bcf646e4fcdea5f191 100644 --- a/python/dune/xt/functions/spe10.hh +++ b/python/dune/xt/functions/spe10.hh @@ -46,7 +46,8 @@ static const constexpr size_t d = G::dimension; template <class G, size_t d, size_t r, size_t rC> typename std::enable_if< Grid::is_grid<G>::value && d == 2, - pybind11::class_<Spe10::Model1Function<typename G::template Codim<0>::Entity, r, rC, double>>>::type + pybind11::class_<Spe10::Model1Function<typename G::template Codim<0>::Entity, r, rC, double>, + GridFunctionInterface<typename G::template Codim<0>::Entity, r, rC, double>>>::type bind_Spe10Model1Function(pybind11::module& m, const std::string& grid_id) { namespace py = pybind11;