#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
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.
*
template<int dim>
MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
- const MGMatrix& matrix,
+ const MGMatrix<SparseMatrix<float> >& matrix,
unsigned int steps);
/**
/**
* Pointer to the matrices.
*/
- SmartPointer< const MGMatrix > matrix;
+ SmartPointer< const MGMatrix< SparseMatrix<float> > > matrix;
};
inline
return steps;
}
-
/*---------------------------- mg_smoother.h ---------------------------*/
/* end of #ifndef __mg_smoother_H */
#endif
#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.
/**
* 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;
/**
* 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;
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));
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));
}
-
/*---------------------------- multigrid.h ---------------------------*/
/* end of #ifndef __multigrid_H */
#endif
*/
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)
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
{
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
/*
template <int dim>
-MultiGrid::
+MG::
template <int dim>
-MultiGrid::
+MG::
template <int dim>
-MultiGrid::
+MG::
template <int dim>
-MultiGrid::
+MG::
*/
* @author Wolfgang Bangerth, 1998
*/
template <int dim>
-class MatrixCreator {
+class MatrixCreator
+{
public:
/**
* Declare a data type which denotes a
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
#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
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.
*
template<int dim>
MGSmootherSOR(const MGDoFHandler<dim> &mg_dof,
- const MGMatrix& matrix,
+ const MGMatrix<SparseMatrix<float> >& matrix,
unsigned int steps);
/**
/**
* Pointer to the matrices.
*/
- SmartPointer< const MGMatrix > matrix;
+ SmartPointer< const MGMatrix< SparseMatrix<float> > > matrix;
};
inline
return steps;
}
-
/*---------------------------- mg_smoother.h ---------------------------*/
/* end of #ifndef __mg_smoother_H */
#endif
#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.
/**
* 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;
/**
* 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;
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));
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));
}
-
/*---------------------------- multigrid.h ---------------------------*/
/* end of #ifndef __multigrid_H */
#endif
*/
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)
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
{
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
/*
template <int dim>
-MultiGrid::
+MG::
template <int dim>
-MultiGrid::
+MG::
template <int dim>
-MultiGrid::
+MG::
template <int dim>
-MultiGrid::
+MG::
*/
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),
#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);
#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
template
void MGTransferPrebuilt::build_matrices (const MGDoFHandler<deal_II_dimension> &mg_dof);
-template MultiGrid<deal_II_dimension>;
+template MG<deal_II_dimension>;
#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,
--- /dev/null
+// $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>;
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,
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);
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),
#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);
#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
template
void MGTransferPrebuilt::build_matrices (const MGDoFHandler<deal_II_dimension> &mg_dof);
-template MultiGrid<deal_II_dimension>;
+template MG<deal_II_dimension>;