From: kanschat Date: Sun, 26 May 2013 15:44:10 +0000 (+0000) Subject: Do not throw assertions from Triangulation::begin(level) and Triangulation::end(level... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ca77263966c230c74d043108368c3b5eeecf699;p=dealii-svn.git Do not throw assertions from Triangulation::begin(level) and Triangulation::end(level) if level is in the global level range git-svn-id: https://svn.dealii.org/trunk@29611 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 291868facf..e54d6a4e59 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -130,6 +130,14 @@ this function.

Specific improvements

    + +
  1. Improved: Triangulation::begin(level) and Triangulation::end(level) now return an +empty iterator range if the level is larger than the maximal locally owned level, +but still in the global level range of a distributed Triangulation. +
    +(Timo Heister and Guido Kanschat, 2013/05/26) +
  2. +
  3. New: The IndexSet::add_indices function that takes another IndexSet object now has an additional argument offset that can be used to offset the indices of first argument. diff --git a/deal.II/include/deal.II/multigrid/multigrid.templates.h b/deal.II/include/deal.II/multigrid/multigrid.templates.h index cfee9c22a9..4422edac91 100644 --- a/deal.II/include/deal.II/multigrid/multigrid.templates.h +++ b/deal.II/include/deal.II/multigrid/multigrid.templates.h @@ -1,7 +1,7 @@ //--------------------------------------------------------------------------- // $Id$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2012 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 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 @@ -153,6 +153,10 @@ Multigrid::level_v_step(const unsigned int level) deallog << "Residual on level " << level << std::endl; // t = A*solution[level] matrix->vmult(level, t[level], solution[level]); + + if (debug>2) + deallog << "Residual norm " << t[level].l2_norm() + << std::endl; // std::cout<::level_v_step(const unsigned int level) { edge_out->vmult_add(level, t[level], solution[level]); if (debug>2) - deallog << "Norm t[" << level << "] " << t[level].l2_norm() << std::endl; + deallog << "Norm t[" << level << "] " << t[level].l2_norm() << std::endl; } if (l==level && edge_down != 0) @@ -179,7 +183,7 @@ Multigrid::level_v_step(const unsigned int level) deallog << "restrict t[" << l-1 << "] " << t[l-1].l2_norm() << std::endl; defect[l-1] -= t[l-1]; if (debug>3) - deallog << "defect d[" << l-1 << "] " << defect[l-1].l2_norm() << std::endl; + deallog << "defect d[" << l-1 << "] " << defect[l-1].l2_norm() << std::endl; } // do recursion @@ -194,6 +198,8 @@ Multigrid::level_v_step(const unsigned int level) // do coarse grid correction transfer->prolongate(level, t[level], solution[level-1]); + if (debug>2) + deallog << "Prolongate norm " << t[level].l2_norm() << std::endl; solution[level] += t[level]; diff --git a/deal.II/source/grid/tria.cc b/deal.II/source/grid/tria.cc index 4350049bcc..6f7d4af79b 100644 --- a/deal.II/source/grid/tria.cc +++ b/deal.II/source/grid/tria.cc @@ -10999,9 +10999,9 @@ template typename Triangulation::cell_iterator Triangulation::last (const unsigned int level) const { - Assert (levelcells.cells.size() != 0, - ExcEmptyLevel (level)); + Assert (levelcells.cells.size() ==0) + return end(level); // find the last raw iterator on // this level @@ -11026,13 +11026,16 @@ Triangulation::last_active () const { // get the last used cell cell_iterator cell = last(); - - // then move to the last active one - if (cell->active()==true) - return cell; - while ((--cell).state() == IteratorState::valid) - if (cell->active()==true) - return cell; + + if (cell != end()) + { + // then move to the last active one + if (cell->active()==true) + return cell; + while ((--cell).state() == IteratorState::valid) + if (cell->active()==true) + return cell; + } return cell; } @@ -11045,12 +11048,15 @@ Triangulation::last_active (const unsigned int level) const // get the last used cell on this level cell_iterator cell = last(level); - // then move to the last active one - if (cell->active()==true) - return cell; - while ((--cell).state() == IteratorState::valid) - if (cell->active()==true) - return cell; + if (cell != end(level)) + { + // then move to the last active one + if (cell->active()==true) + return cell; + while ((--cell).state() == IteratorState::valid) + if (cell->active()==true) + return cell; + } return cell; } @@ -11071,9 +11077,11 @@ template typename Triangulation::raw_cell_iterator Triangulation::end_raw (const unsigned int level) const { - return (level == levels.size()-1 ? - end() : - begin_raw (level+1)); + Assert (level typename Triangulation::cell_iterator Triangulation::end (const unsigned int level) const { - return (level == levels.size()-1 ? - cell_iterator(end()) : - begin (level+1)); + if (level < levels.size()-1) + return begin (level+1); + Assert (level::begin_raw_line (const unsigned int level) const switch (dim) { case 1: - Assert (levelcells.cells.size() == 0) - return end_line (); + Assert (level= levels.size() || levels[level]->cells.cells.size() == 0) + return end_line(); return raw_line_iterator (const_cast*>(this), level, @@ -11250,9 +11259,9 @@ Triangulation::begin_raw_quad (const unsigned int level) const return raw_hex_iterator(); case 2: { - Assert (levelcells.cells.size() == 0) + if (level >= levels.size() || levels[level]->cells.cells.size() == 0) return end_quad(); return raw_quad_iterator (const_cast*>(this), @@ -11335,11 +11344,11 @@ Triangulation::begin_raw_hex (const unsigned int level) const return raw_hex_iterator(); case 3: { - Assert (levelcells.cells.size() == 0) + Assert (level= levels.size() || levels[level]->cells.cells.size() == 0) return end_hex(); - + return raw_hex_iterator (const_cast*>(this), level, 0);