//---------------------------------------------------------------------------
// $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
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<<std::endl;
// t[level].print(std::cout, 2,false);
{
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)
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
// 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];
typename Triangulation<dim,spacedim>::cell_iterator
Triangulation<dim,spacedim>::last (const unsigned int level) const
{
- Assert (level<levels.size(), ExcInvalidLevel(level));
- Assert (levels[level]->cells.cells.size() != 0,
- ExcEmptyLevel (level));
+ Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
+ if (levels[level]->cells.cells.size() ==0)
+ return end(level);
// find the last raw iterator on
// this level
{
// 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;
}
// 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;
}
typename Triangulation<dim, spacedim>::raw_cell_iterator
Triangulation<dim, spacedim>::end_raw (const unsigned int level) const
{
- return (level == levels.size()-1 ?
- end() :
- begin_raw (level+1));
+ Assert (level<n_global_levels(), ExcInvalidLevel(level));
+ if (level < levels.size()-1)
+ return begin_raw (level+1);
+ else
+ return end();
}
typename Triangulation<dim, spacedim>::cell_iterator
Triangulation<dim, spacedim>::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<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
+ return end();
}
switch (dim)
{
case 1:
- Assert (level<levels.size(), ExcInvalidLevel(level));
-
- if (levels[level]->cells.cells.size() == 0)
- return end_line ();
+ Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
+
+ if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
+ return end_line();
return raw_line_iterator (const_cast<Triangulation<dim,spacedim>*>(this),
level,
return raw_hex_iterator();
case 2:
{
- Assert (level<levels.size(), ExcInvalidLevel(level));
+ Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
- if (levels[level]->cells.cells.size() == 0)
+ if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
return end_quad();
return raw_quad_iterator (const_cast<Triangulation<dim,spacedim>*>(this),
return raw_hex_iterator();
case 3:
{
- Assert (level<levels.size(), ExcInvalidLevel(level));
-
- if (levels[level]->cells.cells.size() == 0)
+ Assert (level<n_global_levels() || level<levels.size(), ExcInvalidLevel(level));
+
+ if (level >= levels.size() || levels[level]->cells.cells.size() == 0)
return end_hex();
-
+
return raw_hex_iterator (const_cast<Triangulation<dim,spacedim>*>(this),
level,
0);