};
-/**
- * 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
+/**
+ * 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;
+};
+
+
/* ------------------------------------------------------------------- */
}
-/* ------------------ 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
--- /dev/null
+//------------------------------------------------------------------------
+// $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
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
//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
//
/**
*/
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:
/**
#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*/,