]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Skip a non-collective call unless necessary.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 11 Aug 2005 00:06:13 +0000 (00:06 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 11 Aug 2005 00:06:13 +0000 (00:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@11281 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/petsc_vector_base.cc

index fca25cd832888ff583d4e3266270a5f17fb0496d..252a96cbf1d1ebeb60226fa7668ff72da7cf33c3 100644 (file)
@@ -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<int> petsc_indices (indices.begin(),
-                                          indices.end());
+       const std::vector<int> petsc_indices (indices.begin(),
+                                             indices.end());
 #else
-    const std::vector<PetscInt> petsc_indices (indices.begin(),
-                                               indices.end());
+       const std::vector<PetscInt> 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;
   }

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.