]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Small changes and interface extension.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 6 Mar 1998 17:33:13 +0000 (17:33 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Fri, 6 Mar 1998 17:33:13 +0000 (17:33 +0000)
git-svn-id: https://svn.dealii.org/trunk@43 0785d39b-7218-0410-832d-ea1e28bc413d

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

index fbe09067ed5d7e461dbe295cccdff2e879780653..7f06f7c545674f6d8cc0848e77ce0daa0b1c610f 100644 (file)
 
 
 /**
-  Base class for quadrature formulae in arbitrary dimensions.
+  Base class for quadrature formulae in arbitrary dimensions. This class
+  stores quadrature points and weights on the unit line [0,1], unit
+  square [0,1]x[0,1], etc. This information is used together with
+  objects of the \Ref{FiniteElement} class to compute the values stored
+  in the \Ref{FEValues} objects.
   */
 template <int dim>
 class Quadrature {
@@ -19,12 +23,12 @@ class Quadrature {
                                     /**
                                      * Number of quadrature points.
                                      */
-    const unsigned int n_quad_points;
+    const unsigned int n_quadrature_points;
 
                                     /**
                                      * Constructor.
                                      */
-    Quadrature (const unsigned int n_quad_points);
+    Quadrature (const unsigned int n_quadrature_points);
     
                                     /**
                                      * Return the #i#th quadrature point.
index 92dd78e0996e75766d7ade8173ab89ef091da46c..0f21f502fbab79b0bff2348637ec525c5799e331 100644 (file)
@@ -10,7 +10,7 @@ QGauss2<1>::QGauss2 () :
   static const double xpts[] = { 0.288675135, 0.71132486 };
   static const double wts[]  = { 0.5, 0.5 };
 
-  for (unsigned int i=0; i<n_quad_points; ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       quadrature_points.push_back (Point<1> (xpts[i]));
       weights.push_back (wts[i]);
@@ -34,7 +34,7 @@ QGauss2x4<1>::QGauss2x4 () :
   static const double wts[]  = { 0.5*W0, 0.5*W1, 0.5*W1, 0.5*W0,
                                 0.5*W0, 0.5*W1, 0.5*W1, 0.5*W0 };
 
-  for (unsigned int i=0; i<n_quad_points; ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       quadrature_points.push_back (Point<1> (xpts[i]));
       weights.push_back (wts[i]);
@@ -56,7 +56,7 @@ QGauss4<1>::QGauss4 () :
   static const double xpts[] = { G0, G1, G2, G3 };
   static const double wts[]  = { W0, W1, W1, W0 };
 
-  for (unsigned int i=0; i<n_quad_points; ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       quadrature_points.push_back (Point<1> (xpts[i]));
       weights.push_back (wts[i]);
@@ -84,7 +84,7 @@ QGauss8<1>::QGauss8 () :
   static const double xpts[] = { G0, G1, G2, G3, G4, G5, G6, G7 };
   static const double wts[]  = { W0, W1, W2, W3, W3, W2, W1, W0 };
 
-  for (unsigned int i=0; i<n_quad_points; ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       quadrature_points.push_back (Point<1> (xpts[i]));
       weights.push_back (wts[i]);
@@ -108,7 +108,7 @@ QSimpson<1>::QSimpson () :
   static const double xpts[] = { 0.0, 0.5, 1.0 };
   static const double wts[]  = { 1./6., 2./3., 1./6. };
 
-  for (unsigned int i=0; i<n_quad_points; ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       quadrature_points.push_back (Point<1> (xpts[i]));
       weights.push_back (wts[i]);
@@ -123,7 +123,7 @@ QTrapez<1>::QTrapez () :
   static const double xpts[] = { 0.0, 1.0 };
   static const double wts[]  = { 0.5, 0.5 };
 
-  for (unsigned int i=0; i<n_quad_points; ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       quadrature_points.push_back (Point<1> (xpts[i]));
       weights.push_back (wts[i]);
index 5006d8676325264a9ed5ada18fd077d118e304d4..ca758eb7e6207a0c7ba05a71c49f69b5cbbcb976 100644 (file)
@@ -21,8 +21,10 @@ template <int dim> class Quadrature;
   This class is an optimization which avoids evaluating the shape functions
   at the quadrature points each time a quadrature takes place. Rather, the
   values and gradients (and possibly higher order derivatives in future
-  versions of this library) are evaluated once and for all before doing the
-  quadrature itself.
+  versions of this library) are evaluated once and for all on the unit
+  cell before doing the quadrature itself. Only the Jacobian matrix of
+  the transformation from the unit cell to the real cell and the integration
+  points in real space are calculated each time we move on to a new cell.
 
   Objects of this class store a multitude of different values needed to
   do the assemblage steps on real cells rather than on the unit cell. Among
@@ -43,6 +45,16 @@ template <int dim> class Quadrature;
 template <int dim>
 class FEValues {
   public:
+                                    /**
+                                     * Number of quadrature points.
+                                     */
+    const unsigned int n_quadrature_points;
+
+                                    /**
+                                     * Total number of shape functions.
+                                     */
+    const unsigned int total_dofs;
+    
                                     /**
                                      * Constructor. Fill all arrays with the
                                      * values of the shape functions of the
@@ -76,6 +88,19 @@ class FEValues {
     const Point<dim> & shape_grad (const unsigned int i,
                                   const unsigned int j) const;
 
+                                    /**
+                                     * Return the position of the #i#th
+                                     * quadrature point in real space.
+                                     */
+    const Point<dim> & quadrature_point (const unsigned int i) const;
+
+                                    /**
+                                     * Return the Jacobi determinant times
+                                     * the weight of the #i#th quadrature
+                                     * point.
+                                     */
+    double JxW (const unsigned int i) const;
+    
                                     /**
                                      * Reinitialize the gradients, Jacobi
                                      * determinants, etc for the given cell
@@ -394,7 +419,7 @@ class FiniteElementBase {
 
 
 /**
-  Define a finite element type.
+  Define a finite element class.
   */
 template <int dim>
 class FiniteElement;
index 79db61b61cac651f1596af681f4f51d3d386f52b..6d70b92e3b3b3f5c7f8ffd3171f88aa6a7ced401 100644 (file)
@@ -15,26 +15,28 @@ extern TriaIterator<1,CellAccessor<1> > __dummy2687; // for gcc2.8
 template <int dim>
 FEValues<dim>::FEValues (const FiniteElement<dim> &fe,
                         const Quadrature<dim>    &quadrature) :
-               shape_values(fe.total_dofs, quadrature.n_quad_points),
+               n_quadrature_points(quadrature.n_quadrature_points),
+               total_dofs(fe.total_dofs),
+               shape_values(fe.total_dofs, quadrature.n_quadrature_points),
                shape_gradients(fe.total_dofs,
-                               vector<Point<dim> >(quadrature.n_quad_points)),
+                               vector<Point<dim> >(quadrature.n_quadrature_points)),
                unit_shape_gradients(fe.total_dofs,
-                                    vector<Point<dim> >(quadrature.n_quad_points)),
-               weights(quadrature.n_quad_points, 0),
-               JxW_values(quadrature.n_quad_points, 0),
-               quadrature_points(quadrature.n_quad_points, Point<dim>()),
-               unit_quadrature_points(quadrature.n_quad_points, Point<dim>()),
-               jacobi_matrices (quadrature.n_quad_points)
+                                    vector<Point<dim> >(quadrature.n_quadrature_points)),
+               weights(quadrature.n_quadrature_points, 0),
+               JxW_values(quadrature.n_quadrature_points, 0),
+               quadrature_points(quadrature.n_quadrature_points, Point<dim>()),
+               unit_quadrature_points(quadrature.n_quadrature_points, Point<dim>()),
+               jacobi_matrices (quadrature.n_quadrature_points)
 {
   for (unsigned int i=0; i<fe.total_dofs; ++i)
-    for (unsigned int j=0; j<quadrature.n_quad_points; ++j) 
+    for (unsigned int j=0; j<n_quadrature_points; ++j) 
       {
        shape_values(i,j) = fe.shape_value(i, quadrature.quad_point(j));
        unit_shape_gradients[i][j]
          = fe.shape_grad(i, quadrature.quad_point(j));
       };
 
-  for (unsigned int i=0; i<weights.size(); ++i) 
+  for (unsigned int i=0; i<n_quadrature_points; ++i) 
     {
       weights[i] = quadrature.weight(i);
       unit_quadrature_points[i] = quadrature.quad_point(i);
@@ -66,6 +68,24 @@ FEValues<dim>::shape_grad (const unsigned int i,
 
 
 
+template <int dim>
+const Point<dim> & FEValues<dim>::quadrature_point (const unsigned int i) const {
+  Assert (i<n_quadrature_points, ExcInvalidIndex(i, n_quadrature_points));
+  
+  return quadrature_points[i];
+};
+
+
+
+template <int dim>
+double FEValues<dim>::JxW (const unsigned int i) const {
+  Assert (i<n_quadrature_points, ExcInvalidIndex(i, n_quadrature_points));
+  
+  return JxW_values[i];
+};
+
+
+
 void FEValues<1>::reinit (const Triangulation<1>::cell_iterator &cell,
                          const FiniteElement<1>                &fe) {
   const unsigned int dim=1;
@@ -77,7 +97,7 @@ void FEValues<1>::reinit (const Triangulation<1>::cell_iterator &cell,
                     quadrature_points);
                                   // compute gradients on real element
   for (unsigned int i=0; i<fe.total_dofs; ++i)
-    for (unsigned int j=0; j<quadrature_points.size(); ++j)
+    for (unsigned int j=0; j<n_quadrature_points; ++j)
       for (unsigned int s=0; s<dim; ++s)
        {
          shape_gradients[i][j](s) = 0;
@@ -96,7 +116,7 @@ void FEValues<1>::reinit (const Triangulation<1>::cell_iterator &cell,
                                   // refer to the general doc for
                                   // why we take the inverse of the
                                   // determinant
-  for (unsigned int i=0; i<quadrature_points.size(); ++i)
+  for (unsigned int i=0; i<n_quadrature_points; ++i)
     JxW_values[i] = weights[i] / jacobi_matrices[i].determinant();
 };
 
@@ -113,7 +133,7 @@ void FEValues<2>::reinit (const Triangulation<2>::cell_iterator &cell,
                     quadrature_points);
                                   // compute gradients on real element
   for (unsigned int i=0; i<fe.total_dofs; ++i)
-    for (unsigned int j=0; j<quadrature_points.size(); ++j)
+    for (unsigned int j=0; j<n_quadrature_points; ++j)
       for (unsigned int s=0; s<dim; ++s)
        {
          shape_gradients[i][j](s) = 0;
@@ -130,7 +150,7 @@ void FEValues<2>::reinit (const Triangulation<2>::cell_iterator &cell,
                                   // refer to the general doc for
                                   // why we take the inverse of the
                                   // determinant
-  for (unsigned int i=0; i<quadrature_points.size(); ++i)
+  for (unsigned int i=0; i<n_quadrature_points; ++i)
     JxW_values[i] = weights[i] / jacobi_matrices[i].determinant();
 };
 
@@ -241,8 +261,7 @@ void FiniteElement<1>::fill_fe_values (const Triangulation<1>::cell_iterator &ce
                                   // local mesh width
   double h=(cell->vertex(1)(0) - cell->vertex(0)(0));
 
-  unsigned int n_points = unit_points.size();
-  for (unsigned int i=0; i<n_points; ++i) 
+  for (unsigned int i=0; i<points.size(); ++i) 
     {
       jacobians[i](0,0) = 1./h;
       points[i] = cell->vertex(0) + h*unit_points[i];

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.