Skip to content
Snippets Groups Projects
Commit 09d1f422 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

Merge remote-tracking branch 'origin/python-bindings'

# Conflicts:
#	.pylicense-cpp.cfg
#	.pylicense-other.cfg
#	dune/gdt/test/CMakeLists.txt
parents 5839399c 71ceeb6d
No related branches found
No related tags found
No related merge requests found
Showing
with 2006 additions and 3 deletions
...@@ -39,3 +39,4 @@ demos-* ...@@ -39,3 +39,4 @@ demos-*
*.vtu *.vtu
*.pc *.pc
build-* build-*
*.pyc
...@@ -52,8 +52,18 @@ find_file(SPE10MODEL1DATA ...@@ -52,8 +52,18 @@ find_file(SPE10MODEL1DATA
add_subdirectory(doc) add_subdirectory(doc)
add_subdirectory(dune) add_subdirectory(dune)
add_subdirectory(cmake/modules) add_subdirectory(cmake/modules)
dune_install_python_package(PATH python)
if(dune-pybindxi_FOUND)
foreach(_file
dune/__init__.py
dune/gdt/__init__.py
)
execute_process(COMMAND ln -s ${CMAKE_CURRENT_SOURCE_DIR}/python/${_file} ${CMAKE_CURRENT_BINARY_DIR}/${_file})
endforeach()
endif()
# enable headercheck
add_definitions("-DENABLE_HEADERCHECK=1")
add_format(${CMAKE_CURRENT_SOURCE_DIR}) add_format(${CMAKE_CURRENT_SOURCE_DIR})
add_tidy(${CMAKE_CURRENT_SOURCE_DIR}) add_tidy(${CMAKE_CURRENT_SOURCE_DIR})
......
# This file is part of the dune-gdt project: # This file is part of the dune-gdt project:
# https://github.com/dune-community/dune-gdt # https://github.com/dune-community/dune-gdt
# Copyright 2010-2016 dune-gdt developers and contributors. All rights reserved. # Copyright 2010-2016 dune-gdt developers and contributors. All rights reserved.
# License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause) # 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: # Authors:
# Felix Schindler (2010, 2013 - 2016) # Felix Schindler (2010, 2013 - 2017)
if(dune-pybindxi_FOUND)
dune_pybindxi_add_helper_lib(_gdt_bindings_helper
assembler/system.bindings.cc
discretefunction/default.bindings.cc
#operators/elliptic-ipdg.bindings/alu_common_fem.cc
#operators/elliptic-ipdg.bindings/alu_common_gdt.cc
#operators/elliptic-ipdg.bindings/alu_common_pdelab.cc
#operators/elliptic-ipdg.bindings/alu_eigen_fem.cc
#operators/elliptic-ipdg.bindings/alu_eigen_gdt.cc
#operators/elliptic-ipdg.bindings/alu_eigen_pdelab.cc
operators/elliptic-ipdg.bindings/alu_istl_fem.cc
#operators/elliptic-ipdg.bindings/alu_istl_gdt.cc
#operators/elliptic-ipdg.bindings/alu_istl_pdelab.cc
#operators/elliptic-ipdg.bindings/yasp_common_fem.cc
#operators/elliptic-ipdg.bindings/yasp_common_gdt.cc
#operators/elliptic-ipdg.bindings/yasp_common_pdelab.cc
#operators/elliptic-ipdg.bindings/yasp_eigen_fem.cc
#operators/elliptic-ipdg.bindings/yasp_eigen_gdt.cc
#operators/elliptic-ipdg.bindings/yasp_eigen_pdelab.cc
#operators/elliptic-ipdg.bindings/yasp_istl_fem.cc
#operators/elliptic-ipdg.bindings/yasp_istl_gdt.cc
#operators/elliptic-ipdg.bindings/yasp_istl_pdelab.cc
#operators/elliptic.bindings/common_fem.cc
#operators/elliptic.bindings/common_gdt.cc
#operators/elliptic.bindings/common_pdelab.cc
#operators/elliptic.bindings/eigen_fem.cc
#operators/elliptic.bindings/eigen_gdt.cc
#operators/elliptic.bindings/eigen_pdelab.cc
operators/elliptic.bindings/istl_fem.cc
#operators/elliptic.bindings/istl_gdt.cc
#operators/elliptic.bindings/istl_pdelab.cc
projections/dirichlet.bindings.cc
spaces/cg.bindings.cc
spaces/constraints.bindings.cc
spaces/dg.bindings.cc
#spaces/fv.bindings.cc
)
dune_pybindxi_add_module(_gdt bindings.cc)
target_link_dune_default_libraries(_gdt)
target_link_libraries(_gdt _gdt_bindings_helper)
if(DUNE_XT_WITH_PYTHON_BINDINGS)
add_custom_target(bindings ALL DEPENDS _gdt)
else()
add_custom_target(bindings DEPENDS _gdt)
endif()
endif()
add_subdirectory(test EXCLUDE_FROM_ALL) add_subdirectory(test EXCLUDE_FROM_ALL)
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#include "system.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
// these lines have to match the corresponding ones in the .hh header file
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_GDT(template, YASP_2D_EQUIDISTANT_OFFSET);
#if HAVE_DUNE_FEM
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_FEM(template, YASP_2D_EQUIDISTANT_OFFSET);
#endif
#if HAVE_DUNE_PDELAB
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_PDELAB(template, YASP_2D_EQUIDISTANT_OFFSET);
#endif
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING);
#if HAVE_DUNE_FEM
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING);
#endif
#if HAVE_DUNE_PDELAB
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING);
#endif
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_ASSEMBLER_SYSTEM_BINDINGS_HH
#define DUNE_GDT_ASSEMBLER_SYSTEM_BINDINGS_HH
#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include <dune/xt/common/memory.hh>
#include <dune/xt/grid/grids.bindings.hh>
#include <dune/gdt/spaces.bindings.hh>
#include "system.hh"
namespace Dune {
namespace GDT {
namespace bindings {
template <class T /*, class GV = typename T::GridViewType, class A = T*/>
class SystemAssembler
{
static_assert(is_space<T>::value, "");
public:
typedef GDT::SystemAssembler<T /*, G, A*/> type;
typedef pybind11::class_<type> bound_type;
private:
typedef typename type::TestSpaceType TestSpaceType;
typedef typename type::GridViewType GridViewType;
typedef typename type::AnsatzSpaceType AnsatzSpaceType;
template <bool do_bind = (std::is_same<TestSpaceType, AnsatzSpaceType>::value
&& std::is_same<GridViewType, typename TestSpaceType::GridViewType>::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 view of the given space as grid view.",
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
public:
static bound_type bind(pybind11::module& m, const std::string& space_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
bound_type c(
m, std::string("SystemAssembler__" + space_id).c_str(), std::string("SystemAssembler__" + space_id).c_str());
addbind_ctor_single<>()(c);
c.def("append", [](type& self, type& other) { self.append(other); }, "system_assembler"_a, py::keep_alive<1, 2>());
c.def("append",
[](type& self, XT::Grid::Walker<GridViewType>& other) { self.append(other); },
"grid_walker"_a,
py::keep_alive<1, 2>());
c.def("assemble", [](type& self, const bool use_tbb) { self.assemble(use_tbb); }, "use_tbb"_a = false);
m.def("make_system_assembler",
[](const TestSpaceType& space) { return new type(space); },
"space"_a,
py::keep_alive<0, 1>());
return c;
} // ... bind(...)
}; // class SystemAssembler
#define DUNE_GDT_ASSEMBLER_SYSTEM_BIND_GDT(_prefix, _GRID) \
_prefix class SystemAssembler<FV_SPACE(_GRID, leaf, gdt, 1, 1)>; \
_prefix class SystemAssembler<FV_SPACE(_GRID, level, gdt, 1, 1)>
#define DUNE_GDT_ASSEMBLER_SYSTEM_BIND_FEM(_prefix, _GRID) \
_prefix class SystemAssembler<CG_SPACE(_GRID, leaf, fem, 1, 1, 1)>; \
_prefix class SystemAssembler<CG_SPACE(_GRID, level, fem, 1, 1, 1)>; \
_prefix class SystemAssembler<DG_SPACE(_GRID, leaf, fem, 1, 1, 1)>; \
_prefix class SystemAssembler<DG_SPACE(_GRID, level, fem, 1, 1, 1)>; \
_prefix class SystemAssembler<DG_SPACE(_GRID, leaf, fem, 2, 1, 1)>; \
_prefix class SystemAssembler<DG_SPACE(_GRID, level, fem, 2, 1, 1)>
#define DUNE_GDT_ASSEMBLER_SYSTEM_BIND_PDELAB(_prefix, _GRID) \
_prefix class SystemAssembler<CG_SPACE(_GRID, leaf, pdelab, 1, 1, 1)>; \
_prefix class SystemAssembler<CG_SPACE(_GRID, level, pdelab, 1, 1, 1)>
// these lines have to match the corresponding ones in the .cc source file
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_GDT(extern template, YASP_2D_EQUIDISTANT_OFFSET);
#if HAVE_DUNE_FEM
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_FEM(extern template, YASP_2D_EQUIDISTANT_OFFSET);
#endif
#if HAVE_DUNE_PDELAB
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_PDELAB(extern template, YASP_2D_EQUIDISTANT_OFFSET);
#endif
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_GDT(extern template, ALU_2D_SIMPLEX_CONFORMING);
#if HAVE_DUNE_FEM
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_FEM(extern template, ALU_2D_SIMPLEX_CONFORMING);
#endif
#if HAVE_DUNE_PDELAB
DUNE_GDT_ASSEMBLER_SYSTEM_BIND_PDELAB(extern template, ALU_2D_SIMPLEX_CONFORMING);
#endif
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_ASSEMBLER_SYSTEM_BINDINGS_HH
This diff is collapsed.
#ifndef DUNE_GDT_BINDINGS_HH
#define DUNE_GDT_BINDINGS_HH
#include <dune/xt/grid/grids.bindings.hh>
#include <dune/xt/la/container.bindings.hh>
#include <dune/gdt/assembler/system.bindings.hh>
#include <dune/gdt/discretefunction/default.bindings.hh>
#include <dune/gdt/operators/elliptic.bindings.hh>
#include <dune/gdt/operators/elliptic-ipdg.bindings.hh>
#include <dune/gdt/projections/dirichlet.bindings.hh>
#include <dune/gdt/spaces.bindings.hh>
#include <dune/gdt/spaces/constraints.bindings.hh>
namespace Dune {
namespace GDT {
} // namespace GDT
} // namespace Dune
#endif // DUNE_GDT_BINDINGS_HH
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#include "default.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
// these lines have to match the corresponding ones in the .hh header file
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(template, YASP_2D_EQUIDISTANT_OFFSET, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(template, YASP_2D_EQUIDISTANT_OFFSET, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(template, YASP_2D_EQUIDISTANT_OFFSET, ISTL_DENSE_VECTOR);
#endif
#if HAVE_DUNE_FEM
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(template, YASP_2D_EQUIDISTANT_OFFSET, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(template, YASP_2D_EQUIDISTANT_OFFSET, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(template, YASP_2D_EQUIDISTANT_OFFSET, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_FEM
#if HAVE_DUNE_PDELAB
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(template, YASP_2D_EQUIDISTANT_OFFSET, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(template, YASP_2D_EQUIDISTANT_OFFSET, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(template, YASP_2D_EQUIDISTANT_OFFSET, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_PDELAB
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING, ISTL_DENSE_VECTOR);
#endif
#if HAVE_DUNE_FEM
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_FEM
#if HAVE_DUNE_PDELAB
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_PDELAB
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH
#define DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH
#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include <dune/xt/grid/grids.bindings.hh>
#include <dune/xt/la/type_traits.hh>
#include <dune/xt/la/container.bindings.hh>
#include <dune/gdt/type_traits.hh>
#include <dune/gdt/spaces.bindings.hh>
#include "default.hh"
namespace Dune {
namespace GDT {
namespace bindings {
template <class S, class V>
class ConstDiscreteFunction
{
static_assert(is_space<S>::value, "");
static_assert(XT::LA::is_vector<V>::value, "");
public:
typedef GDT::ConstDiscreteFunction<S, V> type;
private:
typedef XT::Functions::LocalizableFunctionInterface<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_id, const std::string& la_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
bound_type c(m, std::string("ConstDiscreteFunction__" + space_id + "__" + la_id).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", [](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));
m.def(std::string("make_const_discrete_function").c_str(),
[](const S& space, V& vector, const std::string& name) {
return make_const_discrete_function(space, vector, name);
},
"space"_a,
"vector"_a,
"name"_a = "gdt.constdiscretefunction",
py::keep_alive<0, 1>(),
py::keep_alive<0, 2>());
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, "");
public:
typedef GDT::DiscreteFunction<S, V> type;
private:
typedef XT::Functions::LocalizableFunctionInterface<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_id, const std::string& la_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
bound_type c(m, std::string("DiscreteFunction__" + space_id + "__" + la_id).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("space", [](type& self) { return self.space(); });
c.def("vector", [](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));
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>());
return c;
} // ... bind(...)
}; // class DiscreteFunction
#define DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(_prefix, _GRID, _LA) \
_prefix class ConstDiscreteFunction<FV_SPACE(_GRID, leaf, gdt, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<FV_SPACE(_GRID, level, gdt, 1, 1), _LA>; \
_prefix class DiscreteFunction<FV_SPACE(_GRID, leaf, gdt, 1, 1), _LA>; \
_prefix class DiscreteFunction<FV_SPACE(_GRID, level, gdt, 1, 1), _LA>
#define DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(_prefix, _GRID, _LA) \
_prefix class ConstDiscreteFunction<CG_SPACE(_GRID, leaf, fem, 1, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<CG_SPACE(_GRID, level, fem, 1, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<DG_SPACE(_GRID, leaf, fem, 1, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<DG_SPACE(_GRID, level, fem, 1, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<DG_SPACE(_GRID, leaf, fem, 2, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<DG_SPACE(_GRID, level, fem, 2, 1, 1), _LA>; \
_prefix class DiscreteFunction<CG_SPACE(_GRID, leaf, fem, 1, 1, 1), _LA>; \
_prefix class DiscreteFunction<CG_SPACE(_GRID, level, fem, 1, 1, 1), _LA>; \
_prefix class DiscreteFunction<DG_SPACE(_GRID, leaf, fem, 1, 1, 1), _LA>; \
_prefix class DiscreteFunction<DG_SPACE(_GRID, level, fem, 1, 1, 1), _LA>; \
_prefix class DiscreteFunction<DG_SPACE(_GRID, leaf, fem, 2, 1, 1), _LA>; \
_prefix class DiscreteFunction<DG_SPACE(_GRID, level, fem, 2, 1, 1), _LA>
#define DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(_prefix, _GRID, _LA) \
_prefix class ConstDiscreteFunction<CG_SPACE(_GRID, leaf, pdelab, 1, 1, 1), _LA>; \
_prefix class ConstDiscreteFunction<CG_SPACE(_GRID, level, pdelab, 1, 1, 1), _LA>; \
_prefix class DiscreteFunction<CG_SPACE(_GRID, leaf, pdelab, 1, 1, 1), _LA>; \
_prefix class DiscreteFunction<CG_SPACE(_GRID, level, pdelab, 1, 1, 1), _LA>
// these lines have to match the corresponding ones in the .cc source file
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(extern template, YASP_2D_EQUIDISTANT_OFFSET, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(extern template, YASP_2D_EQUIDISTANT_OFFSET, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(extern template, YASP_2D_EQUIDISTANT_OFFSET, ISTL_DENSE_VECTOR);
#endif
#if HAVE_DUNE_FEM
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(extern template, YASP_2D_EQUIDISTANT_OFFSET, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(extern template, YASP_2D_EQUIDISTANT_OFFSET, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(extern template, YASP_2D_EQUIDISTANT_OFFSET, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_FEM
#if HAVE_DUNE_PDELAB
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(extern template, YASP_2D_EQUIDISTANT_OFFSET, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(extern template, YASP_2D_EQUIDISTANT_OFFSET, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(extern template, YASP_2D_EQUIDISTANT_OFFSET, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_PDELAB
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(extern template, ALU_2D_SIMPLEX_CONFORMING, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(extern template, ALU_2D_SIMPLEX_CONFORMING, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_GDT(extern template, ALU_2D_SIMPLEX_CONFORMING, ISTL_DENSE_VECTOR);
#endif
#if HAVE_DUNE_FEM
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(extern template, ALU_2D_SIMPLEX_CONFORMING, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(extern template, ALU_2D_SIMPLEX_CONFORMING, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_FEM(extern template, ALU_2D_SIMPLEX_CONFORMING, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_FEM
#if HAVE_DUNE_PDELAB
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(extern template, ALU_2D_SIMPLEX_CONFORMING, COMMON_DENSE_VECTOR);
#if HAVE_EIGEN
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(extern template, ALU_2D_SIMPLEX_CONFORMING, EIGEN_DENSE_VECTOR);
#endif
#if HAVE_DUNE_ISTL
DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BIND_PDELAB(extern template, ALU_2D_SIMPLEX_CONFORMING, ISTL_DENSE_VECTOR);
#endif
#endif // HAVE_DUNE_PDELAB
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_DISCRETEFUNCTION_DEFAULT_BINDINGS_HH
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_FUNCTIONALS_BASE_PBH
#define DUNE_GDT_FUNCTIONALS_BASE_PBH
#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include <dune/xt/la/container.hh>
#include "base.hh"
namespace Dune {
namespace GDT {
template <class FunctionalType>
pybind11::class_<FunctionalType,
SystemAssembler<typename FunctionalType::SpaceType, typename FunctionalType::GridViewType>>
bind_vector_functional(pybind11::module& m, const std::string& class_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
typedef FunctionalType C;
typedef typename C::SpaceType S;
typedef SystemAssembler<typename FunctionalType::SpaceType, typename FunctionalType::GridViewType> I;
typedef typename C::VectorType V;
py::class_<C, I> c(m, std::string(class_id).c_str(), std::string(class_id).c_str());
c.def("vector", [](C& self) { return self.vector(); });
c.def("space", [](C& self) { return self.space(); });
c.def("apply", [](C& self, const V& source) { return self.apply(source); }, "source"_a);
c.def("apply", [](C& self, const ConstDiscreteFunction<S, V>& source) { return self.apply(source); }, "source"_a);
return c;
} // ... bind_vector_functional(...)
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_FUNCTIONALS_BASE_PBH
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_PBH
#define DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_PBH
//#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include "elliptic-ipdg.hh"
#include "base.pbh"
namespace Dune {
namespace GDT {
namespace internal {
template <class DI, class DF, typename DT, LocalEllipticIpdgIntegrands::Method ipdg_method>
struct elliptic_ipdg_dirichlet_vector_functional_bind_helper
{
static std::string suffix()
{
return "diffusion_factor_and_tensor";
}
template <class C>
static void addbind_factory_methods(pybind11::module& m, const std::string& method_id, const std::string& la_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
typedef typename C::SpaceType S;
typedef typename C::VectorType V;
m.def(std::string(method_id + "__" + la_id).c_str(),
[](const DI& dirichlet,
const DF& diffusion_factor,
const DT& diffusion_tensor,
const XT::Grid::BoundaryInfo<typename S::GridViewType::Intersection>& boundary_info,
const S& space,
const size_t over_integrate) {
return make_elliptic_ipdg_dirichlet_vector_functional<V, ipdg_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(std::string(method_id).c_str(),
[](const DI& dirichlet,
const DF& diffusion_factor,
const DT& diffusion_tensor,
const XT::Grid::BoundaryInfo<typename S::GridViewType::Intersection>& boundary_info,
V& vector,
const S& space,
const size_t over_integrate) {
return make_elliptic_ipdg_dirichlet_vector_functional<ipdg_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 elliptic_ipdg_dirichlet_vector_functional_bind_helper
template <class DI, class D, LocalEllipticIpdgIntegrands::Method ipdg_method>
struct elliptic_ipdg_dirichlet_vector_functional_bind_helper<DI, D, void, ipdg_method>
{
static std::string suffix()
{
return "single_diffusion";
}
template <class C>
static void addbind_factory_methods(pybind11::module& m, const std::string& method_id, const std::string& la_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
typedef typename C::SpaceType S;
typedef typename C::VectorType V;
m.def(std::string(method_id + "__" + la_id).c_str(),
[](const DI& dirichlet,
const D& diffusion,
const XT::Grid::BoundaryInfo<typename S::GridViewType::Intersection>& boundary_info,
const S& space,
const size_t over_integrate) {
return make_elliptic_ipdg_dirichlet_vector_functional<V, ipdg_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(std::string(method_id).c_str(),
[](const DI& dirichlet,
const D& diffusion,
const XT::Grid::BoundaryInfo<typename S::GridViewType::Intersection>& boundary_info,
V& vector,
const S& space,
const size_t over_integrate) {
return make_elliptic_ipdg_dirichlet_vector_functional<ipdg_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 elliptic_ipdg_dirichlet_vector_functional_bind_helper
} // namespace internal
template <class DI,
class DF,
class DT, // <- may be void
class S,
LocalEllipticIpdgIntegrands::Method method = LocalEllipticIpdgIntegrands::default_method,
class V = typename XT::LA::Container<typename S::RangeFieldType>::VectorType,
class GV = typename S::GridViewType,
class F = typename S::RangeFieldType>
pybind11::class_<EllipticIpdgDirichletVectorFunctional<DI, DF, DT, S, method, V, GV, F>>
bind_elliptic_ipdg_dirichlet_vector_functional(pybind11::module& m,
const std::string& space_id,
const std::string& la_id,
const std::string& method_id)
{
static_assert(std::is_same<GV, typename S::GridViewType>::value, "Not tested yet!");
namespace py = pybind11;
using namespace pybind11::literals;
typedef EllipticIpdgDirichletVectorFunctional<DI, DF, DT, S, method, V, GV, F> C;
const std::string suffix =
la_id + "__" + space_id + "_"
+ internal::elliptic_ipdg_dirichlet_vector_functional_bind_helper<DI, DF, DT, method>::suffix();
auto c = bind_vector_functional<C>(m, "Elliptic" + method_id + "DirichletVectorFunctional__" + suffix);
internal::elliptic_ipdg_dirichlet_vector_functional_bind_helper<DI, DF, DT, method>::
template addbind_factory_methods<C>(
m, "make_elliptic_" + XT::Common::to_lower(method_id) + "_dirichlet_vector_functional", la_id);
return c;
} // ... bind_elliptic_ipdg_dirichlet_vector_functional(...)
} // namespace GDT
} // namespace Dune
//#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_FUNCTIONALS_ELLIPTIC_IPDG_PBH
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_FUNCTIONALS_L2_PBH
#define DUNE_GDT_FUNCTIONALS_L2_PBH
#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include "l2.hh"
#include "base.pbh"
namespace Dune {
namespace GDT {
template <class FunctionType,
class Space,
class Vector = typename XT::LA::Container<typename Space::RangeFieldType>::VectorType,
class GridView = typename Space::GridViewType,
class Field = typename Space::RangeFieldType>
pybind11::class_<L2VolumeVectorFunctional<FunctionType, Space, Vector, GridView, Field>>
bind_l2_volume_vector_functional(pybind11::module& m, const std::string& space_id, const std::string& la_id)
{
static_assert(std::is_same<GridView, typename Space::GridViewType>::value, "Not tested yet!");
namespace py = pybind11;
using namespace pybind11::literals;
typedef L2VolumeVectorFunctional<FunctionType, Space, Vector, GridView, Field> C;
auto c = bind_vector_functional<C>(m, "L2VolumeVectorFunctional__" + la_id + "__" + space_id);
m.def(std::string("make_l2_volume_vector_functional__" + la_id).c_str(),
[](const FunctionType& function, const Space& space, const size_t over_integrate) {
return make_l2_volume_vector_functional<Vector>(function, space, over_integrate).release(); // b.c.
}, // L2VolumeVectorFunctional is not movable, returning the raw pointer lets pybind11 correctly
"function"_a, // manage the 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 FunctionType& function, Vector& vector, const Space& 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_l2_volume_vector_functional(...)
template <class FunctionType,
class Space,
class Vector = typename XT::LA::Container<typename Space::RangeFieldType>::VectorType,
class GridView = typename Space::GridViewType,
class Field = typename Space::RangeFieldType>
pybind11::class_<L2FaceVectorFunctional<FunctionType, Space, Vector, GridView, Field>>
bind_l2_face_vector_functional(pybind11::module& m, const std::string& space_id, const std::string& la_id)
{
static_assert(std::is_same<GridView, typename Space::GridViewType>::value, "Not tested yet!");
namespace py = pybind11;
using namespace pybind11::literals;
typedef L2FaceVectorFunctional<FunctionType, Space, Vector, GridView, Field> C;
auto c = bind_vector_functional<C>(m, "L2FaceVectorFunctional__" + la_id + "__" + space_id);
m.def(std::string("make_l2_face_vector_functional__" + la_id).c_str(),
[](const FunctionType& function, const Space& space, const size_t over_integrate) {
return make_l2_face_vector_functional<Vector>(function, space, over_integrate).release(); // b.c.
}, // L2FaceVectorFunctional is not movable, returning the raw pointer lets pybind11 correctly
"function"_a, // manage the memory
"space"_a,
"over_integrate"_a = 0,
py::keep_alive<0, 1>(),
py::keep_alive<0, 2>());
m.def(std::string("make_l2_face_vector_functional__" + la_id).c_str(),
[](const FunctionType& function,
const Space& space,
const XT::Grid::ApplyOn::WhichIntersection<GridView>& which_intersections,
const size_t over_integrate) {
return make_l2_face_vector_functional<Vector>(function, space, over_integrate, which_intersections.copy())
.release(); // b.c.
}, // L2FaceVectorFunctional is not movable, returning the raw pointer lets pybind11 correctly
"function"_a, // manage the memory
"space"_a,
"which_intersections"_a,
"over_integrate"_a = 0,
py::keep_alive<0, 1>(),
py::keep_alive<0, 2>());
m.def("make_l2_face_vector_functional",
[](const FunctionType& function, Vector& vector, const Space& 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("make_l2_face_vector_functional",
[](const FunctionType& function,
Vector& vector,
const Space& space,
const XT::Grid::ApplyOn::WhichIntersection<GridView>& 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_l2_face_vector_functional(...)
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_FUNCTIONALS_L2_PBH
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_OPERATORS_BASE_BINDINGS_HH
#define DUNE_GDT_OPERATORS_BASE_BINDINGS_HH
#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include <dune/xt/la/container.hh>
#include <dune/gdt/type_traits.hh>
#include "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::GridViewType,
typename OperatorType::SourceSpaceType>
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::RangeSpaceType R;
typedef typename type::SourceSpaceType S;
typedef typename XT::LA::Container<typename type::RangeFieldType, type::MatrixType::vector_type>::VectorType V;
bound_type c(m, std::string(class_id).c_str(), std::string(class_id).c_str());
// from MatrixOperatorBase
c.def_static("pattern", [](const R& space) { return type::pattern(space); });
c.def("pattern", [](type& self) { return self.pattern(self.range_space()); });
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) { self.apply(source, range); }, "source"_a, "range"_a);
c.def("apply",
[](type& self, const GDT::ConstDiscreteFunction<S, V>& source, GDT::DiscreteFunction<R, V>& range) {
self.apply(source, range);
},
"source"_a,
"range"_a);
c.def("apply2",
[](type& self, const V& range, const V& source) { 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) { 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) {
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) { 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) { 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) { self.apply_inverse(range, source, type); },
"range"_a,
"source"_a,
"type"_a);
c.def("apply_inverse",
[](type& self, const V& range, V& source) { 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) {
self.apply_inverse(range, source);
},
"range"_a,
"source"_a);
c.def("induced_norm", [](type& self, const V& range) { return self.induced_norm(range); }, "range"_a);
c.def("induced_norm",
[](type& self, const GDT::ConstDiscreteFunction<R, V>& range) { return self.induced_norm(range); },
"range"_a);
return c;
} // ... bind(...)
}; // class MatrixOperatorBase
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_OPERATORS_BASE_BINDINGS_HH
// This file is part of the dune-gdt project:
// https://github.com/dune-community/dune-gdt
// Copyright 2010-2016 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)
#ifndef DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BINDINGS_HH
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BINDINGS_HH
#if HAVE_DUNE_PYBINDXI
#include <dune/pybindxi/pybind11.h>
#include <dune/xt/common/string.hh>
#include <dune/xt/grid/grids.bindings.hh>
#include <dune/gdt/spaces.bindings.hh>
#include "elliptic-ipdg.hh"
#include "base.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
template <class DF,
typename DT, // may be void
class R,
LocalEllipticIpdgIntegrands::Method method,
class M = typename XT::LA::Container<typename R::RangeFieldType>::MatrixType /*,
class GV = typename R::GridViewType,
class S = R,
class F = typename R::RangeFieldType*/>
class EllipticIpdgMatrixOperator
{
public:
typedef GDT::EllipticIpdgMatrixOperator<DF, DT, R, method, M /*, GV, S, F*/> type;
typedef pybind11::class_<type> bound_type;
private:
template <bool single_diffusion = std::is_same<DT, void>::value, 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, const std::string& method_id, const std::string& la_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
m.def(
std::string(method_id + "__" + la_id).c_str(),
[](const DF& diffusion_factor,
const DT& diffusion_tensor,
const XT::Grid::BoundaryInfo<typename R::GridViewType::Intersection>& 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(
std::string(method_id).c_str(),
[](const DF& diffusion_factor,
const DT& diffusion_tensor,
const XT::Grid::BoundaryInfo<typename R::GridViewType::Intersection>& 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
template <bool anything>
struct diffusion_switch<true, anything>
{
static std::string suffix()
{
return "single_diffusion";
}
template <class C>
static void addbind_factory_methods(pybind11::module& m, const std::string& method_id, const std::string& la_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
m.def(
std::string(method_id + "__" + la_id).c_str(),
[](const DF& diffusion,
const XT::Grid::BoundaryInfo<typename R::GridViewType::Intersection>& 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(
std::string(method_id).c_str(),
[](const DF& diffusion,
const XT::Grid::BoundaryInfo<typename R::GridViewType::Intersection>& 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>
public:
static bound_type
bind(pybind11::module& m, const std::string& space_id, const std::string& la_id, const std::string& method_id)
{
namespace py = pybind11;
using namespace pybind11::literals;
const std::string suffix = la_id + "__" + space_id + "_" + diffusion_switch<>::suffix();
auto c = MatrixOperatorBase<type>::bind(m, "Elliptic" + method_id + "MatrixOperator__" + suffix);
diffusion_switch<>::template addbind_factory_methods<type>(
m, "make_elliptic_" + XT::Common::to_lower(method_id) + "_matrix_operator", la_id);
return c;
} // ... bind(...)
}; // EllipticIpdgMatrixOperator
// If everyone just had enough memory, we could just use a single line
// DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND(template);
// in a source file to instantiate everything (together with
// DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND(extern template);
// in this header. Alas, we can use the latter in this header, but need to distribute the load over several sources by
// using the specialized macros below...
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic" // because of the extra ; in some places
#endif
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND(_PRE) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_YASPGRID(_PRE); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALUGRID(_PRE)
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_YASPGRID(_PRE) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LA(_PRE, YASP_2D_EQUIDISTANT_OFFSET)
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALUGRID(_PRE) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LA(_PRE, ALU_2D_SIMPLEX_CONFORMING)
#else
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ALUGRID(_PRE)
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_LA(_PRE, _GRID) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_COMMON(_PRE, _GRID); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_EIGEN(_PRE, _GRID); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ISTL(_PRE, _GRID)
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_COMMON(_PRE, _GRID) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(_PRE, _GRID, common_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(_PRE, _GRID, common_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(_PRE, _GRID, common_dense)
#if HAVE_EIGEN
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_EIGEN(_PRE, _GRID) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(_PRE, _GRID, eigen_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(_PRE, _GRID, eigen_sparse); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(_PRE, _GRID, eigen_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(_PRE, _GRID, eigen_sparse); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(_PRE, _GRID, eigen_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(_PRE, _GRID, eigen_sparse)
#else
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_EIGEN(_PRE, _GRID)
#endif
#if HAVE_DUNE_ISTL
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ISTL(_PRE, _GRID) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(_PRE, _GRID, istl_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(_PRE, _GRID, istl_dense); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(_PRE, _GRID, istl_dense)
#else
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_ISTL(_PRE, _GRID)
#endif
#if HAVE_DUNE_FEM
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(_PRE, _GRID, _LA) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, CG_SPACE(_GRID, leaf, fem, 1, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, CG_SPACE(_GRID, level, fem, 1, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, DG_SPACE(_GRID, leaf, fem, 1, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, DG_SPACE(_GRID, level, fem, 1, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, DG_SPACE(_GRID, leaf, fem, 2, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, DG_SPACE(_GRID, level, fem, 2, 1, 1), _LA)
#else // HAVE_DUNE_FEM
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(_PRE, _GRID)
#endif
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(_PRE, _GRID, _LA) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, FV_SPACE(_GRID, leaf, gdt, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, FV_SPACE(_GRID, level, gdt, 1, 1), _LA)
#if HAVE_DUNE_PDELAB
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(_PRE, _GRID, _LA) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, CG_SPACE(_GRID, leaf, pdelab, 1, 1, 1), _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, CG_SPACE(_GRID, level, pdelab, 1, 1, 1), _LA)
#else
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(_PRE, _GRID, _LA)
#endif
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_METHODS(_PRE, _SPACE, _LA) \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_(_PRE, _SPACE, sipdg, _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_(_PRE, _SPACE, swipdg, _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_(_PRE, _SPACE, swipdg_affine_factor, _LA); \
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_(_PRE, _SPACE, swipdg_affine_tensor, _LA)
#define DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_(_PRE, _SPACE, _METHOD, _LA) \
_PRE class EllipticIpdgMatrixOperator<XT::Functions::LocalizableFunctionInterface<typename _SPACE::EntityType, \
typename _SPACE::DomainFieldType, \
_SPACE::dimDomain, \
typename _SPACE::RangeFieldType, \
1, \
1>, \
XT::Functions::LocalizableFunctionInterface<typename _SPACE::EntityType, \
typename _SPACE::DomainFieldType, \
_SPACE::dimDomain, \
typename _SPACE::RangeFieldType, \
_SPACE::dimDomain, \
_SPACE::dimDomain>, \
_SPACE, \
LocalEllipticIpdgIntegrands::Method::_METHOD, \
typename XT::LA::Container<typename _SPACE::RangeFieldType, \
XT::LA::Backends::_LA>::MatrixType>; \
_PRE class EllipticIpdgMatrixOperator<XT::Functions::LocalizableFunctionInterface<typename _SPACE::EntityType, \
typename _SPACE::DomainFieldType, \
_SPACE::dimDomain, \
typename _SPACE::RangeFieldType, \
1, \
1>, \
void, \
_SPACE, \
LocalEllipticIpdgIntegrands::Method::_METHOD, \
typename XT::LA::Container<typename _SPACE::RangeFieldType, \
XT::LA::Backends::_LA>::MatrixType>; \
_PRE class EllipticIpdgMatrixOperator<XT::Functions::LocalizableFunctionInterface<typename _SPACE::EntityType, \
typename _SPACE::DomainFieldType, \
_SPACE::dimDomain, \
typename _SPACE::RangeFieldType, \
_SPACE::dimDomain, \
_SPACE::dimDomain>, \
void, \
_SPACE, \
LocalEllipticIpdgIntegrands::Method::_METHOD, \
typename XT::LA::Container<typename _SPACE::RangeFieldType, \
XT::LA::Backends::_LA>::MatrixType>
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND(extern template);
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
} // naemspace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PYBINDXI
#endif // DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BINDINGS_HH
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#if HAVE_DUNE_FEM
#include "../elliptic-ipdg.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING, common_dense);
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_FEM
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#endif // HAVE_DUNE_PYBINDXI
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#include "../elliptic-ipdg.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING, common_dense);
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#endif // HAVE_DUNE_PYBINDXI
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#if HAVE_DUNE_PDELAB
#include "../elliptic-ipdg.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING, common_dense);
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PDELAB
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#endif // HAVE_DUNE_PYBINDXI
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#if HAVE_EIGEN
#if HAVE_DUNE_FEM
#include "../elliptic-ipdg.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING, eigen_dense);
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_FEM(template, ALU_2D_SIMPLEX_CONFORMING, eigen_sparse);
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_FEM
#endif // HAVE_EIGEN
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#endif // HAVE_DUNE_PYBINDXI
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#if HAVE_EIGEN
#include "../elliptic-ipdg.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING, eigen_dense);
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_GDT(template, ALU_2D_SIMPLEX_CONFORMING, eigen_sparse);
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_EIGEN
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#endif // HAVE_DUNE_PYBINDXI
#include "config.h"
#if HAVE_DUNE_PYBINDXI
#if HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#if HAVE_EIGEN
#if HAVE_DUNE_PDELAB
#include "../elliptic-ipdg.bindings.hh"
namespace Dune {
namespace GDT {
namespace bindings {
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING, eigen_dense);
DUNE_GDT_OPERATORS_ELLIPTIC_IPDG_BIND_PDELAB(template, ALU_2D_SIMPLEX_CONFORMING, eigen_sparse);
} // namespace bindings
} // namespace GDT
} // namespace Dune
#endif // HAVE_DUNE_PDELAB
#endif // HAVE_EIGEN
#endif // HAVE_ALUGRID || HAVE_DUNE_ALUGRID
#endif // HAVE_DUNE_PYBINDXI
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment