From: Daniel Arndt Date: Wed, 19 Jul 2017 11:15:01 +0000 (+0200) Subject: Use appropriate constructor for QGaussChebyshev* X-Git-Tag: v9.0.0-rc1~1406^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4629%2Fhead;p=dealii.git Use appropriate constructor for QGaussChebyshev* --- diff --git a/include/deal.II/base/quadrature.h b/include/deal.II/base/quadrature.h index f1869b6c12..e0f2e67c8f 100644 --- a/include/deal.II/base/quadrature.h +++ b/include/deal.II/base/quadrature.h @@ -100,6 +100,8 @@ public: /** * Build this quadrature formula as the tensor product of a formula in a * dimension one less than the present and a formula in one dimension. + * This constructor assumes (and tests) that constant functions are integrated + * exactly, i.e. the sum of the quadrature weights is one. * * SubQuadrature::type expands to Quadrature. */ @@ -117,6 +119,10 @@ public: * In order to avoid a conflict with the copy constructor in 1d, we let the * argument be a 0d quadrature formula for dim==1, and a 1d quadrature * formula for all other space dimensions. + * + * This constructor does not require that constant functions are integrated + * exactly. Therefore, it is appropriate if the one-dimensional formula + * is defined with respect to a weighting function. */ explicit Quadrature (const Quadrature &quadrature_1d); diff --git a/source/base/quadrature_lib.cc b/source/base/quadrature_lib.cc index de6dfef917..6e7d9d1960 100644 --- a/source/base/quadrature_lib.cc +++ b/source/base/quadrature_lib.cc @@ -1181,7 +1181,7 @@ QGaussChebyshev<1>::QGaussChebyshev(const unsigned int n) template QGaussChebyshev::QGaussChebyshev (const unsigned int n) : - Quadrature (QGaussChebyshev(n), QGaussChebyshev<1>(n)) + Quadrature (QGaussChebyshev<1>(n)) {} @@ -1249,7 +1249,7 @@ QGaussRadauChebyshev<1>::get_quadrature_weights(const unsigned int n, template <> QGaussRadauChebyshev<1>::QGaussRadauChebyshev(const unsigned int n, - QGaussRadauChebyshev<1>::EndPoint ep) + EndPoint ep) : Quadrature<1> (n), ep (ep) @@ -1267,22 +1267,11 @@ QGaussRadauChebyshev<1>::QGaussRadauChebyshev(const unsigned int n, } -template <> -QGaussRadauChebyshev<2>::QGaussRadauChebyshev (const unsigned int n, - EndPoint ep) - : - Quadrature<2> (QGaussRadauChebyshev<1>(n, static_cast::EndPoint>(ep)), - QGaussRadauChebyshev<1>(n, static_cast::EndPoint>(ep))), - ep (ep) -{} - - template QGaussRadauChebyshev::QGaussRadauChebyshev (const unsigned int n, EndPoint ep) : - Quadrature (QGaussRadauChebyshev(n,static_cast::EndPoint>(ep)), - QGaussRadauChebyshev<1>(n,static_cast::EndPoint>(ep))), + Quadrature (QGaussRadauChebyshev<1>(n,static_cast::EndPoint>(ep))), ep (ep) {} @@ -1346,7 +1335,7 @@ QGaussLobattoChebyshev<1>::QGaussLobattoChebyshev(const unsigned int n) template QGaussLobattoChebyshev::QGaussLobattoChebyshev (const unsigned int n) : - Quadrature (QGaussLobattoChebyshev(n), QGaussLobattoChebyshev<1>(n)) + Quadrature (QGaussLobattoChebyshev<1>(n)) {} // explicit specialization diff --git a/tests/base/quadrature_construct_chebyshev.cc b/tests/base/quadrature_construct_chebyshev.cc new file mode 100644 index 0000000000..1cb5e4411a --- /dev/null +++ b/tests/base/quadrature_construct_chebyshev.cc @@ -0,0 +1,50 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// check that the QGaussChebyshev, QGaussRadauChebyshev and QGaussLobattoChebyshev, +// can be constructed in all dimensions. Previously, this failed since the base class +// constructor used required the one-dimensional quadrature formula to integrate +// constants exactly. This is not true for the classes considered here. + + +#include "../tests.h" + +#include +#include +#include + +template +void +construct_quadrature() +{ + QGaussChebyshev q_1(2); + deallog << "QGaussChebyshev<" << dim << ">: OK" << std::endl; + QGaussRadauChebyshev q_2(2); + deallog << "QGaussRadauChebyshev<" << dim << ">: OK" << std::endl; + QGaussLobattoChebyshev q_3(2); + deallog << "QGaussLobattoChebyshev<" << dim << ">: OK" << std::endl; +} + +int main() +{ + initlog(); + + construct_quadrature<1>(); + construct_quadrature<2>(); + construct_quadrature<3>(); +} + diff --git a/tests/base/quadrature_construct_chebyshev.output b/tests/base/quadrature_construct_chebyshev.output new file mode 100644 index 0000000000..25b1f70988 --- /dev/null +++ b/tests/base/quadrature_construct_chebyshev.output @@ -0,0 +1,10 @@ + +DEAL::QGaussChebyshev<1>: OK +DEAL::QGaussRadauChebyshev<1>: OK +DEAL::QGaussLobattoChebyshev<1>: OK +DEAL::QGaussChebyshev<2>: OK +DEAL::QGaussRadauChebyshev<2>: OK +DEAL::QGaussLobattoChebyshev<2>: OK +DEAL::QGaussChebyshev<3>: OK +DEAL::QGaussRadauChebyshev<3>: OK +DEAL::QGaussLobattoChebyshev<3>: OK