From: wolf Date: Wed, 10 Aug 2005 21:49:09 +0000 (+0000) Subject: Allow a second argument for clear_row and clear_rows X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a80b80bac754ce7ea9cdaf6d19a4c34110e25e79;p=dealii-svn.git Allow a second argument for clear_row and clear_rows git-svn-id: https://svn.dealii.org/trunk@11275 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/petsc_matrix_base.h b/deal.II/lac/include/lac/petsc_matrix_base.h index 5731f48d98..c2ba92bff4 100644 --- a/deal.II/lac/include/lac/petsc_matrix_base.h +++ b/deal.II/lac/include/lac/petsc_matrix_base.h @@ -383,14 +383,30 @@ namespace PETScWrappers * without this operation, removing * constraints on parallel matrices is * a rather complicated procedure. + * + * The second parameter can be used to + * set the diagonal entry of this row + * to a value different from zero. The + * default is to set it to zero. */ - void clear_row (const unsigned int row); + void clear_row (const unsigned int row, + const PetscScalar new_diag_value = 0); /** * Same as clear_row(), except that it * works on a number of rows at once. + * + * The second parameter can be used to + * set the diagonal entries of all + * cleared rows to something different + * from zero. Note that all of these + * diagonal entries get the same value + * -- if you want different values for + * the diagonal entries, you have to + * set them by hand. */ - void clear_rows (const std::vector &rows); + void clear_rows (const std::vector &rows, + const PetscScalar new_diag_value = 0); /** * PETSc matrices store their own diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index 5d9d449eca..e7774dc451 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -198,7 +198,8 @@ namespace PETScWrappers void - MatrixBase::clear_row (const unsigned int row) + MatrixBase::clear_row (const unsigned int row, + const PetscScalar new_diag_value) { compress (); @@ -215,12 +216,11 @@ namespace PETScWrappers ISCreateGeneral (get_mpi_communicator(), 1, &petsc_row, &index_set); #if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR <= 2) - static const PetscScalar zero = 0; const int ierr - = MatZeroRows(matrix, index_set, &zero); + = MatZeroRows(matrix, index_set, &new_diag_value); #else const int ierr - = MatZeroRowsIS(matrix, index_set, 0); + = MatZeroRowsIS(matrix, index_set, new_diag_value); #endif AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -231,7 +231,8 @@ namespace PETScWrappers void - MatrixBase::clear_rows (const std::vector &rows) + MatrixBase::clear_rows (const std::vector &rows, + const PetscScalar new_diag_value) { compress (); @@ -253,12 +254,11 @@ namespace PETScWrappers &petsc_rows[0], &index_set); #if (PETSC_VERSION_MAJOR <= 2) && (PETSC_VERSION_MINOR <= 2) - static const PetscScalar zero = 0; const int ierr - = MatZeroRows(matrix, index_set, &zero); + = MatZeroRows(matrix, index_set, &new_diag_value); #else const int ierr - = MatZeroRowsIS(matrix, index_set, 0.); + = MatZeroRowsIS(matrix, index_set, new_diag_value); #endif AssertThrow (ierr == 0, ExcPETScError(ierr));