From 7f2c29de30a4dfe6fef85867e4b56f8f291b4ba4 Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Tue, 31 May 2016 14:34:12 -0400 Subject: [PATCH] Add default arguments for GridGenerator::hyper_cube. --- source/python/wrappers.cc | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/source/python/wrappers.cc b/source/python/wrappers.cc index ed78375979..6a2e1b7563 100644 --- a/source/python/wrappers.cc +++ b/source/python/wrappers.cc @@ -32,13 +32,14 @@ unsigned int n_active_cells(const dealii::Triangulation<2> &triangulation) return triangulation.n_active_cells(); } -void generate_cube(dealii::Triangulation<2> &triangulation) +void generate_hyper_cube(dealii::Triangulation<2> &triangulation, const double left=0., + const double right=0., const bool colorize=false) { dealii::GridGenerator::hyper_cube(triangulation); } void save(const dealii::Triangulation<2> &triangulation, - const std::string filename) + const std::string filename) { std::ofstream ofs(filename); boost::archive::text_oarchive oa(ofs); @@ -46,13 +47,16 @@ void save(const dealii::Triangulation<2> &triangulation, } void load(dealii::Triangulation<2> &triangulation, - const std::string filename) + const std::string filename) { std::ifstream ifs(filename); boost::archive::text_iarchive ia(ifs); ia >> triangulation; } +// Macro to enable default arguments +BOOST_PYTHON_FUNCTION_OVERLOADS(generate_hyper_cube_overloads, generate_hyper_cube, 1, 4) + BOOST_PYTHON_MODULE(PyDealII) { boost::python::scope().attr("__doc__") = pydealii_docstring; @@ -64,16 +68,18 @@ BOOST_PYTHON_MODULE(PyDealII) boost::python::class_> ("Triangulation") - .def("n_active_cells", &n_active_cells, - "Return the number of active cells", - boost::python::args("self")) - .def("generate_cube", &generate_cube, - "Generate a hypercube", boost::python::args("self")) + .def("n_active_cells", n_active_cells, + "Return the number of active cells", + boost::python::args("self")) + .def("generate_hyper_cube", generate_hyper_cube, + generate_hyper_cube_overloads( + boost::python::args("self", "left", "right", "colorize"), + "Generate a hyper_cube.")) .def("refine_global", &dealii::Triangulation<2>::refine_global, - "Refine the mesh uniformly", - boost::python::args("self", "times")) - .def("save", &save, "Serialize and save the triangulation", - boost::python::args("self", "filename")) - .def("load", &load, "Load and deserialize a triangulation", - boost::python::args("self", "filename")); + "Refine the mesh uniformly", + boost::python::args("self", "times")) + .def("save", save, "Serialize and save the triangulation", + boost::python::args("self", "filename")) + .def("load", load, "Load and deserialize a triangulation", + boost::python::args("self", "filename")); } -- 2.39.5