From: Guido Kanschat Date: Thu, 15 Jun 2000 19:21:02 +0000 (+0000) Subject: New PreconditionJacobi X-Git-Tag: v8.0.0~20385 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8aacfd25e5da7b2a83a345dc07e1322713d7d985;p=dealii.git New PreconditionJacobi git-svn-id: https://svn.dealii.org/trunk@3029 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/precondition.h b/deal.II/lac/include/lac/precondition.h index 9b279680e0..97e65c8020 100644 --- a/deal.II/lac/include/lac/precondition.h +++ b/deal.II/lac/include/lac/precondition.h @@ -13,28 +13,94 @@ #ifndef __deal2__precondition_h #define __deal2__precondition_h +// This file contains simple preconditioners. + #include +#include template class Vector; template class SparseMatrix; /** - * No preconditioning. - * This class helps you, if you want to use a linear solver without - * preconditioning. Since this is a strange idea, the documentation - * here stays quite short. + * No preconditioning. This class helps you, if you want to use a + * linear solver without preconditioning. All solvers in LAC require a + * preconditioner. Therefore, you must use the identity provided here + * to avoid preconditioning. * * @author Guido Kanschat, 1999 */ class PreconditionIdentity { public: - /** - * Execute preconditioning. + /** + * Apply preconditioner. */ template - void operator() (VECTOR&, const VECTOR&) const; + void vmult (VECTOR&, const VECTOR&) const; + /** + * Apply transpose + * preconditioner. Since this is + * the identity, this function is + * the same as + * @ref{vmult}. + */ + template + void Tvmult (VECTOR&, const VECTOR&) const; + /** + * Apply preconditioner. + */ + template + void operator () (VECTOR&, const VECTOR&) const; +}; + + +/** + * Jacobi preconditioner using matrix built-in function. The MATRIX + * class used is required to have a function + * @p{precondition_Jacobi(VECTOR&, const VECTOR&, double} + * + * @author Guido Kanschat, 2000 + */ +template > +class PreconditionJacobi +{ + public: + /** + * Initialize matrix and + * relaxation parameter. The + * matrix is just stored in the + * preconditioner object. The + * relaxation parameter should be + * larger than zero and smaller + * than 2 for numerical + * reasons. It defaults to 1. + */ + void initialize (const MATRIX& A, const double omega = 1.); + /** + * Apply preconditioner. + */ + template + void vmult (VECTOR&, const VECTOR&) const; + /** + * Apply transpose + * preconditioner. Since this is + * a symmetric preconditioner, + * this function is the same as + * @ref{vmult}. + */ + template + void Tvmult (VECTOR&, const VECTOR&) const; + + private: + /** + * Pointer to the matrix object. + */ + SmartPointer A; + /** + * Relaxation parameter. + */ + double omega; }; @@ -315,12 +381,49 @@ class PreconditionedMatrix /* ---------------------------------- Inline functions ------------------- */ template -void -PreconditionIdentity::operator() (VECTOR& dst, const VECTOR& src) const +inline void +PreconditionIdentity::operator () (VECTOR& dst, const VECTOR& src) const +{ + dst = src; +} + +template +inline void +PreconditionIdentity::vmult (VECTOR& dst, const VECTOR& src) const { dst = src; } +template +inline void +PreconditionIdentity::Tvmult (VECTOR& dst, const VECTOR& src) const +{ + dst = src; +} + +//----------------------------------------------------------------------// + +template +inline void +PreconditionJacobi::initialize (const MATRIX& rA, double o) +{ + A = &rA; + omega = o; +} + +template +template +inline void +PreconditionJacobi::vmult (VECTOR& dst, const VECTOR& src) const +{ +//TODO: Assert object not initialized + A->precondition_Jacobi (dst, src, omega); +} + + +//----------------------------------------------------------------------// + + template PreconditionUseMatrix::PreconditionUseMatrix(const MATRIX& M, function_ptr method)