Skip to content
Snippets Groups Projects
Commit db91bb13 authored by Timo Koch's avatar Timo Koch
Browse files

[python][gridgeometry] Add convenience interface boundLocalView(element)

parent aef9f254
No related branches found
No related tags found
1 merge request!2681Feature/python main file
......@@ -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);
}
......
......@@ -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:
......
......@@ -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}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment