From: kanschat Date: Thu, 4 Nov 1999 20:15:57 +0000 (+0000) Subject: new constructor for Quadrature X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89717696016c7b24dbe4ded5646fe9125ed8888c;p=dealii-svn.git new constructor for Quadrature git-svn-id: https://svn.dealii.org/trunk@1825 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/quadrature.h b/deal.II/base/include/base/quadrature.h index bf8baf338d..1435375ca1 100644 --- a/deal.II/base/include/base/quadrature.h +++ b/deal.II/base/include/base/quadrature.h @@ -20,7 +20,7 @@ * * There are a number of derived classes, denoting concrete integration * formulae. These are named by a prefixed #Q#, the name of the formula - * (e.g. #Midpoint# or #Gauss#) and finally (only for Gauss integration + * (e.g. #Midpoint# or #Gauss#) and finally (for Gauss integration * formulae) the number of quadrature points. * * For each quadrature formula @@ -65,7 +65,8 @@ * @author Wolfgang Bangerth, 1998, documentation: Ralf Hartmann, 1999 */ template -class Quadrature { +class Quadrature +{ public: /** * Number of quadrature points. @@ -87,10 +88,13 @@ class Quadrature { const Quadrature<1> &); /** - * Virtual destructor needed, since someone - * may want to use pointers to this class - * though the object pointed to is a derived - * class. + * Constructor from given vectors. + */ + Quadrature (const vector > & points, + const vector & weights); + + /** + * Virtual destructor. */ virtual ~Quadrature (); diff --git a/deal.II/base/include/base/tensorindex.h b/deal.II/base/include/base/tensorindex.h deleted file mode 100644 index b9d0ddb81b..0000000000 --- a/deal.II/base/include/base/tensorindex.h +++ /dev/null @@ -1,228 +0,0 @@ -/*---------------------------- tensorindex.h ---------------------------*/ -/* $Id$ */ -#ifndef __tensorindex_H -#define __tensorindex_H -/*---------------------------- tensorindex.h ---------------------------*/ - -#include - - -/** - * Rank-independent access to elements of #Tensor#. A little class - * template remembering #rank# integers. - * - * This template is implemented only for ranks between 1 and 4. If you - * really need higher ranks, please modify the source code accordingly - * or contact the developer. - * - * @author Guido Kanschat, 1999 - */ -template -class TensorIndex -{ - private: - /** - * Field of indices. - */ - unsigned int index[rank]; - public: - /** - * Constructor taking #rank# indices. - */ - TensorIndex(...); - - /** - * Access operator returning index - * in #n#th component - */ - unsigned int operator () (const unsigned int n) const; - - /** - * Exception. - */ - DeclException1(ExcRank, int, - << "Index " << arg1 << " higher than maximum " << rank-1); -}; - - - -template<> -class TensorIndex<4> -{ - private: - /** - * Field of indices. - */ - unsigned int index[4]; - public: - /** - * Constructor taking #rank# indices. - */ - TensorIndex (const unsigned int i0, - const unsigned int i1, - const unsigned int i2, - const unsigned int i3) - { - index[0] = i0; - index[1] = i1; - index[2] = i2; - index[3] = i3; - } - - - /** - * Access operator returning index - * in #n#th component - */ - unsigned int operator () (const unsigned int n) const - { - Assert(n<4, ExcRank(n)); - return index[n]; - - } - - /** - * Exception - */ - DeclException1(ExcRank, unsigned int, - << "Index " << arg1 << " higher than maximum 3"); -}; - - - -template<> -class TensorIndex<3> -{ - private: - /** - * Field of indices. - */ - unsigned int index[3]; - public: - /** - * Constructor taking #rank# indices. - */ - TensorIndex(const unsigned int i0, - const unsigned int i1, - const unsigned int i2) - { - index[0] = i0; - index[1] = i1; - index[2] = i2; - } - - - /** - * Access operator returning index - * in #n#th component - * - */ - unsigned int operator () (const unsigned int n) const - { - Assert(n<3, ExcRank(n)); - return index[n]; - - } - - /** - * Exception - */ - DeclException1(ExcRank, unsigned int, - << "Index " << arg1 << " higher than maximum 2"); -}; - - - -template<> -class TensorIndex<2> -{ - private: - /** - * Field of indices. - */ - unsigned int index[4]; - public: - /** - * Constructor taking #rank# indices. - */ - TensorIndex(const unsigned int i0, - const unsigned int i1) - { - index[0] = i0; - index[1] = i1; - } - - - /** - * Access operator returning index - * in #n#th component - */ - unsigned int operator () (const unsigned int n) const - { - Assert(n<2, ExcRank(n)); - return index[n]; - - } - - /** - * Exception - */ - DeclException1(ExcRank, unsigned int, - << "Index " << arg1 << " higher than maximum 1"); -}; - - - -template<> -class TensorIndex<1> -{ - private: - /** - * Field of indices. - */ - unsigned int index[1]; - public: - /** - * Constructor taking #rank# indices. - */ - TensorIndex(const unsigned int i0) - { - index[0] = i0; - } - - - /** - * Access operator returning index - * in #n#th component - */ - unsigned int operator () (const unsigned int n) const - { - Assert(n<1, ExcRank(n)); - return index[n]; - - } - - /** - * Exception - */ - DeclException1(ExcRank, unsigned int, - << "Index " << arg1 << " higher than maximum 0"); -}; - - - -template -inline unsigned int -TensorIndex:: -operator() (unsigned int n) const -{ - Assert(n Quadrature::Quadrature (const unsigned int n_q) : n_quadrature_points(n_q), quadrature_points (n_q, Point()), - weights (n_q, 0) {}; + weights (n_q, 0) +{} +template +Quadrature::Quadrature (const vector > & points, + const vector & weights) + : n_quadrature_points(points.size()), + quadrature_points(points), + weights(weights) +{ + Assert(weights.size() == points.size(), + ExcDimensionMismatch(weights.size(), points.size())); +} template <> Quadrature<0>::Quadrature (const Quadrature<-1> &, - const Quadrature<1> &) { + const Quadrature<1> &) +{ Assert (false, ExcInternalError()); };