From 5461b8591e66b94a20ac4c539b4953fbe73c84d1 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 7 Aug 2000 13:07:25 +0000 Subject: [PATCH] Add an exception to catch the case that someone wants to use no iterations at all for an iterated quadrature formula. git-svn-id: https://svn.dealii.org/trunk@3228 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/quadrature.h | 7 +++ deal.II/base/source/quadrature.cc | 79 +++++++++++++++++++------- 2 files changed, 66 insertions(+), 20 deletions(-) diff --git a/deal.II/base/include/base/quadrature.h b/deal.II/base/include/base/quadrature.h index d0d74bbfcc..ddfd70c2a2 100644 --- a/deal.II/base/include/base/quadrature.h +++ b/deal.II/base/include/base/quadrature.h @@ -186,6 +186,13 @@ class QIterated : public Quadrature * Exception */ DeclException0 (ExcInvalidQuadratureFormula); + /** + * Exception + */ + DeclException1 (ExcInvalidNumberOfCopies, + int, + << "The numbers of copies (" << arg1 + << ") of the quadrature formula is not valid."); private: /** diff --git a/deal.II/base/source/quadrature.cc b/deal.II/base/source/quadrature.cc index 54ba4c2ab7..e95a9adedf 100644 --- a/deal.II/base/source/quadrature.cc +++ b/deal.II/base/source/quadrature.cc @@ -22,6 +22,7 @@ Quadrature<0>::Quadrature (const unsigned int) {}; + template Quadrature::Quadrature (const unsigned int n_q) : n_quadrature_points(n_q), @@ -29,6 +30,8 @@ Quadrature::Quadrature (const unsigned int n_q) : weights (n_q, 0) {} + + template Quadrature::Quadrature (const vector > & points, const vector & weights) @@ -40,6 +43,8 @@ Quadrature::Quadrature (const vector > & points, ExcDimensionMismatch(weights.size(), points.size())); } + + template <> Quadrature<0>::Quadrature (const Quadrature<-1> &, const Quadrature<1> &) @@ -48,13 +53,16 @@ Quadrature<0>::Quadrature (const Quadrature<-1> &, }; + template <> Quadrature<1>::Quadrature (const Quadrature<0> &, - const Quadrature<1> &) { + const Quadrature<1> &) +{ Assert (false, ExcInternalError()); }; + template Quadrature::Quadrature (const Quadrature &q1, const Quadrature<1> &q2) : @@ -93,58 +101,75 @@ Quadrature::Quadrature (const Quadrature &q1, }; + template -Quadrature::~Quadrature () {}; +Quadrature::~Quadrature () +{}; + template <> -const Point<0> & Quadrature<0>::point (const unsigned int) const { +const Point<0> & Quadrature<0>::point (const unsigned int) const +{ Assert (false, ExcInternalError()); static const Point<0> dummy; return dummy; }; + template -const Point & Quadrature::point (const unsigned int i) const { +const Point & Quadrature::point (const unsigned int i) const +{ Assert (i -const vector > & Quadrature<0>::get_points () const { +const vector > & Quadrature<0>::get_points () const +{ Assert (false, ExcInternalError()); return quadrature_points; }; + template -const vector > & Quadrature::get_points () const { +const vector > & Quadrature::get_points () const +{ return quadrature_points; }; + template <> -double Quadrature<0>::weight (const unsigned int) const { +double Quadrature<0>::weight (const unsigned int) const +{ Assert (false, ExcInternalError()); return 0; }; + template -double Quadrature::weight (const unsigned int i) const { +double Quadrature::weight (const unsigned int i) const +{ Assert (i -const vector & Quadrature::get_weights () const { +const vector & Quadrature::get_weights () const +{ return weights; }; + template <> const vector & Quadrature<0>::get_weights () const { @@ -153,6 +178,7 @@ const vector & Quadrature<0>::get_weights () const }; + template <> void QProjector<2>::project_to_face (const Quadrature<1> &quadrature, const unsigned int face_no, @@ -182,10 +208,12 @@ void QProjector<2>::project_to_face (const Quadrature<1> &quadrature, }; + template <> void QProjector<3>::project_to_face (const Quadrature<2> &quadrature, const unsigned int face_no, - vector > &q_points) { + vector > &q_points) +{ const unsigned int dim=3; Assert (face_no<2*dim, ExcIndexRange (face_no, 0, 2*dim)); @@ -229,11 +257,13 @@ void QProjector<3>::project_to_face (const Quadrature<2> &quadrature, }; + template <> void QProjector<2>::project_to_subface (const Quadrature<1> &quadrature, const unsigned int face_no, const unsigned int subface_no, - vector > &q_points) { + vector > &q_points) +{ const unsigned int dim=2; Assert (face_no<2*dim, ExcIndexRange (face_no, 0, 2*dim)); Assert (subface_no<(1<<(dim-1)), ExcIndexRange (face_no, 0, 1<<(dim-1))); @@ -301,17 +331,19 @@ void QProjector<2>::project_to_subface (const Quadrature<1> &quadrature, }; + template <> void QProjector<3>::project_to_subface (const Quadrature<2> &quadrature, const unsigned int face_no, const unsigned int subface_no, - vector > &q_points) { + vector > &q_points) +{ const unsigned int dim=3; Assert (face_no<2*dim, ExcIndexRange (face_no, 0, 2*dim)); Assert (subface_no<(1<<(dim-1)), ExcIndexRange (face_no, 0, 1<<(dim-1))); -// for all faces and subfaces: first project + // for all faces and subfaces: first project // onto the first subface of each face, then // move it to the right place for (unsigned int p=0; p::project_to_subface (const Quadrature<2> &quadrature, }; + template void QProjector::project_to_faces (const Quadrature &quadrature, @@ -478,10 +511,11 @@ QProjector::project_to_faces (const Quadrature &quadrature, + template void QProjector::project_to_subfaces (const Quadrature &quadrature, - vector > &q_points) + vector > &q_points) { unsigned int npt = quadrature.n_quadrature_points; unsigned int nf = GeometryInfo::faces_per_cell; @@ -502,7 +536,7 @@ QProjector::project_to_subfaces (const Quadrature &quadrature, -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%// +// ------------------------------------------------------------ // template <> @@ -523,6 +557,7 @@ QIterated<1>::uses_both_endpoints (const Quadrature<1> &base_quadrature) }; + template <> QIterated<1>::QIterated (const Quadrature<1> &base_quadrature, const unsigned int n_copies) : @@ -530,10 +565,12 @@ QIterated<1>::QIterated (const Quadrature<1> &base_quadrature, (base_quadrature.n_quadrature_points-1) * n_copies + 1 : base_quadrature.n_quadrature_points * n_copies) { - // we don't have to skip some points - // in order to get a reasonable quadrature - // formula + Assert (n_copies >= 1, ExcInvalidNumberOfCopies(n_copies)); + if (!uses_both_endpoints(base_quadrature)) + // we don't have to skip some + // points in order to get a + // reasonable quadrature formula { unsigned int next_point = 0; for (unsigned int copy=0; copy::QIterated (const Quadrature<1> &base_quadrature, Assert (n_end_points == 2, ExcInvalidQuadratureFormula()); -for (unsigned int copy=0; copy QIterated::QIterated (const Quadrature<1> &base_quadrature, - const unsigned int N): + const unsigned int N) : Quadrature (QIterated(base_quadrature, N), QIterated<1>(base_quadrature, N)) {}; + // explicit instantiations; note: we need them all for all dimensions template class Quadrature<1>; template class Quadrature<2>; -- 2.39.5