Skip to content

python bindings for dirichlet values class #301

Closed
@rath3t

Description

@rath3t

Currently we have several useless method names in

cls.def("fixBoundaryDOFs",
[](DirichletValues& self, const std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int)>& f) {
auto lambda = [&](BackendType& vec, const MultiIndex& indexGlobal) {
// we explicitly only allow flat indices
f(vec.vector(), indexGlobal[0]);
};
self.fixBoundaryDOFs(lambda);
});
cls.def("fixBoundaryDOFsUsingLocalView",
[](DirichletValues& self,
const std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&)>& f) {
auto lambda = [&](BackendType& vec, int localIndex, LocalView& lv) {
auto lvWrapper = LocalViewWrapper(lv.globalBasis());
// this can be simplified when
// https://gitlab.dune-project.org/staging/dune-functions/-/merge_requests/418 becomes available
pybind11::object obj = pybind11::cast(lv.element());
lvWrapper.bind(obj);
f(vec.vector(), localIndex, lvWrapper);
};
self.fixBoundaryDOFs(lambda);
});
cls.def(
"fixBoundaryDOFsUsingLocalViewAndIntersection",
[](DirichletValues& self,
const std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&, const Intersection&)>& f) {
auto lambda = [&](BackendType& vec, int localIndex, LocalView& lv, const Intersection& intersection) {
auto lvWrapper = LocalViewWrapper(lv.globalBasis());
// this can be simplified when
// https://gitlab.dune-project.org/staging/dune-functions/-/merge_requests/418 becomes available
pybind11::object obj = pybind11::cast(lv.element());
lvWrapper.bind(obj);
f(vec.vector(), localIndex, lvWrapper, intersection);
};
self.fixBoundaryDOFs(lambda);
});

These should be combined to fixBoundaryDOFs.
and also the simplifications from https://gitlab.dune-project.org/staging/dune-functions/-/merge_requests/418 are available and should be added.

Just rename all function to fixBoundaryDOFs and keep the lambdas might already work.

Otherwise accepting py::kwargs might also work. @henrij22 can you have a look?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions