From 2d8fbef11de5b4b028df564dccfd05095cd8ec35 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Fri, 23 Jul 2021 11:09:19 +0200 Subject: [PATCH] [python] Simplify grid geometry construction --- dumux/python/discretization/gridgeometry.hh | 11 +++++++++-- test/python/test_1p.py | 1 - test/python/test_explicit_transport_cctpfa.py | 1 - test/python/test_fvproblem.py | 1 - test/python/test_gridgeometry.py | 1 - 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dumux/python/discretization/gridgeometry.hh b/dumux/python/discretization/gridgeometry.hh index fae252ecb1..0c9ab52615 100644 --- a/dumux/python/discretization/gridgeometry.hh +++ b/dumux/python/discretization/gridgeometry.hh @@ -125,10 +125,17 @@ void registerGridGeometry(pybind11::handle scope, pybind11::class_<GG, Options.. using GridView = typename GG::GridView; cls.def(pybind11::init([](const GridView& gridView){ - return std::make_shared<GG>(gridView); + auto gg = std::make_shared<GG>(gridView); + // remove this once the interface is changed on the C++ side (see #1056) + gg->update(); + return gg; }), "gridView"_a); - cls.def("update", &GG::update); + // update this once the interface is changed on the C++ side (see #1056) + cls.def("update", [](GG& self, const GridView& gridView){ + return self.update(); + }, "gridView"_a); + cls.def_property_readonly("numDofs", &GG::numDofs); cls.def_property_readonly("numScv", &GG::numScv); cls.def_property_readonly("numScvf", &GG::numScvf); diff --git a/test/python/test_1p.py b/test/python/test_1p.py index 872d10123a..b416b20553 100755 --- a/test/python/test_1p.py +++ b/test/python/test_1p.py @@ -38,7 +38,6 @@ parameters = Parameters(dict={ # Set up the grid and the grid geometry gridView = structuredGrid([0,0], [1,1], [10,10]) gridGeometry = GridGeometry(gridView=gridView, discMethod=discMethod) -gridGeometry.update() # Set up the model model = Model(inheritsFrom=['OneP'], gridGeometry=gridGeometry) diff --git a/test/python/test_explicit_transport_cctpfa.py b/test/python/test_explicit_transport_cctpfa.py index efa9282389..beb2f03dc3 100755 --- a/test/python/test_explicit_transport_cctpfa.py +++ b/test/python/test_explicit_transport_cctpfa.py @@ -24,7 +24,6 @@ cells = 20 gridView = structuredGrid([0]*dimension, [1]*dimension, [cells]*dimension) gridGeometry = GridGeometry(gridView, discMethod="cctpfa") -gridGeometry.update() elementMapper = gridView.indexSet diff --git a/test/python/test_fvproblem.py b/test/python/test_fvproblem.py index cb3a64bb0a..95b9e22f53 100644 --- a/test/python/test_fvproblem.py +++ b/test/python/test_fvproblem.py @@ -24,7 +24,6 @@ from dumux.common import BoundaryTypes, FVProblem gridView = structuredGrid([0,0,0],[1,1,1],[3,3,3]) gridGeometry = GridGeometry(gridView, discMethod="box") -gridGeometry.update() @FVProblem(gridGeometry) class Problem: diff --git a/test/python/test_gridgeometry.py b/test/python/test_gridgeometry.py index ca25ba36a1..409f57115e 100755 --- a/test/python/test_gridgeometry.py +++ b/test/python/test_gridgeometry.py @@ -6,7 +6,6 @@ from dumux.discretization import GridGeometry gridView = structuredGrid([0,0],[1,1],[5,5]) gridGeometry = GridGeometry(gridView, discMethod="cctpfa") -gridGeometry.update() print("The total number of scvs is {}".format(gridGeometry.numScv())) print("The total number of scvfs is {}".format(gridGeometry.numScvf())) -- GitLab