From 3e04cbf3e51b74af000a3e5b6b6261eaf6a89f73 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Sun, 26 May 2013 16:30:49 +0000 Subject: [PATCH] also fix DoFHandler::begin(level) git-svn-id: https://svn.dealii.org/trunk@29614 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/dofs/dof_handler.cc | 35 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/deal.II/source/dofs/dof_handler.cc b/deal.II/source/dofs/dof_handler.cc index 8d575a0ceb..083d28b73b 100644 --- a/deal.II/source/dofs/dof_handler.cc +++ b/deal.II/source/dofs/dof_handler.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -797,8 +797,10 @@ template typename DoFHandler::cell_iterator DoFHandler::begin (const unsigned int level) const { - return cell_iterator (*this->get_tria().begin(level), - this); + typename Triangulation::cell_iterator cell = this->get_tria().begin(level); + if (cell == this->get_tria().end(level)) + return end(level); + return cell_iterator (*cell, this); } @@ -834,9 +836,10 @@ template typename DoFHandler::cell_iterator DoFHandler::end (const unsigned int level) const { - return (level == this->get_tria().n_levels()-1 ? - end() : - begin (level+1)); + typename Triangulation::cell_iterator cell = this->get_tria().end(level); + if (cell.state() != IteratorState::valid) + return end(); + return cell_iterator (*cell, this); } @@ -844,9 +847,10 @@ template typename DoFHandler::active_cell_iterator DoFHandler::end_active (const unsigned int level) const { - return (level == this->get_tria().n_levels()-1 ? - active_cell_iterator(end()) : - begin_active (level+1)); + typename Triangulation::cell_iterator cell = this->get_tria().end_active(level); + if (cell.state() != IteratorState::valid) + return active_cell_iterator(end()); + return active_cell_iterator (*cell, this); } @@ -857,8 +861,10 @@ DoFHandler::begin_mg (const unsigned int level) const { // Assert(this->has_level_dofs(), ExcMessage("You can only iterate over mg " // "levels if mg dofs got distributed.")); - return level_cell_iterator (*this->get_tria().begin(level), - this); + typename Triangulation::cell_iterator cell = this->get_tria().begin(level); + if (cell == this->get_tria().end(level)) + return end_mg(level); + return level_cell_iterator (*cell, this); } @@ -868,9 +874,10 @@ DoFHandler::end_mg (const unsigned int level) const { // Assert(this->has_level_dofs(), ExcMessage("You can only iterate over mg " // "levels if mg dofs got distributed.")); - return (level == this->get_tria().n_levels()-1 ? - end() : - begin (level+1)); + typename Triangulation::cell_iterator cell = this->get_tria().end(level); + if (cell.state() != IteratorState::valid) + return end(); + return level_cell_iterator (*cell, this); } -- 2.39.5