* @author Luca Heltai, 2014
*/
template <int dim, int spacedim = dim>
-class CylindricalManifold : public FlatManifold<dim,spacedim>
+class CylindricalManifold : public Manifold<dim,spacedim>
{
public:
/**
* Constructor. Using default values for the constructor arguments
* yields a cylinder along the x-axis (<tt>axis=0</tt>). Choose
* <tt>axis=1</tt> or <tt>axis=2</tt> 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<spacedim> &direction,
- const Point<spacedim> &point_on_axis);
+ const Point<spacedim> &point_on_axis,
+ const double tolerance = 1e-10);
/**
* Compute new points on the CylindricalManifold. See the documentation
private:
/**
- * Given a number for the axis, return a vector that denotes this
- * direction.
+ * Helper FlatManifold to compute temptative midpoints.
*/
- static Point<spacedim> get_axis_vector (const unsigned int axis);
+ FlatManifold<dim,spacedim> flat_manifold;
+
+ /**
+ * Relative tolerance to measure zero distances.
+ */
+ double tolerance;
};
DEAL_II_NAMESPACE_CLOSE
// CylindricalManifold
// ============================================================
-
-template <int dim, int spacedim>
-Point<spacedim>
-CylindricalManifold<dim,spacedim>::get_axis_vector (const unsigned int axis)
-{
- Assert (axis < spacedim, ExcIndexRange (axis, 0, spacedim));
- Point<spacedim> axis_vector;
- axis_vector[axis] = 1;
- return axis_vector;
-}
-
-
template <int dim, int spacedim>
-CylindricalManifold<dim,spacedim>::CylindricalManifold(const unsigned int axis) :
- direction (get_axis_vector (axis)),
- point_on_axis (Point<spacedim>())
+CylindricalManifold<dim,spacedim>::CylindricalManifold(const unsigned int axis,
+ const double tolerance) :
+ direction (Point<spacedim>::unit_vector(axis)),
+ point_on_axis (Point<spacedim>()),
+ tolerance(tolerance)
{
Assert(spacedim > 1, ExcImpossibleInDim(1));
}
template <int dim, int spacedim>
CylindricalManifold<dim,spacedim>::CylindricalManifold(const Point<spacedim> &direction,
- const Point<spacedim> &point_on_axis) :
+ const Point<spacedim> &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));
}
const std::vector<double> &weights = quad.get_weights();
// compute a proposed new point
- Point<spacedim> middle = FlatManifold<dim,spacedim>::get_new_point(quad);
+ Point<spacedim> middle = flat_manifold.get_new_point(quad);
double radius = 0;
Point<spacedim> on_plane;
// 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