From: wolf Date: Tue, 10 Nov 1998 00:14:31 +0000 (+0000) Subject: Add the rather strange function number_of_children to the triangulation iterators. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d38b70e7d7d386e6eb8328db624e09144969bbad;p=dealii-svn.git Add the rather strange function number_of_children to the triangulation iterators. git-svn-id: https://svn.dealii.org/trunk@665 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria_accessor.h b/deal.II/deal.II/include/grid/tria_accessor.h index 6c87c9e3fc..a708b8075e 100644 --- a/deal.II/deal.II/include/grid/tria_accessor.h +++ b/deal.II/deal.II/include/grid/tria_accessor.h @@ -489,6 +489,22 @@ class LineAccessor : public TriaAccessor { */ double measure () const; + /** + * Compute and return the number of + * children of this line. Actually, + * this function only counts the number + * of active children, i.e. the number + * if lines which are not further + * refined. Thus, if both of the two + * children of a line are further + * refined exactly once, the returned + * number will be four, not six. + * + * If the present cell is not refined, + * one is returned. + */ + unsigned int number_of_children () const; + private: /** * Copy operator. This is normally @@ -509,6 +525,8 @@ class LineAccessor : public TriaAccessor { */ void operator = (const LineAccessor &); + + public: // protected: // would be better to make this private, @@ -806,6 +824,22 @@ class QuadAccessor : public TriaAccessor { */ double measure () const; + /** + * Compute and return the number of + * children of this quad. Actually, + * this function only counts the number + * of active children, i.e. the number + * if quads which are not further + * refined. Thus, if all of the four + * children of a quad are further + * refined exactly once, the returned + * number will be 16, not 20. + * + * If the present cell is not refined, + * one is returned. + */ + unsigned int number_of_children () const; + private: /** * Copy operator. This is normally diff --git a/deal.II/deal.II/source/grid/tria_accessor.cc b/deal.II/deal.II/source/grid/tria_accessor.cc index 5a770686a8..3d7585e8bc 100644 --- a/deal.II/deal.II/source/grid/tria_accessor.cc +++ b/deal.II/deal.II/source/grid/tria_accessor.cc @@ -320,7 +320,22 @@ template double LineAccessor::measure () const { return sqrt((vertex(1)-vertex(0)).square()); }; - + + + +template +unsigned int LineAccessor::number_of_children () const { + if (!has_children()) + return 1; + else + { + unsigned int sum = 0; + for (unsigned int c=0; c<2; ++c) + sum += child(c)->number_of_children(); + return sum; + }; +}; + @@ -711,6 +726,21 @@ double QuadAccessor<2>::measure () const { +template +unsigned int QuadAccessor::number_of_children () const { + if (!has_children()) + return 1; + else + { + unsigned int sum = 0; + for (unsigned int c=0; c<4; ++c) + sum += child(c)->number_of_children(); + return sum; + }; +}; + + +