From: Wolfgang Bangerth Date: Mon, 21 Mar 2005 21:04:09 +0000 (+0000) Subject: Add an exception. X-Git-Tag: v8.0.0~14343 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=091abc17862b39beae0cf2e73a2547612a2c3d0d;p=dealii.git Add an exception. git-svn-id: https://svn.dealii.org/trunk@10194 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index de4a7596f3..79dc96b29a 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -982,7 +982,11 @@ class VectorTools * Exception */ DeclException0 (ExcNonInterpolatingFE); - + /** + * Exception + */ + DeclException0 (ExcNoComponentSelected); + private: /** * Null pointer used to diff --git a/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc b/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc index 2b24ccc2ca..bbaf1f1e1a 100644 --- a/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc +++ b/deal.II/deal.II/source/numerics/vectors.all_dimensions.cc @@ -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 &v, const std::vector &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 &v, { s += v(i); ++counter; - }; - + } + Assert (counter > 0, ExcNoComponentSelected()); + s /= counter; for (unsigned int i=0; i