From ed87bafb97a2ef60f8cda83238f85838ddbedba0 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 11 Nov 2010 17:22:43 +0000 Subject: [PATCH] Modify Guido's change in r22657 so that we only really provide the additional functions for TriaAccessor<0,1,spacedim>, not for the more general class TriaAccessor<0,dim,spacedim>. This moves us in the direction where we ask 1d cells for cell->face() which will return an object of the kind TriaAccessor<0,1,spacedim>. We could in principle implement the more general case as well, but that would only be useful if we want to do get the end points of a face in 2d, for example (TriaAccessor<0,2,spacedim>) but there is no use for such a thing in dimension independent programming. git-svn-id: https://svn.dealii.org/trunk@22689 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/grid/tria_accessor.h | 175 +++++++++++++++---- 1 file changed, 140 insertions(+), 35 deletions(-) diff --git a/deal.II/include/deal.II/grid/tria_accessor.h b/deal.II/include/deal.II/grid/tria_accessor.h index 90f43c5bf1..ce2d8d19f2 100644 --- a/deal.II/include/deal.II/grid/tria_accessor.h +++ b/deal.II/include/deal.II/grid/tria_accessor.h @@ -1348,8 +1348,6 @@ class TriaAccessor : public TriaAccessorBase * object if higher order mappings are * used. */ - - Point center () const; /** @@ -1515,9 +1513,9 @@ class TriaAccessor : public TriaAccessorBase */ void clear_refinement_case () const; - /** - * Set the parent of a cell. - */ + /** + * Set the parent of a cell. + */ void set_parent (const unsigned int parent_index); /** @@ -1628,14 +1626,116 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> } /** - * Index of the parent. Always -1 + * @brief Return an invalid object + */ + TriaIterator > + child (const unsigned int) const + { + return TriaIterator >(); + } +}; + + + +/** + * A class that represents an access to a face in 1d -- i.e. to a + * point. This is not a full fledged access from which you can build + * an iterator: for example, you can't iterate from one such point to + * the next. Point also don't have children, and they don't have + * neighbors. + * + * @author Wolfgang Bangerth, 2010 + */ +template +class TriaAccessor<0, 1, spacedim> : public TriaAccessorBase<0,1, spacedim> +{ + public: + /** + * Propagate typedef from + * base class to this class. + */ + typedef typename TriaAccessorBase<0,1,spacedim>::AccessorData AccessorData; + + /** + * Constructor. Should never be + * called and thus produces an + * error. + */ + TriaAccessor (const Triangulation<1,spacedim> *parent = 0, + const int level = -1, + const int index = -1, + const AccessorData *local_data = 0) + : + TriaAccessorBase<0,1, spacedim> (parent, level, index, local_data) + {} + + /** + * Constructor. Should never be + * called and thus produces an + * error. + */ + template + TriaAccessor (const TriaAccessor &) + { + Assert(false, ExcImpossibleInDim(0)); + } + + /** + * Constructor. Should never be + * called and thus produces an + * error. + */ + template + TriaAccessor (const InvalidAccessor &) + { + Assert(false, ExcImpossibleInDim(0)); + } + + /** + * @name Advancement of iterators + */ + /** + * @{ + */ + /** + * This operator advances the + * iterator to the next + * element. For points, this + * operation is not defined, so + * you can't iterate over point + * iterators. + */ + void operator ++ () + { + Assert (false, ExcNotImplemented()); + } + + + /** + * This operator moves the + * iterator to the previous + * element. For points, this + * operation is not defined, so + * you can't iterate over point + * iterators. + */ + void operator -- () + { + Assert (false, ExcNotImplemented()); + } + /** + * @} + */ + + /** + * Index of the parent. You + * can't do this for points. */ int parent_index () const { + Assert (false, ExcNotImplemented()); return -1; } - - /** * @name Accessing sub-objects @@ -1645,12 +1745,13 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> */ /** - * Return the global index of i-th - * vertex of the current object. The - * convention regarding the numbering of - * vertices is laid down in the - * documentation of the GeometryInfo - * class. + * Return the global index of + * i-th vertex of the current + * object. If i is zero, this + * returns the index of the + * current point to which this + * object refers. Otherwise, it + * throws an exception. * * Note that the returned value is only * the index of the geometrical @@ -1668,27 +1769,31 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> /** * Return a reference to the - * @p ith vertex. + * @p ith vertex. If i is zero, this + * returns a reference to the + * current point to which this + * object refers. Otherwise, it + * throws an exception. */ Point & vertex (const unsigned int i) const { Assert(false, ExcNotImplemented()); - static Point p; + static const Point p; return p; } - + /** * Pointer to the @p ith line * bounding this object. Will * point to an invalid object. */ -// typename internal::Triangulation::Iterators::line_iterator +// typename internal::Triangulation::Iterators<1,spacedim>::line_iterator // line (const unsigned int i) const // { -// return TriaIterator >(); +// return TriaIterator >(); // } - + /** * Line index of the @p ith @@ -1704,13 +1809,13 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> Assert(false, ExcImpossibleInDim(0)); return numbers::invalid_unsigned_int; } - + /** * Pointer to the @p ith quad * bounding this object. */ -// typename internal::Triangulation::Iterators::quad_iterator +// typename internal::Triangulation::Iterators<1,spacedim>::quad_iterator // quad (const unsigned int i) const; /** @@ -1745,14 +1850,14 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return false; } - + /** * @brief Always return false */ bool face_flip (const unsigned int face) const { return false; - } + } /** * @brief Always return false @@ -1761,7 +1866,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return false; } - + /** * @brief Always return false @@ -1770,7 +1875,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return false; } - + /** * @} */ @@ -1790,7 +1895,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return false; } - + /** * Return the number of immediate @@ -1801,7 +1906,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return 0; } - + /** * Compute and return the number * of active descendants of this @@ -1825,19 +1930,19 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> /** * @brief Return an invalid object */ - TriaIterator > + TriaIterator > child (const unsigned int) const { - return TriaIterator >(); + return TriaIterator >(); } /** * @brief Return an invalid object */ - TriaIterator > + TriaIterator > isotropic_child (const unsigned int) const { - return TriaIterator >(); + return TriaIterator >(); } /** @@ -1847,7 +1952,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return RefinementCase<0>(RefinementPossibilities<0>::no_refinement); } - + /** * @brief Returns -1 @@ -1856,7 +1961,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { return -1; } - + /** * @brief Returns -1 @@ -1884,7 +1989,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { Assert(false, ExcImpossibleInDim(0)); } - + /** * @brief Do nothing and throw and error */ -- 2.39.5