]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add an exception.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 21 Mar 2005 21:04:09 +0000 (21:04 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Mon, 21 Mar 2005 21:04:09 +0000 (21:04 +0000)
git-svn-id: https://svn.dealii.org/trunk@10194 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/numerics/vectors.h
deal.II/deal.II/source/numerics/vectors.all_dimensions.cc

index de4a7596f3571e95293ab651f71399dd565dfb82..79dc96b29a0e62178fee3320b57783660b9c1e34 100644 (file)
@@ -982,7 +982,11 @@ class VectorTools
                                      * Exception
                                      */
     DeclException0 (ExcNonInterpolatingFE);
-
+                                     /**
+                                      * Exception
+                                      */
+    DeclException0 (ExcNoComponentSelected);
+    
   private:
                                     /**
                                      * Null pointer used to 
index 2b24ccc2cae211cfb60b9a8acce3557104b9af19..bbaf1f1e1ae4a5efcd569925f12fe4b7dbef8df8 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -26,8 +26,9 @@ void
 VectorTools::subtract_mean_value(Vector<double>     &v,
                                 const std::vector<bool> &p_select)
 {
-  unsigned int n = v.size();
-  Assert(n == p_select.size(), ExcDimensionMismatch(n, p_select.size()));
+  const unsigned int n = v.size();
+  Assert(n == p_select.size(),
+         ExcDimensionMismatch(n, p_select.size()));
 
   double       s       = 0;
   unsigned int counter = 0;
@@ -37,8 +38,9 @@ VectorTools::subtract_mean_value(Vector<double>     &v,
       {
        s += v(i);
        ++counter;
-      };
-
+      }
+  Assert (counter > 0, ExcNoComponentSelected());
+  
   s /= counter;
   
   for (unsigned int i=0; i<n; ++i)

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.