* context. This class is an abstract one and has no implementations of
* possible algorithms for these operations.
*
- * @author Wolfgang Bangerth, Guido Kanschat, 1999
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2002
*/
-// template <class VECTOR>
-// class MGTransferBase : public Subscriptor
-// {
-// public:
-// /**
-// * Destructor. Does nothing here, but
-// * needs to be declared virtual anyway.
-// */
-// virtual ~MGTransferBase();
-
-// /**
-// * Prolongate a vector from level
-// * @p{to_level-1} to level
-// * @p{to_level}. The previous
-// * content of @p{dst} is
-// * overwritten.
-// *
-// * @p{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 @p{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& dst,
-// const VECTOR& src) const = 0;
-
-// /**
-// * Restrict a vector from level
-// * @p{from_level} to level
-// * @p{from_level-1} and add this
-// * restriction to
-// * @p{dst}. Obviously, if the
-// * refined region on level
-// * @p{from_level} is smaller than
-// * that on level @p{from_level-1},
-// * some degrees of freedom in
-// * @p{dst} are not covered and will
-// * not be altered. For the other
-// * degress of freedom, the result
-// * of the restriction is added.
-// *
-// * @p{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 @p{src}
-// * shall have as many elements as there
-// * are degrees of freedom on the coarser
-// * level.
-// */
-// virtual void restrict_and_add (const unsigned int from_level,
-// VECTOR& dst,
-// const VECTOR& src) const = 0;
-// };
+ template <class VECTOR>
+ class MGTransfer : public Subscriptor
+ {
+ public:
+ /**
+ * Destructor. Does nothing here, but
+ * needs to be declared virtual anyway.
+ */
+ virtual ~MGTransfer();
+
+ /**
+ * Prolongate a vector from level
+ * @p{to_level-1} to level
+ * @p{to_level}. The previous
+ * content of @p{dst} is
+ * overwritten.
+ *
+ * @p{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 @p{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& dst,
+ const VECTOR& src) const = 0;
+
+ /**
+ * Restrict a vector from level
+ * @p{from_level} to level
+ * @p{from_level-1} and add this
+ * restriction to
+ * @p{dst}. Obviously, if the
+ * refined region on level
+ * @p{from_level} is smaller than
+ * that on level @p{from_level-1},
+ * some degrees of freedom in
+ * @p{dst} are not covered and will
+ * not be altered. For the other
+ * degress of freedom, the result
+ * of the restriction is added.
+ *
+ * @p{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 @p{src}
+ * shall have as many elements as there
+ * are degrees of freedom on the coarser
+ * level.
+ */
+ virtual void restrict_and_add (const unsigned int from_level,
+ VECTOR& dst,
+ const VECTOR& src) const = 0;
+ };
//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces
#if deal_II_dimension == 1
+template <typename number>
template <int dim, class InVector>
void
-MGTransferPrebuilt::copy_to_mg (const MGDoFHandler<dim>&,
- MGLevelObject<Vector<double> >&,
- const InVector&) const
+MGTransferPrebuilt<number>::copy_to_mg (
+ const MGDoFHandler<dim>&,
+ MGLevelObject<Vector<number> >&,
+ const InVector&) const
{
Assert(false, ExcNotImplemented());
}
#else
+template <typename number>
template <int dim, class InVector>
void
-MGTransferPrebuilt::copy_to_mg (const MGDoFHandler<dim>& mg_dof_handler,
- MGLevelObject<Vector<double> >& dst,
- const InVector& src) const
+MGTransferPrebuilt<number>::copy_to_mg (
+ const MGDoFHandler<dim>& mg_dof_handler,
+ MGLevelObject<Vector<number> >& dst,
+ const InVector& src) const
{
// Make src a real finite element function
#endif
+template <typename number>
template <int dim, class OutVector>
void
-MGTransferPrebuilt::copy_from_mg(const MGDoFHandler<dim>& mg_dof_handler,
- OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const
+MGTransferPrebuilt<number>::copy_from_mg(
+ const MGDoFHandler<dim>& mg_dof_handler,
+ OutVector &dst,
+ const MGLevelObject<Vector<number> > &src) const
{
const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell;
//TODO:[GK] constraints->set_zero(dst);
}
+template <typename number>
template <int dim, class OutVector>
void
-MGTransferPrebuilt::copy_from_mg_add(const MGDoFHandler<dim>& mg_dof_handler,
- OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const
+MGTransferPrebuilt<number>::copy_from_mg_add(
+ const MGDoFHandler<dim>& mg_dof_handler,
+ OutVector &dst,
+ const MGLevelObject<Vector<number> > &src) const
{
const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell;
//TODO:[?] This function needs to be specially implemented, since in 2d mode we use faces
#if deal_II_dimension == 1
+template <typename number>
template <int dim, class InVector>
void
-MGTransferSelect::copy_to_mg (const MGDoFHandler<dim>&,
- MGLevelObject<Vector<double> >&,
- const InVector&) const
+MGTransferSelect<number>::copy_to_mg (
+ const MGDoFHandler<dim>&,
+ MGLevelObject<Vector<number> >&,
+ const InVector&) const
{
Assert(false, ExcNotImplemented());
}
#else
+template <typename number>
template <int dim, class InVector>
void
-MGTransferSelect::copy_to_mg (const MGDoFHandler<dim>& mg_dof_handler,
- MGLevelObject<Vector<double> >& dst,
- const InVector& osrc) const
+MGTransferSelect<number>::copy_to_mg (
+ const MGDoFHandler<dim>& mg_dof_handler,
+ MGLevelObject<Vector<number> >& dst,
+ const InVector& osrc) const
{
// Make src a real finite element function
InVector src = osrc;
#endif
+template <typename number>
template <int dim, class OutVector>
void
-MGTransferSelect::copy_from_mg(const MGDoFHandler<dim>& mg_dof_handler,
- OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const
+MGTransferSelect<number>::copy_from_mg(
+ const MGDoFHandler<dim>& mg_dof_handler,
+ OutVector &dst,
+ const MGLevelObject<Vector<number> > &src) const
{
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
//TODO:[GK] constraints->set_zero(dst);
}
+template <typename number>
template <int dim, class OutVector>
void
-MGTransferSelect::copy_from_mg_add(const MGDoFHandler<dim>& mg_dof_handler,
- OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const
+MGTransferSelect<number>::copy_from_mg_add(
+ const MGDoFHandler<dim>& mg_dof_handler,
+ OutVector &dst,
+ const MGLevelObject<Vector<number> > &src) const
{
const FiniteElement<dim>& fe = mg_dof_handler.get_fe();
* once by looping over all cells and storing the result in a matrix for
* each level, but requires additional memory.
*
- * @author Wolfgang Bangerth, Guido Kanschat, 1999
+ * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000, 2001, 2002
*/
-class MGTransferPrebuilt : public Subscriptor // MGTransferBase<Vector<double> >
+template<typename number>
+class MGTransferPrebuilt : public MGTransfer<Vector<number> >
{
public:
/**
* level.
*/
virtual void prolongate (const unsigned int to_level,
- Vector<double> &dst,
- const Vector<double> &src) const;
+ Vector<number> &dst,
+ const Vector<number> &src) const;
/**
* Restrict a vector from level
* level.
*/
virtual void restrict_and_add (const unsigned int from_level,
- Vector<double> &dst,
- const Vector<double> &src) const;
+ Vector<number> &dst,
+ const Vector<number> &src) const;
/**
* Transfer from a vector on the
template<int dim, class InVector>
void
copy_to_mg (const MGDoFHandler<dim>& mg_dof,
- MGLevelObject<Vector<double> > &dst,
+ MGLevelObject<Vector<number> > &dst,
const InVector &src) const;
/**
* Copies data from active
* portions of an MGVector into
* the respective positions of a
- * @p{Vector<double>}. In order to
+ * @p{Vector<number>}. In order to
* keep the result consistent,
* constrained degrees of freedom
* are set to zero.
void
copy_from_mg (const MGDoFHandler<dim>& mg_dof,
OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const;
+ const MGLevelObject<Vector<number> > &src) const;
/**
* Add a multi-level vector to a
void
copy_from_mg_add (const MGDoFHandler<dim>& mg_dof,
OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const;
+ const MGLevelObject<Vector<number> > &src) const;
/**
* Finite element does not
* transfer routines may only have as many components as there are
* @p{true}s in the selected-field.
*
- * @author Guido Kanschat, 2001
+ * @author Guido Kanschat, 2001, 2002
*/
-class MGTransferBlock : public Subscriptor, // MGTransferBase<BlockVector<double> >,
+template <typename number>
+class MGTransferBlock : public MGTransfer<BlockVector<number> >,
private MGTransferBlockBase
{
public:
* level.
*/
virtual void prolongate (const unsigned int to_level,
- BlockVector<double> &dst,
- const BlockVector<double> &src) const;
+ BlockVector<number> &dst,
+ const BlockVector<number> &src) const;
/**
* Restrict a vector from level
* level.
*/
virtual void restrict_and_add (const unsigned int from_level,
- BlockVector<double> &dst,
- const BlockVector<double> &src) const;
+ BlockVector<number> &dst,
+ const BlockVector<number> &src) const;
protected:
};
* selecting a single component. The transfer operators themselves are
* implemented for simple vectors again.
*
- * @author Guido Kanschat, 2001
+ * @author Guido Kanschat, 2001, 2002
*/
-class MGTransferSelect : public Subscriptor, // MGTransferBase<Vector<double> >,
+template <typename number>
+class MGTransferSelect : public MGTransfer<Vector<number> >,
private MGTransferBlockBase
{
public:
* level.
*/
virtual void prolongate (const unsigned int to_level,
- Vector<double> &dst,
- const Vector<double> &src) const;
+ Vector<number> &dst,
+ const Vector<number> &src) const;
/**
* Restrict a vector from level
* level.
*/
virtual void restrict_and_add (const unsigned int from_level,
- Vector<double> &dst,
- const Vector<double> &src) const;
+ Vector<number> &dst,
+ const Vector<number> &src) const;
/**
* Transfer from a vector on the
template<int dim, class InVector>
void
copy_to_mg (const MGDoFHandler<dim>& mg_dof,
- MGLevelObject<Vector<double> > &dst,
+ MGLevelObject<Vector<number> > &dst,
const InVector &src) const;
/**
* Copies data from active
* portions of an MGVector into
* the respective positions of a
- * @p{Vector<double>}. In order to
+ * @p{Vector<number>}. In order to
* keep the result consistent,
* constrained degrees of freedom
* are set to zero.
void
copy_from_mg (const MGDoFHandler<dim>& mg_dof,
OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const;
+ const MGLevelObject<Vector<number> > &src) const;
/**
* Add a multi-level vector to a
void
copy_from_mg_add (const MGDoFHandler<dim>& mg_dof,
OutVector &dst,
- const MGLevelObject<Vector<double> > &src) const;
+ const MGLevelObject<Vector<number> > &src) const;
private:
* returning the solution to the system @p{Ax=b} on the coarsest level
* in @p{x}.
*
- * @author Guido Kanschat, 1999, 2001
+ * @author Guido Kanschat, 1999, 2001, 2002
*/
template <class VECTOR>
class Multigrid : public Subscriptor
* function is done in
* @p{level_mgstep}.
*/
- template <class MATRIX, class TRANSFER, class SMOOTHER, class COARSE>
+ template <class MATRIX, class SMOOTHER, class COARSE>
void vcycle(const MGLevelObject<MATRIX>& matrix,
- const TRANSFER& transfer,
+ const MGTransfer<VECTOR>& transfer,
const SMOOTHER& pre_smooth,
const SMOOTHER& post_smooth,
const COARSE& cgs);
* is used to solve the matrix of
* this level.
*/
- template <class MATRIX, class TRANSFER, class SMOOTHER, class COARSE>
+ template <class MATRIX, class SMOOTHER, class COARSE>
void level_mgstep (const unsigned int level,
const MGLevelObject<MATRIX>& matrix,
- const TRANSFER& transfer,
+ const MGTransfer<VECTOR>& transfer,
const SMOOTHER& pre_smooth,
const SMOOTHER& post_smooth,
const COARSE& cgs);
DeclException2(ExcSwitchedLevels, int, int,
<< "minlevel and maxlevel switched, should be: "
<< arg1 << "<=" << arg2);
- template<int dim, class MATRIX, class VECTOR2, class TRANSFER, class SMOOTHER, class COARSE> friend class PreconditionMG;
+ template<int dim, class MATRIX, class VECTOR2, class SMOOTHER, class TRANSFER, class COARSE> friend class PreconditionMG;
};
* to store @p{src} in the right hand side of the multi-level method and
* @p{void copy_from_mg(VECTOR&)} to store the result of the v-cycle in @p{dst}.
*
- * @author Guido Kanschat, 1999
+ * @author Guido Kanschat, 1999, 2000, 2001, 2002
*/
template<int dim, class MATRIX, class VECTOR, class TRANSFER, class SMOOTHER, class COARSE>
class PreconditionMG : public Subscriptor
PreconditionMG(const MGDoFHandler<dim>& mg_dof,
Multigrid<VECTOR>& mg,
const MGLevelObject<MATRIX>& matrix,
- const TRANSFER& transfer,
+ const TRANSFER& transfer,
const SMOOTHER& pre,
const SMOOTHER& post,
const COARSE& coarse);
template <class VECTOR>
-template <class MATRIX, class TRANSFER, class SMOOTHER, class COARSE>
+template <class MATRIX, class SMOOTHER, class COARSE>
void
Multigrid<VECTOR>::level_mgstep(const unsigned int level,
const MGLevelObject<MATRIX>& matrix,
- const TRANSFER& transfer,
+ const MGTransfer<VECTOR>& transfer,
const SMOOTHER &pre_smooth,
const SMOOTHER &post_smooth,
const COARSE &coarse_grid_solver)
template <class VECTOR>
-template <class MATRIX, class TRANSFER, class SMOOTHER, class COARSE>
+template <class MATRIX, class SMOOTHER, class COARSE>
void
Multigrid<VECTOR>::vcycle(const MGLevelObject<MATRIX>& matrix,
- const TRANSFER& transfer,
+ const MGTransfer<VECTOR>& transfer,
const SMOOTHER &pre_smooth,
const SMOOTHER &post_smooth,
const COARSE &coarse_grid_solver)
#include <cmath>
-//////////////////////////////////////////////////////////////////////
-// template <class VECTOR>
-// MGTransferBase<VECTOR>::~MGTransferBase()
-// {};
+ template <class VECTOR>
+ MGTransfer<VECTOR>::~MGTransfer()
+ {};
-// // Explicit instantiations
-// template class MGTransferBase<Vector<double> >;
-// template class MGTransferBase<Vector<float> >;
-// template class MGTransferBase<BlockVector<double> >;
-// template class MGTransferBase<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 void MGTools::copy_to_mg<deal_II_dimension> (const MGDoFHandler<deal_II_dimension>&,
-// const MGTransferBase<Vector<double> >&,
+// const MGTransfer<Vector<double> >&,
// MGLevelObject<Vector<double> >&,
// const Vector<double>&);
// const MGLevelObject<Vector<double> >&);
// template void MGTools::copy_to_mg<deal_II_dimension> (const MGDoFHandler<deal_II_dimension>&,
-// const MGTransferBase<Vector<double> >&,
+// const MGTransfer<Vector<double> >&,
// MGLevelObject<Vector<double> >&,
// const Vector<float>&);
// const MGLevelObject<Vector<float> >&);
// template void MGTools::copy_to_mg<deal_II_dimension> (const MGDoFHandler<deal_II_dimension>&,
-// const MGTransferBase<Vector<double> >&,
+// const MGTransfer<Vector<double> >&,
// MGLevelObject<Vector<double> >&,
// const BlockVector<double>&);
// const MGLevelObject<Vector<double> >&);
// template void MGTools::copy_to_mg<deal_II_dimension> (const MGDoFHandler<deal_II_dimension>&,
-// const MGTransferBase<Vector<double> >&,
+// const MGTransfer<Vector<double> >&,
// MGLevelObject<Vector<double> >&,
// const BlockVector<float>&);
#include <multigrid/mg_transfer.h>
-MGTransferPrebuilt::~MGTransferPrebuilt ()
+template <typename number>
+MGTransferPrebuilt<number>::~MGTransferPrebuilt ()
{};
-void MGTransferPrebuilt::prolongate (const unsigned int to_level,
- Vector<double> &dst,
- const Vector<double> &src) const
+template <typename number>
+void MGTransferPrebuilt<number>::prolongate (
+ const unsigned int to_level,
+ Vector<number> &dst,
+ const Vector<number> &src) const
{
Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()),
ExcIndexRange (to_level, 1, prolongation_matrices.size()+1));
};
-void MGTransferPrebuilt::restrict_and_add (const unsigned int from_level,
- Vector<double> &dst,
- const Vector<double> &src) const
+template <typename number>
+void MGTransferPrebuilt<number>::restrict_and_add (
+ const unsigned int from_level,
+ Vector<number> &dst,
+ const Vector<number> &src) const
{
Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()),
ExcIndexRange (from_level, 1, prolongation_matrices.size()+1));
-MGTransferBlock::~MGTransferBlock ()
+template <typename number>
+MGTransferBlock<number>::~MGTransferBlock ()
{};
-void MGTransferBlock::prolongate (const unsigned int to_level,
- BlockVector<double> &dst,
- const BlockVector<double> &src) const
+template <typename number>
+void MGTransferBlock<number>::prolongate (
+ const unsigned int to_level,
+ BlockVector<number> &dst,
+ const BlockVector<number> &src) const
{
Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()),
ExcIndexRange (to_level, 1, prolongation_matrices.size()+1));
};
-void MGTransferBlock::restrict_and_add (const unsigned int from_level,
- BlockVector<double> &dst,
- const BlockVector<double> &src) const
+template <typename number>
+void MGTransferBlock<number>::restrict_and_add (
+ const unsigned int from_level,
+ BlockVector<number> &dst,
+ const BlockVector<number> &src) const
{
Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()),
ExcIndexRange (from_level, 1, prolongation_matrices.size()+1));
-MGTransferSelect::~MGTransferSelect ()
+template <typename number>
+MGTransferSelect<number>::~MGTransferSelect ()
{};
-void MGTransferSelect::prolongate (const unsigned int to_level,
- Vector<double> &dst,
- const Vector<double> &src) const
+template <typename number>
+void MGTransferSelect<number>::prolongate (
+ const unsigned int to_level,
+ Vector<number> &dst,
+ const Vector<number> &src) const
{
Assert ((to_level >= 1) && (to_level<=prolongation_matrices.size()),
ExcIndexRange (to_level, 1, prolongation_matrices.size()+1));
};
-void MGTransferSelect::restrict_and_add (const unsigned int from_level,
- Vector<double> &dst,
- const Vector<double> &src) const
+template <typename number>
+void MGTransferSelect<number>::restrict_and_add (
+ const unsigned int from_level,
+ Vector<number> &dst,
+ const Vector<number> &src) const
{
Assert ((from_level >= 1) && (from_level<=prolongation_matrices.size()),
ExcIndexRange (from_level, 1, prolongation_matrices.size()+1));
prolongation_matrices[from_level-1].block(selected, selected)
.Tvmult_add (dst, src);
};
+
+
+// Explicit instantiations
+
+template MGTransferPrebuilt<float>;
+template MGTransferPrebuilt<double>;
+template MGTransferBlock<float>;
+template MGTransferBlock<double>;
+template MGTransferSelect<float>;
+template MGTransferSelect<double>;
/* ----------------------------- MGTransferPrebuilt ------------------------ */
+template <typename number>
template <int dim>
-void MGTransferPrebuilt::build_matrices (const MGDoFHandler<dim> &mg_dof)
+void MGTransferPrebuilt<number>::build_matrices (
+ const MGDoFHandler<dim> &mg_dof)
{
const unsigned int n_levels = mg_dof.get_tria().n_levels();
const unsigned int dofs_per_cell = mg_dof.get_fe().dofs_per_cell;
template <int dim>
-void MGTransferBlockBase::build_matrices (const MGDoFHandler<dim> &mg_dof,
- std::vector<bool> select)
+void MGTransferBlockBase::build_matrices (
+ const MGDoFHandler<dim> &mg_dof,
+ std::vector<bool> select)
{
const FiniteElement<dim>& fe = mg_dof.get_fe();
const unsigned int n_components = fe.n_components();
};
+template <typename number>
template <int dim>
-void MGTransferBlock::build_matrices (const MGDoFHandler<dim> &mg_dof,
- std::vector<bool> select)
+void MGTransferBlock<number>::build_matrices (
+ const MGDoFHandler<dim> &mg_dof,
+ std::vector<bool> select)
{
if (select.size() == 0)
select = std::vector<bool> (mg_dof.get_fe().n_components(), true);
}
+template <typename number>
template <int dim>
-void MGTransferSelect::build_matrices (const MGDoFHandler<dim> &mg_dof,
- unsigned int select)
+void MGTransferSelect<number>::build_matrices (
+ const MGDoFHandler<dim> &mg_dof,
+ unsigned int select)
{
selected = select;
std::vector<bool> s(mg_dof.get_fe().n_components(), false);
// explicit instatations
template
-void MGTransferPrebuilt::build_matrices<deal_II_dimension>
+void MGTransferPrebuilt<float>::build_matrices<deal_II_dimension>
(const MGDoFHandler<deal_II_dimension> &mg_dof);
template
-void MGTransferBlock::build_matrices<deal_II_dimension>
+void MGTransferBlock<float>::build_matrices<deal_II_dimension>
(const MGDoFHandler<deal_II_dimension> &mg_dof,
std::vector<bool>);
template
-void MGTransferSelect::build_matrices<deal_II_dimension>
+void MGTransferSelect<float>::build_matrices<deal_II_dimension>
+(const MGDoFHandler<deal_II_dimension> &mg_dof,
+ unsigned int);
+
+template
+void MGTransferPrebuilt<double>::build_matrices<deal_II_dimension>
+(const MGDoFHandler<deal_II_dimension> &mg_dof);
+
+template
+void MGTransferBlock<double>::build_matrices<deal_II_dimension>
+(const MGDoFHandler<deal_II_dimension> &mg_dof,
+ std::vector<bool>);
+
+template
+void MGTransferSelect<double>::build_matrices<deal_II_dimension>
(const MGDoFHandler<deal_II_dimension> &mg_dof,
unsigned int);