From c7962ccfe3dcf8d375147d7c225043a98c741520 Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 11 Aug 2005 00:06:13 +0000 Subject: [PATCH] Skip a non-collective call unless necessary. git-svn-id: https://svn.dealii.org/trunk@11281 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/source/petsc_vector_base.cc | 28 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) 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; } -- 2.39.5