Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
henrij22 committed Jun 26, 2024
1 parent 69f4ba2 commit 06076f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 35 deletions.
39 changes: 6 additions & 33 deletions ikarus/python/dirichletvalues/dirichletvalues.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,17 @@ void registerDirichletValues(pybind11::handle scope, pybind11::class_<DirichletV
cls.def_property_readonly("fixedDOFsize", &DirichletValues::fixedDOFsize);
cls.def("isConstrained", [](DirichletValues& self, std::size_t i) -> bool { return self.isConstrained(i); });

cls.def("fixIthDOF", [](DirichletValues& self, const MultiIndex& i) { self.fixIthDOF(i); });

auto 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);
};

auto fixBoundaryDOFsUsingLocalView_ =
[](DirichletValues& self,
const std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&)>& f) {

};
cls.def("fixIthDOF", [](DirichletValues& self, std::size_t i) { self.fixIthDOF(MultiIndex(std::array{i})); });

auto fixBoundaryDOFsUsingLocalViewAndIntersection_ =
[](DirichletValues& self,
const std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&, const Intersection&)>& f) {

};
using FixBoundaryDOFsWithGlobalIndexFunction = std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int)>;
using FixBoundaryDOFsWithLocalViewFunction =
std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&)>;
using FixBoundaryDOFsWithIntersectionFunction =
std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&, const Intersection&)>;

cls.def(
"fixBoundaryDOFs",
[&](DirichletValues& self, const pybind11::function& functor) {
using FixBoundaryDOFsWithGlobalIndexFunction = std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int)>;
using FixBoundaryDOFsWithLocalViewFunction =
std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&)>;
using FixBoundaryDOFsWithIntersectionFunction =
std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&, const Intersection&)>;

// Disambiguate by number of arguments, as casting doesn't properly work with functions
pybind11::module inspect_module = pybind11::module::import("inspect");
pybind11::object result = inspect_module.attr("signature")(functor).attr("parameters");
Expand Down Expand Up @@ -145,12 +124,6 @@ void registerDirichletValues(pybind11::handle scope, pybind11::class_<DirichletV

auto fixBoundaryDOFsOfSubSpaceBasis_ = [&]<typename SSB>(DirichletValues& self, const pybind11::function& functor,
const SSB& ssb) {
using FixBoundaryDOFsWithGlobalIndexFunction = std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int)>;
using FixBoundaryDOFsWithLocalViewFunction =
std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&)>;
using FixBoundaryDOFsWithIntersectionFunction =
std::function<void(Eigen::Ref<Eigen::VectorX<bool>>, int, LocalViewWrapper&, const Intersection&)>;

// Disambiguate by number of arguments, as casting doesn't properly work with functions
pybind11::module inspect_module = pybind11::module::import("inspect");
pybind11::object result = inspect_module.attr("signature")(functor).attr("parameters");
Expand Down
5 changes: 3 additions & 2 deletions ikarus/python/test/testdirichletvalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ def fixTopSide(vec, localIndex, localView, intersection):
dirichletValues2.fixBoundaryDOFsOfSubSpaceBasis(fixTopSide, 1)
assert dirichletValues2.fixedDOFsize == 2 + indicesPerDirection

dirichletValues2.fixIthDOF([1])
dirichletValues2.fixIthDOF(1)
assert dirichletValues2.fixedDOFsize == 2 + indicesPerDirection + 1
assert dirichletValues2.container[2]
assert dirichletValues2.container[1]


if __name__ == "__main__":
testDirichletValues()

0 comments on commit 06076f5

Please sign in to comment.