From: wolf Date: Thu, 11 Aug 2005 00:06:13 +0000 (+0000) Subject: Skip a non-collective call unless necessary. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c7962ccfe3dcf8d375147d7c225043a98c741520;p=dealii-svn.git Skip a non-collective call unless necessary. git-svn-id: https://svn.dealii.org/trunk@11281 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/source/petsc_vector_base.cc b/deal.II/lac/source/petsc_vector_base.cc index fca25cd832..252a96cbf1 100644 --- a/deal.II/lac/source/petsc_vector_base.cc +++ b/deal.II/lac/source/petsc_vector_base.cc @@ -226,22 +226,30 @@ namespace PETScWrappers AssertThrow (ierr == 0, ExcPETScError(ierr)); } + // VecSetValues complains if we + // come with an empty + // vector. however, it is not a + // collective operation, so we + // can skip the call if necessary + // (unlike the above calls) + if (indices.size() != 0) + { #if (PETSC_VERSION_MAJOR <= 2) && \ ((PETSC_VERSION_MINOR < 2) || \ ((PETSC_VERSION_MINOR == 2) && (PETSC_VERSION_SUBMINOR == 0))) - const std::vector petsc_indices (indices.begin(), - indices.end()); + const std::vector petsc_indices (indices.begin(), + indices.end()); #else - const std::vector petsc_indices (indices.begin(), - indices.end()); + const std::vector petsc_indices (indices.begin(), + indices.end()); #endif - const int ierr - = VecSetValues (vector, indices.size(), - &petsc_indices[0], &values[0], - INSERT_VALUES); - AssertThrow (ierr == 0, ExcPETScError(ierr)); - + const int ierr + = VecSetValues (vector, indices.size(), + &petsc_indices[0], &values[0], + INSERT_VALUES); + AssertThrow (ierr == 0, ExcPETScError(ierr)); + } last_action = LastAction::insert; }