Skip to content

python bindings for dirichlet values class #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rath3t opened this issue Jun 24, 2024 · 0 comments · Fixed by #305
Closed

python bindings for dirichlet values class #301

rath3t opened this issue Jun 24, 2024 · 0 comments · Fixed by #305
Assignees
Labels
feature New feature
Milestone

Comments

@rath3t
Copy link
Collaborator

rath3t commented Jun 24, 2024

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?

@rath3t rath3t added the feature New feature label Jun 24, 2024
@henrij22 henrij22 added this to the v0.5 milestone Jun 25, 2024
@henrij22 henrij22 self-assigned this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature
Projects
None yet
2 participants