]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
new function for multidimensional tensor products of quadrature rules
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 10 Jun 2005 13:52:28 +0000 (13:52 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 10 Jun 2005 13:52:28 +0000 (13:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@10852 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 96989be0dc63507a74d46b15951bc8a073e35b45..5bd8cb18ab7b2f0243e6ded85c7c210691df5ab9 100644 (file)
@@ -75,7 +75,7 @@
  *
  * @ref Instantiations: few
  *
- * @author Wolfgang Bangerth, 1998, 1999, 2000
+ * @author Wolfgang Bangerth, Guido Kanschat, 1998, 1999, 2000, 2005
  */
 template <int dim>
 class Quadrature : public Subscriptor
@@ -114,6 +114,21 @@ class Quadrature : public Subscriptor
     Quadrature (const SubQuadrature &,
                const Quadrature<1> &);
     
+                                    /**
+                                     * Build this quadrature formula
+                                     * as the <tt>dim</tt>-fold
+                                     * tensor product of a formula in
+                                     * one dimension.
+                                     *
+                                     * Assuming that the points in
+                                     * the on-dimensional rule are in
+                                     * ascending order, the points of
+                                     * the resulting rule are ordered
+                                     * lexicographically with
+                                     * <i>x</i> running fastest.
+                                     */
+    Quadrature (const Quadrature<1> &);
+    
                                     /**
                                      * Construct a quadrature formula
                                      * from given vectors of
index 2dc8bab16fbc630d7dfb58a3e6a82b0a058af261..a9e12b248c4009c68629c8152b2799d4f6e0750a 100644 (file)
 #include <iterator>
 
 
+// Integer to the power of dim
+template <int dim>
+inline unsigned int dimpow (unsigned int n)
+{
+  unsigned int result = n;
+  for (unsigned int i=1;i<dim;++i)
+    result *= n;
+  return result;
+}
+
+
 template <>
 Quadrature<0>::Quadrature (const unsigned int)
               : n_quadrature_points(0)
@@ -141,6 +152,39 @@ Quadrature<dim>::Quadrature (const SubQuadrature &q1,
 
 
 
+template <int dim>
+Quadrature<dim>::Quadrature (const Quadrature<1> &q)
+               :
+               Subscriptor(),
+               n_quadrature_points (dimpow<dim>(q.n_quadrature_points)),
+               quadrature_points (n_quadrature_points),
+               weights (n_quadrature_points, 0.)
+{
+  const unsigned int n0 = q.n_quadrature_points;
+  const unsigned int n1 = (dim>1) ? n0 : 1;
+  const unsigned int n2 = (dim>2) ? n0 : 1;
+
+  unsigned int k=0;
+  for (unsigned int i2=0;i2<n2;++i2)
+    for (unsigned int i1=0;i1<n1;++i1)
+      for (unsigned int i0=0;i0<n0;++i0)
+       {
+         quadrature_points[k](0) = q.point(i0)(0);
+         if (dim>1)
+           quadrature_points[k](1) = q.point(i1)(0);
+         if (dim>2)
+           quadrature_points[k](2) = q.point(i2)(0);
+         weights[k] = q.weight(i0);
+         if (dim>1)
+           weights[k] *= q.weight(i1);
+         if (dim>2)
+           weights[k] *= q.weight(i2);
+         ++k;
+       }
+}
+
+
+
 template <int dim>
 Quadrature<dim>::~Quadrature ()
 {}

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.