]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add extra CylindricalManifold constructor
authorAlexander Grayver <agrayver@erdw.ethz.ch>
Wed, 12 Feb 2020 15:08:50 +0000 (16:08 +0100)
committerAlexander Grayver <agrayver@erdw.ethz.ch>
Wed, 12 Feb 2020 15:08:50 +0000 (16:08 +0100)
contrib/python-bindings/include/manifold_wrapper.h
contrib/python-bindings/source/export_manifold.cc
contrib/python-bindings/source/export_tria_accessor.cc
contrib/python-bindings/source/manifold_wrapper.cc

index 2e9f0c8eb12dd95e181eaff56aeaf04f88fc4430..dc7838ecc648488f5f281d14487cfeeb0dac9bec 100644 (file)
@@ -62,11 +62,18 @@ namespace python
     create_polar(const PointWrapper center);
 
     /**
-     * Create CylindricalManifold.
+     * Create CylindricalManifold along the fixed axis.
      */
     void
     create_cylindrical(const int axis = 0, const double tolerance = 1e-10);
 
+    /**
+     * Create CylindricalManifold with the given orientation.
+     */
+    void
+    create_cylindrical(const boost::python::list &direction,
+                       const boost::python::list &axial_point);
+
     /**
      * Create FunctionManifold with string expressions for the push
      * forward and pull back functions.
index 87a3fe533dcce9dd707c06f1e172d8fdfd56d440..dda1220f9579aedc440927d7d65747903482d142 100644 (file)
@@ -45,11 +45,16 @@ namespace python
     " forward and pull back functions.                          \n";
 
 
-  const char create_cylindrical_docstring[] =
-    " Create cylindrical manifold along a given axis            \n"
+  const char create_cylindrical_fixed_docstring[] =
+    " Create cylindrical manifold oriented along a given axis   \n"
     " (0 - x, 1 - y, 2 - z).                                    \n";
 
 
+  const char create_cylindrical_direction_docstring[] =
+    " Create cylindrical manifold with an axis that points in   \n"
+    " direction direction and goes through the given point on   \n"
+    " axis.                                                     \n";
+
 
   void
   export_manifold()
@@ -67,10 +72,17 @@ namespace python
            create_polar_docstring,
            boost::python::args("self", "center"))
       .def("create_cylindrical",
-           &ManifoldWrapper::create_cylindrical,
+           static_cast<void (ManifoldWrapper::*)(const int, const double)>(
+             &ManifoldWrapper::create_cylindrical),
            create_cylindrical_overloads(
              boost::python::args("self", "axis", "tolerance"),
-             create_cylindrical_docstring))
+             create_cylindrical_fixed_docstring))
+      .def("create_cylindrical",
+           static_cast<void (ManifoldWrapper::*)(const boost::python::list &,
+                                                 const boost::python::list &)>(
+             &ManifoldWrapper::create_cylindrical),
+           create_cylindrical_direction_docstring,
+           boost::python::args("self", "direction", "axial_point"))
       .def("create_function",
            &ManifoldWrapper::create_function,
            create_function_docstring,
index 9ac2c0f66f4f764f3c5d4f376cb688329f354990..37b315d665ea31757d3bcde8a11eaf96e0651a29 100644 (file)
@@ -35,6 +35,9 @@ namespace python
   const char barycenter_docstring[] =
     "Return the barycenter of the current face                          \n";
 
+  const char center_docstring[] =
+    "Return the center of the current face taking into account manifold.\n";
+
   const char set_vertex_docstring[] =
     " Set the ith vertex of the face to point_wrapper                   \n";
 
@@ -65,6 +68,10 @@ namespace python
            &TriaAccessorWrapper::get_barycenter,
            barycenter_docstring,
            boost::python::args("self"))
+      .def("center",
+           &TriaAccessorWrapper::get_center,
+           barycenter_docstring,
+           boost::python::args("self"))
       .def("set_vertex",
            &TriaAccessorWrapper::set_vertex,
            set_vertex_docstring,
index f5ccf84f490da46070983b57bffdcb2953421d8c..973dcc230801eeaf0c4057b034db6ea269006ac1 100644 (file)
@@ -57,6 +57,24 @@ namespace python
 
 
 
+    template <int dim, int spacedim>
+    Manifold<dim, spacedim> *
+    create_cylindrical_manifold(const boost::python::list &direction_list,
+                                const boost::python::list &axial_point_list)
+    {
+      Tensor<1, spacedim> direction;
+      for (int d = 0; d < spacedim; ++d)
+        direction[d] = boost::python::extract<double>(direction_list[d]);
+
+      Point<spacedim> axial_point;
+      for (int d = 0; d < spacedim; ++d)
+        axial_point[d] = boost::python::extract<double>(axial_point_list[d]);
+
+      return new CylindricalManifold<dim, spacedim>(direction, axial_point);
+    }
+
+
+
     template <int dim, int spacedim>
     Manifold<dim, spacedim> *
     create_function_manifold(const std::string &push_forward,
@@ -255,6 +273,28 @@ namespace python
 
 
 
+  void
+  ManifoldWrapper::create_cylindrical(const boost::python::list &direction,
+                                      const boost::python::list &axial_point)
+  {
+    if ((dim == 2) && (spacedim == 3))
+      {
+        manifold_ptr =
+          internal::create_cylindrical_manifold<2, 3>(direction, axial_point);
+      }
+    else if ((dim == 3) && (spacedim == 3))
+      {
+        manifold_ptr =
+          internal::create_cylindrical_manifold<3, 3>(direction, axial_point);
+      }
+    else
+      AssertThrow(false,
+                  ExcMessage(
+                    "Given dim-spacedim combination is not implemented."));
+  }
+
+
+
   void
   ManifoldWrapper::create_function_string(const std::string &push_forward,
                                           const std::string &pull_back)

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.