]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix python FunctionManifold 10208/head
authorAlexander Grayver <agrayver@erdw.ethz.ch>
Thu, 14 May 2020 09:25:39 +0000 (11:25 +0200)
committerAlexander Grayver <agrayver@erdw.ethz.ch>
Thu, 14 May 2020 09:25:39 +0000 (11:25 +0200)
contrib/python-bindings/tests/manifold_wrapper.py
include/deal.II/grid/manifold_lib.h
source/grid/manifold_lib.cc

index b595ff39ec3b43296a6e0f8e7c7d28981cc5cd08..947af539159909d2ec3226fd0b2474cd604f35c2 100644 (file)
@@ -71,7 +71,7 @@ class TestManifoldWrapperFunction(unittest.TestCase):
 
     def setUp(self):
         self.manifold_1 = Manifold(dim = 2, spacedim = 2)
-        self.manifold_1.create_function("x^2;y^2", "sqrt(x);sqrt(y)")
+        self.manifold_1.create_function_string("x^2;y^2", "sqrt(x);sqrt(y)")
 
         self.manifold_2 = Manifold(dim = 2, spacedim = 2)
         self.manifold_2.create_function(lambda p: [p[0]**2., p[1]**2.],\
@@ -85,7 +85,7 @@ class TestManifoldWrapperFunction(unittest.TestCase):
         p_center = Point([0., 0., 0.])
         self.triangulation.generate_hyper_cube()
         self.triangulation.reset_manifold(number = 0)
-        self.triangulation.set_manifold(number = 0, manifold = self.manifold_2)
+        self.triangulation.set_manifold(number = 0, manifold = self.manifold_1)
         for cell in self.triangulation.active_cells():
             cell.set_all_manifold_ids(0)
 
index e8c9143fe70e7b0abd260924f2d29ddf1cbf1393..eaa7ce15431839f5ad8dd3ce123e3b026c8e74cf 100644 (file)
@@ -601,6 +601,10 @@ public:
    *
    * The tolerance argument is used in debug mode to actually check that the
    * two functions are one the inverse of the other.
+   *
+   * Note: the object constructed in this way stores pointers to the
+   * push_forward and  pull_back functions. Therefore, one must guarantee that
+   * the function objects are destroyed only after the constructed manifold.
    */
   FunctionManifold(
     const Function<chartdim> & push_forward_function,
@@ -620,8 +624,8 @@ public:
    *                                std_cxx14::make_unique<MyPullBack>(...));
    */
   FunctionManifold(
-    std::unique_ptr<Function<chartdim>> push_forward_function,
-    std::unique_ptr<Function<spacedim>> pull_back_function,
+    std::unique_ptr<Function<chartdim>> push_forward,
+    std::unique_ptr<Function<spacedim>> pull_back,
     const Tensor<1, chartdim> &         periodicity = Tensor<1, chartdim>(),
     const double                        tolerance   = 1e-10);
 
index 69dc4c7404f781b5abe1d993b3dcc9934164272b..aeda26cef09a87b4857e28a4d3700321190ae02a 100644 (file)
@@ -1378,14 +1378,14 @@ FunctionManifold<dim, spacedim, chartdim>::FunctionManifold(
 
 template <int dim, int spacedim, int chartdim>
 FunctionManifold<dim, spacedim, chartdim>::FunctionManifold(
-  std::unique_ptr<Function<chartdim>> push_forward_function,
-  std::unique_ptr<Function<spacedim>> pull_back_function,
+  std::unique_ptr<Function<chartdim>> push_forward,
+  std::unique_ptr<Function<spacedim>> pull_back,
   const Tensor<1, chartdim> &         periodicity,
   const double                        tolerance)
   : ChartManifold<dim, spacedim, chartdim>(periodicity)
   , const_map()
-  , push_forward_function(push_forward_function.release())
-  , pull_back_function(pull_back_function.release())
+  , push_forward_function(push_forward.release())
+  , pull_back_function(pull_back.release())
   , tolerance(tolerance)
   , owns_pointers(true)
   , finite_difference_step(0)
@@ -1473,8 +1473,6 @@ FunctionManifold<dim, spacedim, chartdim>::clone() const
     }
   else
     {
-      Assert(owns_pointers == false, ExcNotImplemented());
-
       return std_cxx14::make_unique<FunctionManifold<dim, spacedim, chartdim>>(
         *push_forward_function,
         *pull_back_function,

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.