From 81dda483cf41f6127be5d6133dfa416549d4a9f1 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Tue, 12 Jul 2016 12:39:30 +0200 Subject: [PATCH] Added get_new_point with two points and a weight. --- include/deal.II/grid/manifold.h | 27 +++++++++++++++++++++++++-- source/grid/manifold.cc | 33 ++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 9 deletions(-) diff --git a/include/deal.II/grid/manifold.h b/include/deal.II/grid/manifold.h index 6693a9b8ca..bc6c4f3385 100644 --- a/include/deal.II/grid/manifold.h +++ b/include/deal.II/grid/manifold.h @@ -272,14 +272,37 @@ public: */ /// @{ + /** + * Return an intermediate point between two given + * points. Overloading this function allows the default recursive + * implementation of the method get_new_point() that takes a + * Quadrature object as input to work properly. + * + * An implementation of this function should returns a parametric + * curve on the manifold, joining the points `p1` and `p2`, with + * parameter `w` in the interval [0,1]. In particular + * `get_new_point(p1, p2, 0.0)` should return `p1` and + * `get_new_point(p1, p2, 1.0)` should return `p2`. + * + * In its default implementation, this function calls the + * project_to_manifold() method with the convex combination of `p1` + * and `p2`. User classes can get away by simply implementing the + * project_to_manifold() method. + */ + virtual + Point + get_new_point( const Point &p1, + const Point &p2, + const double w) const; + /** * Return the point which shall become the new vertex surrounded by the * given points which make up the quadrature. We use a quadrature object, * which should be filled with the surrounding points together with * appropriate weights. * - * In its default implementation it calls internally the function - * project_to_manifold. User classes can get away by simply implementing + * In its default implementation it calls recursively the function + * get_new_point(). User classes can get away by simply implementing * that method. */ virtual diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index e2d4346ba5..2235b7daa3 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -32,8 +32,6 @@ template Manifold::~Manifold () {} - - template Point Manifold:: @@ -44,21 +42,42 @@ project_to_manifold (const std::vector > &, return Point(); } - +template +Point +Manifold:: +get_new_point (const Point &p1, + const Point &p2, + const double w) const +{ + std::vector > vertices; + vertices.push_back(p1); + vertices.push_back(p2); + return project_to_manifold(vertices, w * p1 + (1-w)*p2 ); +} template Point Manifold:: get_new_point (const Quadrature &quad) const { + Assert(quad.size() > 0, + ExcMessage("Quadrature should have at least one point.")); + Assert(std::abs(std::accumulate(quad.get_weights().begin(), quad.get_weights().end(), 0.0)-1.0) < 1e-10, ExcMessage("The weights for the individual points should sum to 1!")); - Point p; - for (unsigned int i=0; i sorted_quad(quad); + Point p = sorted_quad.point(0); + double w = sorted_quad.weight(0); + + for (unsigned int i=1; i