From: Guido Kanschat Date: Mon, 29 Jan 2001 06:57:01 +0000 (+0000) Subject: Legendre polynomials and declaration of new QGauss X-Git-Tag: v8.0.0~19771 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b21ab6a4ce56a25fd572b7e9ba41f88ee26a9c64;p=dealii.git Legendre polynomials and declaration of new QGauss git-svn-id: https://svn.dealii.org/trunk@3814 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/polynomial.h b/deal.II/base/include/base/polynomial.h index c0505d035d..20c4bf8298 100644 --- a/deal.II/base/include/base/polynomial.h +++ b/deal.II/base/include/base/polynomial.h @@ -162,7 +162,7 @@ class LagrangeEquidistant: public Polynomial /** - * Legendre polynomials of arbitrary order + * Legendre polynomials of arbitrary order on @p{[-1,1]}. * * Constructing a Legendre polynomial of order @p{k}, the coefficients * will be computed by the three-term recursion formula. The @@ -185,12 +185,12 @@ private: * Vector with already computed * coefficients. */ - static std::vector > coefficients + static std::vector > coefficients; /** * Compute coefficients recursively. */ - static void compute_coeficients (unsigned int k); + static void compute_coefficients (unsigned int k); /** * Get coefficients for @@ -199,7 +199,7 @@ private: * of @ref{Polynomial}. */ static const std::vector& get_coefficients (unsigned int k); -} +}; #endif diff --git a/deal.II/base/include/base/quadrature_lib.h b/deal.II/base/include/base/quadrature_lib.h index affdfc7225..d344b3bb6f 100644 --- a/deal.II/base/include/base/quadrature_lib.h +++ b/deal.II/base/include/base/quadrature_lib.h @@ -17,6 +17,28 @@ #include +/** + * Gauß-Legendre quadrature of arbitrary order. + * + * The coefficients of these quadrature rules are computed by the + * function found in @p{Numerical Recipies}. + * + * @author Guido Kanschat, 2001 + */ +template +class QGauss : public Quadrature +{ + public: + /** + * Generate a formula with @p{p} + * quadrature points (order @p{2p-1}). + */ + QGauss (unsigned int p); +}; + + + + /** * 2-Point-Gauss quadrature formula, exact for polynomials of degree 3. * diff --git a/deal.II/base/source/legendre.cc b/deal.II/base/source/legendre.cc new file mode 100644 index 0000000000..b0cdf7176b --- /dev/null +++ b/deal.II/base/source/legendre.cc @@ -0,0 +1,66 @@ +//-------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//-------------------------------------------------------------------- + + +#include + +// Reserve space for polynomials up to degree 19. Should be sufficient +// in most cases. + +template +std::vector > +Legendre::coefficients(20,0); + + +template +void +Legendre::compute_coefficients (unsigned int k) +{ + if (k<=1) + { + coefficients[0].resize(1); + coefficients[0][0] = 1.; + coefficients[1].resize(2); + coefficients[1][0] = 0.; + coefficients[1][1] = 1.; + } else { + compute_coefficients(k-1); + coefficients[k].resize(k+1); + const double a = 1./k+1; + const double b = a*(2*k+1); + + coefficients[k][k] = b*coefficients[k-1][k-1]; + coefficients[k][k-1] = b*coefficients[k-1][k-2]; + for (unsigned int i=1 ; i<= k-2 ; ++i) + coefficients[k][i] = b*coefficients[k-1][i-1] + - k*a*coefficients[k-2][i]; + coefficients[k][0] = -k*a*coefficients[k-2][0]; + } +} + + + +template +const std::vector& +Legendre::get_coefficients (unsigned int k) +{ + compute_coefficients (k); + return coefficients[k]; +} + + + +template +Legendre::Legendre (unsigned int k) + : Polynomial (get_coefficients(k)) +{}