]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
file structure fixed
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 21 Aug 2002 15:18:24 +0000 (15:18 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 21 Aug 2002 15:18:24 +0000 (15:18 +0000)
git-svn-id: https://svn.dealii.org/trunk@6336 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/multigrid/mg_base.h
deal.II/deal.II/include/multigrid/mg_coarse.h [new file with mode: 0644]
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

index cdd8886d03c1ade60c6210661366eb74d6fc23d6..c858ae747e17527dc17e9a6835c21510bf9922cf 100644 (file)
@@ -188,59 +188,6 @@ class MGCoarseGrid : public Subscriptor
 };
 
 
-/**
- * Coarse grid solver using LAC iterative methods.
- * This is a little wrapper, transforming a triplet of iterative
- * solver, matrix and preconditioner into a coarse grid solver.
- *
- * The type of the matrix (i.e. the template parameter @p{MATRIX})
- * should be derived from @p{Subscriptor} to allow for the use of a
- * smart pointer to it.
- *
- * @author Guido Kanschat, 1999
- */
-template<class SOLVER, class MATRIX, class PRECOND, class VECTOR = Vector<double> >
-class MGCoarseGridLACIteration :  public MGCoarseGrid<VECTOR>
-{
-  public:
-                                    /**
-                                     * Constructor.
-                                     * Store solver, matrix and
-                                     * preconditioning method for later
-                                     * use.
-                                     */
-    MGCoarseGridLACIteration (SOLVER        &,
-                             const MATRIX  &,
-                             const PRECOND &);
-    
-                                    /**
-                                     * Implementation of the abstract
-                                     * function.
-                                     * Calls the solver method with
-                                     * matrix, vectors and
-                                     * preconditioner.
-                                     */
-    void operator() (const unsigned int   level,
-                    VECTOR       &dst,
-                    const VECTOR &src) const;
-  private:
-                                    /**
-                                     * Reference to the solver.
-                                     */
-    SOLVER& solver;
-    
-                                    /**
-                                     * Reference to the matrix.
-                                     */
-    const SmartPointer<const MATRIX> matrix;
-    
-                                    /**
-                                     * Reference to the preconditioner.
-                                     */
-    const PRECOND& precondition;
-};
-
-
 /**
  * Base class used to declare the operations needed by a concrete class
  * implementing prolongation and restriction of vectors in the multigrid
@@ -308,6 +255,32 @@ class MGCoarseGridLACIteration :  public MGCoarseGrid<VECTOR>
 
 
 
+/**
+ * Base class for multigrid smoothers. Does nothing but defining the
+ * interface used by multigrid methods.
+ *
+ * @author Guido Kanschat, 2002
+ */
+template <class VECTOR>
+class MGSmoother : public Subscriptor
+{
+  public:
+                                  /**
+                                   * Virtual destructor.
+                                   */
+  virtual ~MGSmoother();
+
+                                  /**
+                                   * Smoothing function. This is the
+                                   * function used in multigrid
+                                   * methods.
+                                   */
+  virtual void smooth (const unsigned int level,
+                      VECTOR&            u,
+                      const VECTOR&      rhs) const = 0;  
+};
+
+
 /* ------------------------------------------------------------------- */
 
 
@@ -400,32 +373,6 @@ MGMatrix<MATRIX, VECTOR>::vmult (unsigned int level,
 }
 
 
-/* ------------------ Functions for MGCoarseGridLACIteration ------------ */
-
-
-template<class SOLVER, class MATRIX, class PRECOND, class VECTOR>
-MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND, VECTOR>
-::MGCoarseGridLACIteration(SOLVER& s,
-                          const MATRIX  &m,
-                          const PRECOND &p)
-               :
-               solver(s),
-               matrix(&m),
-               precondition(p)
-{};
-
-
-template<class SOLVER, class MATRIX, class PRECOND, class VECTOR>
-void
-MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND, VECTOR>
-::operator() (const unsigned int    /* level */,
-             VECTOR       &dst,
-             const VECTOR &src) const
-{
-  solver.solve(*matrix, dst, src, precondition);
-}
-
-
 /*----------------------------   mgbase.h     ---------------------------*/
 
 #endif
diff --git a/deal.II/deal.II/include/multigrid/mg_coarse.h b/deal.II/deal.II/include/multigrid/mg_coarse.h
new file mode 100644 (file)
index 0000000..c922b1e
--- /dev/null
@@ -0,0 +1,100 @@
+//------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//------------------------------------------------------------------------
+#ifndef __deal2__mg_coarse_h
+#define __deal2__mg_coarse_h
+
+
+#include <multigrid/mg_base.h>
+
+
+/**
+ * Coarse grid solver using LAC iterative methods.
+ * This is a little wrapper, transforming a triplet of iterative
+ * solver, matrix and preconditioner into a coarse grid solver.
+ *
+ * The type of the matrix (i.e. the template parameter @p{MATRIX})
+ * should be derived from @p{Subscriptor} to allow for the use of a
+ * smart pointer to it.
+ *
+ * @author Guido Kanschat, 1999
+ */
+template<class SOLVER, class MATRIX, class PRECOND, class VECTOR = Vector<double> >
+class MGCoarseGridLACIteration :  public MGCoarseGrid<VECTOR>
+{
+  public:
+                                    /**
+                                     * Constructor.
+                                     * Store solver, matrix and
+                                     * preconditioning method for later
+                                     * use.
+                                     */
+    MGCoarseGridLACIteration (SOLVER        &,
+                             const MATRIX  &,
+                             const PRECOND &);
+    
+                                    /**
+                                     * Implementation of the abstract
+                                     * function.
+                                     * Calls the solver method with
+                                     * matrix, vectors and
+                                     * preconditioner.
+                                     */
+    void operator() (const unsigned int   level,
+                    VECTOR       &dst,
+                    const VECTOR &src) const;
+  private:
+                                    /**
+                                     * Reference to the solver.
+                                     */
+    SOLVER& solver;
+    
+                                    /**
+                                     * Reference to the matrix.
+                                     */
+    const SmartPointer<const MATRIX> matrix;
+    
+                                    /**
+                                     * Reference to the preconditioner.
+                                     */
+    const PRECOND& precondition;
+};
+
+
+/* ------------------ Functions for MGCoarseGridLACIteration ------------ */
+
+
+template<class SOLVER, class MATRIX, class PRECOND, class VECTOR>
+MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND, VECTOR>
+::MGCoarseGridLACIteration(SOLVER& s,
+                          const MATRIX  &m,
+                          const PRECOND &p)
+               :
+               solver(s),
+               matrix(&m),
+               precondition(p)
+{};
+
+
+template<class SOLVER, class MATRIX, class PRECOND, class VECTOR>
+void
+MGCoarseGridLACIteration<SOLVER, MATRIX, PRECOND, VECTOR>
+::operator() (const unsigned int    /* level */,
+             VECTOR       &dst,
+             const VECTOR &src) const
+{
+  solver.solve(*matrix, dst, src, precondition);
+}
+
+
+
+#endif
index b01defeb2a418bd7fb27abed28182339d2fd3967..207900d974d0046152548992efbb28e48f4d6316 100644 (file)
 template <int dim> class MGDoFHandler;
 
 
-/**
- * Base class for multigrid smoothers. Does nothing but defining the
- * interface used by multigrid methods.
- *
- * @author Guido KAnschat, 2002
- */
-template <class VECTOR>
-class MGSmoother : public Subscriptor
-{
-  public:
-                                  /**
-                                   * Virtual destructor.
-                                   */
-  virtual ~MGSmoother();
-
-                                  /**
-                                   * Smoothing function. This is the
-                                   * function used in multigrid
-                                   * methods.
-                                   */
-  virtual void smooth (const unsigned int level,
-                      VECTOR&            u,
-                      const VECTOR&      rhs) const = 0;  
-};
-
-
 /**
  * Smoother doing nothing. This class is not useful for many applications other
  * than for testing some multigrid procedures. Also some applications might
index 301691ced1c6a8af6c8ea2be069c5f75ff5a7f03..7a787fbc9dc316ad57b3fcaef0bdb96d8173171f 100644 (file)
@@ -25,9 +25,7 @@
 
 
 //TODO:[GK] Cleanup
-//  Move MGSmoother to mg_base.h
 //  move definitions of virtual destructors to mg_base.templates.h
-//  move MGCoarseGridLACIteration to mg_coarse.h
 //
 
 /**
@@ -124,15 +122,6 @@ class Multigrid : public Subscriptor
                                      */
     void vcycle();
 
-                                    /**
-                                     * Print a level vector using
-                                     * @ref{DoFHandler}.
-                                     */
-/*      virtual void print_vector (const unsigned int level, */
-/*                            const VECTOR& v, */
-/*                            const char* name) const; */
-    
-
   private:
     
                                     /**
index 383a54c3a9a3e20def358b2b439e50f06be86ab1..c23bf90d5d485539f51adce4c90f16332a8fe792 100644 (file)
 #include <lac/sparse_matrix.h>
 
 
-//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces
-#if deal_II_dimension == 1
-
-template <int dim>
-template <typename number>
-void
-Multigrid<dim>::copy_to_mg (const Vector<number>&)
-{
-  Assert(false, ExcNotImplemented());
-}
-
-#else
-
-template <int dim>
-template <typename number>
-void
-Multigrid<dim>::copy_to_mg (const Vector<number>& osrc)
-{
-                                  // Make src a real finite element function
-  Vector<number> src = osrc;
-//  constraints->distribute(src);
-
-  const unsigned int dofs_per_cell = mg_dof_handler->get_fe().dofs_per_cell;
-  const unsigned int dofs_per_face = mg_dof_handler->get_fe().dofs_per_face;
-
-                                  // set the elements of the vectors
-                                  // on all levels to zero
-  defect.clear();
-  
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices  (dofs_per_cell);
-  std::vector<unsigned int> level_face_indices (dofs_per_face);
-
-                                  // initialize the objects with
-                                  // their correct size
-  for (unsigned int level=minlevel; level<=maxlevel ; ++level)
-    {
-      const unsigned int system_size = (*level_matrices)[level].m();
-      
-      solution[level].reinit(system_size);
-      defect[level].reinit(system_size);
-      t[level].reinit(system_size);
-    };
-
-                                  // traverse the grid top-down
-                                  // (i.e. starting with the most
-                                  // refined grid). this way, we can
-                                  // always get that part of one
-                                  // level of the output vector which
-                                  // corresponds to a region which is
-                                  // more refined, by restriction of
-                                  // the respective vector on the
-                                  // next finer level, which we then
-                                  // already have built.
-  for (int level=maxlevel; level>=static_cast<int>(minlevel); --level)
-    {
-      typename MGDoFHandler<dim>::active_cell_iterator
-       level_cell = mg_dof_handler->begin_active(level);
-      const typename MGDoFHandler<dim>::active_cell_iterator
-       level_end  = mg_dof_handler->end_active(level);
-
-//TODO:[?] Treat hanging nodes properly
-// The single-level vector is not an FE-function, because the values at
-// hanging nodes are set to zero. This should be treated before the restriction.
-
-                                      // Compute coarse level right hand side
-                                      // by restricting from fine level.
-      for (; level_cell!=level_end; ++level_cell)
-       {
-         DoFObjectAccessor<dim, dim>& global_cell = *level_cell;
-                                          // get the dof numbers of
-                                          // this cell for the global
-                                          // and the level-wise
-                                          // numbering
-         global_cell.get_dof_indices(global_dof_indices);
-         level_cell->get_mg_dof_indices (level_dof_indices);
-
-                                          // transfer the global
-                                          // defect in the vector
-                                          // into the level-wise one
-         for (unsigned int i=0; i<dofs_per_cell; ++i)
-           defect[level](level_dof_indices[i]) = src(global_dof_indices[i]);
-
-         for (unsigned int face_n=0; face_n<GeometryInfo<dim>::faces_per_cell; ++face_n)
-           {
-             const typename MGDoFHandler<dim>::face_iterator
-               face = level_cell->face(face_n);
-             if (face->has_children())
-               {
-                 face->get_mg_dof_indices(level_face_indices);
-
-
-                                                  // Delete values on refinement edge,
-                                                  // since restriction will add them again.
-                 for (unsigned int i=0; i<dofs_per_face; ++i)
-                   defect[level](level_face_indices[i])
-                     = 0.;
-               };
-           };
-       };
-                                      // for that part of the level
-                                      // which is further refined:
-                                      // get the defect by
-                                      // restriction of the defect on
-                                      // one level higher
-      if (static_cast<unsigned int>(level) < maxlevel)
-       {
-         transfer->restrict_and_add (level+1, defect[level], defect[level+1]);
-       }
-    };
-};
-
-#endif
-
-
-template <int dim>
-template <typename number>
-void
-Multigrid<dim>::copy_from_mg(Vector<number> &dst) const
-{
-  const unsigned int dofs_per_cell = mg_dof_handler->get_fe().dofs_per_cell;
-
-  std::vector<unsigned int> global_dof_indices (dofs_per_cell);
-  std::vector<unsigned int> level_dof_indices (dofs_per_cell);
-
-  typename MGDoFHandler<dim>::active_cell_iterator
-    level_cell = mg_dof_handler->begin_active();
-  const typename MGDoFHandler<dim>::active_cell_iterator
-    endc = mg_dof_handler->end();
-
-                                  // traverse all cells and copy the
-                                  // data appropriately to the output
-                                  // vector
-
-                                  // Is the level monotonuosly increasing?
-
-  for (; level_cell != endc; ++level_cell)
-    {
-      DoFObjectAccessor<dim, dim>& global_cell = *level_cell;
-      const unsigned int level = level_cell->level();
-      
-                                      // get the dof numbers of
-                                      // this cell for the global
-                                      // and the level-wise
-                                      // numbering
-      global_cell.get_dof_indices (global_dof_indices);
-      level_cell->get_mg_dof_indices(level_dof_indices);
-
-                                      // copy level-wise data to
-                                      // global vector
-      for (unsigned int i=0; i<dofs_per_cell; ++i)
-       dst(global_dof_indices[i]) = solution[level](level_dof_indices[i]);
-    };
-
-                                  // clear constrained nodes
-  constraints->set_zero(dst);
-}
-
-
-
 template <int dim>
 void
 Multigrid<dim>::print_vector (const unsigned int /*level*/,

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.