From a0f5822a4189d349f4ad37cbfe799c046c34a513 Mon Sep 17 00:00:00 2001 From: guido Date: Fri, 17 Oct 2003 14:22:32 +0000 Subject: [PATCH] MGCoarseGridHouseholder git-svn-id: https://svn.dealii.org/trunk@8098 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/multigrid/mg_coarse.h | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/deal.II/deal.II/include/multigrid/mg_coarse.h b/deal.II/deal.II/include/multigrid/mg_coarse.h index 5390e8c29c..b8cb2cdd0e 100644 --- a/deal.II/deal.II/include/multigrid/mg_coarse.h +++ b/deal.II/deal.II/include/multigrid/mg_coarse.h @@ -95,6 +95,64 @@ class MGCoarseGridLACIteration : public MGCoarseGridBase SmartPointer precondition; }; +//TODO: Improve QR-factorization to make this more efficient. + +/** + * Coarse grid solver by QR factorization + * + * This is a direct solver for possibly indefinite coarse grid + * problems, using the @p{least_squares} function of the class + * FullMatrix. + * + * Since the currently implemented Householder algorithm transforms + * the right hand side immediately, the transformation has to be + * computed for each coarse grid solution. Therefore, this coarse grid + * solver may be inefficient for larger coarse grid systems. + * + * @author Guido Kanschat, 2003 + */ +template +class MGCoarseGridHouseholder : public MGCoarseGridBase +{ + public: + /** + * Constructor, taking the coarse + * grid matrix. + */ + MGCoarseGridHouseholder (const FullMatrix& A); + + /** + * Initialize for a new matrix. + */ + void initialize (const FullMatrix& A); + + /** + * Solution operator, defined in + * the base class. + */ + void operator() (const unsigned int level, + VECTOR &dst, + const VECTOR &src) const; + + private: + /** + * Pointer to the coarse grid + * matrix. + */ + SmartPointer > matrix; + + /** + * Matrix for QR-factorization. + */ + mutable FullMatrix work; + + /** + * Auxiliary vector. + */ + mutable VECTOR aux; +}; + + /* ------------------ Functions for MGCoarseGridLACIteration ------------ */ @@ -167,5 +225,38 @@ MGCoarseGridLACIteration matrix=&m; } +//----------------------------------------------------------------------// + +template +MGCoarseGridHouseholder::MGCoarseGridHouseholder( + const FullMatrix& A) + : + matrix(&A) +{} + + + +template +void +MGCoarseGridHouseholder::initialize( + const FullMatrix& A) +{ + matrix = &A; +} + + + +template +void +MGCoarseGridHouseholder::operator() ( + const unsigned int, + VECTOR &dst, + const VECTOR &src) const +{ + work = *matrix; + aux = src; + work.least_squares(dst, aux); +} + #endif -- 2.39.5