]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement Jacobi preconditioning.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 May 2000 10:49:33 +0000 (10:49 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 May 2000 10:49:33 +0000 (10:49 +0000)
git-svn-id: https://svn.dealii.org/trunk@2932 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_sparse_matrix.h

index 9512228649e806b8c76f67eab6581e4f6256fba9..60065927702ffe7a30a591279504c8092d475d97 100644 (file)
@@ -383,6 +383,24 @@ class BlockSparseMatrix : public Subscriptor
                         const BlockVector<columns,somenumber> &x,
                         const BlockVector<rows,somenumber>    &b) const;
 
+                                    /**
+                                     * Apply the Jacobi
+                                     * preconditioner, which
+                                     * multiplies every element of
+                                     * the #src# vector by the
+                                     * inverse of the respective
+                                     * diagonal element and
+                                     * multiplies the result with the
+                                     * damping factor #omega#.
+                                     *
+                                     * The matrix needs to be square
+                                     * for this operation.
+                                     */
+    template <typename somenumber>
+    void precondition_Jacobi (BlockVector<rows,somenumber>          &dst,
+                             const BlockVector<columns,somenumber> &src,
+                             const number                           omega = 1.) const;
+
                                     /**
                                      * Return a (constant) reference
                                      * to the underlying sparsity
@@ -711,6 +729,22 @@ residual (BlockVector<rows,somenumber>          &dst,
 
 
 
+template <typename number, int  rows, int columns>
+template <typename somenumber>
+void
+BlockSparseMatrix<number,rows,columns>::
+precondition_Jacobi (BlockVector<rows,somenumber>          &dst,
+                    const BlockVector<columns,somenumber> &src,
+                    const number                           omega) const
+{
+  Assert (rows == columns, ExcMatrixNotBlockSquare());
+
+  for (unsigned int i=0; i<rows; ++i)
+    block(i,i).precondition_Jacobi (dst.block(i),
+                                   src.block(i),
+                                   omega);
+};
+
 
 
 #endif    // __deal2__block_sparse_matrix_h

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.