diff --git a/.ci/shared b/.ci/shared index f108b7fd0ac9fefcab197eb331be48da6da3ff57..7090ef1f15a9be6aeac87b31bc77f549302c7820 160000 --- a/.ci/shared +++ b/.ci/shared @@ -1 +1 @@ -Subproject commit f108b7fd0ac9fefcab197eb331be48da6da3ff57 +Subproject commit 7090ef1f15a9be6aeac87b31bc77f549302c7820 diff --git a/.gitsuper b/.gitsuper deleted file mode 100644 index f6402be6a07f302cb78213a1cb5fe66f910c04d2..0000000000000000000000000000000000000000 --- a/.gitsuper +++ /dev/null @@ -1,118 +0,0 @@ -[supermodule] -remote = git@github.com:dune-community/dune-gdt-super.git -status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master) - 28c9ce81c14c878a71e907ab05b9bb72df77883e config.opts (heads/master) - f308c6637edd65dcb83c4c1a46feaf05b958130e dune-alugrid (v2.6.0-7-gf308c663) - 76d7f0c9886a061571cb8dc66dd45a4ef86e7a58 dune-common (v2.2.1-2269-g76d7f0c9) - +36634986b34d08cd8f3805e2e607a7bba86ff25d dune-gdt (heads/saddlepoint) - 5235397bc16d24c759a1672fed7b8cfde4852e52 dune-geometry (v2.2.0-834-g5235397) - af5766f0df47e3d0b62ea486efb9cdbf8e1cfc52 dune-grid (v2.2.0-2671-gaf5766f0d) - 1369ae9329d0928480d6b18ed772fc77e1abf752 dune-grid-glue (v2.4.0-161-g1369ae9) - ef68ae0ec40f9d369e4ea9b31e560af6af545bf6 dune-istl (v2.6.0-4-gef68ae0e) - 5a1f77d7a0a41c2d065b29f00dda0871ec70337b dune-localfunctions (v2.6.0-2-g5a1f77d) - 6d2a4680493a2483d53f9dd05a19dd6b5f436572 dune-pybindxi (v2.2.1-30-g6d2a468) - 58bd932e2311a288e0163d041f836b50f19111cb dune-testtools (remotes/origin/testname_listing_hack2.6) - 07f9700459c616186737a9a34277f2edee76f475 dune-uggrid (v2.6.0-1-g07f97004) - 27a8010443c03eebddc3a910bdbef63ccf1f3e5d dune-xt-common (heads/master) - 376e88d14fd23ea12c3e23befc3fc967d4833751 dune-xt-data (heads/master) - 2da2612032ce64337f5af5cfec68d3c6d639e178 dune-xt-functions (heads/master) - 654c823f698418b67a696618342b54324f2cc151 dune-xt-grid (heads/master) - d1ffc46178cb9d93308294c5144afb4d7d0f0d82 dune-xt-la (heads/master) - 09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (heads/master) -commit = ee1fda4fe42ee5f7c744cf529f84adf689251563 - -[submodule.bin] -remote = git@github.com:dune-community/local-bin.git -status = -commit = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 - -[submodule.config.opts] -remote = git@github.com:dune-community/config.opts.git -status = -commit = 28c9ce81c14c878a71e907ab05b9bb72df77883e - -[submodule.dune-alugrid] -remote = https://github.com/dune-mirrors/dune-alugrid.git -status = -commit = f308c6637edd65dcb83c4c1a46feaf05b958130e - -[submodule.dune-common] -remote = git@github.com:dune-community/dune-common.git -status = -commit = 76d7f0c9886a061571cb8dc66dd45a4ef86e7a58 - -[submodule.dune-gdt] -remote = git@github.com:dune-community/dune-gdt.git -status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master) -commit = 36634986b34d08cd8f3805e2e607a7bba86ff25d - -[submodule.dune-geometry] -remote = git@github.com:dune-community/dune-geometry.git -status = -commit = 5235397bc16d24c759a1672fed7b8cfde4852e52 - -[submodule.dune-grid] -remote = git@github.com:dune-community/dune-grid.git -status = -commit = af5766f0df47e3d0b62ea486efb9cdbf8e1cfc52 - -[submodule.dune-grid-glue] -remote = https://github.com/dune-mirrors/dune-grid-glue.git -status = -commit = 1369ae9329d0928480d6b18ed772fc77e1abf752 - -[submodule.dune-istl] -remote = https://github.com/dune-mirrors/dune-istl.git -status = -commit = ef68ae0ec40f9d369e4ea9b31e560af6af545bf6 - -[submodule.dune-localfunctions] -remote = https://github.com/dune-mirrors/dune-localfunctions.git -status = -commit = 5a1f77d7a0a41c2d065b29f00dda0871ec70337b - -[submodule.dune-pybindxi] -remote = git@github.com:dune-community/dune-pybindxi.git -status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master) -commit = 6d2a4680493a2483d53f9dd05a19dd6b5f436572 - -[submodule.dune-testtools] -remote = git@github.com:dune-community/dune-testtools.git -status = -commit = 58bd932e2311a288e0163d041f836b50f19111cb - -[submodule.dune-uggrid] -remote = https://github.com/dune-mirrors/dune-uggrid.git -status = -commit = 07f9700459c616186737a9a34277f2edee76f475 - -[submodule.dune-xt-common] -remote = git@github.com:dune-community/dune-xt-common.git -status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master) -commit = 27a8010443c03eebddc3a910bdbef63ccf1f3e5d - -[submodule.dune-xt-data] -remote = git@github.com:dune-community/dune-xt-data -status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master) -commit = 376e88d14fd23ea12c3e23befc3fc967d4833751 - -[submodule.dune-xt-functions] -remote = git@github.com:dune-community/dune-xt-functions.git -status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master) -commit = 2da2612032ce64337f5af5cfec68d3c6d639e178 - -[submodule.dune-xt-grid] -remote = git@github.com:dune-community/dune-xt-grid.git -status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master) -commit = 654c823f698418b67a696618342b54324f2cc151 - -[submodule.dune-xt-la] -remote = git@github.com:dune-community/dune-xt-la.git -status = cc1bbdac283f4b9323c64345030f1b8f634b88d5 .vcsetup (heads/master) -commit = d1ffc46178cb9d93308294c5144afb4d7d0f0d82 - -[submodule.scripts] -remote = https://github.com/wwu-numerik/scripts.git -status = fb5ebc10e647d637c69497af2ec2560847eb2112 python/pylicense (v0.2.0~10) -commit = 09d0378f616b94d68bcdd9fc6114813181849ec0 - diff --git a/.pylicense-other.py b/.pylicense-other.py index 9466c53ec881f5c7b485e504e0e27ce8b4893b61..57d6fabcd0e3fa210f9e5636a58eee4c02eb4799 100644 --- a/.pylicense-other.py +++ b/.pylicense-other.py @@ -24,4 +24,4 @@ include_patterns = ('*.txt', '*.cmake', '*.py', '*.sh', '*.bash', '*.dgf', '*.ms '*.gitignore', '*.mailmap', '*.gitattributes', '*gitignore-*', '*stamp-vc', '*dune.module', '*Doxylocal', '*.clang-format', '*COPYING-CMAKE-SCRIPTS', '*README', '*LICENSE', '*mainpage', '*switch-build_dir', '*dune-xt-common.pc.in', '*CMakeLists.txt') -exclude_patterns = ('*config.h.cmake', '*.vcsetup*', '*builder_definitions.cmake', '*.ci/shared/*) +exclude_patterns = ('*config.h.cmake', '*.vcsetup*', '*builder_definitions.cmake', '*.ci/shared/*') diff --git a/.vcsetup b/.vcsetup index 0fe2d7bb19a198ee8d099ff308b9208af0914eb4..1f967c99ec990e557ad7b39a25c0148886019b79 160000 --- a/.vcsetup +++ b/.vcsetup @@ -1 +1 @@ -Subproject commit 0fe2d7bb19a198ee8d099ff308b9208af0914eb4 +Subproject commit 1f967c99ec990e557ad7b39a25c0148886019b79 diff --git a/dune/gdt/local/bilinear-forms/interfaces.hh b/dune/gdt/local/bilinear-forms/interfaces.hh index 18f0b90a6939ac2a194d98d4b9be52f9f2146241..b65572225f3593a8734d147ed13f0c36507f9bda 100644 --- a/dune/gdt/local/bilinear-forms/interfaces.hh +++ b/dune/gdt/local/bilinear-forms/interfaces.hh @@ -172,6 +172,27 @@ public: DynamicMatrix<F>& result_out_out, const XT::Common::Parameter& param = {}) const = 0; + /** + * Variant which consideres the intersection only from the inside. + */ + virtual void apply2(const IntersectionType& intersection, + const LocalTestBasisType& test_basis, + const LocalAnsatzBasisType& ansatz_basis, + DynamicMatrix<F>& result, + const XT::Common::Parameter& param = {}) const + { + this->apply2(intersection, + test_basis, + ansatz_basis, + test_basis, + ansatz_basis, + result, + unused_result_, + unused_result_, + unused_result_, + param); + } + /** * This method is provided for convenience and should not be used within library code. */ @@ -197,7 +218,23 @@ public: result_out_out, param); return {result_in_in, result_in_out, result_out_in, result_out_out}; - } // ... apply(...) + } // ... apply2(...) + + /** + * This method is provided for convenience and should not be used within library code. + */ + DynamicMatrix<F> apply2(const IntersectionType& intersection, + const LocalTestBasisType& test_basis, + const LocalAnsatzBasisType& ansatz_basis, + const XT::Common::Parameter& param = {}) const + { + DynamicMatrix<F> result(test_basis.size(param), ansatz_basis.size(param), 0); + this->apply2(intersection.test_basis, ansatz_basis, param); + return result; + } + +protected: + mutable DynamicMatrix<F> unused_result_; }; // class LocalIntersectionBilinearFormInterface diff --git a/dune/gdt/local/finite-elements/default.hh b/dune/gdt/local/finite-elements/default.hh index ed2b1ae5f6402341b7d807114436876223256746..2d72bed2b3e70430b34282c44e1bcfab38054d04 100644 --- a/dune/gdt/local/finite-elements/default.hh +++ b/dune/gdt/local/finite-elements/default.hh @@ -11,7 +11,10 @@ #ifndef DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH #define DUNE_GDT_LOCAL_FINITE_ELEMENTS_DEFAULT_HH +#include <dune/geometry/quadraturerules.hh> + #include <dune/xt/common/memory.hh> +#include <dune/xt/grid/integrals.hh> #include "interfaces.hh" @@ -145,26 +148,26 @@ private: template <class D, size_t d, class R = double, size_t r = 1, size_t rC = 1> -class ThreadSafeDefaultLocalLagrangeFiniteElementFamily : public LocalFiniteElementFamilyInterface<D, d, R, r, rC> +class ThreadSafeDefaultLocalFiniteElementFamily : public LocalFiniteElementFamilyInterface<D, d, R, r, rC> { - using ThisType = ThreadSafeDefaultLocalLagrangeFiniteElementFamily<D, d, R, r, rC>; + using ThisType = ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, r, rC>; using BaseType = LocalFiniteElementFamilyInterface<D, d, R, r, rC>; public: using typename BaseType::LocalFiniteElementType; - ThreadSafeDefaultLocalLagrangeFiniteElementFamily( + ThreadSafeDefaultLocalFiniteElementFamily( std::function<std::unique_ptr<LocalFiniteElementType>(const GeometryType&, const int&)> factory) : factory_(factory) {} - ThreadSafeDefaultLocalLagrangeFiniteElementFamily(const ThisType& other) + ThreadSafeDefaultLocalFiniteElementFamily(const ThisType& other) : factory_(other.factory_) { // we do not even try to create the FEs in a thread safe way, they will just be recreated when required } - ThreadSafeDefaultLocalLagrangeFiniteElementFamily(ThisType&& source) + ThreadSafeDefaultLocalFiniteElementFamily(ThisType&& source) : factory_(std::move(source.factory_)) , fes_(std::move(source.fes_)) {} @@ -191,7 +194,70 @@ private: const std::function<std::unique_ptr<LocalFiniteElementType>(const GeometryType&, const int&)> factory_; mutable std::map<std::pair<GeometryType, int>, std::shared_ptr<LocalFiniteElementType>> fes_; mutable std::mutex mutex_; -}; // class ThreadSafeDefaultLocalLagrangeFiniteElementFamily +}; // class ThreadSafeDefaultLocalFiniteElementFamily + + +template <class D, size_t d, class R, size_t r = 1> +class LocalL2FiniteElementInterpolation : public LocalFiniteElementInterpolationInterface<D, d, R, r, 1> +{ + using ThisType = LocalL2FiniteElementInterpolation<D, d, R, r>; + using BaseType = LocalFiniteElementInterpolationInterface<D, d, R, r, 1>; + +public: + using typename BaseType::DomainType; + using typename BaseType::RangeType; + + using LocalBasisType = LocalFiniteElementBasisInterface<D, d, R, r, 1>; + + LocalL2FiniteElementInterpolation(const LocalBasisType& local_basis) + : local_basis_(local_basis.copy()) + {} + + LocalL2FiniteElementInterpolation(const ThisType& other) + : local_basis_(other.local_basis_->copy()) + {} + + LocalL2FiniteElementInterpolation(ThisType& source) = default; + + ThisType* copy() const override final + { + return new ThisType(*this); + } + + const GeometryType& geometry_type() const override final + { + return local_basis_->geometry_type(); + } + + size_t size() const override final + { + return local_basis_->size(); + } + + using BaseType::interpolate; + + void interpolate(const std::function<RangeType(DomainType)>& local_function, + const int order, + DynamicVector<R>& dofs) const override final + { + if (dofs.size() < this->size()) + dofs.resize(this->size()); + dofs *= 0.; + std::vector<RangeType> basis_values(local_basis_->size()); + RangeType function_value; + for (auto&& quadrature_point : QuadratureRules<D, d>::rule(this->geometry_type(), order + local_basis_->order())) { + const auto point_in_reference_element = quadrature_point.position(); + const auto quadrature_weight = quadrature_point.weight(); + local_basis_->evaluate(point_in_reference_element, basis_values); + function_value = local_function(point_in_reference_element); + for (size_t ii = 0; ii < local_basis_->size(); ++ii) + dofs[ii] = (basis_values[ii] * function_value) * quadrature_weight; + } + } // ... interpolate(...) + +private: + std::unique_ptr<LocalBasisType> local_basis_; +}; // class LocalL2FiniteElementInterpolation } // namespace GDT diff --git a/dune/gdt/local/finite-elements/flattop.hh b/dune/gdt/local/finite-elements/flattop.hh new file mode 100644 index 0000000000000000000000000000000000000000..dcd2a444593a44930ae750742aeab4b981bc11dc --- /dev/null +++ b/dune/gdt/local/finite-elements/flattop.hh @@ -0,0 +1,299 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_LOCAL_FINITE_ELEMENTS_FLATTOP_HH +#define DUNE_GDT_LOCAL_FINITE_ELEMENTS_FLATTOP_HH + +#include <functional> + +#include <dune/gdt/exceptions.hh> + +#include "default.hh" +#include "interfaces.hh" +#include "lagrange.hh" +#include "power.hh" + +namespace Dune { +namespace GDT { + + +/** + * \sa LocalFlatTop2dCubeFiniteElement + * \sa LocalFlatTopFiniteElementFactory + */ +template <class D = double, class R = double> +class LocalFlatTop2dCubeFiniteElementBasis : public LocalFiniteElementBasisInterface<D, 2, R, 1, 1> +{ + using ThisType = LocalFlatTop2dCubeFiniteElementBasis<D, R>; + using BaseType = LocalFiniteElementBasisInterface<D, 2, R, 1, 1>; + +public: + using typename BaseType::DerivativeRangeType; + using typename BaseType::DomainType; + using typename BaseType::RangeType; + + LocalFlatTop2dCubeFiniteElementBasis(const double& overlap = 0.5) + : geometry_type_(GeometryType::cube, 2) + { + // we cannot let L_ and R_ be members and define phi_L_ and phi_R_ in the ctor initializer list, as they will + // copy/reference broken/empty/default L_ and R_ + const auto L_ = (1. - overlap) / 2.; + const auto R_ = (1. + overlap) / 2.; + phi_L_ = [=](const D& x) { + if (x < L_) + return 1.; + else if (x > R_) + return 0.; + else + return -1. * (x / overlap) + R_ / overlap; + }; + grad_phi_L_ = [=](const D& x) { + if (x < L_) + return 0.; + else if (x > R_) + return 0.; + else + return -1. / overlap; + }; + phi_R_ = [=](const D& x) { + if (x < L_) + return 0.; + else if (x > R_) + return 1.; + else + return (x / overlap) - L_ / overlap; + }; + grad_phi_R_ = [=](const D& x) { + if (x < L_) + return 0.; + else if (x > R_) + return 0.; + else + return (1. / overlap); + }; + } // LocalFlatTop2dCubeFiniteElementBasis(...) + + LocalFlatTop2dCubeFiniteElementBasis(const ThisType& other) = default; + LocalFlatTop2dCubeFiniteElementBasis(ThisType&& source) = default; + + ThisType* copy() const override final + { + return new ThisType(*this); + } + + const GeometryType& geometry_type() const override final + { + return geometry_type_; + } + + int order() const override final + { + return 2; + } + + size_t size() const override final + { + return 4; + } + + using BaseType::evaluate; + + void evaluate(const DomainType& point_in_reference_element, std::vector<RangeType>& result) const override final + { + if (result.size() < 4) + result.resize(4); + const auto& x = point_in_reference_element[0]; + const auto& y = point_in_reference_element[1]; + // each shape function is associated with one corner, the positions of which are known on the reference element + // * shape function 0: bottom left corner + result[0] = phi_L_(x) * phi_L_(y); + // * shape function 1: bottom right corner + result[1] = phi_R_(x) * phi_L_(y); + // * shape function 2: top left corner + result[2] = phi_L_(x) * phi_R_(y); + // * shape function 3: top right corner + result[3] = phi_R_(x) * phi_R_(y); + } // ... evaluate(...) + + using BaseType::jacobian; + + void jacobian(const DomainType& point_in_reference_element, + std::vector<DerivativeRangeType>& result) const override final + { + if (result.size() < 4) + result.resize(4); + const auto& x = point_in_reference_element[0]; + const auto& y = point_in_reference_element[1]; + // * shape function 0 + result[0][0][0] = grad_phi_L_(x) * phi_L_(y); + result[0][0][1] = phi_L_(x) * grad_phi_L_(y); + // * shape function 1 + result[1][0][0] = grad_phi_R_(x) * phi_L_(y); + result[1][0][1] = phi_R_(x) * grad_phi_L_(y); + // * shape function 2 + result[2][0][0] = grad_phi_L_(x) * phi_R_(y); + result[2][0][1] = phi_L_(x) * grad_phi_R_(y); + // * shape function 3 + result[3][0][0] = grad_phi_R_(x) * phi_R_(y); + result[3][0][1] = phi_R_(x) * grad_phi_R_(y); + } // ... jacobian(...) + +private: + const GeometryType geometry_type_; + std::function<R(const D&)> phi_L_; + std::function<R(const D&)> phi_R_; + std::function<R(const D&)> grad_phi_L_; + std::function<R(const D&)> grad_phi_R_; +}; // class LocalFlatTop2dCubeFiniteElementBasis + + +template <class D = double, class R = double> +class LocalFlatTop2dCubeFiniteElement : public LocalFiniteElementDefault<D, 2, R, 1> +{ + using ThisType = LocalFlatTop2dCubeFiniteElement<D, R>; + using BaseType = LocalFiniteElementDefault<D, 2, R, 1>; + +public: + LocalFlatTop2dCubeFiniteElement(const double& overlap = 0.5) + : BaseType( + 1, + LocalFlatTop2dCubeFiniteElementBasis<D, R>(overlap).copy(), + LocalLagrangeFiniteElementFactory<D, 2, R, 1>::create(GeometryType(GeometryType::cube, 2), 1) + ->coefficients() + .copy(), + LocalL2FiniteElementInterpolation<D, 2, R, 1>(LocalFlatTop2dCubeFiniteElementBasis<D, R>(overlap)).copy(), + {}) + {} +}; // class LocalFlatTop2dCubeFiniteElement + + +template <class D, size_t d, class R, size_t r = 1> +class LocalFlatTopFiniteElementFactory +{ + using ScalarLocalFiniteElementType = LocalFiniteElementInterface<D, d, R, 1>; + +public: + using LocalFiniteElementType = LocalFiniteElementInterface<D, d, R, r>; + +private: + static std::string order_error(const GeometryType& geometry_type, const int order) + { + std::stringstream ss; + ss << "when creating a local FlatTop finite element: the FlatTopLocalFiniteElement is known to fail in " << d + << "d on a " << geometry_type << " reference element for order " << order + << " (if you think it is working, update this check)!"; + return ss.str(); + } + + static std::string geometry_error(const GeometryType& geometry_type, const int order) + { + std::stringstream ss; + ss << "when creating a local FlatTop finite element: this is untested!\n" + << "Please update this check if you believe that FlatTopLocalFiniteElement is available for\n- dimension: " << d + << "\n- geometry_type: " << geometry_type << "\n- order: " << order; + return ss.str(); + } + + // Fist we create the scalar FE ... + + template <size_t d_ = d, bool anything = true> + struct scalar_helper + { + static std::unique_ptr<ScalarLocalFiniteElementType> + create(const GeometryType& geometry_type, const int& order, const D& overlap = 0.5) + { + DUNE_THROW_IF(geometry_type.dim() != d, + Exceptions::finite_element_error, + "geometry_type = " << geometry_type << "\nd = " << d); + // checks + if (d == 2) { + if (geometry_type == GeometryTypes::cube(2)) + DUNE_THROW_IF(order != 1, Exceptions::finite_element_error, order_error(geometry_type, order)); + else + DUNE_THROW(Exceptions::finite_element_error, geometry_error(geometry_type, order)); + } else + DUNE_THROW(Exceptions::finite_element_error, geometry_error(geometry_type, order)); + // the actual finite element + return std::unique_ptr<LocalFiniteElementInterface<D, d, R, 1>>( + new LocalFlatTop2dCubeFiniteElement<D, R>(overlap)); + } + }; // helper<...> + + template <bool anything> + struct scalar_helper<0, anything> + { + static std::unique_ptr<ScalarLocalFiniteElementType> + create(const GeometryType& geometry_type, const int& /*order*/, const D& /*overlap*/ = 0.5) + { + // If we need this, and geometry_type.dim() == 0, we must simply implement the corresponding ctors of the 0d FE! + DUNE_THROW_IF( + geometry_type.dim() != 0 || !geometry_type.isSimplex(), + Exceptions::finite_element_error, + "when creating a local 0d orthonomal finite element: not available for geometry_type = " << geometry_type); + return std::make_unique<Local0dFiniteElement<D, R>>(); + } + }; // helper<...> + + // ... then we wrap this in a power FE, if required. + + template <size_t d_ = d, size_t r_ = r> + struct helper // r != 1 + { + static std::unique_ptr<LocalFiniteElementType> + create(const GeometryType& geometry_type, const int& order, const D& overlap = 0.5) + { + return make_local_powered_finite_element<r>(*scalar_helper<>::create(geometry_type, order, overlap)); + } + }; + + template <size_t d_> + struct helper<d_, 1> + { + static std::unique_ptr<LocalFiniteElementType> + create(const GeometryType& geometry_type, const int& order, const D& overlap = 0.5) + { + return scalar_helper<>::create(geometry_type, order, overlap); + } + }; + +public: + static std::unique_ptr<LocalFiniteElementInterface<D, d, R, r>> + create(const GeometryType& geometry_type, const int& order, const D& overlap = 0.5) + { + return helper<>::create(geometry_type, order, overlap); + } +}; // class LocalFlatTopFiniteElementFactory + + +template <class D, size_t d, class R, size_t r = 1> +std::unique_ptr<LocalFiniteElementInterface<D, d, R, r>> +make_local_flattop_finite_element(const GeometryType& geometry_type, const int order, const D& overlap = 0.5) +{ + return LocalFlatTopFiniteElementFactory<D, d, R, r>::create(geometry_type, order, overlap); +} + + +template <class D, size_t d, class R, size_t r = 1> +class LocalFlatTopFiniteElementFamily : public ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, r> +{ + using BaseType = ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, r>; + +public: + LocalFlatTopFiniteElementFamily(const D& overlap = 0.5) + : BaseType([=](const auto& geometry_type, const auto& order) { + return LocalFlatTopFiniteElementFactory<D, d, R, r>::create(geometry_type, order, overlap); + }) + {} +}; // ... LocalFlatTopFiniteElementFamily(...) + + +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_LOCAL_FINITE_ELEMENTS_FLATTOP_HH diff --git a/dune/gdt/local/finite-elements/lagrange.hh b/dune/gdt/local/finite-elements/lagrange.hh index e575ddda9d24d78afbb4a31dd61d0d2f7f5c3ffe..c82c43025426439fc916603574938d249bd47acb 100644 --- a/dune/gdt/local/finite-elements/lagrange.hh +++ b/dune/gdt/local/finite-elements/lagrange.hh @@ -195,9 +195,9 @@ make_local_lagrange_finite_element(const GeometryType& geometry_type, const int template <class D, size_t d, class R, size_t r = 1> -class LocalLagrangeFiniteElementFamily : public ThreadSafeDefaultLocalLagrangeFiniteElementFamily<D, d, R, r> +class LocalLagrangeFiniteElementFamily : public ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, r> { - using BaseType = ThreadSafeDefaultLocalLagrangeFiniteElementFamily<D, d, R, r>; + using BaseType = ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, r>; public: LocalLagrangeFiniteElementFamily() diff --git a/dune/gdt/local/finite-elements/raviart-thomas.hh b/dune/gdt/local/finite-elements/raviart-thomas.hh index 244a502b616e77e41a8e87caabba91445a28d389..91ba7b249bf58b55101de65f47bef11325f0c1a4 100644 --- a/dune/gdt/local/finite-elements/raviart-thomas.hh +++ b/dune/gdt/local/finite-elements/raviart-thomas.hh @@ -353,9 +353,9 @@ make_local_raviart_thomas_finite_element(const GeometryType& geometry_type, cons template <class D, size_t d, class R> -class LocalRaviartThomasFiniteElementFamily : public ThreadSafeDefaultLocalLagrangeFiniteElementFamily<D, d, R, d, 1> +class LocalRaviartThomasFiniteElementFamily : public ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, d, 1> { - using BaseType = ThreadSafeDefaultLocalLagrangeFiniteElementFamily<D, d, R, d, 1>; + using BaseType = ThreadSafeDefaultLocalFiniteElementFamily<D, d, R, d, 1>; public: LocalRaviartThomasFiniteElementFamily() diff --git a/dune/gdt/local/integrands/combined.hh b/dune/gdt/local/integrands/combined.hh new file mode 100644 index 0000000000000000000000000000000000000000..3c48f068b7031826f7bc4e918dfd63b6db9e03dc --- /dev/null +++ b/dune/gdt/local/integrands/combined.hh @@ -0,0 +1,379 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_LOCAL_INTEGRANDS_COMBINED_HH +#define DUNE_GDT_LOCAL_INTEGRANDS_COMBINED_HH + +#include <dune/xt/common/memory.hh> + +#include "interfaces.hh" + +namespace Dune { +namespace GDT { + + +/// \todo add LocalUnaryElementIntegrandSum +/// \todo add operator+ to LocalUnaryElementIntegrandInterface +/// \sa LocalQuaternaryIntersectionIntegrandSum +// template <class E, size_t r, size_t rC, class R, class F> +// class LocalUnaryElementIntegrandSum +// : public XT::Common::ParametricInterface +// , public XT::Grid::ElementBoundObject<Element> +//{ +// static_assert(XT::Grid::is_entity<Element>::value, ""); + +// using ThisType = LocalUnaryElementIntegrandInterface<Element, range_dim, range_dim_cols, RangeField, Field>; + +// public: +// using E = Element; +// using D = typename Element::Geometry::ctype; +// static const constexpr size_t d = E::dimension; +// using F = Field; + +// using R = RangeField; +// static const constexpr size_t r = range_dim; +// static const constexpr size_t rC = range_dim_cols; + +// using typename XT::Grid::ElementBoundObject<Element>::ElementType; +// using DomainType = FieldVector<D, d>; +// using LocalBasisType = XT::Functions::ElementFunctionSetInterface<E, r, rC, R>; + +// LocalUnaryElementIntegrandInterface(const XT::Common::ParameterType& param_type = {}) +// : XT::Common::ParametricInterface(param_type) +// {} + +// virtual ~LocalUnaryElementIntegrandInterface() = default; + +// virtual std::unique_ptr<ThisType> copy() const = 0; + +// protected: +// virtual void post_bind(const IntersectionType& intrsctn) = 0; + +// public: + +// /** +// * Returns the polynomial order of the integrand, given the basis. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual int order(const LocalBasisType& basis, const XT::Common::Parameter& param = {}) const = 0; + +// /** +// * Computes the evaluation of this integrand at the given point for each function in the basis. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual void evaluate(const LocalBasisType& basis, +// const DomainType& point_in_reference_element, +// DynamicVector<F>& result, +// const XT::Common::Parameter& param = {}) const = 0; + +// /** +// * This method is provided for convenience and should not be used within library code. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual DynamicVector<F> evaluate(const LocalBasisType& basis, +// const DomainType& point_in_reference_element, +// const XT::Common::Parameter& param = {}) const +// { +// DynamicVector<F> result(basis.size(param)); +// evaluate(basis, point_in_reference_element, result, param); +// return result; +// } +//}; // class LocalUnaryElementIntegrandSum + + +/// \todo add LocalBinaryElementIntegrandSum +/// \todo add operator+ to LocalBinaryElementIntegrandInterface +/// \sa LocalQuaternaryIntersectionIntegrandSum +// template <class E, size_t t_r, size_t t_RC, class TF, class F, size_t a_r, size_t a_rC, class AF> +// class LocalBinaryElementIntegrandSum +// : public XT::Common::ParametricInterface +// , public XT::Grid::ElementBoundObject<Element> +//{ +// static_assert(XT::Grid::is_entity<Element>::value, ""); + +// using ThisType = LocalBinaryElementIntegrandInterface<Element, +// test_range_dim, +// test_range_dim_cols, +// TestRangeField, +// Field, +// ansatz_range_dim, +// ansatz_range_dim_cols, +// AnsatzRangeField>; + +// public: +// using E = Element; +// using D = typename Element::Geometry::ctype; +// static const constexpr size_t d = E::dimension; +// using F = Field; + +// using TR = TestRangeField; +// static const constexpr size_t t_r = test_range_dim; +// static const constexpr size_t t_rC = test_range_dim_cols; + +// using AR = AnsatzRangeField; +// static const constexpr size_t a_r = ansatz_range_dim; +// static const constexpr size_t a_rC = ansatz_range_dim_cols; + +// using typename XT::Grid::ElementBoundObject<Element>::ElementType; +// using DomainType = FieldVector<D, d>; +// using LocalTestBasisType = XT::Functions::ElementFunctionSetInterface<E, t_r, t_rC, TR>; +// using LocalAnsatzBasisType = XT::Functions::ElementFunctionSetInterface<E, a_r, a_rC, AR>; + +// LocalBinaryElementIntegrandInterface(const XT::Common::ParameterType& param_type = {}) +// : XT::Common::ParametricInterface(param_type) +// {} + +// virtual ~LocalBinaryElementIntegrandInterface() = default; + +// virtual std::unique_ptr<ThisType> copy() const = 0; + +// protected: +// virtual void post_bind(const IntersectionType& intrsctn) = 0; + +// public: +// /** +// * Returns the polynomial order of the integrand, given the bases. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual int order(const LocalTestBasisType& test_basis, +// const LocalAnsatzBasisType& ansatz_basis, +// const XT::Common::Parameter& param = {}) const = 0; + +// /** +// * Computes the evaluation of this integrand at the given point for each combination of functions from the two +// bases. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual void evaluate(const LocalTestBasisType& test_basis, +// const LocalAnsatzBasisType& ansatz_basis, +// const DomainType& point_in_reference_element, +// DynamicMatrix<F>& result, +// const XT::Common::Parameter& param = {}) const = 0; + +// /** +// * This method is provided for convenience and should not be used within library code. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual DynamicMatrix<F> evaluate(const LocalTestBasisType& test_basis, +// const LocalAnsatzBasisType& ansatz_basis, +// const DomainType& point_in_reference_element, +// const XT::Common::Parameter& param = {}) const +// { +// DynamicMatrix<F> result(test_basis.size(param), ansatz_basis.size(param), 0); +// evaluate(test_basis, ansatz_basis, point_in_reference_element, result, param); +// return result; +// } +//}; // class LocalBinaryElementIntegrandInterface + + +/// \todo add LocalBinaryIntersectionIntegrandSum +/// \todo add operator+ to LocalBinaryIntersectionIntegrandInterface +/// \sa LocalQuaternaryIntersectionIntegrandSum +// template <class I, size_t r, size_t rC, class R, class F> +// class LocalBinaryIntersectionIntegrandSum +// : public XT::Common::ParametricInterface +// , public XT::Grid::IntersectionBoundObject<Intersection> +//{ +// static_assert(XT::Grid::is_intersection<Intersection>::value, ""); + +// using ThisType = +// LocalBinaryIntersectionIntegrandInterface<Intersection, range_dim, range_dim_cols, RangeField, Field>; + +// public: +// using typename XT::Grid::IntersectionBoundObject<Intersection>::IntersectionType; +// using ElementType = XT::Grid::extract_inside_element_t<Intersection>; + +// using I = Intersection; +// using E = ElementType; +// using D = typename ElementType::Geometry::ctype; +// static const constexpr size_t d = E::dimension; +// using F = Field; + +// using RF = RangeField; +// static const constexpr size_t r = range_dim; +// static const constexpr size_t rC = range_dim_cols; + +// using DomainType = FieldVector<D, d - 1>; +// using LocalBasisType = XT::Functions::ElementFunctionSetInterface<E, r, rC, RF>; + +// LocalBinaryIntersectionIntegrandInterface(const XT::Common::ParameterType& param_type = {}) +// : XT::Common::ParametricInterface(param_type) +// {} + +// virtual ~LocalBinaryIntersectionIntegrandInterface() = default; + +// virtual std::unique_ptr<ThisType> copy() const = 0; + +// protected: +// virtual void post_bind(const IntersectionType& intrsctn) = 0; + +// public: +// /** +// * Returns the polynomial order of the integrand, given the bases. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual int order(const LocalBasisType& inside_basis, +// const LocalBasisType& outside_basis, +// const XT::Common::Parameter& param = {}) const = 0; + +// /** +// * Computes the evaluation of this integrand at the given point for each combination of functions from the two +// bases. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual void evaluate(const LocalBasisType& inside_basis, +// const LocalBasisType& outside_basis, +// const DomainType& point_in_reference_element, +// DynamicMatrix<F>& result, +// const XT::Common::Parameter& param = {}) const = 0; + +// /** +// * This method is provided for convenience and should not be used within library code. +// * +// * \note Will throw Exceptions::not_bound_to_an_element_yet error if not bound yet! +// **/ +// virtual DynamicMatrix<F> evaluate(const LocalBasisType& inside_basis, +// const LocalBasisType& outside_basis, +// const DomainType& point_in_reference_element, +// const XT::Common::Parameter& param = {}) const +// { +// DynamicMatrix<F> result(inside_basis.size(param), outside_basis.size(param), 0); +// evaluate(inside_basis, inside_basis, point_in_reference_element, result, param); +// return result; +// } +//}; // class LocalBinaryIntersectionIntegrandSum + + +template <class I, size_t t_r, size_t t_rC, class TF, class F, size_t a_r, size_t a_rC, class AF> +class LocalQuaternaryIntersectionIntegrandSum + : public LocalQuaternaryIntersectionIntegrandInterface<I, t_r, t_rC, TF, F, a_r, a_rC, AF> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I, t_r, t_rC, TF, F, a_r, a_rC, AF>; + using ThisType = LocalQuaternaryIntersectionIntegrandSum<I, t_r, t_rC, TF, F, a_r, a_rC, AF>; + +public: + using typename BaseType::DomainType; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + LocalQuaternaryIntersectionIntegrandSum(const BaseType& left, const BaseType& right) + : BaseType(left.parameter_type() + right.parameter_type()) + , left_(left.copy().release()) + , right_(right.copy().release()) + {} + + LocalQuaternaryIntersectionIntegrandSum(const ThisType& other) + : BaseType(other) + , left_(other.left_.access().copy().release()) + , right_(other.right_.access().copy().release()) + {} + + LocalQuaternaryIntersectionIntegrandSum(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intrsctn) override final + { + left_.access().bind(intrsctn); + right_.access().bind(intrsctn); + } + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const XT::Common::Parameter& param = {}) const override final + { + return std::max( + left_.access().order(test_basis_inside, ansatz_basis_inside, test_basis_outside, ansatz_basis_outside, param), + right_.access().order(test_basis_inside, ansatz_basis_inside, test_basis_outside, ansatz_basis_outside, param)); + } + + using BaseType::evaluate; + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Each integrand clears its storage, so we let the left one write into ... + left_.access().evaluate(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + point_in_reference_intersection, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // ..., the right one into ... + right_.access().evaluate(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + point_in_reference_intersection, + result_in_in_, + result_in_out_, + result_out_in_, + result_out_out_, + param); + // ... and simply add them up (cannot use += here, matrices might be larger). + const size_t rows_in = test_basis_inside.size(param); + const size_t rows_out = test_basis_outside.size(param); + const size_t cols_in = ansatz_basis_inside.size(param); + const size_t cols_out = ansatz_basis_outside.size(param); + for (size_t ii = 0; ii < rows_in; ++ii) + for (size_t jj = 0; jj < cols_in; ++jj) + result_in_in[ii][jj] += result_in_in_[ii][jj]; + for (size_t ii = 0; ii < rows_in; ++ii) + for (size_t jj = 0; jj < cols_out; ++jj) + result_in_out[ii][jj] += result_in_out_[ii][jj]; + for (size_t ii = 0; ii < rows_out; ++ii) + for (size_t jj = 0; jj < cols_in; ++jj) + result_out_in[ii][jj] += result_out_in_[ii][jj]; + for (size_t ii = 0; ii < rows_out; ++ii) + for (size_t jj = 0; jj < cols_out; ++jj) + result_out_out[ii][jj] += result_out_out_[ii][jj]; + } // ... evaluate(...) + +private: + XT::Common::StorageProvider<BaseType> left_; + XT::Common::StorageProvider<BaseType> right_; + mutable DynamicMatrix<F> result_in_in_; + mutable DynamicMatrix<F> result_in_out_; + mutable DynamicMatrix<F> result_out_in_; + mutable DynamicMatrix<F> result_out_out_; +}; // class LocalQuaternaryIntersectionIntegrandSum + + +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_LOCAL_INTEGRANDS_COMBINED_HH diff --git a/dune/gdt/local/integrands/elliptic-ipdg.hh b/dune/gdt/local/integrands/elliptic-ipdg.hh index b79d79fd9266a945dda5b558192eeeb5acfb4459..1308b9ea7db0e08ed8c0e068cc67ce4c05817a77 100644 --- a/dune/gdt/local/integrands/elliptic-ipdg.hh +++ b/dune/gdt/local/integrands/elliptic-ipdg.hh @@ -10,16 +10,328 @@ // René Milk (2017) // Tobias Leibner (2014) +#warning This header is deprecated, use and include <dune/gdt/local/integrands/laplace-ipdg.hh> instead! + #ifndef DUNE_GDT_LOCAL_INTEGRANDS_ELLIPTIC_IPDG_HH -#define DUNE_GDT_LOCAL_INTEGRANDS_ELLIPTIC_IPDG_HH +# define DUNE_GDT_LOCAL_INTEGRANDS_ELLIPTIC_IPDG_HH -#include <dune/xt/functions/interfaces/grid-function.hh> +# include <dune/xt/common/deprecated.hh> +# include <dune/xt/functions/grid-function.hh> +# include <dune/xt/functions/interfaces/grid-function.hh> -#include "interfaces.hh" +# include "interfaces.hh" +# include "ipdg.hh" namespace Dune { namespace GDT { +/** + * \brief To replace the ones in LocalEllipticIpdgIntegrands at some point. + */ +namespace LocalEllipticIPDGIntegrands { + + +/** + * \note The role of symmetry_prefactor: + * * -1 => NIPDG + * * 0 => IIPDG + * * 1 => SIPDG + * \note The role of the weight: + * * symmetry_prefactor = 1 && weight_function = 1 => SIPDG + * * symmetry_prefactor = 1 && weight_function = diffusion => SWIPDG + */ +template <class I> +class InnerCoupling : public LocalQuaternaryIntersectionIntegrandInterface<I> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I>; + using ThisType = InnerCoupling<I>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::F; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + InnerCoupling(const double& symmetry_prefactor, + XT::Functions::GridFunction<E, d, d> diffusion, + XT::Functions::GridFunction<E, d, d> weight_function = {1.}) + : BaseType(diffusion.parameter_type() + weight_function.parameter_type()) + , symmetry_prefactor_(symmetry_prefactor) + , diffusion_(diffusion) + , weight_(weight_function) + , local_diffusion_in_(diffusion_.local_function()) + , local_diffusion_out_(diffusion_.local_function()) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + InnerCoupling(const ThisType& other) + : BaseType(other.parameter_type()) + , symmetry_prefactor_(other.symmetry_prefactor_) + , diffusion_(other.diffusion_) + , weight_(other.weight_) + , local_diffusion_in_(diffusion_.local_function()) + , local_diffusion_out_(diffusion_.local_function()) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + InnerCoupling(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intersection) override final + { + DUNE_THROW_IF(!intersection.neighbor(), + Exceptions::integrand_error, + "This integrand cannot be used on a boundary intersection!"); + const auto inside_element = intersection.inside(); + const auto outside_element = intersection.outside(); + local_diffusion_in_->bind(inside_element); + local_weight_in_->bind(inside_element); + local_diffusion_out_->bind(outside_element); + local_weight_out_->bind(outside_element); + } // ... post_bind(...) + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const XT::Common::Parameter& param = {}) const override final + { + return std::max(local_diffusion_in_->order(param), local_diffusion_out_->order(param)) + + std::max(local_weight_in_->order(), local_weight_out_->order(param)) + + std::max(test_basis_inside.order(param), test_basis_outside.order(param)) + + std::max(ansatz_basis_inside.order(param), ansatz_basis_outside.order(param)); + } + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Prepare sotrage, ... + this->ensure_size_and_clear_results(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // evaluate ... + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + const auto point_in_outside_reference_element = + this->intersection().geometryInOutside().global(point_in_reference_intersection); + const auto normal = this->intersection().unitOuterNormal(point_in_reference_intersection); + // ... basis functions and ... + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_in_values_, param); + test_basis_inside.jacobians(point_in_inside_reference_element, test_basis_in_grads_, param); + test_basis_outside.evaluate(point_in_outside_reference_element, test_basis_out_values_, param); + test_basis_outside.jacobians(point_in_outside_reference_element, test_basis_out_grads_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_in_values_, param); + ansatz_basis_inside.jacobians(point_in_inside_reference_element, ansatz_basis_in_grads_, param); + ansatz_basis_outside.evaluate(point_in_outside_reference_element, ansatz_basis_out_values_, param); + ansatz_basis_outside.jacobians(point_in_outside_reference_element, ansatz_basis_out_grads_, param); + // ... data functions, ... + const auto diffusion_in = local_diffusion_in_->evaluate(point_in_inside_reference_element, param); + const auto diffusion_out = local_diffusion_out_->evaluate(point_in_outside_reference_element, param); + const auto weight_in = local_weight_in_->evaluate(point_in_inside_reference_element, param); + const auto weight_out = local_weight_out_->evaluate(point_in_outside_reference_element, param); + // compute the weighted mean ... + const auto delta_plus = normal * (weight_out * normal); + const auto delta_minus = normal * (weight_in * normal); + const auto weight_minus = delta_plus / (delta_plus + delta_minus); + const auto weight_plus = delta_minus / (delta_plus + delta_minus); + // ... and finally compute the integrand. + const size_t rows_in = test_basis_inside.size(param); + const size_t rows_out = test_basis_outside.size(param); + const size_t cols_in = ansatz_basis_inside.size(param); + const size_t cols_out = ansatz_basis_outside.size(param); + for (size_t ii = 0; ii < rows_in; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) { + result_in_in[ii][jj] += + -1.0 * weight_minus * ((diffusion_in * ansatz_basis_in_grads_[jj][0]) * normal) * test_basis_in_values_[ii]; + result_in_in[ii][jj] += -1.0 * symmetry_prefactor_ * weight_minus * ansatz_basis_in_values_[jj] + * ((diffusion_in * test_basis_in_grads_[ii][0]) * normal); + } + for (size_t jj = 0; jj < cols_out; ++jj) { + result_in_out[ii][jj] += -1.0 * weight_plus * ((diffusion_out * ansatz_basis_out_grads_[jj][0]) * normal) + * test_basis_in_values_[ii]; + result_in_out[ii][jj] += symmetry_prefactor_ * weight_minus * ansatz_basis_out_values_[jj] + * ((diffusion_in * test_basis_in_grads_[ii][0]) * normal); + } + } + for (size_t ii = 0; ii < rows_out; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) { + result_out_in[ii][jj] += + weight_minus * ((diffusion_in * ansatz_basis_in_grads_[jj][0]) * normal) * test_basis_out_values_[ii]; + result_out_in[ii][jj] += -1.0 * symmetry_prefactor_ * weight_plus * ansatz_basis_in_values_[jj] + * ((diffusion_out * test_basis_out_grads_[ii][0]) * normal); + } + for (size_t jj = 0; jj < cols_out; ++jj) { + result_out_out[ii][jj] += + weight_plus * ((diffusion_out * ansatz_basis_out_grads_[jj][0]) * normal) * test_basis_out_values_[ii]; + result_out_out[ii][jj] += symmetry_prefactor_ * weight_plus * ansatz_basis_out_values_[jj] + * ((diffusion_out * test_basis_out_grads_[ii][0]) * normal); + } + } + } // ... evaluate(...) + +private: + const double symmetry_prefactor_; + XT::Functions::GridFunction<E, d, d> diffusion_; + XT::Functions::GridFunction<E, d, d> weight_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_diffusion_in_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_diffusion_out_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_weight_in_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_weight_out_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_in_values_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_in_grads_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_out_values_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_out_grads_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_in_values_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_in_grads_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_out_values_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_out_grads_; +}; // InnerCoupling + + +/** + * \note The role of symmetry_prefactor: + * * -1 => NIPDG + * * 0 => IIPDG + * * 1 => SIPDG + * \note The role of the weight: + * * symmetry_prefactor = 1 && weight_function = 1 => SIPDG + * * symmetry_prefactor = 1 && weight_function = diffusion => SWIPDG + */ +template <class I> +class DirichletCoupling : public LocalQuaternaryIntersectionIntegrandInterface<I> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I>; + using ThisType = DirichletCoupling<I>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::F; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + DirichletCoupling(const double& symmetry_prefactor, XT::Functions::GridFunction<E, d, d> diffusion) + : BaseType(diffusion.parameter_type()) + , symmetry_prefactor_(symmetry_prefactor) + , diffusion_(diffusion) + , local_diffusion_(diffusion_.local_function()) + {} + + DirichletCoupling(const ThisType& other) + : BaseType(other.parameter_type()) + , symmetry_prefactor_(other.symmetry_prefactor_) + , diffusion_(other.diffusion_) + , local_diffusion_(diffusion_.local_function()) + {} + + DirichletCoupling(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intersection) override final + { + const auto inside_element = intersection.inside(); + local_diffusion_->bind(inside_element); + } + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& /*test_basis_outside*/, + const LocalAnsatzBasisType& /*ansatz_basis_outside*/, + const XT::Common::Parameter& param = {}) const override final + { + return local_diffusion_->order(param) + test_basis_inside.order(param) + ansatz_basis_inside.order(param); + } + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Prepare sotrage, ... + this->ensure_size_and_clear_results(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // evaluate ... + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + const auto normal = this->intersection().unitOuterNormal(point_in_reference_intersection); + // ... basis functions and ... + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_values_, param); + test_basis_inside.jacobians(point_in_inside_reference_element, test_basis_grads_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_values_, param); + ansatz_basis_inside.jacobians(point_in_inside_reference_element, ansatz_basis_grads_, param); + // ... data functions, ... + const auto diffusion = local_diffusion_->evaluate(point_in_inside_reference_element, param); + // ... and finally compute the integrand. + const size_t rows = test_basis_inside.size(param); + const size_t cols = ansatz_basis_inside.size(param); + for (size_t ii = 0; ii < rows; ++ii) + for (size_t jj = 0; jj < cols; ++jj) { + result_in_in[ii][jj] += -1.0 * ((diffusion * ansatz_basis_grads_[jj][0]) * normal) * test_basis_values_[ii]; + result_in_in[ii][jj] += + -1.0 * symmetry_prefactor_ * ansatz_basis_values_[jj] * ((diffusion * test_basis_grads_[ii][0]) * normal); + } + } // ... evaluate(...) + +private: + const double symmetry_prefactor_; + XT::Functions::GridFunction<E, d, d> diffusion_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_diffusion_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_values_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_grads_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_values_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_grads_; +}; // DirichletCoupling + + +} // namespace LocalEllipticIPDGIntegrands + + /** * \brief Contains local integrands for the family of interior penalty discontinuous Galerkin (IPDG) * discretization schemes. @@ -32,7 +344,7 @@ namespace GDT { namespace LocalEllipticIpdgIntegrands { -enum class Method +enum class DXT_DEPRECATED_MSG("Use the LocalLaplaceIPDGIntegrands instead (10.08.2019)!") Method { ipdg, nipdg, @@ -132,6 +444,7 @@ namespace internal { /** * \note see Epshteyn, Riviere, 2007 */ +DXT_DEPRECATED_MSG("Use the LocalLaplaceIPDGIntegrands instead (10.08.2019)!") static inline double default_beta(const size_t d) { return 1.0 / (d - 1.0); @@ -141,6 +454,7 @@ static inline double default_beta(const size_t d) /** * \note see Epshteyn, Riviere, 2007 */ +DXT_DEPRECATED_MSG("Use the LocalLaplaceIPDGIntegrands instead (10.08.2019)!") static inline double inner_sigma(const size_t pol_order) { double sigma = 1.0; @@ -151,14 +465,14 @@ static inline double inner_sigma(const size_t pol_order) else if (pol_order <= 3) sigma *= 38.0; else { -#ifndef NDEBUG -# ifndef DUNE_GDT_DISABLE_WARNINGS +# ifndef NDEBUG +# ifndef DUNE_GDT_DISABLE_WARNINGS Dune::XT::Common::TimedLogger().get("gdt.local.integrands.elliptic-ipdg.inner").warn() << "a polynomial order of " << pol_order << " is untested!\n" << " #define DUNE_GDT_DISABLE_WARNINGS to statically disable this warning\n" << " or dynamically disable warnings of the TimedLogger() instance!" << std::endl; +# endif # endif -#endif sigma *= 50.0; } return sigma; @@ -168,6 +482,7 @@ static inline double inner_sigma(const size_t pol_order) /** * \note see Epshteyn, Riviere, 2007 */ +DXT_DEPRECATED_MSG("Use the LocalLaplaceIPDGIntegrands instead (10.08.2019)!") static inline double boundary_sigma(const size_t pol_order) { double sigma = 1.0; @@ -178,14 +493,14 @@ static inline double boundary_sigma(const size_t pol_order) else if (pol_order <= 3) sigma *= 74.0; else { -#ifndef NDEBUG -# ifndef DUNE_GDT_DISABLE_WARNINGS +# ifndef NDEBUG +# ifndef DUNE_GDT_DISABLE_WARNINGS Dune::XT::Common::TimedLogger().get("gdt.local.integrands.elliptic-ipdg.boundary").warn() << "a polynomial order of " << pol_order << " is untested!\n" << " #define DUNE_GDT_DISABLE_WARNINGS to statically disable this warning\n" << " or dynamically disable warnings of the TimedLogger() instance!" << std::endl; +# endif # endif -#endif sigma *= 100.0; } return sigma; @@ -199,7 +514,9 @@ static inline double boundary_sigma(const size_t pol_order) * \sa [Epshteyn, Riviere, 2007] for the meaning of beta */ template <class I, class F = double, Method method = default_method> -class Inner : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> +class DXT_DEPRECATED_MSG( + "Use LocalLaplaceIPDGIntegrands::InnerCoupling + LocalIPDGIntegrands::InnerPenalty} instead (10.08.2019)!") Inner + : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> { using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F>; using ThisType = Inner<I, F, method>; @@ -690,7 +1007,9 @@ private: * \sa [Epshteyn, Riviere, 2007] for the meaning of beta */ template <class I, class F = double, Method method = default_method> -class DirichletBoundaryLhs : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> +class DXT_DEPRECATED_MSG( + "Use LocalLaplaceIPDGIntegrands::DirichletCoupling + LocalIPDGIntegrands::boundaryPenalty instead (10.08.2019)!") + DirichletBoundaryLhs : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> { using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F>; using ThisType = DirichletBoundaryLhs<I, F, method>; @@ -882,7 +1201,7 @@ private: }; // DirichletBoundaryLhs -#if 0 +# if 0 template <class DirichletImp, class DiffusionFactorImp, class DiffusionTensorImp, Method method> class BoundaryRHS : public LocalFaceIntegrandInterface<internal::BoundaryRHSTraits<DirichletImp, DiffusionFactorImp, @@ -1124,13 +1443,14 @@ public: const EllipticType elliptic_; const double beta_; }; // class BoundaryRHS -#endif // 0 +# endif // 0 /** * \sa [Epshteyn, Riviere, 2007] for the meaning of beta */ template <class I, class F = double, Method method = default_method> -class InnerOnlyPenalty : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> +class DXT_DEPRECATED_MSG("Use LocalIPDGIntegrands::InnerPenalty instead (05.08.2019)!") InnerOnlyPenalty + : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> { using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F>; using ThisType = InnerOnlyPenalty<I, F, method>; @@ -1576,11 +1896,13 @@ private: mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_out_values_; }; // InnerOnlyPenalty + /** * \sa [Epshteyn, Riviere, 2007] for the meaning of beta */ template <class I, class F = double, Method method = default_method> -class DirichletBoundaryLhsOnlyPenalty : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> +class DXT_DEPRECATED_MSG("Use LocalIPDGIntegrands::BoundaryPenalty instead (05.08.2019)!") + DirichletBoundaryLhsOnlyPenalty : public LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F> { using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I, 1, 1, F, F, 1, 1, F>; using ThisType = DirichletBoundaryLhsOnlyPenalty<I, F, method>; @@ -1764,6 +2086,7 @@ private: mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_grads_; }; // DirichletBoundaryLhsOnlyPenalty + } // namespace LocalEllipticIpdgIntegrands } // namespace GDT } // namespace Dune diff --git a/dune/gdt/local/integrands/elliptic.hh b/dune/gdt/local/integrands/elliptic.hh index 7f383af70ad5fb4bd5f357c3f19c3a9dff4fc5e2..9cf927b796b667e923493e62abf13211986fc679 100644 --- a/dune/gdt/local/integrands/elliptic.hh +++ b/dune/gdt/local/integrands/elliptic.hh @@ -11,16 +11,19 @@ // René Milk (2017) // Tobias Leibner (2014, 2016 - 2018) +#warning This header is deprecated, use and include <dune/gdt/local/integrands/laplace.hh> instead! + #ifndef DUNE_GDT_LOCAL_INTEGRANDS_ELLIPTIC_HH -#define DUNE_GDT_LOCAL_INTEGRANDS_ELLIPTIC_HH +# define DUNE_GDT_LOCAL_INTEGRANDS_ELLIPTIC_HH -#include <dune/xt/common/memory.hh> -#include <dune/xt/la/container/eye-matrix.hh> -#include <dune/xt/functions/base/function-as-grid-function.hh> -#include <dune/xt/functions/constant.hh> -#include <dune/xt/functions/interfaces/grid-function.hh> +# include <dune/xt/common/deprecated.hh> +# include <dune/xt/common/memory.hh> +# include <dune/xt/la/container/eye-matrix.hh> +# include <dune/xt/functions/base/function-as-grid-function.hh> +# include <dune/xt/functions/constant.hh> +# include <dune/xt/functions/interfaces/grid-function.hh> -#include "interfaces.hh" +# include "interfaces.hh" namespace Dune { namespace GDT { @@ -31,7 +34,8 @@ namespace GDT { * `lambda(x) * {[kappa(x) \nabla phi(x)] * \nabla psi(x)}` for all combinations of phi and psi in the bases. */ template <class E, size_t r = 1, class F = double> -class LocalEllipticIntegrand : public LocalBinaryElementIntegrandInterface<E, r, 1, F, F, r, 1, F> +class DXT_DEPRECATED_MSG("Use LocalLaplaceIntegrand instead (10.08.2019)!") LocalEllipticIntegrand + : public LocalBinaryElementIntegrandInterface<E, r, 1, F, F, r, 1, F> { using BaseType = LocalBinaryElementIntegrandInterface<E, r, 1, F, F, r, 1, F>; using ThisType = LocalEllipticIntegrand; diff --git a/dune/gdt/local/integrands/interfaces.hh b/dune/gdt/local/integrands/interfaces.hh index cb6b15f872390708db877ec0a1b72514fd57ca11..96798d086941ed4f1156bb1c9a870df823618cf3 100644 --- a/dune/gdt/local/integrands/interfaces.hh +++ b/dune/gdt/local/integrands/interfaces.hh @@ -26,6 +26,20 @@ namespace Dune { namespace GDT { +// forwards (required for operator+, include are below) +template <class E, size_t r, size_t rC, class R, class F> +class LocalUnaryElementIntegrandSum; + +template <class E, size_t t_r, size_t t_RC, class TF, class F, size_t a_r, size_t a_rC, class AF> +class LocalBinaryElementIntegrandSum; + +template <class I, size_t r, size_t rC, class R, class F> +class LocalBinaryIntersectionIntegrandSum; + +template <class I, size_t t_r, size_t t_rC, class TF, class F, size_t a_r, size_t a_rC, class AF> +class LocalQuaternaryIntersectionIntegrandSum; + + /** * Interface for integrands in integrals over grid elements, which depend on one argument only (usually the test basis * in an integral-based functional). @@ -334,6 +348,11 @@ public: virtual std::unique_ptr<ThisType> copy() const = 0; + LocalQuaternaryIntersectionIntegrandSum<I, t_r, t_rC, TR, F, a_r, a_rC, AR> operator+(const ThisType& other) const + { + return LocalQuaternaryIntersectionIntegrandSum<I, t_r, t_rC, TR, F, a_r, a_rC, AR>(*this, other); + } + /** * Returns the polynomial order of the integrand, given the bases. * @@ -390,12 +409,37 @@ public: return {result_in_in, result_in_out, result_out_in, result_out_out}; } // ... apply(...) -private: - std::unique_ptr<IntersectionType> intersection_; +protected: + void ensure_size_and_clear_results(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param) const + { + const size_t rows_in = test_basis_inside.size(param); + const size_t rows_out = test_basis_outside.size(param); + const size_t cols_in = ansatz_basis_inside.size(param); + const size_t cols_out = ansatz_basis_outside.size(param); + const auto ensure_size_and_clear = [](auto& m, const auto& r, const auto& c) { + if (m.rows() < r || m.cols() < c) + m.resize(r, c); + m *= 0; + }; + ensure_size_and_clear(result_in_in, rows_in, cols_in); + ensure_size_and_clear(result_in_out, rows_in, cols_out); + ensure_size_and_clear(result_out_in, rows_out, cols_in); + ensure_size_and_clear(result_out_out, rows_out, cols_out); + } // ... ensure_size_and_clear_results(...) }; // class LocalQuaternaryIntersectionIntegrandInterface } // namespace GDT } // namespace Dune +#include "combined.hh" + #endif // DUNE_GDT_LOCAL_INTEGRANDS_INTERFACES_HH diff --git a/dune/gdt/local/integrands/ipdg.hh b/dune/gdt/local/integrands/ipdg.hh new file mode 100644 index 0000000000000000000000000000000000000000..c65453f9b70e99b00981975c2643f87d53f1c466 --- /dev/null +++ b/dune/gdt/local/integrands/ipdg.hh @@ -0,0 +1,307 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_LOCAL_INTEGRANDS_IPDG_HH +#define DUNE_GDT_LOCAL_INTEGRANDS_IPDG_HH + +#include <functional> + +#include <dune/xt/common/memory.hh> +#include <dune/xt/functions/grid-function.hh> +#include <dune/xt/grid/entity.hh> +#include <dune/xt/grid/intersection.hh> + +#include "interfaces.hh" + +namespace Dune { +namespace GDT { +namespace LocalIPDGIntegrands { +namespace internal { + + +template <class Intersection> +static std::function<double(const Intersection&)> default_inner_intersection_diameter() +{ + return [](const Intersection& intersection) { + if (Intersection::dimension == 1) { + if (intersection.neighbor()) + return 0.5 * (XT::Grid::diameter(intersection.inside()) + XT::Grid::diameter(intersection.outside())); + else + return XT::Grid::diameter(intersection.inside()); + } else + return XT::Grid::diameter(intersection); + }; +} // ... default_inner_intersection_diameter(...) + + +template <class Intersection> +static std::function<double(const Intersection&)> default_boundary_intersection_diameter() +{ + return [](const Intersection& intersection) { + if (Intersection::dimension == 1) + return XT::Grid::diameter(intersection.inside()); + else + return XT::Grid::diameter(intersection); + }; +} // ... default_boundary_intersection_diameter(...) + + +} // namespace internal + + +template <class I> +class InnerPenalty : public LocalQuaternaryIntersectionIntegrandInterface<I> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I>; + using ThisType = InnerPenalty<I>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::F; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + InnerPenalty( + const double& penalty, + XT::Functions::GridFunction<E, d, d> weight_function = 1., + const std::function<double(const I&)>& intersection_diameter = internal::default_inner_intersection_diameter<I>()) + : BaseType(weight_function.parameter_type()) + , penalty_(penalty) + , weight_(weight_function) + , intersection_diameter_(intersection_diameter) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + InnerPenalty(const ThisType& other) + : BaseType(other.parameter_type()) + , penalty_(other.penalty_) + , weight_(other.weight_) + , intersection_diameter_(other.intersection_diameter_) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + InnerPenalty(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intrsctn) override final + { + DUNE_THROW_IF( + !intrsctn.neighbor(), Exceptions::integrand_error, "This integrand cannot be used on a boundary intersection!"); + local_weight_in_->bind(intrsctn.inside()); + local_weight_out_->bind(intrsctn.outside()); + } + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const XT::Common::Parameter& param = {}) const override final + { + return std::max(local_weight_in_->order(param), local_weight_out_->order(param)) + + std::max(test_basis_inside.order(param), test_basis_outside.order(param)) + + std::max(ansatz_basis_inside.order(param), ansatz_basis_outside.order(param)); + } + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Prepare sotrage, ... + this->ensure_size_and_clear_results(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // evaluate ... + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + const auto point_in_outside_reference_element = + this->intersection().geometryInOutside().global(point_in_reference_intersection); + const auto normal = this->intersection().unitOuterNormal(point_in_reference_intersection); + // ... basis functions + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_in_values_, param); + test_basis_outside.evaluate(point_in_outside_reference_element, test_basis_out_values_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_in_values_, param); + ansatz_basis_outside.evaluate(point_in_outside_reference_element, ansatz_basis_out_values_, param); + // ... and data functions, ... + const auto weight_in = local_weight_in_->evaluate(point_in_inside_reference_element, param); + const auto weight_out = local_weight_out_->evaluate(point_in_outside_reference_element, param); + // compute the weighted penalty ... + const double delta_plus = normal * (weight_out * normal); + const double delta_minus = normal * (weight_in * normal); + const auto weight = (delta_plus * delta_minus) / (delta_plus + delta_minus); // half harmonic average + const auto h = intersection_diameter_(this->intersection()); + const auto penalty = (penalty_ * weight) / h; + // and finally compute the integrand. + const size_t rows_in = test_basis_inside.size(param); + const size_t rows_out = test_basis_outside.size(param); + const size_t cols_in = ansatz_basis_inside.size(param); + const size_t cols_out = ansatz_basis_outside.size(param); + for (size_t ii = 0; ii < rows_in; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) + result_in_in[ii][jj] += penalty * ansatz_basis_in_values_[jj] * test_basis_in_values_[ii]; + for (size_t jj = 0; jj < cols_out; ++jj) + result_in_out[ii][jj] += -1.0 * penalty * ansatz_basis_out_values_[jj] * test_basis_in_values_[ii]; + } + for (size_t ii = 0; ii < rows_out; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) + result_out_in[ii][jj] += -1.0 * penalty * ansatz_basis_in_values_[jj] * test_basis_out_values_[ii]; + for (size_t jj = 0; jj < cols_out; ++jj) + result_out_out[ii][jj] += penalty * ansatz_basis_out_values_[jj] * test_basis_out_values_[ii]; + } + } // ... evaluate(...) + +private: + const double penalty_; + XT::Functions::GridFunction<E, d, d> weight_; + const std::function<double(const I&)> intersection_diameter_; + std::unique_ptr<typename XT::Functions::GridFunction<E, d, d>::LocalFunctionType> local_weight_in_; + std::unique_ptr<typename XT::Functions::GridFunction<E, d, d>::LocalFunctionType> local_weight_out_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_in_values_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_out_values_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_in_values_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_out_values_; +}; // InnerPenalty + + +template <class I> +class BoundaryPenalty : public LocalQuaternaryIntersectionIntegrandInterface<I> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I>; + using ThisType = BoundaryPenalty<I>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::F; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + BoundaryPenalty(const double& penalty, + XT::Functions::GridFunction<E, d, d> weight_function = 1., + const std::function<double(const I&)>& intersection_diameter = + internal::default_boundary_intersection_diameter<I>()) + : BaseType() + , penalty_(penalty) + , weight_(weight_function) + , intersection_diameter_(intersection_diameter) + , local_weight_(weight_.local_function()) + {} + + BoundaryPenalty(const ThisType& other) + : BaseType(other.parameter_type()) + , penalty_(other.penalty_) + , weight_(other.weight_) + , intersection_diameter_(other.intersection_diameter_) + , local_weight_(weight_.local_function()) + {} + + BoundaryPenalty(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intersection) override final + { + local_weight_->bind(intersection.inside()); + } + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& /*test_basis_outside*/, + const LocalAnsatzBasisType& /*ansatz_basis_outside*/, + const XT::Common::Parameter& param = {}) const override final + { + return local_weight_->order(param) + test_basis_inside.order(param) + ansatz_basis_inside.order(param); + } + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Prepare sotrage, ... + this->ensure_size_and_clear_results(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // evaluate ... + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + const auto normal = this->intersection().unitOuterNormal(point_in_reference_intersection); + // ... basis functions ... + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_values_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_values_, param); + // ... and data functions, .... + const auto weight = local_weight_->evaluate(point_in_inside_reference_element, param); + // compute the weighted penalty ... + const auto h = intersection_diameter_(this->intersection()); + const auto penalty = (penalty_ * (normal * (weight * normal))) / h; + // and finally compute integrand. + const size_t rows = test_basis_inside.size(param); + const size_t cols = ansatz_basis_inside.size(param); + for (size_t ii = 0; ii < rows; ++ii) + for (size_t jj = 0; jj < cols; ++jj) + result_in_in[ii][jj] += penalty * ansatz_basis_values_[jj] * test_basis_values_[ii]; + } // ... evaluate(...) + +private: + const double penalty_; + XT::Functions::GridFunction<E, d, d> weight_; + const std::function<double(const I&)> intersection_diameter_; + std::unique_ptr<typename XT::Functions::GridFunction<E, d, d>::LocalFunctionType> local_weight_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_values_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_values_; +}; // BoundaryPenalty + + +} // namespace LocalIPDGIntegrands +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_LOCAL_INTEGRANDS_IPDG_HH diff --git a/dune/gdt/local/integrands/laplace-ipdg.hh b/dune/gdt/local/integrands/laplace-ipdg.hh new file mode 100644 index 0000000000000000000000000000000000000000..23e2585111ee40b2e46a794cc56c329983886e46 --- /dev/null +++ b/dune/gdt/local/integrands/laplace-ipdg.hh @@ -0,0 +1,324 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_LOCAL_INTEGRANDS_LAPLACE_IPDG_HH +#define DUNE_GDT_LOCAL_INTEGRANDS_LAPLACE_IPDG_HH + +#include <dune/xt/functions/grid-function.hh> + +#include "interfaces.hh" +#include "ipdg.hh" + +namespace Dune { +namespace GDT { +namespace LocalLaplaceIPDGIntegrands { + + +/** + * \note The role of symmetry_prefactor: + * * -1 => NIPDG + * * 0 => IIPDG + * * 1 => SIPDG + * \note The role of the weight: + * * symmetry_prefactor = 1 && weight_function = 1 => SIPDG + * * symmetry_prefactor = 1 && weight_function = diffusion => SWIPDG + */ +template <class I> +class InnerCoupling : public LocalQuaternaryIntersectionIntegrandInterface<I> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I>; + using ThisType = InnerCoupling<I>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::F; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + InnerCoupling(const double& symmetry_prefactor, + XT::Functions::GridFunction<E, d, d> diffusion, + XT::Functions::GridFunction<E, d, d> weight_function = {1.}) + : BaseType(diffusion.parameter_type() + weight_function.parameter_type()) + , symmetry_prefactor_(symmetry_prefactor) + , diffusion_(diffusion) + , weight_(weight_function) + , local_diffusion_in_(diffusion_.local_function()) + , local_diffusion_out_(diffusion_.local_function()) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + InnerCoupling(const ThisType& other) + : BaseType(other.parameter_type()) + , symmetry_prefactor_(other.symmetry_prefactor_) + , diffusion_(other.diffusion_) + , weight_(other.weight_) + , local_diffusion_in_(diffusion_.local_function()) + , local_diffusion_out_(diffusion_.local_function()) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + InnerCoupling(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intrsctn) override final + { + DUNE_THROW_IF( + !intrsctn.neighbor(), Exceptions::integrand_error, "This integrand cannot be used on a boundary intersection!"); + const auto inside_element = intrsctn.inside(); + const auto outside_element = intrsctn.outside(); + local_diffusion_in_->bind(inside_element); + local_weight_in_->bind(inside_element); + local_diffusion_out_->bind(outside_element); + local_weight_out_->bind(outside_element); + } // ... post_bind(...) + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const XT::Common::Parameter& param = {}) const override final + { + return std::max(local_diffusion_in_->order(param), local_diffusion_out_->order(param)) + + std::max(local_weight_in_->order(), local_weight_out_->order(param)) + + std::max(test_basis_inside.order(param), test_basis_outside.order(param)) + + std::max(ansatz_basis_inside.order(param), ansatz_basis_outside.order(param)); + } + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Prepare sotrage, ... + this->ensure_size_and_clear_results(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // evaluate ... + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + const auto point_in_outside_reference_element = + this->intersection().geometryInOutside().global(point_in_reference_intersection); + const auto normal = this->intersection().unitOuterNormal(point_in_reference_intersection); + // ... basis functions and ... + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_in_values_, param); + test_basis_inside.jacobians(point_in_inside_reference_element, test_basis_in_grads_, param); + test_basis_outside.evaluate(point_in_outside_reference_element, test_basis_out_values_, param); + test_basis_outside.jacobians(point_in_outside_reference_element, test_basis_out_grads_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_in_values_, param); + ansatz_basis_inside.jacobians(point_in_inside_reference_element, ansatz_basis_in_grads_, param); + ansatz_basis_outside.evaluate(point_in_outside_reference_element, ansatz_basis_out_values_, param); + ansatz_basis_outside.jacobians(point_in_outside_reference_element, ansatz_basis_out_grads_, param); + // ... data functions, ... + const auto diffusion_in = local_diffusion_in_->evaluate(point_in_inside_reference_element, param); + const auto diffusion_out = local_diffusion_out_->evaluate(point_in_outside_reference_element, param); + const auto weight_in = local_weight_in_->evaluate(point_in_inside_reference_element, param); + const auto weight_out = local_weight_out_->evaluate(point_in_outside_reference_element, param); + // compute the weighted mean ... + const auto delta_plus = normal * (weight_out * normal); + const auto delta_minus = normal * (weight_in * normal); + const auto weight_minus = delta_plus / (delta_plus + delta_minus); + const auto weight_plus = delta_minus / (delta_plus + delta_minus); + // ... and finally compute the integrand. + const size_t rows_in = test_basis_inside.size(param); + const size_t rows_out = test_basis_outside.size(param); + const size_t cols_in = ansatz_basis_inside.size(param); + const size_t cols_out = ansatz_basis_outside.size(param); + for (size_t ii = 0; ii < rows_in; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) { + result_in_in[ii][jj] += + -1.0 * weight_minus * ((diffusion_in * ansatz_basis_in_grads_[jj][0]) * normal) * test_basis_in_values_[ii]; + result_in_in[ii][jj] += -1.0 * symmetry_prefactor_ * weight_minus * ansatz_basis_in_values_[jj] + * ((diffusion_in * test_basis_in_grads_[ii][0]) * normal); + } + for (size_t jj = 0; jj < cols_out; ++jj) { + result_in_out[ii][jj] += -1.0 * weight_plus * ((diffusion_out * ansatz_basis_out_grads_[jj][0]) * normal) + * test_basis_in_values_[ii]; + result_in_out[ii][jj] += symmetry_prefactor_ * weight_minus * ansatz_basis_out_values_[jj] + * ((diffusion_in * test_basis_in_grads_[ii][0]) * normal); + } + } + for (size_t ii = 0; ii < rows_out; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) { + result_out_in[ii][jj] += + weight_minus * ((diffusion_in * ansatz_basis_in_grads_[jj][0]) * normal) * test_basis_out_values_[ii]; + result_out_in[ii][jj] += -1.0 * symmetry_prefactor_ * weight_plus * ansatz_basis_in_values_[jj] + * ((diffusion_out * test_basis_out_grads_[ii][0]) * normal); + } + for (size_t jj = 0; jj < cols_out; ++jj) { + result_out_out[ii][jj] += + weight_plus * ((diffusion_out * ansatz_basis_out_grads_[jj][0]) * normal) * test_basis_out_values_[ii]; + result_out_out[ii][jj] += symmetry_prefactor_ * weight_plus * ansatz_basis_out_values_[jj] + * ((diffusion_out * test_basis_out_grads_[ii][0]) * normal); + } + } + } // ... evaluate(...) + +private: + const double symmetry_prefactor_; + XT::Functions::GridFunction<E, d, d> diffusion_; + XT::Functions::GridFunction<E, d, d> weight_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_diffusion_in_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_diffusion_out_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_weight_in_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_weight_out_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_in_values_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_in_grads_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_out_values_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_out_grads_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_in_values_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_in_grads_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_out_values_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_out_grads_; +}; // InnerCoupling + + +/** + * \note The role of symmetry_prefactor: + * * -1 => NIPDG + * * 0 => IIPDG + * * 1 => SIPDG + * \note The role of the weight: + * * symmetry_prefactor = 1 && weight_function = 1 => SIPDG + * * symmetry_prefactor = 1 && weight_function = diffusion => SWIPDG + */ +template <class I> +class DirichletCoupling : public LocalQuaternaryIntersectionIntegrandInterface<I> +{ + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I>; + using ThisType = DirichletCoupling<I>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::F; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + DirichletCoupling(const double& symmetry_prefactor, XT::Functions::GridFunction<E, d, d> diffusion) + : BaseType(diffusion.parameter_type()) + , symmetry_prefactor_(symmetry_prefactor) + , diffusion_(diffusion) + , local_diffusion_(diffusion_.local_function()) + {} + + DirichletCoupling(const ThisType& other) + : BaseType(other.parameter_type()) + , symmetry_prefactor_(other.symmetry_prefactor_) + , diffusion_(other.diffusion_) + , local_diffusion_(diffusion_.local_function()) + {} + + DirichletCoupling(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intersection) override final + { + const auto inside_element = intersection.inside(); + local_diffusion_->bind(inside_element); + } + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& /*test_basis_outside*/, + const LocalAnsatzBasisType& /*ansatz_basis_outside*/, + const XT::Common::Parameter& param = {}) const override final + { + return local_diffusion_->order(param) + test_basis_inside.order(param) + ansatz_basis_inside.order(param); + } + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // Prepare sotrage, ... + this->ensure_size_and_clear_results(test_basis_inside, + ansatz_basis_inside, + test_basis_outside, + ansatz_basis_outside, + result_in_in, + result_in_out, + result_out_in, + result_out_out, + param); + // evaluate ... + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + const auto normal = this->intersection().unitOuterNormal(point_in_reference_intersection); + // ... basis functions and ... + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_values_, param); + test_basis_inside.jacobians(point_in_inside_reference_element, test_basis_grads_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_values_, param); + ansatz_basis_inside.jacobians(point_in_inside_reference_element, ansatz_basis_grads_, param); + // ... data functions, ... + const auto diffusion = local_diffusion_->evaluate(point_in_inside_reference_element, param); + // ... and finally compute the integrand. + const size_t rows = test_basis_inside.size(param); + const size_t cols = ansatz_basis_inside.size(param); + for (size_t ii = 0; ii < rows; ++ii) + for (size_t jj = 0; jj < cols; ++jj) { + result_in_in[ii][jj] += -1.0 * ((diffusion * ansatz_basis_grads_[jj][0]) * normal) * test_basis_values_[ii]; + result_in_in[ii][jj] += + -1.0 * symmetry_prefactor_ * ansatz_basis_values_[jj] * ((diffusion * test_basis_grads_[ii][0]) * normal); + } + } // ... evaluate(...) + +private: + const double symmetry_prefactor_; + XT::Functions::GridFunction<E, d, d> diffusion_; + std::unique_ptr<typename XT::Functions::GridFunctionInterface<E, d, d>::LocalFunctionType> local_diffusion_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_values_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_grads_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_values_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_grads_; +}; // DirichletCoupling + + +} // namespace LocalLaplaceIPDGIntegrands +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_LOCAL_INTEGRANDS_LAPLACE_IPDG_HH diff --git a/dune/gdt/local/integrands/laplace.hh b/dune/gdt/local/integrands/laplace.hh new file mode 100644 index 0000000000000000000000000000000000000000..95b480b0c8c3bba28f79f6e02d87691d7b7af125 --- /dev/null +++ b/dune/gdt/local/integrands/laplace.hh @@ -0,0 +1,109 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_LOCAL_INTEGRANDS_LAPLACE_HH +#define DUNE_GDT_LOCAL_INTEGRANDS_LAPLACE_HH + +#include <dune/xt/common/memory.hh> +#include <dune/xt/la/container/eye-matrix.hh> +#include <dune/xt/functions/grid-function.hh> + +#include "interfaces.hh" + +namespace Dune { +namespace GDT { + + +/** + * Given a weight function kappa, computes `{[kappa(x) \nabla phi(x)] * \nabla psi(x)}` for all combinations of phi and + * psi in the bases. + */ +template <class E, size_t r = 1, class F = double> +class LocalLaplaceIntegrand : public LocalBinaryElementIntegrandInterface<E, r, 1, F, F, r, 1, F> +{ + using BaseType = LocalBinaryElementIntegrandInterface<E, r, 1, F, F, r, 1, F>; + using ThisType = LocalLaplaceIntegrand; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::ElementType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + explicit LocalLaplaceIntegrand( + XT::Functions::GridFunction<E, d, d, F> diffusion = XT::LA::eye_matrix<FieldMatrix<F, d, d>>(d, d)) + : BaseType() + , weight_(diffusion) + , local_weight_(weight_.local_function()) + {} + + LocalLaplaceIntegrand(const ThisType& other) + : BaseType(other.parameter_type()) + , weight_(other.weight_) + , local_weight_(weight_.local_function()) + {} + + LocalLaplaceIntegrand(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const ElementType& ele) override + { + local_weight_->bind(ele); + } + +public: + int order(const LocalTestBasisType& test_basis, + const LocalAnsatzBasisType& ansatz_basis, + const XT::Common::Parameter& param = {}) const override final + { + return local_weight_->order(param) + std::max(test_basis.order(param) - 1, 0) + + std::max(ansatz_basis.order(param) - 1, 0); + } + + void evaluate(const LocalTestBasisType& test_basis, + const LocalAnsatzBasisType& ansatz_basis, + const DomainType& point_in_reference_element, + DynamicMatrix<F>& result, + const XT::Common::Parameter& param = {}) const override final + { + // prepare storage + const size_t rows = test_basis.size(param); + const size_t cols = ansatz_basis.size(param); + if (result.rows() < rows || result.cols() < cols) + result.resize(rows, cols); + result *= 0; + // evaluate + test_basis.jacobians(point_in_reference_element, test_basis_grads_, param); + ansatz_basis.jacobians(point_in_reference_element, ansatz_basis_grads_, param); + const auto weight = local_weight_->evaluate(point_in_reference_element, param); + // compute elliptic evaluation + for (size_t ii = 0; ii < rows; ++ii) + for (size_t jj = 0; jj < cols; ++jj) + for (size_t rr = 0; rr < r; ++rr) + result[ii][jj] += (weight * ansatz_basis_grads_[jj][rr]) * test_basis_grads_[ii][rr]; + } // ... evaluate(...) + +private: + XT::Functions::GridFunction<E, d, d, F> weight_; + std::unique_ptr<typename XT::Functions::GridFunction<E, d, d, F>::LocalFunctionType> local_weight_; + mutable std::vector<typename LocalTestBasisType::DerivativeRangeType> test_basis_grads_; + mutable std::vector<typename LocalAnsatzBasisType::DerivativeRangeType> ansatz_basis_grads_; +}; // class LocalLaplaceIntegrand + + +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_LOCAL_INTEGRANDS_LAPLACE_HH diff --git a/dune/gdt/local/integrands/product.hh b/dune/gdt/local/integrands/product.hh index 8cb7c10970432005fcd9b45dc903b78996efd1d6..4aa83ab9645a63d4ce563249c783327580f46cfd 100644 --- a/dune/gdt/local/integrands/product.hh +++ b/dune/gdt/local/integrands/product.hh @@ -18,7 +18,7 @@ #include <dune/xt/functions/constant.hh> #include <dune/xt/functions/base/combined-functions.hh> #include <dune/xt/functions/base/combined-grid-functions.hh> -#include <dune/xt/functions/base/function-as-grid-function.hh> +#include <dune/xt/functions/grid-function.hh> #include <dune/xt/functions/interfaces/grid-function.hh> #include "interfaces.hh" @@ -47,60 +47,16 @@ public: using typename BaseType::LocalAnsatzBasisType; using typename BaseType::LocalTestBasisType; - using GridFunctionType = XT::Functions::GridFunctionInterface<E, r, r, F>; - - LocalElementProductIntegrand(const F& inducing_value = F(1)) - : BaseType() - , inducing_function_(new XT::Functions::FunctionAsGridFunctionWrapper<E, r, r, F>( - new XT::Functions::ProductFunction<XT::Functions::ConstantFunction<d, 1, 1, F>, - XT::Functions::ConstantFunction<d, r, r, F>>( - new XT::Functions::ConstantFunction<d, 1, 1, F>(inducing_value), - new XT::Functions::ConstantFunction<d, r, r, F>(XT::LA::eye_matrix<FieldMatrix<F, r, r>>(r))))) - , local_function_(inducing_function_.access().local_function()) - , test_basis_values_() - , ansatz_basis_values_() - {} - - LocalElementProductIntegrand(const XT::Functions::FunctionInterface<d, 1, 1, F>& inducing_function) - : BaseType() - , inducing_function_(new XT::Functions::FunctionAsGridFunctionWrapper<E, r, r, F>( - new XT::Functions::ProductFunction<XT::Functions::FunctionInterface<d, 1, 1, F>, - XT::Functions::ConstantFunction<d, r, r, F>>( - inducing_function, - new XT::Functions::ConstantFunction<d, r, r, F>(XT::LA::eye_matrix<FieldMatrix<F, r, r>>(r))))) - , local_function_(inducing_function_.access().local_function()) - , test_basis_values_() - , ansatz_basis_values_() - {} - - LocalElementProductIntegrand(const XT::Functions::GridFunctionInterface<E, 1, 1, F>& inducing_function) - : BaseType() - , inducing_function_(new XT::Functions::FunctionAsGridFunctionWrapper<E, r, r, F>( - new XT::Functions::ProductGridFunction<XT::Functions::GridFunctionInterface<E, 1, 1, F>, - XT::Functions::GridFunctionInterface<E, r, r, F>>( - inducing_function, - new XT::Functions::FunctionAsGridFunctionWrapper<E, r, r, F>( - new XT::Functions::ConstantFunction<d, r, r, F>(XT::LA::eye_matrix<FieldMatrix<F, r, r>>(r)))))) - , local_function_(inducing_function_.access().local_function()) - , test_basis_values_() - , ansatz_basis_values_() - {} - - template <class E_, typename = std::enable_if_t<std::is_same<E_, E>::value && r != 1, void>> - LocalElementProductIntegrand(const XT::Functions::GridFunctionInterface<E_, r, r, F>& inducing_function) + LocalElementProductIntegrand(XT::Functions::GridFunction<E, r, r, F> weight = {1.}) : BaseType() - , inducing_function_(inducing_function) - , local_function_(inducing_function_.access().local_function()) - , test_basis_values_() - , ansatz_basis_values_() + , weight_(weight) + , local_weight_(weight_.local_function()) {} LocalElementProductIntegrand(const ThisType& other) : BaseType(other.parameter_type()) - , inducing_function_(other.inducing_function_) - , local_function_(inducing_function_.access().local_function()) - , test_basis_values_() - , ansatz_basis_values_() + , weight_(other.weight_) + , local_weight_(weight_.local_function()) {} LocalElementProductIntegrand(ThisType&& source) = default; @@ -113,7 +69,7 @@ public: protected: void post_bind(const ElementType& ele) override final { - local_function_->bind(ele); + local_weight_->bind(ele); } public: @@ -121,7 +77,7 @@ public: const LocalAnsatzBasisType& ansatz_basis, const XT::Common::Parameter& param = {}) const override final { - return local_function_->order(param) + test_basis.order(param) + ansatz_basis.order(param); + return local_weight_->order(param) + test_basis.order(param) + ansatz_basis.order(param); } using BaseType::evaluate; @@ -140,23 +96,150 @@ public: // evaluate test_basis.evaluate(point_in_reference_element, test_basis_values_, param); ansatz_basis.evaluate(point_in_reference_element, ansatz_basis_values_, param); - const auto function_value = local_function_->evaluate(point_in_reference_element, param); + const auto weight = local_weight_->evaluate(point_in_reference_element, param); // compute product for (size_t ii = 0; ii < rows; ++ii) for (size_t jj = 0; jj < cols; ++jj) - result[ii][jj] = (function_value * test_basis_values_[ii]) * ansatz_basis_values_[jj]; + result[ii][jj] = (weight * test_basis_values_[ii]) * ansatz_basis_values_[jj]; } // ... evaluate(...) private: - const XT::Common::ConstStorageProvider<GridFunctionType> inducing_function_; - std::unique_ptr<typename GridFunctionType::LocalFunctionType> local_function_; + XT::Functions::GridFunction<E, r, r, F> weight_; + std::unique_ptr<typename XT::Functions::GridFunction<E, r, r, F>::LocalFunctionType> local_weight_; mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_values_; mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_values_; }; // class LocalElementProductIntegrand -/// \todo add LocalIntersectionProductIntegrand -/// +/** + * Given an inducing function f, computes `<f> * phi * psi` for all combinations of phi and psi in the bases, where + * `<f>` denotes the average of f evaluated on the inside and evaluated on the outside. + * + * \note Note that f can also be given as a scalar value or omitted. + */ +template <class I, size_t r = 1, class TR = double, class F = double, class AR = TR> +class LocalIntersectionProductIntegrand : public LocalQuaternaryIntersectionIntegrandInterface<I, r, 1, TR, F, r, 1, AR> +{ + using ThisType = LocalIntersectionProductIntegrand<I, r, TR, F, AR>; + using BaseType = LocalQuaternaryIntersectionIntegrandInterface<I, r, 1, TR, F, r, 1, AR>; + +public: + using BaseType::d; + using typename BaseType::DomainType; + using typename BaseType::E; + using typename BaseType::IntersectionType; + using typename BaseType::LocalAnsatzBasisType; + using typename BaseType::LocalTestBasisType; + + using GridFunctionType = XT::Functions::GridFunctionInterface<E, r, r, F>; + + LocalIntersectionProductIntegrand(XT::Functions::GridFunction<E, r, r, F> weight = {1.}) + : BaseType() + , weight_(weight) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + LocalIntersectionProductIntegrand(const ThisType& other) + : BaseType(other.parameter_type()) + , weight_(other.weight_) + , local_weight_in_(weight_.local_function()) + , local_weight_out_(weight_.local_function()) + {} + + LocalIntersectionProductIntegrand(ThisType&& source) = default; + + std::unique_ptr<BaseType> copy() const override final + { + return std::make_unique<ThisType>(*this); + } + +protected: + void post_bind(const IntersectionType& intersct) override final + { + auto inside_element = intersct.inside(); + local_weight_in_->bind(inside_element); + if (intersct.neighbor()) { + local_weight_out_->bind(intersct.outside()); + } else + local_weight_out_->bind(intersct.inside()); + } // ... post_bind(...) + +public: + int order(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const XT::Common::Parameter& param = {}) const override final + { + return std::max(local_weight_in_->order(param), local_weight_out_->order(param)) + + std::max(test_basis_inside.order(param), test_basis_outside.order(param)) + + std::max(ansatz_basis_inside.order(param), ansatz_basis_outside.order(param)); + } + + using BaseType::evaluate; + + void evaluate(const LocalTestBasisType& test_basis_inside, + const LocalAnsatzBasisType& ansatz_basis_inside, + const LocalTestBasisType& test_basis_outside, + const LocalAnsatzBasisType& ansatz_basis_outside, + const DomainType& point_in_reference_intersection, + DynamicMatrix<F>& result_in_in, + DynamicMatrix<F>& result_in_out, + DynamicMatrix<F>& result_out_in, + DynamicMatrix<F>& result_out_out, + const XT::Common::Parameter& param = {}) const override final + { + // prepare sotrage + const size_t rows_in = test_basis_inside.size(param); + const size_t rows_out = test_basis_outside.size(param); + const size_t cols_in = ansatz_basis_inside.size(param); + const size_t cols_out = ansatz_basis_outside.size(param); + const auto ensure_size = [](auto& m, const auto& rws, const auto& cls) { + if (m.rows() < rws || m.cols() < cls) + m.resize(rws, cls); + }; + ensure_size(result_in_in, rows_in, cols_in); + ensure_size(result_in_out, rows_in, cols_out); + ensure_size(result_out_in, rows_out, cols_in); + ensure_size(result_out_out, rows_out, cols_out); + // evaluate + const auto point_in_inside_reference_element = + this->intersection().geometryInInside().global(point_in_reference_intersection); + test_basis_inside.evaluate(point_in_inside_reference_element, test_basis_in_values_, param); + ansatz_basis_inside.evaluate(point_in_inside_reference_element, ansatz_basis_in_values_, param); + const auto weight_in = local_weight_in_->evaluate(point_in_inside_reference_element, param); + const auto point_in_outside_reference_element = + this->intersection().geometryInOutside().global(point_in_reference_intersection); + test_basis_outside.evaluate(point_in_outside_reference_element, test_basis_out_values_, param); + ansatz_basis_outside.evaluate(point_in_outside_reference_element, ansatz_basis_out_values_, param); + const auto weight_out = local_weight_out_->evaluate(point_in_outside_reference_element, param); + // compute integrand + const auto average_function_value = (weight_in + weight_out) * 0.5; + for (size_t ii = 0; ii < rows_in; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) + result_in_in[ii][jj] = (average_function_value * ansatz_basis_in_values_[jj]) * test_basis_in_values_[ii]; + for (size_t jj = 0; jj < cols_out; ++jj) + result_in_out[ii][jj] = (average_function_value * ansatz_basis_out_values_[jj]) * test_basis_in_values_[ii]; + } + for (size_t ii = 0; ii < rows_out; ++ii) { + for (size_t jj = 0; jj < cols_in; ++jj) + result_out_in[ii][jj] = (average_function_value * ansatz_basis_in_values_[jj]) * test_basis_out_values_[ii]; + for (size_t jj = 0; jj < cols_out; ++jj) + result_out_out[ii][jj] = (average_function_value * ansatz_basis_out_values_[jj]) * test_basis_out_values_[ii]; + } + } // ... evaluate(...) + +private: + XT::Functions::GridFunction<E, r, r, F> weight_; + std::unique_ptr<typename XT::Functions::GridFunction<E, r, r, F>::LocalFunctionType> local_weight_in_; + std::unique_ptr<typename XT::Functions::GridFunction<E, r, r, F>::LocalFunctionType> local_weight_out_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_in_values_; + mutable std::vector<typename LocalTestBasisType::RangeType> test_basis_out_values_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_in_values_; + mutable std::vector<typename LocalAnsatzBasisType::RangeType> ansatz_basis_out_values_; +}; // class LocalIntersectionProductIntegrand + } // namespace GDT } // namespace Dune diff --git a/dune/gdt/local/numerical-fluxes/engquist-osher.hh b/dune/gdt/local/numerical-fluxes/engquist-osher.hh index 29f5f18b0d11bb09fcf37e14fe78811d8be85df4..c308728f9db67f1a91b97daf29a50094b8226eba 100644 --- a/dune/gdt/local/numerical-fluxes/engquist-osher.hh +++ b/dune/gdt/local/numerical-fluxes/engquist-osher.hh @@ -23,32 +23,39 @@ namespace Dune { namespace GDT { -template <size_t d, size_t m = 1, class R = double> -class NumericalEngquistOsherFlux : public internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R> +template <class I, size_t d, size_t m = 1, class R = double> +class NumericalEngquistOsherFlux : public internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<I, d, m, R> { public: template <class... Args> explicit NumericalEngquistOsherFlux(Args&&... /*args*/) - : internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R>() + : internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<I, d, m, R>() {} }; -template <size_t d, class R> -class NumericalEngquistOsherFlux<d, 1, R> : public NumericalFluxInterface<d, 1, R> +template <class I, size_t d, class R> +class NumericalEngquistOsherFlux<I, d, 1, R> : public NumericalFluxInterface<I, d, 1, R> { static const constexpr size_t m = 1; - using ThisType = NumericalEngquistOsherFlux<d, m, R>; - using BaseType = NumericalFluxInterface<d, m, R>; + using ThisType = NumericalEngquistOsherFlux; + using BaseType = NumericalFluxInterface<I, d, m, R>; public: using typename BaseType::FluxType; + using typename BaseType::LocalFluxType; + using typename BaseType::LocalIntersectionCoords; using typename BaseType::PhysicalDomainType; - using typename BaseType::StateRangeType; + using typename BaseType::StateType; + using typename BaseType::XIndependentFluxType; NumericalEngquistOsherFlux(const FluxType& flx) : BaseType(flx) {} + NumericalEngquistOsherFlux(const XIndependentFluxType& flx) + : BaseType(flx) + {} + NumericalEngquistOsherFlux(const ThisType& other) = default; std::unique_ptr<BaseType> copy() const override final @@ -58,38 +65,61 @@ public: using BaseType::apply; - StateRangeType apply(const StateRangeType& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const override final + StateType apply(const LocalIntersectionCoords& x_in_intersection_coords, + const StateType& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const override final { - auto integrate_f = [&](const auto& s, const std::function<double(const R&, const R&)>& min_max) { + this->compute_entity_coords(x_in_intersection_coords); + auto integrate_f = [&](const LocalFluxType& local_flux, + const auto& x, + const auto& s, + const std::function<double(const R&, const R&)>& min_max) { if (!(s[0] > 0.)) return 0.; double ret = 0.; const OneDGrid state_grid(1, 0., s[0]); const auto state_interval = *state_grid.leafGridView().template begin<0>(); - for (const auto& quadrature_point : - QuadratureRules<R, 1>::rule(state_interval.type(), this->flux().order(param))) { + for (const auto& quadrature_point : QuadratureRules<R, 1>::rule(state_interval.type(), local_flux.order(param))) { const auto local_uu = quadrature_point.position(); const auto uu = state_interval.geometry().global(local_uu); - const auto df = this->flux().jacobian(uu, param); + const auto df = local_flux.jacobian(x, uu, param); ret += state_interval.geometry().integrationElement(local_uu) * quadrature_point.weight() * min_max(n * df, 0.); } return ret; }; - return (this->flux().evaluate(0., param) * n) - + integrate_f(u, [](const double& a, const double& b) { return std::max(a, b); }) - + integrate_f(v, [](const double& a, const double& b) { return std::min(a, b); }); + return (local_flux_inside_->evaluate(x_in_inside_coords_, 0., param) * n) + + integrate_f(*local_flux_inside_, + x_in_inside_coords_, + u, + [](const double& a, const double& b) { return std::max(a, b); }) + + integrate_f(this->intersection().neighbor() ? *local_flux_outside_ : *local_flux_inside_, + x_in_outside_coords_, + v, + [](const double& a, const double& b) { return std::min(a, b); }); } + +private: + using BaseType::local_flux_inside_; + using BaseType::local_flux_outside_; + using BaseType::x_in_inside_coords_; + using BaseType::x_in_outside_coords_; }; // class NumericalEngquistOsherFlux -template <size_t d, size_t m, class R> -NumericalEngquistOsherFlux<d, m, R> +template <class I, size_t d, size_t m, class R> +NumericalEngquistOsherFlux<I, d, m, R> +make_numerical_engquist_osher_flux(const XT::Functions::FluxFunctionInterface<I, m, d, m, R>& flux) +{ + return NumericalEngquistOsherFlux<I, d, m, R>(flux); +} + +template <class I, size_t d, size_t m, class R> +NumericalEngquistOsherFlux<I, d, m, R> make_numerical_engquist_osher_flux(const XT::Functions::FunctionInterface<m, d, m, R>& flux) { - return NumericalEngquistOsherFlux<d, m, R>(flux); + return NumericalEngquistOsherFlux<I, d, m, R>(flux); } diff --git a/dune/gdt/local/numerical-fluxes/generic.hh b/dune/gdt/local/numerical-fluxes/generic.hh index faf584fa59d42f57cbf3885979074722095fa0a6..519e46f4d6bef0a0dfccf57d053e4e9000980795 100644 --- a/dune/gdt/local/numerical-fluxes/generic.hh +++ b/dune/gdt/local/numerical-fluxes/generic.hh @@ -22,25 +22,38 @@ namespace GDT { /** * \brief Implementation of NumericalFluxInterface for a given lambda expression. */ -template <size_t d, size_t m = 1, class R = double> -class GenericNumericalFlux : public NumericalFluxInterface<d, m, R> +template <class I, size_t d, size_t m = 1, class R = double> +class GenericNumericalFlux : public NumericalFluxInterface<I, d, m, R> { - using ThisType = GenericNumericalFlux<d, m, R>; - using BaseType = NumericalFluxInterface<d, m, R>; + using ThisType = GenericNumericalFlux; + using BaseType = NumericalFluxInterface<I, d, m, R>; public: using typename BaseType::FluxType; + using typename BaseType::LocalIntersectionCoords; using typename BaseType::PhysicalDomainType; - using typename BaseType::StateRangeType; + using typename BaseType::StateType; + using typename BaseType::XIndependentFluxType; - using GenericFunctionType = std::function<StateRangeType( - const StateRangeType&, const StateRangeType&, const PhysicalDomainType&, const XT::Common::Parameter&)>; + using GenericFunctionType = std::function<StateType(const I&, + const LocalIntersectionCoords&, + const StateType&, + const StateType&, + const PhysicalDomainType&, + const XT::Common::Parameter&)>; GenericNumericalFlux(const FluxType& flx, GenericFunctionType func, const XT::Common::ParameterType& param_type = {}) : BaseType(flx, param_type) , numerical_flux_(func) {} + GenericNumericalFlux(const XIndependentFluxType& flx, + GenericFunctionType func, + const XT::Common::ParameterType& param_type = {}) + : BaseType(flx, param_type) + , numerical_flux_(func) + {} + std::unique_ptr<BaseType> copy() const override final { return std::make_unique<ThisType>(*this); @@ -48,12 +61,13 @@ public: using BaseType::apply; - StateRangeType apply(const StateRangeType& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const override final + StateType apply(const LocalIntersectionCoords& x, + const StateType& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const override final { - return numerical_flux_(u, v, n, this->parse_parameter(param)); + return numerical_flux_(this->intersection(), x, u, v, n, this->parse_parameter(param)); } private: @@ -61,13 +75,22 @@ private: }; // class GenericNumericalFlux -template <size_t d, size_t m, class R> -GenericNumericalFlux<d, m, R> +template <class I, size_t d, size_t m, class R> +GenericNumericalFlux<I, d, m, R> +make_generic_numerical_flux(const XT::Functions::FluxFunctionInterface<I, m, d, m, R>& flux, + typename GenericNumericalFlux<I, d, m, R>::GenericFunctionType func, + const XT::Common::ParameterType& param_type = {}) +{ + return GenericNumericalFlux<I, d, m, R>(flux, func, param_type); +} + +template <class I, size_t d, size_t m, class R> +GenericNumericalFlux<I, d, m, R> make_generic_numerical_flux(const XT::Functions::FunctionInterface<m, d, m, R>& flux, - typename GenericNumericalFlux<d, m, R>::GenericFunctionType func, + typename GenericNumericalFlux<I, d, m, R>::GenericFunctionType func, const XT::Common::ParameterType& param_type = {}) { - return GenericNumericalFlux<d, m, R>(flux, func, param_type); + return GenericNumericalFlux<I, d, m, R>(flux, func, param_type); } diff --git a/dune/gdt/local/numerical-fluxes/interface.hh b/dune/gdt/local/numerical-fluxes/interface.hh index 136dc3e2e11aab61cd573eff132b8a1cec7c2612..728f443f8b1b9eb51f2bc6645ab6439b861b618b 100644 --- a/dune/gdt/local/numerical-fluxes/interface.hh +++ b/dune/gdt/local/numerical-fluxes/interface.hh @@ -15,6 +15,7 @@ #include <dune/xt/common/memory.hh> #include <dune/xt/la/container/vector-interface.hh> #include <dune/xt/functions/constant.hh> +#include <dune/xt/functions/interfaces/flux-function.hh> #include <dune/xt/functions/interfaces/function.hh> #include <dune/gdt/exceptions.hh> @@ -24,28 +25,63 @@ namespace GDT { /** - * Given the sought solution of a system of m conservation laws, u: R^d -> R^m, and d flux functions f_s: R^m -> R^m, - * for 1 <= s <= d (modelled by the flux f: R^m -> R^{d x m}), the purpose of a numerical flux - * g: R^m x R^m x R^d -> R^m is to approximate f(.) * n, e.g., g(u, u, n) = f(u) * n. + * Given the sought solution of a system of m conservation laws, u: R^d -> R^m, and d flux + * functions f_s: R^d x R^m -> R^m, for 1 <= s <= d (modelled by the + * flux f: R^d x R^m -> R^{d x m}), the purpose of a numerical flux + * g: R^m x R^m x R^d -> R^m is to approximate f(.) * n, e.g., g(x, u, u, n) = f(x, u) * n. */ -template <size_t d, size_t m = 1, class R = double> -class NumericalFluxInterface : public XT::Common::ParametricInterface +template <class Intersection, size_t d, size_t m = 1, class R = double> +class NumericalFluxInterface + : public XT::Grid::IntersectionBoundObject<Intersection> + , public XT::Common::ParametricInterface { - using ThisType = NumericalFluxInterface<d, m, R>; + using ThisType = NumericalFluxInterface; public: - using FluxType = XT::Functions::FunctionInterface<m, d, m, R>; - using PhysicalDomainType = FieldVector<double, d>; - using StateRangeType = typename FluxType::DomainType; + using I = Intersection; + using E = typename I::Entity; + using FluxType = XT::Functions::FluxFunctionInterface<E, m, d, m, R>; + using LocalFluxType = typename FluxType::LocalFunctionType; + using XIndependentFluxType = XT::Functions::FunctionInterface<m, d, m, R>; + using FluxWrapperType = XT::Functions::StateFunctionAsFluxFunctionWrapper<E, m, d, m, R>; + using PhysicalDomainType = typename FluxType::DomainType; + using LocalIntersectionCoords = FieldVector<typename I::ctype, d - 1>; + using StateType = typename FluxType::StateType; NumericalFluxInterface(const FluxType& flx, const XT::Common::ParameterType& param_type = {}) : XT::Common::ParametricInterface(param_type + flx.parameter_type()) , flux_(flx) + , local_flux_inside_(flux_.access().local_function()) + , local_flux_outside_(flux_.access().local_function()) {} NumericalFluxInterface(FluxType*&& flx_ptr, const XT::Common::ParameterType& param_type = {}) : XT::Common::ParametricInterface(param_type + flx_ptr->parameter_type()) , flux_(flx_ptr) + , local_flux_inside_(flux_.access().local_function()) + , local_flux_outside_(flux_.access().local_function()) + {} + + NumericalFluxInterface(const XIndependentFluxType& func, const XT::Common::ParameterType& param_type = {}) + : XT::Common::ParametricInterface(param_type + func.parameter_type()) + , flux_(new FluxWrapperType(func)) + , local_flux_inside_(flux_.access().local_function()) + , local_flux_outside_(flux_.access().local_function()) + {} + + NumericalFluxInterface(XIndependentFluxType*&& func_ptr, const XT::Common::ParameterType& param_type = {}) + : XT::Common::ParametricInterface(param_type + func_ptr->parameter_type()) + , flux_(new FluxWrapperType(func_ptr)) + , local_flux_inside_(flux_.access().local_function()) + , local_flux_outside_(flux_.access().local_function()) + {} + + NumericalFluxInterface(const ThisType& other) + : XT::Grid::IntersectionBoundObject<Intersection>(other) + , XT::Common::ParametricInterface(other) + , flux_(other.flux_) + , local_flux_inside_(flux_.access().local_function()) + , local_flux_outside_(flux_.access().local_function()) {} virtual std::unique_ptr<ThisType> copy() const = 0; @@ -55,45 +91,54 @@ public: return false; } + virtual bool x_dependent() const + { + return flux_.access().x_dependent(); + } + const FluxType& flux() const { return flux_.access(); } - virtual StateRangeType apply(const StateRangeType& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const = 0; + virtual StateType apply(const LocalIntersectionCoords& x_in_local_intersection_coords, + const StateType& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const = 0; template <class V> - StateRangeType apply(const StateRangeType& u, - const XT::LA::VectorInterface<V>& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const + StateType apply(const LocalIntersectionCoords x_in_local_intersection_coords, + const StateType& u, + const XT::LA::VectorInterface<V>& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const { DUNE_THROW_IF(v.size() != m, Exceptions::numerical_flux_error, "v.size() = " << v.size() << "\n m = " << m); for (size_t ii = 0; ii < m; ++ii) v_[ii] = v[ii]; - return this->apply(u, v_, n, param); + return this->apply(x_in_local_intersection_coords, u, v_, n, param); } template <class U> - StateRangeType apply(const XT::LA::VectorInterface<U>& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const + StateType apply(const LocalIntersectionCoords x_in_local_intersection_coords, + const XT::LA::VectorInterface<U>& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const { DUNE_THROW_IF(u.size() != m, Exceptions::numerical_flux_error, "u.size() = " << u.size() << "\n m = " << m); for (size_t ii = 0; ii < m; ++ii) u_[ii] = u[ii]; - return this->apply(u_, v, n, param); + return this->apply(x_in_local_intersection_coords, u_, v, n, param); } template <class U, class V> - StateRangeType apply(const XT::LA::VectorInterface<U>& u, - const XT::LA::VectorInterface<V>& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const + StateType apply(const LocalIntersectionCoords x_in_local_intersection_coords, + const XT::LA::VectorInterface<U>& u, + const XT::LA::VectorInterface<V>& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const { DUNE_THROW_IF(u.size() != m, Exceptions::numerical_flux_error, "u.size() = " << u.size() << "\n m = " << m); DUNE_THROW_IF(v.size() != m, Exceptions::numerical_flux_error, "v.size() = " << v.size() << "\n m = " << m); @@ -101,28 +146,59 @@ public: u_[ii] = u[ii]; v_[ii] = v[ii]; } - return this->apply(u_, v_, n, param); + return this->apply(x_in_local_intersection_coords, u_, v_, n, param); } // ... apply(...) + using XT::Grid::IntersectionBoundObject<I>::intersection; + private: const XT::Common::ConstStorageProvider<FluxType> flux_; - mutable StateRangeType u_; - mutable StateRangeType v_; + mutable StateType u_; + mutable StateType v_; + +protected: + virtual void post_bind(const I& inter) override + { + local_flux_inside_->bind(inter.inside()); + if (inter.neighbor()) + local_flux_outside_->bind(inter.outside()); + } + + void compute_entity_coords(const LocalIntersectionCoords& x_in_local_intersection_coords) const + { + if (this->x_dependent()) { + if (!this->is_bound_) + DUNE_THROW(Dune::InvalidStateException, "You have to call bind(intersection) before calling this function!"); + x_in_inside_coords_ = + intersection().inside().geometry().local(intersection().geometry().global(x_in_local_intersection_coords)); + if (intersection().neighbor()) + x_in_outside_coords_ = + intersection().outside().geometry().local(intersection().geometry().global(x_in_local_intersection_coords)); + else + x_in_outside_coords_ = x_in_inside_coords_; + } + } + + mutable std::unique_ptr<LocalFluxType> local_flux_inside_; + mutable std::unique_ptr<LocalFluxType> local_flux_outside_; + mutable PhysicalDomainType x_in_inside_coords_; + mutable PhysicalDomainType x_in_outside_coords_; }; // class NumericalFluxInterface namespace internal { -template <size_t d, size_t m = 1, class R = double> -class ThisNumericalFluxIsNotAvailableForTheseDimensions : public NumericalFluxInterface<d, m, R> +template <class Intersection, size_t d, size_t m = 1, class R = double> +class ThisNumericalFluxIsNotAvailableForTheseDimensions : public NumericalFluxInterface<Intersection, d, m, R> { - using ThisType = ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R>; - using BaseType = NumericalFluxInterface<d, m, R>; + using BaseType = NumericalFluxInterface<Intersection, d, m, R>; public: + using typename BaseType::I; + using typename BaseType::LocalIntersectionCoords; using typename BaseType::PhysicalDomainType; - using typename BaseType::StateRangeType; + using typename BaseType::StateType; template <class... Args> explicit ThisNumericalFluxIsNotAvailableForTheseDimensions(Args&&... /*args*/) @@ -145,13 +221,14 @@ public: using BaseType::apply; - StateRangeType apply(const StateRangeType& /*u*/, - const StateRangeType& /*v*/, - const PhysicalDomainType& /*n*/, - const XT::Common::Parameter& /*param*/ = {}) const override final + StateType apply(const LocalIntersectionCoords& /*x_in_local_intersection_coords*/, + const StateType& /*u*/, + const StateType& /*v*/, + const PhysicalDomainType& /*n*/, + const XT::Common::Parameter& /*param*/ = {}) const override final { DUNE_THROW(Exceptions::numerical_flux_error, "d = " << d << "\n m = " << m); - return StateRangeType(); + return StateType(); } }; // class ThisNumericalFluxIsNotAvailableForTheseDimensions diff --git a/dune/gdt/local/numerical-fluxes/lax-friedrichs.hh b/dune/gdt/local/numerical-fluxes/lax-friedrichs.hh index 3961767319a97ed80ed6ec258a2c035ada5752e8..a75e7e3a7a367561582dd2d3d25f45201334cce9 100644 --- a/dune/gdt/local/numerical-fluxes/lax-friedrichs.hh +++ b/dune/gdt/local/numerical-fluxes/lax-friedrichs.hh @@ -19,32 +19,38 @@ namespace Dune { namespace GDT { -template <size_t d, size_t m = 1, class R = double> -class NumericalLaxFriedrichsFlux : public internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R> +template <class I, size_t d, size_t m = 1, class R = double> +class NumericalLaxFriedrichsFlux : public internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<I, d, m, R> { public: template <class... Args> explicit NumericalLaxFriedrichsFlux(Args&&... /*args*/) - : internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R>() + : internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<I, d, m, R>() {} }; -template <size_t d, class R> -class NumericalLaxFriedrichsFlux<d, 1, R> : public NumericalFluxInterface<d, 1, R> +template <class I, size_t d, class R> +class NumericalLaxFriedrichsFlux<I, d, 1, R> : public NumericalFluxInterface<I, d, 1, R> { static const constexpr size_t m = 1; - using ThisType = NumericalLaxFriedrichsFlux<d, m, R>; - using BaseType = NumericalFluxInterface<d, m, R>; + using ThisType = NumericalLaxFriedrichsFlux; + using BaseType = NumericalFluxInterface<I, d, m, R>; public: using typename BaseType::FluxType; + using typename BaseType::LocalIntersectionCoords; using typename BaseType::PhysicalDomainType; - using typename BaseType::StateRangeType; + using typename BaseType::StateType; + using typename BaseType::XIndependentFluxType; NumericalLaxFriedrichsFlux(const FluxType& flx) : BaseType(flx) {} + NumericalLaxFriedrichsFlux(const XIndependentFluxType& func) + : BaseType(func) + {} + NumericalLaxFriedrichsFlux(const ThisType& other) = default; std::unique_ptr<BaseType> copy() const override final @@ -54,23 +60,44 @@ public: using BaseType::apply; - StateRangeType apply(const StateRangeType& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const override final + StateType apply(const LocalIntersectionCoords& x, + const StateType& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const override final { - const auto lambda = - 1. / std::max(this->flux().jacobian(u, param).infinity_norm(), this->flux().jacobian(v, param).infinity_norm()); - return 0.5 * ((this->flux().evaluate(u, param) + this->flux().evaluate(v, param)) * n) + 0.5 * ((u - v) / lambda); + // prepare + this->compute_entity_coords(x); + // evaluate + const auto df_u = local_flux_inside_->jacobian(x_in_inside_coords_, u, param); + const auto df_v = local_flux_outside_->jacobian(x_in_outside_coords_, v, param); + const auto f_u = local_flux_inside_->evaluate(x_in_inside_coords_, u, param); + const auto f_v = local_flux_outside_->evaluate(x_in_outside_coords_, v, param); + // compute numerical flux + const auto lambda = 1. / std::max(df_u.infinity_norm(), df_v.infinity_norm()); + return 0.5 * ((f_u + f_v) * n + (u - v) / lambda); } + +private: + using BaseType::local_flux_inside_; + using BaseType::local_flux_outside_; + using BaseType::x_in_inside_coords_; + using BaseType::x_in_outside_coords_; }; // class NumericalLaxFriedrichsFlux -template <size_t d, size_t m, class R> -NumericalLaxFriedrichsFlux<d, m, R> +template <class I, size_t d, size_t m, class R> +NumericalLaxFriedrichsFlux<I, d, m, R> +make_numerical_lax_friedrichs_flux(const XT::Functions::FluxFunctionInterface<I, m, d, m, R>& flux) +{ + return NumericalLaxFriedrichsFlux<I, d, m, R>(flux); +} + +template <class I, size_t d, size_t m, class R> +NumericalLaxFriedrichsFlux<I, d, m, R> make_numerical_lax_friedrichs_flux(const XT::Functions::FunctionInterface<m, d, m, R>& flux) { - return NumericalLaxFriedrichsFlux<d, m, R>(flux); + return NumericalLaxFriedrichsFlux<I, d, m, R>(flux); } diff --git a/dune/gdt/local/numerical-fluxes/upwind.hh b/dune/gdt/local/numerical-fluxes/upwind.hh index d8d0961a0449b131aef36804587728a307825979..b7519530b00775185649fbcfc4e77dbb526bbe1e 100644 --- a/dune/gdt/local/numerical-fluxes/upwind.hh +++ b/dune/gdt/local/numerical-fluxes/upwind.hh @@ -17,32 +17,38 @@ namespace Dune { namespace GDT { -template <size_t d, size_t m = 1, class R = double> -class NumericalUpwindFlux : public internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R> +template <class I, size_t d, size_t m = 1, class R = double> +class NumericalUpwindFlux : public internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<I, d, m, R> { public: template <class... Args> explicit NumericalUpwindFlux(Args&&... /*args*/) - : internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<d, m, R>() + : internal::ThisNumericalFluxIsNotAvailableForTheseDimensions<I, d, m, R>() {} }; -template <size_t d, class R> -class NumericalUpwindFlux<d, 1, R> : public NumericalFluxInterface<d, 1, R> +template <class I, size_t d, class R> +class NumericalUpwindFlux<I, d, 1, R> : public NumericalFluxInterface<I, d, 1, R> { static const constexpr size_t m = 1; - using ThisType = NumericalUpwindFlux<d, m, R>; - using BaseType = NumericalFluxInterface<d, m, R>; + using ThisType = NumericalUpwindFlux; + using BaseType = NumericalFluxInterface<I, d, m, R>; public: using typename BaseType::FluxType; + using typename BaseType::LocalIntersectionCoords; using typename BaseType::PhysicalDomainType; - using typename BaseType::StateRangeType; + using typename BaseType::StateType; + using typename BaseType::XIndependentFluxType; NumericalUpwindFlux(const FluxType& flx) : BaseType(flx) {} + NumericalUpwindFlux(const XIndependentFluxType& func) + : BaseType(func) + {} + NumericalUpwindFlux(const ThisType& other) = default; std::unique_ptr<BaseType> copy() const override final @@ -52,24 +58,39 @@ public: using BaseType::apply; - StateRangeType apply(const StateRangeType& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const override final + StateType apply(const LocalIntersectionCoords& x, + const StateType& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const override final { - const auto df = this->flux().jacobian((u + v) / 2., param); - if ((n * df) > 0) - return this->flux().evaluate(u, param) * n; + this->compute_entity_coords(x); + const auto df = local_flux_inside_->jacobian(x_in_inside_coords_, (u + v) / 2., param); + if (n * df > 0) + return local_flux_inside_->evaluate(x_in_inside_coords_, u, param) * n; else - return this->flux().evaluate(v, param) * n; + return local_flux_outside_->evaluate(x_in_outside_coords_, v, param) * n; } + +private: + using BaseType::local_flux_inside_; + using BaseType::local_flux_outside_; + using BaseType::x_in_inside_coords_; + using BaseType::x_in_outside_coords_; }; // class NumericalUpwindFlux -template <size_t d, size_t m, class R> -NumericalUpwindFlux<d, m, R> make_numerical_upwind_flux(const XT::Functions::FunctionInterface<m, d, m, R>& flux) +template <class I, size_t d, size_t m, class R> +NumericalUpwindFlux<I, d, m, R> +make_numerical_upwind_flux(const XT::Functions::FluxFunctionInterface<I, m, d, m, R>& flux) +{ + return NumericalUpwindFlux<I, d, m, R>(flux); +} + +template <class I, size_t d, size_t m, class R> +NumericalUpwindFlux<I, d, m, R> make_numerical_upwind_flux(const XT::Functions::FunctionInterface<m, d, m, R>& flux) { - return NumericalUpwindFlux<d, m, R>(flux); + return NumericalUpwindFlux<I, d, m, R>(flux); } diff --git a/dune/gdt/local/numerical-fluxes/vijayasundaram.hh b/dune/gdt/local/numerical-fluxes/vijayasundaram.hh index 770fa292f3a3c2690a44a4327eac9d97613b7984..fbc58df8c4012d58daf2ff92c75161c44c74756f 100644 --- a/dune/gdt/local/numerical-fluxes/vijayasundaram.hh +++ b/dune/gdt/local/numerical-fluxes/vijayasundaram.hh @@ -24,39 +24,72 @@ namespace Dune { namespace GDT { -template <size_t d, size_t m = 1, class R = double> -class NumericalVijayasundaramFlux : public NumericalFluxInterface<d, m, R> +template <class I, size_t d, size_t m = 1, class R = double> +class NumericalVijayasundaramFlux : public NumericalFluxInterface<I, d, m, R> { - using ThisType = NumericalVijayasundaramFlux<d, m, R>; - using BaseType = NumericalFluxInterface<d, m, R>; + using ThisType = NumericalVijayasundaramFlux; + using BaseType = NumericalFluxInterface<I, d, m, R>; public: + using typename BaseType::E; using typename BaseType::FluxType; + using typename BaseType::LocalFluxType; + using typename BaseType::LocalIntersectionCoords; using typename BaseType::PhysicalDomainType; - using typename BaseType::StateRangeType; - - using FluxEigenDecompositionLambdaType = std::function<std::tuple< - std::vector<XT::Common::real_t<R>>, - XT::Common::FieldMatrix<XT::Common::real_t<R>, m, m>, - XT::Common::FieldMatrix<XT::Common::real_t<R>, m, m>>( - const FluxType&, const FieldVector<R, m>&, const FieldVector<double, d>&, const XT::Common::Parameter& param)>; - - NumericalVijayasundaramFlux(const FluxType& flx) - : BaseType(flx) - , flux_eigen_decomposition_([](const auto& f, const auto& w, const auto& n, const auto& param) { + using typename BaseType::StateType; + using typename BaseType::XIndependentFluxType; + + using FluxEigenDecompositionLambdaType = + std::function<std::tuple<std::vector<XT::Common::real_t<R>>, + XT::Common::FieldMatrix<XT::Common::real_t<R>, m, m>, + XT::Common::FieldMatrix<XT::Common::real_t<R>, m, m>>( + const LocalFluxType&, + const FieldVector<R, m>&, + const FieldVector<double, d>&, + const XT::Common::Parameter& param)>; + + static FluxEigenDecompositionLambdaType default_flux_eigen_decomposition() + { + return [](const LocalFluxType& local_flux, + const StateType& w, + const PhysicalDomainType& n, + const XT::Common::Parameter& param) { // evaluate flux jacobian, compute P matrix [DF2016, p. 404, (8.17)] - const auto df = f.jacobian(w, param); + static PhysicalDomainType dummy_x; + const auto df = local_flux.jacobian(dummy_x, w, param); const auto P = df * n; auto eigensolver = XT::LA::make_eigen_solver( P, {{"type", XT::LA::eigen_solver_types(P)[0]}, {"assert_real_eigendecomposition", "1e-10"}}); return std::make_tuple( eigensolver.real_eigenvalues(), eigensolver.real_eigenvectors(), eigensolver.real_eigenvectors_inverse()); - }) + }; + } + + NumericalVijayasundaramFlux(const FluxType& flx) + : BaseType(flx) + , flux_eigen_decomposition_(default_flux_eigen_decomposition()) + { + if (flx->x_dependent()) + DUNE_THROW(Dune::NotImplemented, "This flux is not yet implemented for x-dependent fluxes!"); + } + + NumericalVijayasundaramFlux(const XIndependentFluxType& flx) + : BaseType(flx) + , flux_eigen_decomposition_(default_flux_eigen_decomposition()) {} NumericalVijayasundaramFlux(const FluxType& flx, FluxEigenDecompositionLambdaType flux_eigen_decomposition) : BaseType(flx) , flux_eigen_decomposition_(flux_eigen_decomposition) + { + if (flx->x_dependent()) + DUNE_THROW(Dune::NotImplemented, "This flux is not yet implemented for x-dependent fluxes!"); + } + + NumericalVijayasundaramFlux(const XIndependentFluxType& flx, + FluxEigenDecompositionLambdaType flux_eigen_decomposition) + : BaseType(flx) + , flux_eigen_decomposition_(flux_eigen_decomposition) {} std::unique_ptr<BaseType> copy() const override final @@ -66,13 +99,15 @@ public: using BaseType::apply; - StateRangeType apply(const StateRangeType& u, - const StateRangeType& v, - const PhysicalDomainType& n, - const XT::Common::Parameter& param = {}) const override final + StateType apply(const LocalIntersectionCoords& x, + const StateType& u, + const StateType& v, + const PhysicalDomainType& n, + const XT::Common::Parameter& param = {}) const override final { // compute decomposition - const auto eigendecomposition = flux_eigen_decomposition_(this->flux(), 0.5 * (u + v), n, param); + this->compute_entity_coords(x); + const auto eigendecomposition = flux_eigen_decomposition_(*local_flux_inside_, 0.5 * (u + v), n, param); const auto& evs = std::get<0>(eigendecomposition); const auto& T = std::get<1>(eigendecomposition); const auto& T_inv = std::get<2>(eigendecomposition); @@ -90,15 +125,23 @@ public: } // ... apply(...) private: + using BaseType::local_flux_inside_; const FluxEigenDecompositionLambdaType flux_eigen_decomposition_; }; // class NumericalVijayasundaramFlux -template <size_t d, size_t m, class R, class... Args> -NumericalVijayasundaramFlux<d, m, R> +template <class I, size_t d, size_t m, class R, class... Args> +NumericalVijayasundaramFlux<I, d, m, R> +make_numerical_vijayasundaram_flux(const XT::Functions::FluxFunctionInterface<I, m, d, m, R>& flux, Args&&... args) +{ + return NumericalVijayasundaramFlux<I, d, m, R>(flux, std::forward<Args>(args)...); +} + +template <class I, size_t d, size_t m, class R, class... Args> +NumericalVijayasundaramFlux<I, d, m, R> make_numerical_vijayasundaram_flux(const XT::Functions::FunctionInterface<m, d, m, R>& flux, Args&&... args) { - return NumericalVijayasundaramFlux<d, m, R>(flux, std::forward<Args>(args)...); + return NumericalVijayasundaramFlux<I, d, m, R>(flux, std::forward<Args>(args)...); } diff --git a/dune/gdt/local/operators/advection-dg.hh b/dune/gdt/local/operators/advection-dg.hh index 5628844288993cde9eae8e2ae46d6f128eb68653..ef401b6e6b168c118824950780b1f52c18df723e 100644 --- a/dune/gdt/local/operators/advection-dg.hh +++ b/dune/gdt/local/operators/advection-dg.hh @@ -47,10 +47,11 @@ class LocalAdvectionDgVolumeOperator : public LocalElementOperatorInterface<SV, public: using BaseType::d; using typename BaseType::D; + using typename BaseType::E; using typename BaseType::LocalRangeType; using typename BaseType::SourceType; - using FluxType = XT::Functions::FunctionInterface<m, d, m, RF>; + using FluxType = XT::Functions::FluxFunctionInterface<E, m, d, m, RF>; using LocalMassMatrixProviderType = LocalMassMatrixProvider<RGV, m, 1, RF>; LocalAdvectionDgVolumeOperator(const FluxType& flux) @@ -87,7 +88,9 @@ public: const auto local_source = source.local_discrete_function(element); const auto local_source_order = local_source->order(param); const auto local_basis_order = basis.order(param); - const auto integrand_order = flux_.order(param) * local_source_order + std::max(local_basis_order - 1, 0); + const auto local_flux = flux_.local_function(); + local_flux->bind(element); + const auto integrand_order = local_flux->order(param) * local_source_order + std::max(local_basis_order - 1, 0); for (const auto& quadrature_point : QuadratureRules<D, d>::rule(element.geometry().type(), integrand_order)) { // prepare const auto point_in_reference_element = quadrature_point.position(); @@ -96,7 +99,7 @@ public: // evaluate basis.jacobians(point_in_reference_element, basis_jacobians_, param); const auto source_value = local_source->evaluate(point_in_reference_element, param); - const auto flux_value = flux_.evaluate(source_value, param); + const auto flux_value = local_flux->evaluate(point_in_reference_element, source_value, param); // compute for (size_t ii = 0; ii < basis.size(param); ++ii) local_dofs_[ii] += integration_factor * quadrature_weight * -1. * (flux_value * basis_jacobians_[ii]); @@ -147,7 +150,7 @@ public: using typename BaseType::LocalOutsideRangeType; using typename BaseType::SourceType; - using NumericalFluxType = NumericalFluxInterface<d, m, IRR>; + using NumericalFluxType = NumericalFluxInterface<I, d, m, IRR>; using LocalMassMatrixProviderType = LocalMassMatrixProvider<IRGV, m, 1, IRR>; LocalAdvectionDgCouplingOperator(const NumericalFluxType& numerical_flux, bool compute_outside = true) @@ -192,10 +195,16 @@ public: outside_local_dofs_.resize(outside_basis.size(param)); inside_local_dofs_ *= 0.; outside_local_dofs_ *= 0.; + const auto local_flux = numerical_flux_->flux().local_function(); + local_flux->bind(intersection.inside()); + const auto inside_flux_order = local_flux->order(param); + local_flux->bind(intersection.outside()); + numerical_flux_->bind(intersection); + const auto outside_flux_order = local_flux->order(param); const auto u = source.local_discrete_function(inside_element); const auto v = source.local_discrete_function(outside_element); const auto integrand_order = std::max(inside_basis.order(param), outside_basis.order(param)) - + numerical_flux_->flux().order(param) * std::max(u->order(param), v->order(param)); + + std::max(inside_flux_order * u->order(param), outside_flux_order * v->order(param)); for (const auto& quadrature_point : QuadratureRules<D, d - 1>::rule(intersection.geometry().type(), integrand_order)) { // prepare @@ -211,7 +220,8 @@ public: inside_basis.evaluate(point_in_inside_reference_element, inside_basis_values_); if (compute_outside_) outside_basis.evaluate(point_in_outside_reference_element, outside_basis_values_); - const auto g = numerical_flux_->apply(u->evaluate(point_in_inside_reference_element), + const auto g = numerical_flux_->apply(point_in_reference_intersection, + u->evaluate(point_in_inside_reference_element), v->evaluate(point_in_outside_reference_element), normal, param); @@ -237,7 +247,7 @@ public: } // ... apply(...) private: - const std::unique_ptr<const NumericalFluxType> numerical_flux_; + const std::unique_ptr<NumericalFluxType> numerical_flux_; const bool compute_outside_; const XT::Common::ConstStorageProvider<LocalMassMatrixProviderType> local_mass_matrices_; mutable std::vector<typename LocalInsideRangeType::LocalBasisType::RangeType> inside_basis_values_; @@ -371,7 +381,7 @@ public: using typename BaseType::SourceType; using D = typename IntersectionType::ctype; - using NumericalFluxType = NumericalFluxInterface<d, m, RF>; + using NumericalFluxType = NumericalFluxInterface<I, d, m, RF>; using FluxType = typename NumericalFluxType::FluxType; using StateRangeType = typename XT::Functions::RangeTypeSelector<RF, m, 1>::type; using LambdaType = @@ -425,9 +435,11 @@ public: const auto& inside_basis = local_range_inside.basis(); inside_local_dofs_.resize(inside_basis.size(param)); inside_local_dofs_ *= 0.; + const auto local_flux = numerical_flux_->flux().local_function(); + numerical_flux_->bind(intersection); + local_flux->bind(intersection.inside()); const auto local_source = source.local_discrete_function(element); - const auto integrand_order = - inside_basis.order(param) + numerical_flux_->flux().order(param) * local_source->order(param); + const auto integrand_order = inside_basis.order(param) + local_flux->order(param) * local_source->order(param); for (const auto& quadrature_point : QuadratureRules<D, d - 1>::rule(intersection.geometry().type(), integrand_order)) { // prepare @@ -441,7 +453,7 @@ public: inside_basis.evaluate(point_in_inside_reference_element, inside_basis_values_); const auto u = local_source->evaluate(point_in_inside_reference_element); const auto v = extrapolate_(intersection, point_in_reference_intersection, numerical_flux_->flux(), u, param); - const auto g = numerical_flux_->apply(u, v, normal, param); + const auto g = numerical_flux_->apply(point_in_reference_intersection, u, v, normal, param); // compute for (size_t ii = 0; ii < inside_basis.size(param); ++ii) inside_local_dofs_[ii] += integration_factor * quadrature_weight * (g * inside_basis_values_[ii]); @@ -455,7 +467,7 @@ public: } // ... apply(...) private: - const std::unique_ptr<const NumericalFluxType> numerical_flux_; + const std::unique_ptr<NumericalFluxType> numerical_flux_; const LambdaType extrapolate_; const XT::Common::ConstStorageProvider<LocalMassMatrixProviderType> local_mass_matrices_; mutable std::vector<typename LocalInsideRangeType::LocalBasisType::RangeType> inside_basis_values_; diff --git a/dune/gdt/local/operators/advection-fv.hh b/dune/gdt/local/operators/advection-fv.hh index 93086c9cabfdd2514a73b0302f7875dced8b06ee..2c7b4f42a17e35eab5d7a3f34e70b42f3a0c345e 100644 --- a/dune/gdt/local/operators/advection-fv.hh +++ b/dune/gdt/local/operators/advection-fv.hh @@ -57,8 +57,8 @@ public: using typename BaseType::LocalInsideRangeType; using typename BaseType::LocalOutsideRangeType; using typename BaseType::SourceType; - - using NumericalFluxType = NumericalFluxInterface<d, m, RR>; + using NumericalFluxType = NumericalFluxInterface<I, d, m, RR>; + using LocalIntersectionCoords = typename NumericalFluxType::LocalIntersectionCoords; LocalAdvectionFvCouplingOperator(const NumericalFluxType& numerical_flux) : BaseType(numerical_flux.parameter_type()) @@ -91,7 +91,10 @@ public: const auto u = source.local_discrete_function(inside_element); const auto v = source.local_discrete_function(outside_element); const auto normal = intersection.centerUnitOuterNormal(); - const auto g = numerical_flux_->apply(u->dofs(), v->dofs(), normal, param); + numerical_flux_->bind(intersection); + if (numerical_flux_->x_dependent()) + x_in_intersection_coords_ = intersection.geometry().local(intersection.geometry().center()); + const auto g = numerical_flux_->apply(x_in_intersection_coords_, u->dofs(), v->dofs(), normal, param); const auto h_intersection = intersection.geometry().volume(); const auto h_inside_element = inside_element.geometry().volume(); const auto h_outside_element = outside_element.geometry().volume(); @@ -103,6 +106,7 @@ public: private: std::unique_ptr<NumericalFluxType> numerical_flux_; + mutable LocalIntersectionCoords x_in_intersection_coords_; }; // class LocalAdvectionFvCouplingOperator @@ -122,8 +126,8 @@ public: using StateDomainType = FieldVector<typename SGV::ctype, SGV::dimension>; using StateDofsType = ConstLocalDofVector<SV, SGV>; - using StateRangeType = typename XT::Functions::RangeTypeSelector<SF, m, 1>::type; - using LambdaType = std::function<StateRangeType( + using StateType = typename XT::Functions::RangeTypeSelector<SF, m, 1>::type; + using LambdaType = std::function<StateType( const StateDofsType& /*u*/, const StateDomainType& /*n*/, const XT::Common::Parameter& /*param*/)>; LocalAdvectionFvBoundaryTreatmentByCustomNumericalFluxOperator( @@ -182,16 +186,16 @@ public: using typename BaseType::SourceType; using D = typename IntersectionType::ctype; - using NumericalFluxType = NumericalFluxInterface<d, m, RF>; + using NumericalFluxType = NumericalFluxInterface<I, d, m, RF>; + using LocalIntersectionCoords = typename NumericalFluxType::LocalIntersectionCoords; using FluxType = typename NumericalFluxType::FluxType; using StateDofsType = ConstLocalDofVector<SV, SGV>; - using StateRangeType = typename XT::Functions::RangeTypeSelector<RF, m, 1>::type; - using LambdaType = - std::function<StateRangeType(const IntersectionType& /*intersection*/, - const FieldVector<D, d - 1>& /*xx_in_reference_intersection_coordinates*/, - const FluxType& /*flux*/, - const StateDofsType& /*u*/, - const XT::Common::Parameter& /*param*/)>; + using StateType = typename XT::Functions::RangeTypeSelector<RF, m, 1>::type; + using LambdaType = std::function<StateType(const IntersectionType& /*intersection*/, + const FieldVector<D, d - 1>& /*xx_in_reference_intersection_coordinates*/, + const FluxType& /*flux*/, + const StateDofsType& /*u*/, + const XT::Common::Parameter& /*param*/)>; LocalAdvectionFvBoundaryTreatmentByCustomExtrapolationOperator( const NumericalFluxType& numerical_flux, @@ -224,6 +228,7 @@ public: Exceptions::operator_error, "Use LocalAdvectionDgBoundaryTreatmentByCustomExtrapolationOperator instead!"); const auto& element = local_range_inside.element(); + numerical_flux_->bind(intersection); const auto u = source.local_discrete_function(element); const auto v = extrapolate_(intersection, ReferenceElements<D, d - 1>::general(intersection.type()).position(0, 0), @@ -231,7 +236,9 @@ public: u->dofs(), param); const auto normal = intersection.centerUnitOuterNormal(); - const auto g = numerical_flux_->apply(u->dofs(), v, normal, param); + if (numerical_flux_->x_dependent()) + x_in_intersection_coords_ = intersection.geometry().local(intersection.geometry().center()); + const auto g = numerical_flux_->apply(x_in_intersection_coords_, u->dofs(), v, normal, param); const auto h_intersection = intersection.geometry().volume(); const auto h_element = element.geometry().volume(); for (size_t ii = 0; ii < m; ++ii) @@ -241,6 +248,7 @@ public: private: std::unique_ptr<NumericalFluxType> numerical_flux_; const LambdaType extrapolate_; + mutable LocalIntersectionCoords x_in_intersection_coords_; }; // class LocalAdvectionFvBoundaryTreatmentByCustomExtrapolationOperator diff --git a/dune/gdt/operators/advection-dg.hh b/dune/gdt/operators/advection-dg.hh index 621515384a2ac8f762f2c02012ed84c262ae5272..aa2cfec909cb5794f5fc2aa048908db986e35aa3 100644 --- a/dune/gdt/operators/advection-dg.hh +++ b/dune/gdt/operators/advection-dg.hh @@ -73,9 +73,8 @@ public: using typename BaseType::F; using typename BaseType::V; - using NumericalFluxType = NumericalFluxInterface<d, m, F>; - using I = XT::Grid::extract_intersection_t<SGV>; + using NumericalFluxType = NumericalFluxInterface<I, d, m, F>; using BoundaryTreatmentByCustomNumericalFluxOperatorType = LocalAdvectionDgBoundaryTreatmentByCustomNumericalFluxOperator<I, V, SGV, m, F, F, RGV, V>; using BoundaryTreatmentByCustomExtrapolationOperatorType = @@ -304,7 +303,7 @@ template <class MatrixType, class SGV, size_t m, class F, class RGV> std::enable_if_t<XT::LA::is_matrix<MatrixType>::value, AdvectionDgOperator<MatrixType, SGV, m, RGV>> make_advection_dg_operator( const SGV& assembly_grid_view, - const NumericalFluxInterface<SGV::dimension, m, F>& numerical_flux, + const NumericalFluxInterface<XT::Grid::extract_intersection_t<SGV>, SGV::dimension, m, F>& numerical_flux, const SpaceInterface<SGV, m, 1, F>& source_space, const SpaceInterface<RGV, m, 1, F>& range_space, const XT::Grid::IntersectionFilter<SGV>& periodicity_exception = XT::Grid::ApplyOn::NoIntersections<SGV>(), diff --git a/dune/gdt/operators/advection-fv.hh b/dune/gdt/operators/advection-fv.hh index ecd296021602d418383848ad55e23a1b387ac727..413fc1f8e3bc64c1f4ab8c698c07fd7ce5a7ce64 100644 --- a/dune/gdt/operators/advection-fv.hh +++ b/dune/gdt/operators/advection-fv.hh @@ -46,9 +46,8 @@ public: using typename BaseType::F; using typename BaseType::V; - using NumericalFluxType = NumericalFluxInterface<SGV::dimension, m, F>; - using I = XT::Grid::extract_intersection_t<SGV>; + using NumericalFluxType = NumericalFluxInterface<I, SGV::dimension, m, F>; using BoundaryTreatmentByCustomNumericalFluxOperatorType = LocalAdvectionFvBoundaryTreatmentByCustomNumericalFluxOperator<I, V, SGV, m, F, F, RGV, V>; using BoundaryTreatmentByCustomExtrapolationOperatorType = @@ -233,7 +232,7 @@ template <class MatrixType, class SGV, size_t m, class F, class RGV> std::enable_if_t<XT::LA::is_matrix<MatrixType>::value, AdvectionFvOperator<MatrixType, SGV, m, RGV>> make_advection_fv_operator( const SGV& assembly_grid_view, - const NumericalFluxInterface<SGV::dimension, m, F>& numerical_flux, + const NumericalFluxInterface<XT::Grid::extract_intersection_t<SGV>, SGV::dimension, m, F>& numerical_flux, const SpaceInterface<SGV, m, 1, F>& source_space, const SpaceInterface<RGV, m, 1, F>& range_space, const XT::Grid::IntersectionFilter<SGV>& periodicity_exception = XT::Grid::ApplyOn::NoIntersections<SGV>()) diff --git a/dune/gdt/spaces/basis/default.hh b/dune/gdt/spaces/basis/default.hh index 32ef1b0b3e13815615dc62efefd33a963260aa6f..8c2c0a9b21c56052150faec1c38b59c77880df4b 100644 --- a/dune/gdt/spaces/basis/default.hh +++ b/dune/gdt/spaces/basis/default.hh @@ -54,7 +54,7 @@ public: const int order) : grid_view_(grid_view) , local_finite_elements_(local_finite_elements) - , order_(order) + , fe_order_(order) , max_size_(0) {} @@ -74,7 +74,7 @@ public: { max_size_ = 0; for (const auto& gt : grid_view_.indexSet().types(0)) - max_size_ = std::max(max_size_, local_finite_elements_.get(gt, order_).size()); + max_size_ = std::max(max_size_, local_finite_elements_.get(gt, fe_order_).size()); } private: @@ -115,7 +115,7 @@ private: void post_bind(const ElementType& elemnt) override final { current_local_fe_ = XT::Common::ConstStorageProvider<LocalFiniteElementInterface<D, d, R, r, rC>>( - self_.local_finite_elements_.get(elemnt.geometry().type(), self_.order_)); + self_.local_finite_elements_.get(elemnt.geometry().type(), self_.fe_order_)); } public: @@ -206,7 +206,7 @@ private: const GridViewType& grid_view_; const FiniteElementFamilyType& local_finite_elements_; - const int order_; + const int fe_order_; size_t max_size_; }; // class DefaultGlobalBasis diff --git a/dune/gdt/spaces/h1/continuous-flattop.hh b/dune/gdt/spaces/h1/continuous-flattop.hh new file mode 100644 index 0000000000000000000000000000000000000000..5f6a4fa2b2d9f2026f4d987c1ea469caadeb6f35 --- /dev/null +++ b/dune/gdt/spaces/h1/continuous-flattop.hh @@ -0,0 +1,178 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_SPACES_H1_CONTINUOUS_FLATTOP_HH +#define DUNE_GDT_SPACES_H1_CONTINUOUS_FLATTOP_HH + +#include <memory> +//#include <vector> + +//#include <dune/common/typetraits.hh> + +//#include <dune/geometry/type.hh> + +#include <dune/grid/common/gridview.hh> + +//#include <dune/xt/common/exceptions.hh> +//#include <dune/xt/grid/type_traits.hh> + +#include <dune/gdt/local/finite-elements/flattop.hh> +#include <dune/gdt/spaces/basis/default.hh> +#include <dune/gdt/spaces/mapper/continuous.hh> +#include <dune/gdt/spaces/interface.hh> + +namespace Dune { +namespace GDT { + + +/** + * \sa make_local_lagrange_finite_element + */ +template <class GV, size_t r = 1, class R = double> +class ContinuousFlatTopSpace : public SpaceInterface<GV, r, 1, R> +{ + using ThisType = ContinuousFlatTopSpace; + using BaseType = SpaceInterface<GV, r, 1, R>; + +public: + using BaseType::d; + using typename BaseType::D; + using typename BaseType::GlobalBasisType; + using typename BaseType::GridViewType; + using typename BaseType::LocalFiniteElementFamilyType; + using typename BaseType::MapperType; + +private: + using MapperImplementation = ContinuousMapper<GridViewType, LocalFiniteElementFamilyType, r>; + using GlobalBasisImplementation = DefaultGlobalBasis<GridViewType, r, 1, R>; + +public: + ContinuousFlatTopSpace(GridViewType grd_vw, const int fe_order, const D& overlap = 0.5) + : grid_view_(grd_vw) + , fe_order_(fe_order) + , local_finite_elements_(std::make_unique<LocalFlatTopFiniteElementFamily<D, d, R, r>>(overlap)) + , mapper_(nullptr) + , basis_(nullptr) + { + this->update_after_adapt(); + } + + ContinuousFlatTopSpace(const ThisType&) = default; + ContinuousFlatTopSpace(ThisType&&) = default; + + ThisType& operator=(const ThisType&) = delete; + ThisType& operator=(ThisType&&) = delete; + + const GridViewType& grid_view() const override final + { + return grid_view_; + } + + const MapperType& mapper() const override final + { + assert(mapper_ && "This must not happen!"); + return *mapper_; + } + + const GlobalBasisType& basis() const override final + { + assert(basis_ && "This must not happen!"); + return *basis_; + } + + const LocalFiniteElementFamilyType& finite_elements() const override final + { + return *local_finite_elements_; + } + + SpaceType type() const override final + { + return SpaceType::continuous_lagrange; + } + + int min_polorder() const override final + { + return fe_order_; + } + + int max_polorder() const override final + { + return fe_order_ + 1; + } + + bool continuous(const int diff_order) const override final + { + return diff_order == 0; + } + + bool continuous_normal_components() const override final + { + return true; + } + + bool is_lagrangian() const override final + { + return true; + } + + void update_after_adapt() override final + { + // check: the mapper does not work for non-conforming intersections + if (d == 3 && grid_view_.indexSet().types(0).size() != 1) + DUNE_THROW(Exceptions::space_error, + "in ContinuousFlatTopSpace: non-conforming intersections are not (yet) " + "supported, and more than one element type in 3d leads to non-conforming intersections!"); + // create/update mapper ... + if (mapper_) + mapper_->update_after_adapt(); + else + mapper_ = std::make_unique<MapperImplementation>(grid_view_, *local_finite_elements_, fe_order_); + // ... and basis + if (basis_) + basis_->update_after_adapt(); + else + basis_ = std::make_unique<GlobalBasisImplementation>(grid_view_, *local_finite_elements_, fe_order_); + this->create_communicator(); + } // ... update_after_adapt(...) + +private: + const GridViewType grid_view_; + const int fe_order_; + std::unique_ptr<const LocalFlatTopFiniteElementFamily<D, d, R, r>> local_finite_elements_; + std::unique_ptr<MapperImplementation> mapper_; + std::unique_ptr<GlobalBasisImplementation> basis_; +}; // class ContinuousFlatTopSpace + + +/** + * \sa ContinuousFlatTopSpace + */ +template <size_t r, class GV, class R = double> +ContinuousFlatTopSpace<GV, r, R> +make_continuous_flattop_space(GV grid_view, const int order, const double& overlap = 0.5) +{ + return ContinuousFlatTopSpace<GV, r, R>(grid_view, order, overlap); +} + + +/** + * \sa ContinuousFlatTopSpace + */ +template <class GV, class R = double> +ContinuousFlatTopSpace<GV, 1, R> +make_continuous_flattop_space(GV grid_view, const int order, const double& overlap = 0.5) +{ + return ContinuousFlatTopSpace<GV, 1, R>(grid_view, order, overlap); +} + + +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_SPACES_H1_CONTINUOUS_FLATTOP_HH diff --git a/dune/gdt/spaces/h1/continuous-lagrange.hh b/dune/gdt/spaces/h1/continuous-lagrange.hh index 8e101a2ee241701b92f9c260e10e49654a613685..1e718fd2de63d6f5021348a38254008aed8bff5a 100644 --- a/dune/gdt/spaces/h1/continuous-lagrange.hh +++ b/dune/gdt/spaces/h1/continuous-lagrange.hh @@ -67,7 +67,7 @@ private: public: ContinuousLagrangeSpace(GridViewType grd_vw, const int order) : grid_view_(grd_vw) - , order_(order) + , fe_order_(order) , local_finite_elements_(std::make_unique<LocalLagrangeFiniteElementFamily<D, d, R, r>>()) , mapper_(nullptr) , basis_(nullptr) @@ -110,12 +110,12 @@ public: int min_polorder() const override final { - return order_; + return fe_order_; } int max_polorder() const override final { - return order_; + return fe_order_; } bool continuous(const int diff_order) const override final @@ -144,18 +144,20 @@ public: if (mapper_) mapper_->update_after_adapt(); else - mapper_ = std::make_unique<MapperImplementation>(grid_view_, *local_finite_elements_, order_); + mapper_ = std::make_unique<MapperImplementation>(grid_view_, *local_finite_elements_, fe_order_); // ... and basis if (basis_) basis_->update_after_adapt(); else - basis_ = std::make_unique<GlobalBasisImplementation>(grid_view_, *local_finite_elements_, order_); + basis_ = std::make_unique<GlobalBasisImplementation>(grid_view_, *local_finite_elements_, fe_order_); this->create_communicator(); } // ... update_after_adapt(...) private: const GridViewType grid_view_; - const int order_; + const int fe_order_; + int min_polorder_; + int max_polorder_; std::unique_ptr<const LocalLagrangeFiniteElementFamily<D, d, R, r>> local_finite_elements_; std::unique_ptr<MapperImplementation> mapper_; std::unique_ptr<GlobalBasisImplementation> basis_; diff --git a/dune/gdt/spaces/mapper/continuous.hh b/dune/gdt/spaces/mapper/continuous.hh index 9b8df2613fd112bd8c67117392671011ff794077..c9a3e1eab856c3d1b0f784f179a3b26da1314c46 100644 --- a/dune/gdt/spaces/mapper/continuous.hh +++ b/dune/gdt/spaces/mapper/continuous.hh @@ -62,10 +62,12 @@ public: using typename BaseType::ElementType; using typename BaseType::GridViewType; - ContinuousMapper(const GridViewType& grd_vw, const LocalFiniteElementFamily& local_finite_elements, const int order) + ContinuousMapper(const GridViewType& grd_vw, + const LocalFiniteElementFamily& local_finite_elements, + const int fe_order) : grid_view_(grd_vw) , local_finite_elements_(local_finite_elements) - , order_(order) + , fe_order_(fe_order) , max_local_size_(0) , mapper_(grid_view_, [&](const auto& geometry_type, const auto /*grid_dim*/) { return all_DoF_attached_geometry_types_.count(geometry_type) > 0; @@ -88,7 +90,7 @@ public: const LocalFiniteElementCoefficientsInterface<D, d>& local_coefficients(const GeometryType& geometry_type) const override final { - return local_finite_elements_.get(geometry_type, order_).coefficients(); + return local_finite_elements_.get(geometry_type, fe_order_).coefficients(); } size_t size() const override final @@ -142,7 +144,7 @@ public: // collect all entities (for all codims) which are used to attach DoFs to all_DoF_attached_geometry_types_.clear(); for (auto&& geometry_type : grid_view_.indexSet().types(0)) { - const auto& finite_element = local_finite_elements_.get(geometry_type, order_); + const auto& finite_element = local_finite_elements_.get(geometry_type, fe_order_); max_local_size_ = std::max(max_local_size_, finite_element.size()); // loop over all keys of this finite element const auto& reference_element = ReferenceElements<D, d>::general(geometry_type); @@ -171,7 +173,7 @@ public: private: const GridViewType& grid_view_; const LocalFiniteElementFamily& local_finite_elements_; - const int order_; + const int fe_order_; size_t max_local_size_; std::set<GeometryType> all_DoF_attached_geometry_types_; Implementation mapper_; diff --git a/dune/gdt/test/burgers/burgers__1d__explicit__dg_p2.cc b/dune/gdt/test/burgers/burgers__1d__explicit__dg_p2.cc index 9d5462ba4f90db8b5f58610e7dddb042c2919549..a6143297ee5ba09407d3c25d5432601f3e83396f 100644 --- a/dune/gdt/test/burgers/burgers__1d__explicit__dg_p2.cc +++ b/dune/gdt/test/burgers/burgers__1d__explicit__dg_p2.cc @@ -29,7 +29,7 @@ TEST_F(Burgers1dExplicitDgP2Test, periodic_boundaries__numerical_engquist_osher_ { this->visualization_steps_ = DXTC_TEST_CONFIG_GET("setup.visualization_steps", 0); this->num_refinements_ = 2; - this->num_additional_refinements_for_reference_ = 3; + this->num_additional_refinements_for_reference_ = 2; this->space_type_ = "dg_p2"; this->numerical_flux_type_ = "engquist_osher"; /*const auto actual_results =*/this->run(); diff --git a/dune/gdt/test/burgers/burgers__1d__explicit__dg_p3.cc b/dune/gdt/test/burgers/burgers__1d__explicit__dg_p3.cc index 74a4b256535098957fe0b1a6aed0e785e3f70de8..c592fe13447161ed970091276cdf7cf0d62efe00 100644 --- a/dune/gdt/test/burgers/burgers__1d__explicit__dg_p3.cc +++ b/dune/gdt/test/burgers/burgers__1d__explicit__dg_p3.cc @@ -28,8 +28,8 @@ using Burgers1dExplicitDgP3Test = BurgersExplicitTest<YASP_1D_EQUIDISTANT_OFFSET TEST_F(Burgers1dExplicitDgP3Test, periodic_boundaries__numerical_engquist_osher_flux) { this->visualization_steps_ = DXTC_TEST_CONFIG_GET("setup.visualization_steps", 0); - this->num_refinements_ = 2; - this->num_additional_refinements_for_reference_ = 3; + this->num_refinements_ = 1; + this->num_additional_refinements_for_reference_ = 1; this->space_type_ = "dg_p3"; this->numerical_flux_type_ = "engquist_osher"; /*const auto actual_results =*/this->run(); diff --git a/dune/gdt/test/instationary-eocstudies/hyperbolic-nonconforming.hh b/dune/gdt/test/instationary-eocstudies/hyperbolic-nonconforming.hh index c82b72dd4a92aabaabaf64923399cf27cd959c4a..a82e4ad2a05fcc0223199dbe980ec96c7e87b1ba 100644 --- a/dune/gdt/test/instationary-eocstudies/hyperbolic-nonconforming.hh +++ b/dune/gdt/test/instationary-eocstudies/hyperbolic-nonconforming.hh @@ -60,9 +60,10 @@ protected: using typename BaseType::R; using typename BaseType::S; using typename BaseType::V; + using I = XT::Grid::extract_intersection_t<GV>; using F = XT::Functions::FunctionInterface<m, d, m>; - using NF = NumericalFluxInterface<d, m>; + using NF = NumericalFluxInterface<I, d, m>; public: InstationaryNonconformingHyperbolicEocStudy( @@ -107,13 +108,13 @@ protected: { std::unique_ptr<NF> numerical_flux; if (numerical_flux_type_ == "upwind") - numerical_flux = std::make_unique<NumericalUpwindFlux<d, m>>(flux()); + numerical_flux = std::make_unique<NumericalUpwindFlux<I, d, m>>(flux()); else if (numerical_flux_type_ == "vijayasundaram") - numerical_flux = std::make_unique<NumericalVijayasundaramFlux<d, m>>(flux()); + numerical_flux = std::make_unique<NumericalVijayasundaramFlux<I, d, m>>(flux()); else if (numerical_flux_type_ == "lax_friedrichs") - numerical_flux = std::make_unique<NumericalLaxFriedrichsFlux<d, m>>(flux()); + numerical_flux = std::make_unique<NumericalLaxFriedrichsFlux<I, d, m>>(flux()); else if (numerical_flux_type_ == "engquist_osher") - numerical_flux = std::make_unique<NumericalEngquistOsherFlux<d, m>>(flux()); + numerical_flux = std::make_unique<NumericalEngquistOsherFlux<I, d, m>>(flux()); else { DUNE_THROW(XT::Common::Exceptions::wrong_input_given, "numerical_flux_type_ = " << numerical_flux_type_); return nullptr; diff --git a/dune/gdt/test/inviscid-compressible-flow/base.hh b/dune/gdt/test/inviscid-compressible-flow/base.hh index e2d62700d27beeb31c8bae73ae692ba7bab99f44..2f8a45915044ede32c06c74c8687d1266d0379c2 100644 --- a/dune/gdt/test/inviscid-compressible-flow/base.hh +++ b/dune/gdt/test/inviscid-compressible-flow/base.hh @@ -96,6 +96,7 @@ protected: using typename BaseType::F; using typename BaseType::GP; using typename BaseType::GV; + using typename BaseType::I; using typename BaseType::M; using typename BaseType::O; using typename BaseType::R; @@ -153,9 +154,9 @@ protected: { auto& self = *this; const auto& euler_tools = this->access().euler_tools; - const NumericalVijayasundaramFlux<d, m> numerical_flux( + const NumericalVijayasundaramFlux<I, d, m> numerical_flux( self.flux(), - /*flux_eigen_decomposition=*/[&](const auto& /*f*/, const auto& w, const auto& n, const auto& + /*flux_eigen_decomposition=*/[&](const auto& /*local_f*/, const auto& w, const auto& n, const auto& /*param*/) { return std::make_tuple(euler_tools.eigenvalues_flux_jacobian(w, n), euler_tools.eigenvectors_flux_jacobian(w, n), diff --git a/dune/gdt/test/stationary-eocstudies/diffusion-ipdg.hh b/dune/gdt/test/stationary-eocstudies/diffusion-ipdg.hh index 3625a2f6ee3c7b5fbca25283658c5465f925139f..90ea966d884aedbf14731bc56b245c50e9c734ea 100644 --- a/dune/gdt/test/stationary-eocstudies/diffusion-ipdg.hh +++ b/dune/gdt/test/stationary-eocstudies/diffusion-ipdg.hh @@ -27,8 +27,9 @@ #include <dune/gdt/functionals/vector-based.hh> #include <dune/gdt/local/functionals/integrals.hh> #include <dune/gdt/local/bilinear-forms/integrals.hh> -#include <dune/gdt/local/integrands/elliptic-ipdg.hh> -#include <dune/gdt/local/integrands/elliptic.hh> +#include <dune/gdt/local/integrands/laplace.hh> +#include <dune/gdt/local/integrands/laplace-ipdg.hh> +#include <dune/gdt/local/integrands/ipdg.hh> #include <dune/gdt/local/integrands/product.hh> #include <dune/gdt/local/integrands/conversion.hh> #include <dune/gdt/norms.hh> @@ -81,6 +82,7 @@ public: StationaryDiffusionIpdgEocStudy() : BaseType() , space_type_("") + , one_(1.) {} protected: @@ -89,9 +91,7 @@ protected: virtual const XT::Grid::BoundaryInfo<I>& boundary_info() const = 0; - virtual const FF& diffusion_factor() const = 0; - - virtual const FT& diffusion_tensor() const = 0; + virtual const FT& diffusion() const = 0; virtual const FF& force() const = 0; @@ -125,15 +125,15 @@ protected: if (DXTC_TEST_CONFIG_GET("setup.visualize", false)) { const std::string prefix = XT::Common::Test::get_unique_test_name() + "_problem_"; const std::string postfix = "_ref_" + XT::Common::to_string(refinement_level); - self.diffusion_factor().visualize(current_space.grid_view(), prefix + "diffusion_factor" + postfix); - self.diffusion_tensor().visualize(current_space.grid_view(), prefix + "diffusion_tensor" + postfix); + // self.diffusion_factor().visualize(current_space.grid_view(), prefix + "diffusion_factor" + postfix); + self.diffusion().visualize(current_space.grid_view(), prefix + "diffusion" + postfix); self.force().visualize(current_space.grid_view(), prefix + "force" + postfix); // self.dirichlet().visualize(current_space.grid_view(), prefix + "dirichlet" + postfix); // self.neumann().visualize(current_space.grid_view(), prefix + "neumann" + postfix); } Timer timer; const auto solution = make_discrete_function(current_space, self.solve(current_space)); - const auto diffusion = diffusion_factor() * diffusion_tensor(); + const auto& one = one_.template as_grid_function<E>(); // only set time if this did not happen in solve() if (self.current_data_["quantity"].count("time to solution (s)") == 0) self.current_data_["quantity"]["time to solution (s)"] = timer.elapsed(); @@ -146,21 +146,21 @@ protected: current_space.grid_view(), current_space, current_space, boundary_info()); oswald_interpolation_operator.assemble(/*parallel=*/true); const auto h1_interpolation = oswald_interpolation_operator.apply(solution); - self.current_data_["norm"][norm_id] = elliptic_norm( - current_space.grid_view(), diffusion_factor(), diffusion_tensor(), solution - h1_interpolation); + self.current_data_["norm"][norm_id] = + elliptic_norm(current_space.grid_view(), one, diffusion(), solution - h1_interpolation); } else if (norm_id == "eta_R") { norm_it = remaining_norms.erase(norm_it); // ... or here ... // compute estimate auto rt_space = make_raviart_thomas_space(current_space.grid_view(), current_space.max_polorder() - 1); auto reconstruction_op = make_ipdg_flux_reconstruction_operator<M, ipdg_method>( - current_space.grid_view(), current_space, rt_space, diffusion_factor(), diffusion_tensor()); + current_space.grid_view(), current_space, rt_space, one, diffusion()); auto flux_reconstruction = reconstruction_op.apply(solution); double eta_R_2 = 0.; std::mutex eta_R_2_mutex; auto walker = XT::Grid::make_walker(current_space.grid_view()); walker.append([]() {}, [&](const auto& element) { - auto local_df = diffusion.local_function(); + auto local_df = this->diffusion().local_function(); local_df->bind(element); auto local_force = this->force().local_function(); local_force->bind(element); @@ -201,40 +201,36 @@ protected: // compute estimate auto rt_space = make_raviart_thomas_space(current_space.grid_view(), current_space.max_polorder() - 1); auto reconstruction_op = make_ipdg_flux_reconstruction_operator<M, ipdg_method>( - current_space.grid_view(), current_space, rt_space, diffusion_factor(), diffusion_tensor()); + current_space.grid_view(), current_space, rt_space, one, diffusion()); auto flux_reconstruction = reconstruction_op.apply(solution); double eta_DF_2 = 0.; std::mutex eta_DF_2_mutex; auto walker = XT::Grid::make_walker(current_space.grid_view()); - walker.append([]() {}, - [&](const auto& element) { - auto local_df = this->diffusion_factor().local_function(); - local_df->bind(element); - auto local_dt = this->diffusion_tensor().local_function(); - local_dt->bind(element); - auto local_solution = solution.local_function(); - local_solution->bind(element); - auto local_reconstruction = flux_reconstruction.local_function(); - local_reconstruction->bind(element); - auto result = XT::Grid::element_integral( - element, - [&](const auto& xx) { - const auto df = local_df->evaluate(xx); - const auto dt = local_dt->evaluate(xx); - const auto diff = dt * df; - const auto diff_inv = XT::LA::invert_matrix(diff); - const auto solution_grad = local_solution->jacobian(xx)[0]; - const auto flux_rec = local_reconstruction->evaluate(xx); - auto difference = diff * solution_grad + flux_rec; - return (diff_inv * difference) * difference; - }, - std::max(local_df->order() + local_dt->order() + std::max(local_solution->order() - 1, 0), - local_reconstruction->order()) - + /*over_integrate=*/3); - std::lock_guard<std::mutex> lock(eta_DF_2_mutex); - eta_DF_2 += result; - }, - []() {}); + walker.append( + []() {}, + [&](const auto& element) { + auto local_df = this->diffusion().local_function(); + local_df->bind(element); + auto local_solution = solution.local_function(); + local_solution->bind(element); + auto local_reconstruction = flux_reconstruction.local_function(); + local_reconstruction->bind(element); + auto result = XT::Grid::element_integral( + element, + [&](const auto& xx) { + const auto diff = local_df->evaluate(xx); + const auto diff_inv = XT::LA::invert_matrix(diff); + const auto solution_grad = local_solution->jacobian(xx)[0]; + const auto flux_rec = local_reconstruction->evaluate(xx); + auto difference = diff * solution_grad + flux_rec; + return (diff_inv * difference) * difference; + }, + std::max(local_df->order() + std::max(local_solution->order() - 1, 0), local_reconstruction->order()) + + /*over_integrate=*/3); + std::lock_guard<std::mutex> lock(eta_DF_2_mutex); + eta_DF_2 += result; + }, + []() {}); walker.walk(/*parallel=*/true); self.current_data_["norm"][norm_id] = std::sqrt(eta_DF_2); } else @@ -262,21 +258,33 @@ protected: virtual std::unique_ptr<O> make_residual_operator(const S& space) override { + const auto& one = one_.template as_grid_function<E>(); // define lhs operator (has to be a pointer to allow the residual operator to manage the memory in the end) auto lhs_op = std::make_unique<MatrixOperator<M, GV>>(make_matrix_operator<M>( space, (space_type_.size() >= 2 && space_type_.substr(0, 2) == "cg") ? Stencil::element : Stencil::element_and_intersection)); - lhs_op->append(LocalElementIntegralBilinearForm<E>( - LocalEllipticIntegrand<E>(this->diffusion_factor(), this->diffusion_tensor()))); - lhs_op->append(LocalIntersectionIntegralBilinearForm<I>(LocalEllipticIpdgIntegrands::Inner<I, double, ipdg_method>( - this->diffusion_factor(), this->diffusion_tensor())), + // - volume term + lhs_op->append(LocalElementIntegralBilinearForm<E>(LocalLaplaceIntegrand<E>(this->diffusion()))); + // - inner faces + lhs_op->append(LocalIntersectionIntegralBilinearForm<I>( + LocalLaplaceIPDGIntegrands::InnerCoupling<I>(1., this->diffusion(), this->diffusion())), {}, XT::Grid::ApplyOn::InnerIntersectionsOnce<GV>()); + lhs_op->append( + LocalIntersectionIntegralBilinearForm<I>(LocalIPDGIntegrands::InnerPenalty<I>( + 8, this->diffusion(), [](const auto& intersection) { return intersection.geometry().volume(); })), + {}, + XT::Grid::ApplyOn::InnerIntersectionsOnce<GV>()); + // - Dirichlet faces lhs_op->append( LocalIntersectionIntegralBilinearForm<I>( - LocalEllipticIpdgIntegrands::DirichletBoundaryLhs<I, double, ipdg_method>(this->diffusion_factor(), - this->diffusion_tensor())), + LocalLaplaceIPDGIntegrands::DirichletCoupling<I>(1., this->diffusion())), + {}, + XT::Grid::ApplyOn::CustomBoundaryIntersections<GV>(this->boundary_info(), new XT::Grid::DirichletBoundary())); + lhs_op->append( + LocalIntersectionIntegralBilinearForm<I>(LocalIPDGIntegrands::BoundaryPenalty<I>( + 14, this->diffusion(), [](const auto& intersection) { return intersection.geometry().volume(); })), {}, XT::Grid::ApplyOn::CustomBoundaryIntersections<GV>(this->boundary_info(), new XT::Grid::DirichletBoundary())); // define rhs functional @@ -297,6 +305,7 @@ protected: } // ... make_residual_operator(...) std::string space_type_; + XT::Functions::ConstantFunction<d> one_; }; // class StationaryDiffusionIpdgEocStudy diff --git a/dune/gdt/test/stationary-heat-equation/ESV2007.hh b/dune/gdt/test/stationary-heat-equation/ESV2007.hh index f3872f39ddf9f18fb3d25a974fd57c0f4e0fe1ac..390c8451f26ea47c824d7442acde6ad62bb81c88 100644 --- a/dune/gdt/test/stationary-heat-equation/ESV2007.hh +++ b/dune/gdt/test/stationary-heat-equation/ESV2007.hh @@ -48,8 +48,7 @@ struct ESV2007DiffusionProblem // We can only reproduce the results from ESV2007 by using a quadrature of order 3, which we obtain with a p1 DG space // and a force of order 2. ESV2007DiffusionProblem(int force_order = 2) - : diffusion_factor(1) - , diffusion_tensor(XT::LA::eye_matrix<XT::Common::FieldMatrix<double, d, d>>(d, d)) + : diffusion(XT::LA::eye_matrix<XT::Common::FieldMatrix<double, d, d>>(d, d)) , dirichlet(0) , neumann(0) , force(force_order) @@ -75,8 +74,7 @@ struct ESV2007DiffusionProblem EXPECT_TRUE(false) << "Please add a specialization for '" << XT::Common::Typename<G>::value << "'!"; } // ... make_initial_grid(...) - const XT::Functions::ConstantFunction<d> diffusion_factor; - const XT::Functions::ConstantFunction<d, d, d> diffusion_tensor; + const XT::Functions::ConstantFunction<d, d, d> diffusion; const XT::Functions::ConstantFunction<d> dirichlet; const XT::Functions::ConstantFunction<d> neumann; const XT::Functions::ESV2007::Testcase1Force<d, 1> force; @@ -144,14 +142,9 @@ protected: return problem.boundary_info; } - const FF& diffusion_factor() const override final + const FT& diffusion() const override final { - return problem.diffusion_factor.template as_grid_function<E>(); - } - - const FT& diffusion_tensor() const override final - { - return problem.diffusion_tensor.template as_grid_function<E>(); + return problem.diffusion.template as_grid_function<E>(); } const FF& force() const override final diff --git a/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.cc b/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.cc index a228d8e0412e5e1a03cea7efe1ad1a67d39c5cf6..440bbc40afed167af65e7601e85efdafefea933f 100644 --- a/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.cc +++ b/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.cc @@ -22,7 +22,9 @@ using namespace Dune; using namespace Dune::GDT::Test; -using ESV2007Table1Test = ESV2007DiffusionTest<ALU_2D_SIMPLEX_CONFORMING>; +#if SIMPLEXGRID_2D_AVAILABLE + +using ESV2007Table1Test = ESV2007DiffusionTest<SIMPLEXGRID_2D>; TEST_F(ESV2007Table1Test, columns_1_to_5) { this->space_type_ = "dg_p1"; @@ -30,3 +32,15 @@ TEST_F(ESV2007Table1Test, columns_1_to_5) const auto expected_results = DXTC_TEST_CONFIG_SUB("results"); XT::Test::check_eoc_study_for_success(expected_results, actual_results); } + +#endif // SIMPLEXGRID_2D_AVAILABLE + + +using NearlyESV2007Table1ButWithCubicGridTest = ESV2007DiffusionTest<CUBEGRID_2D>; +TEST_F(NearlyESV2007Table1ButWithCubicGridTest, columns_1_to_5) +{ + this->space_type_ = "dg_p1"; + const auto actual_results = this->run(); + const auto expected_results = DXTC_TEST_CONFIG_SUB("results"); + XT::Test::check_eoc_study_for_success(expected_results, actual_results); +} diff --git a/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.mini b/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.mini index 6f6bd6a3990e670c59147dda8ff618854b077fe5..c824c5d1cd5f7117492b98489affaf709877199e 100644 --- a/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.mini +++ b/dune/gdt/test/stationary-heat-equation/stationary_heat_equation__ESV2007__table_1.mini @@ -19,3 +19,18 @@ norm.eta_R = [7.23e-02 1.82e-02 4.54e-03] # 1.14e-03] # norm.eta_DF = [3.38e-01 1.69e-01 8.39e-02 4.18e-02] norm.eta_DF = [3.55e-01 1.76e-01 8.73e-02] # 4.35e-02] + +[NearlyESV2007Table1ButWithCubicGridTest.columns_1_to_5.setup] +force_order = 4 +over_integrate = 0 +num_refinements = 2 +num_additional_refinements_for_reference = 0 +reference_solution_order = 4 +use_tbb = false + +[NearlyESV2007Table1ButWithCubicGridTest.columns_1_to_5.results] +target.h = [3.54e-01 1.77e-01 8.84e-02] +norm.H_1_semi = [2.77e-01 1.39e-01 6.98e-02] +norm.eta_NC = [1.11e-02 3.62e-03 1.25e-03] +norm.eta_R = [8.85e-02 2.22e-02 5.56e-03] +norm.eta_DF = [4.42e-01 2.23e-01 1.12e-01] diff --git a/dune/gdt/test/stokes/stokes-taylorhood.hh b/dune/gdt/test/stokes/stokes-taylorhood.hh index dc471cb0902bc4a7606e16fb8cd6ab2342b29b69..c4446612f695291747a7ef9088806187a2d378ac 100644 --- a/dune/gdt/test/stokes/stokes-taylorhood.hh +++ b/dune/gdt/test/stokes/stokes-taylorhood.hh @@ -283,7 +283,7 @@ public: C.set_entry(dof_index, dof_index, 1.); // now solve the system - XT::LA::SaddlePointSolver<double> solver(A, B, B, C); + XT::LA::SaddlePointSolver<Vector, Matrix> solver(A, B, B, C); Vector solution_u(m), solution_p(n); // solve both by direct solver and by schurcomplement (where the schur complement is inverted by CG and the inner // solves with A are using a direct method) diff --git a/dune/gdt/tools/grid-quality-estimates.hh b/dune/gdt/tools/grid-quality-estimates.hh new file mode 100644 index 0000000000000000000000000000000000000000..baecd3fc444a02dbb270d4f9c45ee38fdce73d77 --- /dev/null +++ b/dune/gdt/tools/grid-quality-estimates.hh @@ -0,0 +1,134 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2019) + +#ifndef DUNE_GDT_TOOLS_GRID_QUALITY_ESTIMATES_HH +#define DUNE_GDT_TOOLS_GRID_QUALITY_ESTIMATES_HH + +#include <limits> +#include <vector> + +#include <dune/grid/common/rangegenerators.hh> + +#include <dune/xt/common/exceptions.hh> +#include <dune/xt/la/container/common.hh> +#include <dune/xt/la/container/conversion.hh> +#include <dune/xt/la/generalized-eigen-solver.hh> +#include <dune/xt/grid/entity.hh> +#include <dune/xt/grid/intersection.hh> +#include <dune/xt/grid/type_traits.hh> + +#include <dune/gdt/local/bilinear-forms/integrals.hh> +#include <dune/gdt/local/integrands/laplace.hh> +#include <dune/gdt/local/integrands/product.hh> +#include <dune/gdt/spaces/interface.hh> + +namespace Dune { +namespace GDT { + + +template <class GV, size_t r> +double estimate_inverse_inequality_constant(const SpaceInterface<GV, r>& space) +{ + DUNE_THROW_IF(!XT::Common::Lapacke::available(), XT::Common::Exceptions::dependency_missing, "lapacke"); + using E = XT::Grid::extract_entity_t<GV>; + double result = std::numeric_limits<double>::min(); + auto basis = space.basis().localize(); + for (auto&& element : elements(space.grid_view())) { + basis->bind(element); + const double h = XT::Grid::diameter(element); + auto H1_product_matrix = XT::LA::convert_to<XT::LA::CommonDenseMatrix<double>>( + LocalElementIntegralBilinearForm<E, r>(LocalLaplaceIntegrand<E, r>()).apply2(*basis, *basis)); + auto L2_product_matrix = XT::LA::convert_to<XT::LA::CommonDenseMatrix<double>>( + LocalElementIntegralBilinearForm<E, r>(LocalElementProductIntegrand<E, r>()).apply2(*basis, *basis)); + auto evs = + XT::LA::make_generalized_eigen_solver(H1_product_matrix, + L2_product_matrix, + {{"type", XT::LA::generalized_eigen_solver_types(H1_product_matrix)[0]}, + {"compute_eigenvectors", "false"}, + {"assert_real_eigenvalues", "1e-15"}}) + .real_eigenvalues(); + double min_ev = std::numeric_limits<double>::max(); + for (auto&& ev : evs) + if (std::abs(ev) > 1e-7) // TODO: find a better tolerance here! + min_ev = std::min(min_ev, ev); + // the smalles nonzero eigenvalue is (C_I / h)^2 + result = std::max(result, h * std::sqrt(min_ev)); + } + return result; +} // ... estimate_inverse_inequality_constant(...) + + +template <class GV, size_t r> +double estimate_combined_inverse_trace_inequality_constant(const SpaceInterface<GV, r>& space) +{ + DUNE_THROW_IF(!XT::Common::Lapacke::available(), XT::Common::Exceptions::dependency_missing, "lapacke"); + using E = XT::Grid::extract_entity_t<GV>; + using I = XT::Grid::extract_intersection_t<GV>; + double result = std::numeric_limits<double>::min(); + auto basis = space.basis().localize(); + for (auto&& element : elements(space.grid_view())) { + basis->bind(element); + const double h = XT::Grid::diameter(element); + XT::LA::CommonDenseMatrix<double> L2_face_product_matrix(basis->size(), basis->size(), 0.); + DynamicMatrix<double> tmp_L2_face_product_matrix(basis->size(), basis->size(), 0.); + for (auto&& intersection : intersections(space.grid_view(), element)) { + LocalIntersectionIntegralBilinearForm<I, r>(LocalIntersectionProductIntegrand<I, r>(1.)) + .apply2(intersection, *basis, *basis, tmp_L2_face_product_matrix); + for (size_t ii = 0; ii < basis->size(); ++ii) + for (size_t jj = 0; jj < basis->size(); ++jj) + L2_face_product_matrix.add_to_entry(ii, jj, tmp_L2_face_product_matrix[ii][jj]); + } + auto L2_element_product_matrix = XT::LA::convert_to<XT::LA::CommonDenseMatrix<double>>( + LocalElementIntegralBilinearForm<E, r>(LocalElementProductIntegrand<E, r>(1.)).apply2(*basis, *basis)); + auto evs = XT::LA::make_generalized_eigen_solver( + L2_face_product_matrix, + L2_element_product_matrix, + {{"type", XT::LA::generalized_eigen_solver_types(L2_face_product_matrix)[0]}, + {"compute_eigenvectors", "false"}, + {"assert_real_eigenvalues", "1e-15"}}) + .real_eigenvalues(); + double min_ev = std::numeric_limits<double>::max(); + for (auto&& ev : evs) + if (std::abs(ev) > 1e-7) // TODO: find a better tolerance here! + min_ev = std::min(min_ev, ev); + // the smalles nonzero eigenvalue is (C_M (1 + C_I)) / h + result = std::max(result, h * min_ev); + } + return result; +} // ... estimate_combined_inverse_trace_inequality_constant(...) + + +template <class GV> +double estimate_element_to_intersection_equivalence_constant( + const GridView<GV>& grid_view, + const std::function<double(const XT::Grid::extract_intersection_t<GridView<GV>>&)>& intersection_diameter = + [](const auto& intersection) { + if (GridView<GV>::dimension == 1) { + if (intersection.neighbor()) + return 0.5 * (XT::Grid::diameter(intersection.inside()) + XT::Grid::diameter(intersection.outside())); + else + return XT::Grid::diameter(intersection.inside()); + } else + return XT::Grid::diameter(intersection); + }) +{ + auto result = std::numeric_limits<double>::min(); + for (auto&& element : elements(grid_view)) { + const double h = XT::Grid::diameter(element); + for (auto&& intersection : intersections(grid_view, element)) + result = std::max(result, intersection_diameter(intersection) / h); + } + return result; +} // ... estimate_element_to_intersection_equivalence_constant(...) + + +} // namespace GDT +} // namespace Dune + +#endif // DUNE_GDT_TOOLS_GRID_QUALITY_ESTIMATES_HH diff --git a/dune/gdt/type_traits.hh b/dune/gdt/type_traits.hh index 64c8ff932fe5699ef704a8d4b8372c25eb197fe0..df9b0029907b3e2091369321d29b496e0f602fd6 100644 --- a/dune/gdt/type_traits.hh +++ b/dune/gdt/type_traits.hh @@ -23,6 +23,7 @@ namespace GDT { enum class SpaceType { + continuous_flattop, continuous_lagrange, discontinuous_lagrange, finite_volume, @@ -34,6 +35,8 @@ std::ostream& operator<<(std::ostream& out, const SpaceType& space_type) { if (space_type == SpaceType::continuous_lagrange) out << "continuous_lagrange"; + else if (space_type == SpaceType::continuous_flattop) + out << "continuous_flattop"; else if (space_type == SpaceType::discontinuous_lagrange) out << "discontinuous_lagrange"; else if (space_type == SpaceType::finite_volume) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d6c2495801cc689b95bc77bbe8d24a1dc6b2cea3..621f4703b6c18aed7895e6b518d8dfefb2bc4934 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -9,5 +9,5 @@ # René Fritze (2018) # ~~~ -add_subdirectory(dune/gdt) +add_subdirectory(dune) dxt_add_python_tests() diff --git a/python/dune/CMakeLists.txt b/python/dune/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..1cb4768f2890209df79dd24a2ec741b8af2444b0 --- /dev/null +++ b/python/dune/CMakeLists.txt @@ -0,0 +1,12 @@ +# ~~~ +# This file is part of the dune-gdt project: +# https://github.com/dune-community/dune-gdt +# Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +# or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +# with "runtime exception" (http://www.dune-project.org/license.html) +# Authors: +# René Fritze (2018) +# ~~~ + +add_subdirectory(gdt) diff --git a/python/dune/gdt/CMakeLists.txt b/python/dune/gdt/CMakeLists.txt index ce08e9c3b9bfc0d715d9fc392f0fbe6569e8274c..bc0b3d9b0afcd025b4068cf631d8c6534e23f9e3 100644 --- a/python/dune/gdt/CMakeLists.txt +++ b/python/dune/gdt/CMakeLists.txt @@ -18,3 +18,5 @@ dune_pybindxi_add_module(gamm_2019_talk_on_conservative_rb EXCLUDE_FROM_ALL ${header} gamm-2019-talk-on-conservative-rb.cc) + +add_subdirectory(discretefunction) diff --git a/python/dune/gdt/__init__.py b/python/dune/gdt/__init__.py index 490eb3d68cb8d4359a60cccc8adc148fbbeffa1d..dd488b5818436f31e623e01f9d34a37fdc13c6a7 100644 --- a/python/dune/gdt/__init__.py +++ b/python/dune/gdt/__init__.py @@ -9,94 +9,3 @@ # Felix Schindler (2017 - 2018) # René Fritze (2016, 2018) # ~~~ - -from importlib import import_module - -import numpy as np - -import dune.xt.common - -_init_logger_methods = list() -_test_logger_methods = list() -_init_mpi_methods = list() -_other_modules = ('xt.common', 'xt.grid', 'xt.functions', 'xt.la') - -_gdt_modules = () -# 'spaces_block', -# 'local_diffusive_flux_estimation_operator', -# 'local_elliptic_ipdg_operators', -# 'assembler', -# 'discretefunction', -# 'projections', -# 'functionals_elliptic_ipdg', -# 'functionals_l2', -# 'operators_elliptic', -# 'operators_elliptic_ipdg', -# 'operators_fluxreconstruction', -# 'operators_oswaldinterpolation', -# 'operators_ESV2007', -# 'operators_OS2015', -# 'operators_RS2017', -# 'operators_l2', -# 'operators_weighted_l2'] - -for module_name in _gdt_modules: - mod = import_module('.__{}'.format(module_name), 'dune.gdt') - to_import = [name for name in mod.__dict__ if not name.startswith('_')] - globals().update({name: mod.__dict__[name] for name in to_import}) - _init_logger_methods.append(mod.__dict__['_init_logger']) - _test_logger_methods.append(mod.__dict__['_test_logger']) - _init_mpi_methods.append(mod.__dict__['_init_mpi']) - -del _gdt_modules - - -def init_logger(max_info_level=999, - max_debug_level=999, - enable_warnings=True, - enable_colors=True, - info_color='blue', - debug_color='darkgray', - warning_color='red'): - init_logger_methods = _init_logger_methods.copy() - for module_name in _other_modules: - try: - mm = import_module('dune.{}'.format(module_name)) - for init_logger_method in mm._init_logger_methods: - init_logger_methods.append(init_logger_method) - except ModuleNotFoundError: - pass - for init_logger_method in init_logger_methods: - init_logger_method(max_info_level, max_debug_level, enable_warnings, enable_colors, info_color, debug_color, - warning_color) - - -def test_logger(info=True, debug=True, warning=True): - test_logger_methods = _test_logger_methods.copy() - for module_name in _other_modules: - try: - mm = import_module('dune.{}'.format(module_name)) - for test_logger_method in mm._test_logger_methods: - test_logger_methods.append(test_logger_method) - except ModuleNotFoundError: - pass - for test_logger_method in test_logger_methods: - test_logger_method(info, debug, warning) - - -def init_mpi(args=list()): - if DEBUG: - init_mpi_methods = [ - _init_mpi_methods[0], - ] - else: - init_mpi_methods = _init_mpi_methods.copy() - for module_name in _other_modules: - try: - mm = import_module('dune.{}'.format(module_name)) - for init_mpi_method in mm._init_mpi_methods: - init_mpi_methods.append(init_mpi_method) - except ModuleNotFoundError: - pass - for init_mpi_method in init_mpi_methods: - init_mpi_method(args) diff --git a/python/dune/gdt/assembler/system.cc b/python/dune/gdt/assembler/system.cc deleted file mode 100644 index 355bf905df55a86ad54d6698d2d90e1d9fb24048..0000000000000000000000000000000000000000 --- a/python/dune/gdt/assembler/system.cc +++ /dev/null @@ -1,54 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <python/dune/gdt/assembler/system.hh> -# include <python/dune/gdt/spaces/constraints.hh> - - -PYBIND11_MODULE(__assembler, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__local_elliptic_ipdg_operators"); - - py::class_<Dune::GDT::bindings::ResultStorage> ResultStorage(m, "ResultStorage", "dune-gdt: ResultStorage"); - ResultStorage.def(pybind11::init<>()); - ResultStorage.def_property( - "result", - [](const Dune::GDT::bindings::ResultStorage& self) { return self.result(); }, - [](Dune::GDT::bindings::ResultStorage& self, const double& value) { self.result() = value; }); - - DUNE_GDT_SPACES_CONSTRAINTS_BIND(m); - DUNE_GDT_ASSEMBLER_SYSTEM_BIND(m); - - add_initialization(m, "dune.gdt.assembler"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/assembler/system.hh b/python/dune/gdt/assembler/system.hh deleted file mode 100644 index db14a2f5c3fc3808bce918e7907cb75c2420f9e1..0000000000000000000000000000000000000000 --- a/python/dune/gdt/assembler/system.hh +++ /dev/null @@ -1,394 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_ASSEMBLER_SYSTEM_BINDINGS_HH -#define PYTHON_DUNE_GDT_ASSEMBLER_SYSTEM_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/common/memory.hh> -# include <dune/xt/la/container.hh> -# include <dune/xt/grid/grids.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/grid/layers.bindings.hh> -# include <dune/xt/grid/walker.hh> - -# include <python/dune/gdt/spaces/bindings.hh> -# include <python/dune/gdt/spaces/constraints.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/assembler/system.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -class ResultStorage -{ -public: - ResultStorage() - : result_(0.) - { - } - - ResultStorage(const ResultStorage& other) = delete; - ResultStorage(ResultStorage&& source) = delete; - - ResultStorage& operator=(const ResultStorage& other) = delete; - ResultStorage& operator=(ResultStorage&& source) = delete; - - double& result() - { - return result_; - } - - const double& result() const - { - return result_; - } - -private: - double result_; -}; // class ResultStorage - - -template <class TP, XT::Grid::Layers grid_layer, XT::Grid::Backends grid_backend> -class SystemAssembler -{ - typedef typename TP::type T; - static_assert(is_space<T>::value, ""); - typedef XT::Grid::extract_grid_t<typename T::GridLayerType> G; - typedef typename XT::Grid::Layer<G, grid_layer, grid_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - typedef XT::Grid::extract_entity_t<GL> E; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - -public: - typedef GDT::SystemAssembler<T, GL> type; - typedef pybind11::class_<type, XT::Grid::Walker<GL>> bound_type; - -private: - typedef typename type::TestSpaceType TestSpaceType; - typedef typename type::GridLayerType GridLayerType; - typedef typename type::AnsatzSpaceType AnsatzSpaceType; - - template <bool do_bind = (std::is_same<TestSpaceType, AnsatzSpaceType>::value - && std::is_same<GridLayerType, typename TestSpaceType::GridLayerType>::value), - bool anything = true> - struct addbind_ctor_single - { - void operator()(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - c.def(py::init<T>(), - "space"_a, - "Uses given space as test and ansatz space, and the grid layer of the given space as grid layer.", - py::keep_alive<1, 2>()); - } - }; // struct addbind_ctor_single - - template <bool anything> - struct addbind_ctor_single<false, anything> - { - void operator()(bound_type& /*c*/) - { - } - }; // struct addbind_ctor_single - - template <bool same = std::is_same<GL, typename T::GridLayerType>::value, bool anything = true> - struct space_and_layer_name - { - static std::string value() - { - return space_name<TP>::value(); - } - }; - - template <bool anything> - struct space_and_layer_name<false, anything> - { - static std::string value() - { - return space_name<TP>::value() + "_" + XT::Grid::bindings::layer_name<grid_layer>::value() + "_" - + XT::Grid::bindings::backend_name<grid_backend>::value(); - } - }; - - template <bool same = std::is_same<GL, typename T::GridLayerType>::value, bool anything = true> - struct addbind_factory_methods - { - void operator()(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - m.def("make_system_assembler", - [](const TestSpaceType& space) { return new type(space); }, - "space"_a, - py::keep_alive<0, 1>()); - } - }; - - template <bool anything> - struct addbind_factory_methods<false, anything> - { - void operator()(pybind11::module& /*m*/) - { - } - }; - - template <XT::LA::Backends la> - static void addaddbind_matrixatrix(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename XT::LA::Container<typename T::RangeFieldType, la>::MatrixType M; - - c.def("append", - [](type& self, - const GDT::LocalBoundaryTwoFormInterface<typename T::BaseFunctionSetType, - XT::Grid::extract_intersection_t<GL>>& local_boundary_two_form, - M& matrix, - const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections) { - self.append(local_boundary_two_form, matrix, which_intersections.copy()); - }, - "local_boundary_two_form"_a, - "matrix"_a, - "which_intersections"_a = XT::Grid::ApplyOn::AllIntersections<GL>(), - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - c.def("append", - [](type& self, - const GDT::LocalCouplingTwoFormInterface<typename T::BaseFunctionSetType, - XT::Grid::extract_intersection_t<GL>>& local_coupling_two_form, - M& matrix, - const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections) { - self.append(local_coupling_two_form, matrix, which_intersections.copy()); - }, - "local_coupling_two_form"_a, - "matrix"_a, - "which_intersections"_a = XT::Grid::ApplyOn::AllIntersections<GL>(), - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - c.def("append", - [](type& self, - const GDT::LocalCouplingTwoFormInterface<typename T::BaseFunctionSetType, - XT::Grid::extract_intersection_t<GL>>& local_coupling_two_form, - M& matrix_in_in, - M& matrix_out_out, - M& matrix_in_out, - M& matrix_out_in, - const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections) { - self.append(local_coupling_two_form, - matrix_in_in, - matrix_out_out, - matrix_in_out, - matrix_out_in, - which_intersections.copy()); - }, - "local_coupling_two_form"_a, - "matrix_in_in"_a, - "matrix_out_out"_a, - "matrix_in_out"_a, - "matrix_out_in"_a, - "which_intersections"_a = XT::Grid::ApplyOn::AllIntersections<GL>(), - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>(), - py::keep_alive<0, 5>()); - } // ... addaddbind_matrixatrix(...) - -public: - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = - XT::Common::to_camel_case(std::string("system_assembler_") + space_and_layer_name<>::value()); - - bound_type c(m, ClassName.c_str(), ClassName.c_str()); - addbind_ctor_single<>()(c); - - c.def("append", - [](type& self, type& other, const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections) { - self.append(other, which_intersections.copy()); - }, - "system_assembler"_a, - "which_intersections"_a = XT::Grid::ApplyOn::AllIntersections<GL>(), - py::keep_alive<1, 2>()); - c.def("append", - [](type& self, - XT::Grid::Walker<GridLayerType>& other, - const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections) { - self.append(other, which_intersections.copy()); - }, - "grid_walker"_a, - "which_intersections"_a = XT::Grid::ApplyOn::AllIntersections<GL>(), - py::keep_alive<1, 2>()); - c.def("assemble", - [](type& self, const bool use_tbb) { - py::gil_scoped_release DUNE_UNUSED(release); - self.assemble(use_tbb); - }, - "use_tbb"_a = false); - - bindings::DirichletConstraints<XT::Grid::extract_intersection_t<typename type::GridLayerType>, - XT::Grid::extract_grid_t<typename type::GridLayerType>>::addbind(c); - -# if HAVE_DUNE_ISTL - addaddbind_matrixatrix<XT::LA::Backends::istl_sparse>(c); -# endif - - c.def("append", - [](type& self, - const GDT::LocalVolumeTwoFormInterface<XT::Functions::LocalfunctionInterface<E, D, d, double, 1>, - XT::Functions::LocalfunctionInterface<E, D, d, double, 1>, - double>& local_volume_two_form, - const XT::Functions::GridFunctionInterface<E, D, d, double, 1>& test_function, - const XT::Functions::GridFunctionInterface<E, D, d, double, 1>& ansatz_function, - ResultStorage& result /*, - const XT::Grid::ApplyOn::WhichEntity<GL>& where*/) { - self.append(local_volume_two_form, test_function, ansatz_function, result.result() /*, where.copy()*/); - }, - "local_volume_two_form"_a, - "test_function"_a, - "ansatz_function"_a, - "result"_a /*, - "where"_a = XT::Grid::ApplyOn::AllEntities<GL>()*/, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - addbind_factory_methods<>()(m); - - return c; - } // ... bind(...) -}; // class SystemAssembler - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the lib - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB( \ - _pre, _G, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - _pre class Dune::GDT::bindings::SystemAssembler<Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_s_grid_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend> - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU_SPACE( \ - _pre, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB( \ - _pre, ALU_2D_SIMPLEX_CONFORMING, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) -# else -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU_SPACE( \ - _pre, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) -# endif - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP_SPACE( \ - _pre, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB( \ - _pre, YASP_1D_EQUIDISTANT_OFFSET, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB( \ - _pre, YASP_2D_EQUIDISTANT_OFFSET, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU(_pre, _s_type, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU_SPACE(_pre, leaf, view, _s_type, gdt, leaf, _p, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU_SPACE(_pre, level, view, _s_type, gdt, level, _p, 1, 1) - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP(_pre, _s_type, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP_SPACE(_pre, leaf, view, _s_type, gdt, leaf, _p, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP_SPACE(_pre, level, view, _s_type, gdt, level, _p, 1, 1) - -# define DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU(_pre) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU(_pre, fv, 0, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU(_pre, cg, 1, 1, 1) - -# define DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP(_pre) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP(_pre, fv, 0, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP(_pre, cg, 1, 1, 1) - -# define DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB(_pre) \ - DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU(_pre); \ - DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP(_pre) - -DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB(extern template); - -// end: this is what we need for the lib -// begin: this is what we need for the .so - - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND( \ - _m, _G, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - Dune::GDT::bindings::SystemAssembler<Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_s_grid_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend>::bind(_m) - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_YASP( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND( \ - _m, YASP_1D_EQUIDISTANT_OFFSET, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND( \ - _m, YASP_2D_EQUIDISTANT_OFFSET, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALU( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND( \ - _m, ALU_2D_SIMPLEX_CONFORMING, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) -# else -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALU( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) -# endif - -# define _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_YASP(_m, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALU(_m, _g_layer, _g_backend, _s_type, _s_backend, _s_grid_layer, _p, _r, _rC) - - -# define DUNE_GDT_ASSEMBLER_SYSTEM_BIND(_m) \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS(_m, dd_subdomain_boundary, view, dg, gdt, dd_subdomain, 1, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS(_m, dd_subdomain_coupling, view, dg, gdt, dd_subdomain, 1, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS(_m, leaf, view, cg, gdt, leaf, 1, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS(_m, level, view, cg, gdt, level, 1, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS(_m, leaf, view, fv, gdt, leaf, 0, 1, 1); \ - _DUNE_GDT_ASSEMBLER_SYSTEM_BIND_ALL_GRIDS(_m, level, view, fv, gdt, level, 0, 1, 1) -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_ASSEMBLER_SYSTEM_BINDINGS_HH diff --git a/python/dune/gdt/assembler/system/alu.cc b/python/dune/gdt/assembler/system/alu.cc deleted file mode 100644 index 68a3a27f8910bab9a5b4dc09705cd39bfe3acdf1..0000000000000000000000000000000000000000 --- a/python/dune/gdt/assembler/system/alu.cc +++ /dev/null @@ -1,30 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI && HAVE_DUNE_ALUGRID - -# include "../system.hh" - - -namespace Dune { -namespace GDT { -namespace bindings { - - -DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_ALU(template); - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI && HAVE_DUNE_ALUGRID diff --git a/python/dune/gdt/assembler/system/yasp.cc b/python/dune/gdt/assembler/system/yasp.cc deleted file mode 100644 index 0b1360bfbc0770a963157e1ccd05953a97e5af37..0000000000000000000000000000000000000000 --- a/python/dune/gdt/assembler/system/yasp.cc +++ /dev/null @@ -1,30 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include "../system.hh" - - -namespace Dune { -namespace GDT { -namespace bindings { - - -DUNE_GDT_ASSEMBLER_SYSTEM_BIND_LIB_YASP(template); - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/discretefunction/CMakeLists.txt b/python/dune/gdt/discretefunction/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..41c2d4c1724a55a3b58e79d73d751bcce82957c3 --- /dev/null +++ b/python/dune/gdt/discretefunction/CMakeLists.txt @@ -0,0 +1,16 @@ +# ~~~ +# This file is part of the dune-gdt project: +# https://github.com/dune-community/dune-gdt +# Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +# or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +# with "runtime exception" (http://www.dune-project.org/license.html) +# Authors: +# Felix Schindler (2018) +# René Fritze (2018) +# Tobias Leibner (2018) +# ~~~ + +dune_pybindxi_add_module(_discretefunction_1d EXCLUDE_FROM_ALL ${header} discretefunction_1d.cc) +dune_pybindxi_add_module(_discretefunction_2d EXCLUDE_FROM_ALL ${header} discretefunction_2d.cc) +dune_pybindxi_add_module(_discretefunction_3d EXCLUDE_FROM_ALL ${header} discretefunction_3d.cc) diff --git a/python/dune/gdt/discretefunction/__init__.py b/python/dune/gdt/discretefunction/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..c2b7cd23b3dfd3bdaf597501c2a446b978a24d73 --- /dev/null +++ b/python/dune/gdt/discretefunction/__init__.py @@ -0,0 +1,26 @@ +# ~~~ +# This file is part of the dune-xt-grid project: +# https://github.com/dune-community/dune-xt-grid +# Copyright 2009-2018 dune-xt-grid developers and contributors. All rights reserved. +# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +# or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +# with "runtime exception" (http://www.dune-project.org/license.html) +# Authors: +# Felix Schindler (2017) +# René Fritze (2018) +# ~~~ + +from dune.xt import guarded_import + +from ._discretefunction_1d import * +from ._discretefunction_2d import * +from ._discretefunction_3d import * + + +def make_discrete_function(space, vector, name="dune.gdt.discretefunction"): + for factory in [globals()[s] for s in globals().keys() if s.startswith('make_discrete_function_')]: + try: + return factory(space, vector, name) + except: + continue + raise TypeError('no matching factory for space \'{}\''.format(space)) diff --git a/python/dune/gdt/discretefunction/bindings.cc b/python/dune/gdt/discretefunction/bindings.cc deleted file mode 100644 index bfd4e85733ed5b6e3a7e2d643c7a2ca5485a9e58..0000000000000000000000000000000000000000 --- a/python/dune/gdt/discretefunction/bindings.cc +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> - -# include <python/dune/gdt/discretefunction/bindings.hh> -# include <python/dune/gdt/shared.hh> - -PYBIND11_MODULE(__discretefunction, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__spaces_block"); - - DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND(m); - - add_initialization(m, "dune.gdt.discretefunction"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/discretefunction/bindings.hh b/python/dune/gdt/discretefunction/bindings.hh deleted file mode 100644 index 9bf2d74d03bad7014c8d43996d9297a9935a418d..0000000000000000000000000000000000000000 --- a/python/dune/gdt/discretefunction/bindings.hh +++ /dev/null @@ -1,330 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH -#define PYTHON_DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <python/dune/xt/common/bindings.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/layers.hh> -# include <dune/xt/la/type_traits.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/playground/spaces/block.hh> -# include <dune/gdt/playground/spaces/restricted.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/discretefunction/default.hh> - -namespace Dune { -namespace GDT { -namespace bindings { -namespace internal { - - -template <class S, class V> -class ConstDiscreteFunction -{ - static_assert(is_space<S>::value, ""); - static_assert(XT::LA::is_vector<V>::value, ""); - typedef XT::Grid::extract_grid_t<typename S::GridLayerType> G; - -public: - typedef GDT::ConstDiscreteFunction<S, V> type; - -private: - typedef XT::Functions::GridFunctionInterface<typename S::EntityType, - typename S::DomainFieldType, - S::dimDomain, - typename S::RangeFieldType, - S::dimRange, - S::dimRangeCols> - BaseType; - -public: - typedef pybind11::class_<type, BaseType> bound_type; - - static bound_type bind(pybind11::module& m, const std::string& space_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case("const_discrete_function_" + space_name + "_" - + XT::LA::bindings::container_name<V>::value()); - - bound_type c(m, ClassName.c_str(), ClassName.c_str()); - c.def(py::init<const S&, V&, const std::string>(), - "space"_a, - "vector"_a, - "name"_a = "gdt.constdiscretefunction", - py::keep_alive<1, 2>(), - py::keep_alive<1, 3>()); - c.def("space", [](type& self) { return self.space(); }); - c.def("vector_copy", [](type& self) { return self.vector(); }); - c.def("visualize", - [](type& self, const std::string filename, const bool subsampling) { - return self.visualize(filename, subsampling); - }, - "filename"_a, - "subsampling"_a = (S::polOrder > 1)); - // these two are copied from <dune/xt/functions/interfaces.pbh>, would be nicer to inherit them - c.def("visualize", - [](const type& self, - const XT::Grid::GridProvider<G>& grid_provider, - const std::string& layer, - const ssize_t lvl, - const std::string& path, - const bool subsampling) { - const auto level = XT::Common::numeric_cast<int>(lvl); - if (layer == "leaf") - self.visualize(grid_provider.leaf_view(), path, subsampling); - else if (layer == "level") - self.visualize(grid_provider.template layer<XT::Grid::Layers::level, XT::Grid::Backends::view>(level), - path, - subsampling); - else - DUNE_THROW(XT::Common::Exceptions::wrong_input_given, - "Given layer has to be one of ('leaf', 'level'), is '" << layer << "'!"); - }, - "grid_provider"_a, - "layer"_a = "leaf", - "level"_a = -1, - "path"_a, - "subsampling"_a = true); - c.def("visualize", - [](const type& self, - const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const std::string& layer, - const ssize_t lvl_or_sbdmn, - const std::string& path, - const bool subsampling) { - const auto level_or_subdomain = XT::Common::numeric_cast<int>(lvl_or_sbdmn); - if (layer == "leaf") - self.visualize(dd_grid_provider.leaf_view(), path, subsampling); - else if (layer == "level") - self.visualize(dd_grid_provider.template layer<XT::Grid::Layers::level, XT::Grid::Backends::view>( - level_or_subdomain), - path, - subsampling); - else if (layer == "dd_subdomain") - self.visualize(dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - level_or_subdomain), - path, - subsampling); - else if (layer == "dd_subdomain_oversampled") - self.visualize( - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - level_or_subdomain), - path, - subsampling); - else - DUNE_THROW( - XT::Common::Exceptions::wrong_input_given, - "Given layer has to be one of ('leaf', 'level', 'dd_subdomain', 'dd_subdomain_oversampled'), is '" - << layer - << "'!"); - }, - "dd_grid_provider"_a, - "layer"_a = "leaf", - "level_or_subdomain"_a = -1, - "path"_a, - "subsampling"_a = true); - return c; - } // ... bind(...) -}; // class ConstDiscreteFunction - - -template <class S, class V> -class DiscreteFunction -{ - static_assert(is_space<S>::value, ""); - static_assert(XT::LA::is_vector<V>::value, ""); - - typedef GDT::ConstDiscreteFunction<S, V> BaseType; - -public: - typedef GDT::DiscreteFunction<S, V> type; - typedef pybind11::class_<type, BaseType> bound_type; - - static bound_type bind(pybind11::module& m, const std::string& space_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - - bindings::internal::ConstDiscreteFunction<S, V>::bind(m, space_name); - - const auto ClassName = XT::Common::to_camel_case("discrete_function_" + space_name + "_" - + XT::LA::bindings::container_name<V>::value()); - - bound_type c(m, ClassName.c_str(), ClassName.c_str()); - c.def(py::init<const S&, V&, const std::string>(), - "space"_a, - "vector"_a, - "name"_a = "gdt.discretefunction", - py::keep_alive<1, 2>(), - py::keep_alive<1, 3>()); - c.def( - py::init<const S&, const std::string>(), "space"_a, "name"_a = "gdt.discretefunction", py::keep_alive<1, 2>()); - - m.def( - std::string("make_discrete_function").c_str(), - [](const S& space, V& vector, const std::string& name) { return make_discrete_function(space, vector, name); }, - "space"_a, - "vector"_a, - "name"_a = "gdt.discretefunction", - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - m.def(std::string("make_discrete_function").c_str(), - [](const S& space, const std::string& name) { return make_discrete_function<V>(space, name); }, - "space"_a, - "name"_a = "gdt.discretefunction", - py::keep_alive<0, 1>()); - - return c; - } // ... bind(...) - -}; // class DiscreteFunction - - -} // namespace internal - - -template <class SP, class V> -class DiscreteFunction -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - static_assert(XT::LA::is_vector<V>::value, ""); - typedef GDT::ConstDiscreteFunction<S, V> BaseType; - -public: - typedef GDT::DiscreteFunction<S, V> type; - typedef pybind11::class_<type, BaseType> bound_type; - - template <XT::Grid::Backends backend, XT::Grid::Layers layer> - static void addbind_restricted(pybind11::module& m, const std::string sp_name) - { - try { // we might not be the first to add this - internal::DiscreteFunction<GDT::RestrictedSpace<S, - typename XT::Grid:: - Layer<XT::Grid::extract_grid_t<typename S::GridLayerType>, - layer, - backend>::type>, - V>::bind(m, - sp_name + "_restricted_to_" + XT::Grid::bindings::layer_name<layer>::value() - + "_" - + XT::Grid::bindings::backend_name<backend>::value()); - } catch (std::runtime_error&) { - } - } // ... addbind_restricted(...) - - static bound_type bind(pybind11::module& m) - { - const auto sp_name = space_name<SP>::value(); - auto c = internal::DiscreteFunction<S, V>::bind(m, sp_name); - - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain>(m, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain_boundary>(m, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain_coupling>(m, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain_oversampled>(m, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::leaf>(m, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::level>(m, sp_name); - - return c; - } -}; // class DiscreteFunction - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the .so - - -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC, _la) \ - Dune::GDT::bindings::DiscreteFunction< \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - _r, \ - _rC>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m) - -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_COMMON(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC, common_dense) - -# if HAVE_EIGEN -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_EIGEN(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC, eigen_dense) -# else -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_EIGEN(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) -# endif - -# if HAVE_DUNE_ISTL -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ISTL(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC, istl_dense) -# else -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ISTL(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) -# endif - -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_LA(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_COMMON(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_EIGEN(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ISTL(_m, _G, _g_layer, _s_type, _s_backend, _p, _r, _rC) - -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_YASP(_m, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_LA( \ - _m, YASP_1D_EQUIDISTANT_OFFSET, _g_layer, _s_type, _s_backend, _p, _r, _rC); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_LA( \ - _m, YASP_2D_EQUIDISTANT_OFFSET, _g_layer, _s_type, _s_backend, _p, _r, _rC) - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALU(_m, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_LA( \ - _m, ALU_2D_SIMPLEX_CONFORMING, _g_layer, _s_type, _s_backend, _p, _r, _rC) -# else -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALU(_m, _g_layer, _s_type, _s_backend, _p, _r, _rC) -# endif - -# define _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, _g_layer, _s_type, _s_backend, _p, _r, _rC) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_YASP(_m, _g_layer, _s_type, _s_backend, _p, _r, _rC); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALU(_m, _g_layer, _s_type, _s_backend, _p, _r, _rC) - -# define DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND(_m) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, leaf, dg, gdt, 1, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, level, dg, gdt, 1, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, leaf, fv, gdt, 0, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, level, fv, gdt, 0, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, leaf, cg, gdt, 1, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, level, cg, gdt, 1, 1, 1); - -# define DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_DD(_m) \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, dd_subdomain, dg, gdt, 1, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, dd_subdomain, block_dg, gdt, 1, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, dd_subdomain, cg, gdt, 1, 1, 1); \ - _DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_ALL_GRIDS(_m, dd_subdomain, block_cg, gdt, 1, 1, 1); - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH diff --git a/python/dune/gdt/discretefunction/discretefunction.hh b/python/dune/gdt/discretefunction/discretefunction.hh new file mode 100644 index 0000000000000000000000000000000000000000..76542869ce333cfdeeb31cb5542415cec2a136fd --- /dev/null +++ b/python/dune/gdt/discretefunction/discretefunction.hh @@ -0,0 +1,165 @@ +// This file is part of the dune-gdt project: +// https://github.com/dune-community/dune-gdt +// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. +// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) +// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) +// with "runtime exception" (http://www.dune-project.org/license.html) +// Authors: +// Felix Schindler (2017 - 2018) +// René Fritze (2018) +// Tobias Leibner (2018) + +#ifndef PYTHON_DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH +#define PYTHON_DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH + +#if HAVE_DUNE_PYBINDXI + +# include <dune/pybindxi/pybind11.h> + +# include <python/dune/xt/common/exceptions.bindings.hh> +# include <python/dune/xt/la/container.bindings.hh> +# include <python/dune/xt/grid/grids.bindings.hh> +# include <python/dune/xt/functions/gridfunction-interface.hh> + +# include <dune/xt/common/python.hh> +# include <dune/xt/common/string.hh> +# include <dune/xt/la/container.hh> +# include <dune/xt/grid/grids.hh> +# include <dune/xt/grid/type_traits.hh> +# include <dune/xt/functions/interfaces/grid-function.hh> + +# include <dune/gdt/discretefunction/default.hh> + +namespace Dune { +namespace GDT { +namespace bindings { + + +template <class V, class GV, size_t r = 1, size_t rC = 1, class R = double> +class DiscreteFunction +{ +public: + using type = GDT::DiscreteFunction<V, GV, r, rC, R>; + using base_type = XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<GV>, r, rC, R>; + using bound_type = pybind11::class_<type, base_type>; + + static bound_type bind(pybind11::module& m) + { + namespace py = pybind11; + using namespace pybind11::literals; + using G = typename GV::Grid; + using S = typename type::SpaceType; + + // base_type + const auto grid_name = XT::Grid::bindings::grid_name<G>::value(); + if (std::is_same<R, double>::value) + XT::Common::bindings::guarded_bind( + [&]() { XT::Functions::bindings::bind_GridFunctionInterface<G, r, rC>(m, grid_name); }); + + // type + std::string class_name = "discrete_function_" + grid_name; + if (r > 1) + class_name += "_to" + XT::Common::to_string(r); + if (rC > 1) + class_name += "x" + XT::Common::to_string(rC); + class_name += "_" + XT::LA::bindings::container_name<V>::value(); + class_name = XT::Common::to_camel_case(class_name); + const std::string default_name = "dune.gdt.discretefunction"; + bound_type c(m, XT::Common::to_camel_case(class_name).c_str(), XT::Common::to_camel_case(class_name).c_str()); + c.def(py::init<const S&, V&, const std::string&>(), + "space"_a, + "vector"_a, + "name"_a = default_name, + py::keep_alive<1, 2>(), + py::keep_alive<1, 3>()); + c.def(py::init<const S&, const std::string&>(), "space"_a, "name"_a = default_name, py::keep_alive<1, 2>()); + c.def_property_readonly("space", &type::space); + c.def_property("dof_vector", + [](const type& self) { return self.dofs().vector(); }, + [](type& self, const V& vec) { + DUNE_THROW_IF(vec.size() != self.dofs().vector().size(), + Exceptions::discrete_function_error, + "vec.size() = " << vec.size() << "\n self.dofs().vector().size() = " + << self.dofs().vector().size()); + self.dofs().vector() = vec; + }, + py::return_value_policy::reference_internal); + c.def_property_readonly("name", &type::name); + c.def("visualize", + [](type& self, const std::string& filename) { return self.visualize(filename, VTK::appendedraw); }, + "filename"_a); + + // factory + const std::string factory_name = "make_" + class_name; + m.def( + factory_name.c_str(), + [](const S& space, V& vector, const std::string& name) { return make_discrete_function(space, vector, name); }, + "space"_a, + "vector"_a, + "name"_a = default_name, + py::keep_alive<0, 1>(), + py::keep_alive<0, 2>()); + m.def(factory_name.c_str(), + [](const S& space, const std::string& name) { return make_discrete_function<V>(space, name); }, + "space"_a, + "name"_a = default_name, + py::keep_alive<0, 1>()); + + return c; + } // ... bind(...) +}; // class DiscreteFunction + + +template <class V, class GridTypes = Dune::XT::Grid::AvailableGridTypes> +struct DiscreteFunction_for_all_grids +{ + using G = typename GridTypes::head_type; + using GV = typename G::LeafGridView; + static const constexpr size_t d = G::dimension; + + static void bind(pybind11::module& m) + { + Dune::GDT::bindings::DiscreteFunction<V, GV>::bind(m); + if (d > 1) + Dune::GDT::bindings::DiscreteFunction<V, GV, d>::bind(m); + // add your extra dimensions here + // ... + DiscreteFunction_for_all_grids<V, typename GridTypes::tail_type>::bind(m); + } +}; + +template <class V> +struct DiscreteFunction_for_all_grids<V, boost::tuples::null_type> +{ + static void bind(pybind11::module& /*m*/) {} +}; + + +template <class VectorTypes = Dune::XT::LA::AvailableVectorTypes<double>, + class GridTypes = Dune::XT::Grid::AvailableGridTypes> +struct DiscreteFunction_for_all_vectors_and_grids + +{ + static void bind(pybind11::module& m) + { + using V = typename VectorTypes::head_type; + DiscreteFunction_for_all_grids<V, GridTypes>::bind(m); + DiscreteFunction_for_all_vectors_and_grids<typename VectorTypes::tail_type, GridTypes>::bind(m); + } +}; + +template <class GridTypes> +struct DiscreteFunction_for_all_vectors_and_grids<boost::tuples::null_type, GridTypes> +{ + static void bind(pybind11::module&) {} +}; + + +} // namespace bindings +} // namespace GDT +} // namespace Dune + + +#endif // HAVE_DUNE_PYBINDXI + +#endif // PYTHON_DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH diff --git a/python/dune/gdt/playground/spaces/block.cc b/python/dune/gdt/discretefunction/discretefunction_1d.cc similarity index 56% rename from python/dune/gdt/playground/spaces/block.cc rename to python/dune/gdt/discretefunction/discretefunction_1d.cc index bc8c22ea76a6b05e4acec36e53bef9d86d1c5e40..5e309a5bea0d0b6d9a4f97faa8e534a0e97a70f3 100644 --- a/python/dune/gdt/playground/spaces/block.cc +++ b/python/dune/gdt/discretefunction/discretefunction_1d.cc @@ -5,40 +5,30 @@ // or GPL-2.0+ (http://opensource.org/licenses/gpl-license) // with "runtime exception" (http://www.dune-project.org/license.html) // Authors: -// Felix Schindler (2017) -// René Fritze (2018) +// Felix Schindler (2019) #include "config.h" #if HAVE_DUNE_PYBINDXI -# include <dune/common/parallel/mpihelper.hh> +# include "discretefunction.hh" -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include "block.hh" - - -PYBIND11_MODULE(__spaces_block, m) +PYBIND11_MODULE(_discretefunction_1d, m) { namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); + using namespace Dune; + using namespace Dune::XT; + using namespace Dune::GDT; py::module::import("dune.xt.common"); + py::module::import("dune.xt.la"); py::module::import("dune.xt.grid"); py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - DUNE_GDT_SPACES_BLOCK_BIND(m); - - add_initialization(m, "dune.gdt.spaces.block"); + bindings::DiscreteFunction_for_all_vectors_and_grids<LA::AvailableVectorTypes<double>, + XT::Grid::Available1dGridTypes>::bind(m); } + #endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/spaces/bindings.cc b/python/dune/gdt/discretefunction/discretefunction_2d.cc similarity index 54% rename from python/dune/gdt/spaces/bindings.cc rename to python/dune/gdt/discretefunction/discretefunction_2d.cc index dcf57a1db6e1a68fd3931aed913013ee0e9d7f61..ba3c7d6539811db974a33492d8101d79ca1d14c8 100644 --- a/python/dune/gdt/spaces/bindings.cc +++ b/python/dune/gdt/discretefunction/discretefunction_2d.cc @@ -5,42 +5,30 @@ // or GPL-2.0+ (http://opensource.org/licenses/gpl-license) // with "runtime exception" (http://www.dune-project.org/license.html) // Authors: -// Felix Schindler (2017) -// René Fritze (2018) +// Felix Schindler (2019) #include "config.h" #if HAVE_DUNE_PYBINDXI -# include <dune/common/parallel/mpihelper.hh> +# include "discretefunction.hh" -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include "bindings.hh" - - -PYBIND11_MODULE(__spaces, m) +PYBIND11_MODULE(_discretefunction_2d, m) { namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); + using namespace Dune; + using namespace Dune::XT; + using namespace Dune::GDT; py::module::import("dune.xt.common"); + py::module::import("dune.xt.la"); py::module::import("dune.xt.grid"); py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - DUNE_GDT_SPACES_CG_BIND(m); - DUNE_GDT_SPACES_DG_BIND(m); - DUNE_GDT_SPACES_FV_BIND(m); - DUNE_GDT_SPACES_RT_BIND(m); - - add_initialization(m, "dune.gdt.spaces"); + bindings::DiscreteFunction_for_all_vectors_and_grids<LA::AvailableVectorTypes<double>, + XT::Grid::Available2dGridTypes>::bind(m); } + #endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/local/diffusive-flux-estimation-operator.cc b/python/dune/gdt/discretefunction/discretefunction_3d.cc similarity index 54% rename from python/dune/gdt/local/diffusive-flux-estimation-operator.cc rename to python/dune/gdt/discretefunction/discretefunction_3d.cc index 2b3d7312fc3563ceb04ea8a75357ebc8aabb85fb..449d8b298f5734d092439faa4e41f6ca01b0f3ab 100644 --- a/python/dune/gdt/local/diffusive-flux-estimation-operator.cc +++ b/python/dune/gdt/discretefunction/discretefunction_3d.cc @@ -5,39 +5,30 @@ // or GPL-2.0+ (http://opensource.org/licenses/gpl-license) // with "runtime exception" (http://www.dune-project.org/license.html) // Authors: -// Felix Schindler (2017) -// René Fritze (2018) +// Felix Schindler (2019) #include "config.h" #if HAVE_DUNE_PYBINDXI -# include <dune/common/parallel/mpihelper.hh> +# include "discretefunction.hh" -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include "diffusive-flux-estimation-operator.hh" - - -PYBIND11_MODULE(__local_diffusive_flux_estimation_operator, m) +PYBIND11_MODULE(_discretefunction_3d, m) { namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); + using namespace Dune; + using namespace Dune::XT; + using namespace Dune::GDT; py::module::import("dune.xt.common"); + py::module::import("dune.xt.la"); py::module::import("dune.xt.grid"); py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND(m); - - add_initialization(m, "dune.gdt.assembler"); + bindings::DiscreteFunction_for_all_vectors_and_grids<LA::AvailableVectorTypes<double>, + XT::Grid::Available3dGridTypes>::bind(m); } + #endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/functionals/base.hh b/python/dune/gdt/functionals/base.hh deleted file mode 100644 index c527d78461394917deee63b9cfce0b16ed3bfd90..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/base.hh +++ /dev/null @@ -1,64 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_FUNCTIONALS_BASE_BINDINGS_H -#define PYTHON_DUNE_GDT_FUNCTIONALS_BASE_BINDINGS_H - -// Todo: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/la/container.hh> - -# include <dune/gdt/assembler/system.hh> -# include <dune/gdt/discretefunction/default.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class FunctionalType> -class VectorFunctionalBase -{ -public: - typedef FunctionalType type; - typedef GDT::SystemAssembler<typename FunctionalType::SpaceType, typename FunctionalType::GridLayerType> BaseType; - typedef pybind11::class_<type, BaseType> bound_type; - - static bound_type bind(pybind11::module& m, const std::string& class_id) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename type::SpaceType S; - typedef typename type::VectorType V; - - bound_type c(m, std::string(class_id).c_str(), std::string(class_id).c_str()); - - c.def("vector", [](type& self) { return self.vector(); }); - c.def("space", [](type& self) { return self.space(); }); - c.def("apply", [](type& self, const V& source) { return self.apply(source); }, "source"_a); - c.def( - "apply", [](type& self, const ConstDiscreteFunction<S, V>& source) { return self.apply(source); }, "source"_a); - - return c; - } // ... bind(...) -}; // class VectorFunctionalBase - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_FUNCTIONALS_BASE_BINDINGS_H diff --git a/python/dune/gdt/functionals/elliptic-ipdg/alu_istl.cc b/python/dune/gdt/functionals/elliptic-ipdg/alu_istl.cc deleted file mode 100644 index 5e99d2925c569095819bd4a9edbb27978ac83a9e..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/elliptic-ipdg/alu_istl.cc +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/functionals/elliptic-ipdg/bindings.hh> - - -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(template, leaf, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(template, level, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(template, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# endif - - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/functionals/elliptic-ipdg/bindings.cc b/python/dune/gdt/functionals/elliptic-ipdg/bindings.cc deleted file mode 100644 index 4dd5054ee945dd7b9fd08e3e8041c32f55ad042f..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/elliptic-ipdg/bindings.cc +++ /dev/null @@ -1,56 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <python/dune/gdt/functionals/elliptic-ipdg/bindings.hh> - - -PYBIND11_MODULE(__functionals_elliptic_ipdg, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - -// alu_istl.cc -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALU(m, leaf, view, dg, gdt, 1, istl_dense); - DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALU(m, level, view, dg, gdt, 1, istl_dense); - DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALU(m, dd_subdomain, view, dg, gdt, 1, istl_dense); -# endif - -// yasp_istl.cc -# if HAVE_DUNE_ISTL - DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_YASP(m, leaf, view, dg, gdt, 1, istl_dense); - DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_YASP(m, level, view, dg, gdt, 1, istl_dense); - DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_YASP(m, dd_subdomain, view, dg, gdt, 1, istl_dense); -# endif - - add_initialization(m, "dune.gdt.functionals.elliptic-ipdg"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/functionals/elliptic-ipdg/bindings.hh b/python/dune/gdt/functionals/elliptic-ipdg/bindings.hh deleted file mode 100644 index bc329aa457d6e9497aebcdc5926c448c732f9090..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/elliptic-ipdg/bindings.hh +++ /dev/null @@ -1,728 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BINDINGS_HH -#define PYTHON_DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/grid/type_traits.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/functionals/elliptic-ipdg.hh> -# include <python/dune/gdt/functionals/base.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class DI, - class DF, - typename DT, // may be void - class SP, - LocalEllipticIpdgIntegrands::Method method, - class V /* = typename XT::LA::Container<typename R::RangeFieldType>::VectorType, - class GL = typename RP::type::GridLayerType, - class F = typename RP::type::RangeFieldType*/> -class EllipticIpdgDirichletVectorFunctional -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - -public: - typedef GDT::EllipticIpdgDirichletVectorFunctional<DI, DF, DT, S, method, V /*, GL, F*/> type; - typedef pybind11::class_<type> bound_type; - -private: - template <bool single_diffusion = std::is_same<DT, void>::value, - bool scalar = (DF::dimRange == 1 && DF::dimRangeCols == 1), - bool anything = false> - struct diffusion_switch - { - static std::string suffix() - { - return "diffusion_factor_and_tensor"; - } - - template <class C> - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto method_name = - "make_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_dirichlet_vector_functional"; - - m.def( - std::string(method_name + "_" + XT::LA::bindings::container_name<V>::value()).c_str(), - [](const DI& dirichlet, - const DF& diffusion_factor, - const DT& diffusion_tensor, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename S::GridLayerType>>& boundary_info, - const S& space, - const size_t over_integrate) { - return make_elliptic_ipdg_dirichlet_vector_functional<V, method>( - dirichlet, diffusion_factor, diffusion_tensor, boundary_info, space, over_integrate) - .release(); // <- b.c. EllipticIpdgDirichletVectorFunctional is not movable, returning the raw pointer - }, // lets pybind11 correctly manage the memory - "dirichlet"_a, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "boundary_info"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>(), - py::keep_alive<0, 5>()); - - m.def( - method_name.c_str(), - [](const DI& dirichlet, - const DF& diffusion_factor, - const DT& diffusion_tensor, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename S::GridLayerType>>& boundary_info, - V& vector, - const S& space, - const size_t over_integrate) { - return make_elliptic_ipdg_dirichlet_vector_functional<method>( - dirichlet, diffusion_factor, diffusion_tensor, boundary_info, vector, space, over_integrate) - .release(); // <- s.a. for release() - }, - "dirichlet"_a, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "boundary_info"_a, - "vector"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>(), - py::keep_alive<0, 5>(), - py::keep_alive<0, 6>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch - - struct diffusion_switch_scalar_base - { - template <class C> - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto method_name = - "make_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_dirichlet_vector_functional"; - - m.def( - std::string(method_name + "_" + XT::LA::bindings::container_name<V>::value()).c_str(), - [](const DI& dirichlet, - const DF& diffusion, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename S::GridLayerType>>& boundary_info, - const S& space, - const size_t over_integrate) { - return make_elliptic_ipdg_dirichlet_vector_functional<V, method>( - dirichlet, diffusion, boundary_info, space, over_integrate) - .release(); // <- b.c. EllipticIpdgDirichletVectorFunctional is not movable, returning the raw pointer - }, // lets pybind11 correctly manage the memory - "dirichlet"_a, - "diffusion"_a, - "boundary_info"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>()); - - m.def( - method_name.c_str(), - [](const DI& dirichlet, - const DF& diffusion, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename S::GridLayerType>>& boundary_info, - V& vector, - const S& space, - const size_t over_integrate) { - return make_elliptic_ipdg_dirichlet_vector_functional<method>( - dirichlet, diffusion, boundary_info, vector, space, over_integrate) - .release(); // <- s.a. for release() - }, - "dirichlet"_a, - "diffusion"_a, - "boundary_info"_a, - "vector"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>(), - py::keep_alive<0, 5>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch_scalar_base - - template <bool anything> - struct diffusion_switch<true, true, anything> : public diffusion_switch_scalar_base - { - static std::string suffix() - { - return "single_diffusion_factor"; - } - }; - - template <bool anything> - struct diffusion_switch<true, false, anything> : public diffusion_switch_scalar_base - { - static std::string suffix() - { - return "single_diffusion_tensor"; - } - }; - -public: - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case( - "elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_dirichlet_vector_functional_" - + space_name<SP>::value() - + "_" - + XT::LA::bindings::container_name<V>::value() - + "_" - + diffusion_switch<>::suffix()); - - auto c = VectorFunctionalBase<type>::bind(m, ClassName.c_str()); - - diffusion_switch<>::template addbind_factory_methods<type>(m); - - return c; - } // ... bind(...) -}; // class EllipticIpdgDirichletVectorFunctional - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the lib - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - _prefix class Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>; \ - _prefix class Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType> - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - _prefix class Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>; \ - _prefix class Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>; \ - _prefix class Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType> - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -/* -#if HAVE_ALBERTA -#define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, ALBERTA_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, UG_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_1D( \ - _prefix, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - -// alu_istl.cc -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(extern template, leaf, view, cg, gdt, 1, istl_dense); -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(extern template, level, view, cg, gdt, 1, istl_dense); -// DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_ALU(extern template, dd_subdomain, part, cg, gdt, 1, istl_dense); -# endif - -// yasp_istl.cc -# if HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(extern template, leaf, view, cg, gdt, 1, istl_dense); -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(extern template, level, view, cg, gdt, 1, istl_dense); -// DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(extern template, dd_subdomain, part, cg, gdt, 1, istl_dense); -# endif - -// end: this is what we need for the lib - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_1D( \ - _m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m); \ - Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m) - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m); \ - Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m); \ - Dune::GDT::bindings::EllipticIpdgDirichletVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m) - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_1D( \ - _m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_1D(_m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_1D(_m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_1D( \ - _m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_1D( \ - _m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -# define _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -/* -#if HAVE_ALBERTA -#define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_D(_m, 2, ALBERTA_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_D( \ - _m, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_D(_m, 2, UG_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_YASP(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_1D( \ - _m, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_METHODS_D( \ - _m, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - - -// end: this is what we need for the .so - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BINDINGS_HH diff --git a/python/dune/gdt/functionals/elliptic-ipdg/yasp_istl.cc b/python/dune/gdt/functionals/elliptic-ipdg/yasp_istl.cc deleted file mode 100644 index b74e62fecbb2f2f71a62cda544fc345b0248e232..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/elliptic-ipdg/yasp_istl.cc +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/functionals/elliptic-ipdg/bindings.hh> - - -# if HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(template, leaf, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(template, level, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_BIND_LIB_YASP(template, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# endif - - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/functionals/l2/alu_istl.cc b/python/dune/gdt/functionals/l2/alu_istl.cc deleted file mode 100644 index f0df4d822b0319bf9247e88e18427af63ffc1263..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/l2/alu_istl.cc +++ /dev/null @@ -1,24 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/functionals/l2/bindings.hh> - - -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(template, leaf, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(template, level, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(template, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/functionals/l2/bindings.cc b/python/dune/gdt/functionals/l2/bindings.cc deleted file mode 100644 index de92c3fc68ed72c2a30bb3ba3a8e102b5a99b1f2..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/l2/bindings.cc +++ /dev/null @@ -1,62 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <python/dune/gdt/functionals/l2/bindings.hh> - - -PYBIND11_MODULE(__functionals_l2, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - - // alu_istl.cc - DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(m, leaf, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(m, level, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(m, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(m, leaf, view, cg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(m, level, view, cg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(m, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - -// yasp_istl.cc -# if HAVE_DUNE_ISTL - DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(m, leaf, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(m, level, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(m, dd_subdomain, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(m, leaf, view, cg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(m, level, view, cg, gdt, 1, istl_sparse); - DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(m, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - - add_initialization(m, "dune.gdt.functionals.l2"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/functionals/l2/bindings.hh b/python/dune/gdt/functionals/l2/bindings.hh deleted file mode 100644 index fb1da6478dbe1ba784d5e7ef1073ba4d84a51eb5..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/l2/bindings.hh +++ /dev/null @@ -1,316 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_FUNCTIONALS_L2_BINDINGS_HH -#define PYTHON_DUNE_GDT_FUNCTIONALS_L2_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/functionals/l2.hh> -# include <python/dune/gdt/functionals/base.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class F, class SP, class V /*= typename XT::LA::Container<typename SP::type::RangeFieldType>::VectorType, - class GridView = typename Space::GridLayerType, - class Field = typename Space::RangeFieldType*/> -class L2VolumeVectorFunctional -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - -public: - typedef GDT::L2VolumeVectorFunctional<F, S, V> type; - typedef pybind11::class_<type> bound_type; - - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case("l2_volume_vector_functional_" + space_name<SP>::value() + "_" - + XT::LA::bindings::container_name<V>::value()); - - auto c = VectorFunctionalBase<type>::bind(m, ClassName); - - m.def(std::string("make_l2_volume_vector_functional_" + XT::LA::bindings::container_name<V>::value()).c_str(), - [](const F& function, const S& space, const size_t over_integrate) { - return make_l2_volume_vector_functional<V>(function, space, over_integrate).release(); // <- b.c. - }, // L2VolumeVectorFunctional is not movable, returning the raw pointer lets pybind11 correctly manage the - "function"_a, // memory - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - - m.def("make_l2_volume_vector_functional", - [](const F& function, V& vector, const S& space, const size_t over_integrate) { - return make_l2_volume_vector_functional(function, vector, space, over_integrate).release(); // <- s.a. - }, - "function"_a, - "vector"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - return c; - } // ... bind(...) -}; // class L2VolumeVectorFunctional - - -template <class F, - class SP, - class V /*= typename XT::LA::Container<typename SP::type::RangeFieldType>::VectorType*/, - class GL /*= typename SP::type::GridLayerType, - class Field = typename SP::type::RangeFieldType*/> -class L2FaceVectorFunctional -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - -public: - typedef GDT::L2FaceVectorFunctional<F, S, V> type; - typedef pybind11::class_<type> bound_type; - - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const std::string class_name = "l2_face_vector_functional"; - const auto ClassName = XT::Common::to_camel_case(class_name + "_" + space_name<SP>::value() + "_" - + XT::LA::bindings::container_name<V>::value()); - - auto c = VectorFunctionalBase<type>::bind(m, ClassName); - - m.def(std::string("make_" + class_name + "_" + XT::LA::bindings::container_name<V>::value()).c_str(), - [](const F& function, const S& space, const size_t over_integrate) { - return make_l2_face_vector_functional<V>(function, space, over_integrate).release(); // <- b.c. - }, // L2FaceVectorFunctional is not movable, returning the raw pointer lets pybind11 correctly manage the - "function"_a, // memory - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - m.def(std::string("make_" + class_name + "_" + XT::LA::bindings::container_name<V>::value()).c_str(), - [](const F& function, - const S& space, - const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections, - const size_t over_integrate) { - return make_l2_face_vector_functional<V>(function, space, over_integrate, which_intersections.copy()) - .release(); // <- s.a. - }, - "function"_a, - "space"_a, - "which_intersections"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - - m.def(std::string("make_" + class_name).c_str(), - [](const F& function, V& vector, const S& space, const size_t over_integrate) { - return make_l2_face_vector_functional(function, vector, space, over_integrate).release(); // <- s.a. - }, - "function"_a, - "vector"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - m.def(std::string("make_" + class_name).c_str(), - [](const F& function, - V& vector, - const S& space, - const XT::Grid::ApplyOn::WhichIntersection<GL>& which_intersections, - const size_t over_integrate) { - return make_l2_face_vector_functional(function, vector, space, over_integrate, which_intersections.copy()) - .release(); // <- s.a. - }, - "function"_a, - "vector"_a, - "space"_a, - "which_intersections"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - return c; - } // ... bind(...) -}; // XT::LA::bindings::container_name<V>::value() - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the lib - -# define _DUNE_GDT_FUNCTIONALS_L2_BIND_LIB(_prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _prefix class Dune::GDT::bindings::L2VolumeVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>; \ - _prefix class Dune::GDT::bindings::L2FaceVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType, \ - typename Dune::XT::Grid::Layer<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type> - - -# if HAVE_DUNE_ALUGRID -# define DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_L2_BIND_LIB( \ - _prefix, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -# define DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_L2_BIND_LIB( \ - _prefix, 1, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_FUNCTIONALS_L2_BIND_LIB( \ - _prefix, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - -// alu_istl.cc -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(extern template, leaf, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(extern template, level, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_ALU(extern template, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - -// yasp_istl.cc -# if HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(extern template, leaf, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(extern template, level, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(extern template, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - -// end: this is what we need for the lib - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_FUNCTIONALS_L2_BIND(_m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - Dune::GDT::bindings::L2VolumeVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m); \ - Dune::GDT::bindings::L2FaceVectorFunctional< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType, \ - typename Dune::XT::Grid::Layer<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>::bind(_m) - - -# if HAVE_DUNE_ALUGRID -# define DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_L2_BIND(_m, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define DUNE_GDT_FUNCTIONALS_L2_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -# define DUNE_GDT_FUNCTIONALS_L2_BIND_YASP(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_FUNCTIONALS_L2_BIND( \ - _m, 1, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_FUNCTIONALS_L2_BIND(_m, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_FUNCTIONALS_L2_BINDINGS_HH diff --git a/python/dune/gdt/functionals/l2/yasp_istl.cc b/python/dune/gdt/functionals/l2/yasp_istl.cc deleted file mode 100644 index 2229c17e6fcba3af5099952d0dab89f55798da96..0000000000000000000000000000000000000000 --- a/python/dune/gdt/functionals/l2/yasp_istl.cc +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/functionals/l2/bindings.hh> - - -# if HAVE_DUNE_ISTL -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(template, leaf, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(template, level, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_FUNCTIONALS_L2_BIND_LIB_YASP(template, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/gamm-2019-talk-on-conservative-rb.cc b/python/dune/gdt/gamm-2019-talk-on-conservative-rb.cc index ef4028b4b6d9e9ae81d05e433d149618e63d1b3c..88142231942fe60208b7e3cbb449f835a165eb3d 100644 --- a/python/dune/gdt/gamm-2019-talk-on-conservative-rb.cc +++ b/python/dune/gdt/gamm-2019-talk-on-conservative-rb.cc @@ -48,7 +48,15 @@ using namespace Dune; using namespace Dune::GDT; +#if HAVE_DUNE_ALUGRID using G = ALU_2D_SIMPLEX_CONFORMING; +#elif HAVE_DUNE_UGGRID || HAVE_UG +using G = UG_2D; +#else +# warning Falling back to cubic grid, results will not be reproduced but similar! +using G = YASP_2D_EQUIDISTANT_OFFSET; +#endif + using GP = XT::Grid::GridProvider<G>; using GV = typename G::LeafGridView; using E = XT::Grid::extract_entity_t<GV>; @@ -301,49 +309,7 @@ PYBIND11_MODULE(gamm_2019_talk_on_conservative_rb, m) py::module::import("dune.xt.la"); py::module::import("dune.xt.grid"); py::module::import("dune.xt.functions"); - - Dune::XT::Common::bindings::addbind_exceptions(m); - Dune::XT::Common::bindings::add_initialization(m, "dune.gdt"); - - py::class_<XT::Functions::Spe10::Model1Function<E, d, d, double>, - XT::Functions::GridFunctionInterface<E, d, d, double>> - spe10_function(m, "Spe10Model1Function", "Spe10Model1Function"); - spe10_function.def(py::init([](const FieldVector<double, d>& lower_left, const FieldVector<double, d>& upper_right) { - return new XT::Functions::Spe10::Model1Function<E, d, d, double>( - XT::Data::spe10_model1_filename(), lower_left, upper_right); - }), - "lower_left"_a, - "upper_right"_a); - - py::class_<XT::Functions::FunctionAsGridFunctionWrapper<E, 1, 1, double>, - XT::Functions::GridFunctionInterface<E, 1, 1, double>> - scalar_wrapper(m, "ScalarFunctionAsGridFunctionWrapper", "ScalarFunctionAsGridFunctionWrapper"); - scalar_wrapper.def(py::init([](const XT::Functions::FunctionInterface<d>& func) { - return new XT::Functions::FunctionAsGridFunctionWrapper<E, 1, 1, double>(func); - }), - py::keep_alive<1, 2>(), - "scalar_function"_a); - py::class_<XT::Functions::FunctionAsGridFunctionWrapper<E, d, d, double>, - XT::Functions::GridFunctionInterface<E, d, d, double>> - matrix_wrapper(m, "MatrixFunctionAsGridFunctionWrapper", "MatrixFunctionAsGridFunctionWrapper"); - matrix_wrapper.def(py::init([](const XT::Functions::FunctionInterface<d, d, d>& func) { - return new XT::Functions::FunctionAsGridFunctionWrapper<E, d, d, double>(func); - }), - py::keep_alive<1, 2>(), - "matrix_function"_a); - - m.def("function_to_grid_function", - [](XT::Functions::FunctionInterface<d>& func) { - return std::make_unique<XT::Functions::FunctionAsGridFunctionWrapper<E, 1, 1, double>>(func); - }, - py::keep_alive<0, 1>(), - "scalar_function"_a); - m.def("function_to_grid_function", - [](XT::Functions::FunctionInterface<d, d, d>& func) { - return std::make_unique<XT::Functions::FunctionAsGridFunctionWrapper<E, d, d, double>>(func); - }, - py::keep_alive<0, 1>(), - "matrix_function"_a); + py::module::import("dune.gdt.discretefunction"); m.def("visualize", [](GP& grid, XT::Functions::FunctionInterface<d>& func, const std::string& filename) { @@ -404,24 +370,6 @@ PYBIND11_MODULE(gamm_2019_talk_on_conservative_rb, m) rtn_space.def_property_readonly("dimDomain", [](RTN& /*self*/) { return d; }); rtn_space.def_property_readonly("num_DoFs", [](RTN& self) { return self.mapper().size(); }); - py::class_<ScalarDF> scalar_discrete_function(m, "ScalarDiscreteFunction", "ScalarDiscreteFunction"); - scalar_discrete_function.def( - py::init([](DG& space, V& vec, const std::string& name) { return new ScalarDF(space, vec, name); }), - "dg_space"_a, - "DoF_vector"_a, - "name"_a); - scalar_discrete_function.def( - "visualize", [](ScalarDF& self, const std::string filename) { self.visualize(filename); }, "filename"_a); - - py::class_<VectorDF> vector_discrete_function(m, "VectorDiscreteFunction", "VectorDiscreteFunction"); - vector_discrete_function.def( - py::init([](RTN& space, V& vec, const std::string& name) { return new VectorDF(space, vec, name); }), - "rtn_space"_a, - "DoF_vector"_a, - "name"_a); - vector_discrete_function.def( - "visualize", [](VectorDF& self, const std::string filename) { self.visualize(filename); }, "filename"_a); - m.def("make_discrete_function", [](DG& dg_space, V& vec, const std::string& name) { return ScalarDF(dg_space, vec, name); }, "dg_space"_a, diff --git a/python/dune/gdt/local/diffusive-flux-estimation-operator.hh b/python/dune/gdt/local/diffusive-flux-estimation-operator.hh deleted file mode 100644 index 3ab96574de33c14ccaafc3c97a70284fd56fecc6..0000000000000000000000000000000000000000 --- a/python/dune/gdt/local/diffusive-flux-estimation-operator.hh +++ /dev/null @@ -1,118 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BINDINGS_HH -#define PYTHON_DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BINDINGS_HH -// Todo: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/functions/interfaces/grid-function.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/type_traits.hh> - -# include <dune/gdt/local/integrands/ESV2007.hh> -# include <dune/gdt/local/operators/integrals.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class G> -class LocalDiffusiveFluxEstimationOperator -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename G::template Codim<0>::Entity E; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunction; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d> VectorFunction; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunction; - typedef typename ScalarFunction::LocalfunctionType ScalarLocalFunctionType; - typedef GDT::LocalVolumeTwoFormInterface<ScalarLocalFunctionType> InterfaceType; - -public: - typedef LocalVolumeIntegralOperator<LocalDiffusiveFluxEstimateESV2007Integrand<ScalarFunction, - VectorFunction, - TensorFunction>, - ScalarLocalFunctionType> - type; - typedef pybind11::class_<type, InterfaceType> bound_type; - - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - // bind interface, guard since we might not be the first to do so for this combination - try { - const auto InterfaceName = XT::Common::to_camel_case( - "local_volume_two_form_interface_" + XT::Grid::bindings::grid_name<G>::value() + "_to_1x1"); - py::class_<InterfaceType>(m, InterfaceName.c_str(), "LocalVolumeTwoFormInterface"); - } catch (std::runtime_error&) { - } - - const std::string class_name = "local_diffusive_flux_estimation_esv2007_operator"; - const auto ClassName = - XT::Common::to_camel_case(class_name + "_" + XT::Grid::bindings::grid_name<G>::value() + "_to_1x1"); - - bound_type c(m, ClassName.c_str(), "LocalVolumeIntegralOperator<LocalDiffusiveFluxEstimateESV2007Integrand<...>>"); - - m.def(("make_" + class_name + "_to_1x1").c_str(), - [](const ScalarFunction& diffusion_factor, - const TensorFunction& diffusion_tensor, - const VectorFunction& diffusive_flux, - const size_t over_integrate) { - return type(over_integrate, diffusion_factor, diffusion_tensor, diffusive_flux); - }, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "diffusive_flux"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - return c; - } // ... bind(...) -}; // class LocalDiffusiveFluxEstimationOperator - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the .so - - -# define _DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND(_G, _m) \ - Dune::GDT::bindings::LocalDiffusiveFluxEstimationOperator<_G>::bind(_m) - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND_ALU(_m) \ - _DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND(ALU_2D_SIMPLEX_CONFORMING, _m) -# else -# define _DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND_ALU(_m) -# endif - -# define DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND(_m) \ - _DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BIND_ALU(_m) - -// end: this is what we need for the .so - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_LOCAL_DIFFUSIVE_FLUX_ESTIMATION_OPERATOR_BINDINGS_HH diff --git a/python/dune/gdt/local/elliptic-ipdg-operators.cc b/python/dune/gdt/local/elliptic-ipdg-operators.cc deleted file mode 100644 index 55888904eb8f67b79b3c221359628142c6c96ec3..0000000000000000000000000000000000000000 --- a/python/dune/gdt/local/elliptic-ipdg-operators.cc +++ /dev/null @@ -1,44 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include "elliptic-ipdg-operators.hh" - - -PYBIND11_MODULE(__local_elliptic_ipdg_operators, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - - DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND(m); - - add_initialization(m, "dune.gdt.assembler"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/local/elliptic-ipdg-operators.hh b/python/dune/gdt/local/elliptic-ipdg-operators.hh deleted file mode 100644 index 7ea84327e67010ad9908b29b8b30ecad19cb73cb..0000000000000000000000000000000000000000 --- a/python/dune/gdt/local/elliptic-ipdg-operators.hh +++ /dev/null @@ -1,686 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BINDINGS_HH -#define PYTHON_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/la/container.hh> -# include <dune/xt/functions/interfaces.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/grid/layers.bindings.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> - -# include <dune/gdt/spaces.hh> -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/local/integrands/elliptic-ipdg.hh> -# include <dune/gdt/local/operators/integrals.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class DF, typename DT, class SP, XT::Grid::Layers layer, LocalEllipticIpdgIntegrands::Method method> -class LocalEllipticIpdgInnerIntegralOperator -{ - static_assert(XT::Functions::is_localizable_function<DF>::value, ""); - static_assert(XT::Functions::is_localizable_function<DT>::value || std::is_same<DT, void>::value, ""); - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - typedef XT::Grid::extract_grid_t<typename S::GridLayerType> G; - typedef typename S::BaseFunctionSetType B; - typedef XT::Grid::extract_intersection_t< - typename XT::Grid::Layer<G, layer, S::layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type> - I; - -public: - typedef GDT::LocalCouplingTwoFormInterface<B, I> InterfaceType; - typedef LocalCouplingIntegralOperator<LocalEllipticIpdgIntegrands::Inner<DF, DT, method>, B, I> type; - typedef pybind11::class_<type, InterfaceType> bound_type; - -private: - template <bool intersection_matches_layer = (layer == SP::grid_layer), bool anything = false> - struct intersection_postfix - { - static std::string value() - { - return ""; - } - }; - - template <bool anything> - struct intersection_postfix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<layer>::value() + "_intersection"; - } - }; - - template <bool single_diffusion = std::is_same<DT, void>::value, - bool scalar = (DF::dimRange == 1 && DF::dimRangeCols == 1), - bool anything = false> - struct diffusion_switch - { - static std::string suffix() - { - return "diffusion_factor_and_tensor"; - } - - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - const std::string method_name = - "make_local_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() - + "_inner_integral_operator_" + to_string(size_t(S::dimRange)) + "x" + to_string(size_t(S::dimRangeCols)) - + "_p" + to_string(int(S::polOrder)) + "_" + space_type_name<SP::space_type>::value() + "_" - + backend_name<SP::space_backend>::value() + "_space" + intersection_postfix<>::value(); - - m.def(method_name.c_str(), - [](const DF& diffusion_factor, const DT& diffusion_tensor, const size_t over_integrate) { - return type(over_integrate, diffusion_factor, diffusion_tensor); - }, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch - - struct diffusion_switch_scalar_base - { - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - const std::string method_name = - "make_local_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() - + "_inner_integral_operator_" + to_string(size_t(S::dimRange)) + "x" + to_string(size_t(S::dimRangeCols)) - + "_p" + to_string(int(S::polOrder)) + "_" + space_type_name<SP::space_type>::value() + "_" - + backend_name<SP::space_backend>::value() + "_space" + intersection_postfix<>::value(); - - m.def(method_name.c_str(), - [](const DF& diffusion, const size_t over_integrate) { return type(over_integrate, diffusion); }, - "diffusion"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch_scalar_base - - template <bool anything> - struct diffusion_switch<true, true, anything> : public diffusion_switch_scalar_base - { - - static std::string suffix() - { - return "single_diffusion_factor"; - } - }; - - template <bool anything> - struct diffusion_switch<true, false, anything> : public diffusion_switch_scalar_base - { - - static std::string suffix() - { - return "single_diffusion_tensor"; - } - }; - -public: - static bound_type bind(pybind11::module& m, const std::string& layer_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - // bind interface, guard since we might not be the first to do so for this intersection - try { - const auto InterfaceName = XT::Common::to_camel_case( - "local_coupling_two_form_interface_" + XT::Grid::bindings::grid_name<G>::value() + layer_name + "_to_" - + to_string(size_t(S::dimRange)) - + "x" - + to_string(size_t(S::dimRangeCols)) - + "_p" - + to_string(int(S::polOrder)) - + "_" - + space_type_name<SP::space_type>::value() - + "_" - + backend_name<SP::space_backend>::value() - + "_space" - + intersection_postfix<>::value()); - py::class_<InterfaceType>(m, InterfaceName.c_str(), InterfaceName.c_str()); - } catch (std::runtime_error&) { - } - - const auto ClassName = - XT::Common::to_camel_case("local_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_" - + diffusion_switch<>::suffix() - + "_inner_integral_operator_" - + XT::Grid::bindings::grid_name<G>::value() - + layer_name - + "_to_" - + to_string(size_t(S::dimRange)) - + "x" - + to_string(size_t(S::dimRangeCols)) - + "_p" - + to_string(int(S::polOrder)) - + "_" - + space_type_name<SP::space_type>::value() - + "_" - + backend_name<SP::space_backend>::value() - + "_space" - + intersection_postfix<>::value()); - - bound_type c(m, ClassName.c_str()); - - diffusion_switch<>::addbind_factory_methods(m); - - return c; - } // ... bind(...) -}; // class LocalEllipticIpdgInnerIntegralOperator - - -template <class DF, typename DT, class SP, XT::Grid::Layers layer, LocalEllipticIpdgIntegrands::Method method> -class LocalEllipticIpdgBoundaryIntegralOperator -{ - static_assert(XT::Functions::is_localizable_function<DF>::value, ""); - static_assert(XT::Functions::is_localizable_function<DT>::value || std::is_same<DT, void>::value, ""); - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - typedef XT::Grid::extract_grid_t<typename S::GridLayerType> G; - typedef typename S::BaseFunctionSetType B; - typedef XT::Grid::extract_intersection_t< - typename XT::Grid::Layer<G, layer, S::layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type> - I; - -public: - typedef GDT::LocalBoundaryTwoFormInterface<B, I> InterfaceType; - typedef LocalBoundaryIntegralOperator<LocalEllipticIpdgIntegrands::BoundaryLHS<DF, DT, method>, B, I> type; - typedef pybind11::class_<type, InterfaceType> bound_type; - -private: - template <bool intersection_matches_layer = (layer == SP::grid_layer), bool anything = false> - struct intersection_postfix - { - static std::string value() - { - return ""; - } - }; - - template <bool anything> - struct intersection_postfix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<layer>::value() + "_intersection"; - } - }; - - template <bool single_diffusion = std::is_same<DT, void>::value, - bool scalar = (DF::dimRange == 1 && DF::dimRangeCols == 1), - bool anything = false> - struct diffusion_switch - { - static std::string suffix() - { - return "diffusion_factor_and_tensor"; - } - - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - const std::string method_name = - "make_local_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() - + "_boundary_integral_operator_" + to_string(size_t(S::dimRange)) + "x" + to_string(size_t(S::dimRangeCols)) - + "_p" + to_string(int(S::polOrder)) + "_" + space_type_name<SP::space_type>::value() + "_" - + backend_name<SP::space_backend>::value() + "_space" + intersection_postfix<>::value(); - - m.def(method_name.c_str(), - [](const DF& diffusion_factor, const DT& diffusion_tensor, const size_t over_integrate) { - return type(over_integrate, diffusion_factor, diffusion_tensor); - }, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch - - struct diffusion_switch_scalar_base - { - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - const std::string method_name = - "make_local_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() - + "_boundary_integral_operator_" + to_string(size_t(S::dimRange)) + "x" + to_string(size_t(S::dimRangeCols)) - + "_p" + to_string(int(S::polOrder)) + "_" + space_type_name<SP::space_type>::value() + "_" - + backend_name<SP::space_backend>::value() + "_space" + intersection_postfix<>::value(); - - m.def(method_name.c_str(), - [](const DF& diffusion, const size_t over_integrate) { return type(over_integrate, diffusion); }, - "diffusion"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch_scalar_base - - template <bool anything> - struct diffusion_switch<true, true, anything> : public diffusion_switch_scalar_base - { - - static std::string suffix() - { - return "single_diffusion_factor"; - } - }; - - template <bool anything> - struct diffusion_switch<true, false, anything> : public diffusion_switch_scalar_base - { - - static std::string suffix() - { - return "single_diffusion_tensor"; - } - }; - -public: - static bound_type bind(pybind11::module& m, const std::string& layer_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - using XT::Common::to_string; - - // bind interface, guard since we might not be the first to do so for this intersection - try { - const auto InterfaceName = XT::Common::to_camel_case( - "local_boundary_two_form_interface_" + XT::Grid::bindings::grid_name<G>::value() + layer_name + "_to_" - + to_string(size_t(S::dimRange)) - + "x" - + to_string(size_t(S::dimRangeCols)) - + "_p" - + to_string(int(S::polOrder)) - + "_" - + space_type_name<SP::space_type>::value() - + "_" - + backend_name<SP::space_backend>::value() - + "_space" - + intersection_postfix<>::value()); - py::class_<InterfaceType>(m, InterfaceName.c_str(), InterfaceName.c_str()); - } catch (std::runtime_error&) { - } - - const auto ClassName = - XT::Common::to_camel_case("local_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_" - + diffusion_switch<>::suffix() - + "_boundary_integral_operator_" - + XT::Grid::bindings::grid_name<G>::value() - + layer_name - + "_to_" - + to_string(size_t(S::dimRange)) - + "x" - + to_string(size_t(S::dimRangeCols)) - + "_p" - + to_string(int(S::polOrder)) - + "_" - + space_type_name<SP::space_type>::value() - + "_" - + backend_name<SP::space_backend>::value() - + "_space" - + intersection_postfix<>::value()); - - bound_type c(m, ClassName.c_str()); - - diffusion_switch<>::addbind_factory_methods(m); - - return c; - } // ... bind(...) -}; // class LocalEllipticIpdgBoundaryIntegralOperator - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_1D( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, _method) \ - Dune::GDT::bindings::LocalEllipticIpdgInnerIntegralOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - _R, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_i_layer_type, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method>::bind(_m, _layer_name); \ - Dune::GDT::bindings::LocalEllipticIpdgInnerIntegralOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - _R, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_i_layer_type, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method>::bind(_m, _layer_name); \ - Dune::GDT::bindings::LocalEllipticIpdgBoundaryIntegralOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - _R, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_i_layer_type, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method>::bind(_m, _layer_name); \ - Dune::GDT::bindings::LocalEllipticIpdgBoundaryIntegralOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - _R, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_i_layer_type, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method>::bind(_m, _layer_name) - -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_DD( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, _method) \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_1D( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, _method); \ - Dune::GDT::bindings::LocalEllipticIpdgInnerIntegralOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - _R, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_i_layer_type, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method>::bind(_m, _layer_name); \ - Dune::GDT::bindings::LocalEllipticIpdgBoundaryIntegralOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_G>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_G, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - _R, \ - _r, \ - _rC>, \ - Dune::XT::Grid::Layers::_i_layer_type, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method>::bind(_m, _layer_name) - -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_METHODS_1D( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name) \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_1D( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, sipdg); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_1D( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, swipdg); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_1D(_m, \ - _G, \ - _d, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name, \ - swipdg_affine_factor); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_1D(_m, \ - _G, \ - _d, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name, \ - swipdg_affine_tensor) - -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_METHODS_DD( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name) \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_DD( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, sipdg); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_DD( \ - _m, _G, _d, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name, swipdg); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_DD(_m, \ - _G, \ - _d, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name, \ - swipdg_affine_factor); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_DD(_m, \ - _G, \ - _d, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name, \ - swipdg_affine_tensor) - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_ALU( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name) \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_METHODS_DD(_m, \ - ALU_2D_SIMPLEX_CONFORMING, \ - 2, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name) -# else -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_ALU( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name) -# endif - -# define _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_YASP( \ - _m, _g_layer, _g_backend, _s_type, _s_backend, _i_layer_type, _p, _R, _r, _rC, _layer_name) \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_METHODS_1D(_m, \ - YASP_1D_EQUIDISTANT_OFFSET, \ - 1, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_METHODS_DD(_m, \ - YASP_2D_EQUIDISTANT_OFFSET, \ - 2, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name); \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_METHODS_DD(_m, \ - YASP_3D_EQUIDISTANT_OFFSET, \ - 3, \ - _g_layer, \ - _g_backend, \ - _s_type, \ - _s_backend, \ - _i_layer_type, \ - _p, \ - _R, \ - _r, \ - _rC, \ - _layer_name) - - /* -_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_ALU( \ - _m, leaf, part, _s_type, _s_backend, leaf, _p, _R, _r, _rC, "_leaf_"); \ -_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_ALU( \ - _m, level, part, _s_type, _s_backend, level, _p, _R, _r, _rC, "_level_"); \ -_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_YASP(_m, leaf, part, _s_type, _s_backend, leaf, _p, _R, _r, _rC, ""); \ -_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_YASP( \ - _m, dd_subdomain, part, _s_type, _s_backend, dd_subdomain_coupling, _p, _R, _r, _rC, "_dd_subdomain_") -*/ - -# define DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND(_m) \ - _DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BIND_ALU( \ - _m, dd_subdomain, view, dg, gdt, dd_subdomain_coupling, 1, double, 1, 1, "_dd_subdomain_") - -// end: this is what we need for the .so - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_LOCAL_ELLIPTIC_IPDG_OPERATORS_BINDINGS_HH diff --git a/python/dune/gdt/operators/base.hh b/python/dune/gdt/operators/base.hh deleted file mode 100644 index b5b1c448bb9dca770acfa37dd140dad4ed7894ee..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/base.hh +++ /dev/null @@ -1,196 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_BASE_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_BASE_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/la/container.hh> - -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/operators/base.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class OperatorType> -class MatrixOperatorBase -{ - static_assert(is_matrix_operator<OperatorType>::value, ""); - -public: - typedef OperatorType type; - typedef GDT::SystemAssembler<typename OperatorType::RangeSpaceType, - typename OperatorType::GridLayerType, - typename OperatorType::SourceSpaceType> - BaseType; - typedef pybind11::class_<type, BaseType> bound_type; - -private: - typedef typename type::RangeSpaceType R; - typedef typename type::SourceSpaceType S; - typedef typename XT::LA::Container<typename type::FieldType, type::MatrixType::vector_type>::VectorType V; - -public: - template <bool same_spaces = - std::is_same<typename OperatorType::RangeSpaceType, typename OperatorType::SourceSpaceType>::value, - bool anything = true> - struct induced_norm - { - static void addbind(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - c.def("induced_norm", - [](type& self, const V& range) { - py::gil_scoped_release DUNE_UNUSED(release); - return self.induced_norm(range); - }, - "range"_a); - c.def("induced_norm", - [](type& self, const GDT::ConstDiscreteFunction<R, V>& range) { - py::gil_scoped_release DUNE_UNUSED(release); - return self.induced_norm(range); - }, - "range"_a); - } - }; // struct induced_norm - - template <bool anything> - struct induced_norm<false, anything> - { - static void addbind(bound_type& /*c*/) - { - } - }; - - static bound_type bind(pybind11::module& m, const std::string& class_id) - { - namespace py = pybind11; - using namespace pybind11::literals; - - bound_type c(m, std::string(class_id).c_str(), std::string(class_id).c_str()); - - // Does not work if the grid layer of the operator is not the same as the one from the space: - // c.def_static("pattern", [](const R& space) { return type::pattern(space); }); - - // from MatrixOperatorBase - c.def("pattern", - [](type& self) { return self.pattern(self.range_space(), self.source_space(), self.grid_layer()); }); - c.def("matrix", [](type& self) { return self.matrix(); }); - c.def("source_space", [](type& self) { return self.source_space(); }); - c.def("range_space", [](type& self) { return self.range_space(); }); - c.def("apply", - [](type& self, const V& source, V& range) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply(source, range); - }, - "source"_a, - "range"_a); - c.def("apply", - [](type& self, const GDT::ConstDiscreteFunction<S, V>& source, GDT::DiscreteFunction<R, V>& range) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply(source, range); - }, - "source"_a, - "range"_a); - c.def("apply2", - [](type& self, const V& range, const V& source) { - py::gil_scoped_release DUNE_UNUSED(release); - return self.apply2(range, source); - }, - "range"_a, - "source"_a); - c.def( - "apply2", - [](type& self, const GDT::ConstDiscreteFunction<R, V>& range, const GDT::ConstDiscreteFunction<S, V>& source) { - py::gil_scoped_release DUNE_UNUSED(release); - return self.apply2(range, source); - }, - "range"_a, - "source"_a); - c.def("apply_inverse", - [](type& self, const V& range, V& source, const XT::Common::Configuration& opts) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply_inverse(range, source, opts); - }, - "range"_a, - "source"_a, - "opts"_a); - c.def("apply_inverse", - [](type& self, - const GDT::ConstDiscreteFunction<R, V>& range, - GDT::ConstDiscreteFunction<S, V>& source, - const XT::Common::Configuration& opts) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply_inverse(range, source, opts); - }, - "range"_a, - "source"_a, - "opts"_a); - c.def("invert_options", [](type& self) { return self.invert_options(); }); - c.def("invert_options", [](type& self, const std::string& type) { return self.invert_options(type); }, "type"_a); - - // from OperatorInterface - c.def("apply_inverse", - [](type& self, const V& range, V& source, const std::string& type) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply_inverse(range, source, type); - }, - "range"_a, - "source"_a, - "type"_a); - c.def("apply_inverse", - [](type& self, - const GDT::ConstDiscreteFunction<R, V>& range, - GDT::ConstDiscreteFunction<S, V>& source, - const std::string& type) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply_inverse(range, source, type); - }, - "range"_a, - "source"_a, - "type"_a); - c.def("apply_inverse", - [](type& self, const V& range, V& source) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply_inverse(range, source); - }, - "range"_a, - "source"_a); - c.def("apply_inverse", - [](type& self, const GDT::ConstDiscreteFunction<R, V>& range, GDT::ConstDiscreteFunction<S, V>& source) { - py::gil_scoped_release DUNE_UNUSED(release); - self.apply_inverse(range, source); - }, - "range"_a, - "source"_a); - - induced_norm<>::addbind(c); - - return c; - } // ... bind(...) -}; // class MatrixOperatorBase - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_BASE_BINDINGS_HH diff --git a/python/dune/gdt/operators/elliptic-ipdg/alu_istl.cc b/python/dune/gdt/operators/elliptic-ipdg/alu_istl.cc deleted file mode 100644 index 6e37864063fbbb514e4715b542729a89835bedaf..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic-ipdg/alu_istl.cc +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/operators/elliptic-ipdg/bindings.hh> - - -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(template, leaf, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(template, level, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(template, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# endif - - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/elliptic-ipdg/bindings.cc b/python/dune/gdt/operators/elliptic-ipdg/bindings.cc deleted file mode 100644 index 79069357a31408935d64761a0ce4f40f2565c95c..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic-ipdg/bindings.cc +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <python/dune/gdt/operators/elliptic-ipdg/bindings.hh> - - -PYBIND11_MODULE(__operators_elliptic_ipdg, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__discretefunction"); - -// alu_istl.cc -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALU(m, leaf, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALU(m, level, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALU(m, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# endif - -// yasp_istl.cc -# if HAVE_DUNE_ISTL - DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_YASP(m, leaf, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_YASP(m, level, view, dg, gdt, 1, istl_sparse); - DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_YASP(m, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# endif - - add_initialization(m, "dune.gdt.operators.elliptic.ipdg"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/elliptic-ipdg/bindings.hh b/python/dune/gdt/operators/elliptic-ipdg/bindings.hh deleted file mode 100644 index 1ed981e6070f455846a3fd3cdcdb1558a76066fe..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic-ipdg/bindings.hh +++ /dev/null @@ -1,565 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/common/string.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/type_traits.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <python/dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/operators/elliptic-ipdg.hh> -# include <python/dune/gdt/operators/base.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class DF, - typename DT, // may be void - class RP, - LocalEllipticIpdgIntegrands::Method method, - class M /* = typename XT::LA::Container<typename R::RangeFieldType>::MatrixType, - class GL = typename RP::type::GridLayerType, - class SP = RP, - class F = typename RP::type::RangeFieldType*/> -class EllipticIpdgMatrixOperator -{ - typedef typename RP::type R; - static_assert(is_space<R>::value, ""); - -public: - typedef GDT::EllipticIpdgMatrixOperator<DF, DT, R, method, M /*, GL, S, F*/> type; - typedef pybind11::class_<type> bound_type; - -private: - template <bool single_diffusion = std::is_same<DT, void>::value, - bool scalar = (DF::dimRange == 1 && DF::dimRangeCols == 1), - bool anything = false> - struct diffusion_switch - { - static std::string suffix() - { - return "diffusion_factor_and_tensor"; - } - - template <class C> - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto method_name = - "make_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_matrix_operator"; - - m.def( - std::string(method_name + "_" + XT::LA::bindings::container_name<M>::value()).c_str(), - [](const DF& diffusion_factor, - const DT& diffusion_tensor, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename R::GridLayerType>>& boundary_info, - const R& space, - const size_t over_integrate) { - return make_elliptic_ipdg_matrix_operator<M, method>( - diffusion_factor, diffusion_tensor, boundary_info, space, over_integrate) - .release(); // <- b.c. EllipticIpdgMatrixOperator is not movable, returning the raw pointer lets - }, // pybind11 correctly manage the memory - "diffusion_factor"_a, - "diffusion_tensor"_a, - "boundary_info"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>()); - - m.def( - method_name.c_str(), - [](const DF& diffusion_factor, - const DT& diffusion_tensor, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename R::GridLayerType>>& boundary_info, - M& matrix, - const R& space, - const size_t over_integrate) { - return make_elliptic_ipdg_matrix_operator<method>( - diffusion_factor, diffusion_tensor, boundary_info, matrix, space, over_integrate) - .release(); // <- s.a. for release() - }, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "boundary_info"_a, - "matrix"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>(), - py::keep_alive<0, 5>()); - } // ... addbind_factory_methods(...) - - }; // struct diffusion_switch - - struct diffusion_switch_scalar_base - { - template <class C> - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto method_name = - "make_elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_matrix_operator"; - - m.def( - std::string(method_name + "_" + XT::LA::bindings::container_name<M>::value()).c_str(), - [](const DF& diffusion, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename R::GridLayerType>>& boundary_info, - const R& space, - const size_t over_integrate) { - return make_elliptic_ipdg_matrix_operator<M, method>(diffusion, boundary_info, space, over_integrate) - .release(); // <- s.a. for release() - }, - "diffusion"_a, - "boundary_info"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - m.def( - method_name.c_str(), - [](const DF& diffusion, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<typename R::GridLayerType>>& boundary_info, - M& matrix, - const R& space, - const size_t over_integrate) { - return make_elliptic_ipdg_matrix_operator<method>(diffusion, boundary_info, matrix, space, over_integrate) - .release(); // <- s.a. for release() - }, - "diffusion"_a, - "boundary_info"_a, - "matrix"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch<..., void> - - template <bool anything> - struct diffusion_switch<true, true, anything> : public diffusion_switch_scalar_base - { - static std::string suffix() - { - return "single_diffusion_factor"; - } - }; - - template <bool anything> - struct diffusion_switch<true, false, anything> : public diffusion_switch_scalar_base - { - static std::string suffix() - { - return "single_diffusion_tensor"; - } - }; - -public: - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case( - "elliptic_" + LocalEllipticIpdgIntegrands::method_name<method>::value() + "_matrix_operator_" - + space_name<RP>::value() - + "_" - + XT::LA::bindings::container_name<M>::value() - + "_" - + diffusion_switch<>::suffix()); - - auto c = MatrixOperatorBase<type>::bind(m, ClassName.c_str()); - - diffusion_switch<>::template addbind_factory_methods<type>(m); - - return c; - } // ... bind(...) -}; // EllipticIpdgMatrixOperator - - -} // naemspace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the lib - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - _prefix class Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>; \ - _prefix class Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - 1, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType> - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - _prefix class Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>; \ - _prefix class Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>; \ - _prefix class Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType> - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_1D( \ - _prefix, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -/* -#if HAVE_ALBERTA -#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, ALBERTA_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, UG_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_1D( \ - _prefix, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_METHODS_D( \ - _prefix, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - -// alu_istl.cc -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(extern template, leaf, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(extern template, level, view, cg, gdt, 1, istl_sparse); -// DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_ALU(extern template, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - -// yasp_istl.cc -# if HAVE_DUNE_ISTL -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(extern template, leaf, view, cg, gdt, 1, istl_sparse); -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(extern template, level, view, cg, gdt, 1, istl_sparse); -// DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(extern template, dd_subdomain, view, cg, gdt, 1, istl_sparse); -# endif - -// end: this is what we need for the lib - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_1D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>::bind(_m); \ - Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>::bind(_m) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_1D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, _method); \ - Dune::GDT::bindings::EllipticIpdgMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - Dune::GDT::LocalEllipticIpdgIntegrands::Method::_method, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>::bind(_m) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_1D( \ - _m, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_1D(_m, 1, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_1D(_m, 1, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_1D( \ - _m, 1, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_1D( \ - _m, 1, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_D(_m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, sipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_D(_m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_factor); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_D( \ - _m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la, swipdg_affine_tensor) - -/* -#if HAVE_ALBERTA -#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_D(_m, 2, ALBERTA_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_D( \ - _m, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_D(_m, 2, UG_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_YASP(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_1D( \ - _m, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS_D( \ - _m, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BINDINGS_HH diff --git a/python/dune/gdt/operators/elliptic-ipdg/yasp_istl.cc b/python/dune/gdt/operators/elliptic-ipdg/yasp_istl.cc deleted file mode 100644 index 22199e07861a5157001fee84413445ee2899dfda..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic-ipdg/yasp_istl.cc +++ /dev/null @@ -1,25 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/operators/elliptic-ipdg/bindings.hh> - - -# if HAVE_DUNE_ISTL -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(template, leaf, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(template, level, view, dg, gdt, 1, istl_sparse); -DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LIB_YASP(template, dd_subdomain, view, dg, gdt, 1, istl_sparse); -# endif - - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/elliptic/bindings.cc b/python/dune/gdt/operators/elliptic/bindings.cc deleted file mode 100644 index 30a17de5d33bea4bba60f698167dc5a50550fb50..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic/bindings.cc +++ /dev/null @@ -1,45 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <python/dune/gdt/operators/elliptic/bindings.hh> - - -PYBIND11_MODULE(__operators_elliptic, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__discretefunction"); - - DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ISTL(m); - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/elliptic/bindings.hh b/python/dune/gdt/operators/elliptic/bindings.hh deleted file mode 100644 index 4f130da92fd291f47b4c54ab65f3fff8a324b106..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic/bindings.hh +++ /dev/null @@ -1,465 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_ELLIPTIC_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_ELLIPTIC_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/type_traits.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <python/dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <python/dune/gdt/operators/base.hh> -# include <dune/gdt/operators/elliptic.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class DF, - typename DT, // may be void - class RP, - class M /* = typename XT::LA::Container<typename R::RangeFieldType>::MatrixType, - class GL = typename R::GridLayerType, - class S = R, - class F = typename R::RangeFieldType*/> -class EllipticMatrixOperator -{ - typedef typename RP::type R; - static_assert(is_space<R>::value, ""); - -public: - typedef GDT::EllipticMatrixOperator<DF, DT, R, M /*, GL, S, F*/> type; - typedef pybind11::class_<type> bound_type; - -private: - template <bool single_diffusion = std::is_same<DT, void>::value, - bool scalar = (DF::dimRange == 1 && DF::dimRangeCols == 1), - bool anything = false> - struct diffusion_switch - { - static std::string suffix() - { - return "diffusion_factor_and_tensor"; - } - - template <class C> - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const std::string method_name = "make_elliptic_matrix_operator_" + XT::LA::bindings::container_name<M>::value(); - - m.def( - method_name.c_str(), - [](const DF& diffusion_factor, const DT& diffusion_tensor, const R& space, const size_t over_integrate) { - return make_elliptic_matrix_operator<M>(diffusion_factor, diffusion_tensor, space, over_integrate) - .release(); // <- b.c. EllipticMatrixOperator is not movable, returning the raw pointer lets pybind11 - }, // correctly manage the memory - "diffusion_factor"_a, - "diffusion_tensor"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - m.def( - std::string(method_name).c_str(), - [](const DF& diffusion_factor, - const DT& diffusion_tensor, - M& matrix, - const R& space, - const size_t over_integrate) { - return make_elliptic_matrix_operator(diffusion_factor, diffusion_tensor, matrix, space, over_integrate) - .release(); // <- s.a. for release() - }, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "matrix"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch - - struct diffusion_switch_scalar_base - { - template <class C> - static void addbind_factory_methods(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const std::string method_name = "make_elliptic_matrix_operator_" + XT::LA::bindings::container_name<M>::value(); - - m.def(method_name.c_str(), - [](const DF& diffusion, const R& space, const size_t over_integrate) { - return make_elliptic_matrix_operator<M>(diffusion, space, over_integrate).release(); // <- s.a. - }, - "diffusion"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - - m.def(std::string(method_name).c_str(), - [](const DF& diffusion, M& matrix, const R& space, const size_t over_integrate) { - return make_elliptic_matrix_operator(diffusion, matrix, space, over_integrate).release(); // <- s.a. - }, - "diffusion"_a, - "matrix"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - } // ... addbind_factory_methods(...) - }; // struct diffusion_switch<..., void> - - template <bool anything> - struct diffusion_switch<true, true, anything> : public diffusion_switch_scalar_base - { - - static std::string suffix() - { - return "single_diffusion_factor"; - } - }; - - template <bool anything> - struct diffusion_switch<true, false, anything> : public diffusion_switch_scalar_base - { - - static std::string suffix() - { - return "single_diffusion_tensor"; - } - }; - -public: - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case( - "elliptic_matrix_operator_" + space_name<RP>::value() + "_" + XT::LA::bindings::container_name<M>::value() + "_" - + diffusion_switch<>::suffix()); - - auto c = MatrixOperatorBase<type>::bind(m, ClassName); - - diffusion_switch<>::template addbind_factory_methods<type>(m); - - return c; - } // ... bind(...) -}; // class EllipticMatrixOperator - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the lib - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_1D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _prefix class Dune::GDT::bindings::EllipticMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>; \ - _prefix class Dune::GDT::bindings::EllipticMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType> - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_D( \ - _prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_1D(_prefix, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _prefix class Dune::GDT::bindings::EllipticMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType> - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_D(_prefix, 2, ALBERTA_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_D( \ - _prefix, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_D(_prefix, 2, UG_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_YASP(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_1D( \ - _prefix, 1, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_D( \ - _prefix, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_GRIDS(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ALBERTA(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ALU(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_UG(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_YASP(_prefix, _layer, _g_backend, _s_type, _s_backend, _p, _la) - - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB(_prefix, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_GRIDS(_prefix, leaf, view, dg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_GRIDS(_prefix, level, view, dg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_GRIDS(_prefix, dd_subdomain, view, dg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_GRIDS(_prefix, dd_subdomain, view, cg, gdt, 1, _la) - -# if HAVE_DUNE_ISTL -# define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ISTL(_prefix) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB(_prefix, istl_sparse) -# else -# define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ISTL(_prefix) -# endif - -// istl.cc -DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ISTL(extern template); - -// end: this is what we need for the lib - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_1D(_m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - Dune::GDT::bindings::EllipticMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>::bind(_m); \ - Dune::GDT::bindings::EllipticMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - 1, \ - 1>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>::bind(_m) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_D(_m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_1D(_m, _d, _GRID, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - Dune::GDT::bindings::EllipticMatrixOperator< \ - Dune::XT::Functions::GridFunctionInterface<Dune::XT::Grid::extract_entity_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_g_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - double, \ - _d, \ - double, \ - _d, \ - _d>, \ - void, \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::MatrixType>::bind(_m) - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_D(_m, 2, ALBERTA_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_D( \ - _m, 2, ALU_2D_SIMPLEX_CONFORMING, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# else -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_D(_m, 2, UG_2D, _layer, _g_backend, _s_type, _s_backend, _p, _la) -#else -*/ -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) -//#endif - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_YASP(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_1D( \ - _m, 1, YASP_1D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_D( \ - _m, 2, YASP_2D_EQUIDISTANT_OFFSET, _layer, _g_backend, _s_type, _s_backend, _p, _la) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ALBERTA(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ALU(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_UG(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_YASP(_m, _layer, _g_backend, _s_type, _s_backend, _p, _la) - -# define _DUNE_GDT_OPERATORS_ELLIPTIC_BIND(_m, _la) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, leaf, view, cg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, level, view, cg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, leaf, view, dg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, level, view, dg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, dd_subdomain, view, dg, gdt, 1, _la); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND_GRIDS(_m, dd_subdomain, view, dg, gdt, 1, _la) -# define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_COMMON(_m) -//_DUNE_GDT_OPERATORS_ELLIPTIC_BIND(_m, common_dense) - /* -#if HAVE_EIGEN -#define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_EIGEN(_m) \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND(_m, eigen_dense); \ - _DUNE_GDT_OPERATORS_ELLIPTIC_BIND(_m, eigen_sparse) -#else -*/ -# define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_EIGEN(_m) -//#endif -# if HAVE_DUNE_ISTL -# define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ISTL(_m) _DUNE_GDT_OPERATORS_ELLIPTIC_BIND(_m, istl_sparse) -# else -# define DUNE_GDT_OPERATORS_ELLIPTIC_BIND_ISTL(_m) -# endif - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_ELLIPTIC_BINDINGS_HH diff --git a/python/dune/gdt/operators/elliptic/istl.cc b/python/dune/gdt/operators/elliptic/istl.cc deleted file mode 100644 index 46fa5046cd590d34775190a53807d30ab82fea8a..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/elliptic/istl.cc +++ /dev/null @@ -1,21 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <python/dune/gdt/operators/elliptic/bindings.hh> - - -DUNE_GDT_OPERATORS_ELLIPTIC_BIND_LIB_ISTL(template); - - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/fluxreconstruction.cc b/python/dune/gdt/operators/fluxreconstruction.cc deleted file mode 100644 index 5fee70ab9259928d023896eda91eaff42a4777d2..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/fluxreconstruction.cc +++ /dev/null @@ -1,57 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <python/dune/gdt/shared.hh> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <dune/xt/grid/grids.hh> - -# include <dune/gdt/spaces.hh> -# include <python/dune/gdt/operators/fluxreconstruction.hh> - - -PYBIND11_MODULE(__operators_fluxreconstruction, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__discretefunction"); - -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - Dune::GDT::bindings::DiffusiveFluxReconstructionOperator<ALU_2D_SIMPLEX_CONFORMING, - Dune::GDT::SpaceType::rt, - Dune::GDT::Backends::gdt, - Dune::XT::Grid::Layers::leaf, - 0, - double, - 2, - Dune::XT::LA::Backends::istl_dense>::bind(m); -# endif // HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/fluxreconstruction.hh b/python/dune/gdt/operators/fluxreconstruction.hh deleted file mode 100644 index 030948aefcf084670f3e147ea18bb7a0f524a8c3..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/fluxreconstruction.hh +++ /dev/null @@ -1,99 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_FLUXRECONSTRUCTION_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_FLUXRECONSTRUCTION_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/la/container.hh> - -# include <dune/gdt/spaces.hh> - -# include <dune/gdt/operators/fluxreconstruction.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class G, - SpaceType space_type, - Backends space_backend, - XT::Grid::Layers space_layer_type, - int p, - class R, - size_t r, - XT::LA::Backends la_backend /*, - XT::Grid::Layers layer_type = space_layer_type, - XT::Grid::Backends layer_backend = - SpaceProvider<G, space_layer_type, space_type, space_backend, p, R, r>::layer_backend*/> -class DiffusiveFluxReconstructionOperator -{ - typedef typename SpaceProvider<G, space_layer_type, space_type, space_backend, p, R, r>::type S; - typedef typename S::GridLayerType GL; - typedef typename XT::LA::Container<R, la_backend>::VectorType V; - typedef typename S::EntityType E; - typedef typename S::DomainFieldType D; - static const size_t d = S::dimDomain; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - -public: - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - // m.def("apply_diffusive_flux_reconstruction_operator", - // [](const ScalarFunctionType& diffusion_factor, - // const ScalarFunctionType& source, - // DiscreteFunction<S, V>& range) { - // py::gil_scoped_release DUNE_UNUSED(release); - // GDT::DiffusiveFluxReconstructionOperator<GL, - // ScalarFunctionType, - // void, - // LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor>( - // range.space().grid_layer(), diffusion_factor) - // .apply(source, range); - // }, - // "diffusion_tensor"_a, - // "source"_a, - // "range"_a); - m.def("apply_diffusive_flux_reconstruction_operator", - [](const ScalarFunctionType& diffusion_factor, - const TensorFunctionType& diffusion_tensor, - const ScalarFunctionType& source, - DiscreteFunction<S, V>& range) { - py::gil_scoped_release DUNE_UNUSED(release); - GDT::DiffusiveFluxReconstructionOperator<GL, - ScalarFunctionType, - TensorFunctionType, - LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor>( - range.space().grid_layer(), diffusion_factor, diffusion_tensor) - .apply(source, range); - }, - "diffusion_factor"_a, - "diffusion_tensor"_a, - "source"_a, - "range"_a); - } -}; // class DiffusiveFluxReconstructionOperator - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_FLUXRECONSTRUCTION_BINDINGS_HH diff --git a/python/dune/gdt/operators/l2.cc b/python/dune/gdt/operators/l2.cc deleted file mode 100644 index 7acf814ebf2a3d0720acd3f90f53ff40847a132e..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/l2.cc +++ /dev/null @@ -1,108 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/layers.hh> - -# include <python/dune/gdt/operators/l2.hh> -# include <dune/gdt/playground/spaces/restricted.hh> - -using namespace Dune; -namespace py = pybind11; -using namespace pybind11::literals; -using Dune::XT::Grid::Layers; -using namespace Dune::XT; -using Dune::GDT::SpaceType; - - -template <class G, - XT::Grid::Layers layer_type, - XT::Grid::Backends layer_backend, - size_t range_r = 1, - size_t range_rC = 1, - size_t source_r = range_r, - size_t source_rC = range_rC> -void bind_l2_localizable_product(py::module& m) -{ - try { - GDT::bindings::L2LocalizableProduct<G, layer_type, layer_backend, range_r, range_rC, source_r, source_rC>::bind(m); - } catch (std::runtime_error&) { - } -} - - -PYBIND11_MODULE(__operators_l2, m) -{ - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__discretefunction"); - -# if HAVE_DUNE_ALUGRID - bind_l2_localizable_product<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, XT::Grid::Backends::view>(m); - - Dune::GDT::bindings::L2MatrixOperator<ALU_2D_SIMPLEX_CONFORMING, - Layers::dd_subdomain, - SpaceType::dg, - GDT::Backends::gdt, - 1, - 1, - LA::Backends::istl_sparse>::bind(m); - Dune::GDT::bindings::L2MatrixOperator<ALU_2D_SIMPLEX_CONFORMING, - Layers::leaf, - SpaceType::dg, - GDT::Backends::gdt, - 1, - 1, - LA::Backends::istl_sparse>::bind(m); - Dune::GDT::bindings::L2MatrixOperator<ALU_2D_SIMPLEX_CONFORMING, - Layers::level, - SpaceType::dg, - GDT::Backends::gdt, - 1, - 1, - LA::Backends::istl_sparse>::bind(m); - Dune::GDT::bindings::internal::L2MatrixOperator< - GDT::RestrictedSpace<typename GDT::SpaceProvider<ALU_2D_SIMPLEX_CONFORMING, - Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - 2>::type, - typename XT::Grid::Layer<ALU_2D_SIMPLEX_CONFORMING, - Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<ALU_2D_SIMPLEX_CONFORMING>>::type>, - XT::LA::IstlRowMajorSparseMatrix<double>>::bind(m, - "RtAlu2dSimplexLeafRestrictedSubdomainPartSpace", - "istl_row_major_sparse_matrix_double"); - -# endif // HAVE_DUNE_ALUGRID - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/l2.hh b/python/dune/gdt/operators/l2.hh deleted file mode 100644 index efcd95ea05fc0a3da48841ae81f9f92cff62ce95..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/l2.hh +++ /dev/null @@ -1,245 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_L2_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_L2_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/type_traits.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/spaces.hh> -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <python/dune/gdt/operators/base.hh> -# include <dune/gdt/operators/l2.hh> - -namespace Dune { -namespace GDT { -namespace bindings { -namespace internal { - - -template <class R, class M> -class L2MatrixOperator -{ -public: - typedef GDT::L2MatrixOperator<R, M> type; - typedef pybind11::class_<type, XT::Grid::Walker<typename R::GridLayerType>> bound_type; - -public: - static bound_type bind(pybind11::module& m, const std::string& space_name, const std::string& container_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const std::string class_name = "l2_matrix_operator"; - const auto ClassName = XT::Common::to_camel_case(class_name + "_" + space_name + "_" + container_name); - - bound_type c(m, ClassName.c_str()); - c.def("assemble", [](type& self) { self.assemble(); }); - c.def("matrix", [](type& self) { return self.matrix(); }); - - m.def(std::string("make_" + class_name + "_" + container_name).c_str(), - [](const R& space, const size_t over_integrate) { - return make_l2_matrix_operator<M>(space, over_integrate).release(); - }, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>()); - - m.def(std::string("make_" + class_name).c_str(), - [](M& matrix, const R& space, const size_t over_integrate) { - return make_l2_matrix_operator(matrix, space, over_integrate).release(); - }, - "matrix"_a, - "space"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>()); - - return c; - } // ... bind(...) -}; // class L2MatrixOperator - - -} // namespace internal - - -template <class G, - XT::Grid::Layers layer_type, - GDT::SpaceType space_type, - GDT::Backends space_backend, - int p, - size_t r, - XT::LA::Backends la_backend> -class L2MatrixOperator -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef GDT::SpaceProvider<G, layer_type, space_type, space_backend, p, double, r, 1> RP; - typedef typename RP::type R; - typedef typename XT::LA::Container<double, la_backend>::MatrixType M; - - typedef internal::L2MatrixOperator<R, M> binder; - -public: - typedef typename binder::type type; - typedef typename binder::bound_type bound_type; - -public: - static bound_type bind(pybind11::module& m) - { - return binder::bind(m, space_name<RP>::value(), XT::LA::bindings::container_name<M>::value()); - } -}; // class L2MatrixOperator - - -template <class G, - XT::Grid::Layers layer_type, - XT::Grid::Backends layer_backend, - size_t range_r = 1, - size_t range_rC = 1, - size_t source_r = range_r, - size_t source_rC = range_rC> -class L2LocalizableProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - - template <bool is_dd = layer_type == XT::Grid::Layers::dd_subdomain - || layer_type == XT::Grid::Layers::dd_subdomain_boundary - || layer_type == XT::Grid::Layers::dd_subdomain_coupling - || layer_type == XT::Grid::Layers::dd_subdomain_oversampled, - bool anything = true> - struct GridLayer - { - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type type; - }; - - template <bool anything> - struct GridLayer<false, anything> - { - typedef typename XT::Grid::Layer<G, layer_type, layer_backend>::type type; - }; - - typedef typename GridLayer<>::type GL; - typedef XT::Grid::extract_entity_t<GL> E; - typedef typename G::ctype D; - static const size_t d = G::dimension; - typedef XT::Functions::GridFunctionInterface<E, D, d, double, range_r, range_rC> R; - typedef XT::Functions::GridFunctionInterface<E, D, d, double, source_r, source_rC> S; - -public: - typedef GDT::L2LocalizableProduct<GL, R, S> type; - typedef pybind11::class_<type, XT::Grid::Walker<GL>> bound_type; - -private: - static std::string class_name() - { - return "l2_localizable_product_on_" + XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value() + "_for_" + XT::Common::to_string(range_r) + "x" - + XT::Common::to_string(range_rC) + "_range_times_" + XT::Common::to_string(source_r) + "x" - + XT::Common::to_string(source_rC) + "_source"; - } - - template <bool is_dd = layer_type == XT::Grid::Layers::dd_subdomain - || layer_type == XT::Grid::Layers::dd_subdomain_boundary - || layer_type == XT::Grid::Layers::dd_subdomain_coupling - || layer_type == XT::Grid::Layers::dd_subdomain_oversampled, - bool anything = true> - struct FactoryMethods - { - static void addbind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name()).c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& grid_provider, - const int level_or_subdomain, - const R& range, - const S& source, - const size_t over_integrate) { - return make_l2_localizable_product( - grid_provider.template layer<layer_type, layer_backend>(level_or_subdomain), - range, - source, - over_integrate) - .release(); - }, - "grid_provider"_a, - "level_or_subdomain"_a, - "range"_a, - "source"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>()); - } - }; // struct FactoryMethods<true, ...> - - template <bool anything> - struct FactoryMethods<false, anything> - { - static void addbind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name()).c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, - const int level, - const R& range, - const S& source, - const size_t over_integrate) { - return make_l2_localizable_product( - grid_provider.template layer<layer_type, layer_backend>(level), range, source, over_integrate) - .release(); - }, - "grid_provider"_a, - "level"_a, - "range"_a, - "source"_a, - "over_integrate"_a = 0, - py::keep_alive<0, 3>(), - py::keep_alive<0, 4>()); - - FactoryMethods<true>::addbind(m); - } - }; // struct FactoryMethods<false, ...> - -public: - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - FactoryMethods<>::addbind(m); // needs to come first, as the code below may fail - - const std::string cn = class_name(); - bound_type c(m, XT::Common::to_camel_case(cn).c_str()); - c.def("apply2", [](type& self) { return self.apply2(); }); - c.def("result", [](type& self) { return self.result(); }); - - return c; - } // ... bind(...) -}; // class L2LocalizableProduct - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_L2_BINDINGS_HH diff --git a/python/dune/gdt/operators/oswaldinterpolation.cc b/python/dune/gdt/operators/oswaldinterpolation.cc deleted file mode 100644 index 354ae3c409255dcce4423a6f63937e59bf9e149f..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/oswaldinterpolation.cc +++ /dev/null @@ -1,58 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <dune/xt/grid/grids.hh> - -# include <dune/gdt/spaces.hh> -# include <python/dune/gdt/operators/oswaldinterpolation.hh> - - -PYBIND11_MODULE(__operators_oswaldinterpolation, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__discretefunction"); - -# if HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - Dune::GDT::bindings::OswaldInterpolationOperator<ALU_2D_SIMPLEX_CONFORMING, - Dune::GDT::SpaceType::block_dg, - Dune::GDT::Backends::gdt, - Dune::XT::Grid::Layers::dd_subdomain, - 1, - double, - 1, - Dune::XT::LA::Backends::istl_dense, - Dune::XT::Grid::Layers::dd_subdomain_oversampled>::bind(m); -# endif // HAVE_DUNE_ALUGRID && HAVE_DUNE_ISTL - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/oswaldinterpolation.hh b/python/dune/gdt/operators/oswaldinterpolation.hh deleted file mode 100644 index 8f0bac8fff72c8d2902821214a10a12cd709e3f5..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/oswaldinterpolation.hh +++ /dev/null @@ -1,84 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// Tobias Leibner (2017 - 2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_OSWALDINTERPOLATION_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_OSWALDINTERPOLATION_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/la/container.hh> -# include <dune/xt/grid/gridprovider/provider.hh> - -# include <dune/gdt/spaces.hh> - -# include <dune/gdt/operators/oswaldinterpolation.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class G, - SpaceType space_type, - Backends space_backend, - XT::Grid::Layers space_layer_type, - int p, - class R, - size_t r, - XT::LA::Backends la_backend, - XT::Grid::Layers interpolation_layer_type = space_layer_type, - XT::Grid::Backends interpolation_layer_backend = - SpaceProvider<G, space_layer_type, space_type, space_backend, p, R, r>::layer_backend> -class OswaldInterpolationOperator -{ - typedef typename SpaceProvider<G, space_layer_type, space_type, space_backend, p, R, r>::type S; - typedef typename S::GridLayerType GL; - typedef typename XT::LA::Container<R, la_backend>::VectorType V; - typedef typename XT::Grid:: - Layer<G, interpolation_layer_type, interpolation_layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type - InterpolationLayerType; - -public: - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - m.def("apply_oswald_interpolation_operator", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t layer_level_or_subdomain, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<InterpolationLayerType>>& boundary_info, - const GDT::ConstDiscreteFunction<S, V>& source, - GDT::DiscreteFunction<S, V>& range) { - GDT::OswaldInterpolationOperator<InterpolationLayerType, R>( - dd_grid_provider.template layer<interpolation_layer_type, interpolation_layer_backend>( - layer_level_or_subdomain), - boundary_info) - .apply(source, range); - }, - "dd_grid_provider"_a, - "layer_level_or_subdomain"_a = -1, - "boundary_info"_a = - XT::Grid::AllDirichletBoundaryInfo<XT::Grid::extract_intersection_t<InterpolationLayerType>>(), - "source"_a, - "range"_a); - } -}; // class OswaldInterpolationOperator - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_OSWALDINTERPOLATION_BINDINGS_HH diff --git a/python/dune/gdt/operators/weighted-l2.cc b/python/dune/gdt/operators/weighted-l2.cc deleted file mode 100644 index d53fbf214fdbfa950c146f05c2dce4caf0ea5a31..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/weighted-l2.cc +++ /dev/null @@ -1,55 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2017) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/layers.hh> - -# include <python/dune/gdt/operators/weighted-l2.hh> - - -PYBIND11_MODULE(__operators_weighted_l2, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - using Dune::XT::Grid::Backends; - using Dune::XT::Grid::Layers; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - py::module::import("dune.gdt.__discretefunction"); - -# if HAVE_DUNE_ALUGRID - Dune::GDT::bindings::WeightedL2LocalizableProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - Dune::GDT::bindings::WeightedL2LocalizableProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::level, Backends::view>::bind(m); - Dune::GDT::bindings::WeightedL2LocalizableProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view>:: - bind(m); -# endif // HAVE_DUNE_ALUGRID - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/operators/weighted-l2.hh b/python/dune/gdt/operators/weighted-l2.hh deleted file mode 100644 index 2da773f33cf64bd8367671780032e1a967a77082..0000000000000000000000000000000000000000 --- a/python/dune/gdt/operators/weighted-l2.hh +++ /dev/null @@ -1,143 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_OPERATORS_WEIGHTED_L2_BINDINGS_HH -#define PYTHON_DUNE_GDT_OPERATORS_WEIGHTED_L2_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <dune/xt/grid/gridprovider/provider.hh> -# include <python/dune/xt/grid/layers.bindings.hh> -# include <dune/xt/functions/interfaces/grid-function.hh> - -# include <dune/gdt/spaces/interface.hh> - -# include <dune/gdt/operators/weighted-l2.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class G, XT::Grid::Layers layer_type, XT::Grid::Backends layer_backend> -class WeightedL2LocalizableProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - - typedef XT::Grid::extract_entity_t<GL> E; - typedef typename G::ctype D; - static const size_t d = G::dimension; - typedef XT::Functions::GridFunctionInterface<E, D, d, double, 1, 1> F; - - template <bool is_dd_subdomain = (layer_type == XT::Grid::Layers::dd_subdomain) - || (layer_type == XT::Grid::Layers::dd_subdomain_boundary) - || (layer_type == XT::Grid::Layers::dd_subdomain_coupling), - bool anything = true> - struct helper - { - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - m.def(std::string("apply_weighted_l2_product_" + XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value()) - .c_str(), - [](const F& weight, - const F& range, - const F& source, - const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& grid, - const int level_or_subdomain, - const size_t over_integrate) { - return GDT::WeightedL2LocalizableProduct<F, GL, F, F>( - over_integrate, - weight, - grid.template layer<layer_type, layer_backend>(level_or_subdomain), - range, - source) - .apply2(); - }, - "weight"_a, - "range"_a, - "source"_a, - "grid"_a, - "level_or_subdomain"_a = -1, - "over_integrate"_a = 0); - } // ... bind(...) - }; // struct helper<true, ...> - - template <bool anything> - struct helper<false, anything> - { - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - m.def(std::string("apply_weighted_l2_product_" + XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value()) - .c_str(), - [](const F& weight, - const F& range, - const F& source, - const XT::Grid::GridProvider<G>& grid, - const int level, - const size_t over_integrate) { - return GDT::WeightedL2LocalizableProduct<F, GL, F, F>( - over_integrate, weight, grid.template layer<layer_type, layer_backend>(level), range, source) - .apply2(); - }, - "weight"_a, - "range"_a, - "source"_a, - "grid"_a, - "level"_a = -1, - "over_integrate"_a = 0); - m.def(std::string("apply_weighted_l2_product_" + XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value()) - .c_str(), - [](const F& weight, - const F& range, - const F& source, - const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& grid, - const int layer, - const size_t over_integrate) { - return GDT::WeightedL2LocalizableProduct<F, GL, F, F>( - over_integrate, weight, grid.template layer<layer_type, layer_backend>(layer), range, source) - .apply2(); - }, - "weight"_a, - "range"_a, - "source"_a, - "grid"_a, - "layer"_a = -1, - "over_integrate"_a = 0); - } // ... bind(...) - }; // struct helper<false, ...> - -public: - static void bind(pybind11::module& m) - { - helper<>::bind(m); - } -}; // class WeightedL2LocalizableProduct - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_OPERATORS_WEIGHTED_L2_BINDINGS_HH diff --git a/python/dune/gdt/playground/operators/ESV2007.cc b/python/dune/gdt/playground/operators/ESV2007.cc deleted file mode 100644 index 95caa37d448b3c92a737679d4e18e8460fccfcaa..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/operators/ESV2007.cc +++ /dev/null @@ -1,525 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <memory> - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> -# include <dune/xt/common/numeric_cast.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/grid/layers.bindings.hh> -# include <dune/xt/grid/gridprovider/provider.hh> -# include <dune/xt/grid/walker.hh> -# include <dune/xt/grid/type_traits.hh> - -# include <python/dune/gdt/playground/operators/ESV2007.hh> - -using namespace Dune; -using XT::Grid::Backends; -using XT::Grid::Layers; -namespace py = pybind11; - - -template <class G, Layers layer_type, Backends layer_backend, Layers interpolation_layer_type = layer_type> -struct NonconformityProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - typedef - typename XT::Grid::Layer<G, interpolation_layer_type, Backends::view, XT::Grid::DD::SubdomainGrid<G>>::type IGL; - - typedef GDT::ESV2007::NonconformityProduct<GL, IGL> type; - typedef py::class_<type, XT::Grid::Walker<GL>> bound_type; - - template <bool is_same = (interpolation_layer_type == layer_type) && (layer_backend == Backends::view), - bool anything = true> - struct interpolation_layer_suffix - { - static std::string value() - { - return ""; - } - }; // struct interpolation_layer_suffix<true, ...> - - template <bool anything> - struct interpolation_layer_suffix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<interpolation_layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<Backends::view>::value(); - } - }; // struct interpolation_layer_suffix<false, ...> - - static std::string class_name() - { - return "ESV2007_nonconformity_product"; - } - - static std::string layer_suffix() - { - return XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value() + interpolation_layer_suffix<>::value(); - } - - template <bool is_dd = (layer_type == Layers::dd_subdomain) || (layer_type == Layers::dd_subdomain_boundary) - || (layer_type == Layers::dd_subdomain_coupling) - || (layer_type == Layers::dd_subdomain_oversampled) - || (interpolation_layer_type == Layers::dd_subdomain) - || (interpolation_layer_type == Layers::dd_subdomain_boundary) - || (interpolation_layer_type == Layers::dd_subdomain_coupling) - || (interpolation_layer_type == Layers::dd_subdomain_oversampled), - bool anything = true> - struct factory_method - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t layer_level_or_subdomain, - const ssize_t interpolation_layer_level_or_subdomain, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<IGL>>& interpolation_boundary_info, - const typename type::ScalarFunctionType& lambda, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate) { - return new type(dd_grid_provider.template layer<layer_type, layer_backend>( - XT::Common::numeric_cast<int>(layer_level_or_subdomain)), - dd_grid_provider.template layer<interpolation_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(interpolation_layer_level_or_subdomain)), - interpolation_boundary_info, - lambda, - kappa, - u, - v, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "dd_grid_provider"_a, - "layer_level_or_subdomain"_a = -1, - "interpolation_layer_level_or_subdomain"_a = -1, - "interpolation_boundary_info"_a, - "lambda"_a, - "kappa"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - } - }; // struct factory_method<true, ...> - - template <bool anything> - struct factory_method<false, anything> - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, - const ssize_t layer_level, - const ssize_t interpolation_layer_level, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<IGL>>& interpolation_boundary_info, - const typename type::ScalarFunctionType& lambda, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate) { - return new type( - grid_provider.template layer<layer_type, layer_backend>(XT::Common::numeric_cast<int>(layer_level)), - grid_provider.template layer<interpolation_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(interpolation_layer_level)), - interpolation_boundary_info, - lambda, - kappa, - u, - v, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "grid_provider"_a, - "layer_level"_a = -1, - "interpolation_layer_level"_a = -1, - "interpolation_boundary_info"_a, - "lambda"_a, - "kappa"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - - factory_method<true>::addbind(m); - } - }; // struct factory_method<false, ...> - - static void bind(py::module& m) - { - using namespace pybind11::literals; - - try { // we might not be the first ones to add this type - bound_type c(m, - XT::Common::to_camel_case(class_name() + "_" + XT::Grid::bindings::grid_name<G>::value() + "_" - + layer_suffix()) - .c_str(), - "ESV2007::NonconformityProduct"); - c.def("apply2", [](type& self) { return self.apply2(); }); - c.def("result", [](type& self) { return self.apply2(); }); - } catch (std::runtime_error& ee) { - } - - factory_method<>::addbind(m); - } // ... bind(...) -}; // struct NonconformityProduct - - -template <class G, Layers layer_type, Backends layer_backend, Layers reconstruction_layer_type = layer_type> -struct ResidualProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - typedef - typename XT::Grid::Layer<G, reconstruction_layer_type, Backends::view, XT::Grid::DD::SubdomainGrid<G>>::type RGL; - - typedef GDT::ESV2007::ResidualProduct<GL, RGL> type; - typedef py::class_<type, XT::Grid::Walker<GL>> bound_type; - - template <bool is_same = (reconstruction_layer_type == layer_type) && (layer_backend == Backends::view), - bool anything = true> - struct reconstruction_layer_suffix - { - static std::string value() - { - return ""; - } - }; // struct reconstruction_layer_suffix<true, ...> - - template <bool anything> - struct reconstruction_layer_suffix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<reconstruction_layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<Backends::view>::value(); - } - }; // struct reconstruction_layer_suffix<false, ...> - - static std::string class_name() - { - return "ESV2007_residual_product"; - } - - static std::string layer_suffix() - { - return XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value() + reconstruction_layer_suffix<>::value(); - } - - template <bool is_dd = (layer_type == Layers::dd_subdomain) || (layer_type == Layers::dd_subdomain_boundary) - || (layer_type == Layers::dd_subdomain_coupling) - || (layer_type == Layers::dd_subdomain_oversampled) - || (reconstruction_layer_type == Layers::dd_subdomain) - || (reconstruction_layer_type == Layers::dd_subdomain_boundary) - || (reconstruction_layer_type == Layers::dd_subdomain_coupling) - || (reconstruction_layer_type == Layers::dd_subdomain_oversampled), - bool anything = true> - struct factory_method - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t layer_level_or_subdomain, - const ssize_t reconstruction_layer_level_or_subdomain, - const typename type::ScalarFunctionType& lambda, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& f, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate, - const double& poincare_constant) { - return new type(dd_grid_provider.template layer<layer_type, layer_backend>( - XT::Common::numeric_cast<int>(layer_level_or_subdomain)), - dd_grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level_or_subdomain)), - lambda, - kappa, - f, - u, - v, - poincare_constant, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "dd_grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "kappa"_a, - "f"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2, - "poincare_constant"_a = 1.0 / (M_PIl * M_PIl)); - } - }; // struct factory_method<true, ...> - - template <bool anything> - struct factory_method<false, anything> - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, - const ssize_t layer_level, - const ssize_t reconstruction_layer_level, - const typename type::ScalarFunctionType& lambda, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& f, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate, - const double& poincare_constant) { - return new type( - grid_provider.template layer<layer_type, layer_backend>(XT::Common::numeric_cast<int>(layer_level)), - grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level)), - lambda, - kappa, - f, - u, - v, - poincare_constant, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "kappa"_a, - "f"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2, - "poincare_constant"_a = 1.0 / (M_PIl * M_PIl)); - - factory_method<true>::addbind(m); - } - }; // struct factory_method<false, ...> - - static void bind(py::module& m) - { - using namespace pybind11::literals; - - try { // we might not be the first ones to add this type - bound_type c(m, - XT::Common::to_camel_case(class_name() + "_" + XT::Grid::bindings::grid_name<G>::value() + "_" - + layer_suffix()) - .c_str(), - "ESV2007::ResidualProduct"); - c.def("apply2", [](type& self) { return self.apply2(); }); - c.def("result", [](type& self) { return self.apply2(); }); - } catch (std::runtime_error& ee) { - } - - factory_method<>::addbind(m); - } // ... bind(...) -}; // struct ResidualProduct - - -template <class G, Layers layer_type, Backends layer_backend, Layers reconstruction_layer_type = layer_type> -struct DiffusiveFluxProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - typedef - typename XT::Grid::Layer<G, reconstruction_layer_type, Backends::view, XT::Grid::DD::SubdomainGrid<G>>::type RGL; - - typedef GDT::ESV2007::DiffusiveFluxProduct<GL, RGL> type; - typedef py::class_<type, XT::Grid::Walker<GL>> bound_type; - - template <bool is_same = (reconstruction_layer_type == layer_type) && (layer_backend == Backends::view), - bool anything = true> - struct reconstruction_layer_suffix - { - static std::string value() - { - return ""; - } - }; // struct reconstruction_layer_suffix<true, ...> - - template <bool anything> - struct reconstruction_layer_suffix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<reconstruction_layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<Backends::view>::value(); - } - }; // struct reconstruction_layer_suffix<false, ...> - - static std::string class_name() - { - return "ESV2007_diffusive_flux_product"; - } - - static std::string layer_suffix() - { - return XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value() + reconstruction_layer_suffix<>::value(); - } - - template <bool is_dd = (layer_type == Layers::dd_subdomain) || (layer_type == Layers::dd_subdomain_boundary) - || (layer_type == Layers::dd_subdomain_coupling) - || (layer_type == Layers::dd_subdomain_oversampled) - || (reconstruction_layer_type == Layers::dd_subdomain) - || (reconstruction_layer_type == Layers::dd_subdomain_boundary) - || (reconstruction_layer_type == Layers::dd_subdomain_coupling) - || (reconstruction_layer_type == Layers::dd_subdomain_oversampled), - bool anything = true> - struct factory_method - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t layer_level_or_subdomain, - const ssize_t reconstruction_layer_level_or_subdomain, - const typename type::ScalarFunctionType& lambda, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate) { - return new type(dd_grid_provider.template layer<layer_type, layer_backend>( - XT::Common::numeric_cast<int>(layer_level_or_subdomain)), - dd_grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level_or_subdomain)), - lambda, - kappa, - u, - v, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "dd_grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "kappa"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - } - }; // struct factory_method<true, ...> - - template <bool anything> - struct factory_method<false, anything> - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, - const ssize_t layer_level, - const ssize_t reconstruction_layer_level, - const typename type::ScalarFunctionType& lambda, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate) { - return new type( - grid_provider.template layer<layer_type, layer_backend>(XT::Common::numeric_cast<int>(layer_level)), - grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level)), - lambda, - kappa, - u, - v, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "kappa"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - - factory_method<true>::addbind(m); - } - }; // struct factory_method<false, ...> - - static void bind(py::module& m) - { - using namespace pybind11::literals; - - try { // we might not be the first ones to add this type - bound_type c(m, - XT::Common::to_camel_case(class_name() + "_" + XT::Grid::bindings::grid_name<G>::value() + "_" - + layer_suffix()) - .c_str(), - "ESV2007::DiffusiveFluxProduct"); - c.def("apply2", [](type& self) { return self.apply2(); }); - c.def("result", [](type& self) { return self.apply2(); }); - } catch (std::runtime_error& ee) { - } - - factory_method<>::addbind(m); - } // ... bind(...) -}; // struct DiffusiveFluxProduct - - -PYBIND11_MODULE(__operators_ESV2007, m) -{ - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - -# if HAVE_DUNE_ALUGRID - NonconformityProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - NonconformityProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view>::bind(m); - NonconformityProduct<ALU_2D_SIMPLEX_CONFORMING, - Layers::dd_subdomain, - Backends::view, - Layers::dd_subdomain_oversampled>::bind(m); - ResidualProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - ResidualProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - // on a dd_subdomain_oversampled grid view is broken, if based on - // a 2d simplex alugrid. - ResidualProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view, Layers::leaf>::bind(m); - DiffusiveFluxProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - DiffusiveFluxProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - // s.a. - DiffusiveFluxProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view, Layers::leaf>::bind(m); -# endif - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/playground/operators/ESV2007.hh b/python/dune/gdt/playground/operators/ESV2007.hh deleted file mode 100644 index cc6ed6446d873e3983ce688fa294f19146c00b29..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/operators/ESV2007.hh +++ /dev/null @@ -1,389 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef DUNE_GDT_PLAYGROUND_OPERATORS_RS2017_HH -#define DUNE_GDT_PLAYGROUND_OPERATORS_RS2017_HH - -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/common/typetraits.hh> - -# include <dune/xt/common/fmatrix.hh> -# include <dune/xt/la/eigen-solver.hh> -# include <dune/xt/grid/boundaryinfo/interfaces.hh> -# include <dune/xt/grid/entity.hh> -# include <dune/xt/grid/type_traits.hh> -# include <dune/xt/functions/derived.hh> -# include <dune/xt/functions/interfaces/grid-function.hh> - -# include <dune/gdt/discretefunction/default.hh> -# include <dune/gdt/local/operators/integrals.hh> -# include <dune/gdt/local/integrands/lambda.hh> -# include <dune/gdt/operators/base.hh> -# include <dune/gdt/operators/fluxreconstruction.hh> -# include <dune/gdt/operators/oswaldinterpolation.hh> -# include <dune/gdt/spaces/dg/default.hh> -# include <dune/gdt/spaces/rt/default.hh> - -namespace Dune { -namespace GDT { -namespace ESV2007 { - - -template <class ProductGridLayer, class InterpolationGridLayerType> -class NonconformityProduct - : public LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> -{ - static_assert(XT::Grid::is_layer<ProductGridLayer>::value, ""); - static_assert(XT::Grid::is_layer<InterpolationGridLayerType>::value, ""); - typedef XT::Grid::extract_entity_t<ProductGridLayer> E; - static_assert(std::is_same<XT::Grid::extract_entity_t<InterpolationGridLayerType>, E>::value, ""); - typedef typename ProductGridLayer::ctype D; - static const constexpr size_t d = ProductGridLayer::dimension; - typedef double R; - -public: - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - -private: - typedef LocalizableProductBase<ProductGridLayer, ScalarFunctionType> BaseType; - typedef NonconformityProduct<ProductGridLayer, InterpolationGridLayerType> ThisType; - typedef LocalVolumeIntegralOperator<LocalLambdaBinaryVolumeIntegrand<E>, - typename ScalarFunctionType::LocalfunctionType> - LocalProductType; - typedef DiscontinuousLagrangeSpace<InterpolationGridLayerType, 1, R> DgSpaceType; - typedef DiscreteFunction<DgSpaceType> DiscreteFunctionType; - -public: - using typename BaseType::GridLayerType; - - NonconformityProduct(GridLayerType product_grid_layer, - InterpolationGridLayerType interpolation_grid_layer, - const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<InterpolationGridLayerType>>& - interpolation_boundary_info, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const ScalarFunctionType& u, - const ScalarFunctionType& v, - const size_t over_integrate = 2) - : BaseType(product_grid_layer, u, v) - , interpolation_grid_layer_(interpolation_grid_layer) - , lambda_(lambda) - , kappa_(kappa) - , dg_space_(interpolation_grid_layer_) - , interpolated_u_(dg_space_) - , interpolated_v_(dg_space_) - , over_integrate_(over_integrate) - , local_product_( - // the order lambda - [&](const auto& local_u, const auto& local_v) { - const auto& entity = local_u.entity(); - const auto local_lambda = lambda_.local_function(entity); - const auto local_kappa = kappa_.local_function(entity); - return local_lambda->order() + local_kappa->order() - + size_t(std::max(ssize_t(local_u.order()) - 1, ssize_t(0)) - + std::max(ssize_t(local_v.order()) - 1, ssize_t(0))) - + over_integrate_; - }, - // the evaluate lambda - [&](const auto& local_u, const auto& local_v, const auto& local_point, auto& ret) { - const auto& entity = local_u.entity(); - XT::Common::FieldMatrix<R, d, d> diffusion = kappa_.local_function(entity)->evaluate(local_point); - diffusion *= lambda_.local_function(entity)->evaluate(local_point); - const auto grad_u = local_u.jacobian(local_point).at(0)[0]; - const auto grad_interpolated_u = interpolated_u_.local_function(entity)->jacobian(local_point)[0]; - const auto grad_v = local_v.jacobian(local_point).at(0)[0]; - const auto grad_interpolated_v = interpolated_v_.local_function(entity)->jacobian(local_point)[0]; - ret[0][0] = (diffusion * (grad_u - grad_interpolated_u)) * (grad_v - grad_interpolated_v); - }) - { - OswaldInterpolationOperator<InterpolationGridLayerType> oswald_interpolation(interpolation_grid_layer_, - interpolation_boundary_info); - oswald_interpolation.apply(this->range(), interpolated_u_); - oswald_interpolation.apply(this->source(), interpolated_v_); - this->append(local_product_); - } - - NonconformityProduct(const ThisType&) = delete; - NonconformityProduct(ThisType&&) = delete; - -private: - const InterpolationGridLayerType interpolation_grid_layer_; - const ScalarFunctionType& lambda_; - const TensorFunctionType& kappa_; - const DgSpaceType dg_space_; - DiscreteFunctionType interpolated_u_; - DiscreteFunctionType interpolated_v_; - const size_t over_integrate_; - const LocalProductType local_product_; -}; // class NonconformityProduct - - -namespace internal { - - -template <class ProductGridLayer, class ReconstructionGridLayer> -class ResidualProductBase -{ - static_assert(XT::Grid::is_layer<ProductGridLayer>::value, ""); - static_assert(XT::Grid::is_layer<ReconstructionGridLayer>::value, ""); - -protected: - typedef XT::Grid::extract_entity_t<ProductGridLayer> E; - typedef typename ProductGridLayer::ctype D; - static const constexpr size_t d = ProductGridLayer::dimension; - typedef double R; - -private: - static_assert(std::is_same<XT::Grid::extract_entity_t<ReconstructionGridLayer>, E>::value, ""); - typedef ResidualProductBase<ProductGridLayer, ReconstructionGridLayer> ThisType; - -public: - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - -private: - typedef RaviartThomasSpace<ReconstructionGridLayer, 0, R> RtSpaceType; - typedef DiscreteFunction<RtSpaceType> FluxReconstructionType; - typedef XT::Functions::DivergenceFunction<FluxReconstructionType> DivergenceOfFluxReconstructionType; - typedef typename ScalarFunctionType::DifferenceType DifferenceType; - -public: - ResidualProductBase(ReconstructionGridLayer reconstruction_grid_layer, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const ScalarFunctionType& f, - const ScalarFunctionType& u, - const ScalarFunctionType& v) - : f_(f) - , rt_space_(reconstruction_grid_layer) - , reconstructed_u_(rt_space_) - , reconstructed_v_(rt_space_) - , divergence_of_reconstructed_u_(reconstructed_u_) - , divergence_of_reconstructed_v_(reconstructed_v_) - , f_minus_divergence_of_reconstructed_u_(f_ - divergence_of_reconstructed_u_) - , f_minus_divergence_of_reconstructed_v_(f_ - divergence_of_reconstructed_v_) - { - DiffusiveFluxReconstructionOperator<ReconstructionGridLayer, ScalarFunctionType, TensorFunctionType> - flux_reconstruction(reconstruction_grid_layer, lambda, kappa); - flux_reconstruction.apply(u, reconstructed_u_); - flux_reconstruction.apply(v, reconstructed_v_); - } - - ResidualProductBase(const ThisType&) = delete; - ResidualProductBase(ThisType&&) = delete; - -protected: - const ScalarFunctionType& f_; - const RtSpaceType rt_space_; - FluxReconstructionType reconstructed_u_; - FluxReconstructionType reconstructed_v_; - const DivergenceOfFluxReconstructionType divergence_of_reconstructed_u_; - const DivergenceOfFluxReconstructionType divergence_of_reconstructed_v_; - const DifferenceType f_minus_divergence_of_reconstructed_u_; - const DifferenceType f_minus_divergence_of_reconstructed_v_; -}; // class ResidualProductBase - - -} // namespace internal - - -template <class ProductGridLayer, class ReconstructionGridLayer> -class ResidualProduct - : internal::ResidualProductBase<ProductGridLayer, ReconstructionGridLayer>, - public LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> -{ - typedef internal::ResidualProductBase<ProductGridLayer, ReconstructionGridLayer> ResidualProductBaseType; - typedef LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> - LocalizableProductBaseType; - -public: - using typename ResidualProductBaseType::ScalarFunctionType; - using typename ResidualProductBaseType::TensorFunctionType; - -private: - using typename ResidualProductBaseType::E; - using typename ResidualProductBaseType::R; - typedef LocalVolumeIntegralOperator<LocalLambdaBinaryVolumeIntegrand<E>, - typename ScalarFunctionType::LocalfunctionType> - LocalProductType; - -public: - ResidualProduct(ProductGridLayer product_grid_layer, - ReconstructionGridLayer reconstruction_grid_layer, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const ScalarFunctionType& f, - const ScalarFunctionType& u, - const ScalarFunctionType& v, - const double& poincare_constant = 1.0 / (M_PIl * M_PIl), - const size_t over_integrate = 2) - : ResidualProductBaseType(reconstruction_grid_layer, lambda, kappa, f, u, v) - , LocalizableProductBaseType(product_grid_layer, - this->f_minus_divergence_of_reconstructed_u_, - this->f_minus_divergence_of_reconstructed_v_) - , lambda_(lambda) - , kappa_(kappa) - , poincare_constant_(poincare_constant) - , over_integrate_(over_integrate) - , local_product_( - // the order lambda - [&](const auto& local_f_minus_divergence_of_reconstructed_u, - const auto& local_f_minus_divergence_of_reconstructed_v) { - return local_f_minus_divergence_of_reconstructed_u.order() - + local_f_minus_divergence_of_reconstructed_v.order() + over_integrate_; - }, - // the evaluate lambda - [&](const auto& local_f_minus_divergence_of_reconstructed_u, - const auto& local_f_minus_divergence_of_reconstructed_v, - const auto& local_point, - auto& ret) { - const auto& entity = local_f_minus_divergence_of_reconstructed_u.entity(); - // we need the min_ev for this entity, so we just evaluate in one point - const auto center = entity.geometry().local(entity.geometry().center()); - auto diffusion = kappa_.local_function(entity)->evaluate(center); - diffusion *= lambda_.local_function(entity)->evaluate(center); - const auto min_ev = XT::LA::make_eigen_solver( - diffusion, XT::Common::Configuration{{"assert_positive_eigenvalues"}, {1e-15}}) - .min_eigenvalues(1) - .at(0); - const auto h = XT::Grid::entity_diameter(entity); - ret[0][0] = (poincare_constant_ / min_ev) * h * h - * local_f_minus_divergence_of_reconstructed_u.evaluate(local_point).at(0)[0] - * local_f_minus_divergence_of_reconstructed_v.evaluate(local_point).at(0)[0]; - }) - { - this->append(local_product_); - } - -private: - const ScalarFunctionType& lambda_; - const TensorFunctionType& kappa_; - const double poincare_constant_; - const size_t over_integrate_; - const LocalProductType local_product_; -}; // class ResidualProduct - - -template <class ProductGridLayer, class ReconstructionGridLayer> -class DiffusiveFluxProduct - : public LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> -{ - static_assert(XT::Grid::is_layer<ProductGridLayer>::value, ""); - static_assert(XT::Grid::is_layer<ReconstructionGridLayer>::value, ""); - typedef XT::Grid::extract_entity_t<ProductGridLayer> E; - static_assert(std::is_same<XT::Grid::extract_entity_t<ReconstructionGridLayer>, E>::value, ""); - typedef typename ProductGridLayer::ctype D; - static const constexpr size_t d = ProductGridLayer::dimension; - typedef double R; - typedef DiffusiveFluxProduct<ProductGridLayer, ReconstructionGridLayer> ThisType; - -public: - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - -private: - typedef RaviartThomasSpace<ReconstructionGridLayer, 0, R> RtSpaceType; - typedef DiscreteFunction<RtSpaceType> FluxReconstructionType; - typedef LocalizableProductBase<ProductGridLayer, XT::Functions::GridFunctionInterface<E, D, d, R, 1>> BaseType; - typedef LocalVolumeIntegralOperator<LocalLambdaBinaryVolumeIntegrand<E>, - typename ScalarFunctionType::LocalfunctionType> - LocalProductType; - -public: - DiffusiveFluxProduct(ProductGridLayer product_grid_layer, - ReconstructionGridLayer reconstruction_grid_layer, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const ScalarFunctionType& u, - const ScalarFunctionType& v, - const size_t over_integrate = 2) - : BaseType(product_grid_layer, u, v) - , lambda_(lambda) - , kappa_(kappa) - , rt_space_(reconstruction_grid_layer) - , reconstructed_u_(rt_space_) - , reconstructed_v_(rt_space_) - , over_integrate_(over_integrate) - , local_product_( - // the order lambda - [&](const auto& local_u, const auto& local_v) { - const auto& entity = local_u.entity(); - const size_t diffusion_order = - lambda_.local_function(entity)->order() + kappa_.local_function(entity)->order(); - return 3 * diffusion_order + size_t(std::max(ssize_t(local_u.order()) - 1, ssize_t(0))) - + size_t(std::max(ssize_t(local_v.order()) - 1, ssize_t(0))) + over_integrate_; - }, - // the evaluate lambda - [&](const auto& local_u, const auto& local_v, const auto& local_point, auto& ret) { - const auto& entity = local_u.entity(); - XT::Common::FieldMatrix<R, d, d> diffusion = kappa_.local_function(entity)->evaluate(local_point); - diffusion *= lambda_.local_function(entity)->evaluate(local_point); - XT::Common::FieldMatrix<R, d, d> one_over_diffusion = diffusion; - one_over_diffusion.invert(); // there is no documented way to assert that the inversion was successfull - const auto grad_u = local_u.jacobian(local_point).at(0)[0]; - const auto grad_v = local_v.jacobian(local_point).at(0)[0]; - const auto val_reconstructed_u = reconstructed_u_.local_function(entity)->evaluate(local_point); - const auto val_reconstructed_v = reconstructed_v_.local_function(entity)->evaluate(local_point); - ret[0][0] = (one_over_diffusion * ((diffusion * grad_u) + val_reconstructed_u)) // clang-format off - * ((diffusion * grad_v) + val_reconstructed_v); // clang-format on - }) - { - DiffusiveFluxReconstructionOperator<ReconstructionGridLayer, ScalarFunctionType, TensorFunctionType> - flux_reconstruction(reconstruction_grid_layer, lambda, kappa); - flux_reconstruction.apply(u, reconstructed_u_); - flux_reconstruction.apply(v, reconstructed_v_); - this->append(local_product_); - } - - DiffusiveFluxProduct(const ThisType&) = delete; - DiffusiveFluxProduct(ThisType&&) = delete; - -private: - const ScalarFunctionType& lambda_; - const TensorFunctionType& kappa_; - const RtSpaceType rt_space_; - FluxReconstructionType reconstructed_u_; - FluxReconstructionType reconstructed_v_; - const size_t over_integrate_; - const LocalProductType local_product_; -}; // class DiffusiveFluxProduct - - -} // namespace ESV2007 -} // namespace GDT -} // namespace Dune - -#endif // 0 - -#endif // DUNE_GDT_PLAYGROUND_OPERATORS_RS2017_HH diff --git a/python/dune/gdt/playground/operators/OS2015.cc b/python/dune/gdt/playground/operators/OS2015.cc deleted file mode 100644 index 4f2be0ec68f68c9918466b51e0c916cae0056d39..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/operators/OS2015.cc +++ /dev/null @@ -1,379 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <memory> - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> -# include <dune/xt/common/numeric_cast.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/grid/layers.bindings.hh> -# include <dune/xt/grid/gridprovider/provider.hh> -# include <dune/xt/grid/walker.hh> -# include <dune/xt/grid/type_traits.hh> - -# include <python/dune/gdt/playground/operators/OS2015.hh> - -using namespace Dune; -using XT::Grid::Backends; -using XT::Grid::Layers; -namespace py = pybind11; - - -template <class G, Layers layer_type, Backends layer_backend, Layers reconstruction_layer_type = layer_type> -struct ResidualProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - typedef - typename XT::Grid::Layer<G, reconstruction_layer_type, Backends::view, XT::Grid::DD::SubdomainGrid<G>>::type RGL; - - typedef GDT::OS2015::ResidualProduct<GL, RGL> type; - typedef py::class_<type, XT::Grid::Walker<GL>> bound_type; - - template <bool is_same = (reconstruction_layer_type == layer_type) && (layer_backend == Backends::view), - bool anything = true> - struct reconstruction_layer_suffix - { - static std::string value() - { - return ""; - } - }; // struct reconstruction_layer_suffix<true, ...> - - template <bool anything> - struct reconstruction_layer_suffix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<reconstruction_layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<Backends::view>::value(); - } - }; // struct reconstruction_layer_suffix<false, ...> - - static std::string class_name() - { - return "OS2015_residual_product"; - } - - static std::string layer_suffix() - { - return XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value() + reconstruction_layer_suffix<>::value(); - } - - template <bool is_dd = (layer_type == Layers::dd_subdomain) || (layer_type == Layers::dd_subdomain_boundary) - || (layer_type == Layers::dd_subdomain_coupling) - || (layer_type == Layers::dd_subdomain_oversampled) - || (reconstruction_layer_type == Layers::dd_subdomain) - || (reconstruction_layer_type == Layers::dd_subdomain_boundary) - || (reconstruction_layer_type == Layers::dd_subdomain_coupling) - || (reconstruction_layer_type == Layers::dd_subdomain_oversampled), - bool anything = true> - struct factory_method - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t layer_level_or_subdomain, - const ssize_t reconstruction_layer_level_or_subdomain, - const typename type::ScalarFunctionType& lambda, - const typename type::ScalarFunctionType& lambda_hat, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& f, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate, - const double& poincare_constant) { - return new type(dd_grid_provider.template layer<layer_type, layer_backend>( - XT::Common::numeric_cast<int>(layer_level_or_subdomain)), - dd_grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level_or_subdomain)), - lambda, - lambda_hat, - kappa, - f, - u, - v, - poincare_constant, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "dd_grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "lambda_hat"_a, - "kappa"_a, - "f"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2, - "poincare_constant"_a = 1.0 / (M_PIl * M_PIl)); - } - }; // struct factory_method<true, ...> - - template <bool anything> - struct factory_method<false, anything> - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, - const ssize_t layer_level, - const ssize_t reconstruction_layer_level, - const typename type::ScalarFunctionType& lambda, - const typename type::ScalarFunctionType& lambda_hat, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& f, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate, - const double& poincare_constant) { - return new type( - grid_provider.template layer<layer_type, layer_backend>(XT::Common::numeric_cast<int>(layer_level)), - grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level)), - lambda, - lambda_hat, - kappa, - f, - u, - v, - poincare_constant, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "lambda_hat"_a, - "kappa"_a, - "f"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2, - "poincare_constant"_a = 1.0 / (M_PIl * M_PIl)); - - factory_method<true>::addbind(m); - } - }; // struct factory_method<false, ...> - - static void bind(py::module& m) - { - using namespace pybind11::literals; - - try { // we might not be the first ones to add this type - bound_type c(m, - XT::Common::to_camel_case(class_name() + "_" + XT::Grid::bindings::grid_name<G>::value() + "_" - + layer_suffix()) - .c_str(), - "OS2015::ResidualProduct"); - c.def("apply2", [](type& self) { return self.apply2(); }); - c.def("result", [](type& self) { return self.apply2(); }); - } catch (std::runtime_error& ee) { - } - - factory_method<>::addbind(m); - } // ... bind(...) -}; // struct ResidualProduct - - -template <class G, Layers layer_type, Backends layer_backend, Layers reconstruction_layer_type = layer_type> -struct DiffusiveFluxProduct -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename XT::Grid::Layer<G, layer_type, layer_backend, XT::Grid::DD::SubdomainGrid<G>>::type GL; - typedef - typename XT::Grid::Layer<G, reconstruction_layer_type, Backends::view, XT::Grid::DD::SubdomainGrid<G>>::type RGL; - - typedef GDT::OS2015::DiffusiveFluxProduct<GL, RGL> type; - typedef py::class_<type, XT::Grid::Walker<GL>> bound_type; - - template <bool is_same = (reconstruction_layer_type == layer_type) && (layer_backend == Backends::view), - bool anything = true> - struct reconstruction_layer_suffix - { - static std::string value() - { - return ""; - } - }; // struct reconstruction_layer_suffix<true, ...> - - template <bool anything> - struct reconstruction_layer_suffix<false, anything> - { - static std::string value() - { - return "_" + XT::Grid::bindings::layer_name<reconstruction_layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<Backends::view>::value(); - } - }; // struct reconstruction_layer_suffix<false, ...> - - static std::string class_name() - { - return "OS2015_diffusive_flux_product"; - } - - static std::string layer_suffix() - { - return XT::Grid::bindings::layer_name<layer_type>::value() + "_" - + XT::Grid::bindings::backend_name<layer_backend>::value() + reconstruction_layer_suffix<>::value(); - } - - template <bool is_dd = (layer_type == Layers::dd_subdomain) || (layer_type == Layers::dd_subdomain_boundary) - || (layer_type == Layers::dd_subdomain_coupling) - || (layer_type == Layers::dd_subdomain_oversampled) - || (reconstruction_layer_type == Layers::dd_subdomain) - || (reconstruction_layer_type == Layers::dd_subdomain_boundary) - || (reconstruction_layer_type == Layers::dd_subdomain_coupling) - || (reconstruction_layer_type == Layers::dd_subdomain_oversampled), - bool anything = true> - struct factory_method - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t layer_level_or_subdomain, - const ssize_t reconstruction_layer_level_or_subdomain, - const typename type::ScalarFunctionType& lambda, - const typename type::ScalarFunctionType& lambda_hat, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate) { - return new type(dd_grid_provider.template layer<layer_type, layer_backend>( - XT::Common::numeric_cast<int>(layer_level_or_subdomain)), - dd_grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level_or_subdomain)), - lambda, - lambda_hat, - kappa, - u, - v, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "dd_grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "lambda_hat"_a, - "kappa"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - } - }; // struct factory_method<true, ...> - - template <bool anything> - struct factory_method<false, anything> - { - static void addbind(py::module& m) - { - using namespace pybind11::literals; - - m.def(std::string("make_" + class_name() + "_" + layer_suffix()).c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, - const ssize_t layer_level, - const ssize_t reconstruction_layer_level, - const typename type::ScalarFunctionType& lambda, - const typename type::ScalarFunctionType& lambda_hat, - const typename type::TensorFunctionType& kappa, - const typename type::ScalarFunctionType& u, - const typename type::ScalarFunctionType& v, - const ssize_t over_integrate) { - return new type( - grid_provider.template layer<layer_type, layer_backend>(XT::Common::numeric_cast<int>(layer_level)), - grid_provider.template layer<reconstruction_layer_type, Backends::view>( - XT::Common::numeric_cast<int>(reconstruction_layer_level)), - lambda, - lambda_hat, - kappa, - u, - v, - XT::Common::numeric_cast<size_t>(over_integrate)); - }, - "grid_provider"_a, - "layer_level"_a = -1, - "reconstruction_layer_level"_a = -1, - "lambda"_a, - "lambda_hat"_a, - "kappa"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - - factory_method<true>::addbind(m); - } - }; // struct factory_method<false, ...> - - static void bind(py::module& m) - { - using namespace pybind11::literals; - - try { // we might not be the first ones to add this type - bound_type c(m, - XT::Common::to_camel_case(class_name() + "_" + XT::Grid::bindings::grid_name<G>::value() + "_" - + layer_suffix()) - .c_str(), - "OS2015::DiffusiveFluxProduct"); - c.def("apply2", [](type& self) { return self.apply2(); }); - c.def("result", [](type& self) { return self.apply2(); }); - } catch (std::runtime_error& ee) { - } - - factory_method<>::addbind(m); - } // ... bind(...) -}; // struct DiffusiveFluxProduct - - -PYBIND11_MODULE(__operators_OS2015, m) -{ - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - -# if HAVE_DUNE_ALUGRID - // This is not efficient: we reconstruct on the whole leaf instead of only the neighborhood, but the rt space - // on a dd_subdomain_oversampled grid view (which is a wrapped part) is broken, if based on - // a 2d simplex alugrid. - ResidualProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view, Layers::leaf>::bind(m); - DiffusiveFluxProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - DiffusiveFluxProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::leaf, Backends::view>::bind(m); - // s.a. - DiffusiveFluxProduct<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view, Layers::leaf>::bind(m); -# endif - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/playground/operators/OS2015.hh b/python/dune/gdt/playground/operators/OS2015.hh deleted file mode 100644 index b9b368337af7c5fdac5c897d7bbe1f48dfe2e93a..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/operators/OS2015.hh +++ /dev/null @@ -1,351 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef DUNE_GDT_PLAYGROUND_OPERATORS_OS2015_HH -#define DUNE_GDT_PLAYGROUND_OPERATORS_OS2015_HH - -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/common/typetraits.hh> - -# include <dune/geometry/quadraturerules.hh> -# include <dune/geometry/referenceelements.hh> - -# include <dune/xt/common/fmatrix.hh> -# include <dune/xt/la/container/eigen.hh> -# include <dune/xt/la/eigen-solver.hh> -# include <dune/xt/grid/boundaryinfo/interfaces.hh> -# include <dune/xt/grid/entity.hh> -# include <dune/xt/grid/type_traits.hh> -# include <dune/xt/functions/derived.hh> -# include <dune/xt/functions/interfaces/grid-function.hh> - -# include <dune/gdt/discretefunction/default.hh> -# include <dune/gdt/local/operators/integrals.hh> -# include <dune/gdt/local/integrands/lambda.hh> -# include <dune/gdt/operators/base.hh> -# include <dune/gdt/operators/fluxreconstruction.hh> -# include <dune/gdt/spaces/rt/default.hh> - -namespace Dune { -namespace GDT { -namespace OS2015 { -namespace internal { - - -template <class ProductGridLayer, class ReconstructionGridLayer> -class ResidualProductBase -{ - static_assert(XT::Grid::is_layer<ProductGridLayer>::value, ""); - static_assert(XT::Grid::is_layer<ReconstructionGridLayer>::value, ""); - -protected: - typedef XT::Grid::extract_entity_t<ProductGridLayer> E; - typedef typename ProductGridLayer::ctype D; - static const constexpr size_t d = ProductGridLayer::dimension; - typedef double R; - -private: - static_assert(std::is_same<XT::Grid::extract_entity_t<ReconstructionGridLayer>, E>::value, ""); - typedef ResidualProductBase<ProductGridLayer, ReconstructionGridLayer> ThisType; - -public: - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - -private: - typedef RaviartThomasSpace<ReconstructionGridLayer, 0, R> RtSpaceType; - typedef DiscreteFunction<RtSpaceType> FluxReconstructionType; - typedef XT::Functions::DivergenceFunction<FluxReconstructionType> DivergenceOfFluxReconstructionType; - typedef typename ScalarFunctionType::DifferenceType DifferenceType; - -public: - ResidualProductBase(ReconstructionGridLayer reconstruction_grid_layer, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const ScalarFunctionType& f, - const ScalarFunctionType& u, - const ScalarFunctionType& v) - : f_(f) - , rt_space_(reconstruction_grid_layer) - , reconstructed_u_(rt_space_) - , reconstructed_v_(rt_space_) - , divergence_of_reconstructed_u_(reconstructed_u_) - , divergence_of_reconstructed_v_(reconstructed_v_) - , f_minus_divergence_of_reconstructed_u_(f_ - divergence_of_reconstructed_u_) - , f_minus_divergence_of_reconstructed_v_(f_ - divergence_of_reconstructed_v_) - { - DiffusiveFluxReconstructionOperator<ReconstructionGridLayer, - ScalarFunctionType, - TensorFunctionType, - LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor> - flux_reconstruction(reconstruction_grid_layer, lambda, kappa); - flux_reconstruction.apply(u, reconstructed_u_); - flux_reconstruction.apply(v, reconstructed_v_); - } - - ResidualProductBase(const ThisType&) = delete; - ResidualProductBase(ThisType&&) = delete; - -protected: - const ScalarFunctionType& f_; - const RtSpaceType rt_space_; - FluxReconstructionType reconstructed_u_; - FluxReconstructionType reconstructed_v_; - const DivergenceOfFluxReconstructionType divergence_of_reconstructed_u_; - const DivergenceOfFluxReconstructionType divergence_of_reconstructed_v_; - const DifferenceType f_minus_divergence_of_reconstructed_u_; - const DifferenceType f_minus_divergence_of_reconstructed_v_; -}; // class ResidualProductBase - - -} // namespace internal - - -template <class ProductGridLayer, class ReconstructionGridLayer> -class ResidualProduct - : internal::ResidualProductBase<ProductGridLayer, ReconstructionGridLayer>, - public LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> -{ - typedef internal::ResidualProductBase<ProductGridLayer, ReconstructionGridLayer> ResidualProductBaseType; - typedef LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> - LocalizableProductBaseType; - -public: - using typename ResidualProductBaseType::ScalarFunctionType; - using typename ResidualProductBaseType::TensorFunctionType; - -private: - using typename ResidualProductBaseType::E; - using typename ResidualProductBaseType::D; - using ResidualProductBaseType::d; - using typename ResidualProductBaseType::R; - typedef LocalVolumeIntegralOperator<LocalLambdaBinaryVolumeIntegrand<E>, - typename ScalarFunctionType::LocalfunctionType> - LocalProductType; - -public: - ResidualProduct(ProductGridLayer product_grid_layer, - ReconstructionGridLayer reconstruction_grid_layer, - const ScalarFunctionType& lambda, - const ScalarFunctionType& lambda_hat, - const TensorFunctionType& kappa, - const ScalarFunctionType& f, - const ScalarFunctionType& u, - const ScalarFunctionType& v, - const double& poincare_constant = 1.0 / (M_PIl * M_PIl), - const size_t over_integrate = 2) - : ResidualProductBaseType(reconstruction_grid_layer, lambda, kappa, f, u, v) - , LocalizableProductBaseType(product_grid_layer, - this->f_minus_divergence_of_reconstructed_u_, - this->f_minus_divergence_of_reconstructed_v_) - , lambda_(lambda_hat) - , kappa_(kappa) - , poincare_constant_(poincare_constant) - , over_integrate_(over_integrate) - , local_product_( - // the order lambda - [&](const auto& local_f_minus_divergence_of_reconstructed_u, - const auto& local_f_minus_divergence_of_reconstructed_v) { - return local_f_minus_divergence_of_reconstructed_u.order() - + local_f_minus_divergence_of_reconstructed_v.order() + over_integrate_; - }, - // the evaluate lambda - [&](const auto& local_f_minus_divergence_of_reconstructed_u, - const auto& local_f_minus_divergence_of_reconstructed_v, - const auto& local_point, - auto& ret) { - ret[0][0] = local_f_minus_divergence_of_reconstructed_u.evaluate(local_point).at(0)[0] - * local_f_minus_divergence_of_reconstructed_v.evaluate(local_point).at(0)[0]; - }) - , min_diffusion_ev_(std::numeric_limits<R>::max()) - , subdomain_vertices_() - , finalized_(false) - { - this->append(local_product_); - - // the functor to collect all grid vertices - this->append([&](const E& entity) { - for (size_t cc = 0; cc < entity.subEntities(d); ++cc) - subdomain_vertices_.emplace_back(entity.template subEntity<d>(cc).geometry().center()); - }); - - // the functor to compute the min eigenvalue of the diffusion - this->append([&](const E& entity) { - const auto local_lambda = lambda_.local_function(entity); - const auto local_kappa = kappa_.local_function(entity); - // To find the minimum of a function we evaluate it - // * in all quadrature points of a quadrature which would integrate such a function exactly - for (const auto& quadrature_point : - QuadratureRules<D, d>::rule(entity.type(), local_lambda->order() + local_kappa->order() + over_integrate_)) { - const auto xx = quadrature_point.position(); - auto diffusion = local_kappa->evaluate(xx); - diffusion *= local_lambda->evaluate(xx); - min_diffusion_ev_ = std::min( - min_diffusion_ev_, - XT::LA::make_eigen_solver(diffusion, XT::Common::Configuration{{"assert_positive_eigenvalues"}, {1e-15}}) - .min_eigenvalues(1) - .at(0)); - } - // * and in the corners of the gigen entity. - const auto& reference_element = ReferenceElements<D, d>::general(entity.type()); - for (int ii = 0; ii < reference_element.size(d); ++ii) { - const auto xx = reference_element.position(ii, d); - auto diffusion = local_kappa->evaluate(xx); - diffusion *= local_lambda->evaluate(xx); - min_diffusion_ev_ = std::min( - min_diffusion_ev_, - XT::LA::make_eigen_solver(diffusion, XT::Common::Configuration{{"assert_positive_eigenvalues"}, {1e-15}}) - .min_eigenvalues(1) - .at(0)); - } - }); - } // ResidualProduct(...) - - R apply2() - { - if (!finalized_) { - this->walk(); - R subdomain_h = std::numeric_limits<R>::min(); - for (size_t ii = 0; ii < subdomain_vertices_.size(); ++ii) - for (size_t jj = ii + 1; jj < subdomain_vertices_.size(); ++jj) - subdomain_h = std::max(subdomain_h, (subdomain_vertices_[ii] - subdomain_vertices_[jj]).two_norm()); - this->result_ *= (poincare_constant_ / min_diffusion_ev_) * subdomain_h * subdomain_h; - } - return this->result_; - } - -private: - const ScalarFunctionType& lambda_; - const TensorFunctionType& kappa_; - const double poincare_constant_; - const size_t over_integrate_; - const LocalProductType local_product_; - R min_diffusion_ev_; - std::vector<FieldVector<D, d>> subdomain_vertices_; - bool finalized_; -}; // class ResidualProduct - - -template <class ProductGridLayer, class ReconstructionGridLayer> -class DiffusiveFluxProduct - : public LocalizableProductBase<ProductGridLayer, - XT::Functions::GridFunctionInterface<XT::Grid::extract_entity_t<ProductGridLayer>, - typename ProductGridLayer::ctype, - ProductGridLayer::dimension, - double, - 1>> -{ - static_assert(XT::Grid::is_layer<ProductGridLayer>::value, ""); - static_assert(XT::Grid::is_layer<ReconstructionGridLayer>::value, ""); - typedef XT::Grid::extract_entity_t<ProductGridLayer> E; - static_assert(std::is_same<XT::Grid::extract_entity_t<ReconstructionGridLayer>, E>::value, ""); - typedef typename ProductGridLayer::ctype D; - static const constexpr size_t d = ProductGridLayer::dimension; - typedef double R; - typedef DiffusiveFluxProduct<ProductGridLayer, ReconstructionGridLayer> ThisType; - -public: - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - -private: - typedef RaviartThomasSpace<ReconstructionGridLayer, 0, R> RtSpaceType; - typedef DiscreteFunction<RtSpaceType> FluxReconstructionType; - typedef LocalizableProductBase<ProductGridLayer, XT::Functions::GridFunctionInterface<E, D, d, R, 1>> BaseType; - typedef LocalVolumeIntegralOperator<LocalLambdaBinaryVolumeIntegrand<E>, - typename ScalarFunctionType::LocalfunctionType> - LocalProductType; - -public: - DiffusiveFluxProduct(ProductGridLayer product_grid_layer, - ReconstructionGridLayer reconstruction_grid_layer, - const ScalarFunctionType& lambda, - const ScalarFunctionType& lambda_hat, - const TensorFunctionType& kappa, - const ScalarFunctionType& u, - const ScalarFunctionType& v, - const size_t over_integrate = 2) - : BaseType(product_grid_layer, u, v) - , lambda_(lambda) - , lambda_hat_(lambda_hat) - , kappa_(kappa) - , rt_space_(reconstruction_grid_layer) - , reconstructed_u_(rt_space_) - , reconstructed_v_(rt_space_) - , over_integrate_(over_integrate) - , local_product_( - // the order lambda - [&](const auto& local_u, const auto& local_v) { - const auto& entity = local_u.entity(); - const size_t diffusion_order = - lambda_.local_function(entity)->order() + kappa_.local_function(entity)->order(); - return 3 * diffusion_order + size_t(std::max(ssize_t(local_u.order()) - 1, ssize_t(0))) - + size_t(std::max(ssize_t(local_v.order()) - 1, ssize_t(0))) + over_integrate_; - }, - // the evaluate lambda - [&](const auto& local_u, const auto& local_v, const auto& local_point, auto& ret) { - const auto& entity = local_u.entity(); - XT::Common::FieldMatrix<R, d, d> diffusion = kappa_.local_function(entity)->evaluate(local_point); - XT::Common::FieldMatrix<R, d, d> one_over_diffusion_hat = diffusion; - diffusion *= lambda_.local_function(entity)->evaluate(local_point); - one_over_diffusion_hat *= lambda_hat_.local_function(entity)->evaluate(local_point); - one_over_diffusion_hat.invert(); // there is no documented way to assert that the inversion was successfull - const auto grad_u = local_u.jacobian(local_point).at(0)[0]; - const auto grad_v = local_v.jacobian(local_point).at(0)[0]; - const auto val_reconstructed_u = reconstructed_u_.local_function(entity)->evaluate(local_point); - const auto val_reconstructed_v = reconstructed_v_.local_function(entity)->evaluate(local_point); - ret[0][0] = (one_over_diffusion_hat * ((diffusion * grad_u) + val_reconstructed_u)) // clang-format off - * ((diffusion * grad_v) + val_reconstructed_v); // clang-format on - }) - { - DiffusiveFluxReconstructionOperator<ReconstructionGridLayer, - ScalarFunctionType, - TensorFunctionType, - LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor> - flux_reconstruction(reconstruction_grid_layer, lambda, kappa); - flux_reconstruction.apply(u, reconstructed_u_); - flux_reconstruction.apply(v, reconstructed_v_); - this->append(local_product_); - } - - DiffusiveFluxProduct(const ThisType&) = delete; - DiffusiveFluxProduct(ThisType&&) = delete; - -private: - const ScalarFunctionType& lambda_; - const ScalarFunctionType& lambda_hat_; - const TensorFunctionType& kappa_; - const RtSpaceType rt_space_; - FluxReconstructionType reconstructed_u_; - FluxReconstructionType reconstructed_v_; - const size_t over_integrate_; - const LocalProductType local_product_; -}; // class DiffusiveFluxProduct - - -} // namespace OS2015 -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // DUNE_GDT_PLAYGROUND_OPERATORS_OS2015_HH diff --git a/python/dune/gdt/playground/operators/RS2017.cc b/python/dune/gdt/playground/operators/RS2017.cc deleted file mode 100644 index 64074df779c3c94401309505e2c4d913b77469e7..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/operators/RS2017.cc +++ /dev/null @@ -1,204 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_ALUGRID && HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <dune/xt/la/eigen-solver.hh> - -# include <dune/gdt/operators/elliptic.hh> - -# include <python/dune/gdt/playground/operators/RS2017.hh> - -using namespace Dune; -using namespace Dune::GDT::RS2017; -using XT::Grid::Backends; -using XT::Grid::Layers; -namespace py = pybind11; - - -PYBIND11_MODULE(__operators_RS2017, m) -{ - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - - SwipdgPenaltySubdomainProduct<ALU_2D_SIMPLEX_CONFORMING>::bind(m); - HdivSemiProduct<ALU_2D_SIMPLEX_CONFORMING>::bind(m); - DiffusiveFluxAaProduct<ALU_2D_SIMPLEX_CONFORMING>::bind(m); - DiffusiveFluxAbProduct<ALU_2D_SIMPLEX_CONFORMING>::bind(m); - DiffusiveFluxBbProduct<ALU_2D_SIMPLEX_CONFORMING>::bind(m); - ResidualPartFunctional<ALU_2D_SIMPLEX_CONFORMING>::bind(m); - - bind_neighborhood_reconstruction<ALU_2D_SIMPLEX_CONFORMING>(m); - bind_neighborhood_discretization<ALU_2D_SIMPLEX_CONFORMING>(m); - - typedef typename ALU_2D_SIMPLEX_CONFORMING::template Codim<0>::Entity E; - typedef double D; - static const constexpr size_t d = 2; - typedef double R; - - typedef XT::LA::IstlDenseVector<R> V; - typedef XT::LA::IstlRowMajorSparseMatrix<R> M; - - m.def("RS2017_residual_indicator_min_diffusion_eigenvalue", - [](XT::Grid::GridProvider<ALU_2D_SIMPLEX_CONFORMING, XT::Grid::DD::SubdomainGrid<ALU_2D_SIMPLEX_CONFORMING>>& - dd_grid_provider, - const ssize_t subdomain, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& lambda, - const XT::Functions::GridFunctionInterface<E, D, d, R, d, d>& kappa, - const ssize_t over_int) { - py::gil_scoped_release DUNE_UNUSED(release); - const auto over_integrate = XT::Common::numeric_cast<size_t>(over_int); - auto subdomain_layer = dd_grid_provider.template layer<Layers::dd_subdomain, Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)); - typedef decltype(subdomain_layer) GL; - XT::Grid::Walker<GL> walker(subdomain_layer); - double min_ev = std::numeric_limits<double>::max(); - walker.append([&](const E& entity) { - const auto local_lambda = lambda.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - // To find the minimum of a function we evaluate it - // * in all quadrature points of a quadrature which would integrate such a function exactly - for (const auto& quadrature_point : QuadratureRules<D, d>::rule( - entity.type(), local_lambda->order() + local_kappa->order() + over_integrate)) { - const auto xx = quadrature_point.position(); - auto diffusion = local_kappa->evaluate(xx); - diffusion *= local_lambda->evaluate(xx); - min_ev = std::min(min_ev, - XT::LA::make_eigen_solver( - diffusion, XT::Common::Configuration{{"assert_positive_eigenvalues"}, {1e-15}}) - .min_eigenvalues(1) - .at(0)); - } - // * and in the corners of the gigen entity. - const auto& reference_element = ReferenceElements<D, d>::general(entity.type()); - for (int ii = 0; ii < reference_element.size(d); ++ii) { - const auto xx = reference_element.position(ii, d); - auto diffusion = local_kappa->evaluate(xx); - diffusion *= local_lambda->evaluate(xx); - min_ev = std::min(min_ev, - XT::LA::make_eigen_solver( - diffusion, XT::Common::Configuration{{"assert_positive_eigenvalues"}, {1e-15}}) - .min_eigenvalues(1) - .at(0)); - } - }); - walker.walk(); - return min_ev; - }, - "dd_grid_provider"_a, - "subdomain"_a, - "lambda"_a, - "kappa"_a, - "over_integrate"_a = 2); - m.def("RS2017_residual_indicator_subdomain_diameter", - [](XT::Grid::GridProvider<ALU_2D_SIMPLEX_CONFORMING, XT::Grid::DD::SubdomainGrid<ALU_2D_SIMPLEX_CONFORMING>>& - dd_grid_provider, - const ssize_t subdomain) { - py::gil_scoped_release DUNE_UNUSED(release); - auto subdomain_layer = dd_grid_provider.template layer<Layers::dd_subdomain, Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)); - typedef decltype(subdomain_layer) GL; - XT::Grid::Walker<GL> walker(subdomain_layer); - std::vector<FieldVector<D, d>> subdomain_vertices; - walker.append([&](const E& entity) { - for (size_t cc = 0; cc < entity.subEntities(d); ++cc) - subdomain_vertices.emplace_back(entity.template subEntity<d>(cc).geometry().center()); - }); - walker.walk(); - R subdomain_h = std::numeric_limits<R>::min(); - for (size_t ii = 0; ii < subdomain_vertices.size(); ++ii) - for (size_t jj = ii + 1; jj < subdomain_vertices.size(); ++jj) - subdomain_h = std::max(subdomain_h, (subdomain_vertices[ii] - subdomain_vertices[jj]).two_norm()); - return subdomain_h; - }, - "dd_grid_provider"_a, - "subdomain"_a); - m.def("RS2017_apply_l2_product", - [](XT::Grid::GridProvider<ALU_2D_SIMPLEX_CONFORMING, XT::Grid::DD::SubdomainGrid<ALU_2D_SIMPLEX_CONFORMING>>& - dd_grid_provider, - const ssize_t subdomain, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& u, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& v, - const ssize_t over_integrate) { - py::gil_scoped_release DUNE_UNUSED(release); - return GDT::make_l2_operator(dd_grid_provider.template layer<Layers::dd_subdomain, Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - XT::Common::numeric_cast<size_t>(over_integrate)) - ->apply2(u, v); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "u"_a, - "v"_a, - "over_integrate"_a = 2); - - typedef GDT::EllipticMatrixOperator< - XT::Functions::GridFunctionInterface<E, D, d, R, 1>, - XT::Functions::GridFunctionInterface<E, D, d, R, d, d>, - typename GDT::SpaceProvider<ALU_2D_SIMPLEX_CONFORMING, - Layers::dd_subdomain, - GDT::SpaceType::dg, - GDT::Backends::gdt, - 1, - double, - 1>::type, - XT::LA::IstlRowMajorSparseMatrix<double>, - typename XT::Grid::Layer<ALU_2D_SIMPLEX_CONFORMING, Layers::dd_subdomain, Backends::view>::type> - EllipticMatrixOperatorType; - try { // we might not be the first to add this - py::class_<EllipticMatrixOperatorType, - GDT::SystemAssembler<typename EllipticMatrixOperatorType::SourceSpaceType, - typename EllipticMatrixOperatorType::GridLayerType>> - elliptic_matrix_operator(m, "EllipticMatrixOperatorNeighborhood"); - elliptic_matrix_operator.def("matrix", [](EllipticMatrixOperatorType& self) { return self.matrix(); }); - } catch (std::runtime_error&) { - } - m.def("RS2017_make_elliptic_matrix_operator_on_subdomain", - [](XT::Grid::GridProvider<ALU_2D_SIMPLEX_CONFORMING, XT::Grid::DD::SubdomainGrid<ALU_2D_SIMPLEX_CONFORMING>>& - dd_grid_provider, - const ssize_t subdomain, - const typename EllipticMatrixOperatorType::SourceSpaceType& space, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& lambda, - const XT::Functions::GridFunctionInterface<E, D, d, R, d, d>& kappa, - const ssize_t over_integrate) { - return new EllipticMatrixOperatorType(XT::Common::numeric_cast<ssize_t>(over_integrate), - lambda, - kappa, - space, - dd_grid_provider.template layer<Layers::dd_subdomain, Backends::view>( - XT::Common::numeric_cast<int>(subdomain))); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "space"_a, - "lambda"_a, - "kappa"_a, - "over_integrate"_a = 2); - - add_initialization(m, "dune.gdt.operators.elliptic"); -} - -#endif // HAVE_DUNE_ALUGRID && HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/playground/operators/RS2017.hh b/python/dune/gdt/playground/operators/RS2017.hh deleted file mode 100644 index 3992a5e2bd7c7d3ef46212f113d19295869becf2..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/operators/RS2017.hh +++ /dev/null @@ -1,1311 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef DUNE_GDT_PLAYGROUND_OPERATORS_RS2017_HH -#define DUNE_GDT_PLAYGROUND_OPERATORS_RS2017_HH - -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI -# include <type_traits> - -# include <dune/common/typetraits.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <dune/xt/common/numeric_cast.hh> -# include <dune/xt/la/container/istl.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/layers.hh> -# include <dune/xt/grid/type_traits.hh> -# include <dune/xt/functions/interfaces/grid-function.hh> - -# include <python/dune/gdt/assembler/system.hh> -# include <dune/gdt/functionals/elliptic-ipdg.hh> -# include <dune/gdt/functionals/l2.hh> -# include <dune/gdt/local/integrands/elliptic.hh> -# include <dune/gdt/local/integrands/elliptic-ipdg.hh> -# include <dune/gdt/local/integrands/lambda.hh> -# include <dune/gdt/local/operators/integrals.hh> -# include <dune/gdt/operators/base.hh> -# include <python/dune/gdt/operators/base.hh> -# include <dune/gdt/operators/elliptic-ipdg.hh> -# include <dune/gdt/operators/fluxreconstruction.hh> -# include <dune/gdt/operators/l2.hh> -# include <dune/gdt/spaces.hh> - -namespace Dune { -namespace GDT { -namespace RS2017 { - -# if HAVE_DUNE_ISTL - - -template <class G> -class DiffusiveFluxAaProduct - : public GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - typename GDT::SpaceProvider<G, - XT::Grid::Layers::dd_subdomain, - GDT::SpaceType::dg, - GDT::Backends::gdt, - 1, - double, - 1>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef typename GDT:: - SpaceProvider<G, XT::Grid::Layers::dd_subdomain, GDT::SpaceType::dg, GDT::Backends::gdt, 1, double, 1> - SP; - typedef GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - typename SP::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> - BaseType; - typedef DiffusiveFluxAaProduct<G> ThisType; - -public: - using typename BaseType::GridLayerType; - using typename BaseType::RangeSpaceType; - - typedef XT::Grid::extract_entity_t<GridLayerType> E; - typedef XT::Grid::extract_intersection_t<GridLayerType> I; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - typedef typename RangeSpaceType::BaseFunctionSetType BasisType; - - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - GDT::bindings::MatrixOperatorBase<ThisType>::bind( - m, - XT::Common::to_camel_case("RS2017_diffusive_flux_aa_product_matrix_operator_subdomain_" - + XT::Grid::bindings::grid_name<G>::value()) - .c_str()); - - m.def("RS2017_make_diffusive_flux_aa_product_matrix_operator_on_subdomain", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const RangeSpaceType& space, - const ScalarFunctionType& lambda_hat, - const ScalarFunctionType& lambda_u, - const ScalarFunctionType& lambda_v, - const TensorFunctionType& kappa, - const size_t over_integrate) { - return new ThisType( - space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - lambda_hat, - lambda_u, - lambda_v, - kappa, - over_integrate); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "space"_a, - "lambda_hat"_a, - "lambda_u"_a, - "lambda_v"_a, - "kappa"_a, - "over_integrate"_a = 2); - } // ... bind(...) - - DiffusiveFluxAaProduct(RangeSpaceType space, - GridLayerType grd_lyr, - const ScalarFunctionType& lambda_hat, - const ScalarFunctionType& lambda_u, - const ScalarFunctionType& lambda_v, - const TensorFunctionType& kappa, - const size_t over_integrate = 2) - : BaseType(space, grd_lyr) - , unit_matrix_(XT::Common::from_string<XT::Common::FieldMatrix<D, d, d>>("[1 0 0; 0 1 0; 0 0 1]")) - , over_integrate_(over_integrate) - , local_operator_( - [&](const auto& test_base, const auto& ansatz_base) { - const auto& entity = test_base.entity(); - const auto local_lambda_hat = lambda_hat.local_function(entity); - const auto local_lambda_u = lambda_u.local_function(entity); - const auto local_lambda_v = lambda_v.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - const auto integrand_order = local_lambda_hat->order() + local_lambda_u->order() + local_lambda_v->order() - + 3 * local_kappa->order() - + size_t(std::max(ssize_t(test_base.order()) - 1, ssize_t(0))) - + size_t(std::max(ssize_t(ansatz_base.order()) - 1, ssize_t(0))); - return integrand_order + over_integrate_; - }, - [&](const auto& test_base, const auto& ansatz_base, const auto& local_point, auto& ret) { - const auto& entity = test_base.entity(); - const auto local_lambda_hat = lambda_hat.local_function(entity); - const auto local_lambda_u = lambda_u.local_function(entity); - const auto local_lambda_v = lambda_v.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - XT::Common::FieldMatrix<D, d, d> diffusion_hat_inverse = local_kappa->evaluate(local_point); - XT::Common::FieldMatrix<D, d, d> diffusion_u = diffusion_hat_inverse; - XT::Common::FieldMatrix<D, d, d> diffusion_v = diffusion_hat_inverse; - diffusion_hat_inverse *= local_lambda_hat->evaluate(local_point); -# ifndef NDEBUG - const auto diffusion_hat = diffusion_hat_inverse; -# endif - diffusion_hat_inverse.invert(); -# ifndef NDEBUG - // there is no documented way to tell if the inversion was successfull - if (XT::Common::FloatCmp::ne(diffusion_hat_inverse * diffusion_hat, unit_matrix_)) - DUNE_THROW(XT::Common::Exceptions::internal_error, - "Local inversion of lambda_hat*kappa failed!\n\nx = " - << local_point - << "\nlocal_lambda_hat(x) = " - << local_lambda_hat->evaluate(local_point) - << "\nlocal_kappa(x) = " - << local_kappa->evaluate(local_point) - << "\ninverse = " - << diffusion_hat_inverse - << "\ninverse * (local_lambda_hat(x)*local_kappa(x))) = " - << diffusion_hat_inverse * diffusion_hat); -# endif - diffusion_u *= local_lambda_u->evaluate(local_point); - diffusion_v *= local_lambda_v->evaluate(local_point); - const auto test_grads = test_base.jacobian(local_point); - const auto ansatz_grads = ansatz_base.jacobian(local_point); - ret *= 0.; - for (size_t ii = 0; ii < test_base.size(); ++ii) - for (size_t jj = 0; jj < ansatz_base.size(); ++jj) - ret[ii][jj] = - ((diffusion_hat_inverse * (diffusion_u * ansatz_grads[jj][0])) * (diffusion_v * test_grads[ii][0])); - }) - { - this->append(local_operator_); - } - - DiffusiveFluxAaProduct(const ThisType&) = delete; - DiffusiveFluxAaProduct(ThisType&&) = delete; - -private: - const XT::Common::FieldMatrix<D, d, d> unit_matrix_; - const size_t over_integrate_; - const GDT::LocalVolumeIntegralOperator<GDT::LocalLambdaBinaryVolumeIntegrand<E, R, 1>, BasisType> local_operator_; -}; // class DiffusiveFluxAaProduct - - -template <class G> -class DiffusiveFluxAbProduct - : public GDT:: - MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - typename GDT::SpaceProvider<G, - XT::Grid::Layers::dd_subdomain, - GDT::SpaceType::dg, - GDT::Backends::gdt, - 1, - double, - 1>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>> -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - typename GDT::SpaceProvider<G, - XT::Grid::Layers::dd_subdomain, - GDT::SpaceType::dg, - GDT::Backends::gdt, - 1, - double, - 1>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>> - BaseType; - typedef DiffusiveFluxAbProduct<G> ThisType; - -public: - using typename BaseType::GridLayerType; - using typename BaseType::RangeSpaceType; - using typename BaseType::RangeBaseType; - using typename BaseType::SourceSpaceType; - using typename BaseType::SourceBaseType; - - typedef XT::Grid::extract_entity_t<GridLayerType> E; - typedef XT::Grid::extract_intersection_t<GridLayerType> I; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - py::class_<ThisType, XT::Grid::Walker<GridLayerType>> c( - m, - XT::Common::to_camel_case("RS2017_diffusive_flux_ab_product_matrix_operator_subdomain_" - + XT::Grid::bindings::grid_name<G>::value()) - .c_str()); - c.def("assemble", [](ThisType& self) { self.assemble(); }); - c.def("matrix", [](ThisType& self) { return self.matrix(); }); - - m.def("RS2017_make_diffusive_flux_ab_product_matrix_operator_on_subdomain", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const RangeSpaceType& range_space, - const SourceSpaceType& source_space, - const ScalarFunctionType& lambda_hat, - const ScalarFunctionType& lambda_range, - const TensorFunctionType& kappa, - const size_t over_integrate) { - return new ThisType( - range_space, - source_space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - lambda_hat, - lambda_range, - kappa, - over_integrate); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "range_space"_a, - "source_space"_a, - "lambda_hat"_a, - "lambda_range"_a, - "kappa"_a, - "over_integrate"_a = 2); - } // ... bind(...) - - DiffusiveFluxAbProduct(RangeSpaceType range_space, - SourceSpaceType source_space, - GridLayerType grd_lyr, - const ScalarFunctionType& lambda_hat, - const ScalarFunctionType& lambda_range, - const TensorFunctionType& kappa, - const size_t over_integrate = 2) - : BaseType(range_space, source_space, grd_lyr) - , unit_matrix_(XT::Common::from_string<XT::Common::FieldMatrix<D, d, d>>("[1 0 0; 0 1 0; 0 0 1]")) - , over_integrate_(over_integrate) - , local_operator_( - [&](const auto& test_base, const auto& ansatz_base) { - const auto& entity = test_base.entity(); - const auto local_lambda_hat = lambda_hat.local_function(entity); - const auto local_lambda_range = lambda_range.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - const auto integrand_order = - local_lambda_hat->order() + local_lambda_range->order() + 2 * local_kappa->order() - + size_t(std::max(ssize_t(test_base.order()) - 1, ssize_t(0))) + ansatz_base.order(); - return integrand_order + over_integrate_; - }, - [&](const auto& test_base, const auto& ansatz_base, const auto& local_point, auto& ret) { - const auto& entity = test_base.entity(); - const auto local_lambda_hat = lambda_hat.local_function(entity); - const auto local_lambda_range = lambda_range.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - XT::Common::FieldMatrix<D, d, d> diffusion_hat_inverse = local_kappa->evaluate(local_point); - XT::Common::FieldMatrix<D, d, d> diffusion_range = diffusion_hat_inverse; - diffusion_hat_inverse *= local_lambda_hat->evaluate(local_point); -# ifndef NDEBUG - const auto diffusion_hat = diffusion_hat_inverse; -# endif - diffusion_hat_inverse.invert(); -# ifndef NDEBUG - // there is no documented way to tell if the inversion was successfull - if (XT::Common::FloatCmp::ne(diffusion_hat_inverse * diffusion_hat, unit_matrix_)) - DUNE_THROW(XT::Common::Exceptions::internal_error, - "Local inversion of lambda_hat*kappa failed!\n\nx = " - << local_point - << "\nlocal_lambda_hat(x) = " - << local_lambda_hat->evaluate(local_point) - << "\nlocal_kappa(x) = " - << local_kappa->evaluate(local_point) - << "\ninverse = " - << diffusion_hat_inverse - << "\ninverse * (local_lambda_hat(x)*local_kappa(x))) = " - << diffusion_hat_inverse * diffusion_hat); -# endif - diffusion_range *= local_lambda_range->evaluate(local_point); - const auto test_grads = test_base.jacobian(local_point); - const auto ansatz_values = ansatz_base.evaluate(local_point); - ret *= 0.; - for (size_t ii = 0; ii < test_base.size(); ++ii) - for (size_t jj = 0; jj < ansatz_base.size(); ++jj) - ret[ii][jj] = ((diffusion_hat_inverse * (diffusion_range * test_grads[ii][0])) * (ansatz_values[jj])); - }) - { - this->append(local_operator_); - } - - DiffusiveFluxAbProduct(const ThisType&) = delete; - DiffusiveFluxAbProduct(ThisType&&) = delete; - -private: - const XT::Common::FieldMatrix<D, d, d> unit_matrix_; - const size_t over_integrate_; - const GDT::LocalVolumeIntegralOperator<GDT::LocalLambdaBinaryVolumeIntegrand<E, R, 1, 1, d, 1>, - RangeBaseType, - SourceBaseType> - local_operator_; -}; // class DiffusiveFluxAbProduct - - -template <class G> -class DiffusiveFluxBbProduct - : public GDT:: - MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> - BaseType; - typedef DiffusiveFluxBbProduct<G> ThisType; - -public: - using typename BaseType::GridLayerType; - using typename BaseType::RangeSpaceType; - using typename BaseType::RangeBaseType; - - typedef XT::Grid::extract_entity_t<GridLayerType> E; - typedef XT::Grid::extract_intersection_t<GridLayerType> I; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - py::class_<ThisType, XT::Grid::Walker<GridLayerType>> c( - m, - XT::Common::to_camel_case("RS2017_diffusive_flux_bb_product_matrix_operator_subdomain_" - + XT::Grid::bindings::grid_name<G>::value()) - .c_str()); - c.def("assemble", [](ThisType& self) { self.assemble(); }); - c.def("matrix", [](ThisType& self) { return self.matrix(); }); - - m.def("RS2017_make_diffusive_flux_bb_product_matrix_operator_on_subdomain", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const RangeSpaceType& space, - const ScalarFunctionType& lambda_hat, - const TensorFunctionType& kappa, - const size_t over_integrate) { - return new ThisType( - space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - lambda_hat, - kappa, - over_integrate); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "space"_a, - "lambda_hat"_a, - "kappa"_a, - "over_integrate"_a = 2); - } // ... bind(...) - - DiffusiveFluxBbProduct(RangeSpaceType space, - GridLayerType grd_lyr, - const ScalarFunctionType& lambda_hat, - const TensorFunctionType& kappa, - const size_t over_integrate = 2) - : BaseType(space, grd_lyr) - , unit_matrix_(XT::Common::from_string<XT::Common::FieldMatrix<D, d, d>>("[1 0 0; 0 1 0; 0 0 1]")) - , over_integrate_(over_integrate) - , local_operator_( - [&](const auto& test_base, const auto& ansatz_base) { - const auto& entity = test_base.entity(); - const auto local_lambda_hat = lambda_hat.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - const auto integrand_order = - local_lambda_hat->order() + local_kappa->order() + test_base.order() + ansatz_base.order(); - return integrand_order + over_integrate_; - }, - [&](const auto& test_base, const auto& ansatz_base, const auto& local_point, auto& ret) { - const auto& entity = test_base.entity(); - const auto local_lambda_hat = lambda_hat.local_function(entity); - const auto local_kappa = kappa.local_function(entity); - XT::Common::FieldMatrix<D, d, d> diffusion_hat_inverse = local_kappa->evaluate(local_point); - diffusion_hat_inverse *= local_lambda_hat->evaluate(local_point); -# ifndef NDEBUG - const auto diffusion_hat = diffusion_hat_inverse; -# endif - diffusion_hat_inverse.invert(); -# ifndef NDEBUG - // there is no documented way to tell if the inversion was successfull - if (XT::Common::FloatCmp::ne(diffusion_hat_inverse * diffusion_hat, unit_matrix_)) - DUNE_THROW(XT::Common::Exceptions::internal_error, - "Local inversion of lambda_hat*kappa failed!\n\nx = " - << local_point - << "\nlocal_lambda_hat(x) = " - << local_lambda_hat->evaluate(local_point) - << "\nlocal_kappa(x) = " - << local_kappa->evaluate(local_point) - << "\ninverse = " - << diffusion_hat_inverse - << "\ninverse * (local_lambda_hat(x)*local_kappa(x))) = " - << diffusion_hat_inverse * diffusion_hat); -# endif - const auto test_values = test_base.evaluate(local_point); - const auto ansatz_values = ansatz_base.evaluate(local_point); - ret *= 0.; - for (size_t ii = 0; ii < test_base.size(); ++ii) - for (size_t jj = 0; jj < ansatz_base.size(); ++jj) - ret[ii][jj] = ((diffusion_hat_inverse * test_values[ii]) * ansatz_values[jj]); - }) - { - this->append(local_operator_); - } - - DiffusiveFluxBbProduct(const ThisType&) = delete; - DiffusiveFluxBbProduct(ThisType&&) = delete; - -private: - const XT::Common::FieldMatrix<D, d, d> unit_matrix_; - const size_t over_integrate_; - const GDT::LocalVolumeIntegralOperator<GDT::LocalLambdaBinaryVolumeIntegrand<E, R, d, 1>, RangeBaseType> - local_operator_; -}; // class DiffusiveFluxBbProduct - - -template <class G> -class SwipdgPenaltySubdomainProduct - : public GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - typename GDT::SpaceProvider<G, - XT::Grid::Layers::dd_subdomain, - GDT::SpaceType::dg, - GDT::Backends::gdt, - 1, - double, - 1>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef GDT::SpaceProvider<G, XT::Grid::Layers::dd_subdomain, GDT::SpaceType::dg, GDT::Backends::gdt, 1, double, 1> - SP; - typedef GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - typename SP::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> - BaseType; - typedef SwipdgPenaltySubdomainProduct<G> ThisType; - -public: - using typename BaseType::GridLayerType; - using typename BaseType::RangeSpaceType; - - typedef XT::Grid::extract_entity_t<GridLayerType> E; - typedef XT::Grid::extract_intersection_t<GridLayerType> I; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> TensorFunctionType; - typedef typename RangeSpaceType::BaseFunctionSetType BasisType; - - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - GDT::bindings::MatrixOperatorBase<ThisType>::bind( - m, - XT::Common::to_camel_case("RS2017_penalty_product_matrix_operator_subdomain_" - + XT::Grid::bindings::grid_name<G>::value()) - .c_str()); - - m.def("RS2017_make_penalty_product_matrix_operator_on_subdomain", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const XT::Grid::BoundaryInfo<I>& boundary_info, - const RangeSpaceType& space, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const size_t over_integrate) { - return new ThisType( - space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - boundary_info, - lambda, - kappa, - over_integrate); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "boundary_info"_a, - "space"_a, - "lambda_bar"_a, - "kappa"_a, - "over_integrate"_a = 2); - } // ... bind(...) - - SwipdgPenaltySubdomainProduct(RangeSpaceType space, - GridLayerType grd_lyr, - const XT::Grid::BoundaryInfo<I>& boundary_info, - const ScalarFunctionType& lambda, - const TensorFunctionType& kappa, - const size_t over_integrate = 2) - : BaseType(space, grd_lyr) - , lambda_(lambda) - , kappa_(kappa) - , over_integrate_(over_integrate) - , local_coupling_operator_( - // the order lambda - [&](const auto& test_base_en, - const auto& ansatz_base_en, - const auto& test_base_ne, - const auto& ansatz_base_ne) { - const auto& entity = test_base_en.entity(); - const auto& neighbor = test_base_ne.entity(); - const auto local_lambda_en = lambda_.local_function(entity); - const auto local_lambda_ne = lambda_.local_function(neighbor); - const auto local_kappa_en = kappa_.local_function(entity); - const auto local_kappa_ne = kappa_.local_function(neighbor); - const auto integrand_order = std::max(local_lambda_en->order(), local_lambda_ne->order()) - + std::max(local_kappa_en->order(), local_kappa_ne->order()) - + std::max(test_base_en.order(), test_base_ne.order()) - + std::max(ansatz_base_en.order(), ansatz_base_ne.order()); - return integrand_order + over_integrate_; - }, - // The evaluate lambda, this is the penalty part of LocalEllipticIpdgIntegrands::Inner from - // dune/gdt/local/integrands/elliptic-ipdg.hh, swipdg_affine_factor variant. - [&](const auto& test_base_en, - const auto& ansatz_base_en, - const auto& test_base_ne, - const auto& ansatz_base_ne, - const auto& intersection, - const auto& local_point, - auto& ret_en_en, - auto& ret_ne_ne, - auto& ret_en_ne, - auto& ret_ne_en) { - // clear ret - ret_en_en *= 0.0; - ret_ne_ne *= 0.0; - ret_en_ne *= 0.0; - ret_ne_en *= 0.0; - // convert local point (which is in intersection coordinates) to entity/neighbor coordinates - const auto local_point_en = intersection.geometryInInside().global(local_point); - const auto local_point_ne = intersection.geometryInOutside().global(local_point); - const auto normal = intersection.unitOuterNormal(local_point); - // evaluate local function - const auto& entity = test_base_en.entity(); - const auto& neighbor = test_base_ne.entity(); - const auto lambda_val_en = lambda_.local_function(entity)->evaluate(local_point_en); - const auto lambda_val_ne = lambda_.local_function(neighbor)->evaluate(local_point_ne); - const XT::Common::FieldMatrix<D, d, d> kappa_val_en = - kappa_.local_function(entity)->evaluate(local_point_en); - const XT::Common::FieldMatrix<D, d, d> kappa_val_ne = - kappa_.local_function(neighbor)->evaluate(local_point_ne); - // compute penalty - const size_t max_polorder = - std::max(test_base_en.order(), - std::max(ansatz_base_en.order(), std::max(test_base_ne.order(), ansatz_base_ne.order()))); - const R sigma = GDT::LocalEllipticIpdgIntegrands::internal::inner_sigma(max_polorder); - const R delta_plus = normal * (kappa_val_ne * normal); - const R delta_minus = normal * (kappa_val_en * normal); - const R gamma = (delta_plus * delta_minus) / (delta_plus + delta_minus); - const auto h = intersection.geometry().volume(); - const auto beta = GDT::LocalEllipticIpdgIntegrands::internal::default_beta(d); - const R penalty = (0.5 * (lambda_val_en + lambda_val_ne) * sigma * gamma) / std::pow(h, beta); - // evaluate bases - const size_t rows_en = test_base_en.size(); - const size_t cols_en = ansatz_base_en.size(); - const size_t rows_ne = test_base_ne.size(); - const size_t cols_ne = ansatz_base_ne.size(); - const auto test_values_en = test_base_en.evaluate(local_point_en); - const auto ansatz_values_en = ansatz_base_en.evaluate(local_point_en); - const auto test_values_ne = test_base_ne.evaluate(local_point_ne); - const auto ansatz_values_ne = ansatz_base_ne.evaluate(local_point_ne); - // compute integrals, loop over all combinations of basis functions - assert(ret_en_en.rows() >= rows_en && ret_en_en.cols() >= cols_en); - assert(ret_en_ne.rows() >= rows_en && ret_en_ne.cols() >= cols_ne); - assert(ret_ne_en.rows() >= rows_ne && ret_ne_en.cols() >= cols_en); - assert(ret_ne_ne.rows() >= rows_ne && ret_ne_ne.cols() >= cols_ne); - for (size_t ii = 0; ii < rows_en; ++ii) { - for (size_t jj = 0; jj < cols_en; ++jj) - ret_en_en[ii][jj] += penalty * ansatz_values_en[jj] * test_values_en[ii]; - for (size_t jj = 0; jj < cols_ne; ++jj) - ret_en_ne[ii][jj] += -1.0 * penalty * ansatz_values_ne[jj] * test_values_en[ii]; - } - for (size_t ii = 0; ii < rows_ne; ++ii) { - for (size_t jj = 0; jj < cols_en; ++jj) - ret_ne_en[ii][jj] += -1.0 * penalty * ansatz_values_en[jj] * test_values_ne[ii]; - for (size_t jj = 0; jj < cols_ne; ++jj) - ret_ne_ne[ii][jj] += penalty * ansatz_values_ne[jj] * test_values_ne[ii]; - } - }) - , local_boundary_operator_( - // the order lambda - [&](const auto& test_base, const auto& ansatz_base) { - const auto& entity = test_base.entity(); - const auto local_lambda = lambda_.local_function(entity); - const auto local_kappa = kappa_.local_function(entity); - const auto integrand_order = - local_lambda->order() + local_kappa->order() + test_base.order() + ansatz_base.order(); - return integrand_order + over_integrate_; - }, - // The evaluate lambda, this is the penalty part of LocalEllipticIpdgIntegrands::BoundaryLHS from - // dune/gdt/local/integrands/elliptic-ipdg.hh, swipdg_affine_factor variant. - [&](const auto& test_base, - const auto& ansatz_base, - const auto& intersection, - const auto& local_point, - auto& ret) { - // clear ret - ret *= 0.0; - // get local point (which is in intersection coordinates) in entity coordinates - const auto local_point_entity = intersection.geometryInInside().global(local_point); - const auto normal = intersection.unitOuterNormal(local_point); - // evaluate local functions - const auto& entity = test_base.entity(); - XT::Common::FieldMatrix<D, d, d> diffusion = kappa_.local_function(entity)->evaluate(local_point_entity); - diffusion *= lambda_.local_function(entity)->evaluate(local_point_entity); - // compute penalty - const size_t max_polorder = std::max(test_base.order(), ansatz_base.order()); - const R sigma = GDT::LocalEllipticIpdgIntegrands::internal::boundary_sigma(max_polorder); - const R gamma = normal * (diffusion * normal); - const auto h = intersection.geometry().volume(); - const auto beta = GDT::LocalEllipticIpdgIntegrands::internal::default_beta(d); - const R penalty = (sigma * gamma) / std::pow(h, beta); - // evaluate bases - const size_t rows = test_base.size(); - const size_t cols = ansatz_base.size(); - const auto test_values = test_base.evaluate(local_point_entity); - const auto ansatz_values = ansatz_base.evaluate(local_point_entity); - // compute integrals, loop over all combinations of basis functions - assert(ret.rows() >= rows && ret.cols() >= cols); - for (size_t ii = 0; ii < rows; ++ii) - for (size_t jj = 0; jj < cols; ++jj) - ret[ii][jj] += penalty * ansatz_values[jj] * test_values[ii]; - }) - { - this->append(local_coupling_operator_, new XT::Grid::ApplyOn::InnerIntersectionsPrimally<GridLayerType>()); - this->append(local_boundary_operator_, new XT::Grid::ApplyOn::DirichletIntersections<GridLayerType>(boundary_info)); - } - - SwipdgPenaltySubdomainProduct(const ThisType&) = delete; - SwipdgPenaltySubdomainProduct(ThisType&&) = delete; - -private: - const ScalarFunctionType& lambda_; - const TensorFunctionType& kappa_; - const size_t over_integrate_; - const GDT::LocalCouplingIntegralOperator<GDT::LocalLambdaQuaternaryFaceIntegrand<E, I>, BasisType, I> - local_coupling_operator_; - const GDT::LocalBoundaryIntegralOperator<GDT::LocalLambdaBinaryFaceIntegrand<E, I>, BasisType, I> - local_boundary_operator_; -}; // class SwipdgPenaltySubdomainProduct - - -template <class G> -void bind_neighborhood_discretization(pybind11::module& m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename G::template Codim<0>::Entity E; - typedef double D; - static const constexpr size_t d = 2; - typedef double R; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> DF; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, d, d> DT; - - typedef typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain_oversampled, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type NGL; - typedef GDT:: - SpaceProvider<G, XT::Grid::Layers::dd_subdomain, GDT::SpaceType::block_dg, GDT::Backends::gdt, 1, double, 1> - SP; - typedef typename SP::type S; - typedef XT::LA::IstlDenseVector<R> V; - typedef XT::LA::IstlRowMajorSparseMatrix<R> M; - - try { // we might not be the first to add this SystemAssembler - GDT::bindings::SystemAssembler<SP, XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>::bind(m); - } catch (std::runtime_error&) { - } - - m.def("RS2017_make_neighborhood_system_assembler", - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const S& neighborhood_space) { - return new GDT::SystemAssembler<S, NGL>( - neighborhood_space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain))); - }); - - typedef GDT:: - EllipticIpdgMatrixOperator<DF, DT, S, GDT::LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor, M, NGL> - DgMatrixOperator; - py::class_<DgMatrixOperator, GDT::SystemAssembler<S, NGL>> dg_matrix_operator( - m, "EllipticIpdgMatrixOperatorNeighborhood"); - dg_matrix_operator.def("matrix", [](DgMatrixOperator& self) { return self.matrix(); }); - - m.def("RS2017_make_elliptic_swipdg_matrix_operator_on_neighborhood", - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<NGL>>& boundary_info, - const S& neighborhood_space, - const DF& lambda, - const DT& kappa, - const ssize_t over_integrate) { - return new DgMatrixOperator( - over_integrate, - boundary_info, - lambda, - kappa, - neighborhood_space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain))); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "boundary_info"_a, - "neighborhood_space"_a, - "lambda"_a, - "kappa"_a, - "over_integrate"_a = 2); - - typedef GDT::EllipticIpdgDirichletVectorFunctional<DF, - DF, - DT, - S, - GDT::LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor, - V, - NGL> - DgVectorFunctional; - py::class_<DgVectorFunctional, GDT::SystemAssembler<S, NGL>> dg_vector_functional( - m, "EllipticSwipdgVectorFunctionalNeighborhood"); - dg_vector_functional.def("vector", [](DgVectorFunctional& self) { return self.vector(); }); - - m.def("RS2017_make_elliptic_swipdg_vector_functional_on_neighborhood", - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<NGL>>& boundary_info, - const S& neighborhood_space, - const DF& g_D, - const DF& lambda, - const DT& kappa, - const ssize_t over_integrate) { - return new DgVectorFunctional( - over_integrate, - boundary_info, - g_D, - lambda, - kappa, - neighborhood_space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain))); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "boundary_info"_a, - "neighborhood_space"_a, - "g_D"_a, - "lambda"_a, - "kappa"_a, - "over_integrate"_a = 2); - - typedef GDT::L2VolumeVectorFunctional<DF, S, V, NGL> L2VolumeFunctional; - py::class_<L2VolumeFunctional, GDT::SystemAssembler<S, NGL>> l2_volume_vector_functional( - m, "L2VolumeVectorFunctionalNeighborhood"); - l2_volume_vector_functional.def("vector", [](L2VolumeFunctional& self) { return self.vector(); }); - - m.def("RS2017_make_l2_vector_functional_on_neighborhood", - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const S& neighborhood_space, - const DF& f, - const ssize_t over_integrate) { - return new L2VolumeFunctional( - over_integrate, - f, - neighborhood_space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain))); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "neighborhood_space"_a, - "f"_a, - "over_integrate"_a = 2); -} // ... bind_neighborhood_discretization(...) - - -template <class G> -class HdivSemiProduct - : public GDT:: - MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef GDT::MatrixOperatorBase<XT::LA::IstlRowMajorSparseMatrix<double>, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> - BaseType; - typedef HdivSemiProduct<G> ThisType; - -public: - using typename BaseType::GridLayerType; - using typename BaseType::RangeSpaceType; - - typedef XT::Grid::extract_entity_t<GridLayerType> E; - typedef XT::Grid::extract_intersection_t<GridLayerType> I; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - typedef typename RangeSpaceType::BaseFunctionSetType BasisType; - - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - py::class_<ThisType, XT::Grid::Walker<GridLayerType>> c( - m, - XT::Common::to_camel_case("RS2017_Hdiv_semi_product_matrix_operator_subdomain_" - + XT::Grid::bindings::grid_name<G>::value()) - .c_str()); - c.def("assemble", [](ThisType& self) { self.assemble(); }); - c.def("matrix", [](ThisType& self) { return self.matrix(); }); - - m.def("RS2017_make_Hdiv_semi_product_matrix_operator_on_subdomain", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const RangeSpaceType& space, - const size_t over_integrate) { - return new ThisType( - space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - over_integrate); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "space"_a, - "over_integrate"_a = 2); - } // ... bind(...) - - HdivSemiProduct(RangeSpaceType space, GridLayerType grd_lyr, const size_t over_integrate = 2) - : BaseType(space, grd_lyr) - , over_integrate_(over_integrate) - , local_operator_( - [&](const auto& test_base, const auto& ansatz_base) { - const auto integrand_order = std::max(ssize_t(test_base.order()) - 1, ssize_t(0)) - + std::max(ssize_t(ansatz_base.order()) - 1, ssize_t(0)); - return size_t(integrand_order) + over_integrate_; - }, - [&](const auto& test_base, const auto& ansatz_base, const auto& local_point, auto& ret) { - const auto test_gradient = test_base.jacobian(local_point); - const auto ansatz_gradient = ansatz_base.jacobian(local_point); - for (size_t ii = 0; ii < test_base.size(); ++ii) - for (size_t jj = 0; jj < ansatz_base.size(); ++jj) { - R test_divergence = 0.; - R ansatz_divergence = 0.; - for (size_t dd = 0; dd < d; ++dd) { - test_divergence += test_gradient[ii][dd][dd]; - ansatz_divergence += ansatz_gradient[jj][dd][dd]; - } - ret[ii][jj] = test_divergence * ansatz_divergence; - } - }) - { - this->append(local_operator_); - } - - HdivSemiProduct(const ThisType&) = delete; - HdivSemiProduct(ThisType&&) = delete; - -private: - const size_t over_integrate_; - const GDT::LocalVolumeIntegralOperator<GDT::LocalLambdaBinaryVolumeIntegrand<E, R, d>, BasisType> local_operator_; -}; // class HdivSemiProduct - - -template <class G> -class ResidualPartFunctional - : public GDT:: - VectorFunctionalBase<XT::LA::IstlDenseVector<double>, - GDT::RestrictedSpace<typename GDT::SpaceProvider<G, - XT::Grid::Layers::leaf, - GDT::SpaceType::rt, - GDT::Backends::gdt, - 0, - double, - G::dimension>::type, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type>, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> -{ - static_assert(XT::Grid::is_grid<G>::value, ""); - typedef GDT::RestrictedSpace< - typename GDT:: - SpaceProvider<G, XT::Grid::Layers::leaf, GDT::SpaceType::rt, GDT::Backends::gdt, 0, double, G::dimension>:: - type, - typename XT::Grid:: - Layer<G, XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view, XT::Grid::DD::SubdomainGrid<G>>::type> - RtSpaceType; - typedef GDT::VectorFunctionalBase<XT::LA::IstlDenseVector<double>, - RtSpaceType, - typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type> - BaseType; - typedef ResidualPartFunctional<G> ThisType; - -public: - using typename BaseType::GridLayerType; - using typename BaseType::SpaceType; - - typedef XT::Grid::extract_entity_t<GridLayerType> E; - typedef XT::Grid::extract_intersection_t<GridLayerType> I; - typedef typename G::ctype D; - static const constexpr size_t d = G::dimension; - typedef double R; - typedef XT::Functions::GridFunctionInterface<E, D, d, R, 1> ScalarFunctionType; - typedef typename SpaceType::BaseFunctionSetType BasisType; - - static void bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - py::class_<ThisType, XT::Grid::Walker<GridLayerType>> c( - m, - XT::Common::to_camel_case("RS2017_residual_part_vector_functional_subdomain_" - + XT::Grid::bindings::grid_name<G>::value()) - .c_str()); - c.def("assemble", [](ThisType& self) { self.assemble(); }); - c.def("vector", [](ThisType& self) { return self.vector(); }); - - m.def("RS2017_make_residual_part_vector_functional_on_subdomain", - [](const XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const SpaceType& space, - const ScalarFunctionType& f, - const size_t over_integrate) { - return new ThisType( - space, - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - f, - over_integrate); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "space"_a, - "f"_a, - "over_integrate"_a = 2); - } // ... bind(...) - - ResidualPartFunctional(SpaceType space, - GridLayerType grd_lyr, - const ScalarFunctionType& f, - const size_t over_integrate = 0) - : BaseType(space, grd_lyr) - , f_(f) - , over_integrate_(over_integrate) - , local_functional_( - [&](const auto& test_base) { - const auto integrand_order = ssize_t(f_.local_function(test_base.entity())->order()) - + std::max(ssize_t(test_base.order()) - 1, ssize_t(0)); - return size_t(integrand_order) + over_integrate_; - }, - [&](const auto& test_base, const auto& local_point, auto& ret) { - const auto local_f = f_.local_function(test_base.entity()); - ret *= 0.; - // f \times \divergence test - const auto test_jacobians = test_base.jacobian(local_point); - for (size_t ii = 0; ii < test_base.size(); ++ii) - for (size_t dd = 0; dd < d; ++dd) - ret[ii] += test_jacobians[ii][dd][dd]; - ret *= local_f->evaluate(local_point); - }) - { - this->append(local_functional_); - } - - ResidualPartFunctional(const ThisType&) = delete; - ResidualPartFunctional(ThisType&&) = delete; - -private: - const ScalarFunctionType& f_; - const size_t over_integrate_; - const GDT::LocalVolumeIntegralFunctional<GDT::LocalLambdaUnaryVolumeIntegrand<E, R, d, 1>, BasisType> - local_functional_; -}; // class ResidualPartFunctional - - -template <class G> -void bind_neighborhood_reconstruction(pybind11::module& m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename G::template Codim<0>::Entity E; - typedef double D; - static const constexpr size_t d = 2; - typedef double R; - typedef typename XT::Grid::Layer<G, XT::Grid::Layers::leaf, XT::Grid::Backends::view>::type LeafViewType; - typedef GDT::RaviartThomasSpace<LeafViewType, 0> RtSpaceType; - typedef typename XT::Grid::Layer<G, - XT::Grid::Layers::dd_subdomain_oversampled, - XT::Grid::Backends::view, - XT::Grid::DD::SubdomainGrid<G>>::type NeighborHoodGridLayer; - typedef GDT::RestrictedSpace<RtSpaceType, NeighborHoodGridLayer> NeighborhoodRtSpaceType; - typedef XT::LA::IstlDenseVector<R> VectorType; - typedef GDT:: - LocalizableDiffusiveFluxReconstructionOperator<NeighborHoodGridLayer, - XT::Functions::GridFunctionInterface<E, D, d, R, 1>, - GDT::DiscreteFunction<NeighborhoodRtSpaceType, VectorType>, - GDT::LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor> - LocalizableDiffusiveFluxReconstructionOperatorForRestrictedSpaceType; - - m.def("RS2017_apply_diffusive_flux_reconstruction_in_neighborhood", - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& lambda, - const XT::Functions::GridFunctionInterface<E, D, d, R, d, d>& kappa, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& u, - typename LocalizableDiffusiveFluxReconstructionOperatorForRestrictedSpaceType::RangeType& reconstructed_u, - const ssize_t over_integrate) { - py::gil_scoped_release DUNE_UNUSED(release); - LocalizableDiffusiveFluxReconstructionOperatorForRestrictedSpaceType( - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - lambda, - kappa, - u, - reconstructed_u, - over_integrate) - .apply(); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "lambda_hat"_a, - "kappa"_a, - "u"_a, - "reconstructed_u"_a, - "over_integrate"_a = 2); - - typedef GDT:: - LocalizableDiffusiveFluxReconstructionOperator<NeighborHoodGridLayer, - XT::Functions::GridFunctionInterface<E, D, d, R, 1>, - GDT::DiscreteFunction<RtSpaceType, VectorType>, - GDT::LocalEllipticIpdgIntegrands::Method::swipdg_affine_factor> - LocalizableDiffusiveFluxReconstructionOperatorForLeafSpaceType; - - m.def("RS2017_apply_diffusive_flux_reconstruction_in_neighborhood", - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider, - const ssize_t subdomain, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& lambda, - const XT::Functions::GridFunctionInterface<E, D, d, R, d, d>& kappa, - const XT::Functions::GridFunctionInterface<E, D, d, R, 1>& u, - typename LocalizableDiffusiveFluxReconstructionOperatorForLeafSpaceType::RangeType& reconstructed_u, - const ssize_t over_integrate) { - py::gil_scoped_release DUNE_UNUSED(release); - LocalizableDiffusiveFluxReconstructionOperatorForLeafSpaceType( - dd_grid_provider.template layer<XT::Grid::Layers::dd_subdomain_oversampled, XT::Grid::Backends::view>( - XT::Common::numeric_cast<size_t>(subdomain)), - lambda, - kappa, - u, - reconstructed_u, - over_integrate) - .apply(); - }, - "dd_grid_provider"_a, - "subdomain"_a, - "lambda_hat"_a, - "kappa"_a, - "u"_a, - "reconstructed_u"_a, - "over_integrate"_a = 2); -} // ... bind_neighborhood_reconstruction(...) - - -# else // HAVE_DUNE_ISTL - - -template <class G> -class DiffusiveFluxAaProduct -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -}; - - -template <class G> -class DiffusiveFluxAbProduct -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -}; - - -template <class G> -class DiffusiveFluxBbProduct -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -}; - - -template <class G> -class SwipdgPenaltySubdomainProduct -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -}; - - -template <class G> -void bind_neighborhood_discretization(pybind11::module& /*m*/) -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -} - - -template <class G> -class HdivSemiProduct -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -}; - - -template <class G> -class ResidualPartFunctional -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -}; - - -template <class G> -void bind_neighborhood_reconstruction(pybind11::module& /*m*/) -{ - static_assert(AlwaysFalse<G>::value, "You are missing dune-istl!"); -} - - -# endif // HAVE_DUNE_ISTL - -} // namespace RS2017 -} // namespace GDT -} // namespace Dune - -#endif // 0 -#endif // DUNE_GDT_PLAYGROUND_OPERATORS_RS2017_HH diff --git a/python/dune/gdt/playground/spaces/block.hh b/python/dune/gdt/playground/spaces/block.hh deleted file mode 100644 index 7cbadcd95ff233850b9ee8a0c96614200a18abd0..0000000000000000000000000000000000000000 --- a/python/dune/gdt/playground/spaces/block.hh +++ /dev/null @@ -1,453 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_PLAYGROUND_SPACES_BLOCK_BINDINGS_HH -#define PYTHON_DUNE_GDT_PLAYGROUND_SPACES_BLOCK_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/grid/common/rangegenerators.hh> - -# include <dune/xt/common/numeric_cast.hh> -# include <dune/xt/common/string.hh> -# include <dune/xt/la/container.hh> -# include <dune/xt/grid/gridprovider/provider.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <python/dune/xt/grid/grids.bindings.hh> - -# include <dune/gdt/assembler/system.hh> -# include <dune/gdt/discretefunction/default.hh> -# include <dune/gdt/projections.hh> -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/playground/spaces/block.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class SP> -class BlockMapper -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - using G = XT::Grid::extract_grid_t<typename S::GridLayerType>; - -public: - typedef GDT::BlockMapper<S> type; - typedef pybind11::class_<type> bound_type; - - template <XT::LA::Backends la> - static void addbind_matrix(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename XT::LA::Container<double, la>::MatrixType M; - - c.def("copy_local_to_global", - [](const type& self, - const M& local_matrix, - const XT::LA::SparsityPatternDefault& local_pattern, - const ssize_t block, - M& global_matrix) { - auto bb = XT::Common::numeric_cast<size_t>(block); - for (size_t local_ii = 0; local_ii < local_pattern.size(); ++local_ii) { - const size_t global_ii = self.mapToGlobal(bb, local_ii); - for (const size_t& local_jj : local_pattern.inner(local_ii)) { - const size_t global_jj = self.mapToGlobal(bb, local_jj); - global_matrix.add_to_entry(global_ii, global_jj, local_matrix.get_entry(local_ii, local_jj)); - } - } - }, - "local_matrix"_a, - "local_sparsity_pattern"_a, - "block"_a, - "global_matrix"_a); - c.def("copy_local_to_global", - [](const type& self, - const M& local_matrix, - const XT::LA::SparsityPatternDefault& local_pattern, - const ssize_t test_block, - const ssize_t ansatz_block, - M& global_matrix) { - auto tt = XT::Common::numeric_cast<size_t>(test_block); - auto aa = XT::Common::numeric_cast<size_t>(ansatz_block); - for (size_t local_ii = 0; local_ii < local_pattern.size(); ++local_ii) { - const size_t global_ii = self.mapToGlobal(tt, local_ii); - for (const size_t& local_jj : local_pattern.inner(local_ii)) { - const size_t global_jj = self.mapToGlobal(aa, local_jj); - global_matrix.add_to_entry(global_ii, global_jj, local_matrix.get_entry(local_ii, local_jj)); - } - } - }, - "local_matrix"_a, - "local_sparsity_pattern"_a, - "test_block"_a, - "ansatz_block"_a, - "global_matrix"_a); - } // ... addbind_matrix(...) - - template <XT::LA::Backends la> - static void addbind_vector(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename XT::LA::Container<double, la>::VectorType V; - - c.def("copy_local_to_global", - [](const type& self, const V& local_vector, const ssize_t block, V& global_vector) { - auto bb = XT::Common::numeric_cast<size_t>(block); - for (size_t local_ii = 0; local_ii < local_vector.size(); ++local_ii) { - const size_t global_ii = self.mapToGlobal(bb, local_ii); - global_vector.add_to_entry(global_ii, local_vector.get_entry(local_ii)); - } - }, - "local_vector"_a, - "block"_a, - "global_vector"_a); - } // ... addbind_vector(...) - - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case("block_" + space_name<SP>::value() + "_mappe"); - - bound_type c(m, ClassName.c_str()); - - c.def_property_readonly("size", [](const type& self) { return self.size(); }); - - // sparsity patterns - c.def("copy_local_to_global", - [](const type& self, - const XT::LA::SparsityPatternDefault& local_pattern, - const ssize_t block, - XT::LA::SparsityPatternDefault& global_pattern) { - auto bb = XT::Common::numeric_cast<size_t>(block); - for (size_t local_ii = 0; local_ii < local_pattern.size(); ++local_ii) { - const size_t global_ii = self.mapToGlobal(bb, local_ii); - const auto& local_rows = local_pattern.inner(local_ii); - for (const auto& local_jj : local_rows) { - const size_t global_jj = self.mapToGlobal(bb, local_jj); - global_pattern.insert(global_ii, global_jj); - } - } - }, - "local_sparsity_pattern"_a, - "block"_a, - "global_sparsity_pattern"_a); - c.def("copy_local_to_global", - [](const type& self, - const XT::LA::SparsityPatternDefault& local_pattern, - const ssize_t test_block, - const ssize_t ansatz_block, - XT::LA::SparsityPatternDefault& global_pattern) { - auto tt = XT::Common::numeric_cast<size_t>(test_block); - auto aa = XT::Common::numeric_cast<size_t>(ansatz_block); - for (size_t local_ii = 0; local_ii < local_pattern.size(); ++local_ii) { - const size_t global_ii = self.mapToGlobal(tt, local_ii); - const auto& local_rows = local_pattern.inner(local_ii); - for (const auto& local_jj : local_rows) { - const size_t global_jj = self.mapToGlobal(aa, local_jj); - global_pattern.insert(global_ii, global_jj); - } - } - }, - "local_sparsity_pattern"_a, - "test_block"_a, - "ansatz_block"_a, - "global_sparsity_pattern"_a); - - // matrices - addbind_matrix<XT::LA::Backends::common_dense>(c); - addbind_matrix<XT::LA::Backends::common_sparse>(c); -# if HAVE_EIGEN - addbind_matrix<XT::LA::Backends::eigen_dense>(c); - addbind_matrix<XT::LA::Backends::eigen_sparse>(c); -# endif -# if HAVE_DUNE_ISTL - addbind_matrix<XT::LA::Backends::istl_sparse>(c); -# endif - - // vectors - addbind_vector<XT::LA::Backends::common_dense>(c); -# if HAVE_EIGEN - addbind_vector<XT::LA::Backends::eigen_dense>(c); -# endif -# if HAVE_DUNE_ISTL - addbind_vector<XT::LA::Backends::istl_dense>(c); -# endif - - return c; - } // ... bind(...) -}; // class BlockMapper - - -template <class SP> -class BlockSpace -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - using G = XT::Grid::extract_grid_t<typename S::GridLayerType>; - -public: - typedef GDT::BlockSpace<S> type; - typedef pybind11::class_<type> bound_type; - -private: - template <bool is_dg = (SP::space_type == SpaceType::dg), bool anything = false> - struct projector - { - template <class V> - static V project(const type& self, const std::vector<V>& local_vectors, const std::vector<size_t>& subdomains) - { - V neighborhood_vector(self.mapper().size(), 0.); - assert(local_vectors.size() == subdomains.size() && "This should not happen, blame the caller!"); - for (size_t ii = 0; ii < local_vectors.size(); ++ii) { - const auto subdomain = subdomains[ii]; - const auto& local_vector = local_vectors[ii]; - for (size_t jj = 0; jj < local_vector.size(); ++jj) - neighborhood_vector[self.mapper().mapToGlobal(subdomain, jj)] = local_vector[jj]; - } - return neighborhood_vector; - } - }; // struct projector<true, ...> - - template <bool anything> - struct projector<false, anything> - { - template <class V> - static V project(const type&, const std::vector<V>&, const std::vector<size_t>&) - { - static_assert(AlwaysFalse<V>::value, "Not implemented for non DG spaces"); - } - }; - - template <XT::LA::Backends la> - static void addbind_vector(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef typename XT::LA::Container<double, la>::VectorType V; - - c.def("project_onto_neighborhood", - [](const type& self, const std::vector<V>& local_vectors, const std::vector<ssize_t>& neighborhood) { - if (local_vectors.size() != neighborhood.size()) - DUNE_THROW(XT::Common::Exceptions::shapes_do_not_match, - "local_vectors.size(): " << local_vectors.size() << "\n neighborhood.size(): " - << neighborhood.size()); - std::vector<size_t> subdomains(neighborhood.size()); - for (size_t ii = 0; ii < neighborhood.size(); ++ii) - subdomains[ii] = XT::Common::numeric_cast<size_t>(neighborhood[ii]); - std::vector<std::shared_ptr<const S>> neighborhood_spaces(self.dd_grid().size(), nullptr); - for (const auto& subdomain : subdomains) { - if (self.backend()[subdomain] == nullptr) - DUNE_THROW(XT::Common::Exceptions::you_are_using_this_wrong, - "This BlockSpace (restricted to a neighborhood) does not have a local space for subdomain " - << subdomain - << "!"); - neighborhood_spaces[subdomain] = self.backend()[subdomain]; - } - const type neighborhood_space(self.dd_grid(), neighborhood_spaces); - return projector<>::project(neighborhood_space, local_vectors, subdomains); - }, - "local_vectors"_a, - "neighborhood"_a); - } // ... addbind_vector(...) - -public: - static bound_type bind(pybind11::module& m) - { - BlockMapper<SP>::bind(m); - - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case("block_" + space_name<SP>::value()); - - bound_type c(m, ClassName.c_str(), ClassName.c_str()); // metaclass required for static properties - - c.def("__init__", - [](type& self, XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider) { - const auto& dd_grid = dd_grid_provider.dd_grid(); - std::vector<std::shared_ptr<const S>> local_spaces(dd_grid.size()); - for (size_t ss = 0; ss < dd_grid.size(); ++ss) - local_spaces[ss] = std::make_shared<S>(SP::create(dd_grid_provider, boost::numeric_cast<int>(ss))); - try { - new (&self) type(dd_grid, local_spaces); - } catch (...) { - self.~type(); - throw; - } - }, - "dd_grid"_a, - py::keep_alive<1, 2>()); - c.def_property_readonly("dimDomain", [](const type& /*self*/) { return S::dimDomain; }); - c.def_property_readonly("dimRange", [](const type& /*self*/) { return S::dimRange; }); - c.def_property_readonly("dimRangeCols", [](const type& /*self*/) { return S::dimRangeCols; }); - c.def_property_readonly("polOrder", [](const type& /*self*/) { return S::polOrder; }); - c.def_property_readonly("num_blocks", [](const type& self) { return self.num_blocks(); }); - c.def_property_readonly("mapper", - [](const type& self) { - // we get a segfault without the explicit copy - return std::decay_t<decltype(self.mapper())>(self.mapper()); - }, - py::keep_alive<0, 1>()); - // these need to be defined *after* their non static counterparts - c.def_property_readonly_static("dimDomain", [](const type& /*self*/) { return S::dimDomain; }); - c.def_property_readonly_static("dimRange", [](const type& /*self*/) { return S::dimRange; }); - c.def_property_readonly_static("dimRangeCols", [](const type& /*self*/) { return S::dimRangeCols; }); - c.def_property_readonly_static("polOrder", [](const type& /*self*/) { return S::polOrder; }); - c.def("local_space", - [](const type& self, ssize_t block) { return self.local_space(XT::Common::numeric_cast<size_t>(block)); }, - "block"_a); - c.def("compute_boundary_pattern", - [](const type& self, const ssize_t block, const std::string tp) { - auto bb = XT::Common::numeric_cast<size_t>(block); - if (tp == "volume") - return self.local_space(bb).compute_volume_pattern(self.dd_grid().boundary_grid_view(bb)); - else if (tp == "face") - return self.local_space(bb).compute_face_pattern(self.dd_grid().boundary_grid_view(bb)); - else if (tp == "face_and_volume") - return self.local_space(bb).compute_face_and_volume_pattern(self.dd_grid().boundary_grid_view(bb)); - else - DUNE_THROW(XT::Common::Exceptions::wrong_input_given, - " type has to be one of ('volume', 'face', 'face_and_volume'), is '" << tp << "'!"); - // we will never get here - return XT::LA::SparsityPatternDefault(); - }, - "block"_a, - "type"_a); - c.def("compute_coupling_pattern", - [](const type& self, const ssize_t subdomain, const ssize_t neighbor, const std::string tp) { - auto ss = XT::Common::numeric_cast<size_t>(subdomain); - auto nn = XT::Common::numeric_cast<size_t>(neighbor); - if (tp == "volume") - return self.local_space(ss).compute_volume_pattern(self.dd_grid().coupling_grid_view(ss, nn), - self.local_space(nn)); - else if (tp == "face") - return self.local_space(ss).compute_face_pattern(self.dd_grid().coupling_grid_view(ss, nn), - self.local_space(nn)); - else if (tp == "face_and_volume") - return self.local_space(ss).compute_face_and_volume_pattern(self.dd_grid().coupling_grid_view(ss, nn), - self.local_space(nn)); - else - DUNE_THROW(XT::Common::Exceptions::wrong_input_given, - " type has to be one of ('volume', 'face', 'face_and_volume'), is '" << tp << "'!"); - // we will never get here - return XT::LA::SparsityPatternDefault(); - }, - "block_subdomain"_a, - "neighboring_subdomain"_a, - "type"_a); - c.def("boundary_assembler", - [](const type& self, const ssize_t subdomain) { - auto ss = XT::Common::numeric_cast<size_t>(subdomain); - auto boundary_grid_part = self.dd_grid().boundary_grid_view(ss); - return new GDT::SystemAssembler<S, decltype(boundary_grid_part), S>(self.local_space(ss), // see below for - boundary_grid_part); // the 'new' - }, - "subdomain"_a); - c.def("coupling_assembler", - [](const type& self, const ssize_t subdomain, const ssize_t neighbor) { - auto ss = XT::Common::numeric_cast<size_t>(subdomain); - auto nn = XT::Common::numeric_cast<size_t>(neighbor); - auto coupling_grid_part = self.dd_grid().coupling_grid_view(ss, nn); - return new GDT::SystemAssembler<S, decltype(coupling_grid_part), S>(coupling_grid_part, // SystemAssembler - self.local_space(ss), // is not copyable - self.local_space(ss), // or movable, - self.local_space(nn), // thus the raw - self.local_space(nn)); // pointer - }, - "subdomain"_a, - "neighbor"_a); - c.def("restricted_to_neighborhood", - [](const type& self, const std::vector<ssize_t>& neighborhood) { - std::vector<std::shared_ptr<const S>> neighborhood_spaces(self.dd_grid().size(), nullptr); - for (const auto& subdomain : neighborhood) - neighborhood_spaces[subdomain] = self.backend()[XT::Common::numeric_cast<size_t>(subdomain)]; - return type(self.dd_grid(), neighborhood_spaces); - }, - "neighborhood"_a); - - addbind_vector<XT::LA::Backends::common_dense>(c); -# if HAVE_EIGEN - addbind_vector<XT::LA::Backends::eigen_dense>(c); -# endif -# if HAVE_DUNE_ISTL - addbind_vector<XT::LA::Backends::istl_dense>(c); -# endif - - const std::string factory_method_name = "make_block_" + space_name<SP>::value_wo_grid(); - m.def(factory_method_name.c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& dd_grid_provider) { - const auto& dd_grid = dd_grid_provider.dd_grid(); - std::vector<std::shared_ptr<const S>> local_spaces(dd_grid.size()); - for (size_t ss = 0; ss < dd_grid.size(); ++ss) - local_spaces[ss] = std::make_shared<S>(SP::create(dd_grid_provider, boost::numeric_cast<int>(ss))); - return type(dd_grid, local_spaces); - }, - "dd_grid_provider"_a); - - return c; - } // ... bind(...) -}; // class BlockSpace - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_SPACES_BLOCK_BIND(_m, _GRID, _s_type, _s_backend, _p) \ - Dune::GDT::bindings::BlockSpace<Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::dd_subdomain, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>>::bind(_m) - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_SPACES_BLOCK_BIND_ALU(_m, _s_type, _s_backend, _p) \ - _DUNE_GDT_SPACES_BLOCK_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, _s_type, _s_backend, _p) -# else -# define _DUNE_GDT_SPACES_BLOCK_BIND_ALU(_m, _s_type, _s_backend, _p) -# endif - -# define _DUNE_GDT_SPACES_BLOCK_BIND_YASP(_m, _s_type, _s_backend, _p) \ - _DUNE_GDT_SPACES_BLOCK_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, _s_type, _s_backend, _p); \ - _DUNE_GDT_SPACES_BLOCK_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, _s_type, _s_backend, _p) - -# define _DUNE_GDT_SPACES_BLOCK_BIND_ALL_GRIDS(_m, _s_type, _s_backend, _p) \ - _DUNE_GDT_SPACES_BLOCK_BIND_ALU(_m, _s_type, _s_backend, _p); \ - _DUNE_GDT_SPACES_BLOCK_BIND_YASP(_m, _s_type, _s_backend, _p) - - -# define DUNE_GDT_SPACES_BLOCK_BIND(_m) _DUNE_GDT_SPACES_BLOCK_BIND_ALL_GRIDS(_m, dg, gdt, 1) -# define _DUNE_GDT_SPACES_BLOCK_BIND_FEM(_m) _DUNE_GDT_SPACES_BLOCK_BIND_ALL_GRIDS(_m, dg, gdt, 1) - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_PLAYGROUND_SPACES_BLOCK_BINDINGS_HH diff --git a/python/dune/gdt/projections/bindings.cc b/python/dune/gdt/projections/bindings.cc deleted file mode 100644 index 93fcf43079acac3c27f171673526cfeda60ca0ba..0000000000000000000000000000000000000000 --- a/python/dune/gdt/projections/bindings.cc +++ /dev/null @@ -1,46 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) - -#include "config.h" - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <python/dune/gdt/shared.hh> - -# include <dune/gdt/projections/bindings.hh> -# include <python/dune/gdt/projections/dirichlet.hh> - - -PYBIND11_MODULE(__projections, m) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - Dune::XT::Common::bindings::addbind_exceptions(m); - - py::module::import("dune.xt.common"); - py::module::import("dune.xt.grid"); - py::module::import("dune.xt.functions"); - py::module::import("dune.xt.la"); - py::module::import("dune.gdt.__spaces"); - - DUNE_GDT_PROJECTIONS_BIND(m); - DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(m); - - add_initialization(m, "dune.gdt.projections"); -} - -#endif // HAVE_DUNE_PYBINDXI diff --git a/python/dune/gdt/projections/bindings.hh b/python/dune/gdt/projections/bindings.hh deleted file mode 100644 index 90f8401e30ed493ba3f66e13d9ea595efd44ba26..0000000000000000000000000000000000000000 --- a/python/dune/gdt/projections/bindings.hh +++ /dev/null @@ -1,150 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_PROJECTIONS_BINDINGS_HH -#define PYTHON_DUNE_GDT_PROJECTIONS_BINDINGS_HH - -// Todo: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/projections.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class SP, class V> -class project -{ - typedef typename SP::type SpaceType; - static_assert(is_space<SpaceType>::value, ""); - static_assert(XT::LA::is_vector<V>::value, ""); - typedef typename XT::Functions::GridFunctionInterface<typename SpaceType::EntityType, - typename SpaceType::DomainFieldType, - SpaceType::dimDomain, - typename SpaceType::RangeFieldType, - SpaceType::dimRange, - SpaceType::dimRangeCols> - SourceType; - typedef DiscreteFunction<SpaceType, V> RangeType; - -public: - static void bind(pybind11::module& m) - { - using namespace pybind11::literals; - - m.def("project", - [](const SourceType& source, RangeType& range, const size_t over_integrate) { - GDT::project(source, range, over_integrate); - }, - "source"_a, - "range"_a, - "over_integrate"_a = 0); - } // ... bind(...) -}; // class project - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_PROJECTIONS_BIND(_m, _GRID, _g_layer, _s_backend, _s_type, _p, _la) \ - Dune::GDT::bindings::project< \ - Dune::GDT::SpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_g_layer, \ - Dune::GDT::SpaceType::_s_type, \ - Dune::GDT::Backends::_s_backend, \ - _p, \ - double, \ - 1, \ - 1>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m) - -// for each grid - -//#if HAVE_ALBERTA -// ... -//#else -# define _DUNE_GDT_PROJECTIONS_BIND_ALBERTA(_m, _g_layer, _s_backend, _s_type, _p, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_PROJECTIONS_BIND_ALU(_m, _g_layer, _s_backend, _s_type, _p, _la) \ - _DUNE_GDT_PROJECTIONS_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, _g_layer, _s_backend, _s_type, _p, _la) -# else -# define _DUNE_GDT_PROJECTIONS_BIND_ALU(_m, _g_layer, _s_backend, _s_type, _p, _la) -# endif - -//#if HAVE_DUNE_UGGRID || HAVE_UG -// ... -//#else -# define _DUNE_GDT_PROJECTIONS_BIND_UG(_m, _g_layer, _s_backend, _s_type, _p, _la) -//#endif - -# define _DUNE_GDT_PROJECTIONS_BIND_YASP(_m, _g_layer, _s_backend, _s_type, _p, _la) \ - _DUNE_GDT_PROJECTIONS_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, _g_layer, _s_backend, _s_type, _p, _la); \ - _DUNE_GDT_PROJECTIONS_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, _g_layer, _s_backend, _s_type, _p, _la) - -# define _DUNE_GDT_PROJECTIONS_BIND_ALL_GRIDS(_m, _g_layer, _s_backend, _s_type, _p, _la) \ - _DUNE_GDT_PROJECTIONS_BIND_ALBERTA(_m, _g_layer, _s_backend, _s_type, _p, _la); \ - _DUNE_GDT_PROJECTIONS_BIND_ALU(_m, _g_layer, _s_backend, _s_type, _p, _la); \ - _DUNE_GDT_PROJECTIONS_BIND_UG(_m, _g_layer, _s_backend, _s_type, _p, _la); \ - _DUNE_GDT_PROJECTIONS_BIND_YASP(_m, _g_layer, _s_backend, _s_type, _p, _la) - -// for each space backend - -# define _DUNE_GDT_PROJECTIONS_BIND_DEFAULT(_m, _la) \ - _DUNE_GDT_PROJECTIONS_BIND_ALL_GRIDS(_m, leaf, gdt, fv, 0, _la); \ - _DUNE_GDT_PROJECTIONS_BIND_ALL_GRIDS(_m, dd_subdomain, gdt, cg, 1, _la); \ - _DUNE_GDT_PROJECTIONS_BIND_ALL_GRIDS(_m, level, gdt, fv, 0, _la); \ - _DUNE_GDT_PROJECTIONS_BIND_ALL_GRIDS(_m, dd_subdomain, gdt, dg, 1, _la) - - -# define _DUNE_GDT_PROJECTIONS_BIND_ALL_SPACES(_m, _la) _DUNE_GDT_PROJECTIONS_BIND_DEFAULT(_m, _la); - -// for each la backend - -//#define _DUNE_GDT_PROJECTIONS_BIND_COMMON(_m) _DUNE_GDT_PROJECTIONS_BIND_ALL_SPACES(_m, common_dense) -# define _DUNE_GDT_PROJECTIONS_BIND_COMMON(_m) - -//#if HAVE_EIGEN -//#define _DUNE_GDT_PROJECTIONS_BIND_EIGEN(_m) _DUNE_GDT_PROJECTIONS_BIND_ALL_SPACES(_m, eigen_dense) -//#else -# define _DUNE_GDT_PROJECTIONS_BIND_EIGEN(_m) -//#endif - -# if HAVE_DUNE_ISTL -# define _DUNE_GDT_PROJECTIONS_BIND_ISTL(_m) _DUNE_GDT_PROJECTIONS_BIND_ALL_SPACES(_m, istl_dense) -# else -# define _DUNE_GDT_PROJECTIONS_BIND_ISTL(_m) -# endif - -# define DUNE_GDT_PROJECTIONS_BIND(_m) \ - _DUNE_GDT_PROJECTIONS_BIND_COMMON(_m); \ - _DUNE_GDT_PROJECTIONS_BIND_EIGEN(_m); \ - _DUNE_GDT_PROJECTIONS_BIND_ISTL(_m) - -// end: this is what we need for the .so - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_PROJECTIONS_BINDINGS_HH diff --git a/python/dune/gdt/projections/dirichlet.hh b/python/dune/gdt/projections/dirichlet.hh deleted file mode 100644 index 50038a1b68ec8134db849d5f4af8e6302bfbcece..0000000000000000000000000000000000000000 --- a/python/dune/gdt/projections/dirichlet.hh +++ /dev/null @@ -1,160 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_PROJECTIONS_DIRICHLET_BINDINGS_HH -#define PYTHON_DUNE_GDT_PROJECTIONS_DIRICHLET_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/spaces/bindings.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/projections/dirichlet.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class SP, class V> -class DirichletProjectionLocalizableOperator -{ - typedef typename SP::type SpaceType; - static_assert(is_space<SpaceType>::value, ""); - static_assert(XT::LA::is_vector<V>::value, ""); - typedef typename SpaceType::GridLayerType GridLayerType; - typedef typename XT::Functions::GridFunctionInterface<typename SpaceType::EntityType, - typename SpaceType::DomainFieldType, - SpaceType::dimDomain, - typename SpaceType::RangeFieldType, - SpaceType::dimRange, - SpaceType::dimRangeCols> - SourceType; - typedef DiscreteFunction<SpaceType, V> RangeType; - typedef XT::Grid::Walker<GridLayerType> BaseType; - -public: - typedef GDT::DirichletProjectionLocalizableOperator<GridLayerType, SourceType, RangeType, double> type; - typedef pybind11::class_<type, BaseType> bound_type; - - static bound_type bind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = - XT::Common::to_camel_case("dirichlet_projection_localizable_operator_" + space_name<SP>::value() + "_" - + XT::LA::bindings::container_name<V>::value()); - - bound_type c(m, ClassName.c_str()); - c.def("apply", [](type& self) { self.apply(); }); - - m.def(std::string("make_localizable_dirichlet_projection_operator").c_str(), - [](const XT::Grid::BoundaryInfo<XT::Grid::extract_intersection_t<GridLayerType>>& boundary_info, - const SourceType& source, - RangeType& range) { - return make_localizable_dirichlet_projection_operator( - range.space().grid_layer(), boundary_info, source, range) - .release(); - }, - "boundary_info"_a, - "source"_a, - "range"_a, - py::keep_alive<0, 1>(), - py::keep_alive<0, 2>(), - py::keep_alive<0, 3>()); - - return c; - } // ... bind(...) -}; // class DirichletProjectionLocalizableOperator - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m, _GRID, _layer, _backend, _r, _rC, _la) \ - Dune::GDT::bindings::DirichletProjectionLocalizableOperator< \ - Dune::GDT:: \ - CgSpaceProvider<_GRID, Dune::XT::Grid::Layers::_layer, Dune::GDT::Backends::_backend, 1, double, _r, _rC>, \ - typename Dune::XT::LA::Container<double, Dune::XT::LA::Backends::_la>::VectorType>::bind(_m) - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ALBERTA(_m, _layer, _backend, _la) \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m, ALBERTA_2D, _layer, _backend, 1, 1, _la) -#else -*/ -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ALBERTA(_m, _layer, _backend, _la) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ALU(_m, _layer, _backend, _la) \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, _layer, _backend, 1, 1, _la) -# else -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ALU(_m, _layer, _backend, _la) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_UG(_m, _layer, _backend, _la) \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m, UG_2D, _layer, _backend, 1, 1, _la) -#else -*/ -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_UG(_m, _layer, _backend, _la) -//#endif - -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_YASP(_m, _layer, _backend, _la) \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, _layer, _backend, 1, 1, _la); \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, _layer, _backend, 1, 1, _la) - -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_GDT(_m, _la) \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ALBERTA(_m, leaf, gdt, _la); \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ALU(_m, leaf, gdt, _la); \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_UG(_m, leaf, gdt, _la); \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_YASP(_m, leaf, gdt, _la) - - -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_BACKENDS(_m, _la) _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_GDT(_m, _la); - -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_COMMON(_m) -//_DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_BACKENDS(_m, common_dense) - -//#if HAVE_EIGEN -//#define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_EIGEN(_m) _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_BACKENDS(_m, eigen_dense) -//#else -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_EIGEN(_m) -//#endif - -# if HAVE_DUNE_ISTL -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ISTL(_m) _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_BACKENDS(_m, istl_dense) -# else -# define _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ISTL(_m) -# endif - - -# define DUNE_GDT_PROJECTIONS_DIRICHLET_BIND(_m) \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_COMMON(_m); \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_EIGEN(_m); \ - _DUNE_GDT_PROJECTIONS_DIRICHLET_BIND_ISTL(_m) - -// end: this is what we need for the .so - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_PROJECTIONS_DIRICHLET_BINDINGS_HH diff --git a/python/dune/gdt/shared.hh b/python/dune/gdt/shared.hh deleted file mode 100644 index bd622d28ab1f7918c5afb5b8a3eda5279aebed75..0000000000000000000000000000000000000000 --- a/python/dune/gdt/shared.hh +++ /dev/null @@ -1,76 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// -// Created by r_milk01 on 2/7/18. - -#ifndef PYTHON_DUNE_GDT_SHARED_HH -#define PYTHON_DUNE_GDT_SHARED_HH - -#if HAVE_DUNE_PYBINDXI - -# include <dune/common/parallel/mpihelper.hh> - -# include <dune/pybindxi/pybind11.h> -# include <dune/pybindxi/stl.h> - -# include <python/dune/xt/common/bindings.hh> -# include <dune/xt/common/numeric_cast.hh> -# include <dune/xt/common/timedlogging.hh> - -void add_initialization(pybind11::module& m, std::string logger_name) -{ - namespace py = pybind11; - using namespace pybind11::literals; - - m.def("_init_mpi", - [](const std::vector<std::string>& args) { - int argc = Dune::XT::Common::numeric_cast<int>(args.size()); - char** argv = Dune::XT::Common::vector_to_main_args(args); - Dune::MPIHelper::instance(argc, argv); - }, - "args"_a = std::vector<std::string>()); - - m.def("_init_logger", - [](const ssize_t max_info_level, - const ssize_t max_debug_level, - const bool enable_warnings, - const bool enable_colors, - const std::string& info_color, - const std::string& debug_color, - const std::string& warning_color) { - Dune::XT::Common::TimedLogger().create( - max_info_level, max_debug_level, enable_warnings, enable_colors, info_color, debug_color, warning_color); - }, - "max_info_level"_a = std::numeric_limits<ssize_t>::max(), - "max_debug_level"_a = std::numeric_limits<ssize_t>::max(), - "enable_warnings"_a = true, - "enable_colors"_a = true, - "info_color"_a = "blue", - "debug_color"_a = "darkgray", - "warning_color"_a = "red"); - - m.def("_test_logger", - [=](const bool info, const bool debug, const bool warning) { - auto logger = Dune::XT::Common::TimedLogger().get(logger_name); - if (info) - logger.info() << "info logging works!" << std::endl; - if (debug) - logger.debug() << "debug logging works!" << std::endl; - if (warning) - logger.warn() << "warning logging works!" << std::endl; - }, - "info"_a = true, - "debug"_a = true, - "warning"_a = true); -} - -#endif // HAVE_DUNE_PYBINDXI - -#endif // PYTHON_DUNE_GDT_SHARED_HH diff --git a/python/dune/gdt/spaces/bindings.hh b/python/dune/gdt/spaces/bindings.hh deleted file mode 100644 index fed318daa80532403034da6168c748afe2be4e35..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/bindings.hh +++ /dev/null @@ -1,26 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_BINDINGS_HH - -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/gdt/spaces.hh> -# include <python/dune/gdt/spaces/interface.hh> -# include <python/dune/gdt/spaces/cg.hh> -# include <python/dune/gdt/spaces/dg.hh> -# include <python/dune/gdt/spaces/fv.hh> -# include <python/dune/gdt/spaces/rt.hh> - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_BINDINGS_HH diff --git a/python/dune/gdt/spaces/cg.hh b/python/dune/gdt/spaces/cg.hh deleted file mode 100644 index 56104c9d5c3f35c97ab59f743e08abd028c1def9..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/cg.hh +++ /dev/null @@ -1,86 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_CG_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_CG_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <python/dune/xt/grid/grids.bindings.hh> - -# include <dune/gdt/spaces/cg.hh> -# include <python/dune/gdt/spaces/interface.hh> - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_SPACES_CG_BIND(_m, _GRID, _layer, _r, _rC) \ - Dune::GDT::bindings::SpaceInterface< \ - Dune::GDT:: \ - CgSpaceProvider<_GRID, Dune::XT::Grid::Layers::_layer, Dune::GDT::Backends::gdt, 1, double, _r, _rC>>:: \ - bind(_m) - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_SPACES_CG_BIND_ALBERTA_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_CG_BIND(_m, ALBERTA_2D, _layer, 1, 1) -#define _DUNE_GDT_SPACES_CG_BIND_ALBERTA(_m) \ - _DUNE_GDT_SPACES_CG_BIND_ALBERTA_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_CG_BIND_ALBERTA_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_CG_BIND_ALBERTA_LAYER(_m, level) -#else -*/ -# define _DUNE_GDT_SPACES_CG_BIND_ALBERTA(_m) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_SPACES_CG_BIND_ALU_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_CG_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, _layer, 1, 1) -# define _DUNE_GDT_SPACES_CG_BIND_ALU(_m) \ - _DUNE_GDT_SPACES_CG_BIND_ALU_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_CG_BIND_ALU_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_CG_BIND_ALU_LAYER(_m, level) -# else -# define _DUNE_GDT_SPACES_CG_BIND_ALU(_m) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define _DUNE_GDT_SPACES_CG_BIND_UG_LAYER(_m, _layer) _DUNE_GDT_SPACES_CG_BIND(_m, UG_2D, _layer, 1, 1) -#define _DUNE_GDT_SPACES_CG_BIND_UG(_m) \ - _DUNE_GDT_SPACES_CG_BIND_UG_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_CG_BIND_UG_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_CG_BIND_UG_LAYER(_m, level) -#else -*/ -# define _DUNE_GDT_SPACES_CG_BIND_UG(_m) -//#endif - -# define _DUNE_GDT_SPACES_CG_BIND_YASP_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_CG_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, _layer, 1, 1); \ - _DUNE_GDT_SPACES_CG_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, _layer, 1, 1) -# define _DUNE_GDT_SPACES_CG_BIND_YASP(_m) \ - _DUNE_GDT_SPACES_CG_BIND_YASP_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_CG_BIND_YASP_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_CG_BIND_YASP_LAYER(_m, level) - -# define DUNE_GDT_SPACES_CG_BIND(_m) \ - _DUNE_GDT_SPACES_CG_BIND_ALBERTA(_m); \ - _DUNE_GDT_SPACES_CG_BIND_ALU(_m); \ - _DUNE_GDT_SPACES_CG_BIND_UG(_m); \ - _DUNE_GDT_SPACES_CG_BIND_YASP(_m) - - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_CG_BINDINGS_HH diff --git a/python/dune/gdt/spaces/constraints.hh b/python/dune/gdt/spaces/constraints.hh deleted file mode 100644 index 99bff702b6c3faca69c15f184659770c4232cafe..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/constraints.hh +++ /dev/null @@ -1,245 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_CONSTRAINTS_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_CONSTRAINTS_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <boost/numeric/conversion/cast.hpp> - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/common/exceptions.hh> -# include <dune/xt/common/type_traits.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <dune/xt/grid/type_traits.hh> -# include <dune/xt/la/container.hh> -# include <python/dune/xt/la/container.bindings.hh> - -# include <dune/gdt/assembler/system.hh> -# include <dune/gdt/spaces/cg/interface.hh> -# include <dune/gdt/spaces/cg.hh> - -# include <dune/gdt/spaces/constraints.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <class I, class G> -class DirichletConstraints -{ -public: - typedef GDT::DirichletConstraints<I> type; - typedef pybind11::class_<type> bound_type; - - static bound_type bind(pybind11::module& m, const std::string& layer_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto grid_name = XT::Grid::bindings::grid_name<G>::value(); - const auto ClassName = XT::Common::to_camel_case("DirichletConstraints_" + layer_name + "_" + grid_name); - - bound_type c(m, ClassName.c_str(), ClassName.c_str()); - c.def("__init__", - [](type& self, const XT::Grid::BoundaryInfo<I>& boundary_info, const ssize_t size, const bool set) { - try { - new (&self) type(boundary_info, boost::numeric_cast<size_t>(size), set); - } catch (boost::bad_numeric_cast& ee) { - DUNE_THROW(XT::Common::Exceptions::wrong_input_given, - "Given size has to be positive!\n\n The error in boost while converting '" - << size - << "' to '" - << XT::Common::Typename<size_t>::value() - << "' was: " - << ee.what()); - } - }, - "boundary_info"_a, - "size"_a, - "set_diagonal_entries"_a = true, - py::keep_alive<1, 2>()); - c.def("boundary_info", &type::boundary_info); - c.def("size", &type::size); - - m.def(std::string("make_dirichlet_constraints").c_str(), - [](const XT::Grid::BoundaryInfo<I>& boundary_info, const ssize_t size, const bool set) { - size_t size__as_size_t = 0; - try { - size__as_size_t = boost::numeric_cast<size_t>(size); - } catch (boost::bad_numeric_cast& ee) { - DUNE_THROW(XT::Common::Exceptions::wrong_input_given, - "Given size has to be positive!\n\n The error in boost while converting '" - << size - << "' to '" - << XT::Common::Typename<size_t>::value() - << "' was: " - << ee.what()); - } - return type(boundary_info, size__as_size_t, set); - }, - "boundary_info"_a, - "size"_a, - "set_diagonal_entries"_a, - py::keep_alive<0, 1>()); - - return c; - } // ... bind(...) - - template <XT::LA::Backends la_backend, class R = double> - static void addbind(bound_type& c) - { - typedef typename XT::LA::Container<R, la_backend>::MatrixType M; - typedef typename XT::LA::Container<R, la_backend>::VectorType V; - using namespace pybind11::literals; - - c.def("apply", [](const type& self, M& matrix) { self.apply(matrix); }, "matrix"_a); - c.def("apply", [](const type& self, V& vector) { self.apply(vector); }, "vector"_a); - c.def("apply", [](const type& self, M& matrix, V& vector) { self.apply(matrix, vector); }, "matrix"_a, "vector"_a); - } // ... addbind(...) - -private: - template <class T, bool is_cg = is_cg_space<T>::value> - struct addbind_assembler - { - template <class GL, class A> - void operator()(pybind11::class_<GDT::SystemAssembler<T, GL, A>, XT::Grid::Walker<GL>>& bound_system_assembler) - { - using namespace pybind11::literals; - - bound_system_assembler.def("append", - [](GDT::SystemAssembler<T, GL, A>& self, - GDT::DirichletConstraints<XT::Grid::extract_intersection_t<GL>>& constraints) { - self.append(constraints); - }, - "dirichlet_constraints"_a); - } // ... addbind(...) - }; // struct addbind_assembler - - template <class T> - struct addbind_assembler<T, false> - { - template <class GL, class A> - void operator()(pybind11::class_<GDT::SystemAssembler<T, GL, A>, XT::Grid::Walker<GL>>& /*bound_system_assembler*/) - { - } - }; - -public: - template <class T, class GL, class A> - static void addbind(pybind11::class_<GDT::SystemAssembler<T, GL, A>, XT::Grid::Walker<GL>>& bound_system_assembler) - { - addbind_assembler<T>()(bound_system_assembler); - } -}; // class DirichletConstraints - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA(_c, _GRID, _layer, _backend, _la) \ - Dune::GDT::bindings::DirichletConstraints<Dune::XT::Grid::extract_intersection_t<typename Dune::XT::Grid::Layer< \ - _GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - _GRID>::addbind<Dune::XT::LA::Backends::_la>(_c) - -# define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_COMMON(_c, _GRID, _layer, _backend) -// _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA(_c, _GRID, _layer, _backend, common_dense) - -/* -#if HAVE_EIGEN -#define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_EIGEN(_c, _GRID, _layer, _backend) \ - _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA(_c, _GRID, _layer, _backend, eigen_sparse) -#else -*/ -# define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_EIGEN(_c, _GRID, _layer, _backend) -//#endif - -# if HAVE_DUNE_ISTL -# define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_ISTL(_c, _GRID, _layer, _backend) \ - _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA(_c, _GRID, _layer, _backend, istl_sparse) -# else -# define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_ISTL(_c, _GRID, _layer, _backend) -# endif - -# define _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_ALL(_c, _GRID, _layer, _backend) \ - _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_COMMON(_c, _GRID, _layer, _backend); \ - _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_EIGEN(_c, _GRID, _layer, _backend); \ - _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_ISTL(_c, _GRID, _layer, _backend) - -# define _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, _GRID, _layer, _backend, _layer_name) \ - auto dirichlet_constraints_##_GRID##_##_layer##_##_backend = Dune::GDT::bindings::DirichletConstraints< \ - Dune::XT::Grid::extract_intersection_t< \ - typename Dune::XT::Grid::Layer<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::XT::Grid::Backends::_backend, \ - Dune::XT::Grid::DD::SubdomainGrid<_GRID>>::type>, \ - _GRID>::bind(_m, _layer_name); \ - _DUNE_GDT_SPACES_CONSTRAINTS_ADDBIND_LA_ALL( \ - dirichlet_constraints_##_GRID##_##_layer##_##_backend, _GRID, _layer, _backend) - - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_ALBERTA(_m) \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, ALBERTA_2D, leaf, view, ""); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, ALBERTA_2D, dd_subdomain, part, "dd_subdomain") -#else -*/ -# define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_ALBERTA(_m) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_ALU(_m) \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, leaf, view, "leaf"); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, level, view, "level"); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, dd_subdomain, view, "dd_subdomain") -# else -# define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_ALU(_m) -# endif - -/* -#if HAVE_DUNE_UGGRID -#define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_UG(_m) \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, UG_2D, leaf, view, "leaf"); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, UG_2D, level, view, "level"); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, UG_2D, dd_subdomain, part, "dd_subdomain") -#else -*/ -# define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_UG(_m) -//#endif - -# define _DUNE_GDT_SPACES_CONSTRAINTS_BIND_YASP(_m) \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, leaf, view, ""); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, dd_subdomain, view, "dd_subdomain"); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, leaf, view, ""); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, dd_subdomain, view, "dd_subdomain") - -# define DUNE_GDT_SPACES_CONSTRAINTS_BIND(_m) \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND_ALBERTA(_m); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND_ALU(_m); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND_UG(_m); \ - _DUNE_GDT_SPACES_CONSTRAINTS_BIND_YASP(_m) - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_CONSTRAINTS_BINDINGS_HH diff --git a/python/dune/gdt/spaces/dg.hh b/python/dune/gdt/spaces/dg.hh deleted file mode 100644 index 6db34ad25b577243861de4f0ca3c58a54935c711..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/dg.hh +++ /dev/null @@ -1,83 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_DG_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_DG_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <python/dune/xt/grid/grids.bindings.hh> - -# include <dune/gdt/spaces/dg.hh> -# include <python/dune/gdt/spaces/interface.hh> - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_SPACES_DG_BIND(_m, _GRID, _layer, _r, _rC) \ - Dune::GDT::bindings::SpaceInterface< \ - Dune::GDT:: \ - DgSpaceProvider<_GRID, Dune::XT::Grid::Layers::_layer, Dune::GDT::Backends::gdt, 1, double, _r, _rC>>:: \ - bind(_m) - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_SPACES_DG_BIND_ALBERTA_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_DG_BIND(_m, ALBERTA_2D, _layer, 1, 1) -#define _DUNE_GDT_SPACES_DG_BIND_ALBERTA(_m) \ - _DUNE_GDT_SPACES_DG_BIND_ALBERTA_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_DG_BIND_ALBERTA_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_DG_BIND_ALBERTA_LAYER(_m, level) -#else -*/ -# define _DUNE_GDT_SPACES_DG_BIND_ALBERTA(_m) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_SPACES_DG_BIND_ALU_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_DG_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, _layer, 1, 1) -# define _DUNE_GDT_SPACES_DG_BIND_ALU(_m) \ - _DUNE_GDT_SPACES_DG_BIND_ALU_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_DG_BIND_ALU_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_DG_BIND_ALU_LAYER(_m, level) -# else -# define _DUNE_GDT_SPACES_DG_BIND_ALU(_m) -# endif - -//#if HAVE_DUNE_UGGRID || HAVE_UG // <- does not work -//#define _DUNE_GDT_SPACES_DG_BIND_UG_LAYER(_m, _layer) _DUNE_GDT_SPACES_DG_BIND(_m, UG_2D, _layer, 1, 1) -//#define _DUNE_GDT_SPACES_DG_BIND_UG(_m) -// _DUNE_GDT_SPACES_DG_BIND_UG_LAYER(_m, dd_subdomain); -// _DUNE_GDT_SPACES_DG_BIND_UG_LAYER(_m, leaf); -// _DUNE_GDT_SPACES_DG_BIND_UG_LAYER(_m, level) -//#else -//#define _DUNE_GDT_SPACES_DG_BIND_UG(_m) -//#endif - -# define _DUNE_GDT_SPACES_DG_BIND_YASP_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_DG_BIND(_m, YASP_1D_EQUIDISTANT_OFFSET, _layer, 1, 1); \ - _DUNE_GDT_SPACES_DG_BIND(_m, YASP_2D_EQUIDISTANT_OFFSET, _layer, 1, 1) -# define _DUNE_GDT_SPACES_DG_BIND_YASP(_m) \ - _DUNE_GDT_SPACES_DG_BIND_YASP_LAYER(_m, dd_subdomain); \ - _DUNE_GDT_SPACES_DG_BIND_YASP_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_DG_BIND_YASP_LAYER(_m, level) - -# define DUNE_GDT_SPACES_DG_BIND(_m) \ - _DUNE_GDT_SPACES_DG_BIND_ALBERTA(_m); \ - _DUNE_GDT_SPACES_DG_BIND_ALU(_m); \ - _DUNE_GDT_SPACES_DG_BIND_YASP(_m) -//_DUNE_GDT_SPACES_DG_BIND_UG(_m); // <- does not work - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_DG_BINDINGS_HH diff --git a/python/dune/gdt/spaces/fv.hh b/python/dune/gdt/spaces/fv.hh deleted file mode 100644 index 2b31c30d37c5be0b298fdb5f2750e7484989bf12..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/fv.hh +++ /dev/null @@ -1,80 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_FV_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_FV_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <python/dune/xt/grid/grids.bindings.hh> - -# include <dune/gdt/spaces/fv.hh> -# include <python/dune/gdt/spaces/interface.hh> - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_SPACES_FV_BIND_GDT(_m, _GRID, _layer, _r, _rC) \ - Dune::GDT::bindings::SpaceInterface< \ - Dune::GDT:: \ - FvSpaceProvider<_GRID, Dune::XT::Grid::Layers::_layer, Dune::GDT::Backends::gdt, double, _r, _rC>>:: \ - bind(_m) - -/* -#if HAVE_ALBERTA -#define _DUNE_GDT_SPACES_FV_BIND_GDT_ALBERTA_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_FV_BIND_GDT(_m, ALBERTA_2D, _layer, 1, 1) -#define _DUNE_GDT_SPACES_FV_BIND_GDT_ALBERTA(_m) \ - _DUNE_GDT_SPACES_FV_BIND_GDT_ALBERTA_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_ALBERTA_LAYER(_m, level) -#else -*/ -# define _DUNE_GDT_SPACES_FV_BIND_GDT_ALBERTA(_m) -//#endif - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_SPACES_FV_BIND_GDT_ALU_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_FV_BIND_GDT(_m, ALU_2D_SIMPLEX_CONFORMING, _layer, 1, 1) -# define _DUNE_GDT_SPACES_FV_BIND_GDT_ALU(_m) \ - _DUNE_GDT_SPACES_FV_BIND_GDT_ALU_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_ALU_LAYER(_m, level) -# else -# define _DUNE_GDT_SPACES_FV_BIND_GDT_ALU(_m) -# endif - -/* -#if HAVE_DUNE_UGGRID || HAVE_UG -#define _DUNE_GDT_SPACES_FV_BIND_GDT_UG_LAYER(_m, _layer) _DUNE_GDT_SPACES_FV_BIND_GDT(_m, UG_2D, _layer, 1, 1) -#define _DUNE_GDT_SPACES_FV_BIND_GDT_UG(_m) \ - _DUNE_GDT_SPACES_FV_BIND_GDT_UG_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_UG_LAYER(_m, level) -#else -*/ -# define _DUNE_GDT_SPACES_FV_BIND_GDT_UG(_m) -//#endif - -# define _DUNE_GDT_SPACES_FV_BIND_GDT_YASP_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_FV_BIND_GDT(_m, YASP_2D_EQUIDISTANT_OFFSET, _layer, 1, 1) -# define _DUNE_GDT_SPACES_FV_BIND_GDT_YASP(_m) \ - _DUNE_GDT_SPACES_FV_BIND_GDT_YASP_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_YASP_LAYER(_m, level) - -# define DUNE_GDT_SPACES_FV_BIND(_m) \ - _DUNE_GDT_SPACES_FV_BIND_GDT_ALBERTA(_m); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_ALU(_m); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_UG(_m); \ - _DUNE_GDT_SPACES_FV_BIND_GDT_YASP(_m) - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_FV_BINDINGS_HH diff --git a/python/dune/gdt/spaces/interface.hh b/python/dune/gdt/spaces/interface.hh deleted file mode 100644 index 9871cae7aa06b7cc0bf3922ef037374584524632..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/interface.hh +++ /dev/null @@ -1,557 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_INTERFACE_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_INTERFACE_BINDINGS_HH -// TODO: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <dune/pybindxi/pybind11.h> - -# include <dune/xt/common/string.hh> -# include <python/dune/xt/grid/grids.bindings.hh> -# include <python/dune/xt/grid/layers.bindings.hh> -# include <dune/xt/grid/dd/subdomains/grid.hh> -# include <dune/xt/grid/gridprovider/provider.hh> -# include <dune/xt/grid/type_traits.hh> - -# include <dune/gdt/playground/spaces/restricted.hh> -# include <dune/gdt/spaces.hh> -# include <dune/gdt/type_traits.hh> - -# include <dune/gdt/spaces/interface.hh> -# include <dune/gdt/spaces/cg.hh> -# include <dune/gdt/spaces/dg.hh> -# include <dune/gdt/spaces/fv.hh> - -namespace Dune { -namespace GDT { -namespace bindings { - - -template <Backends backend> -struct backend_name -{ - static_assert(AlwaysFalse<typename internal::backend_dependent_typename<backend>::type>::value, - "Please add a specialization for this backend!"); - - static std::string value() - { - return ""; - } -}; - -template <> -struct backend_name<Backends::gdt> -{ - static std::string value() - { - return "gdt"; - } -}; - - -template <SpaceType tp> -struct space_type_name -{ - static_assert(AlwaysFalse<typename internal::space_type_dependent_typename<tp>::type>::value, - "Please add a specialization for this space type!"); - - static std::string value() - { - return ""; - } -}; - -template <> -struct space_type_name<SpaceType::cg> -{ - static std::string value() - { - return "cg"; - } -}; - -template <> -struct space_type_name<SpaceType::block_cg> -{ - static std::string value() - { - return "block_cg"; - } -}; - -template <> -struct space_type_name<SpaceType::dg> -{ - static std::string value() - { - return "dg"; - } -}; - -template <> -struct space_type_name<SpaceType::block_dg> -{ - static std::string value() - { - return "block_dg"; - } -}; - -template <> -struct space_type_name<SpaceType::fv> -{ - static std::string value() - { - return "fv"; - } -}; - -template <> -struct space_type_name<SpaceType::block_fv> -{ - static std::string value() - { - return "block_fv"; - } -}; - -template <> -struct space_type_name<SpaceType::rt> -{ - static std::string value() - { - return "rt"; - } -}; - -template <> -struct space_type_name<SpaceType::block_rt> -{ - static std::string value() - { - return "block_rt"; - } -}; - - -namespace internal { - - -template <class G, XT::Grid::Layers layer, Backends backend, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name_base -{ - static std::string value_wo_grid() - { - using XT::Common::to_string; - return XT::Grid::bindings::layer_name<layer>::value() + "_" + XT::Grid::bindings::backend_name<g>::value() + "_to_" - + to_string(r) + "x" + to_string(rC) + "_" + backend_name<backend>::value(); - } - - static std::string value() - { - return XT::Grid::bindings::grid_name<G>::value() + "_" + value_wo_grid(); - } -}; - - -} // namespace internal - - -template <class P> -struct space_name -{ - static_assert(AlwaysFalse<P>::value, "Please add a specialization for this space provider!"); - - static std::string value() - { - return ""; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, int p, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<CgSpaceProvider<G, layer, backend, p, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::cg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_p" + XT::Common::to_string(p) - + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::cg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_p" + XT::Common::to_string(p) - + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, int p, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<BlockCgSpaceProvider<G, layer, backend, p, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::block_cg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_p" + XT::Common::to_string(p) - + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::block_cg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_p" + XT::Common::to_string(p) - + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, int p, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<DgSpaceProvider<G, layer, backend, p, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::dg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_p" + XT::Common::to_string(p) - + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::dg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_p" + XT::Common::to_string(p) - + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, int p, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<BlockDgSpaceProvider<G, layer, backend, p, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::block_dg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_p" + XT::Common::to_string(p) - + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::block_dg>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_p" + XT::Common::to_string(p) - + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<FvSpaceProvider<G, layer, backend, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::fv>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::fv>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<BlockFvSpaceProvider<G, layer, backend, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::block_fv>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::block_fv>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, int p, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<RtSpaceProvider<G, layer, backend, p, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::rt>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_p" + XT::Common::to_string(p) - + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::rt>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_p" + XT::Common::to_string(p) - + "_space"; - } -}; - -template <class G, XT::Grid::Layers layer, Backends backend, int p, size_t r, size_t rC, XT::Grid::Backends g> -struct space_name<BlockRtSpaceProvider<G, layer, backend, p, double, r, rC, g>> -{ - static std::string value() - { - return space_type_name<SpaceType::block_rt>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value() + "_p" + XT::Common::to_string(p) - + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<SpaceType::block_rt>::value() + "_" - + internal::space_name_base<G, layer, backend, r, rC, g>::value_wo_grid() + "_p" + XT::Common::to_string(p) - + "_space"; - } -}; - -template <class G, - XT::Grid::Layers l, - SpaceType tp, - Backends b, - int p, - class R, - size_t r, - size_t rC, - XT::Grid::Backends g> -struct space_name<SpaceProvider<G, l, tp, b, p, R, r, rC, g>> -{ - static std::string value() - { - return space_type_name<tp>::value() + "_" + internal::space_name_base<G, l, b, r, rC, g>::value() + "_p" - + XT::Common::to_string(p) + "_space"; - } - - static std::string value_wo_grid() - { - return space_type_name<tp>::value() + "_" + internal::space_name_base<G, l, b, r, rC, g>::value_wo_grid() + "_p" - + XT::Common::to_string(p) + "_space"; - } -}; - - -template <class S> -class SpaceInterfaceWoFactory -{ - static_assert(is_space<S>::value, ""); - -public: - typedef S type; - typedef pybind11::class_<type> bound_type; - - static bound_type bind(pybind11::module& m, const std::string& space_name) - { - namespace py = pybind11; - using namespace pybind11::literals; - - const auto ClassName = XT::Common::to_camel_case(space_name /*space_name<SP>::value()*/); - - bound_type c(m, ClassName.c_str(), ClassName.c_str()); - - c.def_property_readonly("dimDomain", [](const type& /*self*/) { return S::dimDomain; }); - c.def_property_readonly("dimRange", [](const type& /*self*/) { return S::dimRange; }); - c.def_property_readonly("dimRangeCols", [](const type& /*self*/) { return S::dimRangeCols; }); - c.def_property_readonly("polOrder", [](const type& /*self*/) { return S::polOrder; }); - c.def_property_readonly_static("dimDomain", [](const type& /*self*/) { return S::dimDomain; }); - c.def_property_readonly_static("dimRange", [](const type& /*self*/) { return S::dimRange; }); - c.def_property_readonly_static("dimRangeCols", [](const type& /*self*/) { return S::dimRangeCols; }); - c.def_property_readonly_static("polOrder", [](const type& /*self*/) { return S::polOrder; }); - - c.def("size", [](const type& self) { return self.mapper().size(); }); - c.def("visualize", - [](const type& self, const std::string& filename) { self.visualize(filename); }, - "filename"_a = ""); - c.def("compute_pattern", - [](const type& self, const std::string tp) { - if (tp == "default") - return self.compute_pattern(); - else if (tp == "volume") - return self.compute_volume_pattern(); - else if (tp == "face") - return self.compute_face_pattern(); - else if (tp == "face_and_volume") - return self.compute_face_and_volume_pattern(); - else - DUNE_THROW(XT::Common::Exceptions::wrong_input_given, - " type has to be one of ('default', volume', 'face', 'face_and_volume'), is '" << tp << "'!"); - // we will never get here - return XT::LA::SparsityPatternDefault(); - }, - "type"_a = "default"); - - return c; - } // ... bind(...) -}; // class SpaceInterfaceWoFactory - - -template <class SP> -class SpaceInterface -{ - typedef typename SP::type S; - static_assert(is_space<S>::value, ""); - using G = XT::Grid::extract_grid_t<typename S::GridLayerType>; - - template <bool is_dd_subdomain_layer = (SP::grid_layer == XT::Grid::Layers::dd_subdomain), bool anything = true> - struct factory_methods - { - static void addbind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - const std::string factory_method_name = "make_" + space_name<SP>::value_wo_grid(); - - m.def(factory_method_name.c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& grid_provider, int level) { - return SP::create(grid_provider, level); - }, - "grid_provider"_a, - "level"_a = 0, - py::keep_alive<0, 1>()); - } - }; - - template <bool anything> - struct factory_methods<false, anything> - { - static void addbind(pybind11::module& m) - { - namespace py = pybind11; - using namespace pybind11::literals; - const std::string factory_method_name = "make_" + space_name<SP>::value_wo_grid(); - - m.def(factory_method_name.c_str(), - [](XT::Grid::GridProvider<G>& grid_provider, int level) { return SP::create(grid_provider, level); }, - "grid_provider"_a, - "level"_a = 0, - py::keep_alive<0, 1>()); - m.def(factory_method_name.c_str(), - [](XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& grid_provider, int level) { - return SP::create(grid_provider, level); - }, - "grid_provider"_a, - "level"_a = 0, - py::keep_alive<0, 1>()); - } - }; - -public: - typedef S type; - typedef pybind11::class_<type> bound_type; - -private: - template <XT::Grid::Backends backend, - XT::Grid::Layers layer, - bool is_dd = (layer == XT::Grid::Layers::dd_subdomain || layer == XT::Grid::Layers::dd_subdomain_boundary - || layer == XT::Grid::Layers::dd_subdomain_coupling - || layer == XT::Grid::Layers::dd_subdomain_oversampled)> - struct restriction_methods // true - { - static void addbind(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef GDT::RestrictedSpace<S, typename XT::Grid::Layer<G, layer, backend>::type> RestrictedSpaceType; - - c.def(std::string("restrict_to_" + XT::Grid::bindings::layer_name<layer>::value() + "_" - + XT::Grid::bindings::backend_name<backend>::value()) - .c_str(), - [](type& self, - XT::Grid::GridProvider<G, XT::Grid::DD::SubdomainGrid<G>>& grid_provider, - const int level_or_subdomain = -1) { - return RestrictedSpaceType(self, grid_provider.template layer<layer, backend>(level_or_subdomain)); - }, - "grid_provider"_a, - "level_or_subdomain"_a, - py::keep_alive<1, 0>()); - } - }; // struct restriction_methods - - template <XT::Grid::Backends backend, XT::Grid::Layers layer> - struct restriction_methods<backend, layer, false> - { - static void addbind(bound_type& c) - { - namespace py = pybind11; - using namespace pybind11::literals; - - typedef GDT::RestrictedSpace<S, typename XT::Grid::Layer<G, layer, backend>::type> RestrictedSpaceType; - - c.def(std::string("restrict_to_" + XT::Grid::bindings::layer_name<layer>::value() + "_" - + XT::Grid::bindings::backend_name<backend>::value()) - .c_str(), - [](type& self, XT::Grid::GridProvider<G>& grid_provider, const int level = -1) { - return RestrictedSpaceType(self, grid_provider.template layer<layer, backend>(level)); - }, - "grid_provider"_a, - "level"_a, - py::keep_alive<1, 0>()); - restriction_methods<backend, layer, true>::addbind(c); - } - }; // struct restriction_methods<..., false> - - template <XT::Grid::Backends backend, XT::Grid::Layers layer> - static void addbind_restricted(pybind11::module& m, bound_type& c, const std::string sp_name) - { - using namespace pybind11::literals; - - typedef GDT::RestrictedSpace<S, typename XT::Grid::Layer<G, layer, backend>::type> RestrictedSpaceType; - - try { // we might not be the first to add this RestrictedSpace - const auto restricted_space_name = sp_name + "_restricted_to_" + XT::Grid::bindings::layer_name<layer>::value() - + "_" + XT::Grid::bindings::backend_name<backend>::value(); - auto restricted_space = SpaceInterfaceWoFactory<RestrictedSpaceType>::bind(m, restricted_space_name); - restricted_space.def("restrict", - [](RestrictedSpaceType& self, const XT::LA::IstlDenseVector<double>& unrestricted_vector) { - return self.mapper().restrict(unrestricted_vector); - }, - "unrestricted_vector"_a); - restricted_space.def("extend", - [](RestrictedSpaceType& self, const XT::LA::IstlDenseVector<double>& restricted_vector) { - return self.mapper().extend(restricted_vector); - }, - "restricted_vector"_a); - } catch (std::runtime_error&) { - } - - restriction_methods<backend, layer>::addbind(c); - } // ... addbind_restricted(...) - -public: - static bound_type bind(pybind11::module& m) - { - const auto sp_name = space_name<SP>::value(); - auto c = SpaceInterfaceWoFactory<S>::bind(m, sp_name); - - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain>(m, c, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain_boundary>(m, c, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain_coupling>(m, c, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::dd_subdomain_oversampled>(m, c, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::leaf>(m, c, sp_name); - addbind_restricted<XT::Grid::Backends::view, XT::Grid::Layers::level>(m, c, sp_name); - - factory_methods<>::addbind(m); - return c; - } // ... bind(...) -}; // class SpaceInterface - - -} // namespace bindings -} // namespace GDT -} // namespace Dune - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_INTERFACE_BINDINGS_HH diff --git a/python/dune/gdt/spaces/rt.hh b/python/dune/gdt/spaces/rt.hh deleted file mode 100644 index 1fc867fe474da70d8697757cf06625bbc106c95f..0000000000000000000000000000000000000000 --- a/python/dune/gdt/spaces/rt.hh +++ /dev/null @@ -1,50 +0,0 @@ -// This file is part of the dune-gdt project: -// https://github.com/dune-community/dune-gdt -// Copyright 2010-2018 dune-gdt developers and contributors. All rights reserved. -// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) -// or GPL-2.0+ (http://opensource.org/licenses/gpl-license) -// with "runtime exception" (http://www.dune-project.org/license.html) -// Authors: -// Felix Schindler (2017 - 2018) -// René Fritze (2018) -// Tobias Leibner (2018) - -#ifndef PYTHON_DUNE_GDT_SPACES_RT_BINDINGS_HH -#define PYTHON_DUNE_GDT_SPACES_RT_BINDINGS_HH -// Todo: python bindings need to be updated to the new-master -#if 0 // HAVE_DUNE_PYBINDXI - -# include <python/dune/xt/grid/grids.bindings.hh> - -# include <python/dune/gdt/spaces/interface.hh> -# include <dune/gdt/spaces/hdiv/raviart-thomas.hh> - - -// begin: this is what we need for the .so - -# define _DUNE_GDT_SPACES_RT_BIND(_m, _GRID, _layer) \ - Dune::GDT::bindings::SpaceInterface<Dune::GDT::RtSpaceProvider<_GRID, \ - Dune::XT::Grid::Layers::_layer, \ - Dune::GDT::Backends::gdt, \ - 0, \ - double, \ - _GRID::dimension, \ - 1>>::bind(_m) - -# if HAVE_DUNE_ALUGRID -# define _DUNE_GDT_SPACES_RT_BIND_ALU_LAYER(_m, _layer) \ - _DUNE_GDT_SPACES_RT_BIND(_m, ALU_2D_SIMPLEX_CONFORMING, _layer) -# define _DUNE_GDT_SPACES_RT_BIND_ALU(_m) \ - _DUNE_GDT_SPACES_RT_BIND_ALU_LAYER(_m, leaf); \ - _DUNE_GDT_SPACES_RT_BIND_ALU_LAYER(_m, level) -# else -# define _DUNE_GDT_SPACES_RT_BIND_ALU(_m) -# endif - -# define DUNE_GDT_SPACES_RT_BIND(_m) _DUNE_GDT_SPACES_RT_BIND_ALU(_m) - -// end: this is what we need for the .so - - -#endif // HAVE_DUNE_PYBINDXI -#endif // PYTHON_DUNE_GDT_SPACES_RT_BINDINGS_HH diff --git a/python/dune/gdt/usercode.cc b/python/dune/gdt/usercode.cc index b54d6753eac0ef0f17b45ffbf365c044ab2bee32..989cf947ffaedb4e412319882f50ad894e4fd053 100644 --- a/python/dune/gdt/usercode.cc +++ b/python/dune/gdt/usercode.cc @@ -25,9 +25,7 @@ PYBIND11_MODULE(usercode, m) py::module::import("dune.xt.la"); py::module::import("dune.xt.grid"); py::module::import("dune.xt.functions"); - - Dune::XT::Common::bindings::addbind_exceptions(m); - Dune::XT::Common::bindings::add_initialization(m, "dune.gdt"); + py::module::import("dune.gdt.discretefunction"); // put your bindings below } // PYBIND11_MODULE(usercode, ...) diff --git a/python/test/base.py b/python/test/base.py index c3080c308f4ed1887b58d42e800f71edd156c46f..77bae28bcb14eda1fb9c70d4a79ca4020047753f 100644 --- a/python/test/base.py +++ b/python/test/base.py @@ -1,4 +1,3 @@ - import pytest from dune.xt.common.test import load_all_submodule @@ -6,5 +5,3 @@ from dune.xt.common.test import load_all_submodule def test_load_all(): import dune.gdt as gdt load_all_submodule(gdt) - -