1#ifndef DUNE_PYTHON_LOCALFUNCTIONS_LOCALFINITEELEMENT_HH
2#define DUNE_PYTHON_LOCALFUNCTIONS_LOCALFINITEELEMENT_HH
4#include <dune/python/pybind11/pybind11.h>
7#include <dune/localfunctions/common/localkey.hh>
8#include <dune/localfunctions/common/virtualinterface.hh>
15template<
typename LocalBasis>
16DUNE_EXPORT auto registerLocalBasis(pybind11::handle scope)
18 static auto cls = pybind11::class_<LocalBasis>(scope,
"LocalBasis");
20 cls.def(
"__len__", [](
const LocalBasis& basis) {
return basis.size(); });
21 cls.def_property_readonly(
"order", [](
const LocalBasis& basis) {
return basis.order(); });
22 cls.def(
"evaluateFunction",
23 [](
const LocalBasis& basis,
const typename LocalBasis::Traits::DomainType& in) {
24 std::vector<typename LocalBasis::Traits::RangeType> out;
25 basis.evaluateFunction(in, out);
28 cls.def(
"evaluateJacobian",
29 [](
const LocalBasis& basis,
const typename LocalBasis::Traits::DomainType& in) {
30 std::vector<typename LocalBasis::Traits::JacobianType> out;
31 basis.evaluateJacobian(in, out);
37DUNE_EXPORT auto registerLocalKey(pybind11::handle scope)
39 static auto cls = pybind11::class_<LocalKey>(scope,
"LocalKey");
43 cls.def_property(
"index",
44 [](
const LocalKey& key) {
return key.index(); },
45 [](LocalKey& key,
unsigned int index) { key.index(index); });
46 cls.def(
"__lt__", &LocalKey::operator<);
53template<
typename LocalFiniteElement>
54DUNE_EXPORT auto registerLocalFiniteElement(pybind11::handle scope,
const char* name =
"LocalFiniteElement")
56 static auto cls = pybind11::class_<LocalFiniteElement>(scope, name);
58 detail::registerLocalBasis<typename LocalFiniteElement::Traits::LocalBasisType>(cls);
60 cls.def_property_readonly(
"localBasis", &LocalFiniteElement::localBasis, pybind11::return_value_policy::reference_internal);
63 cls.def(
"__len__", &LocalFiniteElement::size);
64 cls.def_property_readonly(
"type", &LocalFiniteElement::type);
unsigned int codim() const
Return codim of associated entity.
Definition: localkey.hh:60
unsigned int subEntity() const
Return number of associated subentity.
Definition: localkey.hh:54
Dune namespace.
Definition: alignedallocator.hh:11
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18