* 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
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"));
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));
}