From 29d4a37cfe6b027fd19148458c0ec1392b96af13 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Tue, 26 Apr 2016 14:42:42 +0200 Subject: [PATCH] Use consistent exception name for FE_Q of degree 0. --- include/deal.II/fe/fe_q_base.h | 11 +++++++++++ source/fe/fe_q.cc | 20 +++++++------------- source/fe/fe_q_base.cc | 6 +++--- tests/fe/fe_q_01.output | 2 +- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/include/deal.II/fe/fe_q_base.h b/include/deal.II/fe/fe_q_base.h index 601189dea1..6d03628a27 100644 --- a/include/deal.II/fe/fe_q_base.h +++ b/include/deal.II/fe/fe_q_base.h @@ -267,6 +267,17 @@ public: compare_for_face_domination (const FiniteElement &fe_other) const; //@} + /** + * Attempt to construct an FE_Q object of degree 0 + * + * @ingroup Exceptions + */ + DeclExceptionMsg (ExcFEQCannotHaveDegree0, + "FE_Q can only be used for polynomial degrees " + "greater than zero. If you want an element of polynomial " + "degree zero, then it cannot be continuous and you " + "will want to use FE_DGQ(0)."); + protected: /** * Only for internal use. Its full name is @p get_dofs_per_object_vector diff --git a/source/fe/fe_q.cc b/source/fe/fe_q.cc index a4c969dee5..343d5f5839 100644 --- a/source/fe/fe_q.cc +++ b/source/fe/fe_q.cc @@ -25,17 +25,17 @@ DEAL_II_NAMESPACE_OPEN namespace { + template std::vector > get_QGaussLobatto_points (const unsigned int degree) { if (degree > 0) return QGaussLobatto<1>(degree+1).get_points(); else - AssertThrow(false, - ExcMessage ("FE_Q can only be used for polynomial degrees " - "greater than zero. If you want an element of polynomial " - "degree zero, then it cannot be continuous and you " - "will want to use FE_DGQ(0).")); + { + typedef FE_Q_Base, dim, spacedim> FEQ; + AssertThrow(false, typename FEQ::ExcFEQCannotHaveDegree0()); + } return std::vector >(); } } @@ -46,13 +46,13 @@ template FE_Q::FE_Q (const unsigned int degree) : FE_Q_Base, dim, spacedim> - (TensorProductPolynomials(Polynomials::generate_complete_Lagrange_basis(get_QGaussLobatto_points(degree))), + (TensorProductPolynomials(Polynomials::generate_complete_Lagrange_basis(get_QGaussLobatto_points(degree))), FiniteElementData(this->get_dpo_vector(degree), 1, degree, FiniteElementData::H1), std::vector (1, false)) { - this->initialize(get_QGaussLobatto_points(degree)); + this->initialize(get_QGaussLobatto_points(degree)); } @@ -67,12 +67,6 @@ FE_Q::FE_Q (const Quadrature<1> &points) FiniteElementData::H1), std::vector (1, false)) { - const unsigned int degree = points.size()-1; - (void)degree; - Assert (degree > 0, - ExcMessage ("This element can only be used for polynomial degrees " - "at least zero")); - this->initialize(points.get_points()); } diff --git a/source/fe/fe_q_base.cc b/source/fe/fe_q_base.cc index a521c6c5b8..dcb28803f2 100644 --- a/source/fe/fe_q_base.cc +++ b/source/fe/fe_q_base.cc @@ -1118,12 +1118,12 @@ face_to_cell_index (const unsigned int face_index, template std::vector -FE_Q_Base::get_dpo_vector(const unsigned int deg) +FE_Q_Base::get_dpo_vector(const unsigned int degree) { - AssertThrow(deg>0,ExcMessage("FE_Q needs to be of degree > 0.")); + AssertThrow(degree>0, ExcFEQCannotHaveDegree0()); std::vector dpo(dim+1, 1U); for (unsigned int i=1; i 0.") +DEAL::ExcFEQCannotHaveDegree0() -- 2.39.5