From: prill Date: Fri, 13 Jul 2007 12:35:37 +0000 (+0000) Subject: Extended interface: new add_values parameter for PETScWrappers::VectorBase::set(... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84ec290cc1a01b91373222a4e803c581d4807c5c;p=dealii-svn.git Extended interface: new add_values parameter for PETScWrappers::VectorBase::set(...). git-svn-id: https://svn.dealii.org/trunk@14854 0785d39b-7218-0410-832d-ea1e28bc413d --- 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)); }