From 5cf61b4611be11ac4bed5fd2d67dfc4dbcca874c Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 16 Dec 1999 15:10:32 +0000 Subject: [PATCH] Move some functions from MGDoFHandler to MGDoFTools. git-svn-id: https://svn.dealii.org/trunk@2074 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_tools.h | 2 +- deal.II/deal.II/include/dofs/mg_dof_handler.h | 39 +++++------- deal.II/deal.II/include/dofs/mg_dof_tools.h | 61 +++++++++++++++++++ .../include/multigrid/mg_dof_handler.h | 39 +++++------- .../deal.II/include/multigrid/mg_dof_tools.h | 61 +++++++++++++++++++ .../deal.II/source/dofs/dof_renumbering.cc | 7 ++- deal.II/deal.II/source/dofs/mg_dof_handler.cc | 26 -------- deal.II/deal.II/source/dofs/mg_dof_tools.cc | 42 +++++++++++++ .../source/multigrid/mg_dof_handler.cc | 26 -------- .../deal.II/source/multigrid/mg_dof_tools.cc | 42 +++++++++++++ tests/deal.II/mg.cc | 3 +- tests/deal.II/mglocal.cc | 3 +- 12 files changed, 243 insertions(+), 108 deletions(-) create mode 100644 deal.II/deal.II/include/dofs/mg_dof_tools.h create mode 100644 deal.II/deal.II/include/multigrid/mg_dof_tools.h create mode 100644 deal.II/deal.II/source/dofs/mg_dof_tools.cc create mode 100644 deal.II/deal.II/source/multigrid/mg_dof_tools.cc diff --git a/deal.II/deal.II/include/dofs/dof_tools.h b/deal.II/deal.II/include/dofs/dof_tools.h index 49c05b3676..5bc970dc17 100644 --- a/deal.II/deal.II/include/dofs/dof_tools.h +++ b/deal.II/deal.II/include/dofs/dof_tools.h @@ -42,7 +42,7 @@ * other basis functions on a cell adjacent to the boundary vanish at the * boundary itself, except for those which are located on the boundary. * - * @author Wolfgang Bangerth and others, 1999 + * @author Wolfgang Bangerth and others, 1998, 1999 */ class DoFTools { diff --git a/deal.II/deal.II/include/dofs/mg_dof_handler.h b/deal.II/deal.II/include/dofs/mg_dof_handler.h index f27031aa0c..2315512e68 100644 --- a/deal.II/deal.II/include/dofs/mg_dof_handler.h +++ b/deal.II/deal.II/include/dofs/mg_dof_handler.h @@ -119,11 +119,21 @@ class MGDoFDimensionInfo<3> { - +/** + * This class manages degrees of freedom for a multilevel hierarchy of + * grids. It does mostly the same as does the #DoDHandler# class, but + * it uses a separate enumeration of the degrees of freedom on each + * level. For example, a vertex has several DoF numbers, one for each + * level of the triangulation on which it exists. + * + * At present, multilevel algorithms are not fully functional, so this + * documentation is still very brief. +//TODO: Extend MGDoFHandler doc + * + * @author Wolfgang Bangerth, 1998, 1999 + */ template -class MGDoFHandler - : - public DoFHandler +class MGDoFHandler : public DoFHandler { public: typedef typename MGDoFDimensionInfo::raw_line_iterator raw_line_iterator; @@ -190,27 +200,6 @@ class MGDoFHandler void renumber_dofs (const unsigned int level, const vector &new_numbers); - /** - * Write the sparsity structure of the - * matrix belonging to the specified - * #level# including constrained - * degrees of freedom into the - * matrix structure. The sparsity pattern - * does not include entries introduced by - * the elimination of constrained nodes. - * The sparsity - * pattern is not compressed, since if - * you want to call - * #ConstraintMatrix::condense(1)# - * afterwards, new entries have to be - * added. However, if you don't want to call - * #ConstraintMatrix::condense(1)#, you - * have to compress the matrix yourself, - * using #SparseMatrixStruct::compress()#. - */ - void make_sparsity_pattern (const unsigned int level, - SparseMatrixStruct &sparsity) const; - /*--------------------------------------*/ /** diff --git a/deal.II/deal.II/include/dofs/mg_dof_tools.h b/deal.II/deal.II/include/dofs/mg_dof_tools.h new file mode 100644 index 0000000000..4b7714b2e7 --- /dev/null +++ b/deal.II/deal.II/include/dofs/mg_dof_tools.h @@ -0,0 +1,61 @@ +/*---------------------------- mg_dof_tools.h ---------------------------*/ +/* $Id$ */ +#ifndef __mg_dof_tools_H +#define __mg_dof_tools_H +/*---------------------------- mg_dof_tools.h ---------------------------*/ + + +#include +#include + + +/** + * This is a collection of functions operating on, and manipulating + * the numbers of degrees of freedom in a multilevel triangulation. It + * is similar in purpose and function to the #DoFTools# class, but + * operates on #MGDoFHandler# objects instead of #DoFHandler# + * objects. See there and the documentation of the member functions + * for more information. + * + * All member functions are static, so there is no need to create an + * object of class #DoFTools#. + * + * @author Wolfgang Bangerth and others, 1999 + */ +class MGDoFTools +{ + public: + /** + * Write the sparsity structure + * of the matrix belonging to the + * specified #level# including + * constrained degrees of freedom + * into the matrix structure. The + * sparsity pattern does not + * include entries introduced by + * the elimination of constrained + * nodes. The sparsity pattern + * is not compressed, since if + * you want to call + * #ConstraintMatrix::condense(1)# + * afterwards, new entries have + * to be added. However, if you + * don't want to call + * #ConstraintMatrix::condense(1)#, + * you have to compress the + * matrix yourself, using + * #SparseMatrixStruct::compress()#. + */ + template + static void + make_sparsity_pattern (const MGDoFHandler &dof_handler, + const unsigned int level, + SparseMatrixStruct &sparsity); +}; + + + +/*---------------------------- mg_dof_tools.h ---------------------------*/ +/* end of #ifndef __mg_dof_tools_H */ +#endif +/*---------------------------- mg_dof_tools.h ---------------------------*/ diff --git a/deal.II/deal.II/include/multigrid/mg_dof_handler.h b/deal.II/deal.II/include/multigrid/mg_dof_handler.h index f27031aa0c..2315512e68 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_handler.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_handler.h @@ -119,11 +119,21 @@ class MGDoFDimensionInfo<3> { - +/** + * This class manages degrees of freedom for a multilevel hierarchy of + * grids. It does mostly the same as does the #DoDHandler# class, but + * it uses a separate enumeration of the degrees of freedom on each + * level. For example, a vertex has several DoF numbers, one for each + * level of the triangulation on which it exists. + * + * At present, multilevel algorithms are not fully functional, so this + * documentation is still very brief. +//TODO: Extend MGDoFHandler doc + * + * @author Wolfgang Bangerth, 1998, 1999 + */ template -class MGDoFHandler - : - public DoFHandler +class MGDoFHandler : public DoFHandler { public: typedef typename MGDoFDimensionInfo::raw_line_iterator raw_line_iterator; @@ -190,27 +200,6 @@ class MGDoFHandler void renumber_dofs (const unsigned int level, const vector &new_numbers); - /** - * Write the sparsity structure of the - * matrix belonging to the specified - * #level# including constrained - * degrees of freedom into the - * matrix structure. The sparsity pattern - * does not include entries introduced by - * the elimination of constrained nodes. - * The sparsity - * pattern is not compressed, since if - * you want to call - * #ConstraintMatrix::condense(1)# - * afterwards, new entries have to be - * added. However, if you don't want to call - * #ConstraintMatrix::condense(1)#, you - * have to compress the matrix yourself, - * using #SparseMatrixStruct::compress()#. - */ - void make_sparsity_pattern (const unsigned int level, - SparseMatrixStruct &sparsity) const; - /*--------------------------------------*/ /** diff --git a/deal.II/deal.II/include/multigrid/mg_dof_tools.h b/deal.II/deal.II/include/multigrid/mg_dof_tools.h new file mode 100644 index 0000000000..4b7714b2e7 --- /dev/null +++ b/deal.II/deal.II/include/multigrid/mg_dof_tools.h @@ -0,0 +1,61 @@ +/*---------------------------- mg_dof_tools.h ---------------------------*/ +/* $Id$ */ +#ifndef __mg_dof_tools_H +#define __mg_dof_tools_H +/*---------------------------- mg_dof_tools.h ---------------------------*/ + + +#include +#include + + +/** + * This is a collection of functions operating on, and manipulating + * the numbers of degrees of freedom in a multilevel triangulation. It + * is similar in purpose and function to the #DoFTools# class, but + * operates on #MGDoFHandler# objects instead of #DoFHandler# + * objects. See there and the documentation of the member functions + * for more information. + * + * All member functions are static, so there is no need to create an + * object of class #DoFTools#. + * + * @author Wolfgang Bangerth and others, 1999 + */ +class MGDoFTools +{ + public: + /** + * Write the sparsity structure + * of the matrix belonging to the + * specified #level# including + * constrained degrees of freedom + * into the matrix structure. The + * sparsity pattern does not + * include entries introduced by + * the elimination of constrained + * nodes. The sparsity pattern + * is not compressed, since if + * you want to call + * #ConstraintMatrix::condense(1)# + * afterwards, new entries have + * to be added. However, if you + * don't want to call + * #ConstraintMatrix::condense(1)#, + * you have to compress the + * matrix yourself, using + * #SparseMatrixStruct::compress()#. + */ + template + static void + make_sparsity_pattern (const MGDoFHandler &dof_handler, + const unsigned int level, + SparseMatrixStruct &sparsity); +}; + + + +/*---------------------------- mg_dof_tools.h ---------------------------*/ +/* end of #ifndef __mg_dof_tools_H */ +#endif +/*---------------------------- mg_dof_tools.h ---------------------------*/ diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index 4e7ff00d39..402788c30b 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -1,14 +1,15 @@ /* $Id$ */ +#include #include #include #include #include #include +#include +#include #include #include -#include -#include #include #include @@ -214,7 +215,7 @@ void DoFRenumbering::Cuthill_McKee (MGDoFHandler &dof_handler, // make the connection graph SparseMatrixStruct sparsity (dof_handler.n_dofs(level), dof_handler.max_couplings_between_dofs()); - dof_handler.make_sparsity_pattern (level, sparsity); + MGDoFTools::make_sparsity_pattern (dof_handler, level, sparsity); const int n_dofs = sparsity.n_rows(); // store the new dof numbers; -1 means diff --git a/deal.II/deal.II/source/dofs/mg_dof_handler.cc b/deal.II/deal.II/source/dofs/mg_dof_handler.cc index 87f8192c25..d615123b84 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_handler.cc @@ -1539,32 +1539,6 @@ unsigned int MGDoFHandler::n_dofs (const unsigned int level) const { -template -void MGDoFHandler::make_sparsity_pattern (const unsigned int level, - SparseMatrixStruct &sparsity) const { - Assert (selected_fe != 0, ExcNoFESelected()); - Assert (sparsity.n_rows() == n_dofs(level), - ExcDimensionMismatch (sparsity.n_rows(), n_dofs(level))); - Assert (sparsity.n_cols() == n_dofs(level), - ExcDimensionMismatch (sparsity.n_cols(), n_dofs(level))); - - const unsigned int dofs_per_cell = selected_fe->dofs_per_cell; - vector dofs_on_this_cell(dofs_per_cell); - cell_iterator cell = begin(level), - endc = end(level); - for (; cell!=endc; ++cell) - { - cell->get_mg_dof_indices (dofs_on_this_cell); - // make sparsity pattern for this cell - for (unsigned int i=0; i diff --git a/deal.II/deal.II/source/dofs/mg_dof_tools.cc b/deal.II/deal.II/source/dofs/mg_dof_tools.cc new file mode 100644 index 0000000000..e66eec7357 --- /dev/null +++ b/deal.II/deal.II/source/dofs/mg_dof_tools.cc @@ -0,0 +1,42 @@ +/* $Id$ */ + +#include +#include +#include +#include +#include +#include + + +template +void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &mg_dof_handler, + const unsigned int level, + SparseMatrixStruct &sparsity) +{ + Assert (sparsity.n_rows() == mg_dof_handler.n_dofs(level), + ExcDimensionMismatch (sparsity.n_rows(), mg_dof_handler.n_dofs(level))); + Assert (sparsity.n_cols() == mg_dof_handler.n_dofs(level), + ExcDimensionMismatch (sparsity.n_cols(), mg_dof_handler.n_dofs(level))); + + const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; + vector dofs_on_this_cell(dofs_per_cell); + MGDoFHandler::cell_iterator cell = mg_dof_handler.begin(level), + endc = mg_dof_handler.end(level); + for (; cell!=endc; ++cell) + { + cell->get_mg_dof_indices (dofs_on_this_cell); + // make sparsity pattern for this cell + for (unsigned int i=0; i &, + const unsigned int, + SparseMatrixStruct &); + diff --git a/deal.II/deal.II/source/multigrid/mg_dof_handler.cc b/deal.II/deal.II/source/multigrid/mg_dof_handler.cc index 87f8192c25..d615123b84 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_handler.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_handler.cc @@ -1539,32 +1539,6 @@ unsigned int MGDoFHandler::n_dofs (const unsigned int level) const { -template -void MGDoFHandler::make_sparsity_pattern (const unsigned int level, - SparseMatrixStruct &sparsity) const { - Assert (selected_fe != 0, ExcNoFESelected()); - Assert (sparsity.n_rows() == n_dofs(level), - ExcDimensionMismatch (sparsity.n_rows(), n_dofs(level))); - Assert (sparsity.n_cols() == n_dofs(level), - ExcDimensionMismatch (sparsity.n_cols(), n_dofs(level))); - - const unsigned int dofs_per_cell = selected_fe->dofs_per_cell; - vector dofs_on_this_cell(dofs_per_cell); - cell_iterator cell = begin(level), - endc = end(level); - for (; cell!=endc; ++cell) - { - cell->get_mg_dof_indices (dofs_on_this_cell); - // make sparsity pattern for this cell - for (unsigned int i=0; i diff --git a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc new file mode 100644 index 0000000000..e66eec7357 --- /dev/null +++ b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc @@ -0,0 +1,42 @@ +/* $Id$ */ + +#include +#include +#include +#include +#include +#include + + +template +void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &mg_dof_handler, + const unsigned int level, + SparseMatrixStruct &sparsity) +{ + Assert (sparsity.n_rows() == mg_dof_handler.n_dofs(level), + ExcDimensionMismatch (sparsity.n_rows(), mg_dof_handler.n_dofs(level))); + Assert (sparsity.n_cols() == mg_dof_handler.n_dofs(level), + ExcDimensionMismatch (sparsity.n_cols(), mg_dof_handler.n_dofs(level))); + + const unsigned int dofs_per_cell = mg_dof_handler.get_fe().dofs_per_cell; + vector dofs_on_this_cell(dofs_per_cell); + MGDoFHandler::cell_iterator cell = mg_dof_handler.begin(level), + endc = mg_dof_handler.end(level); + for (; cell!=endc; ++cell) + { + cell->get_mg_dof_indices (dofs_on_this_cell); + // make sparsity pattern for this cell + for (unsigned int i=0; i &, + const unsigned int, + SparseMatrixStruct &); + diff --git a/tests/deal.II/mg.cc b/tests/deal.II/mg.cc index dfadf7b593..b5993d549f 100644 --- a/tests/deal.II/mg.cc +++ b/tests/deal.II/mg.cc @@ -26,6 +26,7 @@ #include #include #include +#include #include "helmholtz.h" @@ -120,7 +121,7 @@ int main() { mgstruct[i].reinit(mgdof.n_dofs(i), mgdof.n_dofs(i), mgdof.max_couplings_between_dofs()); - mgdof.make_sparsity_pattern(i, mgstruct[i]); + MGDoFTools::make_sparsity_pattern(mgdof, i, mgstruct[i]); mgstruct[i].compress(); mgA[i].reinit(mgstruct[i]); diff --git a/tests/deal.II/mglocal.cc b/tests/deal.II/mglocal.cc index f0174a666b..2ce1219d35 100644 --- a/tests/deal.II/mglocal.cc +++ b/tests/deal.II/mglocal.cc @@ -27,6 +27,7 @@ #include #include #include +#include #include @@ -133,7 +134,7 @@ int main() { mgstruct[i].reinit(mgdof.n_dofs(i), mgdof.n_dofs(i), mgdof.max_couplings_between_dofs()); - mgdof.make_sparsity_pattern(i, mgstruct[i]); + MGDoFTools::make_sparsity_pattern(mgdof, i, mgstruct[i]); mgstruct[i].compress(); mgA[i].reinit(mgstruct[i]); -- 2.39.5