]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
iterated simpson rule
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 21 Jun 1999 15:39:42 +0000 (15:39 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 21 Jun 1999 15:39:42 +0000 (15:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@1425 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/quadrature_lib.h
deal.II/base/source/quadrature_lib.cc

index 1fbe65054b0b931865ae54d5ba36a32ce308b355..6982cd08aa4142d697dcb0ae23f28ff81956cbe8 100644 (file)
 
 
 /**
- *  Second order Gauss quadrature formula.
+ *  2-Point-Gauss quadrature formula.
  *
  *  Reference: Ward Cheney, David Kincaid: Numerical Mathematics and Computing.
  */
 template <int dim>
-class QGauss2 : public Quadrature<dim> {
+class QGauss2 : public Quadrature<dim>
+{
   public:
     QGauss2 ();
 };
@@ -23,12 +24,13 @@ class QGauss2 : public Quadrature<dim> {
 
 
 /**
- *  Third order Gauss quadrature formula.
+ *  3-Point-Gauss quadrature formula.
  *
  *  Reference: Ward Cheney, David Kincaid: Numerical Mathematics and Computing.
  */
 template <int dim>
-class QGauss3 : public Quadrature<dim> {
+class QGauss3 : public Quadrature<dim>
+{
   public:
     QGauss3 ();
 };
@@ -36,12 +38,13 @@ class QGauss3 : public Quadrature<dim> {
 
 
 /**
- * Fourth order Gauss quadrature formula.
+ * 4-Point-Gauss quadrature formula.
  *
  *  Reference: Ward Cheney, David Kincaid: Numerical Mathematics and Computing.
  */
 template <int dim>
-class QGauss4 : public Quadrature<dim> {
+class QGauss4 : public Quadrature<dim>
+{
   public:
     QGauss4 ();
 };
@@ -50,12 +53,13 @@ class QGauss4 : public Quadrature<dim> {
 
 
 /**
- *  Fifth order Gauss quadrature formula.
+ *  5-Point-Gauss quadrature formula.
  *
  *  Reference: Ward Cheney, David Kincaid: Numerical Mathematics and Computing.
  */
 template <int dim>
-class QGauss5 : public Quadrature<dim> {
+class QGauss5 : public Quadrature<dim>
+{
   public:
     QGauss5 ();
 };
@@ -63,7 +67,7 @@ class QGauss5 : public Quadrature<dim> {
 
 
 /**
- *  Sixth order Gauss quadrature formula. I have not found explicite
+ *  6-Point-Gauss quadrature formula. I have not found explicite
  *  representations of the zeros of the Legendre functions of sixth
  *  and higher degree. If anyone finds them, please replace the existing
  *  numbers by these expressions.
@@ -72,7 +76,8 @@ class QGauss5 : public Quadrature<dim> {
  *  Element Methods
  */
 template <int dim>
-class QGauss6 : public Quadrature<dim> {
+class QGauss6 : public Quadrature<dim>
+{
   public:
     QGauss6 ();
 };
@@ -80,7 +85,7 @@ class QGauss6 : public Quadrature<dim> {
 
 
 /**
- *  Seventh order Gauss quadrature formula. I have not found explicite
+ *  7-Point-Gauss quadrature formula. I have not found explicite
  *  representations of the zeros of the Legendre functions of sixth
  *  and higher degree. If anyone finds them, please replace the existing
  *  numbers by these expressions.
@@ -89,7 +94,8 @@ class QGauss6 : public Quadrature<dim> {
  *  Element Methods
  */
 template <int dim>
-class QGauss7 : public Quadrature<dim> {
+class QGauss7 : public Quadrature<dim>
+{
   public:
     QGauss7 ();
 };
@@ -97,7 +103,7 @@ class QGauss7 : public Quadrature<dim> {
 
 
 /**
- *  Eighth order Gauss quadrature formula. I have not found explicite
+ *  8-Point-Gauss quadrature formula. I have not found explicite
  *  representations of the zeros of the Legendre functions of sixth
  *  and higher degree. If anyone finds them, please replace the existing
  *  numbers by these expressions.
@@ -106,7 +112,8 @@ class QGauss7 : public Quadrature<dim> {
  *  Element Methods
  */
 template <int dim>
-class QGauss8 : public Quadrature<dim> {
+class QGauss8 : public Quadrature<dim>
+{
   public:
     QGauss8 ();
 };
@@ -117,20 +124,23 @@ class QGauss8 : public Quadrature<dim> {
 
 /**
  * First order midpoint quadrature rule.
+ * For compatibility, this rule may be accessed as #QGauss1#, too.
  */
 template <int dim>
-class QMidpoint : public Quadrature<dim> {
+class QMidpoint : public Quadrature<dim>
+{
   public:
     QMidpoint ();
 };
 
-
+#define QGauss1 QMidpoint
 
 /**
  * Simpson quadrature rule.
  */
 template <int dim>
-class QSimpson : public Quadrature<dim> {
+class QSimpson : public Quadrature<dim>
+{
   public:
     QSimpson ();
 };
@@ -141,22 +151,22 @@ class QSimpson : public Quadrature<dim> {
  * Trapezoidal quadrature rule.
  */
 template <int dim>
-class QTrapez : public Quadrature<dim> {
+class QTrapez : public Quadrature<dim>
+{
   public:
     QTrapez ();
 };
 
 
 /**
- * Iterated trapezoidal rule.  The original reason for implementing
- * this was gnuplot output for patches.  Before this comment is
- * removed, please do not rely on the correctness of the quadrature
- * weights.
+ * Iterated trapezoidal rule. The aim of this class is to provide a
+ * low order formula, where the error constant can be tuned by
+ * increasing the number of quadrature points. This is useful in
+ * integrating non-differentiable functions on cells.
  *
  * For internal use, it may be worth to know that the points are
  * ordered in a fashion such that the last coordinate is the one which
- * runs fastest, and when overflowing moving ahead the second last
- * coordinate, and so on.
+ * runs fastest and then lexicographically from back to front.
  */
 template <int dim>
 class QIteratedTrapez :
@@ -166,6 +176,19 @@ public:
   QIteratedTrapez(const unsigned intervals);
 };
 
+/**
+ * Iterated Simpson rule.
+ * Like #QIteratedTrapez#, this class provides a lower order formula,
+ * while the error constant can be tuned by choosing the number of sub-cells.
+ */
+template <int dim>
+class QIteratedSimpson :
+  public Quadrature<dim>
+{
+public:
+  QIteratedSimpson(const unsigned intervals);
+};
+
 /*----------------------------   quadrature_lib.h     ---------------------------*/
 /* end of #ifndef __quadrature_lib_H */
 #endif
index 27df2295251c0fdf8e10d81975eeb255fc7db887..c8ef62669439f961ec502ce6c6429e713764d5a5 100644 (file)
@@ -329,6 +329,24 @@ QIteratedTrapez<1>::QIteratedTrapez (const unsigned n) :
   weights[n] = .5/n;
 }
 
+template<>
+QIteratedSimpson<1>::QIteratedSimpson(const unsigned n) :
+               Quadrature<1> (2*n+1)
+{
+  weights.clear();
+  
+  for (unsigned int i=0 ; i<n; ++i)
+    {
+      quadrature_points[2*i] = Point<1>(1.*i/n);
+      quadrature_points[2*i+1] = Point<1>(1.*i/n+.5/n);
+
+      weights[2*i]   += 1./(6*n);
+      weights[2*i+1] += 4./(6*n);
+      weights[2*i+2] += 1./(6*n);
+    }
+  quadrature_points[2*n] = Point<1>(1.);
+}
+
 // construct the quadrature formulae in higher dimensions by
 // tensor product of lower dimensions
 template <int dim>
@@ -375,6 +393,10 @@ template <int dim>
 QIteratedTrapez<dim>::QIteratedTrapez (const unsigned n) :
                Quadrature<dim> (QIteratedTrapez<dim-1>(n), QIteratedTrapez<1>(n)) {};
 
+template <int dim>
+QIteratedSimpson<dim>::QIteratedSimpson (const unsigned n) :
+               Quadrature<dim> (QIteratedTrapez<dim-1>(n), QIteratedTrapez<1>(n)) {};
+
 
 
 // explicite specialization
@@ -389,6 +411,7 @@ template class QMidpoint<2>;
 template class QSimpson<2>;
 template class QTrapez<2>;
 template class QIteratedTrapez<2>;
+template class QIteratedSimpson<2>;
 
 template class QGauss2<3>;
 template class QGauss3<3>;
@@ -401,4 +424,4 @@ template class QMidpoint<3>;
 template class QSimpson<3>;
 template class QTrapez<3>;
 template class QIteratedTrapez<3>;
-
+template class QIteratedSimpson<3>;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.