]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Slight update in SparseMatrix collective add/set functions. Add some more documentati...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 27 Nov 2008 10:10:10 +0000 (10:10 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 27 Nov 2008 10:10:10 +0000 (10:10 +0000)
git-svn-id: https://svn.dealii.org/trunk@17764 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/solver_bicgstab.h
deal.II/lac/include/lac/sparse_matrix.h

index 440b34d92dfa3a5aa1d3c971b9634826eb87f580..c9faae836389b2e924c22c1042371d3b58af3b89 100644 (file)
@@ -42,16 +42,18 @@ DEAL_II_NAMESPACE_OPEN
  * solver changes.
  *
  * The Bicgstab-method has two additional parameters: the first is a
- * boolean, deciding whether to compute the actual residual in each
- * step (@p true) or to use the length of the computed orthogonal
- * residual (@p false). Remark, that computing the residual causes a
- * third matrix-vector-multiplication, though no additional
- * preconditioning, in each step. The reason for doing this is, that
- * the size of the orthogonalized residual computed during the
- * iteration may be larger by orders of magnitude than the true
- * residual. This is due to numerical instabilities related to badly
- * conditioned matrices. Since this instability results in a bad
- * stopping criterion, the default for this parameter is @p true.
+ * boolean, deciding whether to compute the actual residual in each step (@p
+ * true) or to use the length of the computed orthogonal residual (@p
+ * false). Remark, that computing the residual causes a third
+ * matrix-vector-multiplication, though no additional preconditioning, in
+ * each step. The reason for doing this is, that the size of the
+ * orthogonalized residual computed during the iteration may be larger by
+ * orders of magnitude than the true residual. This is due to numerical
+ * instabilities related to badly conditioned matrices. Since this
+ * instability results in a bad stopping criterion, the default for this
+ * parameter is @p true. Whenever the user knows that the estimated residual
+ * works reasonably as well, it the flag should be set to @p false in order
+ * to increase the performance of the solver.
  *
  * The second parameter is the size of a breakdown criterion. It is
  * difficult to find a general good criterion, so if things do not
@@ -62,13 +64,17 @@ class SolverBicgstab : public Solver<VECTOR>
 {
   public:
                                     /**
-                                     * There are two possibilities to compute
-                                     * the residual: one is an estimate using
-                                     * the computed value @p tau. The other
-                                     * is exact computation using another matrix
-                                     * vector multiplication.
+                                     * There are two possibilities to
+                                     * compute the residual: one is an
+                                     * estimate using the computed value @p
+                                     * tau. The other is exact computation
+                                     * using another matrix vector
+                                     * multiplication. This increases the
+                                     * costs of the algorithm, so it is
+                                     * should be set to false whenever the
+                                     * problem allows it.
                                      *
-                                     * Bicgstab, is susceptible to breakdowns, so
+                                     * Bicgstab is susceptible to breakdowns, so
                                      * we need a parameter telling us, which
                                      * numbers are considered zero.
                                      */
@@ -77,9 +83,9 @@ class SolverBicgstab : public Solver<VECTOR>
                                         /**
                                          * Constructor.
                                          *
-                                         * The default is exact residual
-                                         * computation and breakdown
-                                         * parameter 1e-16.
+                                         * The default is to perform an
+                                         * exact residual computation and
+                                         * breakdown parameter 1e-10.
                                          */
        AdditionalData(bool exact_residual = true,
                       double breakdown=1.e-10) :
index f324138bc4f6c6fee1ea4f3afd602875fd8b9c11..45c24714872e26eb1c2bbde3e24e84fc7f9c076a 100644 (file)
@@ -2106,9 +2106,6 @@ SparseMatrix<number>::set (const unsigned int  row,
   global_indices.resize(n_cols);
   column_values.resize(n_cols);
 
-  const unsigned int * index_ptr = &col_indices[0];
-  const number * value_ptr = &values[0];
-
                                   // First, search all the indices to find
                                   // out which values we actually need to
                                   // set.
@@ -2116,18 +2113,15 @@ SparseMatrix<number>::set (const unsigned int  row,
                                   // efficient.
   for (unsigned int j=0; j<n_cols; ++j)
     {
-      const number value = *value_ptr++;
+      const number value = values[j];
       Assert (numbers::is_finite(value),
              ExcMessage("The given value is not finite but either "
                         "infinite or Not A Number (NaN)"));
 
       if (value == 0 && elide_zero_values == true)
-       {
-         ++index_ptr;
-         continue;
-       }
+       continue;
 
-      const unsigned int index = cols->operator()(row, *index_ptr++);
+      const unsigned int index = cols->operator()(row, col_indices[j]);
 
                                   // it is allowed to set elements in
                                   // the matrix that are not part of
@@ -2146,8 +2140,8 @@ SparseMatrix<number>::set (const unsigned int  row,
       n_columns++;
     }
 
-  index_ptr = &global_indices[0];
-  value_ptr = &column_values[0];
+  const unsigned int * index_ptr = &global_indices[0];
+  const number * value_ptr = &column_values[0];
   
                                    // Finally, go through the index list 
                                    // and set the elements one by one.
@@ -2245,9 +2239,6 @@ SparseMatrix<number>::add (const unsigned int  row,
   global_indices.resize(n_cols);
   column_values.resize(n_cols);
 
-  const unsigned int * index_ptr = &col_indices[0];
-  const number * value_ptr = &values[0];
-
                                   // First, search all the indices to find
                                   // out which values we actually need to
                                   // add.
@@ -2255,18 +2246,15 @@ SparseMatrix<number>::add (const unsigned int  row,
                                   // efficient.
   for (unsigned int j=0; j<n_cols; ++j)
     {
-      const number value = *value_ptr++;
+      const number value = values[j];
       Assert (numbers::is_finite(value),
              ExcMessage("The given value is not finite but either "
                         "infinite or Not A Number (NaN)"));
 
       if (value == 0 && elide_zero_values == true)
-       {
-         ++index_ptr;
-         continue;
-       }
+       continue;
 
-      const unsigned int index = cols->operator()(row, *index_ptr++);
+      const unsigned int index = cols->operator()(row, col_indices[j]);
 
                                   // it is allowed to add elements to
                                   // the matrix that are not part of
@@ -2285,9 +2273,9 @@ SparseMatrix<number>::add (const unsigned int  row,
       n_columns++;
     }
 
-  index_ptr = &global_indices[0];
-  value_ptr = &column_values[0];
-  
+  const unsigned int * index_ptr = &global_indices[0];
+  const number * value_ptr = &column_values[0];
+
                                    // Finally, go through the index list 
                                    // and add the elements one by one.
   for (unsigned int j=0; j<n_columns; ++j)

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.