From b4d9bc48753e0574ef67e116c7812b7b65383145 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 26 Aug 1998 08:26:09 +0000 Subject: [PATCH] Add end iterators for each level. git-svn-id: https://svn.dealii.org/trunk@521 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_handler.h | 98 ++++++++++++++++ deal.II/deal.II/include/grid/tria.h | 106 ++++++++++++++++- deal.II/deal.II/source/dofs/dof_handler.cc | 121 ++++++++++++++++++++ deal.II/deal.II/source/grid/tria.cc | 125 ++++++++++++++++++++- 4 files changed, 444 insertions(+), 6 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index 50233197a2..c8937443c5 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -811,6 +811,30 @@ class DoFHandler : public DoFDimensionInfo { */ raw_cell_iterator end () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + cell_iterator end (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_cell_iterator end_raw (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_cell_iterator end_active (const unsigned int level) const; + /** * Return an iterator pointing to the * last cell, used or not. @@ -912,6 +936,30 @@ class DoFHandler : public DoFDimensionInfo { */ raw_face_iterator end_face () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + face_iterator end_face (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_face_iterator end_raw_face (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_face_iterator end_active_face (const unsigned int level) const; + /** * Return an iterator pointing to the * last face, used or not. @@ -1006,6 +1054,31 @@ class DoFHandler : public DoFDimensionInfo { raw_line_iterator end_line () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + line_iterator end_line (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_line_iterator end_raw_line (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_line_iterator end_active_line (const unsigned int level) const; + + /** * Return an iterator pointing to the * last line, used or not. @@ -1088,6 +1161,31 @@ class DoFHandler : public DoFDimensionInfo { raw_quad_iterator end_quad () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + quad_iterator end_quad (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_quad_iterator end_raw_quad (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_quad_iterator end_active_quad (const unsigned int level) const; + + /** * Return an iterator pointing to the * last quad, used or not. diff --git a/deal.II/deal.II/include/grid/tria.h b/deal.II/deal.II/include/grid/tria.h index fd660175b2..4c4c8202cb 100644 --- a/deal.II/deal.II/include/grid/tria.h +++ b/deal.II/deal.II/include/grid/tria.h @@ -24,6 +24,7 @@ template class TriaIterator; template class TriaActiveIterator; template class DoFHandler; +template class MGDoFHandler; template struct CellData; struct SubCellData; @@ -267,9 +268,7 @@ class TriaDimensionInfo<2> { * template * int Triangulation::n_cells (const int level) const { * cell_iterator cell = begin (level), - * endc = (level == levels.size()-1 ? - * cell_iterator(end()) : - * begin (level+1)); + * endc = end(level); * int n=0; * for (; cell!=endc; ++cell) * ++n; @@ -1527,6 +1526,7 @@ class Triangulation : public TriaDimensionInfo { void load_user_flags_quad (const vector &v); /*@}*/ + /* ------------------------------------ */ /** * @name Cell iterator functions @@ -1572,6 +1572,31 @@ class Triangulation : public TriaDimensionInfo { */ raw_cell_iterator end () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + cell_iterator end (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_cell_iterator end_raw (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_cell_iterator end_active (const unsigned int level) const; + + /** * Return an iterator pointing to the * last cell, used or not. @@ -1674,6 +1699,30 @@ class Triangulation : public TriaDimensionInfo { */ raw_face_iterator end_face () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + face_iterator end_face (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_face_iterator end_raw_face (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_face_iterator end_active_face (const unsigned int level) const; + /** * Return an iterator pointing to the * last face, used or not. @@ -1768,6 +1817,30 @@ class Triangulation : public TriaDimensionInfo { raw_line_iterator end_line () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + line_iterator end_line (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_line_iterator end_raw_line (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_line_iterator end_active_line (const unsigned int level) const; + /** * Return an iterator pointing to the * last line, used or not. @@ -1850,6 +1923,30 @@ class Triangulation : public TriaDimensionInfo { raw_quad_iterator end_quad () const; + /** + * Return an iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + quad_iterator end_quad (const unsigned int level) const; + + /** + * Return a raw iterator which is the first + * iterator not on level. If #level# is + * the last level, then this returns + * #end()#. + */ + raw_quad_iterator end_raw_quad (const unsigned int level) const; + + /** + * Return an active iterator which is the + * first iterator not on level. If #level# + * is the last level, then this returns + * #end()#. + */ + active_quad_iterator end_active_quad (const unsigned int level) const; + /** * Return an iterator pointing to the * last quad, used or not. @@ -2018,7 +2115,7 @@ class Triangulation : public TriaDimensionInfo { * rather than by returning a pre-stored * value. It is therefore often better * to rewrite lines like - * #for (i=0; i { friend class TriaRawIterator<2,CellAccessor<2> >; friend class DoFHandler; + friend class MGDoFHandler; }; diff --git a/deal.II/deal.II/source/dofs/dof_handler.cc b/deal.II/deal.II/source/dofs/dof_handler.cc index 1ff01dda01..b03c4367b8 100644 --- a/deal.II/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/deal.II/source/dofs/dof_handler.cc @@ -545,6 +545,127 @@ DoFHandler::end_quad () const { +template +typename DoFDimensionInfo::raw_cell_iterator +DoFHandler::end_raw (const unsigned int level) const { + return (level == levels.size()-1 ? + end() : + begin_raw (level+1)); +}; + + + +template +typename DoFDimensionInfo::cell_iterator +DoFHandler::end (const unsigned int level) const { + return (level == levels.size()-1 ? + cell_iterator(end()) : + begin (level+1)); +}; + + + +template +typename DoFDimensionInfo::active_cell_iterator +DoFHandler::end_active (const unsigned int level) const { + return (level == levels.size()-1 ? + active_cell_iterator(end()) : + begin_active (level+1)); +}; + + + +template +typename DoFDimensionInfo::raw_face_iterator +DoFHandler::end_raw_face (const unsigned int level) const { + return (level == levels.size()-1 ? + end_face() : + begin_raw_face (level+1)); +}; + + + +template +typename DoFDimensionInfo::face_iterator +DoFHandler::end_face (const unsigned int level) const { + return (level == levels.size()-1 ? + face_iterator(end_face()) : + begin_face (level+1)); +}; + + + +template +typename DoFDimensionInfo::active_face_iterator +DoFHandler::end_active_face (const unsigned int level) const { + return (level == levels.size()-1 ? + active_face_iterator(end_face()) : + begin_active_face (level+1)); +}; + + + +template +typename DoFDimensionInfo::raw_line_iterator +DoFHandler::end_raw_line (const unsigned int level) const { + return (level == levels.size()-1 ? + end_line() : + begin_raw_line (level+1)); +}; + + + +template +typename DoFDimensionInfo::line_iterator +DoFHandler::end_line (const unsigned int level) const { + return (level == levels.size()-1 ? + line_iterator(end_line()) : + begin_line (level+1)); +}; + + + +template +typename DoFDimensionInfo::active_line_iterator +DoFHandler::end_active_line (const unsigned int level) const { + return (level == levels.size()-1 ? + active_line_iterator(end_line()) : + begin_active_line (level+1)); +}; + + + + +template +typename DoFDimensionInfo::raw_quad_iterator +DoFHandler::end_raw_quad (const unsigned int level) const { + return (level == levels.size()-1 ? + end_quad() : + begin_raw_quad (level+1)); +}; + + + +template +typename DoFDimensionInfo::quad_iterator +DoFHandler::end_quad (const unsigned int level) const { + return (level == levels.size()-1 ? + quad_iterator(end_quad()) : + begin_quad (level+1)); +}; + + + +template +typename DoFDimensionInfo::active_quad_iterator +DoFHandler::end_active_quad (const unsigned int level) const { + return (level == levels.size()-1 ? + active_quad_iterator(end_quad()) : + begin_active_quad (level+1)); +}; + + + template typename DoFHandler::raw_line_iterator DoFHandler::last_raw_line (const unsigned int level) const { diff --git a/deal.II/deal.II/source/grid/tria.cc b/deal.II/deal.II/source/grid/tria.cc index 39e0011e3b..1f35a3111a 100644 --- a/deal.II/deal.II/source/grid/tria.cc +++ b/deal.II/deal.II/source/grid/tria.cc @@ -62,6 +62,7 @@ Triangulation<1>::begin (const unsigned int level) const { }; + template <> TriaDimensionInfo<1>::raw_cell_iterator Triangulation<1>::end () const { @@ -81,7 +82,6 @@ Triangulation<2>::begin (const unsigned int level) const { - template <> TriaDimensionInfo<2>::raw_cell_iterator Triangulation<2>::end () const { @@ -1457,7 +1457,6 @@ Triangulation::begin_active_quad (unsigned int level) const { }; - template typename TriaDimensionInfo::raw_line_iterator Triangulation::end_line () const { @@ -1624,6 +1623,128 @@ Triangulation::last_active_quad () const { +template +typename TriaDimensionInfo::raw_cell_iterator +Triangulation::end_raw (const unsigned int level) const { + return (level == levels.size()-1 ? + end() : + begin_raw (level+1)); +}; + + + +template +typename TriaDimensionInfo::cell_iterator +Triangulation::end (const unsigned int level) const { + return (level == levels.size()-1 ? + cell_iterator(end()) : + begin (level+1)); +}; + + + +template +typename TriaDimensionInfo::active_cell_iterator +Triangulation::end_active (const unsigned int level) const { + return (level == levels.size()-1 ? + active_cell_iterator(end()) : + begin_active (level+1)); +}; + + + +template +typename TriaDimensionInfo::raw_face_iterator +Triangulation::end_raw_face (const unsigned int level) const { + return (level == levels.size()-1 ? + end_face() : + begin_raw_face (level+1)); +}; + + + +template +typename TriaDimensionInfo::face_iterator +Triangulation::end_face (const unsigned int level) const { + return (level == levels.size()-1 ? + face_iterator(end_face()) : + begin_face (level+1)); +}; + + + +template +typename TriaDimensionInfo::active_face_iterator +Triangulation::end_active_face (const unsigned int level) const { + return (level == levels.size()-1 ? + active_face_iterator(end_face()) : + begin_active_face (level+1)); +}; + + + +template +typename TriaDimensionInfo::raw_line_iterator +Triangulation::end_raw_line (const unsigned int level) const { + return (level == levels.size()-1 ? + end_line() : + begin_raw_line (level+1)); +}; + + + +template +typename TriaDimensionInfo::line_iterator +Triangulation::end_line (const unsigned int level) const { + return (level == levels.size()-1 ? + line_iterator(end_line()) : + begin_line (level+1)); +}; + + + +template +typename TriaDimensionInfo::active_line_iterator +Triangulation::end_active_line (const unsigned int level) const { + return (level == levels.size()-1 ? + active_line_iterator(end_line()) : + begin_active_line (level+1)); +}; + + + + +template +typename TriaDimensionInfo::raw_quad_iterator +Triangulation::end_raw_quad (const unsigned int level) const { + return (level == levels.size()-1 ? + end_quad() : + begin_raw_quad (level+1)); +}; + + + +template +typename TriaDimensionInfo::quad_iterator +Triangulation::end_quad (const unsigned int level) const { + return (level == levels.size()-1 ? + quad_iterator(end_quad()) : + begin_quad (level+1)); +}; + + + +template +typename TriaDimensionInfo::active_quad_iterator +Triangulation::end_active_quad (const unsigned int level) const { + return (level == levels.size()-1 ? + active_quad_iterator(end_quad()) : + begin_active_quad (level+1)); +}; + + + + -- 2.39.5