From 3216b22c877327c3d485224219a2a2e0a6e68532 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 28 Feb 2016 11:52:34 -0600 Subject: [PATCH] Add a member function Manifold::get_direction_vector(). --- include/deal.II/grid/manifold.h | 37 +++++++++++++++++++++++++++++++++ source/grid/manifold.cc | 17 +++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/include/deal.II/grid/manifold.h b/include/deal.II/grid/manifold.h index fb66068136..13582e91c6 100644 --- a/include/deal.II/grid/manifold.h +++ b/include/deal.II/grid/manifold.h @@ -336,6 +336,43 @@ public: get_new_point_on_cell (const typename Triangulation::cell_iterator &cell) const; /// @} + + /** + * @name Computing direction vectors + */ + /// @{ + + /** + * Return a "direction" vector that, at $\mathbf x_1$, is tangential to + * the geodesic that connects two points $\mathbf x_1,\mathbf x_2$. The geodesic + * is the shortest line between these two points, where "shortest" is defined + * via a metric specific to a particular implementation of this class in a + * derived class. For example, in the case of a FlatManifold, the shortest + * line between two points is just the straight line, and in this case the + * direction vector is just the difference $\mathbf d=\mathbf x_2-\mathbf x_1$. + * On the other hand, for a manifold that describes a surface embedded in + * a higher dimensional space (e.g., the surface of a sphere), then the + * direction vector is tangential to the surface, and consequently may point in + * a different direction than the straight line that connects the two points. + * + * This function is used, among other cases, in computing normal vectors to + * faces or, more generally, surfaces such as the boundary. Since not all + * programs need this functionality, this function has a default + * implementation that just throws an exception. Consequently, derived + * classes only have to implement this function if the program that uses + * them does in fact call it directly or indirectly. + * + * @param x1 The first point that describes the geodesic, and the one + * at which the "direction" is to be evaluated. + * @param x2 The second point that describes the geodesic. + * @return A "direction" vector tangential to the geodesic. + */ + virtual + Tensor<1,spacedim> + get_tangent_vector (const Point &x1, + const Point &x2) const; + + /// @} }; diff --git a/source/grid/manifold.cc b/source/grid/manifold.cc index 57a8a5250f..31883b9b40 100644 --- a/source/grid/manifold.cc +++ b/source/grid/manifold.cc @@ -167,6 +167,8 @@ get_new_point_on_quad (const Triangulation<1,1>::quad_iterator &) const return Point<1>(); } + + template <> Point<2> Manifold<1,2>:: @@ -177,6 +179,7 @@ get_new_point_on_quad (const Triangulation<1,2>::quad_iterator &) const } + template <> Point<3> Manifold<1,3>:: @@ -186,6 +189,8 @@ get_new_point_on_quad (const Triangulation<1,3>::quad_iterator &) const return Point<3>(); } + + template Point Manifold:: @@ -195,6 +200,8 @@ get_new_point_on_hex (const typename Triangulation::hex_iterator return Point(); } + + template <> Point<3> Manifold<3,3>:: @@ -204,6 +211,16 @@ get_new_point_on_hex (const Triangulation<3, 3>::hex_iterator &hex) const } + +template +Tensor<1,spacedim> +Manifold::get_tangent_vector(const Point &, + const Point &) const +{ + Assert (false, ExcPureFunctionCalled()); + return Tensor<1,spacedim>(); +} + /* -------------------------- FlatManifold --------------------- */ -- 2.39.5