]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
more mulitgrid and some cosmetics
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 20 Apr 1999 15:00:28 +0000 (15:00 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 20 Apr 1999 15:00:28 +0000 (15:00 +0000)
git-svn-id: https://svn.dealii.org/trunk@1193 0785d39b-7218-0410-832d-ea1e28bc413d

18 files changed:
deal.II/deal.II/include/dofs/dof_handler.h
deal.II/deal.II/include/dofs/mg_dof_handler.h
deal.II/deal.II/include/multigrid/mg_dof_handler.h
deal.II/deal.II/include/multigrid/mg_smoother.h
deal.II/deal.II/include/multigrid/multigrid.h
deal.II/deal.II/include/numerics/data_io.h
deal.II/deal.II/include/numerics/mg_smoother.h
deal.II/deal.II/include/numerics/multigrid.h
deal.II/deal.II/include/numerics/solution_transfer.h
deal.II/deal.II/include/numerics/time_dependent.h
deal.II/deal.II/source/multigrid/mg_smoother.cc
deal.II/deal.II/source/multigrid/multigrid.cc
deal.II/deal.II/source/numerics/mg_smoother.cc
deal.II/deal.II/source/numerics/multigrid.cc
deal.II/doc/parser/dealparse.l
deal.II/doc/parser/dealparse.y
tests/deal.II/fe_tables.cc
tests/deal.II/mg1.cc

index 6252b03017947c94cab1d671cd11590ec35827c0..6a1fd77c0d5d9826ad7b93a7fe44f07e46166581 100644 (file)
@@ -347,7 +347,11 @@ class DoFDimensionInfo<3> {
  *
  * @author Wolfgang Bangerth, 1998 */
 template <int dim>
-class DoFHandler : public DoFDimensionInfo<dim> {
+class DoFHandler
+  :
+  public Subscriptor,
+  public DoFDimensionInfo<dim>
+{
   public:
     typedef typename DoFDimensionInfo<dim>::raw_line_iterator raw_line_iterator;
     typedef typename DoFDimensionInfo<dim>::line_iterator line_iterator;
index 1d6a7d7fb130d57095e2c5982253b7ade5f0a653..f433d1ce4b9ab30798899f172882e33422f738df 100644 (file)
@@ -121,7 +121,10 @@ class MGDoFDimensionInfo<3> {
 
 
 template <int dim>
-class MGDoFHandler : public DoFHandler<dim> {
+class MGDoFHandler
+  :
+  public DoFHandler<dim>
+{
   public:
     typedef typename MGDoFDimensionInfo<dim>::raw_line_iterator raw_line_iterator;
     typedef typename MGDoFDimensionInfo<dim>::line_iterator line_iterator;
index 1d6a7d7fb130d57095e2c5982253b7ade5f0a653..f433d1ce4b9ab30798899f172882e33422f738df 100644 (file)
@@ -121,7 +121,10 @@ class MGDoFDimensionInfo<3> {
 
 
 template <int dim>
-class MGDoFHandler : public DoFHandler<dim> {
+class MGDoFHandler
+  :
+  public DoFHandler<dim>
+{
   public:
     typedef typename MGDoFDimensionInfo<dim>::raw_line_iterator raw_line_iterator;
     typedef typename MGDoFDimensionInfo<dim>::line_iterator line_iterator;
index 2703b910cf9927681d934a012c9c0b649747a56d..9f49892d2b08ea98c55298a0e92846c5451e6cec 100644 (file)
@@ -7,21 +7,55 @@
 
 #include <lac/forward-declarations.h>
 #include <basic/forward-declarations.h>
-#include <base/subscriptor.h>
+#include <base/smartpointer.h>
 #include <vector>
 
 
+/**
+ * Abstract base class for multigrid smoothers.
+ * In fact, this class only provides the interface of the smoothing function.
+ * Using deal.II grid handling, #MGSmoother# is a good point to start.
+ *
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999
+ */
+class MGSmootherBase
+  :
+  public Subscriptor 
+{  
+  public:
+                                    /**
+                                     * Virtual destructor.
+                                     */
+    virtual ~MGSmootherBase();
+    
+                                    /**
+                                     * Smoothen the residual of #u# on the given
+                                     * level. This function should keep the interior
+                                     * level boundary values, so you may want
+                                     * to call #set_zero_interior_boundary#
+                                     * in the derived class #MGSmoother#
+                                     * somewhere in your derived function,
+                                     * or another function doing similar
+                                     * things.
+                                     */
+    virtual void smooth (const unsigned int   level,
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const = 0;
+
+};
 
 /**
- * Abstract base class for multigrid smoothers. It declares the interface
- * to smoothers and implements some functionality for setting the values
+ * Base class for multigrid smoothers. It declares the interface
+ * to smoothers by inheriting #MGSmootherBase# and implements some functionality for setting
+ * the values
  * of vectors at interior boundaries (i.e. boundaries between differing
  * levels of the triangulation) to zero, by building a list of these degrees
  * of freedom's indices at construction time.
  *
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
-class MGSmoother :  public Subscriptor 
+class MGSmoother
+  :  public MGSmootherBase
 {
   private:
                                     /**
@@ -60,44 +94,12 @@ class MGSmoother :  public Subscriptor
                                      * the different levels, which are
                                      * needed by the function
                                      * #set_zero_interior_boundaries#.
-                                     */
-    template <int dim>
-    MGSmoother (const MGDoFHandler<dim> &mg_dof);
-
-                                    /**
-                                     * Destructor, made virtual.
-                                     */
-    virtual ~MGSmoother ();
-    
-                                    /**
-                                     * Smooth the vector #u# on the given
-                                     * level. This function should set the
-                                     * interior boundary values of u to zero
-                                     * at the end of its work, so you may want
-                                     * to call #set_zero_interior_boundary#
-                                     * at the end of your derived function,
-                                     * or another function doing similar
-                                     * things.
                                      *
-                                     * This function is responsible for the
-                                     * presmoothing, postsmoothing is done
-                                     * by another function, which, however,
-                                     * calls this function if not overloaded.
-                                     */
-    virtual void pre_smooth (const unsigned int  level,
-                            Vector<float>      &u) const = 0;
-
-                                    /**
-                                     * Postsmoothing; the same applies as for
-                                     * the presmoothing function. If you
-                                     * want pre- and postsmoothing to do the
-                                     * same operations, you may want to not
-                                     * overload this function, since its
-                                     * default implementation simply calls
-                                     * #pre_smooth#.
+                                     * The parameter steps indicates the number of smoothing
+                                     * steps to be executed by #smooth#.
                                      */
-    virtual void post_smooth (const unsigned int  level,
-                             Vector<float>      &u) const;
+    template <int dim>
+    MGSmoother (const MGDoFHandler<dim> &mg_dof, unsigned int steps);    
 
                                     /**
                                      * Reset the values of the degrees of
@@ -111,8 +113,20 @@ class MGSmoother :  public Subscriptor
                                      */
     void set_zero_interior_boundary (const unsigned int  level,
                                     Vector<float>      &u) const;
+                                    /**
+                                     * Modify the number of smoothing steps.
+                                     */
+    void set_steps(unsigned int steps);
+                                    /**
+                                     * How many steps should be used?
+                                     */
+    unsigned int get_steps() const;
 
   private:
+                                    /**
+                                     * Number of smoothing steps.
+                                     */
+    unsigned int steps;
                                     /**
                                      * For each level, we store a list of
                                      * degree of freedom indices which are
@@ -123,11 +137,66 @@ class MGSmoother :  public Subscriptor
                                      * entry refers to the second level.
                                      *
                                      * These arrays are set by the constructor.
+                                     * The entries for each level are sorted ascendingly.
                                      */
     vector<vector<int> > interior_boundary_dofs;
 };
 
+/**
+ * Implementation of an SOR smoother.
+ *
+ * This class is an implementation of a smootin algorithm for multigrid. It
+ * knows the actual instance of the multigrid matrix and uses the SOR method of the level
+ * matrices.
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999
+ */
+class MGSmootherSOR
+  :
+  public MGSmoother
+{
+  public:
+                                    /**
+                                     * Constructor.
+                                     * The constructor uses an #MGDoFHandler# to initialize
+                                     * data structures for interior level boundary handling
+                                     * in #MGSmoother#. Furthermore, it takes a pointer to the
+                                     * matrices and the number of SOR steps required in each
+                                     * smoothing operation.
+                                     */
+
+    template<int dim>
+    MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
+                 const MGMatrix& matrix,
+                 unsigned int steps);
     
+                                    /**
+                                     * Implementation of the interface in #MGSmootherBase#.
+                                     * We use the SOR method in #SparseMatrix# for the real work
+                                     * and find a way to keep the boundary values.
+                                     */
+    virtual void smooth (const unsigned int   level,
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const;
+  private:
+                                    /**
+                                     * Pointer to the matrices.
+                                     */
+    SmartPointer< const MGMatrix > matrix;
+};
+
+inline
+void
+MGSmoother::set_steps(unsigned int i)
+{
+  steps = i;
+}
+
+inline
+unsigned int
+MGSmoother::get_steps() const
+{
+  return steps;
+}
 
 
 /*----------------------------   mg_smoother.h     ---------------------------*/
index 81a59959b7297e45d5e713739eda79c5ef127137..942166e8cd6f5c738e8e258f650b7d0088611204 100644 (file)
@@ -4,6 +4,7 @@
 #define __multigrid_H
 /*----------------------------   multigrid.h     ---------------------------*/
 
+#include <base/subscriptor.h>
 #include <base/smartpointer.h>
 #include <lac/forward-declarations.h>
 #include <basic/forward-declarations.h>
@@ -12,7 +13,7 @@
 
 #include <vector>
 class MGTransferBase;
-class MGSmoother;
+class MGSmootherBase;
 
 
 /**
@@ -44,12 +45,12 @@ class MultiGridBase
     const MultiGridBase& operator=(const MultiGridBase&);
     
                                     /**
-                                     * Auxiliary vector.
+                                     * Auxiliary vector, defect.
                                      */
     vector<Vector<float> > d;
 
                                     /**
-                                     * Auxiliary vector.
+                                     * Auxiliary vector, solution.
                                      */
     vector<Vector<float> > s;
 
@@ -58,33 +59,22 @@ class MultiGridBase
                                      */
     Vector<float> t;
     
-                                    /**
-                                     * Highest level of cells.
-                                     */
-    unsigned maxlevel;
-
-                                    /**
-                                     * Level for coarse grid solution.
-                                     */
-    unsigned minlevel;
-
                                     /**
                                      * Prolongation and restriction object.
                                      */
-    SmartPointer<MGTransferBase> transfer;
+    SmartPointer<const MGTransferBase> transfer;
     
   protected:
                                     /**
-                                     * Number of pre-smoothing steps. Is used
-                                     * as a parameter to #pre_smooth#.
+                                     * Highest level of cells.
                                      */
-    unsigned n_pre_smooth;
-  
+    unsigned int maxlevel;
+
                                     /**
-                                     * Number of post-smoothing steps Is used
-                                     * as a parameter to #post_smooth#.
+                                     * Level for coarse grid solution.
                                      */
-    unsigned n_post_smooth;
+    unsigned int minlevel;
+
                                     /**
                                      * The actual v-cycle multigrid method.
                                      * This function is called on the
@@ -94,7 +84,9 @@ class MultiGridBase
                                      * #coarse_grid_solution# and
                                      * proceeds back up.
                                      */
-    void level_mgstep(unsigned level, MGSmoother& smoother);  
+    void level_mgstep(unsigned int level,
+                     const MGSmootherBase& pre_smooth,
+                     const MGSmootherBase& post_smooth);  
 
                                     /**
                                      * Apply residual operator on all
@@ -102,7 +94,7 @@ class MultiGridBase
                                      * This is implemented in a
                                      * derived class.
                                      */
-    virtual void level_residual(unsigned level,
+    virtual void level_residual(unsigned int level,
                             Vector<float>& dst,
                             const Vector<float>& src,
                             const Vector<float>& rhs) = 0;
@@ -118,7 +110,7 @@ class MultiGridBase
                                      * n_post_smooth)#
                                      * smoothing steps of #pre_smooth#.
                                      */
-    virtual void coarse_grid_solution(unsigned l,
+    virtual void coarse_grid_solution(unsigned int l,
                                      Vector<float>& dst,
                                      const Vector<float>& src);
   
@@ -130,9 +122,8 @@ class MultiGridBase
                                     /**
                                      * Constructor, subject to change.
                                      */
-    MultiGridBase(MGTransferBase& transfer,
-                 unsigned maxlevel, unsigned minlevel,
-                 unsigned pre_smooth, unsigned post_smooth);
+    MultiGridBase(const MGTransferBase& transfer,
+                 unsigned int maxlevel, unsigned int minlevel);
     virtual ~MultiGridBase();
     
 };
@@ -190,6 +181,30 @@ class MGTransferBase  :  public Subscriptor
                           const Vector<float> &src) const = 0;
 };
 
+/**
+ * An array of matrices for each level.
+ * This class provides the functionality of #vector<SparseMatrix<float> ># combined
+ * with a subscriptor for smart pointers.
+ * @author Guido Kanschat, 1999
+ */
+class MGMatrix
+  :
+  public Subscriptor,
+  public Vector<SparseMatrix<float> >
+{
+  public:
+                                    /**
+                                     * Standard constructor.
+                                     */
+    MGMatrix() 
+      {}
+                                    /**
+                                     * Constructor allowing to initialize the number of levels.
+                                     */
+    MGMatrix(unsigned int n_levels);
+};
+
+
 /**
  * Implementation of multigrid with matrices.
  * While #MultiGridBase# was only an abstract framework for the v-cycle,
@@ -198,11 +213,13 @@ class MGTransferBase  :  public Subscriptor
  * 
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
-template<int dim, class Matrix>
+template<int dim>
 class MultiGrid
+  :
+  public MultiGridBase
 {
   public:
-    MultiGrid(const MGDoFHandler<dim>&);
+    MultiGrid(const MGDoFHandler<dim>&, const MGTransferBase& transfer);
     
                                     /** Transfer from dVector to
                                      * MGVector.
@@ -230,11 +247,32 @@ class MultiGrid
     template<typename number>
     void copy_from_mg(Vector<number>& dst,
                      const vector<Vector<float> >& src) const;
+
+                                    /**
+                                     * Access to matrix structure.
+                                     */
+    SparseMatrixStruct& get_sparsity_pattern(unsigned int level);
+
+                                    /**
+                                     * Read-only access to matrix structure.
+                                     */
+    const SparseMatrixStruct& get_sparsity_pattern(unsigned int level) const;
+
+                                    /**
+                                     * Access to level matrices.
+                                     */
+    SparseMatrix<float>& get_matrix(unsigned int level);
+
+                                    /**
+                                     * Read-only access to level matrices.
+                                     */
+    const SparseMatrix<float>& get_matrix(unsigned int level) const;
+
   private:
                                     /**
                                      * Associated #MGDoFHandler#.
                                      */
-    SmartPointer<MGDoFHandler<dim> > dofs;
+    SmartPointer<const MGDoFHandler<dim> > dofs;
 
                                     /**
                                      * Matrix structures for each level.
@@ -327,6 +365,26 @@ class MGTransferPrebuilt : public MGTransferBase
     vector<SparseMatrix<float> > prolongation_matrices;
 };
 
+template<int dim>
+inline
+SparseMatrix<float>&
+MultiGrid<dim>::get_matrix(unsigned int level)
+{
+  Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
+  
+  return matrices[level];
+}
+
+template<int dim>
+inline
+const SparseMatrix<float>&
+MultiGrid<dim>::get_matrix(unsigned int level) const
+{
+  Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
+  
+  return matrices[level];
+}
+
 
 
 /*----------------------------   multigrid.h     ---------------------------*/
index e0e9c1dff788ec6b79b219cb4c448618f3d055b4..cc7951ddce0a3b95f9eda1f39c12faf93857011a 100644 (file)
@@ -391,7 +391,7 @@ class DataOut {
                                      * Write a patch for each grid cell using
                                      * #accuracy# subintervals per dimension.
                                      */
-    void write_gnuplot (ostream &out, const unsigned accuracy=1) const;
+    void write_gnuplot (ostream &out, const unsigned int accuracy=1) const;
 
                                     /**
                                      * Write data and grid in GNUPLOT format.
index 2703b910cf9927681d934a012c9c0b649747a56d..9f49892d2b08ea98c55298a0e92846c5451e6cec 100644 (file)
@@ -7,21 +7,55 @@
 
 #include <lac/forward-declarations.h>
 #include <basic/forward-declarations.h>
-#include <base/subscriptor.h>
+#include <base/smartpointer.h>
 #include <vector>
 
 
+/**
+ * Abstract base class for multigrid smoothers.
+ * In fact, this class only provides the interface of the smoothing function.
+ * Using deal.II grid handling, #MGSmoother# is a good point to start.
+ *
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999
+ */
+class MGSmootherBase
+  :
+  public Subscriptor 
+{  
+  public:
+                                    /**
+                                     * Virtual destructor.
+                                     */
+    virtual ~MGSmootherBase();
+    
+                                    /**
+                                     * Smoothen the residual of #u# on the given
+                                     * level. This function should keep the interior
+                                     * level boundary values, so you may want
+                                     * to call #set_zero_interior_boundary#
+                                     * in the derived class #MGSmoother#
+                                     * somewhere in your derived function,
+                                     * or another function doing similar
+                                     * things.
+                                     */
+    virtual void smooth (const unsigned int   level,
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const = 0;
+
+};
 
 /**
- * Abstract base class for multigrid smoothers. It declares the interface
- * to smoothers and implements some functionality for setting the values
+ * Base class for multigrid smoothers. It declares the interface
+ * to smoothers by inheriting #MGSmootherBase# and implements some functionality for setting
+ * the values
  * of vectors at interior boundaries (i.e. boundaries between differing
  * levels of the triangulation) to zero, by building a list of these degrees
  * of freedom's indices at construction time.
  *
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
-class MGSmoother :  public Subscriptor 
+class MGSmoother
+  :  public MGSmootherBase
 {
   private:
                                     /**
@@ -60,44 +94,12 @@ class MGSmoother :  public Subscriptor
                                      * the different levels, which are
                                      * needed by the function
                                      * #set_zero_interior_boundaries#.
-                                     */
-    template <int dim>
-    MGSmoother (const MGDoFHandler<dim> &mg_dof);
-
-                                    /**
-                                     * Destructor, made virtual.
-                                     */
-    virtual ~MGSmoother ();
-    
-                                    /**
-                                     * Smooth the vector #u# on the given
-                                     * level. This function should set the
-                                     * interior boundary values of u to zero
-                                     * at the end of its work, so you may want
-                                     * to call #set_zero_interior_boundary#
-                                     * at the end of your derived function,
-                                     * or another function doing similar
-                                     * things.
                                      *
-                                     * This function is responsible for the
-                                     * presmoothing, postsmoothing is done
-                                     * by another function, which, however,
-                                     * calls this function if not overloaded.
-                                     */
-    virtual void pre_smooth (const unsigned int  level,
-                            Vector<float>      &u) const = 0;
-
-                                    /**
-                                     * Postsmoothing; the same applies as for
-                                     * the presmoothing function. If you
-                                     * want pre- and postsmoothing to do the
-                                     * same operations, you may want to not
-                                     * overload this function, since its
-                                     * default implementation simply calls
-                                     * #pre_smooth#.
+                                     * The parameter steps indicates the number of smoothing
+                                     * steps to be executed by #smooth#.
                                      */
-    virtual void post_smooth (const unsigned int  level,
-                             Vector<float>      &u) const;
+    template <int dim>
+    MGSmoother (const MGDoFHandler<dim> &mg_dof, unsigned int steps);    
 
                                     /**
                                      * Reset the values of the degrees of
@@ -111,8 +113,20 @@ class MGSmoother :  public Subscriptor
                                      */
     void set_zero_interior_boundary (const unsigned int  level,
                                     Vector<float>      &u) const;
+                                    /**
+                                     * Modify the number of smoothing steps.
+                                     */
+    void set_steps(unsigned int steps);
+                                    /**
+                                     * How many steps should be used?
+                                     */
+    unsigned int get_steps() const;
 
   private:
+                                    /**
+                                     * Number of smoothing steps.
+                                     */
+    unsigned int steps;
                                     /**
                                      * For each level, we store a list of
                                      * degree of freedom indices which are
@@ -123,11 +137,66 @@ class MGSmoother :  public Subscriptor
                                      * entry refers to the second level.
                                      *
                                      * These arrays are set by the constructor.
+                                     * The entries for each level are sorted ascendingly.
                                      */
     vector<vector<int> > interior_boundary_dofs;
 };
 
+/**
+ * Implementation of an SOR smoother.
+ *
+ * This class is an implementation of a smootin algorithm for multigrid. It
+ * knows the actual instance of the multigrid matrix and uses the SOR method of the level
+ * matrices.
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999
+ */
+class MGSmootherSOR
+  :
+  public MGSmoother
+{
+  public:
+                                    /**
+                                     * Constructor.
+                                     * The constructor uses an #MGDoFHandler# to initialize
+                                     * data structures for interior level boundary handling
+                                     * in #MGSmoother#. Furthermore, it takes a pointer to the
+                                     * matrices and the number of SOR steps required in each
+                                     * smoothing operation.
+                                     */
+
+    template<int dim>
+    MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
+                 const MGMatrix& matrix,
+                 unsigned int steps);
     
+                                    /**
+                                     * Implementation of the interface in #MGSmootherBase#.
+                                     * We use the SOR method in #SparseMatrix# for the real work
+                                     * and find a way to keep the boundary values.
+                                     */
+    virtual void smooth (const unsigned int   level,
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const;
+  private:
+                                    /**
+                                     * Pointer to the matrices.
+                                     */
+    SmartPointer< const MGMatrix > matrix;
+};
+
+inline
+void
+MGSmoother::set_steps(unsigned int i)
+{
+  steps = i;
+}
+
+inline
+unsigned int
+MGSmoother::get_steps() const
+{
+  return steps;
+}
 
 
 /*----------------------------   mg_smoother.h     ---------------------------*/
index 81a59959b7297e45d5e713739eda79c5ef127137..942166e8cd6f5c738e8e258f650b7d0088611204 100644 (file)
@@ -4,6 +4,7 @@
 #define __multigrid_H
 /*----------------------------   multigrid.h     ---------------------------*/
 
+#include <base/subscriptor.h>
 #include <base/smartpointer.h>
 #include <lac/forward-declarations.h>
 #include <basic/forward-declarations.h>
@@ -12,7 +13,7 @@
 
 #include <vector>
 class MGTransferBase;
-class MGSmoother;
+class MGSmootherBase;
 
 
 /**
@@ -44,12 +45,12 @@ class MultiGridBase
     const MultiGridBase& operator=(const MultiGridBase&);
     
                                     /**
-                                     * Auxiliary vector.
+                                     * Auxiliary vector, defect.
                                      */
     vector<Vector<float> > d;
 
                                     /**
-                                     * Auxiliary vector.
+                                     * Auxiliary vector, solution.
                                      */
     vector<Vector<float> > s;
 
@@ -58,33 +59,22 @@ class MultiGridBase
                                      */
     Vector<float> t;
     
-                                    /**
-                                     * Highest level of cells.
-                                     */
-    unsigned maxlevel;
-
-                                    /**
-                                     * Level for coarse grid solution.
-                                     */
-    unsigned minlevel;
-
                                     /**
                                      * Prolongation and restriction object.
                                      */
-    SmartPointer<MGTransferBase> transfer;
+    SmartPointer<const MGTransferBase> transfer;
     
   protected:
                                     /**
-                                     * Number of pre-smoothing steps. Is used
-                                     * as a parameter to #pre_smooth#.
+                                     * Highest level of cells.
                                      */
-    unsigned n_pre_smooth;
-  
+    unsigned int maxlevel;
+
                                     /**
-                                     * Number of post-smoothing steps Is used
-                                     * as a parameter to #post_smooth#.
+                                     * Level for coarse grid solution.
                                      */
-    unsigned n_post_smooth;
+    unsigned int minlevel;
+
                                     /**
                                      * The actual v-cycle multigrid method.
                                      * This function is called on the
@@ -94,7 +84,9 @@ class MultiGridBase
                                      * #coarse_grid_solution# and
                                      * proceeds back up.
                                      */
-    void level_mgstep(unsigned level, MGSmoother& smoother);  
+    void level_mgstep(unsigned int level,
+                     const MGSmootherBase& pre_smooth,
+                     const MGSmootherBase& post_smooth);  
 
                                     /**
                                      * Apply residual operator on all
@@ -102,7 +94,7 @@ class MultiGridBase
                                      * This is implemented in a
                                      * derived class.
                                      */
-    virtual void level_residual(unsigned level,
+    virtual void level_residual(unsigned int level,
                             Vector<float>& dst,
                             const Vector<float>& src,
                             const Vector<float>& rhs) = 0;
@@ -118,7 +110,7 @@ class MultiGridBase
                                      * n_post_smooth)#
                                      * smoothing steps of #pre_smooth#.
                                      */
-    virtual void coarse_grid_solution(unsigned l,
+    virtual void coarse_grid_solution(unsigned int l,
                                      Vector<float>& dst,
                                      const Vector<float>& src);
   
@@ -130,9 +122,8 @@ class MultiGridBase
                                     /**
                                      * Constructor, subject to change.
                                      */
-    MultiGridBase(MGTransferBase& transfer,
-                 unsigned maxlevel, unsigned minlevel,
-                 unsigned pre_smooth, unsigned post_smooth);
+    MultiGridBase(const MGTransferBase& transfer,
+                 unsigned int maxlevel, unsigned int minlevel);
     virtual ~MultiGridBase();
     
 };
@@ -190,6 +181,30 @@ class MGTransferBase  :  public Subscriptor
                           const Vector<float> &src) const = 0;
 };
 
+/**
+ * An array of matrices for each level.
+ * This class provides the functionality of #vector<SparseMatrix<float> ># combined
+ * with a subscriptor for smart pointers.
+ * @author Guido Kanschat, 1999
+ */
+class MGMatrix
+  :
+  public Subscriptor,
+  public Vector<SparseMatrix<float> >
+{
+  public:
+                                    /**
+                                     * Standard constructor.
+                                     */
+    MGMatrix() 
+      {}
+                                    /**
+                                     * Constructor allowing to initialize the number of levels.
+                                     */
+    MGMatrix(unsigned int n_levels);
+};
+
+
 /**
  * Implementation of multigrid with matrices.
  * While #MultiGridBase# was only an abstract framework for the v-cycle,
@@ -198,11 +213,13 @@ class MGTransferBase  :  public Subscriptor
  * 
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
-template<int dim, class Matrix>
+template<int dim>
 class MultiGrid
+  :
+  public MultiGridBase
 {
   public:
-    MultiGrid(const MGDoFHandler<dim>&);
+    MultiGrid(const MGDoFHandler<dim>&, const MGTransferBase& transfer);
     
                                     /** Transfer from dVector to
                                      * MGVector.
@@ -230,11 +247,32 @@ class MultiGrid
     template<typename number>
     void copy_from_mg(Vector<number>& dst,
                      const vector<Vector<float> >& src) const;
+
+                                    /**
+                                     * Access to matrix structure.
+                                     */
+    SparseMatrixStruct& get_sparsity_pattern(unsigned int level);
+
+                                    /**
+                                     * Read-only access to matrix structure.
+                                     */
+    const SparseMatrixStruct& get_sparsity_pattern(unsigned int level) const;
+
+                                    /**
+                                     * Access to level matrices.
+                                     */
+    SparseMatrix<float>& get_matrix(unsigned int level);
+
+                                    /**
+                                     * Read-only access to level matrices.
+                                     */
+    const SparseMatrix<float>& get_matrix(unsigned int level) const;
+
   private:
                                     /**
                                      * Associated #MGDoFHandler#.
                                      */
-    SmartPointer<MGDoFHandler<dim> > dofs;
+    SmartPointer<const MGDoFHandler<dim> > dofs;
 
                                     /**
                                      * Matrix structures for each level.
@@ -327,6 +365,26 @@ class MGTransferPrebuilt : public MGTransferBase
     vector<SparseMatrix<float> > prolongation_matrices;
 };
 
+template<int dim>
+inline
+SparseMatrix<float>&
+MultiGrid<dim>::get_matrix(unsigned int level)
+{
+  Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
+  
+  return matrices[level];
+}
+
+template<int dim>
+inline
+const SparseMatrix<float>&
+MultiGrid<dim>::get_matrix(unsigned int level) const
+{
+  Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
+  
+  return matrices[level];
+}
+
 
 
 /*----------------------------   multigrid.h     ---------------------------*/
index be79aa3c1e2c9db0f99032f512c062860707622d..dad32bbf7c18f4ed6dca8a6519b4759185347ac8 100644 (file)
@@ -328,7 +328,13 @@ class SolutionTransfer
                                      */
     enum PreparationState {
          none, pure_refinement, coarsening_and_refinement
-    } prepared_for;
+    };
+
+                                    /**
+                                     * ???
+                                     */
+    PreparationState prepared_for;
+
 
                                     /**
                                      * Is used for #prepare_for_refining#
index f2d3c7aa07b70c8612c767fcc148a9491c2b780c..be0ab5532da4faee311efd12aea331f65a5cdd96 100644 (file)
@@ -637,7 +637,7 @@ class TimeStepBase : public Subscriptor
                                      * Enum denoting the type of problem
                                      * which will have to be solved next.
                                      */
-    enum {
+    enum SolutionState {
          primal_problem = 0x0,
          dual_problem   = 0x1,
          postprocess    = 0x2
@@ -681,7 +681,7 @@ class TimeStepBase : public Subscriptor
                                      * can take effect of the triangulation
                                      * already existing.
                                      */
-    virtual void wake_up (const unsigned);
+    virtual void wake_up (const unsigned int);
 
                                     /**
                                      * This is the opposite function
@@ -700,7 +700,7 @@ class TimeStepBase : public Subscriptor
                                      * By default, this function does
                                      * nothing.
                                      */
-    virtual void sleep (const unsigned);
+    virtual void sleep (const unsigned int);
 
                                     /**
                                      * This function is called each time
@@ -991,7 +991,7 @@ class TimeStepBase_Tria :  public TimeStepBase
                                      * cass denoting the next action to be
                                      * done.
                                      */
-    enum {
+    enum SolutionState {
          grid_refinement = 0x1000
     };
     
@@ -1081,7 +1081,7 @@ class TimeStepBase_Tria :  public TimeStepBase
                                      * can take effect of the triangulation
                                      * already existing.
                                      */
-    virtual void wake_up (const unsigned wakeup_level);
+    virtual void wake_up (const unsigned int wakeup_level);
 
                                     /**
                                      * This is the opposite function
@@ -1108,7 +1108,7 @@ class TimeStepBase_Tria :  public TimeStepBase
                                      * that your function can use the
                                      * triangulation as long as ou need it.
                                      */
-    virtual void sleep (const unsigned);
+    virtual void sleep (const unsigned int);
 
                                     /**
                                      * Do the refinement according to the
@@ -1218,7 +1218,12 @@ class TimeStepBase_Tria :  public TimeStepBase
                                      * vectors therefore hold the history
                                      * of the grid.
                                      */
-    vector<vector<bool> >   refine_flags, coarsen_flags;
+    vector<vector<bool> >   refine_flags;
+
+                                    /**
+                                     * @see refine_flags
+                                     */
+    vector<vector<bool> >   coarsen_flags;
 
                                     /**
                                      * Restore the grid according to the saved
@@ -1504,7 +1509,11 @@ struct TimeStepBase_Tria<dim>::RefinementFlags
                                      * (first: top deviation, second: bottom
                                      * deviation).
                                      */
-    const double        cell_number_corridor_top, cell_number_corridor_bottom;
+    const double        cell_number_corridor_top;
+                                    /**
+                                     * @see cell_number_corridor_top
+                                     */
+    const double        cell_number_corridor_bottom;
 
                                     /**
                                      * List of relaxations to the correction
index bc6a227a858898f439d05c9ff8c5d3250ed0e493..98fe594fca71dd24829aaa509a225dcdb0543c19 100644 (file)
@@ -5,6 +5,7 @@
 #include <grid/mg_dof_accessor.h>
 #include <grid/tria_iterator.h>
 #include <fe/fe.h>
+#include <numerics/multigrid.h>
 #include <numerics/mg_smoother.h>
 #include <lac/vector.h>
 
@@ -13,7 +14,9 @@
 
 #if deal_II_dimension == 1
 
-MGSmoother::MGSmoother (const MGDoFHandler<1> &/*mg_dof*/) 
+MGSmoother::MGSmoother (const MGDoFHandler<1> &/*mg_dof*/, unsigned int steps)
+               :
+               steps(steps)
 {
   Assert (false, ExcNotImplemented());
 };
@@ -24,7 +27,9 @@ MGSmoother::MGSmoother (const MGDoFHandler<1> &/*mg_dof*/)
 #if deal_II_dimension > 1
 
 template <int dim>
-MGSmoother::MGSmoother (const MGDoFHandler<dim> &mg_dof) 
+MGSmoother::MGSmoother (const MGDoFHandler<dim> &mg_dof, unsigned int steps)
+               :
+               steps(steps)
 {
   const unsigned int n_levels = mg_dof.get_tria().n_levels();
   
@@ -83,12 +88,12 @@ MGSmoother::MGSmoother (const MGDoFHandler<dim> &mg_dof)
 
 #endif
 
+//////////////////////////////////////////////////////////////////////
 
-
-MGSmoother::~MGSmoother () 
+MGSmootherBase::~MGSmootherBase () 
 {};
 
-
+//////////////////////////////////////////////////////////////////////
 
 void
 MGSmoother::set_zero_interior_boundary (const unsigned int  level,
@@ -102,22 +107,32 @@ MGSmoother::set_zero_interior_boundary (const unsigned int  level,
       u(*p) = 0;
 };
 
+//////////////////////////////////////////////////////////////////////
 
-
+template<int dim>
+MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
+                            const MGMatrix& matrix,
+                            unsigned int steps)
+               :
+               MGSmoother(mg_dof, steps),
+               matrix(&matrix)
+{}
 
 void
-MGSmoother::post_smooth (const unsigned int  level,
-                        Vector<float>      &u) const
+MGSmootherSOR::smooth (const unsigned int   /*level*/,
+                      Vector<float>       &/*u*/,
+                      const Vector<float> &/*rhs*/) const
 {
-  pre_smooth (level, u);
-};
-
-
 
+}
 
 // explicit instantiations
 // don't do the following instantiation in 1d, since there is a specialized
 // function there
 #if deal_II_dimension > 1
-template MGSmoother::MGSmoother (const MGDoFHandler<deal_II_dimension>&);
+template MGSmoother::MGSmoother (const MGDoFHandler<deal_II_dimension>&, unsigned int);
 #endif
+
+template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<deal_II_dimension> &mg_dof,
+                                     const MGMatrix& matrix, unsigned int steps);
+
index f17272409f31c893473d0950384381aafa06ab79..8578b44254fbc2ac0f9abc8e8bdb670e2847c00b 100644 (file)
@@ -7,6 +7,8 @@
 #include <grid/tria_iterator.h>
 #include <fe/fe.h>
 #include <numerics/multigrid.h>
+#include <numerics/multigrid.templates.h>
+#include <numerics/mg_smoother.h>
 #include <lac/vector.h>
 
 
@@ -15,19 +17,19 @@ MultiGridBase::~MultiGridBase ()
 
 
 
-MultiGridBase::MultiGridBase(MGTransferBase& transfer,
-                            unsigned maxlevel, unsigned minlevel,
-                            unsigned pre_smooth, unsigned post_smooth)
+MultiGridBase::MultiGridBase(const MGTransferBase& transfer,
+                            unsigned maxlevel, unsigned minlevel)
                :
                d(maxlevel-minlevel),
                s(maxlevel-minlevel),
-               maxlevel(maxlevel), minlevel(minlevel),
                transfer(&transfer),
-               n_pre_smooth(pre_smooth), n_post_smooth(post_smooth)
+               maxlevel(maxlevel), minlevel(minlevel)
 {}
 
 void
-MultiGridBase::level_mgstep(unsigned level, MGSmoother& smoother)
+MultiGridBase::level_mgstep(unsigned level,
+                           const MGSmootherBase& pre_smooth,
+                           const MGSmootherBase& post_smooth)
 {
   if (level == minlevel)
     {
@@ -36,7 +38,7 @@ MultiGridBase::level_mgstep(unsigned level, MGSmoother& smoother)
     }
   
                                   // smoothing of the residual by modifying s
-//  smooth(level, d[level], s[level], n_pre_smooth);
+  pre_smooth.smooth(level, s[level], d[level]);
 
                                   // t = d-As
   level_residual(level, t, s[level], d[level]);
@@ -44,12 +46,12 @@ MultiGridBase::level_mgstep(unsigned level, MGSmoother& smoother)
                                   // make t rhs of lower level
   transfer->restrict(level, t, d[level-1]);
                                   // do recursion
-  level_mgstep(level-1, smoother);
+  level_mgstep(level-1, pre_smooth, post_smooth);
                                   // do coarse grid correction
   transfer->prolongate(level, s[level], s[level-1]);
 
                                   // smoothing (modify s again)
-//  post_smooth(level, d[level], s[level], n_post_smooth);
+  post_smooth.smooth(level, s[level], d[level]);
 }
 
 
@@ -223,4 +225,4 @@ void MGTransferPrebuilt::restrict (const unsigned int   from_level,
 template
 void MGTransferPrebuilt::build_matrices (const MGDoFHandler<deal_II_dimension> &mg_dof);
 
-
+template MultiGrid<deal_II_dimension>;
index bc6a227a858898f439d05c9ff8c5d3250ed0e493..98fe594fca71dd24829aaa509a225dcdb0543c19 100644 (file)
@@ -5,6 +5,7 @@
 #include <grid/mg_dof_accessor.h>
 #include <grid/tria_iterator.h>
 #include <fe/fe.h>
+#include <numerics/multigrid.h>
 #include <numerics/mg_smoother.h>
 #include <lac/vector.h>
 
@@ -13,7 +14,9 @@
 
 #if deal_II_dimension == 1
 
-MGSmoother::MGSmoother (const MGDoFHandler<1> &/*mg_dof*/) 
+MGSmoother::MGSmoother (const MGDoFHandler<1> &/*mg_dof*/, unsigned int steps)
+               :
+               steps(steps)
 {
   Assert (false, ExcNotImplemented());
 };
@@ -24,7 +27,9 @@ MGSmoother::MGSmoother (const MGDoFHandler<1> &/*mg_dof*/)
 #if deal_II_dimension > 1
 
 template <int dim>
-MGSmoother::MGSmoother (const MGDoFHandler<dim> &mg_dof) 
+MGSmoother::MGSmoother (const MGDoFHandler<dim> &mg_dof, unsigned int steps)
+               :
+               steps(steps)
 {
   const unsigned int n_levels = mg_dof.get_tria().n_levels();
   
@@ -83,12 +88,12 @@ MGSmoother::MGSmoother (const MGDoFHandler<dim> &mg_dof)
 
 #endif
 
+//////////////////////////////////////////////////////////////////////
 
-
-MGSmoother::~MGSmoother () 
+MGSmootherBase::~MGSmootherBase () 
 {};
 
-
+//////////////////////////////////////////////////////////////////////
 
 void
 MGSmoother::set_zero_interior_boundary (const unsigned int  level,
@@ -102,22 +107,32 @@ MGSmoother::set_zero_interior_boundary (const unsigned int  level,
       u(*p) = 0;
 };
 
+//////////////////////////////////////////////////////////////////////
 
-
+template<int dim>
+MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
+                            const MGMatrix& matrix,
+                            unsigned int steps)
+               :
+               MGSmoother(mg_dof, steps),
+               matrix(&matrix)
+{}
 
 void
-MGSmoother::post_smooth (const unsigned int  level,
-                        Vector<float>      &u) const
+MGSmootherSOR::smooth (const unsigned int   /*level*/,
+                      Vector<float>       &/*u*/,
+                      const Vector<float> &/*rhs*/) const
 {
-  pre_smooth (level, u);
-};
-
-
 
+}
 
 // explicit instantiations
 // don't do the following instantiation in 1d, since there is a specialized
 // function there
 #if deal_II_dimension > 1
-template MGSmoother::MGSmoother (const MGDoFHandler<deal_II_dimension>&);
+template MGSmoother::MGSmoother (const MGDoFHandler<deal_II_dimension>&, unsigned int);
 #endif
+
+template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<deal_II_dimension> &mg_dof,
+                                     const MGMatrix& matrix, unsigned int steps);
+
index f17272409f31c893473d0950384381aafa06ab79..8578b44254fbc2ac0f9abc8e8bdb670e2847c00b 100644 (file)
@@ -7,6 +7,8 @@
 #include <grid/tria_iterator.h>
 #include <fe/fe.h>
 #include <numerics/multigrid.h>
+#include <numerics/multigrid.templates.h>
+#include <numerics/mg_smoother.h>
 #include <lac/vector.h>
 
 
@@ -15,19 +17,19 @@ MultiGridBase::~MultiGridBase ()
 
 
 
-MultiGridBase::MultiGridBase(MGTransferBase& transfer,
-                            unsigned maxlevel, unsigned minlevel,
-                            unsigned pre_smooth, unsigned post_smooth)
+MultiGridBase::MultiGridBase(const MGTransferBase& transfer,
+                            unsigned maxlevel, unsigned minlevel)
                :
                d(maxlevel-minlevel),
                s(maxlevel-minlevel),
-               maxlevel(maxlevel), minlevel(minlevel),
                transfer(&transfer),
-               n_pre_smooth(pre_smooth), n_post_smooth(post_smooth)
+               maxlevel(maxlevel), minlevel(minlevel)
 {}
 
 void
-MultiGridBase::level_mgstep(unsigned level, MGSmoother& smoother)
+MultiGridBase::level_mgstep(unsigned level,
+                           const MGSmootherBase& pre_smooth,
+                           const MGSmootherBase& post_smooth)
 {
   if (level == minlevel)
     {
@@ -36,7 +38,7 @@ MultiGridBase::level_mgstep(unsigned level, MGSmoother& smoother)
     }
   
                                   // smoothing of the residual by modifying s
-//  smooth(level, d[level], s[level], n_pre_smooth);
+  pre_smooth.smooth(level, s[level], d[level]);
 
                                   // t = d-As
   level_residual(level, t, s[level], d[level]);
@@ -44,12 +46,12 @@ MultiGridBase::level_mgstep(unsigned level, MGSmoother& smoother)
                                   // make t rhs of lower level
   transfer->restrict(level, t, d[level-1]);
                                   // do recursion
-  level_mgstep(level-1, smoother);
+  level_mgstep(level-1, pre_smooth, post_smooth);
                                   // do coarse grid correction
   transfer->prolongate(level, s[level], s[level-1]);
 
                                   // smoothing (modify s again)
-//  post_smooth(level, d[level], s[level], n_post_smooth);
+  post_smooth.smooth(level, s[level], d[level]);
 }
 
 
@@ -223,4 +225,4 @@ void MGTransferPrebuilt::restrict (const unsigned int   from_level,
 template
 void MGTransferPrebuilt::build_matrices (const MGDoFHandler<deal_II_dimension> &mg_dof);
 
-
+template MultiGrid<deal_II_dimension>;
index eb9d17129e89710d65e97eaef39d73979c2edf71..24f07b2f3b3e61579961f6a90d763445dd7e559b 100644 (file)
@@ -16,8 +16,10 @@ extern int yydebug;
 %x LINECOMMENT
 %x EXC_IGNORE
 %x INSTRING
+%x INFUNCTION
+%x BASEINIT
 
-NAME  [a-zA-Z][_a-zA-Z0-9]*
+NAME  [_a-zA-Z][_a-zA-Z0-9]*
 INT   [+-]?[0-9]+
 WHITE [ \t\n\f\v]
 CLASS (class)|(struct)|(union)
@@ -49,9 +51,21 @@ DeclException[0-9]  { return(DECLEXCEPTION); }
 <LINECOMMENT>.
 <LINECOMMENT>\n     { yy_pop_state(); }
 
+ /* Ignore function bodies */
+
+<INFUNCTION>"{" { yy_push_state(INFUNCTION); }
+<INFUNCTION>"}" { yy_pop_state(); }
+<INFUNCTION>.
+<INFUNCTION>\n
+
+ /* Ignore base initializers */
+<BASEINIT>"{" { yy_pop_state(); yy_push_state(INFUNCTION); }
+<BASEINIT>.
+<BASEINIT>\n
+
  /* Ignore preprocessor commands */
 
-^#.*\n
+^#.*(\\\n.*)*\n
 
  /* Ignore friend declarations so far */
 
@@ -69,6 +83,7 @@ template { return TEMPLATE; }
 enum     { return ENUM; }
 friend   { return FRIEND; }
 typedef  { return TYPEDEF; }
+namespace { return NAMESPACE; }
 typename {}
 
 {CLASS}  { yylval = string(yytext); return CLASS; }
@@ -92,5 +107,15 @@ typename {}
              cerr << "[" << yylval << "]"; return IDENTIFIER; }
 . { yylval = string(yytext); return yytext[0]; }
 
+"..."    { yylval = string(yytext); return THREEDOTS; }
 %%
 
+void enterfunction()
+{
+  yy_push_state(INFUNCTION);
+}
+
+void enterbaseinitializers()
+{
+  yy_push_state(BASEINIT);
+}
index 18e7fd0c33b656e2da771401b04292740dea8781..c8d0bafd2dcf9f3662dd759a2b6107f9dfc1ddab 100644 (file)
@@ -12,7 +12,8 @@ stack<string> class_stack;
 stack<string> access_stack;
 
 int yylex();
-void yy_push_fargs();
+void enterfunction();
+void enterbaseinitializers();  
 
 void yyerror(const char* s)
   {
@@ -20,6 +21,7 @@ void yyerror(const char* s)
   }
 %}
 
+%token NAMESPACE
 %token CLASS
 %token TYPEDEF
 %token ACCESS
@@ -42,6 +44,7 @@ void yyerror(const char* s)
 %token COMTEMP
 %token DECLEXCEPTION
 %token INLINE
+%token THREEDOTS
 %token ENDOFDECL
 %%
 
@@ -52,49 +55,56 @@ all:  declaration_list
 
 declaration_list: declaration
   | declaration_list { cout << "@@@" << endl; } declaration
+  | NAMESPACE '{' declaration_list '}' ';'
   | declaration_list ';'
 ;
 
 declaration:
   class_declaration ';'
+  | function_declaration '{' { enterfunction(); }
+  | function_declaration ':' { enterbaseinitializers(); }
   | function_declaration ';'
-  | function_declaration '{' '}' ';'
-  | function_declaration '{' '}'
   | variable_declaration ';'
   | enum_declaration ';'
   | typedef_declaration ';'
   | template_declaration class_declaration ';'
-    { cout << setw(OUTW) << "Template-Description:" << $1 << endl; }
+    { cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
   | template_declaration function_declaration ';'
-    { cout << setw(OUTW) << "Template-Description:" << $1 << endl; }
+    { cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
+  | template_declaration function_declaration '{' { enterfunction(); 
+      cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
+  | template_declaration function_declaration ':' { enterbaseinitializers(); 
+      cout << setw(OUTW) << "@Template-Description:" << $1 << endl; }
   | deal_exception_declaration ';'
+  | ';'
 ;
 
 variable_declaration:
   vartype identifier
-    { cout << setw(OUTW) << "Variable-Declaration:" << $2 << endl
-          << setw(OUTW) << "Type:" << $1 << endl
-          << setw(OUTW) << "In-Class:" << class_stack.top() << endl
-          << setw(OUTW) << "Access:" << access_stack.top() << endl; }
+    { cout << setw(OUTW) << "@Variable-Declaration:" << $2 << endl
+          << setw(OUTW) << "@Type:" << $1 << endl
+          << setw(OUTW) << "@In-Class:" << class_stack.top() << endl
+          << setw(OUTW) << "@Access:" << access_stack.top() << endl; }
   | vartype identifier array_dimensions
-    { cout << setw(OUTW) << "Variable-Declaration:" << $2 << endl
-          << setw(OUTW) << "Type:" << $1 << endl
-          << setw(OUTW) << "In-Class:" << class_stack.top() << endl
-          << setw(OUTW) << "Access:" << access_stack.top() << endl
-          << setw(OUTW) << "Array-Dimension:" << $3 << endl; }
+    { cout << setw(OUTW) << "@Variable-Declaration:" << $2 << endl
+          << setw(OUTW) << "@Type:" << $1 << endl
+          << setw(OUTW) << "@In-Class:" << class_stack.top() << endl
+          << setw(OUTW) << "@Access:" << access_stack.top() << endl
+          << setw(OUTW) << "@Array-Dimension:" << $3 << endl; }
   | variable_declaration '=' expression
+/*  | enum_declaration identifier*/
 ;
 
 typedef_declaration:
     TYPEDEF vartype identifier
-      { cout << setw(OUTW) << "Typedef:" << $3 << endl
-            << setw(OUTW) << "Type:" << $2 << endl
-            << setw(OUTW) << "Access:" << access_stack.top() << endl; }
+      { cout << setw(OUTW) << "@Typedef:" << $3 << endl
+            << setw(OUTW) << "@Type:" << $2 << endl
+            << setw(OUTW) << "@Access:" << access_stack.top() << endl; }
     | TYPEDEF vartype identifier array_dimensions
-      { cout << setw(OUTW) << "Typedef:" << $3 << endl
-            << setw(OUTW) << "Type:" << $2 << endl
-            << setw(OUTW) << "Access:" << access_stack.top() << endl
-            << setw(OUTW) << "Array-Dimension:" << $4 << endl; }
+      { cout << setw(OUTW) << "@Typedef:" << $3 << endl
+            << setw(OUTW) << "@Type:" << $2 << endl
+            << setw(OUTW) << "@Access:" << access_stack.top() << endl
+            << setw(OUTW) << "@Array-Dimension:" << $4 << endl; }
 ;
 
 array_dimensions:
@@ -107,22 +117,22 @@ array_dimensions:
 function_declaration:
   function_name argument_declaration
     {
-      cout << setw(OUTW) << "Function-Definition:" << $1 << endl
-          << setw(OUTW) << "Function-Parameters:" << $2 << endl
-          << setw(OUTW) << "In-Class:" << class_stack.top() << endl
-          << setw(OUTW) << "Access:" << access_stack.top() << endl;
+      cout << setw(OUTW) << "@Function-Definition:" << $1 << endl
+          << setw(OUTW) << "@Function-Parameters:" << $2 << endl
+          << setw(OUTW) << "@In-Class:" << class_stack.top() << endl
+          << setw(OUTW) << "@Access:" << access_stack.top() << endl;
     }
   | function_name argument_declaration CONST
     {
-      cout << setw(OUTW) << "Function-Definition:" << $1 << endl
-          << setw(OUTW) << "Function-Parameters:" << $2 << endl
-          << setw(OUTW) << "Const:" << "const" << endl
-          << setw(OUTW) << "In-Class:" << class_stack.top() << endl
-          << setw(OUTW) << "Access:" << access_stack.top() << endl;
+      cout << setw(OUTW) << "@Function-Definition:" << $1 << endl
+          << setw(OUTW) << "@Function-Parameters:" << $2 << endl
+          << setw(OUTW) << "@Const:" << "const" << endl
+          << setw(OUTW) << "@In-Class:" << class_stack.top() << endl
+          << setw(OUTW) << "@Access:" << access_stack.top() << endl;
     }
   | vartype function_declaration
     {
-      cout << setw(OUTW) << "Return-Type:" << $1 << endl;
+      cout << setw(OUTW) << "@Return-Type:" << $1 << endl;
     }
 ;
 
@@ -131,7 +141,7 @@ function_name:
   | '~' identifier { $$ = string("~") + $2; }
   | OPERATOR operator { $$ = string("operator") + $2; }
   | OPERATOR vartype { $$ = string("operator") + $2; }
-  
+  | identifier ':' ':' function_name { $$ = $1 + string("::") + $4; }
 ;
 
 operator: OP
@@ -147,6 +157,7 @@ operator: OP
 
 argument_declaration:
   '(' ')' { $$ = string(""); }
+  | '(' THREEDOTS ')' { $$ = $2; }
   | '(' arguments ')'
     { $$ = $2; }
 ;
@@ -193,8 +204,8 @@ class_declaration: class_head
     {
       class_stack.pop();
       access_stack.pop();
-      cout << "@@@" << endl << setw(OUTW) << "Class-Definition:" << $1 << endl
-          << setw(OUTW) << "In-Class:" << class_stack.top() << endl;
+      cout << "@@@" << endl << setw(OUTW) << "@Class-Definition:" << $1 << endl
+          << setw(OUTW) << "@In-Class:" << class_stack.top() << endl;
     }
 ;
 
@@ -231,11 +242,11 @@ member_declaration:
   declaration
   | VIRTUAL declaration
     {
-      cout << setw(OUTW) << "Virtual:" << "virtual" << endl;
+      cout << setw(OUTW) << "@Virtual:" << "virtual" << endl;
     }
   | VIRTUAL function_declaration '=' INT
     {
-      cout << setw(OUTW) << "Virtual:" << "pure" << endl;
+      cout << setw(OUTW) << "@Virtual:" << "pure" << endl;
     }
   | ACCESS ':' { access_stack.top() = $1; }
   | friend_declaration
@@ -250,7 +261,7 @@ vartype:
   identifier { $$ = $1; }
   | UNSIGNED IDENTIFIER { $$ = string("unsigned ") + $2; }
   | CONST vartype { $$ = string("const ") + $2; }
-/*  | vartype CONST { $$ = $1 +  string(" const"); } */
+  | vartype '*' CONST { $$ = $1 +  string("* const"); }
   | vartype '&' { $$ = $1 + string("&"); }
   | vartype '*' { $$ = $1 + string("*"); }
   | STATIC vartype { $$ = string("static ") + $2; }
@@ -276,6 +287,7 @@ expression:
   | expression OP expression { $$ = $1 + $2 + $3; }
   | expression INT { $$ = $1 + $2; }
   | identifier argument_declaration { $$ = $1 + $2; }
+  | '(' expression ')' { $$ = $1 + $2 + $3; }
 ;
 
 literal:
@@ -300,10 +312,15 @@ template_arg:
   | CLASS IDENTIFIER { $$ = $1 + SPC + $2; }
 ;
 
-template_declaration:
+template_statement:
   TEMPLATE '<' arguments '>' { $$ = $3; }
 ;
 
+template_declaration:
+  template_statement
+  | template_declaration template_statement { $$ = $1 + $2; }
+;
+
 deal_exception_declaration:
   DECLEXCEPTION '(' IDENTIFIER deal_exception_arglist ')'
 ;
index 725e6743f9b5660013c4dacd726b2012e0229d96..03e1b8d536a57a6e31bbe0a35afae49ebc9a7c72 100644 (file)
@@ -36,7 +36,7 @@ print_fe_statistics(const FiniteElement<dim>& fe)
   DoFHandler<dim> dof(&tr);
   dof.distribute_dofs(fe);
   StraightBoundary<dim> boundary;
-  DoFHandler<dim>::active_cell_iterator cell = dof.begin_active();
+//  DoFHandler<dim>::active_cell_iterator cell = dof.begin_active();
   DoFHandler<dim>::active_face_iterator face = dof.begin_active_face();
 
   vector<Point<dim> > unit_points(fe.total_dofs);
index 0497bec99beceb7cfbd1a06cdb40679bd05af86e..8c2efd4f32c42fbeb5085ef3291a7bae75969e7b 100644 (file)
@@ -4,6 +4,7 @@
 // deal_II_libraries=-ldeal_II_2d
 
 #include <numerics/multigrid.h>
+#include <numerics/mg_smoother.h>
 
 class TransferTest
   :
@@ -18,13 +19,27 @@ class TransferTest
     friend class MultiGridBase;
 };
 
+class SmoothTest
+  :
+  public MGSmootherBase
+{
+  public:
+        virtual void smooth (const unsigned int  level,
+                            Vector<float>      &u,
+                            const Vector<float>& rhs) const;
+};
+
+
 class MGTest
   :
   public MultiGridBase
 {
+    MGSmootherBase& smoother;
+    
   public:
-    MGTest(TransferTest& t)
-                   : MultiGridBase(t, 9, 3, 2, 4)
+    MGTest(TransferTest& t, SmoothTest& s)
+                   : MultiGridBase(t, 9, 3),
+                     smoother(s)
       {}
     
     virtual void level_residual(unsigned level,
@@ -32,20 +47,17 @@ class MGTest
                                const Vector<float>& src,
                                const Vector<float>& rhs);
     
-    virtual void smooth(unsigned level,
-                       Vector<float>& x,
-                       const Vector<float>& b,
-                       unsigned steps);
     void doit()
       {
-       level_mgstep(9);
+       level_mgstep(9, smoother, smoother);
       }
 };
 
 main()
 {
   TransferTest tr;
-  MGTest mg(tr);
+  SmoothTest s;
+  MGTest mg(tr, s);
   mg.doit();
   
 }
@@ -66,6 +78,14 @@ TransferTest::restrict(unsigned l,
   cout << "Restricting  " << l << " to " << l-1 << endl;
 }
 
+void
+SmoothTest::smooth (const unsigned int  level,
+                   Vector<float>      &,
+                   const Vector<float>&) const
+{
+  cout << "Smoothing on" << level << endl;
+}
+
 void
 MGTest::level_residual(unsigned l,
                       Vector<float>&,
@@ -74,12 +94,3 @@ MGTest::level_residual(unsigned l,
 {
   cout << "Residual on  " << l << endl;
 }
-
-void
-MGTest::smooth(unsigned l,
-              Vector<float>&,
-              const Vector<float>&,
-              unsigned steps)
-{
-  cout << "Smooth on    " << l << " : " << steps << " steps" << endl;
-}

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.