From: Luca Heltai Date: Wed, 6 Aug 2014 14:32:12 +0000 (+0200) Subject: Made CylindricalManifold derived from Manifold instead of FlatManifold. X-Git-Tag: v8.2.0-rc1~225^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F54%2Fhead;p=dealii.git Made CylindricalManifold derived from Manifold instead of FlatManifold. --- diff --git a/include/deal.II/grid/manifold_lib.h b/include/deal.II/grid/manifold_lib.h index 8397511a05..fda040d710 100644 --- a/include/deal.II/grid/manifold_lib.h +++ b/include/deal.II/grid/manifold_lib.h @@ -124,26 +124,30 @@ private: * @author Luca Heltai, 2014 */ template -class CylindricalManifold : public FlatManifold +class CylindricalManifold : public Manifold { public: /** * Constructor. Using default values for the constructor arguments * yields a cylinder along the x-axis (axis=0). Choose * axis=1 or axis=2 for a tube along the y- or - * z-axis, respectively. + * z-axis, respectively. The tolerance value is used to determine + * if a point is on the axis. */ - CylindricalManifold (const unsigned int axis = 0); + CylindricalManifold (const unsigned int axis = 0, + const double tolerance = 1e-10); /** * Constructor. If constructed with this constructor, the manifold * described is a cylinder with an axis that points in direction * #direction and goes through the given #point_on_axis. The * direction may be arbitrarily scaled, and the given point may be - * any point on the axis. + * any point on the axis. The tolerance value is used to determine + * if a point is on the axis. */ CylindricalManifold (const Point &direction, - const Point &point_on_axis); + const Point &point_on_axis, + const double tolerance = 1e-10); /** * Compute new points on the CylindricalManifold. See the documentation @@ -166,10 +170,14 @@ protected: private: /** - * Given a number for the axis, return a vector that denotes this - * direction. + * Helper FlatManifold to compute temptative midpoints. */ - static Point get_axis_vector (const unsigned int axis); + FlatManifold flat_manifold; + + /** + * Relative tolerance to measure zero distances. + */ + double tolerance; }; DEAL_II_NAMESPACE_CLOSE diff --git a/source/grid/manifold_lib.cc b/source/grid/manifold_lib.cc index efc765ff17..bd479a1255 100644 --- a/source/grid/manifold_lib.cc +++ b/source/grid/manifold_lib.cc @@ -131,22 +131,12 @@ SphericalManifold::pull_back(const Point &space_point) c // CylindricalManifold // ============================================================ - -template -Point -CylindricalManifold::get_axis_vector (const unsigned int axis) -{ - Assert (axis < spacedim, ExcIndexRange (axis, 0, spacedim)); - Point axis_vector; - axis_vector[axis] = 1; - return axis_vector; -} - - template -CylindricalManifold::CylindricalManifold(const unsigned int axis) : - direction (get_axis_vector (axis)), - point_on_axis (Point()) +CylindricalManifold::CylindricalManifold(const unsigned int axis, + const double tolerance) : + direction (Point::unit_vector(axis)), + point_on_axis (Point()), + tolerance(tolerance) { Assert(spacedim > 1, ExcImpossibleInDim(1)); } @@ -154,9 +144,11 @@ CylindricalManifold::CylindricalManifold(const unsigned int axis) template CylindricalManifold::CylindricalManifold(const Point &direction, - const Point &point_on_axis) : + const Point &point_on_axis, + const double tolerance) : direction (direction), - point_on_axis (point_on_axis) + point_on_axis (point_on_axis), + tolerance(tolerance) { Assert(spacedim > 2, ExcImpossibleInDim(spacedim)); } @@ -173,7 +165,7 @@ get_new_point (const Quadrature &quad) const const std::vector &weights = quad.get_weights(); // compute a proposed new point - Point middle = FlatManifold::get_new_point(quad); + Point middle = flat_manifold.get_new_point(quad); double radius = 0; Point on_plane; @@ -193,7 +185,7 @@ get_new_point (const Quadrature &quad) const // scale it to the desired length and put everything back together, // unless we have a point on the axis - if (vector_from_axis.norm() <= this->tolerance * middle.norm()) + if (vector_from_axis.norm() <= tolerance * middle.norm()) return middle; else