]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add default arguments for GridGenerator::hyper_cube.
authorBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 31 May 2016 18:34:12 +0000 (14:34 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Wed, 3 Aug 2016 20:34:02 +0000 (16:34 -0400)
source/python/wrappers.cc

index ed7837597911ee9edddaf201e08678b5c55021d4..6a2e1b75630b1a13902df0869f52dff27ae669cb 100644 (file)
@@ -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_<dealii::Triangulation<2>> ("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"));
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.