diff --git a/dumux/python/discretization/gridgeometry.hh b/dumux/python/discretization/gridgeometry.hh index f153f9caa3a5e5c07ac8f584ece68f86ec9fb588..34a4c6a806197d20eac6ea97f60c51067e758e27 100644 --- a/dumux/python/discretization/gridgeometry.hh +++ b/dumux/python/discretization/gridgeometry.hh @@ -103,6 +103,7 @@ void registerFVElementGeometry(pybind11::handle scope) cls.def_property_readonly("numScv", &FVEG::numScv); cls.def_property_readonly("hasBoundaryScvf", &FVEG::hasBoundaryScvf); cls.def("bind", &FVEG::bind, "element"_a); + cls.def("bindElement", &FVEG::bindElement, "element"_a); cls.def_property_readonly("scvs", [](FVEG& self){ const auto range = scvs(self); return pybind11::make_iterator(range.begin(), range.end()); @@ -151,6 +152,14 @@ void registerGridGeometry(pybind11::handle scope, pybind11::class_<GG, Options.. return localView(self); }); + using LocalView = typename GG::LocalView; + using Element = typename LocalView::Element; + cls.def("boundLocalView", [](GG& self, const Element& element){ + auto view = localView(self); + view.bind(element); + return view; + }, "element"_a); + using SubControlVolume = typename GG::SubControlVolume; Impl::registerSubControlVolume<SubControlVolume>(scope); @@ -158,7 +167,6 @@ void registerGridGeometry(pybind11::handle scope, pybind11::class_<GG, Options.. Impl::registerSubControlVolumeFace<SubControlVolumeFace>(scope); // also compile the corresponding local view - using LocalView = typename GG::LocalView; Impl::registerFVElementGeometry<LocalView>(scope); } diff --git a/test/python/test_fvproblem.py b/test/python/test_fvproblem.py old mode 100644 new mode 100755 index ebfbd91a5b0ee71c4c85b6a215480beb38e0c221..12adceaad7533c68e212c4251a6e669dc2cc569f --- a/test/python/test_fvproblem.py +++ b/test/python/test_fvproblem.py @@ -65,8 +65,7 @@ numNeumann = 0 numDirichlet = 0 totalSource = 0 for e in gridView.elements: - fvGeometry = problem.gridGeometry.localView # test problem interface - fvGeometry.bind(e) + fvGeometry = problem.gridGeometry.boundLocalView(e) # test problem interface for scv in fvGeometry.scvs: bTypes = problem.boundaryTypes(element=e, scv=scv) if bTypes.isDirichlet: diff --git a/test/python/test_gridgeometry.py b/test/python/test_gridgeometry.py index 7d7fa8e2d143aa746c29be86771f2f72500ac252..03e0a4249645411f619356865c2628e02dd6293a 100755 --- a/test/python/test_gridgeometry.py +++ b/test/python/test_gridgeometry.py @@ -11,9 +11,7 @@ print("The total number of scvs is {}".format(gridGeometry.numScv)) print("The total number of scvfs is {}".format(gridGeometry.numScvf)) for e in gridView.elements: - fvGeometry = gridGeometry.localView - fvGeometry.bind(e) - + fvGeometry = gridGeometry.boundLocalView(e) for scv in fvGeometry.scvs: print(f"scv dofIndex: {scv.dofIndex}") print(f"scv center: {scv.center}")