]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
more multigrid
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 30 Apr 1999 11:44:21 +0000 (11:44 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 30 Apr 1999 11:44:21 +0000 (11:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@1235 0785d39b-7218-0410-832d-ea1e28bc413d

14 files changed:
deal.II/deal.II/include/multigrid/mg_smoother.h
deal.II/deal.II/include/multigrid/multigrid.h
deal.II/deal.II/include/multigrid/multigrid.templates.h
deal.II/deal.II/include/numerics/matrices.h
deal.II/deal.II/include/numerics/mg_smoother.h
deal.II/deal.II/include/numerics/multigrid.h
deal.II/deal.II/include/numerics/multigrid.templates.h
deal.II/deal.II/source/multigrid/mg_smoother.cc
deal.II/deal.II/source/multigrid/multigrid.cc
deal.II/deal.II/source/numerics/assembler.cc
deal.II/deal.II/source/numerics/equation.cc [new file with mode: 0644]
deal.II/deal.II/source/numerics/matrices.cc
deal.II/deal.II/source/numerics/mg_smoother.cc
deal.II/deal.II/source/numerics/multigrid.cc

index 9f49892d2b08ea98c55298a0e92846c5451e6cec..1016d092c56ed727e4fa77ef367b121a8bce0b46 100644 (file)
@@ -6,44 +6,12 @@
 
 
 #include <lac/forward-declarations.h>
+#include <lac/mgbase.h>
 #include <basic/forward-declarations.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;
-
-};
-
 /**
  * Base class for multigrid smoothers. It declares the interface
  * to smoothers by inheriting #MGSmootherBase# and implements some functionality for setting
@@ -142,6 +110,29 @@ class MGSmoother
     vector<vector<int> > interior_boundary_dofs;
 };
 
+/**
+ * Smoother doing nothing.
+ * @author Guido Kanschat, 1999
+ */
+class MGSmootherIdentity
+  :
+  public MGSmoother
+{
+  public:
+                                    /**
+                                     * Constructor.
+                                     */
+    template<int dim>
+    MGSmootherIdentity(const MGDoFHandler<dim> &mg_dof);
+                                    /**
+                                     * Implementation of the interface in #MGSmootherBase#.
+                                     * This function does nothing.
+                                     */
+    virtual void smooth (const unsigned int   level,
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const;
+};
+
 /**
  * Implementation of an SOR smoother.
  *
@@ -166,7 +157,7 @@ class MGSmootherSOR
 
     template<int dim>
     MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
-                 const MGMatrix& matrix,
+                 const MGMatrix<SparseMatrix<float> >& matrix,
                  unsigned int steps);
     
                                     /**
@@ -181,7 +172,7 @@ class MGSmootherSOR
                                     /**
                                      * Pointer to the matrices.
                                      */
-    SmartPointer< const MGMatrix > matrix;
+    SmartPointer< const MGMatrix< SparseMatrix<float> > > matrix;
 };
 
 inline
@@ -198,7 +189,6 @@ MGSmoother::get_steps() const
   return steps;
 }
 
-
 /*----------------------------   mg_smoother.h     ---------------------------*/
 /* end of #ifndef __mg_smoother_H */
 #endif
index 942166e8cd6f5c738e8e258f650b7d0088611204..916e2e7c6bc099123a7f99428c6b3d06143c1736 100644 (file)
 #include <basic/forward-declarations.h>
 #include <lac/sparsematrix.h>
 #include <lac/vector.h>
+#include <lac/mgbase.h>
 
 #include <vector>
-class MGTransferBase;
-class MGSmootherBase;
-
-
-/**
- * Basic matrix class for multigrid preconditioning.
- *
- * This matrix may be used in the iterative methods of LAC, where the
- * functions #vmult# and #precondition# and possibly their transposed
- * versions are needed.
- *
- * The functionality of the multigrid method is restricted to defect
- * correction. It is <B>not</B> iterative and the start solution is
- * always zero. Since by this <I>u<SUP>E</SUP><SUB>l</SUB></I> and
- * <I>u<SUP>A</SUP><SUB>l</SUB></I> (see report on multigrid) are
- * always zero, restriction is simplified a lot and maybe even the
- * seam condition on grids is oblivious. Still, I am not sure that
- * these restrictions on the class might cause numerical
- * inefficiencies.
- *
- * The function #precondition# is the actual multigrid method and
- * makes use of several operations to be implemented in derived
- * classes. It takes a defect in #src# and the result is the multigrid
- * preconditioned defect in #dst#.
- *
- * @author Guido Kanschat, 1999
- * */
-class MultiGridBase
-{
-    MultiGridBase(const MultiGridBase&);
-    const MultiGridBase& operator=(const MultiGridBase&);
-    
-                                    /**
-                                     * Auxiliary vector, defect.
-                                     */
-    vector<Vector<float> > d;
-
-                                    /**
-                                     * Auxiliary vector, solution.
-                                     */
-    vector<Vector<float> > s;
-
-                                    /**
-                                     * Auxiliary vector.
-                                     */
-    Vector<float> t;
-    
-                                    /**
-                                     * Prolongation and restriction object.
-                                     */
-    SmartPointer<const MGTransferBase> transfer;
-    
-  protected:
-                                    /**
-                                     * Highest level of cells.
-                                     */
-    unsigned int maxlevel;
-
-                                    /**
-                                     * Level for coarse grid solution.
-                                     */
-    unsigned int minlevel;
-
-                                    /**
-                                     * The actual v-cycle multigrid method.
-                                     * This function is called on the
-                                     * highest level and recursively
-                                     * invokes itself down to the
-                                     * coarsest. There, it calls
-                                     * #coarse_grid_solution# and
-                                     * proceeds back up.
-                                     */
-    void level_mgstep(unsigned int level,
-                     const MGSmootherBase& pre_smooth,
-                     const MGSmootherBase& post_smooth);  
-
-                                    /**
-                                     * Apply residual operator on all
-                                     * cells of a level.
-                                     * This is implemented in a
-                                     * derived class.
-                                     */
-    virtual void level_residual(unsigned int level,
-                            Vector<float>& dst,
-                            const Vector<float>& src,
-                            const Vector<float>& rhs) = 0;
-
-                                    /**
-                                     * Solve exactly on coarsest grid.
-                                     * Usually, this function should
-                                     * be overloaded by a more
-                                     * sophisticated derived
-                                     * class. Still, there is a
-                                     * standard implementation doing
-                                     * #10 * (n_pre_smooth +
-                                     * n_post_smooth)#
-                                     * smoothing steps of #pre_smooth#.
-                                     */
-    virtual void coarse_grid_solution(unsigned int l,
-                                     Vector<float>& dst,
-                                     const Vector<float>& src);
-  
-
-  
-
-  
-  public:
-                                    /**
-                                     * Constructor, subject to change.
-                                     */
-    MultiGridBase(const MGTransferBase& transfer,
-                 unsigned int maxlevel, unsigned int minlevel);
-    virtual ~MultiGridBase();
-    
-};
-
-
-
-/**
- * Base class used to declare the operations needed by a concrete class
- * implementing prolongation and restriction of vectors in the multigrid
- * context. This class is an abstract one and has no implementations of
- * possible algorithms for these operations.
- *
- * @author Wolfgang Bangerth, Guido Kanschat, 1999
- */
-class MGTransferBase  :  public Subscriptor
-{
-  public:
-                                    /**
-                                     * Destructor. Does nothing here, but
-                                     * needs to be declared virtual anyway.
-                                     */
-    virtual ~MGTransferBase();
-
-                                    /**
-                                     * Prolongate a vector from level
-                                     * #to_level-1# to level #to_level#.
-                                     *
-                                     * #src# is assumed to be a vector with
-                                     * as many elements as there are degrees
-                                     * of freedom on the coarser level of
-                                     * the two involved levels, while #src#
-                                     * shall have as many elements as there
-                                     * are degrees of freedom on the finer
-                                     * level.
-                                     */
-    virtual void prolongate (const unsigned int   to_level,
-                            Vector<float>       &dst,
-                            const Vector<float> &src) const = 0;
-
-                                    /**
-                                     * Restrict a vector from level
-                                     * #from_level# to level
-                                     * #from_level-1#.
-                                     *
-                                     * #src# is assumed to be a vector with
-                                     * as many elements as there are degrees
-                                     * of freedom on the finer level of
-                                     * the two involved levels, while #src#
-                                     * shall have as many elements as there
-                                     * are degrees of freedom on the coarser
-                                     * level.
-                                     */
-    virtual void restrict (const unsigned int   from_level,
-                          Vector<float>       &dst,
-                          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,
+ * While #MGBase# was only an abstract framework for the v-cycle,
  * here we have the implementation of the pure virtual functions defined there.
  * Furthermore, level information is obtained from a triangulation object.
  * 
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
 template<int dim>
-class MultiGrid
+class MG
   :
-  public MultiGridBase
+  public MGBase
 {
   public:
-    MultiGrid(const MGDoFHandler<dim>&, const MGTransferBase& transfer);
+    MG(const MGDoFHandler<dim>&, const MGTransferBase& transfer);
     
                                     /** Transfer from dVector to
                                      * MGVector.
@@ -277,7 +86,7 @@ class MultiGrid
                                     /**
                                      * Matrix structures for each level.
                                      * These are generated by the constructor
-                                     * of #MultiGrid# and can be accessed
+                                     * of #MG# and can be accessed
                                      * later.
                                      */
     vector<SparseMatrixStruct> matrix_structures;
@@ -285,7 +94,7 @@ class MultiGrid
                                     /**
                                      * Matrices for each level.
                                      * The matrices are prepared by
-                                     * the constructor of #MultiGrid# and can
+                                     * the constructor of #MG# and can
                                      * be accessed for assembling.
                                      */
     vector<SparseMatrix<float> > matrices;
@@ -365,10 +174,11 @@ class MGTransferPrebuilt : public MGTransferBase
     vector<SparseMatrix<float> > prolongation_matrices;
 };
 
+
 template<int dim>
 inline
 SparseMatrix<float>&
-MultiGrid<dim>::get_matrix(unsigned int level)
+MG<dim>::get_matrix(unsigned int level)
 {
   Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
   
@@ -378,7 +188,7 @@ MultiGrid<dim>::get_matrix(unsigned int level)
 template<int dim>
 inline
 const SparseMatrix<float>&
-MultiGrid<dim>::get_matrix(unsigned int level) const
+MG<dim>::get_matrix(unsigned int level) const
 {
   Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
   
@@ -386,7 +196,6 @@ MultiGrid<dim>::get_matrix(unsigned int level) const
 }
 
 
-
 /*----------------------------   multigrid.h     ---------------------------*/
 /* end of #ifndef __multigrid_H */
 #endif
index 2750ff8927bf20acbb5ebf9d9ee089c8cd144e01..d290cd72238bbeac47163282ebc8d0cede109ac0 100644 (file)
@@ -8,9 +8,9 @@ MultiGrid::
 */
 
 template <int dim>
-MultiGrid<dim>::MultiGrid(const MGDoFHandler<dim>& dofs, const MGTransferBase& transfer)
+MG<dim>::MG(const MGDoFHandler<dim>& dofs, const MGTransferBase& transfer)
                :
-               MultiGridBase(transfer, 0, dofs.get_tria().n_levels()-1),
+               MGBase(transfer, 0, dofs.get_tria().n_levels()-1),
                dofs(&dofs),
                matrix_structures(maxlevel-minlevel),
                matrices(maxlevel-minlevel)
@@ -24,7 +24,7 @@ MultiGrid<dim>::MultiGrid(const MGDoFHandler<dim>& dofs, const MGTransferBase& t
 
 template <int dim> template <typename number>
 void
-MultiGrid<dim>::copy_to_mg(vector<Vector<float> >& dst,
+MG<dim>::copy_to_mg(vector<Vector<float> >& dst,
                           const Vector<number>& src) const
 {
 
@@ -32,7 +32,7 @@ MultiGrid<dim>::copy_to_mg(vector<Vector<float> >& dst,
 
 template <int dim> template <typename number>
 void
-MultiGrid<dim>::copy_from_mg(Vector<number>& dst,
+MG<dim>::copy_from_mg(Vector<number>& dst,
                             const vector<Vector<float> >& src) const
 {
 // active iterator
@@ -41,12 +41,12 @@ MultiGrid<dim>::copy_from_mg(Vector<number>& dst,
 
 /*
 template <int dim>
-MultiGrid::
+MG::
 template <int dim>
-MultiGrid::
+MG::
 template <int dim>
-MultiGrid::
+MG::
 template <int dim>
-MultiGrid::
+MG::
 
 */
index 035520209b8a791d9c9ce51cf3e15c5dea2f4f0c..2917c41584c25b7e50fdde86afe8fefaf1af0601 100644 (file)
  * @author Wolfgang Bangerth, 1998
  */
 template <int dim>
-class MatrixCreator {
+class MatrixCreator
+{
   public:
                                     /**
                                      * Declare a data type which denotes a
@@ -270,6 +271,18 @@ class MatrixCreator {
                                       SparseMatrix<double>     &matrix,
                                       const Function<dim>      *a = 0);
 
+                                    /**
+                                     * Generate Laplace matrix for a given level.
+                                     * 
+                                     * See the general doc of this class
+                                     * for more information.
+                                     */
+    static void create_level_laplace_matrix (unsigned int             level,
+                                            const MGDoFHandler<dim>& dof,
+                                            const Quadrature<dim>&   q,
+                                            SparseMatrix<float>&     matrix,
+                                            const Function<dim>*     a = 0);
+
                                     /**
                                      * Assemble the Laplace matrix and a right
                                      * hand side vector. If no 
index 9f49892d2b08ea98c55298a0e92846c5451e6cec..1016d092c56ed727e4fa77ef367b121a8bce0b46 100644 (file)
@@ -6,44 +6,12 @@
 
 
 #include <lac/forward-declarations.h>
+#include <lac/mgbase.h>
 #include <basic/forward-declarations.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;
-
-};
-
 /**
  * Base class for multigrid smoothers. It declares the interface
  * to smoothers by inheriting #MGSmootherBase# and implements some functionality for setting
@@ -142,6 +110,29 @@ class MGSmoother
     vector<vector<int> > interior_boundary_dofs;
 };
 
+/**
+ * Smoother doing nothing.
+ * @author Guido Kanschat, 1999
+ */
+class MGSmootherIdentity
+  :
+  public MGSmoother
+{
+  public:
+                                    /**
+                                     * Constructor.
+                                     */
+    template<int dim>
+    MGSmootherIdentity(const MGDoFHandler<dim> &mg_dof);
+                                    /**
+                                     * Implementation of the interface in #MGSmootherBase#.
+                                     * This function does nothing.
+                                     */
+    virtual void smooth (const unsigned int   level,
+                        Vector<float>       &u,
+                        const Vector<float> &rhs) const;
+};
+
 /**
  * Implementation of an SOR smoother.
  *
@@ -166,7 +157,7 @@ class MGSmootherSOR
 
     template<int dim>
     MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
-                 const MGMatrix& matrix,
+                 const MGMatrix<SparseMatrix<float> >& matrix,
                  unsigned int steps);
     
                                     /**
@@ -181,7 +172,7 @@ class MGSmootherSOR
                                     /**
                                      * Pointer to the matrices.
                                      */
-    SmartPointer< const MGMatrix > matrix;
+    SmartPointer< const MGMatrix< SparseMatrix<float> > > matrix;
 };
 
 inline
@@ -198,7 +189,6 @@ MGSmoother::get_steps() const
   return steps;
 }
 
-
 /*----------------------------   mg_smoother.h     ---------------------------*/
 /* end of #ifndef __mg_smoother_H */
 #endif
index 942166e8cd6f5c738e8e258f650b7d0088611204..916e2e7c6bc099123a7f99428c6b3d06143c1736 100644 (file)
 #include <basic/forward-declarations.h>
 #include <lac/sparsematrix.h>
 #include <lac/vector.h>
+#include <lac/mgbase.h>
 
 #include <vector>
-class MGTransferBase;
-class MGSmootherBase;
-
-
-/**
- * Basic matrix class for multigrid preconditioning.
- *
- * This matrix may be used in the iterative methods of LAC, where the
- * functions #vmult# and #precondition# and possibly their transposed
- * versions are needed.
- *
- * The functionality of the multigrid method is restricted to defect
- * correction. It is <B>not</B> iterative and the start solution is
- * always zero. Since by this <I>u<SUP>E</SUP><SUB>l</SUB></I> and
- * <I>u<SUP>A</SUP><SUB>l</SUB></I> (see report on multigrid) are
- * always zero, restriction is simplified a lot and maybe even the
- * seam condition on grids is oblivious. Still, I am not sure that
- * these restrictions on the class might cause numerical
- * inefficiencies.
- *
- * The function #precondition# is the actual multigrid method and
- * makes use of several operations to be implemented in derived
- * classes. It takes a defect in #src# and the result is the multigrid
- * preconditioned defect in #dst#.
- *
- * @author Guido Kanschat, 1999
- * */
-class MultiGridBase
-{
-    MultiGridBase(const MultiGridBase&);
-    const MultiGridBase& operator=(const MultiGridBase&);
-    
-                                    /**
-                                     * Auxiliary vector, defect.
-                                     */
-    vector<Vector<float> > d;
-
-                                    /**
-                                     * Auxiliary vector, solution.
-                                     */
-    vector<Vector<float> > s;
-
-                                    /**
-                                     * Auxiliary vector.
-                                     */
-    Vector<float> t;
-    
-                                    /**
-                                     * Prolongation and restriction object.
-                                     */
-    SmartPointer<const MGTransferBase> transfer;
-    
-  protected:
-                                    /**
-                                     * Highest level of cells.
-                                     */
-    unsigned int maxlevel;
-
-                                    /**
-                                     * Level for coarse grid solution.
-                                     */
-    unsigned int minlevel;
-
-                                    /**
-                                     * The actual v-cycle multigrid method.
-                                     * This function is called on the
-                                     * highest level and recursively
-                                     * invokes itself down to the
-                                     * coarsest. There, it calls
-                                     * #coarse_grid_solution# and
-                                     * proceeds back up.
-                                     */
-    void level_mgstep(unsigned int level,
-                     const MGSmootherBase& pre_smooth,
-                     const MGSmootherBase& post_smooth);  
-
-                                    /**
-                                     * Apply residual operator on all
-                                     * cells of a level.
-                                     * This is implemented in a
-                                     * derived class.
-                                     */
-    virtual void level_residual(unsigned int level,
-                            Vector<float>& dst,
-                            const Vector<float>& src,
-                            const Vector<float>& rhs) = 0;
-
-                                    /**
-                                     * Solve exactly on coarsest grid.
-                                     * Usually, this function should
-                                     * be overloaded by a more
-                                     * sophisticated derived
-                                     * class. Still, there is a
-                                     * standard implementation doing
-                                     * #10 * (n_pre_smooth +
-                                     * n_post_smooth)#
-                                     * smoothing steps of #pre_smooth#.
-                                     */
-    virtual void coarse_grid_solution(unsigned int l,
-                                     Vector<float>& dst,
-                                     const Vector<float>& src);
-  
-
-  
-
-  
-  public:
-                                    /**
-                                     * Constructor, subject to change.
-                                     */
-    MultiGridBase(const MGTransferBase& transfer,
-                 unsigned int maxlevel, unsigned int minlevel);
-    virtual ~MultiGridBase();
-    
-};
-
-
-
-/**
- * Base class used to declare the operations needed by a concrete class
- * implementing prolongation and restriction of vectors in the multigrid
- * context. This class is an abstract one and has no implementations of
- * possible algorithms for these operations.
- *
- * @author Wolfgang Bangerth, Guido Kanschat, 1999
- */
-class MGTransferBase  :  public Subscriptor
-{
-  public:
-                                    /**
-                                     * Destructor. Does nothing here, but
-                                     * needs to be declared virtual anyway.
-                                     */
-    virtual ~MGTransferBase();
-
-                                    /**
-                                     * Prolongate a vector from level
-                                     * #to_level-1# to level #to_level#.
-                                     *
-                                     * #src# is assumed to be a vector with
-                                     * as many elements as there are degrees
-                                     * of freedom on the coarser level of
-                                     * the two involved levels, while #src#
-                                     * shall have as many elements as there
-                                     * are degrees of freedom on the finer
-                                     * level.
-                                     */
-    virtual void prolongate (const unsigned int   to_level,
-                            Vector<float>       &dst,
-                            const Vector<float> &src) const = 0;
-
-                                    /**
-                                     * Restrict a vector from level
-                                     * #from_level# to level
-                                     * #from_level-1#.
-                                     *
-                                     * #src# is assumed to be a vector with
-                                     * as many elements as there are degrees
-                                     * of freedom on the finer level of
-                                     * the two involved levels, while #src#
-                                     * shall have as many elements as there
-                                     * are degrees of freedom on the coarser
-                                     * level.
-                                     */
-    virtual void restrict (const unsigned int   from_level,
-                          Vector<float>       &dst,
-                          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,
+ * While #MGBase# was only an abstract framework for the v-cycle,
  * here we have the implementation of the pure virtual functions defined there.
  * Furthermore, level information is obtained from a triangulation object.
  * 
  * @author Wolfgang Bangerth, Guido Kanschat, 1999
  */
 template<int dim>
-class MultiGrid
+class MG
   :
-  public MultiGridBase
+  public MGBase
 {
   public:
-    MultiGrid(const MGDoFHandler<dim>&, const MGTransferBase& transfer);
+    MG(const MGDoFHandler<dim>&, const MGTransferBase& transfer);
     
                                     /** Transfer from dVector to
                                      * MGVector.
@@ -277,7 +86,7 @@ class MultiGrid
                                     /**
                                      * Matrix structures for each level.
                                      * These are generated by the constructor
-                                     * of #MultiGrid# and can be accessed
+                                     * of #MG# and can be accessed
                                      * later.
                                      */
     vector<SparseMatrixStruct> matrix_structures;
@@ -285,7 +94,7 @@ class MultiGrid
                                     /**
                                      * Matrices for each level.
                                      * The matrices are prepared by
-                                     * the constructor of #MultiGrid# and can
+                                     * the constructor of #MG# and can
                                      * be accessed for assembling.
                                      */
     vector<SparseMatrix<float> > matrices;
@@ -365,10 +174,11 @@ class MGTransferPrebuilt : public MGTransferBase
     vector<SparseMatrix<float> > prolongation_matrices;
 };
 
+
 template<int dim>
 inline
 SparseMatrix<float>&
-MultiGrid<dim>::get_matrix(unsigned int level)
+MG<dim>::get_matrix(unsigned int level)
 {
   Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
   
@@ -378,7 +188,7 @@ MultiGrid<dim>::get_matrix(unsigned int level)
 template<int dim>
 inline
 const SparseMatrix<float>&
-MultiGrid<dim>::get_matrix(unsigned int level) const
+MG<dim>::get_matrix(unsigned int level) const
 {
   Assert((level>=minlevel) && (level<maxlevel), ExcIndexRange(level, minlevel, maxlevel));
   
@@ -386,7 +196,6 @@ MultiGrid<dim>::get_matrix(unsigned int level) const
 }
 
 
-
 /*----------------------------   multigrid.h     ---------------------------*/
 /* end of #ifndef __multigrid_H */
 #endif
index 2750ff8927bf20acbb5ebf9d9ee089c8cd144e01..d290cd72238bbeac47163282ebc8d0cede109ac0 100644 (file)
@@ -8,9 +8,9 @@ MultiGrid::
 */
 
 template <int dim>
-MultiGrid<dim>::MultiGrid(const MGDoFHandler<dim>& dofs, const MGTransferBase& transfer)
+MG<dim>::MG(const MGDoFHandler<dim>& dofs, const MGTransferBase& transfer)
                :
-               MultiGridBase(transfer, 0, dofs.get_tria().n_levels()-1),
+               MGBase(transfer, 0, dofs.get_tria().n_levels()-1),
                dofs(&dofs),
                matrix_structures(maxlevel-minlevel),
                matrices(maxlevel-minlevel)
@@ -24,7 +24,7 @@ MultiGrid<dim>::MultiGrid(const MGDoFHandler<dim>& dofs, const MGTransferBase& t
 
 template <int dim> template <typename number>
 void
-MultiGrid<dim>::copy_to_mg(vector<Vector<float> >& dst,
+MG<dim>::copy_to_mg(vector<Vector<float> >& dst,
                           const Vector<number>& src) const
 {
 
@@ -32,7 +32,7 @@ MultiGrid<dim>::copy_to_mg(vector<Vector<float> >& dst,
 
 template <int dim> template <typename number>
 void
-MultiGrid<dim>::copy_from_mg(Vector<number>& dst,
+MG<dim>::copy_from_mg(Vector<number>& dst,
                             const vector<Vector<float> >& src) const
 {
 // active iterator
@@ -41,12 +41,12 @@ MultiGrid<dim>::copy_from_mg(Vector<number>& dst,
 
 /*
 template <int dim>
-MultiGrid::
+MG::
 template <int dim>
-MultiGrid::
+MG::
 template <int dim>
-MultiGrid::
+MG::
 template <int dim>
-MultiGrid::
+MG::
 
 */
index 98fe594fca71dd24829aaa509a225dcdb0543c19..cc16654c94a5eadcf65a2d91d75389e3b4859b82 100644 (file)
@@ -107,11 +107,27 @@ MGSmoother::set_zero_interior_boundary (const unsigned int  level,
       u(*p) = 0;
 };
 
+//////////////////////////////////////////////////////////////////////
+
+
+template<int dim>
+MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler<dim> &mg_dof)
+               :
+               MGSmoother(mg_dof, 0)
+{}
+
+void
+MGSmootherIdentity::smooth (const unsigned int,
+                      Vector<float>       &,
+                           const Vector<float> &) const
+{}
+
+
 //////////////////////////////////////////////////////////////////////
 
 template<int dim>
 MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
-                            const MGMatrix& matrix,
+                            const MGMatrix<SparseMatrix<float> >& matrix,
                             unsigned int steps)
                :
                MGSmoother(mg_dof, steps),
@@ -134,5 +150,8 @@ template MGSmoother::MGSmoother (const MGDoFHandler<deal_II_dimension>&, unsigne
 #endif
 
 template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<deal_II_dimension> &mg_dof,
-                                     const MGMatrix& matrix, unsigned int steps);
+                                     const MGMatrix<SparseMatrix<float> >& matrix,
+                                     unsigned int steps);
+
+template MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler<deal_II_dimension> &mg_dof);
 
index 8578b44254fbc2ac0f9abc8e8bdb670e2847c00b..c969467c8b00f4e9e093acd754ada24b6a61da9c 100644 (file)
 #include <lac/vector.h>
 
 
-MultiGridBase::~MultiGridBase () 
-{};
-
-
-
-MultiGridBase::MultiGridBase(const MGTransferBase& transfer,
-                            unsigned maxlevel, unsigned minlevel)
-               :
-               d(maxlevel-minlevel),
-               s(maxlevel-minlevel),
-               transfer(&transfer),
-               maxlevel(maxlevel), minlevel(minlevel)
-{}
-
-void
-MultiGridBase::level_mgstep(unsigned level,
-                           const MGSmootherBase& pre_smooth,
-                           const MGSmootherBase& post_smooth)
-{
-  if (level == minlevel)
-    {
-      coarse_grid_solution(level, d[level], s[level]);
-      return;
-    }
-  
-                                  // smoothing of the residual by modifying s
-  pre_smooth.smooth(level, s[level], d[level]);
-
-                                  // t = d-As
-  level_residual(level, t, s[level], d[level]);
-  
-                                  // make t rhs of lower level
-  transfer->restrict(level, t, d[level-1]);
-                                  // do recursion
-  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.smooth(level, s[level], d[level]);
-}
-
-
-void
-MultiGridBase::coarse_grid_solution(unsigned /*level*/,
-                                   Vector<float>& /*dst*/,
-                                   const Vector<float>& /*src*/)
-{
-//  smooth(level, dst, src, 10 * (n_pre_smooth + n_post_smooth));
-}
-
-
-
 
 // ab hier Wolfgang
 
@@ -225,4 +172,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>;
+template MG<deal_II_dimension>;
index d6467cc1942657619869771eda9d0ad83b17f1d8..61de39a15afdcd90bc5a4d8697bb2e8e3e42cb07 100644 (file)
 #include <lac/sparsematrix.h>
 
 
-template <int dim>
-Equation<dim>::Equation (const unsigned int n_equations) :
-               n_eq(n_equations) {};
-
-
-
-template <int dim>
-void Equation<dim>::assemble (FullMatrix<double>          &,
-                             Vector<double>           &,
-                             const FEValues<dim> &,
-                             const typename DoFHandler<dim>::cell_iterator &) const {
-  Assert (false, ExcPureVirtualFunctionCalled());
-};
-
-
-
-template <int dim>
-void Equation<dim>::assemble (FullMatrix<double>          &,
-                             const FEValues<dim> &,
-                             const typename DoFHandler<dim>::cell_iterator &) const {
-  Assert (false, ExcPureVirtualFunctionCalled());
-};
-
-
-
-template <int dim>
-void Equation<dim>::assemble (Vector<double>           &,
-                             const FEValues<dim> &,
-                             const typename DoFHandler<dim>::cell_iterator &) const {
-  Assert (false, ExcPureVirtualFunctionCalled());
-};
-
-
-
-
 template <int dim>
 Assembler<dim>::AssemblerData::AssemblerData (const DoFHandler<dim>    &dof,
                                              const bool                assemble_matrix,
diff --git a/deal.II/deal.II/source/numerics/equation.cc b/deal.II/deal.II/source/numerics/equation.cc
new file mode 100644 (file)
index 0000000..ccf0415
--- /dev/null
@@ -0,0 +1,49 @@
+// $Id$
+
+#include <numerics/assembler.h>
+#include <grid/tria_iterator.h>
+#include <grid/tria_iterator.templates.h>
+#include <fe/fe.h>
+#include <lac/fullmatrix.h>
+#include <lac/vector.h>
+#include <lac/sparsematrix.h>
+
+template <int dim>
+Equation<dim>::Equation (const unsigned int n_equations) :
+               n_eq(n_equations) {};
+
+
+
+template <int dim>
+void Equation<dim>::assemble (FullMatrix<double>          &,
+                             Vector<double>           &,
+                             const FEValues<dim> &,
+                             const typename DoFHandler<dim>::cell_iterator &) const
+{
+  Assert (false, ExcPureVirtualFunctionCalled());
+};
+
+
+
+template <int dim>
+void Equation<dim>::assemble (FullMatrix<double>          &,
+                             const FEValues<dim> &,
+                             const typename DoFHandler<dim>::cell_iterator &) const
+{
+  Assert (false, ExcPureVirtualFunctionCalled());
+};
+
+
+
+template <int dim>
+void Equation<dim>::assemble (Vector<double>           &,
+                             const FEValues<dim> &,
+                             const typename DoFHandler<dim>::cell_iterator &) const
+{
+  Assert (false, ExcPureVirtualFunctionCalled());
+};
+
+
+
+
+template class Equation<deal_II_dimension>;
index 9f71473f8f6dd419b0e01f27f42b98c597d959ec..8700e1fda60176bca17db8b0b50b5e45bbbe1730 100644 (file)
@@ -340,7 +340,39 @@ void MatrixCreator<dim>::create_laplace_matrix (const DoFHandler<dim>    &dof,
   while ((++assembler).state() == valid);
 };
 
+/*
 
+template <int dim>
+void MatrixCreator<dim>::create_level_laplace_matrix (unsigned int level,
+                                                     const MGDoFHandler<dim>    &dof,
+                                                     const Quadrature<dim>    &q,
+                                                     SparseMatrix<float>     &matrix,
+                                                     const Function<dim> * const a)
+{
+  Vector<double> dummy;   // no entries, should give an error if accessed
+  UpdateFlags update_flags = UpdateFlags(update_gradients |
+                                        update_JxW_values);
+  if (a != 0)
+    update_flags = UpdateFlags(update_flags | update_q_points);
+  const Assembler<dim>::AssemblerData data (dof,
+                                           true, false,  // assemble matrix but not rhs
+                                           matrix, dummy,
+                                           q, update_flags);
+  TriaIterator<dim, Assembler<dim> >
+    assembler (const_cast<Triangulation<dim>*>(&dof.get_tria()),
+              dof.get_tria().begin(level)->level(),
+              dof.get_tria().begin(level)->index(),
+              &data);
+  LaplaceMatrix<dim> equation (0, a);
+  do 
+    {
+      assembler->assemble (equation);
+      ++assembler
+    }
+  while ( (assembler.state()==valid) && (assembler->level() == level) );
+};
+
+*/
 
 template <int dim>
 void MatrixCreator<dim>::create_laplace_matrix (const DoFHandler<dim>    &dof,
@@ -348,7 +380,8 @@ void MatrixCreator<dim>::create_laplace_matrix (const DoFHandler<dim>    &dof,
                                                SparseMatrix<double>     &matrix,
                                                const Function<dim>      &rhs,
                                                Vector<double>           &rhs_vector,
-                                               const Function<dim> * const a) {
+                                               const Function<dim> * const a)
+{
   UpdateFlags update_flags = UpdateFlags(update_q_points  |
                                         update_gradients |
                                         update_JxW_values);
index 98fe594fca71dd24829aaa509a225dcdb0543c19..cc16654c94a5eadcf65a2d91d75389e3b4859b82 100644 (file)
@@ -107,11 +107,27 @@ MGSmoother::set_zero_interior_boundary (const unsigned int  level,
       u(*p) = 0;
 };
 
+//////////////////////////////////////////////////////////////////////
+
+
+template<int dim>
+MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler<dim> &mg_dof)
+               :
+               MGSmoother(mg_dof, 0)
+{}
+
+void
+MGSmootherIdentity::smooth (const unsigned int,
+                      Vector<float>       &,
+                           const Vector<float> &) const
+{}
+
+
 //////////////////////////////////////////////////////////////////////
 
 template<int dim>
 MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
-                            const MGMatrix& matrix,
+                            const MGMatrix<SparseMatrix<float> >& matrix,
                             unsigned int steps)
                :
                MGSmoother(mg_dof, steps),
@@ -134,5 +150,8 @@ template MGSmoother::MGSmoother (const MGDoFHandler<deal_II_dimension>&, unsigne
 #endif
 
 template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler<deal_II_dimension> &mg_dof,
-                                     const MGMatrix& matrix, unsigned int steps);
+                                     const MGMatrix<SparseMatrix<float> >& matrix,
+                                     unsigned int steps);
+
+template MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler<deal_II_dimension> &mg_dof);
 
index 8578b44254fbc2ac0f9abc8e8bdb670e2847c00b..c969467c8b00f4e9e093acd754ada24b6a61da9c 100644 (file)
 #include <lac/vector.h>
 
 
-MultiGridBase::~MultiGridBase () 
-{};
-
-
-
-MultiGridBase::MultiGridBase(const MGTransferBase& transfer,
-                            unsigned maxlevel, unsigned minlevel)
-               :
-               d(maxlevel-minlevel),
-               s(maxlevel-minlevel),
-               transfer(&transfer),
-               maxlevel(maxlevel), minlevel(minlevel)
-{}
-
-void
-MultiGridBase::level_mgstep(unsigned level,
-                           const MGSmootherBase& pre_smooth,
-                           const MGSmootherBase& post_smooth)
-{
-  if (level == minlevel)
-    {
-      coarse_grid_solution(level, d[level], s[level]);
-      return;
-    }
-  
-                                  // smoothing of the residual by modifying s
-  pre_smooth.smooth(level, s[level], d[level]);
-
-                                  // t = d-As
-  level_residual(level, t, s[level], d[level]);
-  
-                                  // make t rhs of lower level
-  transfer->restrict(level, t, d[level-1]);
-                                  // do recursion
-  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.smooth(level, s[level], d[level]);
-}
-
-
-void
-MultiGridBase::coarse_grid_solution(unsigned /*level*/,
-                                   Vector<float>& /*dst*/,
-                                   const Vector<float>& /*src*/)
-{
-//  smooth(level, dst, src, 10 * (n_pre_smooth + n_post_smooth));
-}
-
-
-
 
 // ab hier Wolfgang
 
@@ -225,4 +172,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>;
+template MG<deal_II_dimension>;

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.