From 70726988930dc80911f3548a9c5dd7b31260d87d Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 26 Aug 1998 08:56:43 +0000 Subject: [PATCH] Implement the creation of sparsity patterns for the levelwise matrices. git-svn-id: https://svn.dealii.org/trunk@523 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/mg_dof_handler.h | 36 +++++++++++++++++++ .../include/multigrid/mg_dof_handler.h | 36 +++++++++++++++++++ deal.II/deal.II/source/dofs/mg_dof_handler.cc | 36 ++++++++++++++++++- .../source/multigrid/mg_dof_handler.cc | 36 ++++++++++++++++++- 4 files changed, 142 insertions(+), 2 deletions(-) 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 0e52401f37..34840ddd18 100644 --- a/deal.II/deal.II/include/dofs/mg_dof_handler.h +++ b/deal.II/deal.II/include/dofs/mg_dof_handler.h @@ -156,6 +156,26 @@ class MGDoFHandler : public DoFHandler { const bool use_constraints = false, const vector &starting_points = vector()); + /** + * 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 #dSMatrixStruct::compress()#. + */ + void make_sparsity_pattern (const unsigned int level, + dSMatrixStruct &sparsity) const; /*--------------------------------------*/ @@ -623,6 +643,22 @@ class MGDoFHandler : public DoFHandler { /*@}*/ /*---------------------------------------*/ + + /** + * Return the number of degrees of freedom + * on the specified level. + * Included in this number are those + * DoFs which are constrained by + * hanging nodes. + */ + unsigned int n_dofs (const unsigned int level) const; + + /** + * Exception. + */ + DeclException1 (ExcInvalidLevel, + int, + << "The level index " << arg1 << "was not in the valid range."); private: 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 0e52401f37..34840ddd18 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_handler.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_handler.h @@ -156,6 +156,26 @@ class MGDoFHandler : public DoFHandler { const bool use_constraints = false, const vector &starting_points = vector()); + /** + * 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 #dSMatrixStruct::compress()#. + */ + void make_sparsity_pattern (const unsigned int level, + dSMatrixStruct &sparsity) const; /*--------------------------------------*/ @@ -623,6 +643,22 @@ class MGDoFHandler : public DoFHandler { /*@}*/ /*---------------------------------------*/ + + /** + * Return the number of degrees of freedom + * on the specified level. + * Included in this number are those + * DoFs which are constrained by + * hanging nodes. + */ + unsigned int n_dofs (const unsigned int level) const; + + /** + * Exception. + */ + DeclException1 (ExcInvalidLevel, + int, + << "The level index " << arg1 << "was not in the valid range."); private: 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 bb3d7d999f..d9f1a8b213 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_handler.cc @@ -10,7 +10,7 @@ #include #include #include - +#include /* ------------------------ MGVertexDoFs ----------------------------------- */ @@ -962,6 +962,40 @@ MGDoFHandler<2>::distribute_dofs_on_cell (active_cell_iterator &cell, +template +unsigned int MGDoFHandler::n_dofs (const unsigned int level) const { + Assert (level < mg_used_dofs.size(), ExcInvalidLevel(level)); + + return mg_used_dofs[level]; +}; + + + +template +void MGDoFHandler::make_sparsity_pattern (const unsigned int level, + dSMatrixStruct &sparsity) const { + Assert (selected_fe != 0, ExcNoFESelected()); + Assert (sparsity.n_rows() == n_dofs(level), + ExcDifferentDimensions (sparsity.n_rows(), n_dofs(level))); + Assert (sparsity.n_cols() == n_dofs(level), + ExcDifferentDimensions (sparsity.n_cols(), n_dofs(level))); + + const unsigned int total_dofs = selected_fe->total_dofs; + vector dofs_on_this_cell(total_dofs); + cell_iterator cell = begin_active(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 #include #include - +#include /* ------------------------ MGVertexDoFs ----------------------------------- */ @@ -962,6 +962,40 @@ MGDoFHandler<2>::distribute_dofs_on_cell (active_cell_iterator &cell, +template +unsigned int MGDoFHandler::n_dofs (const unsigned int level) const { + Assert (level < mg_used_dofs.size(), ExcInvalidLevel(level)); + + return mg_used_dofs[level]; +}; + + + +template +void MGDoFHandler::make_sparsity_pattern (const unsigned int level, + dSMatrixStruct &sparsity) const { + Assert (selected_fe != 0, ExcNoFESelected()); + Assert (sparsity.n_rows() == n_dofs(level), + ExcDifferentDimensions (sparsity.n_rows(), n_dofs(level))); + Assert (sparsity.n_cols() == n_dofs(level), + ExcDifferentDimensions (sparsity.n_cols(), n_dofs(level))); + + const unsigned int total_dofs = selected_fe->total_dofs; + vector dofs_on_this_cell(total_dofs); + cell_iterator cell = begin_active(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