]> https://gitweb.dealii.org/ - dealii.git/commitdiff
some initialize functions added to handle different smoothers on each level
authorBaerbel Jannsen <baerbel.janssen@gmail.com>
Tue, 5 Jan 2010 13:50:48 +0000 (13:50 +0000)
committerBaerbel Jannsen <baerbel.janssen@gmail.com>
Tue, 5 Jan 2010 13:50:48 +0000 (13:50 +0000)
git-svn-id: https://svn.dealii.org/trunk@20288 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_smoother.h

index ef498eed7ad39535b9e121b0e262a712e0e2f311..fdcb4b729f3ce1c44cafe68cc729dd7aa0ee25ca 100644 (file)
@@ -222,17 +222,12 @@ class MGSmootherRelaxation : public MGSmoother<VECTOR>
                         const bool transpose = false);
 
                                     /**
-                                     * Initialize for matrices. The
-                                     * parameter @p matrices can be
-                                     * any object having functions
-                                     * <tt>get_minlevel()</tt> and
-                                     * <tt>get_maxlevel()</tt> as well as
-                                     * an <tt>operator[]</tt> returning a
-                                     * reference to @p MATRIX. This
+                                     * Initialize for matrices. This
                                      * function stores pointers to
                                      * the level matrices and
                                      * initializes the smoothing
-                                     * operator for each level.
+                                     * operator with the same smoother
+                                      * for each level.
                                      *
                                      * @p additional_data is an
                                      * object of type
@@ -241,28 +236,40 @@ class MGSmootherRelaxation : public MGSmoother<VECTOR>
                                      * initialization function of the
                                      * relaxation method.
                                      */
-    template <class MGMATRIXOBJECT, class DATA>
-    void initialize (const MGMATRIXOBJECT& matrices,
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
                     const DATA& additional_data);
 
+                                    /**
+                                     * Initialize for matrices. This
+                                     * function stores pointers to
+                                     * the level matrices and
+                                     * initializes the smoothing
+                                     * operator with the according
+                                      * smoother for each level.
+                                     *
+                                     * @p additional_data is an
+                                     * object of type
+                                     * @p RELAX::AdditionalData and
+                                     * is handed to the
+                                     * initialization function of the
+                                     * relaxation method.
+                                     */
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
+                    const MGLevelObject<DATA>& additional_data);
+
                                     /**
                                      * Initialize for single blocks
-                                     * of matrices. The parameter
-                                     * @p matrices can be any object
-                                     * having functions
-                                     * <tt>get_minlevel()</tt> and
-                                     * <tt>get_maxlevel()</tt> as well as
-                                     * an <tt>operator[]</tt> returning a
-                                     * reference to a block matrix
-                                     * where each block is of type
-                                     * @p MATRIX. Of this block
+                                     * of matrices. Of this block
                                      * matrix, the block indicated by
                                      * @p block_row and
                                      * @p block_col is selected on
                                      * each level.  This function
                                      * stores pointers to the level
                                      * matrices and initializes the
-                                     * smoothing operator for each
+                                     * smoothing operator with the 
+                                      * same smoother for each
                                      * level.
                                      *
                                      * @p additional_data is an
@@ -272,10 +279,36 @@ class MGSmootherRelaxation : public MGSmoother<VECTOR>
                                      * initialization function of the
                                      * relaxation method.
                                      */
-    template <class MGMATRIXOBJECT, class DATA>
-    void initialize (const MGMATRIXOBJECT& matrices,
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
                     const DATA& additional_data,
                     const unsigned int block_row,
+                    const unsigned int block_col);
+
+                                    /**
+                                     * Initialize for single blocks
+                                     * of matrices. Of this block
+                                     * matrix, the block indicated by
+                                     * @p block_row and
+                                     * @p block_col is selected on
+                                     * each level.  This function
+                                     * stores pointers to the level
+                                     * matrices and initializes the
+                                     * smoothing operator with the 
+                                      * according smoother for each
+                                     * level.
+                                     *
+                                     * @p additional_data is an
+                                     * object of type
+                                     * @p RELAX::AdditionalData and
+                                     * is handed to the
+                                     * initialization function of the
+                                     * relaxation method.
+                                     */
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
+                    const MGLevelObject<DATA>& additional_data,
+                    const unsigned int block_row,
                     const unsigned int block_col);
 
                                     /**
@@ -358,17 +391,12 @@ class MGSmootherPrecondition : public MGSmoother<VECTOR>
                           const bool transpose = false);
 
                                     /**
-                                     * Initialize for matrices. The
-                                     * parameter @p matrices can be
-                                     * any object having functions
-                                     * <tt>get_minlevel()</tt> and
-                                     * <tt>get_maxlevel()</tt> as well as
-                                     * an <tt>operator[]</tt> returning a
-                                     * reference to @p MATRIX. This
+                                     * Initialize for matrices. This
                                      * function stores pointers to
                                      * the level matrices and
                                      * initializes the smoothing
-                                     * operator for each level.
+                                     * operator with the same smoother
+                                      * for each level.
                                      *
                                      * @p additional_data is an
                                      * object of type
@@ -377,28 +405,40 @@ class MGSmootherPrecondition : public MGSmoother<VECTOR>
                                      * initialization function of the
                                      * relaxation method.
                                      */
-    template <class MGMATRIXOBJECT, class DATA>
-    void initialize (const MGMATRIXOBJECT& matrices,
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
                     const DATA& additional_data);
 
+                                    /**
+                                     * Initialize for matrices. This
+                                     * function stores pointers to
+                                     * the level matrices and
+                                     * initializes the smoothing
+                                     * operator with the according
+                                      * smoother for each level.
+                                     *
+                                     * @p additional_data is an
+                                     * object of type
+                                     * @p RELAX::AdditionalData and
+                                     * is handed to the
+                                     * initialization function of the
+                                     * relaxation method.
+                                     */
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
+                    const MGLevelObject<DATA>& additional_data);
+
                                     /**
                                      * Initialize for single blocks
-                                     * of matrices. The parameter
-                                     * @p matrices can be any object
-                                     * having functions
-                                     * <tt>get_minlevel()</tt> and
-                                     * <tt>get_maxlevel()</tt> as well as
-                                     * an <tt>operator[]</tt> returning a
-                                     * reference to a block matrix
-                                     * where each block is of type
-                                     * @p MATRIX. Of this block
+                                     * of matrices. Of this block
                                      * matrix, the block indicated by
                                      * @p block_row and
                                      * @p block_col is selected on
                                      * each level.  This function
                                      * stores pointers to the level
                                      * matrices and initializes the
-                                     * smoothing operator for each
+                                     * smoothing operator with the 
+                                      * same smoother for each
                                      * level.
                                      *
                                      * @p additional_data is an
@@ -408,10 +448,36 @@ class MGSmootherPrecondition : public MGSmoother<VECTOR>
                                      * initialization function of the
                                      * relaxation method.
                                      */
-    template <class MGMATRIXOBJECT, class DATA>
-    void initialize (const MGMATRIXOBJECT& matrices,
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
                     const DATA& additional_data,
                     const unsigned int block_row,
+                    const unsigned int block_col);
+
+                                    /**
+                                     * Initialize for single blocks
+                                     * of matrices. Of this block
+                                     * matrix, the block indicated by
+                                     * @p block_row and
+                                     * @p block_col is selected on
+                                     * each level.  This function
+                                     * stores pointers to the level
+                                     * matrices and initializes the
+                                     * smoothing operator with the 
+                                      * according smoother for each
+                                     * level.
+                                     *
+                                     * @p additional_data is an
+                                     * object of type
+                                     * @p RELAX::AdditionalData and
+                                     * is handed to the
+                                     * initialization function of the
+                                     * relaxation method.
+                                     */
+    template <class MATRIX2, class DATA>
+    void initialize (const MGLevelObject<MATRIX2>& matrices,
+                    const MGLevelObject<DATA>& additional_data,
+                    const unsigned int block_row,
                     const unsigned int block_col);
 
                                     /**
@@ -547,10 +613,10 @@ MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::clear ()
 
 
 template <class MATRIX, class RELAX, class VECTOR>
-template <class MGMATRIXOBJECT, class DATA>
+template <class MATRIX2, class DATA>
 inline void
 MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::initialize (
-  const MGMATRIXOBJECT& m,
+  const MGLevelObject<MATRIX2>& m,
   const DATA& data)
 {
   const unsigned int min = m.get_minlevel();
@@ -566,12 +632,31 @@ MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::initialize (
     }
 }
 
+template <class MATRIX, class RELAX, class VECTOR>
+template <class MATRIX2, class DATA>
+inline void
+MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::initialize (
+  const MGLevelObject<MATRIX2>& m,
+  const MGLevelObject<DATA>& data)
+{
+  const unsigned int min = m.get_minlevel();
+  const unsigned int max = m.get_maxlevel();
+  
+  matrices.resize(min, max);
+  smoothers.resize(min, max);
+
+  for (unsigned int i=min;i<=max;++i)
+    {
+      matrices[i] = &m[i];
+      smoothers[i].initialize(m[i], data[i]);
+    }
+}
 
 template <class MATRIX, class RELAX, class VECTOR>
-template <class MGMATRIXOBJECT, class DATA>
+template <class MATRIX2, class DATA>
 inline void
 MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::initialize (
-  const MGMATRIXOBJECT& m,
+  const MGLevelObject<MATRIX2>& m,
   const DATA& data,
   const unsigned int row,
   const unsigned int col)
@@ -589,6 +674,27 @@ MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::initialize (
     }
 }
 
+template <class MATRIX, class RELAX, class VECTOR>
+template <class MATRIX2, class DATA>
+inline void
+MGSmootherRelaxation<MATRIX, RELAX, VECTOR>::initialize (
+  const MGLevelObject<MATRIX2>& m,
+  const MGLevelObject<DATA>& data,
+  const unsigned int row,
+  const unsigned int col)
+{
+  const unsigned int min = m.get_minlevel();
+  const unsigned int max = m.get_maxlevel();
+  
+  matrices.resize(min, max);
+  smoothers.resize(min, max);
+
+  for (unsigned int i=min;i<=max;++i)
+    {
+      matrices[i] = &(m[i].block(row, col));
+      smoothers[i].initialize(m[i].block(row, col), data[i]);
+    }
+}
 
 #ifdef DEAL_II_MULTIGRID_COMPATIBILITY
 
@@ -727,10 +833,10 @@ MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::clear ()
 
 
 template <class MATRIX, class RELAX, class VECTOR>
-template <class MGMATRIXOBJECT, class DATA>
+template <class MATRIX2, class DATA>
 inline void
 MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::initialize (
-  const MGMATRIXOBJECT& m,
+  const MGLevelObject<MATRIX2>& m,
   const DATA& data)
 {
   const unsigned int min = m.get_minlevel();
@@ -746,12 +852,31 @@ MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::initialize (
     }
 }
 
+template <class MATRIX, class RELAX, class VECTOR>
+template <class MATRIX2, class DATA>
+inline void
+MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::initialize (
+  const MGLevelObject<MATRIX2>& m,
+  const MGLevelObject<DATA>& data)
+{
+  const unsigned int min = m.get_minlevel();
+  const unsigned int max = m.get_maxlevel();
+  
+  matrices.resize(min, max);
+  smoothers.resize(min, max);
+
+  for (unsigned int i=min;i<=max;++i)
+    {
+      matrices[i] = &m[i];
+      smoothers[i].initialize(m[i], data[i]);
+    }
+}
 
 template <class MATRIX, class RELAX, class VECTOR>
-template <class MGMATRIXOBJECT, class DATA>
+template <class MATRIX2, class DATA>
 inline void
 MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::initialize (
-  const MGMATRIXOBJECT& m,
+  const MGLevelObject<MATRIX2>& m,
   const DATA& data,
   const unsigned int row,
   const unsigned int col)
@@ -769,6 +894,27 @@ MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::initialize (
     }
 }
 
+template <class MATRIX, class RELAX, class VECTOR>
+template <class MATRIX2, class DATA>
+inline void
+MGSmootherPrecondition<MATRIX, RELAX, VECTOR>::initialize (
+  const MGLevelObject<MATRIX2>& m,
+  const MGLevelObject<DATA>& data,
+  const unsigned int row,
+  const unsigned int col)
+{
+  const unsigned int min = m.get_minlevel();
+  const unsigned int max = m.get_maxlevel();
+  
+  matrices.resize(min, max);
+  smoothers.resize(min, max);
+
+  for (unsigned int i=min;i<=max;++i)
+    {
+      matrices[i] = &(m[i].block(row, col));
+      smoothers[i].initialize(m[i].block(row, col), data[i]);
+    }
+}
 
 template <class MATRIX, class RELAX, class VECTOR>
 inline void

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.