]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Extended interface: new add_values parameter for PETScWrappers::VectorBase::set(...
authorprill <prill@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 13 Jul 2007 12:35:37 +0000 (12:35 +0000)
committerprill <prill@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 13 Jul 2007 12:35:37 +0000 (12:35 +0000)
git-svn-id: https://svn.dealii.org/trunk@14854 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/petsc_vector_base.h
deal.II/lac/source/petsc_vector_base.cc

index a4252f02d3d9ef8afe1df1d3d1c1abcc5104a586..79a69eada85f12fb4f39cfe41196f155258fac7d 100644 (file)
@@ -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<unsigned int> &indices,
-                const std::vector<PetscScalar>  &values);
+                const std::vector<PetscScalar>  &values,
+               const bool add_values = false);
       
                                        /**
                                         * Return the scalar product of two
index 612d6ce19842f4a4d706843dd0f414a481e60550..f9260ec675eeb18d68a8f93bbf2aac871359d054 100644 (file)
@@ -216,7 +216,8 @@ namespace PETScWrappers
 
   void
   VectorBase::set (const std::vector<unsigned int> &indices,
-                   const std::vector<PetscScalar>  &values)
+                   const std::vector<PetscScalar>  &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<PetscInt> 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));
       }
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.