From 84ec290cc1a01b91373222a4e803c581d4807c5c Mon Sep 17 00:00:00 2001 From: prill Date: Fri, 13 Jul 2007 12:35:37 +0000 Subject: [PATCH] Extended interface: new add_values parameter for PETScWrappers::VectorBase::set(...). git-svn-id: https://svn.dealii.org/trunk@14854 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/petsc_vector_base.h | 5 ++++- deal.II/lac/source/petsc_vector_base.cc | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/deal.II/lac/include/lac/petsc_vector_base.h b/deal.II/lac/include/lac/petsc_vector_base.h index a4252f02d3..79a69eada8 100644 --- a/deal.II/lac/include/lac/petsc_vector_base.h +++ b/deal.II/lac/include/lac/petsc_vector_base.h @@ -370,9 +370,12 @@ namespace PETScWrappers * are stated in the first argument, * the corresponding values in the * second. + * If the flag @p add_values is true, + * the values are added to the vector. */ void set (const std::vector &indices, - const std::vector &values); + const std::vector &values, + const bool add_values = false); /** * Return the scalar product of two diff --git a/deal.II/lac/source/petsc_vector_base.cc b/deal.II/lac/source/petsc_vector_base.cc index 612d6ce198..f9260ec675 100644 --- a/deal.II/lac/source/petsc_vector_base.cc +++ b/deal.II/lac/source/petsc_vector_base.cc @@ -216,7 +216,8 @@ namespace PETScWrappers void VectorBase::set (const std::vector &indices, - const std::vector &values) + const std::vector &values, + const bool add_values) { Assert (indices.size() == values.size(), ExcMessage ("Function called with arguments of different sizes")); @@ -248,11 +249,14 @@ namespace PETScWrappers const std::vector petsc_indices (indices.begin(), indices.end()); #endif - + + InsertMode mode = INSERT_VALUES; + if (add_values) + mode = ADD_VALUES; const int ierr = VecSetValues (vector, indices.size(), &petsc_indices[0], &values[0], - INSERT_VALUES); + mode); AssertThrow (ierr == 0, ExcPETScError(ierr)); } -- 2.39.5