From: guido Date: Fri, 30 Apr 1999 11:44:21 +0000 (+0000) Subject: more multigrid X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dffb6d5c2abd52877cb4ff340d514daca532cae3;p=dealii-svn.git more multigrid git-svn-id: https://svn.dealii.org/trunk@1235 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/multigrid/mg_smoother.h b/deal.II/deal.II/include/multigrid/mg_smoother.h index 9f49892d2b..1016d092c5 100644 --- a/deal.II/deal.II/include/multigrid/mg_smoother.h +++ b/deal.II/deal.II/include/multigrid/mg_smoother.h @@ -6,44 +6,12 @@ #include +#include #include #include #include -/** - * 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 &u, - const Vector &rhs) const = 0; - -}; - /** * Base class for multigrid smoothers. It declares the interface * to smoothers by inheriting #MGSmootherBase# and implements some functionality for setting @@ -142,6 +110,29 @@ class MGSmoother vector > interior_boundary_dofs; }; +/** + * Smoother doing nothing. + * @author Guido Kanschat, 1999 + */ +class MGSmootherIdentity + : + public MGSmoother +{ + public: + /** + * Constructor. + */ + template + MGSmootherIdentity(const MGDoFHandler &mg_dof); + /** + * Implementation of the interface in #MGSmootherBase#. + * This function does nothing. + */ + virtual void smooth (const unsigned int level, + Vector &u, + const Vector &rhs) const; +}; + /** * Implementation of an SOR smoother. * @@ -166,7 +157,7 @@ class MGSmootherSOR template MGSmootherSOR(const MGDoFHandler &mg_dof, - const MGMatrix& matrix, + const MGMatrix >& matrix, unsigned int steps); /** @@ -181,7 +172,7 @@ class MGSmootherSOR /** * Pointer to the matrices. */ - SmartPointer< const MGMatrix > matrix; + SmartPointer< const MGMatrix< SparseMatrix > > matrix; }; inline @@ -198,7 +189,6 @@ MGSmoother::get_steps() const return steps; } - /*---------------------------- mg_smoother.h ---------------------------*/ /* end of #ifndef __mg_smoother_H */ #endif diff --git a/deal.II/deal.II/include/multigrid/multigrid.h b/deal.II/deal.II/include/multigrid/multigrid.h index 942166e8cd..916e2e7c6b 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.h +++ b/deal.II/deal.II/include/multigrid/multigrid.h @@ -10,216 +10,25 @@ #include #include #include +#include #include -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 not iterative and the start solution is - * always zero. Since by this uEl and - * uAl (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 > d; - - /** - * Auxiliary vector, solution. - */ - vector > s; - - /** - * Auxiliary vector. - */ - Vector t; - - /** - * Prolongation and restriction object. - */ - SmartPointer 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& dst, - const Vector& src, - const Vector& 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& dst, - const Vector& 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 &dst, - const Vector &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 &dst, - const Vector &src) const = 0; -}; - -/** - * An array of matrices for each level. - * This class provides the functionality of #vector ># combined - * with a subscriptor for smart pointers. - * @author Guido Kanschat, 1999 - */ -class MGMatrix - : - public Subscriptor, - public Vector > -{ - 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 -class MultiGrid +class MG : - public MultiGridBase + public MGBase { public: - MultiGrid(const MGDoFHandler&, const MGTransferBase& transfer); + MG(const MGDoFHandler&, const MGTransferBase& transfer); /** Transfer from dVector to * MGVector. @@ -277,7 +86,7 @@ class MultiGrid /** * 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 matrix_structures; @@ -285,7 +94,7 @@ class MultiGrid /** * 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 > matrices; @@ -365,10 +174,11 @@ class MGTransferPrebuilt : public MGTransferBase vector > prolongation_matrices; }; + template inline SparseMatrix& -MultiGrid::get_matrix(unsigned int level) +MG::get_matrix(unsigned int level) { Assert((level>=minlevel) && (level::get_matrix(unsigned int level) template inline const SparseMatrix& -MultiGrid::get_matrix(unsigned int level) const +MG::get_matrix(unsigned int level) const { Assert((level>=minlevel) && (level::get_matrix(unsigned int level) const } - /*---------------------------- multigrid.h ---------------------------*/ /* end of #ifndef __multigrid_H */ #endif diff --git a/deal.II/deal.II/include/multigrid/multigrid.templates.h b/deal.II/deal.II/include/multigrid/multigrid.templates.h index 2750ff8927..d290cd7223 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.templates.h +++ b/deal.II/deal.II/include/multigrid/multigrid.templates.h @@ -8,9 +8,9 @@ MultiGrid:: */ template -MultiGrid::MultiGrid(const MGDoFHandler& dofs, const MGTransferBase& transfer) +MG::MG(const MGDoFHandler& 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) @@ -24,7 +24,7 @@ MultiGrid::MultiGrid(const MGDoFHandler& dofs, const MGTransferBase& t template template void -MultiGrid::copy_to_mg(vector >& dst, +MG::copy_to_mg(vector >& dst, const Vector& src) const { @@ -32,7 +32,7 @@ MultiGrid::copy_to_mg(vector >& dst, template template void -MultiGrid::copy_from_mg(Vector& dst, +MG::copy_from_mg(Vector& dst, const vector >& src) const { // active iterator @@ -41,12 +41,12 @@ MultiGrid::copy_from_mg(Vector& dst, /* template -MultiGrid:: +MG:: template -MultiGrid:: +MG:: template -MultiGrid:: +MG:: template -MultiGrid:: +MG:: */ diff --git a/deal.II/deal.II/include/numerics/matrices.h b/deal.II/deal.II/include/numerics/matrices.h index 035520209b..2917c41584 100644 --- a/deal.II/deal.II/include/numerics/matrices.h +++ b/deal.II/deal.II/include/numerics/matrices.h @@ -151,7 +151,8 @@ * @author Wolfgang Bangerth, 1998 */ template -class MatrixCreator { +class MatrixCreator +{ public: /** * Declare a data type which denotes a @@ -270,6 +271,18 @@ class MatrixCreator { SparseMatrix &matrix, const Function *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& dof, + const Quadrature& q, + SparseMatrix& matrix, + const Function* a = 0); + /** * Assemble the Laplace matrix and a right * hand side vector. If no diff --git a/deal.II/deal.II/include/numerics/mg_smoother.h b/deal.II/deal.II/include/numerics/mg_smoother.h index 9f49892d2b..1016d092c5 100644 --- a/deal.II/deal.II/include/numerics/mg_smoother.h +++ b/deal.II/deal.II/include/numerics/mg_smoother.h @@ -6,44 +6,12 @@ #include +#include #include #include #include -/** - * 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 &u, - const Vector &rhs) const = 0; - -}; - /** * Base class for multigrid smoothers. It declares the interface * to smoothers by inheriting #MGSmootherBase# and implements some functionality for setting @@ -142,6 +110,29 @@ class MGSmoother vector > interior_boundary_dofs; }; +/** + * Smoother doing nothing. + * @author Guido Kanschat, 1999 + */ +class MGSmootherIdentity + : + public MGSmoother +{ + public: + /** + * Constructor. + */ + template + MGSmootherIdentity(const MGDoFHandler &mg_dof); + /** + * Implementation of the interface in #MGSmootherBase#. + * This function does nothing. + */ + virtual void smooth (const unsigned int level, + Vector &u, + const Vector &rhs) const; +}; + /** * Implementation of an SOR smoother. * @@ -166,7 +157,7 @@ class MGSmootherSOR template MGSmootherSOR(const MGDoFHandler &mg_dof, - const MGMatrix& matrix, + const MGMatrix >& matrix, unsigned int steps); /** @@ -181,7 +172,7 @@ class MGSmootherSOR /** * Pointer to the matrices. */ - SmartPointer< const MGMatrix > matrix; + SmartPointer< const MGMatrix< SparseMatrix > > matrix; }; inline @@ -198,7 +189,6 @@ MGSmoother::get_steps() const return steps; } - /*---------------------------- mg_smoother.h ---------------------------*/ /* end of #ifndef __mg_smoother_H */ #endif diff --git a/deal.II/deal.II/include/numerics/multigrid.h b/deal.II/deal.II/include/numerics/multigrid.h index 942166e8cd..916e2e7c6b 100644 --- a/deal.II/deal.II/include/numerics/multigrid.h +++ b/deal.II/deal.II/include/numerics/multigrid.h @@ -10,216 +10,25 @@ #include #include #include +#include #include -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 not iterative and the start solution is - * always zero. Since by this uEl and - * uAl (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 > d; - - /** - * Auxiliary vector, solution. - */ - vector > s; - - /** - * Auxiliary vector. - */ - Vector t; - - /** - * Prolongation and restriction object. - */ - SmartPointer 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& dst, - const Vector& src, - const Vector& 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& dst, - const Vector& 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 &dst, - const Vector &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 &dst, - const Vector &src) const = 0; -}; - -/** - * An array of matrices for each level. - * This class provides the functionality of #vector ># combined - * with a subscriptor for smart pointers. - * @author Guido Kanschat, 1999 - */ -class MGMatrix - : - public Subscriptor, - public Vector > -{ - 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 -class MultiGrid +class MG : - public MultiGridBase + public MGBase { public: - MultiGrid(const MGDoFHandler&, const MGTransferBase& transfer); + MG(const MGDoFHandler&, const MGTransferBase& transfer); /** Transfer from dVector to * MGVector. @@ -277,7 +86,7 @@ class MultiGrid /** * 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 matrix_structures; @@ -285,7 +94,7 @@ class MultiGrid /** * 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 > matrices; @@ -365,10 +174,11 @@ class MGTransferPrebuilt : public MGTransferBase vector > prolongation_matrices; }; + template inline SparseMatrix& -MultiGrid::get_matrix(unsigned int level) +MG::get_matrix(unsigned int level) { Assert((level>=minlevel) && (level::get_matrix(unsigned int level) template inline const SparseMatrix& -MultiGrid::get_matrix(unsigned int level) const +MG::get_matrix(unsigned int level) const { Assert((level>=minlevel) && (level::get_matrix(unsigned int level) const } - /*---------------------------- multigrid.h ---------------------------*/ /* end of #ifndef __multigrid_H */ #endif diff --git a/deal.II/deal.II/include/numerics/multigrid.templates.h b/deal.II/deal.II/include/numerics/multigrid.templates.h index 2750ff8927..d290cd7223 100644 --- a/deal.II/deal.II/include/numerics/multigrid.templates.h +++ b/deal.II/deal.II/include/numerics/multigrid.templates.h @@ -8,9 +8,9 @@ MultiGrid:: */ template -MultiGrid::MultiGrid(const MGDoFHandler& dofs, const MGTransferBase& transfer) +MG::MG(const MGDoFHandler& 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) @@ -24,7 +24,7 @@ MultiGrid::MultiGrid(const MGDoFHandler& dofs, const MGTransferBase& t template template void -MultiGrid::copy_to_mg(vector >& dst, +MG::copy_to_mg(vector >& dst, const Vector& src) const { @@ -32,7 +32,7 @@ MultiGrid::copy_to_mg(vector >& dst, template template void -MultiGrid::copy_from_mg(Vector& dst, +MG::copy_from_mg(Vector& dst, const vector >& src) const { // active iterator @@ -41,12 +41,12 @@ MultiGrid::copy_from_mg(Vector& dst, /* template -MultiGrid:: +MG:: template -MultiGrid:: +MG:: template -MultiGrid:: +MG:: template -MultiGrid:: +MG:: */ diff --git a/deal.II/deal.II/source/multigrid/mg_smoother.cc b/deal.II/deal.II/source/multigrid/mg_smoother.cc index 98fe594fca..cc16654c94 100644 --- a/deal.II/deal.II/source/multigrid/mg_smoother.cc +++ b/deal.II/deal.II/source/multigrid/mg_smoother.cc @@ -107,11 +107,27 @@ MGSmoother::set_zero_interior_boundary (const unsigned int level, u(*p) = 0; }; +////////////////////////////////////////////////////////////////////// + + +template +MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler &mg_dof) + : + MGSmoother(mg_dof, 0) +{} + +void +MGSmootherIdentity::smooth (const unsigned int, + Vector &, + const Vector &) const +{} + + ////////////////////////////////////////////////////////////////////// template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler &mg_dof, - const MGMatrix& matrix, + const MGMatrix >& matrix, unsigned int steps) : MGSmoother(mg_dof, steps), @@ -134,5 +150,8 @@ template MGSmoother::MGSmoother (const MGDoFHandler&, unsigne #endif template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler &mg_dof, - const MGMatrix& matrix, unsigned int steps); + const MGMatrix >& matrix, + unsigned int steps); + +template MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler &mg_dof); diff --git a/deal.II/deal.II/source/multigrid/multigrid.cc b/deal.II/deal.II/source/multigrid/multigrid.cc index 8578b44254..c969467c8b 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.cc @@ -12,59 +12,6 @@ #include -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& /*dst*/, - const Vector& /*src*/) -{ -// smooth(level, dst, src, 10 * (n_pre_smooth + n_post_smooth)); -} - - - // ab hier Wolfgang @@ -225,4 +172,4 @@ void MGTransferPrebuilt::restrict (const unsigned int from_level, template void MGTransferPrebuilt::build_matrices (const MGDoFHandler &mg_dof); -template MultiGrid; +template MG; diff --git a/deal.II/deal.II/source/numerics/assembler.cc b/deal.II/deal.II/source/numerics/assembler.cc index d6467cc194..61de39a15a 100644 --- a/deal.II/deal.II/source/numerics/assembler.cc +++ b/deal.II/deal.II/source/numerics/assembler.cc @@ -11,41 +11,6 @@ #include -template -Equation::Equation (const unsigned int n_equations) : - n_eq(n_equations) {}; - - - -template -void Equation::assemble (FullMatrix &, - Vector &, - const FEValues &, - const typename DoFHandler::cell_iterator &) const { - Assert (false, ExcPureVirtualFunctionCalled()); -}; - - - -template -void Equation::assemble (FullMatrix &, - const FEValues &, - const typename DoFHandler::cell_iterator &) const { - Assert (false, ExcPureVirtualFunctionCalled()); -}; - - - -template -void Equation::assemble (Vector &, - const FEValues &, - const typename DoFHandler::cell_iterator &) const { - Assert (false, ExcPureVirtualFunctionCalled()); -}; - - - - template Assembler::AssemblerData::AssemblerData (const DoFHandler &dof, const bool assemble_matrix, diff --git a/deal.II/deal.II/source/numerics/equation.cc b/deal.II/deal.II/source/numerics/equation.cc new file mode 100644 index 0000000000..ccf0415e69 --- /dev/null +++ b/deal.II/deal.II/source/numerics/equation.cc @@ -0,0 +1,49 @@ +// $Id$ + +#include +#include +#include +#include +#include +#include +#include + +template +Equation::Equation (const unsigned int n_equations) : + n_eq(n_equations) {}; + + + +template +void Equation::assemble (FullMatrix &, + Vector &, + const FEValues &, + const typename DoFHandler::cell_iterator &) const +{ + Assert (false, ExcPureVirtualFunctionCalled()); +}; + + + +template +void Equation::assemble (FullMatrix &, + const FEValues &, + const typename DoFHandler::cell_iterator &) const +{ + Assert (false, ExcPureVirtualFunctionCalled()); +}; + + + +template +void Equation::assemble (Vector &, + const FEValues &, + const typename DoFHandler::cell_iterator &) const +{ + Assert (false, ExcPureVirtualFunctionCalled()); +}; + + + + +template class Equation; diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 9f71473f8f..8700e1fda6 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -340,7 +340,39 @@ void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, while ((++assembler).state() == valid); }; +/* +template +void MatrixCreator::create_level_laplace_matrix (unsigned int level, + const MGDoFHandler &dof, + const Quadrature &q, + SparseMatrix &matrix, + const Function * const a) +{ + Vector 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::AssemblerData data (dof, + true, false, // assemble matrix but not rhs + matrix, dummy, + q, update_flags); + TriaIterator > + assembler (const_cast*>(&dof.get_tria()), + dof.get_tria().begin(level)->level(), + dof.get_tria().begin(level)->index(), + &data); + LaplaceMatrix equation (0, a); + do + { + assembler->assemble (equation); + ++assembler + } + while ( (assembler.state()==valid) && (assembler->level() == level) ); +}; + +*/ template void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, @@ -348,7 +380,8 @@ void MatrixCreator::create_laplace_matrix (const DoFHandler &dof, SparseMatrix &matrix, const Function &rhs, Vector &rhs_vector, - const Function * const a) { + const Function * const a) +{ UpdateFlags update_flags = UpdateFlags(update_q_points | update_gradients | update_JxW_values); diff --git a/deal.II/deal.II/source/numerics/mg_smoother.cc b/deal.II/deal.II/source/numerics/mg_smoother.cc index 98fe594fca..cc16654c94 100644 --- a/deal.II/deal.II/source/numerics/mg_smoother.cc +++ b/deal.II/deal.II/source/numerics/mg_smoother.cc @@ -107,11 +107,27 @@ MGSmoother::set_zero_interior_boundary (const unsigned int level, u(*p) = 0; }; +////////////////////////////////////////////////////////////////////// + + +template +MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler &mg_dof) + : + MGSmoother(mg_dof, 0) +{} + +void +MGSmootherIdentity::smooth (const unsigned int, + Vector &, + const Vector &) const +{} + + ////////////////////////////////////////////////////////////////////// template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler &mg_dof, - const MGMatrix& matrix, + const MGMatrix >& matrix, unsigned int steps) : MGSmoother(mg_dof, steps), @@ -134,5 +150,8 @@ template MGSmoother::MGSmoother (const MGDoFHandler&, unsigne #endif template MGSmootherSOR::MGSmootherSOR(const MGDoFHandler &mg_dof, - const MGMatrix& matrix, unsigned int steps); + const MGMatrix >& matrix, + unsigned int steps); + +template MGSmootherIdentity::MGSmootherIdentity(const MGDoFHandler &mg_dof); diff --git a/deal.II/deal.II/source/numerics/multigrid.cc b/deal.II/deal.II/source/numerics/multigrid.cc index 8578b44254..c969467c8b 100644 --- a/deal.II/deal.II/source/numerics/multigrid.cc +++ b/deal.II/deal.II/source/numerics/multigrid.cc @@ -12,59 +12,6 @@ #include -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& /*dst*/, - const Vector& /*src*/) -{ -// smooth(level, dst, src, 10 * (n_pre_smooth + n_post_smooth)); -} - - - // ab hier Wolfgang @@ -225,4 +172,4 @@ void MGTransferPrebuilt::restrict (const unsigned int from_level, template void MGTransferPrebuilt::build_matrices (const MGDoFHandler &mg_dof); -template MultiGrid; +template MG;