From b167ed2ef6ae44ec3d718721c61cac179f8d0c3c Mon Sep 17 00:00:00 2001 From: kronbichler Date: Thu, 23 Apr 2009 07:18:49 +0000 Subject: [PATCH] I had introduced some subtle errors in the SSOR preconditioner implementation. This should be fixed now. git-svn-id: https://svn.dealii.org/trunk@18695 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/sparse_matrix.templates.h | 28 +++++++++++-------- .../include/lac/sparse_matrix_ez.templates.h | 14 ++++++---- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index 3fe59f41ff..e5874f41e0 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -1198,12 +1198,13 @@ SparseMatrix::precondition_SSOR (Vector &dst, pos_right_of_diagonal[row]; Assert (first_right_of_diagonal_index <= *(rowstart_ptr+1), ExcInternalError()); - number s = *dst_ptr; + number s = 0; for (unsigned int j=(*rowstart_ptr)+1; jcolnums[j]); + s += val[j] * dst(cols->colnums[j]); // divide by diagonal element - *dst_ptr = s * om / val[*rowstart_ptr]; + *dst_ptr -= s * om; + *dst_ptr /= val[*rowstart_ptr]; }; rowstart_ptr = &cols->rowstart[0]; @@ -1219,11 +1220,12 @@ SparseMatrix::precondition_SSOR (Vector &dst, const unsigned int end_row = *(rowstart_ptr+1); const unsigned int first_right_of_diagonal_index = pos_right_of_diagonal[row]; - number s = *dst_ptr; + number s = 0; for (unsigned int j=first_right_of_diagonal_index; jcolnums[j]); + s += val[j] * dst(cols->colnums[j]); - *dst_ptr = s * om / val[*rowstart_ptr]; + *dst_ptr -= s * om; + *dst_ptr /= val[*rowstart_ptr]; }; return; } @@ -1249,12 +1251,13 @@ SparseMatrix::precondition_SSOR (Vector &dst, - &cols->colnums[0]); - number s = *dst_ptr; + number s = 0; for (unsigned int j=(*rowstart_ptr)+1; jcolnums[j]); + s += val[j] * dst(cols->colnums[j]); // divide by diagonal element - *dst_ptr = s * om / val[*rowstart_ptr]; + *dst_ptr -= s * om; + *dst_ptr /= val[*rowstart_ptr]; }; rowstart_ptr = &cols->rowstart[0]; @@ -1273,10 +1276,11 @@ SparseMatrix::precondition_SSOR (Vector &dst, &cols->colnums[end_row], static_cast(row)) - &cols->colnums[0]); - number s = *dst_ptr; + number s = 0; for (unsigned int j=first_right_of_diagonal_index; jcolnums[j]); - *dst_ptr = s * om / val[*rowstart_ptr]; + s += val[j] * dst(cols->colnums[j]); + *dst_ptr -= s * om; + *dst_ptr /= val[*rowstart_ptr]; }; } diff --git a/deal.II/lac/include/lac/sparse_matrix_ez.templates.h b/deal.II/lac/include/lac/sparse_matrix_ez.templates.h index 9ff6264c6a..64f553d672 100644 --- a/deal.II/lac/include/lac/sparse_matrix_ez.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix_ez.templates.h @@ -342,12 +342,13 @@ SparseMatrixEZ::precondition_SSOR (Vector &dst, for (ri = row_info.begin(); ri != end; ++dst_ptr, ++src_ptr, ++ri) { Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal()); - number s = *src_ptr; + number s = 0; const unsigned int end_row = ri->start + ri->diagonal; for (unsigned int i=ri->start;istart + ri->diagonal].value; + *dst_ptr = *src_ptr - s * om; + *dst_ptr /= data[ri->start + ri->diagonal].value; } // Diagonal dst_ptr = dst.begin(); @@ -362,11 +363,12 @@ SparseMatrixEZ::precondition_SSOR (Vector &dst, for (rri = row_info.rbegin(); rri != rend; --dst_ptr, ++rri) { const unsigned int end_row = rri->start + rri->length; - number s = *dst_ptr; + number s = 0; for (unsigned int i=rri->start+rri->diagonal+1;istart + rri->diagonal].value; + *dst_ptr -= s * om; + *dst_ptr /= data[rri->start + rri->diagonal].value; } } -- 2.39.5