From: guido Date: Fri, 22 Jan 1999 17:14:17 +0000 (+0000) Subject: MultiGrid's growing X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=775bc094c1a4139368397589d0d6cb3499f0fd6a;p=dealii-svn.git MultiGrid's growing git-svn-id: https://svn.dealii.org/trunk@742 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/multigrid/multigrid.h b/deal.II/deal.II/include/multigrid/multigrid.h index 6a65244517..58e968a92d 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.h +++ b/deal.II/deal.II/include/multigrid/multigrid.h @@ -83,7 +83,8 @@ class MultiGrid * Copies data from active portions * of an MGVector into the * respective positions of a - * dVector. + * dVector. All other entries of + * #src# are zero. */ void copy_from_mg(dVector& dst, const MGVector& src) const; @@ -102,35 +103,77 @@ protected: /** * Number of pre-smoothing steps. */ - unsigned n_presmooth; + unsigned n_pre_smooth; /** * Number of post-smoothing steps */ - unsigned n_postsmooth; + unsigned n_post_smooth; /** * The (pre-)smoothing algorithm. + * This function is required to + * perform #steps# iterations to + * smoothen the residual $Ax-b$. */ virtual void smooth(unsigned level, - dVector& dst, - const dVector& src) const; + dVector& x, + const dVector& b, + unsigned steps) const; /** * The post-smoothing algorithm. * Defaults to #smooth#. */ virtual void post_smooth(unsigned level, - dVector& dst, - const dVector& src) const; + dVector& dst, + const dVector& src, + unsigned steps) const; + /** + * Apply operator on all + * cells of a level. + * + */ + virtual void level_vmult(unsigned level, + dVector& dst, + const dVector& src) const; /** * Apply operator on non-refined * cells. + * + * The sum over all levels + * of the results of this function + * is the multiplication with the + * normal fine-grid matrix. */ virtual void level_active_vmult(unsigned level, dVector& dst, const dVector& src) const; + /** + * Restriction from #level#. + * + * This function adds the + * restriction of #src# to #dst#, + * where #src# is a vector on #level# + * and #dst# is on #level#-1. + */ + virtual void restriction(unsigned level, + dVector& dst, + const dVector& src) const; + + + /** + * Prolongation to #level#. + * + * Adds the prolongation of + * #src# to #dst#. Here, #dst# is on + * #level# and #src# on #level#-1. + */ + virtual void prolongation(unsigned level, + dVector& dst, + const dVector& src) const; + /** * Solve exactly on coarsest grid. */ diff --git a/deal.II/deal.II/include/numerics/multigrid.h b/deal.II/deal.II/include/numerics/multigrid.h index 6a65244517..58e968a92d 100644 --- a/deal.II/deal.II/include/numerics/multigrid.h +++ b/deal.II/deal.II/include/numerics/multigrid.h @@ -83,7 +83,8 @@ class MultiGrid * Copies data from active portions * of an MGVector into the * respective positions of a - * dVector. + * dVector. All other entries of + * #src# are zero. */ void copy_from_mg(dVector& dst, const MGVector& src) const; @@ -102,35 +103,77 @@ protected: /** * Number of pre-smoothing steps. */ - unsigned n_presmooth; + unsigned n_pre_smooth; /** * Number of post-smoothing steps */ - unsigned n_postsmooth; + unsigned n_post_smooth; /** * The (pre-)smoothing algorithm. + * This function is required to + * perform #steps# iterations to + * smoothen the residual $Ax-b$. */ virtual void smooth(unsigned level, - dVector& dst, - const dVector& src) const; + dVector& x, + const dVector& b, + unsigned steps) const; /** * The post-smoothing algorithm. * Defaults to #smooth#. */ virtual void post_smooth(unsigned level, - dVector& dst, - const dVector& src) const; + dVector& dst, + const dVector& src, + unsigned steps) const; + /** + * Apply operator on all + * cells of a level. + * + */ + virtual void level_vmult(unsigned level, + dVector& dst, + const dVector& src) const; /** * Apply operator on non-refined * cells. + * + * The sum over all levels + * of the results of this function + * is the multiplication with the + * normal fine-grid matrix. */ virtual void level_active_vmult(unsigned level, dVector& dst, const dVector& src) const; + /** + * Restriction from #level#. + * + * This function adds the + * restriction of #src# to #dst#, + * where #src# is a vector on #level# + * and #dst# is on #level#-1. + */ + virtual void restriction(unsigned level, + dVector& dst, + const dVector& src) const; + + + /** + * Prolongation to #level#. + * + * Adds the prolongation of + * #src# to #dst#. Here, #dst# is on + * #level# and #src# on #level#-1. + */ + virtual void prolongation(unsigned level, + dVector& dst, + const dVector& src) const; + /** * Solve exactly on coarsest grid. */ diff --git a/deal.II/deal.II/source/multigrid/multigrid.cc b/deal.II/deal.II/source/multigrid/multigrid.cc index 1a58b75b5c..e7fdaf0785 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.cc @@ -27,6 +27,7 @@ MultiGrid::precondition(dVector& dst, const dVector& src) const level_mgstep(maxlevel); } + void MultiGrid::level_mgstep(unsigned level) const { @@ -36,9 +37,15 @@ MultiGrid::level_mgstep(unsigned level) const return; } - for (unsigned i=0; i< n_presmooth; ++i) - { - smooth(level, d[level], s[level]); - } + smooth(level, d[level], s[level], n_pre_smooth); + + post_smooth(level, d[level], s[level], n_post_smooth); } + +void MultiGrid::post_smooth(unsigned level, + dVector& dst, const dVector& src, + unsigned steps) const +{ + smooth(level, dst, src, steps); +} diff --git a/deal.II/deal.II/source/numerics/multigrid.cc b/deal.II/deal.II/source/numerics/multigrid.cc index 1a58b75b5c..e7fdaf0785 100644 --- a/deal.II/deal.II/source/numerics/multigrid.cc +++ b/deal.II/deal.II/source/numerics/multigrid.cc @@ -27,6 +27,7 @@ MultiGrid::precondition(dVector& dst, const dVector& src) const level_mgstep(maxlevel); } + void MultiGrid::level_mgstep(unsigned level) const { @@ -36,9 +37,15 @@ MultiGrid::level_mgstep(unsigned level) const return; } - for (unsigned i=0; i< n_presmooth; ++i) - { - smooth(level, d[level], s[level]); - } + smooth(level, d[level], s[level], n_pre_smooth); + + post_smooth(level, d[level], s[level], n_post_smooth); } + +void MultiGrid::post_smooth(unsigned level, + dVector& dst, const dVector& src, + unsigned steps) const +{ + smooth(level, dst, src, steps); +}