From 841d0086ca8da747903f3a991ded9162832cd3b9 Mon Sep 17 00:00:00 2001 From: guido Date: Tue, 3 May 2005 06:35:01 +0000 Subject: [PATCH] MGCoarseGridLACIteration simplified git-svn-id: https://svn.dealii.org/trunk@10614 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/multigrid/mg_coarse.h | 83 +++++++++++++------ deal.II/doc/news/changes.html | 9 ++ 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/mg_coarse.h b/deal.II/deal.II/include/multigrid/mg_coarse.h index 5c30d04bcc..d64e241eb4 100644 --- a/deal.II/deal.II/include/multigrid/mg_coarse.h +++ b/deal.II/deal.II/include/multigrid/mg_coarse.h @@ -15,6 +15,7 @@ #include +#include #include /*!@addtogroup mg */ @@ -31,7 +32,7 @@ * * @author Guido Kanschat, 1999, Ralf Hartmann, 2002. */ -template > +template > class MGCoarseGridLACIteration : public MGCoarseGridBase { public: @@ -46,13 +47,20 @@ class MGCoarseGridLACIteration : public MGCoarseGridBase * preconditioning method for later * use. */ + template MGCoarseGridLACIteration (SOLVER &, const MATRIX &, const PRECOND &); - + + /** + * Destructor freeing the pointers. + */ + ~MGCoarseGridLACIteration (); + /** * Initialize new data. */ + template void initialize (SOLVER &, const MATRIX &, const PRECOND &); @@ -79,6 +87,7 @@ class MGCoarseGridLACIteration : public MGCoarseGridBase * matrix that was given to the * constructor by a new matrix. */ + template void set_matrix (const MATRIX &); private: @@ -90,14 +99,16 @@ class MGCoarseGridLACIteration : public MGCoarseGridBase /** * Reference to the matrix. */ - SmartPointer matrix; + PointerMatrixBase* matrix; /** * Reference to the preconditioner. */ - SmartPointer precondition; + PointerMatrixBase* precondition; }; + + //TODO: Improve QR-factorization to make this more efficient. /** @@ -166,55 +177,74 @@ class MGCoarseGridHouseholder : public MGCoarseGridBase /* ------------------ Functions for MGCoarseGridLACIteration ------------ */ -template -MGCoarseGridLACIteration +template +MGCoarseGridLACIteration ::MGCoarseGridLACIteration() : solver(0, typeid(*this).name()), - matrix(0, typeid(*this).name()), - precondition(0, typeid(*this).name()) + matrix(0), + precondition(0) {} -template -MGCoarseGridLACIteration +template +template +MGCoarseGridLACIteration ::MGCoarseGridLACIteration(SOLVER& s, const MATRIX &m, const PRECOND &p) : - solver(&s, typeid(*this).name()), - matrix(&m, typeid(*this).name()), - precondition(&p, typeid(*this).name()) -{} + solver(&s, typeid(*this).name()) +{ + matrix = new PointerMatrix(&m); + precondition = new PointerMatrix(&p); +} + + +template +MGCoarseGridLACIteration +::~MGCoarseGridLACIteration() +{ + clear(); +} -template +template +template void -MGCoarseGridLACIteration +MGCoarseGridLACIteration ::initialize(SOLVER& s, const MATRIX &m, const PRECOND &p) { solver = &s; - matrix = &m; - precondition = &p; + if (matrix) + delete matrix; + matrix = new PointerMatrix(&m); + if (precondition) + delete precondition; + precondition = new PointerMatrix(&p); } -template +template void -MGCoarseGridLACIteration +MGCoarseGridLACIteration ::clear() { solver = 0; + if (matrix) + delete matrix; matrix = 0; + if (precondition) + delete precondition; precondition = 0; } -template +template void -MGCoarseGridLACIteration +MGCoarseGridLACIteration ::operator() (const unsigned int /* level */, VECTOR &dst, const VECTOR &src) const @@ -226,12 +256,15 @@ MGCoarseGridLACIteration } -template +template +template void -MGCoarseGridLACIteration +MGCoarseGridLACIteration ::set_matrix(const MATRIX &m) { - matrix=&m; + if (matrix) + delete matrix; + matrix = new PointerMatrix(&m); } //--------------------------------------------------------------------------- diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index 39489a4137..7a47059cf6 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -42,6 +42,15 @@ inconvenience this causes.
    +
  1. Changed: The class MGCoarseGridLACIteration lost two template + arguments. Since the matrix and preconditioner are now stored in + form of PointerMatrix objects, handling + of the class is much simpler, in particular when exchanging + preconditioners. +
    (GK 2005/05/03) +

    +
  2. Changed: The template argument of BlockMatrixArray was changed to number, equal to the same argument of the used