From: kanschat Date: Wed, 20 Jun 2007 17:08:50 +0000 (+0000) Subject: unify exceptions and add groups to VectorTools functions X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24dabb8054ed401f9c6a99e7769e0548ba4d185e;p=dealii-svn.git unify exceptions and add groups to VectorTools functions git-svn-id: https://svn.dealii.org/trunk@14793 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe_tools.h b/deal.II/deal.II/include/fe/fe_tools.h index 5021bf6424..88ee831232 100644 --- a/deal.II/deal.II/include/fe/fe_tools.h +++ b/deal.II/deal.II/include/fe/fe_tools.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -1182,7 +1182,7 @@ class FETools * * @ingroup Exceptions */ - DeclException0 (ExcFEMustBePrimitive); + DeclException0 (ExcFENotPrimitive); /** * Exception * diff --git a/deal.II/deal.II/include/numerics/vectors.h b/deal.II/deal.II/include/numerics/vectors.h index 148f197f9f..9f07bf08cb 100644 --- a/deal.II/deal.II/include/numerics/vectors.h +++ b/deal.II/deal.II/include/numerics/vectors.h @@ -394,7 +394,10 @@ class VectorTools W1infty_norm }; - +/** + * @name Interpolation and projection + */ + //@{ /** * Compute the interpolation of * @p function at the support @@ -523,7 +526,7 @@ class VectorTools const bool project_to_boundary_first = false); /** - * Calls the @p project + * Calls the project() * function, see above, with * mapping=MappingQ1@(). */ @@ -539,191 +542,6 @@ class VectorTools Quadrature(0)), const bool project_to_boundary_first = false); - /** - * Create a right hand side - * vector. Prior content of the - * given @p rhs_vector vector is - * deleted. - * - * See the general documentation of this - * class for further information. - */ - template - static void create_right_hand_side (const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - const Function &rhs, - Vector &rhs_vector); - - /** - * Calls the @p create_right_hand_side - * function, see above, with - * mapping=MappingQ1@(). - */ - template - static void create_right_hand_side (const DoFHandler &dof, - const Quadrature &q, - const Function &rhs, - Vector &rhs_vector); - - /** - * Like the previous set of functions, - * but for hp objects. - */ - template - static void create_right_hand_side (const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - const Function &rhs, - Vector &rhs_vector); - - /** - * Like the previous set of functions, - * but for hp objects. - */ - template - static void create_right_hand_side (const hp::DoFHandler &dof, - const hp::QCollection &q, - const Function &rhs, - Vector &rhs_vector); - - /** - * Create a right hand side - * vector for a point source at point @p p. - * Prior content of the - * given @p rhs_vector vector is - * deleted. - * - * See the general documentation of this - * class for further information. - */ - template - static void create_point_source_vector(const Mapping &mapping, - const DoFHandler &dof, - const Point &p, - Vector &rhs_vector); - - /** - * Calls the @p create_point_source_vector - * function, see above, with - * mapping=MappingQ1@(). - */ - template - static void create_point_source_vector(const DoFHandler &dof, - const Point &p, - Vector &rhs_vector); - - /** - * Like the previous set of functions, - * but for hp objects. - */ - template - static void create_point_source_vector(const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const Point &p, - Vector &rhs_vector); - - /** - * Like the previous set of functions, - * but for hp objects. The function uses - * the default Q1 mapping object. Note - * that if your hp::DoFHandler uses any - * active fe index other than zero, then - * you need to call the function above - * that provides a mapping object for - * each active fe index. - */ - template - static void create_point_source_vector(const hp::DoFHandler &dof, - const Point &p, - Vector &rhs_vector); - - /** - * Create a right hand side - * vector from boundary - * forces. Prior content of the - * given @p rhs_vector vector is - * deleted. - * - * See the general documentation of this - * class for further information. - */ - template - static void create_boundary_right_hand_side (const Mapping &mapping, - const DoFHandler &dof, - const Quadrature &q, - const Function &rhs, - Vector &rhs_vector, - const std::set &boundary_indicators = std::set()); - - /** - * Specialization of above - * function for 1d. Since the - * computation is not useful in - * 1d, this function simply - * throws an exception. - */ - static void create_boundary_right_hand_side (const Mapping<1> &mapping, - const DoFHandler<1> &dof, - const Quadrature<0> &q, - const Function<1> &rhs, - Vector &rhs_vector, - const std::set &boundary_indicators = std::set()); - - /** - * Calls the - * @p create_boundary_right_hand_side - * function, see above, with - * mapping=MappingQ1@(). - */ - template - static void create_boundary_right_hand_side (const DoFHandler &dof, - const Quadrature &q, - const Function &rhs, - Vector &rhs_vector, - const std::set &boundary_indicators = std::set()); - - /** - * Same as the set of functions above, - * but for hp objects. - */ - template - static void create_boundary_right_hand_side (const hp::MappingCollection &mapping, - const hp::DoFHandler &dof, - const hp::QCollection &q, - const Function &rhs, - Vector &rhs_vector, - const std::set &boundary_indicators = std::set()); - - /** - * Specialization of above - * function for 1d. Since the - * computation is not useful in - * 1d, this function simply - * throws an exception. - */ - static void create_boundary_right_hand_side (const hp::MappingCollection<1> &mapping, - const hp::DoFHandler<1> &dof, - const hp::QCollection<0> &q, - const Function<1> &rhs, - Vector &rhs_vector, - const std::set &boundary_indicators = std::set()); - - /** - * Calls the @p - * create_boundary_right_hand_side - * function, see above, with a single Q1 - * mapping as collection. This function - * therefore will only work if the only - * active fe index in use is zero. - */ - template - static void create_boundary_right_hand_side (const hp::DoFHandler &dof, - const hp::QCollection &q, - const Function &rhs, - Vector &rhs_vector, - const std::set &boundary_indicators = std::set()); - /** * Prepare Dirichlet boundary * conditions. Make up the list @@ -947,6 +765,204 @@ class VectorTools const Quadrature &q, std::map &boundary_values); + //@} + /** + * @name Assembling of right hand sides + */ + //@{ + + /** + * Create a right hand side + * vector. Prior content of the + * given @p rhs_vector vector is + * deleted. + * + * See the general documentation of this + * class for further information. + */ + template + static void create_right_hand_side (const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + const Function &rhs, + Vector &rhs_vector); + + /** + * Calls the @p create_right_hand_side + * function, see above, with + * mapping=MappingQ1@(). + */ + template + static void create_right_hand_side (const DoFHandler &dof, + const Quadrature &q, + const Function &rhs, + Vector &rhs_vector); + + /** + * Like the previous set of functions, + * but for hp objects. + */ + template + static void create_right_hand_side (const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + const Function &rhs, + Vector &rhs_vector); + + /** + * Like the previous set of functions, + * but for hp objects. + */ + template + static void create_right_hand_side (const hp::DoFHandler &dof, + const hp::QCollection &q, + const Function &rhs, + Vector &rhs_vector); + + /** + * Create a right hand side + * vector for a point source at point @p p. + * Prior content of the + * given @p rhs_vector vector is + * deleted. + * + * See the general documentation of this + * class for further information. + */ + template + static void create_point_source_vector(const Mapping &mapping, + const DoFHandler &dof, + const Point &p, + Vector &rhs_vector); + + /** + * Calls the @p create_point_source_vector + * function, see above, with + * mapping=MappingQ1@(). + */ + template + static void create_point_source_vector(const DoFHandler &dof, + const Point &p, + Vector &rhs_vector); + + /** + * Like the previous set of functions, + * but for hp objects. + */ + template + static void create_point_source_vector(const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const Point &p, + Vector &rhs_vector); + + /** + * Like the previous set of functions, + * but for hp objects. The function uses + * the default Q1 mapping object. Note + * that if your hp::DoFHandler uses any + * active fe index other than zero, then + * you need to call the function above + * that provides a mapping object for + * each active fe index. + */ + template + static void create_point_source_vector(const hp::DoFHandler &dof, + const Point &p, + Vector &rhs_vector); + + /** + * Create a right hand side + * vector from boundary + * forces. Prior content of the + * given @p rhs_vector vector is + * deleted. + * + * See the general documentation of this + * class for further information. + */ + template + static void create_boundary_right_hand_side (const Mapping &mapping, + const DoFHandler &dof, + const Quadrature &q, + const Function &rhs, + Vector &rhs_vector, + const std::set &boundary_indicators = std::set()); + + /** + * Specialization of above + * function for 1d. Since the + * computation is not useful in + * 1d, this function simply + * throws an exception. + */ + static void create_boundary_right_hand_side (const Mapping<1> &mapping, + const DoFHandler<1> &dof, + const Quadrature<0> &q, + const Function<1> &rhs, + Vector &rhs_vector, + const std::set &boundary_indicators = std::set()); + + /** + * Calls the + * @p create_boundary_right_hand_side + * function, see above, with + * mapping=MappingQ1@(). + */ + template + static void create_boundary_right_hand_side (const DoFHandler &dof, + const Quadrature &q, + const Function &rhs, + Vector &rhs_vector, + const std::set &boundary_indicators = std::set()); + + /** + * Same as the set of functions above, + * but for hp objects. + */ + template + static void create_boundary_right_hand_side (const hp::MappingCollection &mapping, + const hp::DoFHandler &dof, + const hp::QCollection &q, + const Function &rhs, + Vector &rhs_vector, + const std::set &boundary_indicators = std::set()); + + /** + * Specialization of above + * function for 1d. Since the + * computation is not useful in + * 1d, this function simply + * throws an exception. + */ + static void create_boundary_right_hand_side (const hp::MappingCollection<1> &mapping, + const hp::DoFHandler<1> &dof, + const hp::QCollection<0> &q, + const Function<1> &rhs, + Vector &rhs_vector, + const std::set &boundary_indicators = std::set()); + + /** + * Calls the @p + * create_boundary_right_hand_side + * function, see above, with a single Q1 + * mapping as collection. This function + * therefore will only work if the only + * active fe index in use is zero. + */ + template + static void create_boundary_right_hand_side (const hp::DoFHandler &dof, + const hp::QCollection &q, + const Function &rhs, + Vector &rhs_vector, + const std::set &boundary_indicators = std::set()); + + //@} + /** + * @name Evaluation of functions + * and errors + */ + //@{ + /** * Compute the error of the * finite element solution. @@ -1200,7 +1216,13 @@ class VectorTools const DoFHandler &dof, const InVector &fe_function, const Point &point); - + + //@} + /** + * Mean value operations + */ + //@{ + /** * Subtract the (algebraic) mean value * from a vector. This function is most @@ -1280,15 +1302,8 @@ class VectorTools const Quadrature &quadrature, const InVector &v, const unsigned int component); + //@} - /** - * Exception - */ - DeclException0 (ExcInvalidFE); - /** - * Exception - */ - DeclException0 (ExcFENotPrimitive); /** * Exception */ @@ -1296,10 +1311,6 @@ class VectorTools /** * Exception */ - DeclException0 (ExcComponentMismatch); - /** - * Exception - */ DeclException0 (ExcNonInterpolatingFE); /** * Exception diff --git a/deal.II/deal.II/include/numerics/vectors.templates.h b/deal.II/deal.II/include/numerics/vectors.templates.h index 84661e3da3..13e5071a7e 100644 --- a/deal.II/deal.II/include/numerics/vectors.templates.h +++ b/deal.II/deal.II/include/numerics/vectors.templates.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,8 @@ void VectorTools::interpolate (const Mapping &mapping, VECTOR &vec) { Assert (dof.get_fe().n_components() == function.n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(dof.get_fe().n_components(), + function.n_components)); const hp::FECollection fe (dof.get_fe()); const unsigned int n_components = fe.n_components(); @@ -395,7 +397,8 @@ void VectorTools::project (const Mapping &mapping, const bool project_to_boundary_first) { Assert (dof.get_fe().n_components() == function.n_components, - ExcInvalidFE()); + ExcDimensionMismatch(dof.get_fe().n_components(), + function.n_components)); Assert (vec_result.size() == dof.n_dofs(), ExcDimensionMismatch (vec_result.size(), dof.n_dofs())); @@ -507,7 +510,7 @@ void VectorTools::create_right_hand_side (const Mapping &mapping, { const FiniteElement &fe = dof_handler.get_fe(); Assert (fe.n_components() == rhs_function.n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); Assert (rhs_vector.size() == dof_handler.n_dofs(), ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); rhs_vector = 0; @@ -632,7 +635,7 @@ void VectorTools::create_right_hand_side (const hp::MappingCollection &m { const hp::FECollection &fe = dof_handler.get_fe(); Assert (fe.n_components() == rhs_function.n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); Assert (rhs_vector.size() == dof_handler.n_dofs(), ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); rhs_vector = 0; @@ -867,7 +870,7 @@ VectorTools::create_boundary_right_hand_side (const Mapping &mapping, { const FiniteElement &fe = dof_handler.get_fe(); Assert (fe.n_components() == rhs_function.n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); Assert (rhs_vector.size() == dof_handler.n_dofs(), ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); @@ -1021,7 +1024,7 @@ VectorTools::create_boundary_right_hand_side (const hp::MappingCollection { const hp::FECollection &fe = dof_handler.get_fe(); Assert (fe.n_components() == rhs_function.n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); Assert (rhs_vector.size() == dof_handler.n_dofs(), ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); @@ -1215,7 +1218,7 @@ VectorTools::interpolate_boundary_values (const Mapping<1> &, // cell const FiniteElement<1> &fe = outermost_cell->get_fe(); Assert (fe.n_components() == boundary_function.n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(fe.n_components(), boundary_function.n_components)); // set the component mask to either // the original value or a vector @@ -1224,7 +1227,7 @@ VectorTools::interpolate_boundary_values (const Mapping<1> &, std::vector (fe.n_components(), true) : component_mask_); Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, - ExcComponentMismatch()); + ExcNoComponentSelected()); // now set the value of the // outermost degree of @@ -1311,7 +1314,7 @@ interpolate_boundary_values (const Mapping &mapping, for (typename FunctionMap::type::const_iterator i=function_map.begin(); i!=function_map.end(); ++i) Assert (n_components == i->second->n_components, - ExcInvalidFE()); + ExcDimensionMismatch(n_components, i->second->n_components)); // set the component mask to either // the original value or a vector @@ -1320,7 +1323,7 @@ interpolate_boundary_values (const Mapping &mapping, std::vector (n_components, true) : component_mask_); Assert (std::count(component_mask.begin(), component_mask.end(), true) > 0, - ExcComponentMismatch()); + ExcNoComponentSelected()); // field to store the indices std::vector face_dofs; @@ -1537,7 +1540,7 @@ interpolate_boundary_values (const Mapping &mapping, for (unsigned int c=0; c &mapping, // acceptable for higher dimensions. Fix this. Assert (dof.get_fe().n_components() == boundary_functions.begin()->second->n_components, - ExcComponentMismatch()); + ExcDimensionMismatch(dof.get_fe().n_components(), + boundary_functions.begin()->second->n_components)); std::vector dof_to_boundary_mapping; std::set selected_boundary_components; diff --git a/deal.II/deal.II/source/fe/fe_tools.cc b/deal.II/deal.II/source/fe/fe_tools.cc index 3b17e2ae8a..ed50d20c07 100644 --- a/deal.II/deal.II/source/fe/fe_tools.cc +++ b/deal.II/deal.II/source/fe/fe_tools.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -375,8 +375,8 @@ void FETools::get_interpolation_matrix (const FiniteElement &fe1, // way. note that this will only // work if the element is // primitive, so check this first - Assert (fe1.is_primitive() == true, ExcFEMustBePrimitive()); - Assert (fe2.is_primitive() == true, ExcFEMustBePrimitive()); + Assert (fe1.is_primitive() == true, ExcFENotPrimitive()); + Assert (fe2.is_primitive() == true, ExcFENotPrimitive()); // Initialize FEValues for fe1 at // the unit support points of the