#include <vector>
+//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
+//
+
/**
* Implementation of the multigrid method.
*
template <int dim>
Multigrid(const MGDoFHandler<dim>& mg_dof_handler,
const MGMatrixBase<VECTOR>& matrix,
+ const MGCoarseGrid<VECTOR>& coarse,
const MGTransfer<VECTOR>& transfer,
const MGSmoother<VECTOR>& pre_smooth,
const MGSmoother<VECTOR>& post_smooth,
* function is done in
* @p{level_mgstep}.
*/
- template <class COARSE>
- void vcycle(const COARSE& cgs);
+ void vcycle();
/**
* Print a level vector using
* is used to solve the matrix of
* this level.
*/
- template <class COARSE>
- void level_mgstep (const unsigned int level,
- const COARSE& cgs);
+ void level_mgstep (const unsigned int level);
/**
* Level for coarse grid solution.
*/
*/
SmartPointer<const MGMatrixBase<VECTOR> > matrix;
+ /**
+ * The matrix for each level.
+ */
+ SmartPointer<const MGCoarseGrid<VECTOR> > coarse;
+
/**
* Object for grid tranfer.
*/
SmartPointer<const MGTransfer<VECTOR> > transfer;
+
/**
* The pre-smoothing object.
*/
DeclException2(ExcSwitchedLevels, int, int,
<< "minlevel and maxlevel switched, should be: "
<< arg1 << "<=" << arg2);
- template<int dim, class VECTOR2, class TRANSFER, class COARSE> friend class PreconditionMG;
+ template<int dim, class VECTOR2, class TRANSFER> friend class PreconditionMG;
};
*
* @author Guido Kanschat, 1999, 2000, 2001, 2002
*/
-template<int dim, class VECTOR, class TRANSFER, class COARSE>
+template<int dim, class VECTOR, class TRANSFER>
class PreconditionMG : public Subscriptor
{
public:
*/
PreconditionMG(const MGDoFHandler<dim>& mg_dof,
Multigrid<VECTOR>& mg,
- const TRANSFER& transfer,
- const COARSE& coarse);
+ const TRANSFER& transfer);
/**
* Preconditioning operator.
/**
* Object for grid tranfer.
*/
- SmartPointer<const TRANSFER> transfer;
-
- /**
- * The coarse grid solver.
- */
- SmartPointer<const COARSE> coarse;
+ SmartPointer<const TRANSFER> transfer;
};
template <int dim>
Multigrid<VECTOR>::Multigrid (const MGDoFHandler<dim>& mg_dof_handler,
const MGMatrixBase<VECTOR>& matrix,
+ const MGCoarseGrid<VECTOR>& coarse,
const MGTransfer<VECTOR>& transfer,
const MGSmoother<VECTOR>& pre_smooth,
const MGSmoother<VECTOR>& post_smooth,
solution(minlevel,maxlevel),
t(minlevel,maxlevel),
matrix(&matrix),
+ coarse(&coarse),
transfer(&transfer),
pre_smooth(&pre_smooth),
post_smooth(&post_smooth)
template <class VECTOR>
-template <class COARSE>
void
-Multigrid<VECTOR>::level_mgstep(const unsigned int level,
- const COARSE &coarse_grid_solver)
+Multigrid<VECTOR>::level_mgstep(const unsigned int level)
{
#ifdef MG_DEBUG
char *name = new char[100];
if (level == minlevel)
{
- coarse_grid_solver(level, solution[level], defect[level]);
+ (*coarse)(level, solution[level], defect[level]);
#ifdef MG_DEBUG
sprintf(name, "MG%d-solution",level);
print_vector(level, solution[level], name);
// edge_vmult(level, defect[level-1], defect[level]);
// do recursion
- level_mgstep(level-1, coarse_grid_solver);
+ level_mgstep(level-1);
// reset size of the auxiliary
// vector, since it has been
template <class VECTOR>
-template <class COARSE>
void
-Multigrid<VECTOR>::vcycle(const COARSE &coarse_grid_solver)
+Multigrid<VECTOR>::vcycle()
{
// The defect vector has been
// initialized by copy_to_mg. Now
t[level].reinit(defect[level]);
}
- level_mgstep (maxlevel, coarse_grid_solver);
+ level_mgstep (maxlevel);
// abort ();
}
/* ------------------------------------------------------------------- */
-template<int dim, class VECTOR, class TRANSFER, class COARSE>
-PreconditionMG<dim, VECTOR, TRANSFER, COARSE>
+template<int dim, class VECTOR, class TRANSFER>
+PreconditionMG<dim, VECTOR, TRANSFER>
::PreconditionMG(const MGDoFHandler<dim>& mg_dof_handler,
Multigrid<VECTOR>& mg,
- const TRANSFER& transfer,
- const COARSE& coarse)
+ const TRANSFER& transfer)
:
mg_dof_handler(&mg_dof_handler),
multigrid(&mg),
- transfer(&transfer),
- coarse(&coarse)
+ transfer(&transfer)
{}
-template<int dim, class VECTOR, class TRANSFER, class COARSE>
+template<int dim, class VECTOR, class TRANSFER>
void
-PreconditionMG<dim, VECTOR, TRANSFER, COARSE>::vmult (
+PreconditionMG<dim, VECTOR, TRANSFER>::vmult (
VECTOR& dst,
const VECTOR& src) const
{
multigrid->defect,
src);
- multigrid->vcycle(*coarse);
+ multigrid->vcycle();
transfer->copy_from_mg(*mg_dof_handler,
dst,
}
-template<int dim, class VECTOR, class TRANSFER, class COARSE>
+template<int dim, class VECTOR, class TRANSFER>
void
-PreconditionMG<dim, VECTOR, TRANSFER, COARSE>::vmult_add (
+PreconditionMG<dim, VECTOR, TRANSFER>::vmult_add (
VECTOR& dst,
const VECTOR& src) const
{
multigrid->defect,
src);
- multigrid->vcycle(*coarse);
+ multigrid->vcycle();
transfer->copy_from_mg_add(*mg_dof_handler,
dst,
}
-template<int dim, class VECTOR, class TRANSFER, class COARSE>
+template<int dim, class VECTOR, class TRANSFER>
void
-PreconditionMG<dim, VECTOR, TRANSFER, COARSE>::Tvmult (
+PreconditionMG<dim, VECTOR, TRANSFER>::Tvmult (
VECTOR&,
const VECTOR&) const
{
}
-template<int dim, class VECTOR, class TRANSFER, class COARSE>
+template<int dim, class VECTOR, class TRANSFER>
void
-PreconditionMG<dim, VECTOR, TRANSFER, COARSE>::Tvmult_add (
+PreconditionMG<dim, VECTOR, TRANSFER>::Tvmult_add (
VECTOR&,
const VECTOR&) const
{
- template <class VECTOR>
- MGTransfer<VECTOR>::~MGTransfer()
- {};
+template <class VECTOR>
+MGTransfer<VECTOR>::~MGTransfer()
+{};
- template <class VECTOR>
- MGMatrixBase<VECTOR>::~MGMatrixBase()
- {};
+template <class VECTOR>
+MGMatrixBase<VECTOR>::~MGMatrixBase()
+{};
- // Explicit instantiations
+template <class VECTOR>
+MGCoarseGrid<VECTOR>::~MGCoarseGrid()
+{};
- template class MGTransfer<Vector<double> >;
- template class MGTransfer<Vector<float> >;
- template class MGTransfer<BlockVector<double> >;
- template class MGTransfer<BlockVector<float> >;
- template class MGMatrixBase<Vector<double> >;
- template class MGMatrixBase<Vector<float> >;
- template class MGMatrixBase<BlockVector<double> >;
- template class MGMatrixBase<BlockVector<float> >;
+// Explicit instantiations
+
+template class MGTransfer<Vector<double> >;
+template class MGTransfer<Vector<float> >;
+template class MGTransfer<BlockVector<double> >;
+template class MGTransfer<BlockVector<float> >;
+
+template class MGMatrixBase<Vector<double> >;
+template class MGMatrixBase<Vector<float> >;
+template class MGMatrixBase<BlockVector<double> >;
+template class MGMatrixBase<BlockVector<float> >;
+
+template class MGCoarseGrid<Vector<double> >;
+template class MGCoarseGrid<Vector<float> >;
+template class MGCoarseGrid<BlockVector<double> >;
+template class MGCoarseGrid<BlockVector<float> >;