From: kanschat Date: Sun, 26 May 2013 16:30:49 +0000 (+0000) Subject: also fix DoFHandler::begin(level) X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=388e42a07b257781a98440a07c17e0205038a661;p=dealii-svn.git also fix DoFHandler::begin(level) git-svn-id: https://svn.dealii.org/trunk@29614 0785d39b-7218-0410-832d-ea1e28bc413d --- 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); }