]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
MGCoarseGridHouseholder
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 17 Oct 2003 14:22:32 +0000 (14:22 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 17 Oct 2003 14:22:32 +0000 (14:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@8098 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_coarse.h

index 5390e8c29c1a529aec5233f8b58fa7afe0986ba1..b8cb2cdd0e58b0e3297bb92ce697abfb90658c28 100644 (file)
@@ -95,6 +95,64 @@ class MGCoarseGridLACIteration :  public MGCoarseGridBase<VECTOR>
     SmartPointer<const PRECOND> 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<typename number, class VECTOR>
+class MGCoarseGridHouseholder : public MGCoarseGridBase<VECTOR>
+{
+  public:
+                                    /**
+                                     * Constructor, taking the coarse
+                                     * grid matrix.
+                                     */
+    MGCoarseGridHouseholder (const FullMatrix<number>& A);
+
+                                    /**
+                                     * Initialize for a new matrix.
+                                     */
+    void initialize (const FullMatrix<number>& 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<const FullMatrix<number> > matrix;
+
+                                    /**
+                                     * Matrix for QR-factorization.
+                                     */
+    mutable FullMatrix<number> work;
+
+                                    /**
+                                     * Auxiliary vector.
+                                     */
+    mutable VECTOR aux;
+};
+
+  
 
 /* ------------------ Functions for MGCoarseGridLACIteration ------------ */
 
@@ -167,5 +225,38 @@ MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND, VECTOR>
   matrix=&m;
 }
 
+//----------------------------------------------------------------------//
+
+template<typename number, class VECTOR>
+MGCoarseGridHouseholder<number, VECTOR>::MGCoarseGridHouseholder(
+  const FullMatrix<number>& A)
+               :
+               matrix(&A)
+{}
+
+
+
+template<typename number, class VECTOR>
+void
+MGCoarseGridHouseholder<number, VECTOR>::initialize(
+  const FullMatrix<number>& A)
+{
+  matrix = &A;
+}
+
+
+
+template<typename number, class VECTOR>
+void
+MGCoarseGridHouseholder<number, VECTOR>::operator() (
+  const unsigned int,
+  VECTOR       &dst,
+  const VECTOR &src) const
+{
+  work = *matrix;
+  aux = src;
+  work.least_squares(dst, aux);
+}
+
 
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.