From: kronbichler Date: Thu, 27 Nov 2008 10:10:10 +0000 (+0000) Subject: Slight update in SparseMatrix collective add/set functions. Add some more documentati... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03d27e4b62ef6895ac038298b7b55ab7483bdefa;p=dealii-svn.git Slight update in SparseMatrix collective add/set functions. Add some more documentation about the residual computation for the Bicgstab solver. git-svn-id: https://svn.dealii.org/trunk@17764 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/solver_bicgstab.h b/deal.II/lac/include/lac/solver_bicgstab.h index 440b34d92d..c9faae8363 100644 --- a/deal.II/lac/include/lac/solver_bicgstab.h +++ b/deal.II/lac/include/lac/solver_bicgstab.h @@ -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 { 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 /** * 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) : diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index f324138bc4..45c2471487 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -2106,9 +2106,6 @@ SparseMatrix::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::set (const unsigned int row, // efficient. for (unsigned int j=0; joperator()(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::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::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::add (const unsigned int row, // efficient. for (unsigned int j=0; joperator()(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::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