]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add an assertion.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 May 2004 15:54:46 +0000 (15:54 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 14 May 2004 15:54:46 +0000 (15:54 +0000)
git-svn-id: https://svn.dealii.org/trunk@9241 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/function.h
deal.II/base/source/function.cc

index 93c20a0c3d8bd2aefeb3157f8d603c9f25d61c30..bbddaaeb89b3759fe9703b0a6218ab1051bc65a6 100644 (file)
@@ -343,6 +343,13 @@ class Function : public FunctionTime,
                     << "number of components. However, here the left operand "
                     << "has " << arg1 << " components, and the right operand "
                     << arg2 << " components.");
+                                     /**
+                                      * Exception
+                                      */
+    DeclException1 (ExcInvalidNumberOfComponents,
+                    int,
+                    << "The number of components of a function object must "
+                    << "at least be one, but you gave " << arg1);
 };
 
 
index d5cccf91a493ff7cae3d8f86c33516a1a4dfa8d3..2c7dca438e56aa6dccad61e0f9b956a48e0fd1dc 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, 2004 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -28,7 +28,16 @@ Function<dim>::Function (const unsigned int n_components,
                 :
                FunctionTime(initial_time),
                n_components(n_components)
-{}
+{
+                                   // avoid the construction of function
+                                   // objects that don't return any
+                                   // values. This doesn't make much sense in
+                                   // the first place, but will lead to odd
+                                   // errors later on (happened to me in fact
+                                   // :-)
+  Assert (n_components > 0,
+          ExcInvalidNumberOfComponents(n_components));
+}
 
 
 template <int dim>

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.