From 5c6dced901a88e550a6a776fed98691f08fac97d Mon Sep 17 00:00:00 2001 From: Alexander Grayver Date: Thu, 14 May 2020 11:25:39 +0200 Subject: [PATCH] Fix python FunctionManifold --- contrib/python-bindings/tests/manifold_wrapper.py | 4 ++-- include/deal.II/grid/manifold_lib.h | 8 ++++++-- source/grid/manifold_lib.cc | 10 ++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/contrib/python-bindings/tests/manifold_wrapper.py b/contrib/python-bindings/tests/manifold_wrapper.py index b595ff39ec..947af53915 100644 --- a/contrib/python-bindings/tests/manifold_wrapper.py +++ b/contrib/python-bindings/tests/manifold_wrapper.py @@ -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) diff --git a/include/deal.II/grid/manifold_lib.h b/include/deal.II/grid/manifold_lib.h index e8c9143fe7..eaa7ce1543 100644 --- a/include/deal.II/grid/manifold_lib.h +++ b/include/deal.II/grid/manifold_lib.h @@ -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 & push_forward_function, @@ -620,8 +624,8 @@ public: * std_cxx14::make_unique(...)); */ FunctionManifold( - std::unique_ptr> push_forward_function, - std::unique_ptr> pull_back_function, + std::unique_ptr> push_forward, + std::unique_ptr> pull_back, const Tensor<1, chartdim> & periodicity = Tensor<1, chartdim>(), const double tolerance = 1e-10); diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index 69dc4c7404..aeda26cef0 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -1378,14 +1378,14 @@ FunctionManifold::FunctionManifold( template FunctionManifold::FunctionManifold( - std::unique_ptr> push_forward_function, - std::unique_ptr> pull_back_function, + std::unique_ptr> push_forward, + std::unique_ptr> pull_back, const Tensor<1, chartdim> & periodicity, const double tolerance) : ChartManifold(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::clone() const } else { - Assert(owns_pointers == false, ExcNotImplemented()); - return std_cxx14::make_unique>( *push_forward_function, *pull_back_function, -- 2.39.5