From d6489ab2549c3bcbb2d4bcfcba62a459f24f3228 Mon Sep 17 00:00:00 2001 From: bangerth Date: Mon, 26 Apr 2010 19:00:00 +0000 Subject: [PATCH] Make present_level an empty object if structdim != dim. git-svn-id: https://svn.dealii.org/trunk@21042 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/grid/tria_accessor.h | 218 ++++++++++++------- 1 file changed, 139 insertions(+), 79 deletions(-) diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 5d1957ed12..9c4657b980 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -51,6 +51,66 @@ namespace internal namespace TriaAccessor { struct Implementation; + + /** + * Implementation of a type with + * which to store the level of an + * accessor object. We only need + * it for the case that + * structdim == + * dim. Otherwise, an empty + * object is sufficient. + */ + template struct PresentLevelType + { + struct type { + /** + * Dummy + * constructor. Only + * level zero is allowed. + */ + type (const int level) + { + Assert (level == 0, ExcInternalError()); + } + + /** + * Dummy conversion + * operator. Returns + * level zero. + */ + operator int () const + { + return 0; + } + + void operator ++ () const + { + Assert (false, ExcInternalError()); + } + + void operator -- () const + { + Assert (false, ExcInternalError()); + } + }; + }; + + + /** + * Implementation of a type with + * which to store the level of an + * accessor object. We only need + * it for the case that + * structdim == + * dim. Otherwise, an empty + * object is sufficient. + */ + template struct PresentLevelType + { + typedef int type; + }; + } } template class TriaAccessor; @@ -67,7 +127,7 @@ template class TriaAccessor<0, dim, spacedim>; */ namespace TriaAccessorExceptions { -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ @@ -91,12 +151,12 @@ namespace TriaAccessorExceptions * @ingroup Exceptions */ DeclException0 (ExcCellHasNoChildren); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException0 (ExcUnusedCellAsChild); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ @@ -105,32 +165,32 @@ namespace TriaAccessorExceptions << "You can only set the child index if the cell has no " << "children, or clear it. The given " << "index was " << arg1 << " (-1 means: clear children)"); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException0 (ExcUnusedCellAsNeighbor); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException0 (ExcUncaughtCase); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException0 (ExcDereferenceInvalidObject); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException0 (ExcCantCompareIterators); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException0 (ExcNeighborIsCoarser); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ @@ -147,14 +207,14 @@ namespace TriaAccessorExceptions * @ingroup Exceptions */ DeclException0 (ExcFacesHaveNoLevel); -//TODO: Write documentation! +//TODO: Write documentation! /** * @ingroup Exceptions */ DeclException1 (ExcSetOnlyEvenChildren, int, << "You can only set the child index of an even numbered child." - << "The number of the child given was " << arg1 << "."); + << "The number of the child given was " << arg1 << "."); } @@ -197,8 +257,8 @@ class TriaAccessorBase * surface in four-dimensional * space, then this value is * four. - */ - static const unsigned int space_dimension = spacedim; + */ + static const unsigned int space_dimension = spacedim; /** * Dimensionality of the object @@ -222,7 +282,7 @@ class TriaAccessorBase * equals 1. */ static const unsigned int structure_dimension = structdim; - + /** * Declare the data type that * this accessor class expects to @@ -262,7 +322,7 @@ class TriaAccessorBase * from the iterator class. */ void copy_from (const TriaAccessorBase &); - + /** * Copy operator. Creates an * object with exactly the same data. @@ -289,12 +349,12 @@ class TriaAccessorBase * used anyway. */ void operator = (const TriaAccessorBase *); - + /** - * Compare for equality. + * Compare for equality. */ bool operator == (const TriaAccessorBase &) const; - + /** * Compare for inequality. */ @@ -337,7 +397,7 @@ class TriaAccessorBase /** * @} */ - + /** * Access to the other objects of * a Triangulation with same @@ -345,7 +405,7 @@ class TriaAccessorBase */ internal::Triangulation::TriaObjects > & objects () const; - + public: /** * Data type to be used for passing @@ -355,7 +415,7 @@ class TriaAccessorBase * number of these parameters is. */ typedef void * LocalData; - + /** * @name Iterator address and state */ @@ -369,14 +429,14 @@ class TriaAccessorBase * This is only valid for cells. */ int level () const; - + /** * Return the index of the * element presently pointed to * on the present level. */ int index () const; - + /** * Return the state of the * iterator. For the different @@ -394,7 +454,7 @@ class TriaAccessorBase * belongs to. */ const Triangulation & get_triangulation () const; - + /** * @} */ @@ -404,8 +464,8 @@ class TriaAccessorBase * (structdim==dim). Else, * contains zero. */ - int present_level; - + typename internal::TriaAccessor::PresentLevelType::type present_level; + /** * Used to store the index of * the element presently pointed @@ -413,15 +473,15 @@ class TriaAccessorBase * used. */ int present_index; - + /** * Pointer to the triangulation * which we act on. */ const Triangulation *tria; - + private: - + template friend class TriaRawIterator; template friend class TriaIterator; template friend class TriaActiveIterator; @@ -478,7 +538,7 @@ class InvalidAccessor : public TriaAccessorBase const int level = -1, const int index = -1, const AccessorData *local_data = 0); - + /** * Copy constructor. This class * is used for iterators that @@ -503,7 +563,7 @@ class InvalidAccessor : public TriaAccessorBase */ template InvalidAccessor (const OtherAccessor &); - + /** * Dummy copy operation. */ @@ -521,7 +581,7 @@ class InvalidAccessor : public TriaAccessorBase */ void operator ++ () const; void operator -- () const; - + /** * Dummy function representing * whether the accessor points to @@ -574,7 +634,7 @@ class TriaAccessor : public TriaAccessorBase const int level = -1, const int index = -1, const AccessorData *local_data = 0); - + /** * Conversion constructor. This * constructor exists to make certain @@ -607,7 +667,7 @@ class TriaAccessor : public TriaAccessorBase */ template TriaAccessor (const TriaAccessor &); - + /** * Test for the element being * used or not. The return @@ -630,7 +690,7 @@ class TriaAccessor : public TriaAccessorBase /** * @{ */ - + /** * Return the global index of i-th * vertex of the current object. The @@ -646,7 +706,7 @@ class TriaAccessor : public TriaAccessorBase * associated with it. For this, see the * @p DoFAccessor::vertex_dof_index * functions. - */ + */ unsigned int vertex_index (const unsigned int i) const; /** @@ -672,7 +732,7 @@ class TriaAccessor : public TriaAccessorBase * generated. */ unsigned int line_index (const unsigned int i) const; - + /** * Pointer to the @p ith quad * bounding this object. @@ -766,7 +826,7 @@ class TriaAccessor : public TriaAccessorBase * otherwise. In 1d and 2d, this is always * @p true, but in 3d it may be different, * see the respective discussion in the - * documentation of the + * documentation of the * GeometryInfo classe. * * This function is really only @@ -778,7 +838,7 @@ class TriaAccessor : public TriaAccessorBase /** * @} */ - + /** * @name Accessing children */ @@ -848,7 +908,7 @@ class TriaAccessor : public TriaAccessorBase * zero. */ unsigned int max_refinement_depth () const; - + /** * Return an iterator to the @p ith * child. @@ -898,7 +958,7 @@ class TriaAccessor : public TriaAccessorBase * the child does not exist, -1 is * returned. */ - int isotropic_child_index (const unsigned int i) const; + int isotropic_child_index (const unsigned int i) const; /** * @} */ @@ -909,7 +969,7 @@ class TriaAccessor : public TriaAccessorBase /** * @{ */ - + /** * Boundary indicator of this * object. @@ -979,7 +1039,7 @@ class TriaAccessor : public TriaAccessorBase * current function. */ void set_all_boundary_indicators (const unsigned char) const; - + /** * Return whether this object is at the * boundary. Obviously, the use of this @@ -1004,11 +1064,11 @@ class TriaAccessor : public TriaAccessorBase * for the boundary object. */ const Boundary & get_boundary () const; - + /** * @} */ - + /** * @name User data @@ -1039,7 +1099,7 @@ class TriaAccessor : public TriaAccessorBase /** * Clear the user flag for this - * and all descendants. + * and all descendants. */ void recursively_clear_user_flag () const; @@ -1048,7 +1108,7 @@ class TriaAccessor : public TriaAccessorBase * independent if pointer or index. */ void clear_user_data () const; - + /** * Set the user pointer * to @p p. @@ -1060,7 +1120,7 @@ class TriaAccessor : public TriaAccessorBase * to a @p NULL pointer. */ void clear_user_pointer () const; - + /** * Access the value of the user * pointer. It is in the @@ -1103,7 +1163,7 @@ class TriaAccessor : public TriaAccessorBase * the triangulation. */ void recursively_set_user_pointer (void *p) const; - + /** * Clear the user pointer of this * object and all of its @@ -1113,18 +1173,18 @@ class TriaAccessor : public TriaAccessorBase * function. */ void recursively_clear_user_pointer () const; - + /** * Set the user index * to @p p. */ void set_user_index (const unsigned int p) const; - + /** * Reset the user index to 0. */ void clear_user_index () const; - + /** * Access the value of the user * index. @@ -1163,7 +1223,7 @@ class TriaAccessor : public TriaAccessorBase /** * @} */ - + /** * @name Geometric information about an object */ @@ -1240,12 +1300,12 @@ class TriaAccessor : public TriaAccessorBase */ bool is_translation_of (const TriaIterator > &o) const; - + /** * @} */ - - + + private: /** * Copy the data of the given @@ -1254,7 +1314,7 @@ class TriaAccessor : public TriaAccessorBase * triangulation. */ void set (const internal::Triangulation::TriaObject &o) const; - + /** * Set the flag indicating, what * line_orientation() will @@ -1267,7 +1327,7 @@ class TriaAccessor : public TriaAccessorBase */ void set_line_orientation (const unsigned int line, const bool orientation) const; - + /** * Set whether the quad with * index @p face has its normal @@ -1315,7 +1375,7 @@ class TriaAccessor : public TriaAccessorBase */ void set_face_rotation (const unsigned int face, const bool rotation) const; - + /** * Set the @p used flag. Only * for internal use in the @@ -1374,14 +1434,14 @@ class TriaAccessor : public TriaAccessorBase * not allowed. */ void set_children (const unsigned int i, const int index) const; - + /** * Clear the child field, * i.e. set it to a value which * indicates that this cell has * no children. */ - void clear_children () const; + void clear_children () const; private: /** @@ -1402,7 +1462,7 @@ class TriaAccessor : public TriaAccessorBase * anyway. */ void operator = (const TriaAccessor &); - + template friend class Triangulation; friend class internal::Triangulation::Implementation; @@ -1466,7 +1526,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> { Assert (false, ExcInternalError()); } - + /** * Boundary indicator of this * object. @@ -1505,7 +1565,7 @@ class TriaAccessor<0, dim, spacedim> : public TriaAccessorBase<0,dim, spacedim> * in two dimension, etc. * * The following refers to any dimension: - * + * * This class allows access to a cell, which is a line in 1D * and a quad in 2D. Cells have more functionality than lines or quads * by themselves, for example they can be flagged for refinement, they @@ -1531,7 +1591,7 @@ class CellAccessor : public TriaAccessor * container this is part of. */ typedef Triangulation Container; - + /** * @name Constructors */ @@ -1588,7 +1648,7 @@ class CellAccessor : public TriaAccessor /** * @} */ - + /** * @name Accessing sub-objects and neighbors */ @@ -1722,13 +1782,13 @@ class CellAccessor : public TriaAccessor TriaIterator > neighbor_child_on_subface (const unsigned int face_no, const unsigned int subface_no) const; - + /** * Return a pointer to the * @p ith neighbor. If the * neighbor does not exist, an * invalid iterator is returned. - * + * * Note (cf. TriaLevel<0>): * The neighbor of a cell has at most the * same level as this cell, i.e. it may @@ -1798,7 +1858,7 @@ class CellAccessor : public TriaAccessor * face. */ bool neighbor_is_coarser (const unsigned int neighbor) const; - + /** * This function is a generalization of the * @p neighbor_of_neighbor function for the @@ -1819,7 +1879,7 @@ class CellAccessor : public TriaAccessor */ std::pair neighbor_of_coarser_neighbor (const unsigned int neighbor) const; - + /** * This function is a generalization of the * @p neighbor_of_neighbor and the @p @@ -1830,7 +1890,7 @@ class CellAccessor : public TriaAccessor * the face_no is returned. */ unsigned int neighbor_face_no (const unsigned int neighbor) const; - + /** * @} */ @@ -1957,7 +2017,7 @@ class CellAccessor : public TriaAccessor * cells in 2d and 3d. */ internal::SubfaceCase subface_case(const unsigned int face_no) const; - + /** * Return whether the coarsen flag * is set or not. @@ -1986,7 +2046,7 @@ class CellAccessor : public TriaAccessor /** * @{ */ - + /** * Return the material id of this * cell. @@ -2091,12 +2151,12 @@ class CellAccessor : public TriaAccessor */ void set_neighbor (const unsigned int i, const TriaIterator > &pointer) const; - + /** * @} */ - - + + /** * @ingroup Exceptions */ @@ -2109,7 +2169,7 @@ class CellAccessor : public TriaAccessor * @ingroup Exceptions */ DeclException0 (ExcCellFlaggedForCoarsening); - + protected: /** * This function assumes that the @@ -2145,9 +2205,9 @@ class CellAccessor : public TriaAccessor * neighbors. */ unsigned int neighbor_of_neighbor_internal (const unsigned int neighbor) const; - + private: - + /** * Copy operator. This is * normally used in a context -- 2.39.5