// $Id$
// Version: $Name$
//
-// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by the deal.II authors
+// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by the deal.II authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
const bool variable = false,
const bool symmetric = false,
const bool transpose = false);
-
+
/**
* Modify the number of smoothing
* steps on finest level.
* smoothing. The effect is
* overriden by set_symmetric().
*/
- void set_transpose (const bool);
+ void set_transpose (const bool);
/**
* Set #debug to a nonzero value
* to get more information
*/
void set_debug (const unsigned int level);
-
+
protected:
/**
* Number of smoothing steps on
* is chosen.
*/
bool transpose;
-
+
/**
* Output debugging information
* to #deallog if this is
/**
* Memory for auxiliary vectors.
*/
- VectorMemory<VECTOR>& mem;
+ VectorMemory<VECTOR>& mem;
};
* each level. This function
* stores pointers to the level
* matrices and initializes the
- * smoothing operator with the
+ * smoothing operator with the
* same smoother for each
* level.
*
* each level. This function
* stores pointers to the level
* matrices and initializes the
- * smoothing operator with the
+ * smoothing operator with the
* according smoother for each
* level.
*
* Empty all vectors.
*/
void clear ();
-
+
/**
* The actual smoothing method.
*/
* Memory used by this object.
*/
unsigned int memory_consumption () const;
-
+
private:
/**
* <tt>Vector<.></tt>, where the template arguments are all combinations of
* @p float and @p double. Additional instantiations may be created
* by including the file mg_smoother.templates.h.
- *
+ *
* @author Guido Kanschat, 2009
*/
template<class MATRIX, class RELAX, class VECTOR>
* each level. This function
* stores pointers to the level
* matrices and initializes the
- * smoothing operator with the
+ * smoothing operator with the
* same smoother for each
* level.
*
* each level. This function
* stores pointers to the level
* matrices and initializes the
- * smoothing operator with the
+ * smoothing operator with the
* according smoother for each
* level.
*
* Empty all vectors.
*/
void clear ();
-
+
/**
* The actual smoothing method.
*/
* Memory used by this object.
*/
unsigned int memory_consumption () const;
-
+
private:
/**
MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::clear ()
{
smoothers.clear();
-
+
unsigned int i=matrices.get_minlevel(),
max_level=matrices.get_maxlevel();
for (; i<=max_level; ++i)
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
+
matrices.resize(min, max);
smoothers.resize(min, max);
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
- Assert (data.get_minlevel() == min,
+ Assert (data.get_minlevel() == min,
ExcDimensionMismatch(data.get_minlevel(), min));
- Assert (data.get_maxlevel() == max,
+ Assert (data.get_maxlevel() == max,
ExcDimensionMismatch(data.get_maxlevel(), max));
-
+
matrices.resize(min, max);
smoothers.resize(min, max);
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
+
matrices.resize(min, max);
smoothers.resize(min, max);
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
- Assert (data.get_minlevel() == min,
+
+ Assert (data.get_minlevel() == min,
ExcDimensionMismatch(data.get_minlevel(), min));
- Assert (data.get_maxlevel() == max,
+ Assert (data.get_maxlevel() == max,
ExcDimensionMismatch(data.get_maxlevel(), max));
matrices.resize(min, max);
T = false;
if (this->debug > 0)
deallog << 'S' << level << ' ';
-
+
for (unsigned int i=0; i<steps2; ++i)
{
if (T)
}
if (this->debug > 0)
deallog << std::endl;
-
+
this->mem.free(r);
this->mem.free(d);
}
if (this->variable)
steps2 *= (1<<(maxlevel-level));
-
+
bool T = this->transpose;
if (this->symmetric && (steps2 % 2 == 0))
T = false;
if (this->debug > 0)
deallog << 'S' << level << ' ';
-
+
for (unsigned int i=0; i<steps2; ++i)
{
if (T)
MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::clear ()
{
smoothers.clear();
-
+
unsigned int i=matrices.get_minlevel(),
max_level=matrices.get_maxlevel();
for (; i<=max_level; ++i)
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
+
matrices.resize(min, max);
smoothers.resize(min, max);
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
- Assert (data.get_minlevel() == min,
+
+ Assert (data.get_minlevel() == min,
ExcDimensionMismatch(data.get_minlevel(), min));
- Assert (data.get_maxlevel() == max,
+ Assert (data.get_maxlevel() == max,
ExcDimensionMismatch(data.get_maxlevel(), max));
matrices.resize(min, max);
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
+
matrices.resize(min, max);
smoothers.resize(min, max);
{
const unsigned int min = m.get_minlevel();
const unsigned int max = m.get_maxlevel();
-
- Assert (data.get_minlevel() == min,
+
+ Assert (data.get_minlevel() == min,
ExcDimensionMismatch(data.get_minlevel(), min));
- Assert (data.get_maxlevel() == max,
+ Assert (data.get_maxlevel() == max,
ExcDimensionMismatch(data.get_maxlevel(), max));
matrices.resize(min, max);
VECTOR* r = this->mem.alloc();
VECTOR* d = this->mem.alloc();
- r->reinit(u);
- d->reinit(u);
- bool T = this->transpose;
- if (this->symmetric && (steps2 % 2 == 0))
- T = false;
- if (this->debug > 0)
- deallog << 'S' << level << ' ';
-
- for (unsigned int i=0; i<steps2; ++i)
+ try
{
- if (T)
+ r->reinit(u);
+ d->reinit(u);
+
+ bool T = this->transpose;
+ if (this->symmetric && (steps2 % 2 == 0))
+ T = false;
+ if (this->debug > 0)
+ deallog << 'S' << level << ' ';
+
+ for (unsigned int i=0; i<steps2; ++i)
{
- if (this->debug > 0)
- deallog << 'T';
- matrices[level].Tvmult(*r,u);
- r->sadd(-1.,1.,rhs);
- if (this->debug > 2)
- deallog << ' ' << r->l2_norm() << ' ';
- smoothers[level].Tvmult(*d, *r);
- if (this->debug > 1)
- deallog << ' ' << d->l2_norm() << ' ';
- } else {
- if (this->debug > 0)
- deallog << 'N';
- matrices[level].vmult(*r,u);
- r->sadd(-1.,1.,rhs);
- if (this->debug > 2)
- deallog << ' ' << r->l2_norm() << ' ';
- smoothers[level].vmult(*d, *r);
- if (this->debug > 1)
- deallog << ' ' << d->l2_norm() << ' ';
+ if (T)
+ {
+ if (this->debug > 0)
+ deallog << 'T';
+ matrices[level].Tvmult(*r,u);
+ r->sadd(-1.,1.,rhs);
+ if (this->debug > 2)
+ deallog << ' ' << r->l2_norm() << ' ';
+ smoothers[level].Tvmult(*d, *r);
+ if (this->debug > 1)
+ deallog << ' ' << d->l2_norm() << ' ';
+ } else {
+ if (this->debug > 0)
+ deallog << 'N';
+ matrices[level].vmult(*r,u);
+ r->sadd(-1.,1.,rhs);
+ if (this->debug > 2)
+ deallog << ' ' << r->l2_norm() << ' ';
+ smoothers[level].vmult(*d, *r);
+ if (this->debug > 1)
+ deallog << ' ' << d->l2_norm() << ' ';
+ }
+ u += *d;
+ if (this->symmetric)
+ T = !T;
}
- u += *d;
- if (this->symmetric)
- T = !T;
+ if (this->debug > 0)
+ deallog << std::endl;
+
+ this->mem.free(r);
+ this->mem.free(d);
+ }
+ catch (...)
+ {
+ // make sure we don't produce a
+ // memory leak
+ this->mem.free(r);
+ this->mem.free(d);
+
+ throw;
}
- if (this->debug > 0)
- deallog << std::endl;
-
- this->mem.free(r);
- this->mem.free(d);
}