]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
First step towards parallelization.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 31 Jan 2000 18:26:46 +0000 (18:26 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 31 Jan 2000 18:26:46 +0000 (18:26 +0000)
git-svn-id: https://svn.dealii.org/trunk@2299 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_vanka.h
deal.II/lac/include/lac/sparse_vanka.templates.h

index 9facd46b5d9a7e6ab82a66f9a822b8789579c5a7..0bbda58ab5eb511d940e0d738cc6f512470db09c 100644 (file)
@@ -252,6 +252,47 @@ class SparseVanka
                                      */
     void compute_inverse (const unsigned int               row,
                          map<unsigned int, unsigned int> &local_index);
+
+                                    /**
+                                     * Apply the inverses in the
+                                     * range #[begin,end)# to the
+                                     * #src# vector and move the
+                                     * result into #dst#. Actually,
+                                     * only values of #src# from
+                                     * within the range are taken
+                                     * (all others are set to zero),
+                                     * and only values inside the
+                                     * range are written to #dst#, so
+                                     * the application of this
+                                     * function only does what is
+                                     * announced in the general
+                                     * documentation if the given
+                                     * range is the whole interval.
+                                     *
+                                     * The reason for providing the
+                                     * interval anyway is that in
+                                     * derived classes we may want to
+                                     * apply the preconditioner to
+                                     * blocks of the matrix only, in
+                                     * order to parallelize the
+                                     * application. Then, it is
+                                     * important to only write to
+                                     * some slices of #dst# and only
+                                     * takes values from similar
+                                     * slices of #src#, in order to
+                                     * eliminate the dependencies of
+                                     * threads of each other.
+                                     *
+                                     * The #operator()# of this class
+                                     * of course calls this function
+                                     * with the whole interval
+                                     * #[begin,end)=[0,matrix.m())#.
+                                     */
+    template<typename number2>
+    void apply_preconditioner (Vector<number2>       &dst,
+                              const Vector<number2> &src,
+                              const unsigned int     begin,
+                              const unsigned int     end) const;
 };
 
 
index de9049861561175083a16e1a7598ccff2d8ba28a..149b4bad1705293b61ec709d17f5dc030ed57385 100644 (file)
@@ -215,11 +215,37 @@ SparseVanka<number>::operator ()(Vector<number2>       &dst,
 {
                                   // first set output vector to zero
   dst.clear ();
+                                  // then pass on to the function
+                                  // that actually does the work
+  apply_preconditioner (dst, src, 0, matrix->m());
+};
+
+
+
+template<typename number>
+template<typename number2>
+void
+SparseVanka<number>::apply_preconditioner (Vector<number2>       &dst,
+                                          const Vector<number2> &src,
+                                          const unsigned int     begin,
+                                          const unsigned int     end) const
+{
+  Assert (begin < end, ExcInternalError());
+  
                                   // first define an alias to the sparsity
                                   // pattern of the matrix, since this
                                   // will be used quite often
   const SparsityPattern &structure
     = matrix->get_sparsity_pattern();
+
+
+                                  // store whether we shall work on
+                                  // the whole matrix, or only on
+                                  // blocks. this variable is used to
+                                  // optimize access to vectors a
+                                  // little bit.
+  const bool range_is_restricted = (begin != 0) && (end != matrix->m());
+  
   
                                   // space to be used for local
                                   // systems. allocate as much memory
@@ -289,7 +315,11 @@ SparseVanka<number>::operator ()(Vector<number2>       &dst,
            const unsigned int irow_length = structure.row_length(irow);
            
                                             // copy rhs
-           b(i) = src(irow);
+           if (!range_is_restricted ||
+               ((begin <= irow) && (irow < end)))
+             b(i) = src(irow);
+           else
+             b(i) = 0;
            
                                             // for all the DoFs that irow
                                             // couples with
@@ -310,6 +340,7 @@ SparseVanka<number>::operator ()(Vector<number2>       &dst,
                                                 //
                                                 // note that if so, we already
                                                 // have copied the entry above
+//TODO:        why is dst accessed here???
                if (js == local_index.end())
                  b(i) -= matrix->raw_entry(irow,j) * dst(col);
                else
@@ -333,7 +364,12 @@ SparseVanka<number>::operator ()(Vector<number2>       &dst,
          {
            const unsigned int irow = is->first;
            const unsigned int i = is->second;
-           dst(irow) = x(i);
+
+           if (!range_is_restricted ||
+               ((begin <= irow) && (irow < end)))
+             dst(irow) = x(i);
+                                              // do nothing if not in
+                                              // the range
          };
        
                                         // if we don't store the

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.