From: Wolfgang Bangerth Date: Wed, 26 Jan 2000 08:58:03 +0000 (+0000) Subject: Separate the SparseMatrixStruct class into a file of its own and rename it to Sparsit... X-Git-Tag: v8.0.0~21094 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=76e648a70615a344bad882b94dca171389a2906e;p=dealii.git Separate the SparseMatrixStruct class into a file of its own and rename it to SparsityPattern. git-svn-id: https://svn.dealii.org/trunk@2266 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/Attic/examples/dof/dof_test.cc b/deal.II/deal.II/Attic/examples/dof/dof_test.cc index 4c46d77b3f..d820d9c111 100644 --- a/deal.II/deal.II/Attic/examples/dof/dof_test.cc +++ b/deal.II/deal.II/Attic/examples/dof/dof_test.cc @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -360,8 +360,8 @@ void TestCases::run (ParameterHandler &prm) { cout << " Renumbering degrees of freedom..." << endl; DoFRenumbering::Cuthill_McKee (*dof); - SparseMatrixStruct sparsity (dof->n_dofs(), - dof->max_couplings_between_dofs()); + SparsityPattern sparsity (dof->n_dofs(), + dof->max_couplings_between_dofs()); DoFTools::make_sparsity_pattern (*dof, sparsity); diff --git a/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc b/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc index 86d512190e..e48fd7e987 100644 --- a/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc +++ b/deal.II/deal.II/Attic/examples/multigrid/multigrid.cc @@ -128,7 +128,7 @@ class PoissonProblem { /** * Sparsity pattern of the system matrix. */ - SparseMatrixStruct system_sparsity; + SparsityPattern system_sparsity; /** * System matrix. diff --git a/deal.II/deal.II/Attic/examples/step-by-step/step-2/step-2.cc b/deal.II/deal.II/Attic/examples/step-by-step/step-2/step-2.cc index e39eda858b..181571a7bc 100644 --- a/deal.II/deal.II/Attic/examples/step-by-step/step-2/step-2.cc +++ b/deal.II/deal.II/Attic/examples/step-by-step/step-2/step-2.cc @@ -221,8 +221,8 @@ void distribute_dofs (DoFHandler<2> &dof_handler) // many rows and columns as there // are degrees of freedom on the // grid: - SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(), - dof_handler.n_dofs()); + SparsityPattern sparsity_pattern (dof_handler.n_dofs(), + dof_handler.n_dofs()); // We fill it with the places where // nonzero elements will be located // given the present numbering of @@ -310,8 +310,8 @@ void renumber_dofs (DoFHandler<2> &dof_handler) // Renumber the degrees of freedom... DoFRenumbering::Cuthill_McKee (dof_handler); // ...regenerate the sparsity pattern... - SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(), - dof_handler.n_dofs()); + SparsityPattern sparsity_pattern (dof_handler.n_dofs(), + dof_handler.n_dofs()); DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); sparsity_pattern.compress (); // ...and output the result: diff --git a/deal.II/deal.II/Attic/examples/step-by-step/step-3/step-3.cc b/deal.II/deal.II/Attic/examples/step-by-step/step-3/step-3.cc index 10e649fe44..448bae97f8 100644 --- a/deal.II/deal.II/Attic/examples/step-by-step/step-3/step-3.cc +++ b/deal.II/deal.II/Attic/examples/step-by-step/step-3/step-3.cc @@ -128,7 +128,7 @@ class LaplaceProblem // system matrix resulting from // the discretization of the // Laplace equation... - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; // ...and variables which will @@ -245,7 +245,7 @@ void LaplaceProblem::make_grid_and_dofs () // `sealed', so to say), and we can // initialize the matrix itself // with it. Note that the - // SparseMatrixStruct object does + // SparsityPattern object does // not hold the values of the // matrix, it only stores the // places where entries are. The diff --git a/deal.II/deal.II/Attic/examples/step-by-step/step-4/step-4.cc b/deal.II/deal.II/Attic/examples/step-by-step/step-4/step-4.cc index 9b45c7d7f5..805feb5f53 100644 --- a/deal.II/deal.II/Attic/examples/step-by-step/step-4/step-4.cc +++ b/deal.II/deal.II/Attic/examples/step-by-step/step-4/step-4.cc @@ -75,7 +75,7 @@ class LaplaceProblem FEQ1 fe; DoFHandler dof_handler; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/deal.II/Attic/examples/step-by-step/step-5/step-5.cc b/deal.II/deal.II/Attic/examples/step-by-step/step-5/step-5.cc index 21ad88c484..4f389ee257 100644 --- a/deal.II/deal.II/Attic/examples/step-by-step/step-5/step-5.cc +++ b/deal.II/deal.II/Attic/examples/step-by-step/step-5/step-5.cc @@ -72,7 +72,7 @@ class LaplaceProblem FEQ1 fe; DoFHandler dof_handler; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/deal.II/Attic/examples/step-by-step/step-6/step-6.cc b/deal.II/deal.II/Attic/examples/step-by-step/step-6/step-6.cc index b26124a9af..aa281775ed 100644 --- a/deal.II/deal.II/Attic/examples/step-by-step/step-6/step-6.cc +++ b/deal.II/deal.II/Attic/examples/step-by-step/step-6/step-6.cc @@ -121,7 +121,7 @@ class LaplaceProblem // hanging nodes: ConstraintMatrix hanging_node_constraints; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/deal.II/Attic/examples/step-by-step/step-8/step-8.cc b/deal.II/deal.II/Attic/examples/step-by-step/step-8/step-8.cc index 93d6d2c47f..5b03e6e1e3 100644 --- a/deal.II/deal.II/Attic/examples/step-by-step/step-8/step-8.cc +++ b/deal.II/deal.II/Attic/examples/step-by-step/step-8/step-8.cc @@ -86,7 +86,7 @@ class ElasticProblem ConstraintMatrix hanging_node_constraints; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/deal.II/include/dofs/dof_accessor.templates.h b/deal.II/deal.II/include/dofs/dof_accessor.templates.h index 161b79d683..d8515f2fc6 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -12,10 +12,6 @@ #include #include -#include -#include -#include - #include diff --git a/deal.II/deal.II/include/dofs/dof_constraints.h b/deal.II/deal.II/include/dofs/dof_constraints.h index ae3a955c9d..4b4500ed1b 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.h @@ -158,15 +158,15 @@ class ConstraintMatrix : public Subscriptor * Condense a given sparsity pattern. This * function assumes the uncondensed * matrix struct to be compressed and the - * to be filled one to be empty. The + * one to be filled to be empty. The * condensed structure is compressed * afterwards. * * The constraint matrix object must be * closed to call this function. */ - void condense (const SparseMatrixStruct &uncondensed, - SparseMatrixStruct &condensed) const; + void condense (const SparsityPattern &uncondensed, + SparsityPattern &condensed) const; /** @@ -185,7 +185,7 @@ class ConstraintMatrix : public Subscriptor * The matrix struct is compressed at the * end of the function. */ - void condense (SparseMatrixStruct &sparsity) const; + void condense (SparsityPattern &sparsity) const; /** * Condense a given matrix. The associated diff --git a/deal.II/deal.II/include/dofs/dof_constraints.templates.h b/deal.II/deal.II/include/dofs/dof_constraints.templates.h index 5c2f975c32..854aa7e35b 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.templates.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.templates.h @@ -1,9 +1,20 @@ +/*---------------------------- dof_constraints.templates.h ---------------------------*/ +/* $Id$ */ +#ifndef __dof_constraints_templates_H +#define __dof_constraints_templates_H +/*---------------------------- dof_constraints.templates.h ---------------------------*/ + + +#include +#include + + template void ConstraintMatrix::condense (const SparseMatrix &uncondensed, SparseMatrix &condensed) const { - const SparseMatrixStruct &uncondensed_struct = uncondensed.get_sparsity_pattern (); + const SparsityPattern &uncondensed_struct = uncondensed.get_sparsity_pattern (); Assert (sorted == true, ExcMatrixNotClosed()); Assert (uncondensed_struct.is_compressed() == true, ExcMatrixNotClosed()); @@ -128,7 +139,7 @@ template void ConstraintMatrix::condense (SparseMatrix &uncondensed) const { - const SparseMatrixStruct &sparsity = uncondensed.get_sparsity_pattern (); + const SparsityPattern &sparsity = uncondensed.get_sparsity_pattern (); Assert (sorted == true, ExcMatrixNotClosed()); Assert (sparsity.is_compressed() == true, ExcMatrixNotClosed()); @@ -466,3 +477,10 @@ ConstraintMatrix::distribute (Vector &vec) const }; + + + +/*---------------------------- dof_constraints.templates.h ---------------------------*/ +/* end of #ifndef __dof_constraints_templates_H */ +#endif +/*---------------------------- dof_constraints.templates.h ---------------------------*/ diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index e0c7e59111..775ba3c8ae 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -389,7 +389,7 @@ class DoFHandler : public Subscriptor, * This is the maximum number of entries * per line in the system matrix; this * information can therefore be used upon - * construction of the #SparseMatrixStruct# + * construction of the #SparsityPattern# * object. * * The returned number is not really the diff --git a/deal.II/deal.II/include/dofs/dof_tools.h b/deal.II/deal.II/include/dofs/dof_tools.h index 517e678e67..07cfc35692 100644 --- a/deal.II/deal.II/include/dofs/dof_tools.h +++ b/deal.II/deal.II/include/dofs/dof_tools.h @@ -84,12 +84,12 @@ class DoFTools * afterwards. * * Remember using - * #SparseMatrixStruct::compress()# + * #SparsityPattern::compress()# * after generating the pattern. */ template static void make_sparsity_pattern (const DoFHandler &dof, - SparseMatrixStruct &sparsity_pattern); + SparsityPattern &sparsity_pattern); /** * Locate non-zero entries for @@ -149,7 +149,7 @@ class DoFTools template static void make_sparsity_pattern (const DoFHandler &dof, const vector > &mask, - SparseMatrixStruct &sparsity_pattern); + SparsityPattern &sparsity_pattern); /** * Write the sparsity structure @@ -170,7 +170,7 @@ class DoFTools * #ConstraintMatrix::condense(1)#, * you have to compress the * matrix yourself, using - * #SparseMatrixStruct::compress()#. + * #SparsityPattern::compress()#. * * Since this function is * obviously useless in one @@ -181,7 +181,7 @@ class DoFTools static void make_boundary_sparsity_pattern (const DoFHandler &dof, const vector &dof_to_boundary_mapping, - SparseMatrixStruct &sparsity_pattern); + SparsityPattern &sparsity_pattern); /** * Write the sparsity structure of the @@ -219,7 +219,7 @@ class DoFTools make_boundary_sparsity_pattern (const DoFHandler& dof, const typename DoFHandler::FunctionMap &boundary_indicators, const vector &dof_to_boundary_mapping, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); /** * Generate sparsity pattern for @@ -239,7 +239,7 @@ class DoFTools */ template static void make_flux_sparsity_pattern (const DoFHandler &dof_handler, - SparseMatrixStruct &sparsity_pattern); + SparsityPattern &sparsity_pattern); /** * Make up the constraints which diff --git a/deal.II/deal.II/include/dofs/mg_dof_tools.h b/deal.II/deal.II/include/dofs/mg_dof_tools.h index 4b7714b2e7..c97e55e53c 100644 --- a/deal.II/deal.II/include/dofs/mg_dof_tools.h +++ b/deal.II/deal.II/include/dofs/mg_dof_tools.h @@ -44,13 +44,13 @@ class MGDoFTools * #ConstraintMatrix::condense(1)#, * you have to compress the * matrix yourself, using - * #SparseMatrixStruct::compress()#. + * #SparsityPattern::compress()#. */ template static void make_sparsity_pattern (const MGDoFHandler &dof_handler, const unsigned int level, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); }; diff --git a/deal.II/deal.II/include/multigrid/mg_dof_tools.h b/deal.II/deal.II/include/multigrid/mg_dof_tools.h index 4b7714b2e7..c97e55e53c 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_tools.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_tools.h @@ -44,13 +44,13 @@ class MGDoFTools * #ConstraintMatrix::condense(1)#, * you have to compress the * matrix yourself, using - * #SparseMatrixStruct::compress()#. + * #SparsityPattern::compress()#. */ template static void make_sparsity_pattern (const MGDoFHandler &dof_handler, const unsigned int level, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); }; diff --git a/deal.II/deal.II/include/multigrid/multigrid.h b/deal.II/deal.II/include/multigrid/multigrid.h index bdac914ff0..16f83a9083 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.h +++ b/deal.II/deal.II/include/multigrid/multigrid.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -194,16 +193,21 @@ class MGTransferPrebuilt : public MGTransferBase private: - vector prolongation_sparsities; + /** + * Sparsity patterns for the + * prolongation matrices on each + * level. + */ + vector prolongation_sparsities; - /** - * The actual prolongation matrix. - * column indices belong to the - * dof indices of the mother cell, - * i.e. the coarse level. - * while row indices belong to the - * child cell, i.e. the fine level. - */ + /** + * The actual prolongation matrix. + * column indices belong to the + * dof indices of the mother cell, + * i.e. the coarse level. + * while row indices belong to the + * child cell, i.e. the fine level. + */ vector > prolongation_matrices; }; diff --git a/deal.II/deal.II/include/numerics/base.h b/deal.II/deal.II/include/numerics/base.h index 1b0834b2c3..a153b14737 100644 --- a/deal.II/deal.II/include/numerics/base.h +++ b/deal.II/deal.II/include/numerics/base.h @@ -210,22 +210,22 @@ class ProblemBase { /** * Sparsity pattern of the system matrix. */ - SparseMatrixStruct system_sparsity; + SparsityPattern system_sparsity; /** * System matrix. */ - SparseMatrix system_matrix; + SparseMatrix system_matrix; /** * Vector storing the right hand side. */ - Vector right_hand_side; + Vector right_hand_side; /** * Solution vector. */ - Vector solution; + Vector solution; /** * List of constraints introduced by diff --git a/deal.II/deal.II/include/numerics/dof_renumbering.h b/deal.II/deal.II/include/numerics/dof_renumbering.h index 33a2cf70b7..37395e2abe 100644 --- a/deal.II/deal.II/include/numerics/dof_renumbering.h +++ b/deal.II/deal.II/include/numerics/dof_renumbering.h @@ -68,7 +68,7 @@ * * The renumbering algorithms need quite a lot of memory, since they have * to store for each dof with which other dofs it couples. This is done - * using a #SparseMatrixStruct# object used to store the sparsity pattern of + * using a #SparsityPattern# object used to store the sparsity pattern of * matrices. It * is not useful for the user to do anything between distributing the dofs * and renumbering, i.e. the calls to #DoFHandler::distribute_dofs# and diff --git a/deal.II/deal.II/include/numerics/matrices.h b/deal.II/deal.II/include/numerics/matrices.h index 695163e894..0cf81a99b2 100644 --- a/deal.II/deal.II/include/numerics/matrices.h +++ b/deal.II/deal.II/include/numerics/matrices.h @@ -24,7 +24,7 @@ * * All functions take a sparse matrix object to hold the matrix to be * created. The functions assume that the matrix is initialized with a - * sparsity pattern (#SparseMatrixStruct#) corresponding to the given degree + * sparsity pattern (#SparsityPattern#) corresponding to the given degree * of freedom handler, i.e. the sparsity structure is already as needed. * You can do this by calling the #DoFHandler::make_sparsity_pattern# * function. diff --git a/deal.II/deal.II/include/numerics/multigrid.h b/deal.II/deal.II/include/numerics/multigrid.h index bdac914ff0..16f83a9083 100644 --- a/deal.II/deal.II/include/numerics/multigrid.h +++ b/deal.II/deal.II/include/numerics/multigrid.h @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -194,16 +193,21 @@ class MGTransferPrebuilt : public MGTransferBase private: - vector prolongation_sparsities; + /** + * Sparsity patterns for the + * prolongation matrices on each + * level. + */ + vector prolongation_sparsities; - /** - * The actual prolongation matrix. - * column indices belong to the - * dof indices of the mother cell, - * i.e. the coarse level. - * while row indices belong to the - * child cell, i.e. the fine level. - */ + /** + * The actual prolongation matrix. + * column indices belong to the + * dof indices of the mother cell, + * i.e. the coarse level. + * while row indices belong to the + * child cell, i.e. the fine level. + */ vector > prolongation_matrices; }; diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index 674bbdacb8..3cc5bf2623 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index ce0cd63e92..b07515369a 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -4,7 +4,7 @@ #include -#include +#include #include #include #include @@ -12,7 +12,8 @@ -bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintMatrix::ConstraintLine &a) const { +bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintMatrix::ConstraintLine &a) const +{ return line < a.line; }; @@ -119,8 +120,8 @@ void ConstraintMatrix::clear () { -void ConstraintMatrix::condense (const SparseMatrixStruct &uncondensed, - SparseMatrixStruct &condensed) const { +void ConstraintMatrix::condense (const SparsityPattern &uncondensed, + SparsityPattern &condensed) const { Assert (sorted == true, ExcMatrixNotClosed()); Assert (uncondensed.is_compressed() == true, ExcMatrixNotClosed()); Assert (uncondensed.n_rows() == uncondensed.n_cols(), @@ -228,7 +229,7 @@ void ConstraintMatrix::condense (const SparseMatrixStruct &uncondensed, -void ConstraintMatrix::condense (SparseMatrixStruct &sparsity) const { +void ConstraintMatrix::condense (SparsityPattern &sparsity) const { Assert (sorted == true, ExcMatrixNotClosed()); Assert (sparsity.is_compressed() == false, ExcMatrixIsClosed()); Assert (sparsity.n_rows() == sparsity.n_cols(), diff --git a/deal.II/deal.II/source/dofs/dof_renumbering.cc b/deal.II/deal.II/source/dofs/dof_renumbering.cc index 402788c30b..576a66fa1f 100644 --- a/deal.II/deal.II/source/dofs/dof_renumbering.cc +++ b/deal.II/deal.II/source/dofs/dof_renumbering.cc @@ -1,6 +1,6 @@ /* $Id$ */ -#include +#include #include #include #include @@ -23,8 +23,8 @@ void DoFRenumbering::Cuthill_McKee (DoFHandler &dof_handler, const bool use_constraints, const vector &starting_indices) { // make the connection graph - SparseMatrixStruct sparsity (dof_handler.n_dofs(), - dof_handler.max_couplings_between_dofs()); + SparsityPattern sparsity (dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); DoFTools::make_sparsity_pattern (dof_handler, sparsity); if (use_constraints) @@ -213,8 +213,8 @@ void DoFRenumbering::Cuthill_McKee (MGDoFHandler &dof_handler, const bool reversed_numbering, const vector &starting_indices) { // make the connection graph - SparseMatrixStruct sparsity (dof_handler.n_dofs(level), - dof_handler.max_couplings_between_dofs()); + SparsityPattern sparsity (dof_handler.n_dofs(level), + dof_handler.max_couplings_between_dofs()); MGDoFTools::make_sparsity_pattern (dof_handler, level, sparsity); const int n_dofs = sparsity.n_rows(); diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index bf6eca3726..95faa5439e 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include @@ -19,8 +19,8 @@ template void -DoFTools::make_sparsity_pattern (const DoFHandler& dof, - SparseMatrixStruct &sparsity) +DoFTools::make_sparsity_pattern (const DoFHandler &dof, + SparsityPattern &sparsity) { const unsigned int n_dofs = dof.n_dofs(); @@ -47,9 +47,9 @@ DoFTools::make_sparsity_pattern (const DoFHandler& dof, template void -DoFTools::make_sparsity_pattern (const DoFHandler& dof, - const vector > &mask, - SparseMatrixStruct &sparsity) +DoFTools::make_sparsity_pattern (const DoFHandler &dof, + const vector > &mask, + SparsityPattern &sparsity) { const unsigned int n_dofs = dof.n_dofs(); const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell; @@ -96,8 +96,8 @@ DoFTools::make_sparsity_pattern (const DoFHandler& dof, template <> void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<1>&, - const vector &, - SparseMatrixStruct &) + const vector &, + SparsityPattern &) { Assert (false, ExcInternalError()); }; @@ -109,7 +109,7 @@ void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<1>&, const DoFHandler<1>::FunctionMap &, const vector &, - SparseMatrixStruct &) + SparsityPattern &) { Assert (false, ExcInternalError()); } @@ -122,7 +122,7 @@ template void DoFTools::make_boundary_sparsity_pattern (const DoFHandler& dof, const vector &dof_to_boundary_mapping, - SparseMatrixStruct &sparsity) + SparsityPattern &sparsity) { const unsigned int n_dofs = dof.n_dofs(); @@ -164,7 +164,7 @@ template void DoFTools::make_boundary_sparsity_pattern (const DoFHandler& dof, const DoFHandler::FunctionMap &boundary_indicators, const vector &dof_to_boundary_mapping, - SparseMatrixStruct &sparsity) + SparsityPattern &sparsity) { const unsigned int n_dofs = dof.n_dofs(); @@ -209,8 +209,8 @@ void DoFTools::make_boundary_sparsity_pattern (const DoFHandler& dof, template void -DoFTools::make_flux_sparsity_pattern (const DoFHandler& dof, - SparseMatrixStruct &sparsity) +DoFTools::make_flux_sparsity_pattern (const DoFHandler &dof, + SparsityPattern &sparsity) { const unsigned int n_dofs = dof.n_dofs(); @@ -666,26 +666,26 @@ DoFTools::extract_level_dofs(const unsigned int level, #if deal_II_dimension > 1 template void DoFTools::make_flux_sparsity_pattern (const DoFHandler& dof, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); template void DoFTools::make_boundary_sparsity_pattern (const DoFHandler& dof, const vector &, - SparseMatrixStruct &); + SparsityPattern &); template void DoFTools::make_boundary_sparsity_pattern (const DoFHandler& dof, const DoFHandler::FunctionMap &boundary_indicators, const vector &dof_to_boundary_mapping, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); #endif template void DoFTools::make_sparsity_pattern (const DoFHandler& dof, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); template void DoFTools::make_sparsity_pattern (const DoFHandler& dof, const vector > &mask, - SparseMatrixStruct &sparsity); + SparsityPattern &sparsity); template void diff --git a/deal.II/deal.II/source/dofs/mg_dof_accessor.cc b/deal.II/deal.II/source/dofs/mg_dof_accessor.cc index 27cc111a4d..3af8742a17 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_accessor.cc @@ -11,8 +11,8 @@ #include #include -#include -#include + + 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 db54f243d7..d880f442b1 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_handler.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_handler.cc @@ -12,7 +12,6 @@ #include #include #include -#include #include diff --git a/deal.II/deal.II/source/dofs/mg_dof_tools.cc b/deal.II/deal.II/source/dofs/mg_dof_tools.cc index e66eec7357..2fbb4da48c 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_tools.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_tools.cc @@ -1,6 +1,6 @@ /* $Id$ */ -#include +#include #include #include #include @@ -11,7 +11,7 @@ template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &mg_dof_handler, const unsigned int level, - SparseMatrixStruct &sparsity) + SparsityPattern &sparsity) { Assert (sparsity.n_rows() == mg_dof_handler.n_dofs(level), ExcDimensionMismatch (sparsity.n_rows(), mg_dof_handler.n_dofs(level))); @@ -38,5 +38,5 @@ void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &mg_dof_handler, // explicit instantiations template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &, const unsigned int, - SparseMatrixStruct &); + SparsityPattern &); diff --git a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc index 27cc111a4d..3af8742a17 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc @@ -11,8 +11,8 @@ #include #include -#include -#include + + 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 db54f243d7..d880f442b1 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_handler.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_handler.cc @@ -12,7 +12,6 @@ #include #include #include -#include #include diff --git a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc index e66eec7357..2fbb4da48c 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc @@ -1,6 +1,6 @@ /* $Id$ */ -#include +#include #include #include #include @@ -11,7 +11,7 @@ template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &mg_dof_handler, const unsigned int level, - SparseMatrixStruct &sparsity) + SparsityPattern &sparsity) { Assert (sparsity.n_rows() == mg_dof_handler.n_dofs(level), ExcDimensionMismatch (sparsity.n_rows(), mg_dof_handler.n_dofs(level))); @@ -38,5 +38,5 @@ void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &mg_dof_handler, // explicit instantiations template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler &, const unsigned int, - SparseMatrixStruct &); + SparsityPattern &); diff --git a/deal.II/deal.II/source/multigrid/mg_smoother.cc b/deal.II/deal.II/source/multigrid/mg_smoother.cc index 2b68b6ba36..9b6a5b4e97 100644 --- a/deal.II/deal.II/source/multigrid/mg_smoother.cc +++ b/deal.II/deal.II/source/multigrid/mg_smoother.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include diff --git a/deal.II/deal.II/source/multigrid/multigrid.cc b/deal.II/deal.II/source/multigrid/multigrid.cc index 1b23f08634..5ac6408d95 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.cc @@ -10,7 +10,7 @@ #include #include #include - +#include /* --------------------------------- MG ------------------------------------ */ @@ -91,7 +91,7 @@ void MGTransferPrebuilt::build_matrices (const MGDoFHandler &mg_dof) // level which have children for (unsigned int level=0; level::apply_boundary_values (const map &boundary_va return; - map::const_iterator dof = boundary_values.begin(), - endd = boundary_values.end(); + map::const_iterator dof = boundary_values.begin(), + endd = boundary_values.end(); const unsigned int n_dofs = matrix.m(); - const SparseMatrixStruct &sparsity = matrix.get_sparsity_pattern(); + const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); const unsigned int *sparsity_rowstart = sparsity.get_rowstart_indices(); const int *sparsity_colnums = sparsity.get_column_numbers(); diff --git a/deal.II/deal.II/source/numerics/mg_smoother.cc b/deal.II/deal.II/source/numerics/mg_smoother.cc index 2b68b6ba36..9b6a5b4e97 100644 --- a/deal.II/deal.II/source/numerics/mg_smoother.cc +++ b/deal.II/deal.II/source/numerics/mg_smoother.cc @@ -8,6 +8,7 @@ #include #include #include +#include #include diff --git a/deal.II/deal.II/source/numerics/multigrid.cc b/deal.II/deal.II/source/numerics/multigrid.cc index 1b23f08634..5ac6408d95 100644 --- a/deal.II/deal.II/source/numerics/multigrid.cc +++ b/deal.II/deal.II/source/numerics/multigrid.cc @@ -10,7 +10,7 @@ #include #include #include - +#include /* --------------------------------- MG ------------------------------------ */ @@ -91,7 +91,7 @@ void MGTransferPrebuilt::build_matrices (const MGDoFHandler &mg_dof) // level which have children for (unsigned int level=0; level &dof, // set up mass matrix and right hand side vec.reinit (dof.n_dofs()); - SparseMatrixStruct sparsity(dof.n_dofs(), - dof.n_dofs(), - dof.max_couplings_between_dofs()); + SparsityPattern sparsity(dof.n_dofs(), + dof.n_dofs(), + dof.max_couplings_between_dofs()); DoFTools::make_sparsity_pattern (dof, sparsity); constraints.condense (sparsity); @@ -672,8 +672,8 @@ VectorTools::project_boundary_values (const DoFHandler &dof, dof.map_dof_to_boundary_indices (boundary_functions, dof_to_boundary_mapping); // set up sparsity structure - SparseMatrixStruct sparsity(dof.n_boundary_dofs(boundary_functions), - dof.max_couplings_between_boundary_dofs()); + SparsityPattern sparsity(dof.n_boundary_dofs(boundary_functions), + dof.max_couplings_between_boundary_dofs()); DoFTools::make_boundary_sparsity_pattern (dof, boundary_functions, dof_to_boundary_mapping, diff --git a/deal.II/examples/step-2/step-2.cc b/deal.II/examples/step-2/step-2.cc index e39eda858b..181571a7bc 100644 --- a/deal.II/examples/step-2/step-2.cc +++ b/deal.II/examples/step-2/step-2.cc @@ -221,8 +221,8 @@ void distribute_dofs (DoFHandler<2> &dof_handler) // many rows and columns as there // are degrees of freedom on the // grid: - SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(), - dof_handler.n_dofs()); + SparsityPattern sparsity_pattern (dof_handler.n_dofs(), + dof_handler.n_dofs()); // We fill it with the places where // nonzero elements will be located // given the present numbering of @@ -310,8 +310,8 @@ void renumber_dofs (DoFHandler<2> &dof_handler) // Renumber the degrees of freedom... DoFRenumbering::Cuthill_McKee (dof_handler); // ...regenerate the sparsity pattern... - SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(), - dof_handler.n_dofs()); + SparsityPattern sparsity_pattern (dof_handler.n_dofs(), + dof_handler.n_dofs()); DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); sparsity_pattern.compress (); // ...and output the result: diff --git a/deal.II/examples/step-3/step-3.cc b/deal.II/examples/step-3/step-3.cc index 10e649fe44..448bae97f8 100644 --- a/deal.II/examples/step-3/step-3.cc +++ b/deal.II/examples/step-3/step-3.cc @@ -128,7 +128,7 @@ class LaplaceProblem // system matrix resulting from // the discretization of the // Laplace equation... - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; // ...and variables which will @@ -245,7 +245,7 @@ void LaplaceProblem::make_grid_and_dofs () // `sealed', so to say), and we can // initialize the matrix itself // with it. Note that the - // SparseMatrixStruct object does + // SparsityPattern object does // not hold the values of the // matrix, it only stores the // places where entries are. The diff --git a/deal.II/examples/step-4/step-4.cc b/deal.II/examples/step-4/step-4.cc index 9b45c7d7f5..805feb5f53 100644 --- a/deal.II/examples/step-4/step-4.cc +++ b/deal.II/examples/step-4/step-4.cc @@ -75,7 +75,7 @@ class LaplaceProblem FEQ1 fe; DoFHandler dof_handler; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/examples/step-5/step-5.cc b/deal.II/examples/step-5/step-5.cc index 21ad88c484..4f389ee257 100644 --- a/deal.II/examples/step-5/step-5.cc +++ b/deal.II/examples/step-5/step-5.cc @@ -72,7 +72,7 @@ class LaplaceProblem FEQ1 fe; DoFHandler dof_handler; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/examples/step-6/step-6.cc b/deal.II/examples/step-6/step-6.cc index b26124a9af..aa281775ed 100644 --- a/deal.II/examples/step-6/step-6.cc +++ b/deal.II/examples/step-6/step-6.cc @@ -121,7 +121,7 @@ class LaplaceProblem // hanging nodes: ConstraintMatrix hanging_node_constraints; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/examples/step-8/step-8.cc b/deal.II/examples/step-8/step-8.cc index 93d6d2c47f..5b03e6e1e3 100644 --- a/deal.II/examples/step-8/step-8.cc +++ b/deal.II/examples/step-8/step-8.cc @@ -86,7 +86,7 @@ class ElasticProblem ConstraintMatrix hanging_node_constraints; - SparseMatrixStruct sparsity_pattern; + SparsityPattern sparsity_pattern; SparseMatrix system_matrix; Vector solution; diff --git a/deal.II/lac/include/lac/precondition_block.templates.h b/deal.II/lac/include/lac/precondition_block.templates.h index a7c147d60e..386549ac3f 100644 --- a/deal.II/lac/include/lac/precondition_block.templates.h +++ b/deal.II/lac/include/lac/precondition_block.templates.h @@ -15,6 +15,7 @@ PreconditionBlock::PreconditionBlock (): A(0) {}; + template PreconditionBlock::~PreconditionBlock () { @@ -22,6 +23,8 @@ PreconditionBlock::~PreconditionBlock () inverse.erase(inverse.begin(), inverse.end()); } + + template void PreconditionBlock::clear () { @@ -30,6 +33,8 @@ void PreconditionBlock::clear () blocksize=0; } + + template void PreconditionBlock::use_matrix( const SparseMatrix &M) @@ -38,18 +43,21 @@ void PreconditionBlock::use_matrix( } + template void PreconditionBlock::set_block_size(unsigned int bsize) { blocksize=bsize; } + template unsigned int PreconditionBlock::block_size() const { return blocksize; } + template void PreconditionBlock::invert_diagblocks() { @@ -119,10 +127,12 @@ PreconditionBlockSOR::PreconditionBlockSOR(const number ome omega(omega) {} + template PreconditionBlockSOR::~PreconditionBlockSOR(){} + template template void PreconditionBlockSOR::operator() (Vector &dst, @@ -137,9 +147,9 @@ void PreconditionBlockSOR::operator() (Vector &dst Assert (inverse.size()==0 || inverse.size()==n_cells, ExcWrongNumberOfInverses(inverse.size(), n_cells)); - const SparseMatrixStruct &spars=M.get_sparsity_pattern(); - const unsigned int *rowstart = spars.get_rowstart_indices(); - const int *columns = spars.get_column_numbers(); + const SparsityPattern &spars = M.get_sparsity_pattern(); + const unsigned int *rowstart = spars.get_rowstart_indices(); + const int *columns = spars.get_column_numbers(); Vector b_cell(blocksize), x_cell(blocksize); diff --git a/deal.II/lac/include/lac/solver_selector.h b/deal.II/lac/include/lac/solver_selector.h index 410b8108c7..c1b4c3c48f 100644 --- a/deal.II/lac/include/lac/solver_selector.h +++ b/deal.II/lac/include/lac/solver_selector.h @@ -5,9 +5,8 @@ #define __solver_selector_H /*---------------------------- solver_selector.h ---------------------------*/ -#include #include -#include +#include #include #include #include @@ -17,7 +16,7 @@ #include #include #include - +#include /** diff --git a/deal.II/lac/include/lac/sparse_ilu.h b/deal.II/lac/include/lac/sparse_ilu.h index 9e13efa130..51b9fac3c7 100644 --- a/deal.II/lac/include/lac/sparse_ilu.h +++ b/deal.II/lac/include/lac/sparse_ilu.h @@ -56,7 +56,7 @@ * superset of the sparsity pattern in the original matrix. * * Such fill-in can be accomplished by various ways, one of which is a - * copy-constructor of the #SparseMatrixStruct# class which allows the addition + * copy-constructor of the #SparsityPattern# class which allows the addition * of side-diagonals to a given sparsity structure. * * @@ -95,7 +95,7 @@ class SparseILU : protected SparseMatrix * * You have to initialize * the matrix before usage with - * #reinit(SparseMatrixStruct)#. + * #reinit(SparsityPattern)#. */ SparseILU (); @@ -112,7 +112,7 @@ class SparseILU : protected SparseMatrix * long as #reinit# is not called with a * new sparsity structure. */ - SparseILU (const SparseMatrixStruct &sparsity); + SparseILU (const SparsityPattern &sparsity); /** * Reinitialize the object but keep to @@ -143,7 +143,7 @@ class SparseILU : protected SparseMatrix * function is not publically visible * any more. */ - void reinit (const SparseMatrixStruct &sparsity); + void reinit (const SparsityPattern &sparsity); /** * Perform the incomplete LU factorization diff --git a/deal.II/lac/include/lac/sparse_ilu.templates.h b/deal.II/lac/include/lac/sparse_ilu.templates.h index 4f0acff54a..c7b91ecb97 100644 --- a/deal.II/lac/include/lac/sparse_ilu.templates.h +++ b/deal.II/lac/include/lac/sparse_ilu.templates.h @@ -20,7 +20,7 @@ SparseILU::SparseILU () template -SparseILU::SparseILU (const SparseMatrixStruct &sparsity) : +SparseILU::SparseILU (const SparsityPattern &sparsity) : SparseMatrix (sparsity) {}; @@ -35,7 +35,7 @@ void SparseILU::reinit () template -void SparseILU::reinit (const SparseMatrixStruct &sparsity) +void SparseILU::reinit (const SparsityPattern &sparsity) { SparseMatrix::reinit (sparsity); }; @@ -108,7 +108,7 @@ void SparseILU::decompose (const SparseMatrix &matrix, // now work only on this // matrix - const SparseMatrixStruct &sparsity = get_sparsity_pattern(); + const SparsityPattern &sparsity = get_sparsity_pattern(); const unsigned int * const rowstart_indices = sparsity.get_rowstart_indices(); const int * const column_numbers = sparsity.get_column_numbers(); diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 06865ca0c6..d93459ae67 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -14,669 +14,7 @@ #include #include #include - -#include - - -//forward declarations -template class Vector; -template class SparseMatrix; -class ostream; - - - -/** - * Structure representing the sparsity pattern of a sparse matrix. - * - * The following picture will illustrate the relation between the - * #SparceMatrixStructure# an the #SparceMatrix#. - * - * \begin{verbatim} - * SparseMatrixStructure: \ - * | - * _________________________ | - * rowstart |0 | 4| 8|11|13|.... | - * |__|__|__|__|__|__________ | - * | \ \ | - * | \ \__ | - * | \ \ | - * | \ \__ | - * \ / \ \ | - * | \ \__ | - * | \ \ | - * | \ \__ | - * | \ \ | - * 0___________4___________8____ \ Position - * colnums |3 | 2| 9|17| 1| 4| 6| 8| 4|.. / - * /__|/_|__|__|__|__|__|__|__|__ | - * / / | - * / \______ _____/ \_____ _____/ | - * / \/ \/ | - * / / row = 0 row = 1 | - * / / | - * / / | - * / / | - * / /___colnums[1] | - * / | - * /_________colnums[0] | - * | - * / - * \end{verbatim} - * - * \begin{verbatim} - * For row = 0 - * - * it exists: (0| 3) = colnums[0] - * (0| 2) = colnums[1] - * (0| 9) = colnums[2] - * (0|17) = colnums[3] - * - * For row = 1 - * - * it exists: (1| 1) = colnums[4] - * (1| 4) = colnums[5] - * .... - * - * \end{verbatim} - * - * \begin{verbatim} - * SparseMatrix: \ - * | - * _____________________________ | - * val | | | | | | | | | 3|.. \ Value - * |__|__|__|__|__|__|__|__|__|__ / - * | - * | - * / - * \end{verbatim} - * - * If you want to get the #3# you need to get its position in the - * table above and its value by returning the value of the element on - * which the pointer shows, using #*val#. For example #val[8]=3#. Its - * position is #colnums[8]# so #row=2#. In other words, if you want to get - * the element #a_{24}# you know that #row=2#. To get the element, a - * search of #4# form #colnums[rowstart[2]]# to #colnums[rowstart[3]]# is - * needed. Then #a_{24}=val[number of the found element] = 3#. - * - * - * @author Original version by Roland Becker, Guido Kanschat, Franz-Theo Suttmeier; lots of enhancements, reorganisation and documentation by Wolfgang Bangerth; some documentation by Rasched Zamni - */ -class SparseMatrixStruct : public Subscriptor -{ - public: - /** - * Initialize the matrix empty, - * that is with no memory - * allocated. This is useful if - * you want such objects as - * member variables in other - * classes. You can make the - * structure usable by calling - * the #reinit# function. - */ - SparseMatrixStruct (); - - /** - * Copy constructor. This constructor is - * only allowed to be called if the matrix - * structure to be copied is empty. This is - * so in order to prevent involuntary - * copies of objects for temporaries, which - * can use large amounts of computing time. - * However, copy constructors are needed - * if yo want to use the STL data types - * on classes like this, e.g. to write - * such statements like - * #v.push_back (SparseMatrixStruct());#, - * with #v# a vector of #SparseMatrixStruct# - * objects. - * - * Usually, it is sufficient to use the - * explicit keyword to disallow unwanted - * temporaries, but for the STL vectors, - * this does not work. Since copying a - * structure like this is not useful - * anyway because multiple matrices can - * use the same sparsity structure, copies - * are only allowed for empty objects, as - * described above. - */ - SparseMatrixStruct (const SparseMatrixStruct &); - - /** - * Initialize a rectangular matrix with - * #m# rows and #n# columns. - * The matrix may contain at most #max_per_row# - * nonzero entries per row. - */ - SparseMatrixStruct (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row); - - /** - * Initialize a rectangular - * matrix with #m# rows and #n# - * columns. The maximal number - * of nonzero entries for each - * row is given by the - * #row_lengths# array. - */ - SparseMatrixStruct (const unsigned int m, - const unsigned int n, - const vector &row_lengths); - - /** - * Initialize a square matrix of dimension - * #n# with at most #max_per_row# - * nonzero entries per row. - */ - SparseMatrixStruct (const unsigned int n, - const unsigned int max_per_row); - - /** - * Initialize a square - * matrix with #m# rows and #m# - * columns. The maximal number - * of nonzero entries for each - * row is given by the - * #row_lengths# array. - */ - SparseMatrixStruct (const unsigned int m, - const vector &row_lengths); - - /** - * Copy operator. For this the same holds - * as for the copy constructor: it is - * declared, defined and fine to be called, - * but the latter only for empty objects. - */ - SparseMatrixStruct & operator = (const SparseMatrixStruct &); - - /** - * Make a copy with extra off-diagonals. - * - * This constructs objects intended for - * the application of the ILU(n)-method - * or other incomplete decompositions. - * Therefore, additional to the original - * entry structure, space for - * #extra_off_diagonals# - * side-diagonals is provided on both - * sides of the main diagonal. - * - * #max_per_row# is the maximum number of - * nonzero elements per row which this - * structure is to hold. It is assumed - * that this number is sufficiently large - * to accomodate both the elements in - * #original# as well as the new - * off-diagonal elements created by this - * constructor. You will usually want to - * give the same number as you gave for - * #original# plus the number of side - * diagonals times two. You may however - * give a larger value if you wish to add - * further nonzero entries for the - * decomposition based on other criteria - * than their being on side-diagonals. - * - * This function requires that #original# - * refer to a square matrix structure. - * It shall be compressed. The matrix - * structure is not compressed - * after this function finishes. - */ - SparseMatrixStruct(const SparseMatrixStruct& original, - const unsigned int max_per_row, - const unsigned int extra_off_diagonals); - - /** - * Destructor. - */ - ~SparseMatrixStruct (); - - /** - * Reallocate memory and set up data - * structures for a new matrix with - * #m# rows and #n# columns, - * with at most #max_per_row# - * nonzero entries per row. - * - * This function simply maps its - * operations to the other - * #reinit# function. - */ - void reinit (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row); - - /** - * Reallocate memory for a matrix - * of size #m \times n#. The - * number of entries for each row - * is taken from the array - * #row_lengths# which has to - * give this number of each row - * #i=1...m#. - * - * If #m*n==0# all memory is freed, - * resulting in a total reinitialization - * of the object. If it is nonzero, new - * memory is only allocated if the new - * size extends the old one. This is done - * to save time and to avoid fragmentation - * of the heap. - */ - void reinit (const unsigned int m, - const unsigned int n, - const vector &row_lengths); - - /** - * This function compresses the sparsity - * structure that this object represents. - * It does so by eliminating unused - * entries and sorting the remaining - * ones to allow faster access by usage - * of binary search algorithms. A special - * sorting scheme is used for the diagonal - * entry of square matrices, which is - * always the first entry of each row. - * - * The memory which is no more - * needed is released. - * - * #SparseMatrix# objects require the - * #SparseMatrixStruct# objects they are - * initialized with to be compressed, to - * reduce memory requirements. - */ - void compress (); - - /** - * Return whether the object is empty. It - * is empty if no memory is allocated, - * which is the same as that both - * dimensions are zero. - */ - bool empty () const; - - /** - * Return the maximum number of entries per - * row. Before compression, this equals the - * number given to the constructor, while - * after compression, it equals the maximum - * number of entries actually allocated by - * the user. - */ - unsigned int max_entries_per_row () const; - - /** - * Return the index of the matrix - * element with row number #i# and - * column number #j#. If the matrix - * element is not a nonzero one, - * return -1. - * - * This function is usually called - * by the #operator()# of the - * #SparseMatrix#. It shall only be - * called for compressed sparsity - * patterns, since in this case - * searching whether the entry - * exists can be done quite fast - * with a binary sort algorithm - * because the column numbers are - * sorted. - */ - int operator() (const unsigned int i, const unsigned int j) const; - - /** - * Add a nonzero entry to the matrix. - * This function may only be called - * for non-compressed sparsity patterns. - * - * If the entry already exists, nothing - * bad happens. - */ - void add (const unsigned int i, const unsigned int j); - - /** - * This matrix adds a whole connectivity - * list to the sparsity structure - * respresented by this object. It assumes - * the #rowcols# array to be a list of - * indices which are all linked together, - * i.e. all entries - * #(rowcols[i], rowcols[j])# for all - * #i,j=0...n# for this sparsity pattern - * are created. #n# is assumed to be the - * number of elements pointed to by - * #rowcols#. - */ - void add_matrix (const unsigned int n, const int* rowcols); - - ////////// - void add_matrix (const unsigned int m, const unsigned int n, - const int* rows, const int* cols); - - /** - * Print the sparsity of the matrix - * in a format that #gnuplot# understands - * and which can be used to plot the - * sparsity pattern in a graphical - * way. The format consists of pairs - * #i j# of nonzero elements, each - * representing one entry of this - * matrix, one per line of the output - * file. Indices are counted from - * zero on, as usual. Since sparsity - * patterns are printed in the same - * way as matrices are displayed, we - * print the negative of the column - * index, which means that the - * #(0,0)# element is in the top left - * rather than in the bottom left - * corner. - * - * Print the sparsity pattern in - * gnuplot by setting the data style - * to dots or points and use the - * #plot# command. - */ - void print_gnuplot (ostream &out) const; - - /** - * Return number of rows of this - * matrix, which equals the dimension - * of the image space. - */ - unsigned int n_rows () const; - - /** - * Return number of columns of this - * matrix, which equals the dimension - * of the range space. - */ - unsigned int n_cols () const; - - /** - * Number of entries in a specific row. - */ - unsigned int row_length (const unsigned int row) const; - - /** - * Access to column number field. - * Return the column number of - * the #index#th entry in #row#. - */ - unsigned int column_number (const unsigned int row, - const unsigned int index) const; - - /** - * Compute the bandwidth of the matrix - * represented by this structure. The - * bandwidth is the maximum of - * $|i-j|$ for which the index pair - * $(i,j)$ represents a nonzero entry - * of the matrix. - */ - unsigned int bandwidth () const; - - /** - * Return the number of nonzero elements of - * this matrix. Actually, it returns the - * number of entries in the sparsity - * pattern; if any of the entries should - * happen to be zero, it is counted - * anyway. - * - * This function may only be called if the - * matrix struct is compressed. It does not - * make too much sense otherwise anyway. - */ - unsigned int n_nonzero_elements () const; - - /** - * Return whether the structure is - * compressed or not. - */ - bool is_compressed () const; - - /** - * This is kind of an expert mode. Get - * access to the rowstart array, but - * read-only. - * - * Use of this function is highly - * deprecated. Use #row_length# - * and #column_number# instead. - * - * Though the return value is declared - * #const#, you should be aware that it - * may change if you call any nonconstant - * function of objects which operate on - * it. - * - * You should use this interface very - * carefully and only if you are absolutely - * sure to know what you do. You should - * also note that the structure of these - * arrays may change over time. - * If you change the layout yourself, you - * should also rename this function to - * avoid programs relying on outdated - * information! */ - const unsigned int * get_rowstart_indices () const; - - /** - * This is kind of an expert mode: get - * access to the colnums array, but - * readonly. - * - * Use of this function is highly - * deprecated. Use #row_length# - * and #column_number# instead. - * - * Though the return value is declared - * #const#, you should be aware that it - * may change if you call any nonconstant - * function of objects which operate on - * it. - * - * You should use this interface very - * carefully and only if you are absolutely - * sure to know what you do. You should - * also note that the structure of these - * arrays may change over time. - * If you change the layout yourself, you - * should also rename this function to - * avoid programs relying on outdated - * information! - */ - const int * get_column_numbers () const; - - - /** - * Exception - */ - DeclException1 (ExcInvalidNumber, - int, - << "The provided number is invalid here: " << arg1); - /** - * Exception - */ - DeclException2 (ExcInvalidIndex, - int, int, - << "The given index " << arg1 - << " should be less than " << arg2 << "."); - /** - * Exception - */ - DeclException2 (ExcNotEnoughSpace, - int, int, - << "Upon entering a new entry to row " << arg1 - << ": there was no free entry any more. " << endl - << "(Maximum number of entries for this row: " - << arg2 << "; maybe the matrix is already compressed?)"); - /** - * Exception - */ - DeclException0 (ExcNotCompressed); - /** - * Exception - */ - DeclException0 (ExcMatrixIsCompressed); - /** - * Exception - */ - DeclException0 (ExcEmptyObject); - /** - * Exception - */ - DeclException0 (ExcInternalError); - /** - * Exception - */ - DeclException0 (ExcIO); - /** - * Exception - */ - DeclException0 (ExcInvalidConstructorCall); - /** - * Exception - */ - DeclException0 (ExcNotSquare); - - private: - /** - * Maximum number of rows that can - * be stored in the #row_start# array. - * Since reallocation of that array - * only happens if the present one is - * too small, but never when the size - * of this matrix structure shrinks, - * #max_dim# might be larger than - * #rows# and in this case #row_start# - * has more elements than are used. - */ - unsigned int max_dim; - - /** - * Number of rows that this sparsity - * structure shall represent. - */ - unsigned int rows; - - /** - * Number of columns that this sparsity - * structure shall represent. - */ - unsigned int cols; - - /** - * Size of the actually allocated array - * #colnums#. Here, the same applies as - * for the #rowstart# array, i.e. it - * may be larger than the actually used - * part of the array. - */ - unsigned int max_vec_len; - - /** - * Maximum number of elements per - * row. This is set to the value - * given to the #reinit# function - * (or to the constructor), or to - * the maximum row length - * computed from the vectors in - * case the more flexible - * constructors or reinit - * versions are called. Its value - * is more or less meaningsless - * after #compress()# has been - * called. - */ - unsigned int max_row_length; - - /** - * Array which hold for each row which - * is the first element in #colnums# - * belonging to that row. Note that - * the size of the array is one larger - * than the number of rows, because - * the last element is used for - * #row=rows#, i.e. the row past the - * last used one. The value of - * #rowstart[rows]# equals the index - * of the element past the end in - * #colnums#; this way, we are able to - * write loops like - * #for (i=rowstart[k]; i friend class SparseMatrix; -}; - +#include @@ -708,7 +46,7 @@ class SparseMatrix : public Subscriptor * * You have to initialize * the matrix before usage with - * #reinit(SparseMatrixStruct)#. + * #reinit(SparsityPattern)#. */ SparseMatrix (); @@ -717,7 +55,7 @@ class SparseMatrix : public Subscriptor * only allowed to be called if the matrix * to be copied is empty. This is for the * same reason as for the - * #SparseMatrixStruct#, see there for the + * #SparsityPattern#, see there for the * details. * * If you really want to copy a whole @@ -740,7 +78,7 @@ class SparseMatrix : public Subscriptor * long as #reinit# is not called with a * new sparsity structure. */ - SparseMatrix (const SparseMatrixStruct &sparsity); + SparseMatrix (const SparsityPattern &sparsity); /** * Destructor. Free all memory, but do not @@ -787,7 +125,7 @@ class SparseMatrix : public Subscriptor * long as #reinit# is not called with a * new sparsity structure. */ - virtual void reinit (const SparseMatrixStruct &sparsity); + virtual void reinit (const SparsityPattern &sparsity); /** * Release all memory and return to a state @@ -801,7 +139,7 @@ class SparseMatrix : public Subscriptor /** * Return whether the object is empty. It * is empty if either both dimensions - * are zero or no #SparseMatrixStruct# + * are zero or no #SparsityPattern# * is associated. */ bool empty () const; @@ -940,7 +278,7 @@ class SparseMatrix : public Subscriptor * access to the #i#th element of this * matrix. The elements are stored in * a consecutive way, refer to the - * #SparseMatrixStruct# class for more details. + * #SparsityPattern# class for more details. * * You should use this interface very * carefully and only if you are absolutely @@ -1143,7 +481,7 @@ class SparseMatrix : public Subscriptor * function of objects which operate on * it. */ - const SparseMatrixStruct & get_sparsity_pattern () const; + const SparsityPattern & get_sparsity_pattern () const; /** * Print the matrix to the given stream, @@ -1237,7 +575,7 @@ class SparseMatrix : public Subscriptor * use, we subscribe to it using the * #SmartPointer# class. */ - SmartPointer cols; + SmartPointer cols; /** * Array of values for all the @@ -1318,79 +656,6 @@ class SparseMatrix : public Subscriptor /*---------------------- Inline functions -----------------------------------*/ - -inline -unsigned int -SparseMatrixStruct::n_rows () const -{ - return rows; -}; - - - -inline -unsigned int -SparseMatrixStruct::n_cols () const -{ - return cols; -}; - - - -inline -bool -SparseMatrixStruct::is_compressed () const -{ - return compressed; -}; - - - -inline -const unsigned int * -SparseMatrixStruct::get_rowstart_indices () const -{ - return rowstart; -}; - - - -inline -const int * -SparseMatrixStruct::get_column_numbers () const -{ - return colnums; -}; - - -inline -unsigned int -SparseMatrixStruct::row_length (const unsigned int row) const -{ - Assert(row @@ -1423,7 +688,8 @@ void SparseMatrix::set (const unsigned int i, const unsigned int j, const int index = cols->operator()(i,j); - if (index >= 0) val[index] = value; + if (index >= 0) + val[index] = value; }; @@ -1438,7 +704,8 @@ void SparseMatrix::add (const unsigned int i, const unsigned int j, const int index = cols->operator()(i,j); - if (index >= 0) val[index] += value; + if (index >= 0) + val[index] += value; }; @@ -1486,6 +753,7 @@ number & SparseMatrix::diag_element (const unsigned int i) }; + template inline number @@ -1495,7 +763,7 @@ SparseMatrix::raw_entry(unsigned int row, unsigned int index) const Assert(indexrow_length(row), ExcIndexRange(index,0,cols->row_length(row))); return val[cols->rowstart[row]+index]; -} +}; diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index e9fcb5eda7..b0223fa581 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -63,7 +63,7 @@ SparseMatrix::operator = (const SparseMatrix &m) template -SparseMatrix::SparseMatrix (const SparseMatrixStruct &c) : +SparseMatrix::SparseMatrix (const SparsityPattern &c) : cols(&c), val(0), max_len(0) @@ -118,7 +118,7 @@ SparseMatrix::reinit () template void -SparseMatrix::reinit (const SparseMatrixStruct &sparsity) +SparseMatrix::reinit (const SparsityPattern &sparsity) { if (cols != 0) cols->unsubscribe(); @@ -881,7 +881,7 @@ SparseMatrix::SSOR (Vector& dst, const number om) const template -const SparseMatrixStruct & +const SparsityPattern & SparseMatrix::get_sparsity_pattern () const { Assert (cols != 0, ExcMatrixNotInitialized()); diff --git a/deal.II/lac/include/lac/sparse_vanka.templates.h b/deal.II/lac/include/lac/sparse_vanka.templates.h index 25875fd708..8ed7e4e1ea 100644 --- a/deal.II/lac/include/lac/sparse_vanka.templates.h +++ b/deal.II/lac/include/lac/sparse_vanka.templates.h @@ -49,7 +49,7 @@ SparseVanka::compute_inverses () // first define an alias to the sparsity // pattern of the matrix, since this // will be used quite often - const SparseMatrixStruct &structure + const SparsityPattern &structure = matrix->get_sparsity_pattern(); map local_index; @@ -67,7 +67,7 @@ SparseVanka::compute_inverses () // entries in this row, and // 2 the position within this // row (as stored in the - // sparsematrixstruct object + // SparsityPattern object // // since we do not explicitely // consider nonsysmmetric sparsity @@ -133,7 +133,7 @@ SparseVanka::operator ()(Vector &dst, // first define an alias to the sparsity // pattern of the matrix, since this // will be used quite often - const SparseMatrixStruct &structure + const SparsityPattern &structure = matrix->get_sparsity_pattern(); // space to be used for local @@ -175,7 +175,7 @@ SparseVanka::operator ()(Vector &dst, // entries in this row, and // 2 the position within this // row (as stored in the - // sparsematrixstruct object + // SparsityPattern object // // since we do not explicitely // consider nonsysmmetric sparsity diff --git a/deal.II/lac/include/lac/sparsity_pattern.h b/deal.II/lac/include/lac/sparsity_pattern.h new file mode 100644 index 0000000000..41a65bb1c7 --- /dev/null +++ b/deal.II/lac/include/lac/sparsity_pattern.h @@ -0,0 +1,755 @@ +/*---------------------------- sparsity_pattern.h ---------------------------*/ +/* $Id$ */ +#ifndef __sparsity_pattern_H +#define __sparsity_pattern_H +/*---------------------------- sparsity_pattern.h ---------------------------*/ + + + +#include +#include +#include + +#include + + + + +/** + * Structure representing the sparsity pattern of a sparse matrix. + * + * The following picture will illustrate the relation between the + * #SparsityPattern# an the #SparseMatrix#. + * + * \begin{verbatim} + * SparsityPattern: \ + * | + * _________________________ | + * rowstart |0 | 4| 8|11|13|.... | + * |__|__|__|__|__|__________ | + * | \ \ | + * | \ \__ | + * | \ \ | + * | \ \__ | + * \ / \ \ | + * | \ \__ | + * | \ \ | + * | \ \__ | + * | \ \ | + * 0___________4___________8____ \ Position + * colnums |3 | 2| 9|17| 1| 4| 6| 8| 4|.. / + * /__|/_|__|__|__|__|__|__|__|__ | + * / / | + * / \______ _____/ \_____ _____/ | + * / \/ \/ | + * / / row = 0 row = 1 | + * / / | + * / / | + * / / | + * / /___colnums[1] | + * / | + * /_________colnums[0] | + * | + * / + * \end{verbatim} + * + * \begin{verbatim} + * For row = 0 + * + * it exists: (0| 3) = colnums[0] + * (0| 2) = colnums[1] + * (0| 9) = colnums[2] + * (0|17) = colnums[3] + * + * For row = 1 + * + * it exists: (1| 1) = colnums[4] + * (1| 4) = colnums[5] + * .... + * + * \end{verbatim} + * + * \begin{verbatim} + * SparseMatrix: \ + * | + * _____________________________ | + * val | | | | | | | | | 3|.. \ Value + * |__|__|__|__|__|__|__|__|__|__ / + * | + * | + * / + * \end{verbatim} + * + * If you want to get the #3# you need to get its position in the + * table above and its value by returning the value of the element on + * which the pointer shows, using #*val#. For example #val[8]=3#. Its + * position is #colnums[8]# so #row=2#. In other words, if you want to get + * the element #a_{24}# you know that #row=2#. To get the element, a + * search of #4# form #colnums[rowstart[2]]# to #colnums[rowstart[3]]# is + * needed. Then #a_{24}=val[number of the found element] = 3#. + * + * + * @author Original version by Roland Becker, Guido Kanschat, Franz-Theo Suttmeier; lots of enhancements, reorganisation and documentation by Wolfgang Bangerth; some documentation by Rasched Zamni + */ +class SparsityPattern : public Subscriptor +{ + public: + /** + * Initialize the matrix empty, + * that is with no memory + * allocated. This is useful if + * you want such objects as + * member variables in other + * classes. You can make the + * structure usable by calling + * the #reinit# function. + */ + SparsityPattern (); + + /** + * Copy constructor. This constructor is + * only allowed to be called if the matrix + * structure to be copied is empty. This is + * so in order to prevent involuntary + * copies of objects for temporaries, which + * can use large amounts of computing time. + * However, copy constructors are needed + * if yo want to use the STL data types + * on classes like this, e.g. to write + * such statements like + * #v.push_back (SparsityPattern());#, + * with #v# a vector of #SparsityPattern# + * objects. + * + * Usually, it is sufficient to use the + * explicit keyword to disallow unwanted + * temporaries, but for the STL vectors, + * this does not work. Since copying a + * structure like this is not useful + * anyway because multiple matrices can + * use the same sparsity structure, copies + * are only allowed for empty objects, as + * described above. + */ + SparsityPattern (const SparsityPattern &); + + /** + * Initialize a rectangular matrix with + * #m# rows and #n# columns. + * The matrix may contain at most #max_per_row# + * nonzero entries per row. + */ + SparsityPattern (const unsigned int m, + const unsigned int n, + const unsigned int max_per_row); + + /** + * Initialize a rectangular + * matrix with #m# rows and #n# + * columns. The maximal number + * of nonzero entries for each + * row is given by the + * #row_lengths# array. + */ + SparsityPattern (const unsigned int m, + const unsigned int n, + const vector &row_lengths); + + /** + * Initialize a square matrix of dimension + * #n# with at most #max_per_row# + * nonzero entries per row. + */ + SparsityPattern (const unsigned int n, + const unsigned int max_per_row); + + /** + * Initialize a square + * matrix with #m# rows and #m# + * columns. The maximal number + * of nonzero entries for each + * row is given by the + * #row_lengths# array. + */ + SparsityPattern (const unsigned int m, + const vector &row_lengths); + + /** + * Copy operator. For this the same holds + * as for the copy constructor: it is + * declared, defined and fine to be called, + * but the latter only for empty objects. + */ + SparsityPattern & operator = (const SparsityPattern &); + + /** + * Make a copy with extra off-diagonals. + * + * This constructs objects intended for + * the application of the ILU(n)-method + * or other incomplete decompositions. + * Therefore, additional to the original + * entry structure, space for + * #extra_off_diagonals# + * side-diagonals is provided on both + * sides of the main diagonal. + * + * #max_per_row# is the maximum number of + * nonzero elements per row which this + * structure is to hold. It is assumed + * that this number is sufficiently large + * to accomodate both the elements in + * #original# as well as the new + * off-diagonal elements created by this + * constructor. You will usually want to + * give the same number as you gave for + * #original# plus the number of side + * diagonals times two. You may however + * give a larger value if you wish to add + * further nonzero entries for the + * decomposition based on other criteria + * than their being on side-diagonals. + * + * This function requires that #original# + * refer to a square matrix structure. + * It shall be compressed. The matrix + * structure is not compressed + * after this function finishes. + */ + SparsityPattern (const SparsityPattern& original, + const unsigned int max_per_row, + const unsigned int extra_off_diagonals); + + /** + * Destructor. + */ + ~SparsityPattern (); + + /** + * Reallocate memory and set up data + * structures for a new matrix with + * #m# rows and #n# columns, + * with at most #max_per_row# + * nonzero entries per row. + * + * This function simply maps its + * operations to the other + * #reinit# function. + */ + void reinit (const unsigned int m, + const unsigned int n, + const unsigned int max_per_row); + + /** + * Reallocate memory for a matrix + * of size #m \times n#. The + * number of entries for each row + * is taken from the array + * #row_lengths# which has to + * give this number of each row + * #i=1...m#. + * + * If #m*n==0# all memory is freed, + * resulting in a total reinitialization + * of the object. If it is nonzero, new + * memory is only allocated if the new + * size extends the old one. This is done + * to save time and to avoid fragmentation + * of the heap. + */ + void reinit (const unsigned int m, + const unsigned int n, + const vector &row_lengths); + + /** + * This function compresses the sparsity + * structure that this object represents. + * It does so by eliminating unused + * entries and sorting the remaining + * ones to allow faster access by usage + * of binary search algorithms. A special + * sorting scheme is used for the diagonal + * entry of square matrices, which is + * always the first entry of each row. + * + * The memory which is no more + * needed is released. + * + * #SparseMatrix# objects require the + * #SparsityPattern# objects they are + * initialized with to be compressed, to + * reduce memory requirements. + */ + void compress (); + + /** + * Return whether the object is empty. It + * is empty if no memory is allocated, + * which is the same as that both + * dimensions are zero. + */ + bool empty () const; + + /** + * Return the maximum number of entries per + * row. Before compression, this equals the + * number given to the constructor, while + * after compression, it equals the maximum + * number of entries actually allocated by + * the user. + */ + unsigned int max_entries_per_row () const; + + /** + * Return the index of the matrix + * element with row number #i# and + * column number #j#. If the matrix + * element is not a nonzero one, + * return -1. + * + * This function is usually called + * by the #operator()# of the + * #SparseMatrix#. It shall only be + * called for compressed sparsity + * patterns, since in this case + * searching whether the entry + * exists can be done quite fast + * with a binary sort algorithm + * because the column numbers are + * sorted. + */ + int operator() (const unsigned int i, const unsigned int j) const; + + /** + * Add a nonzero entry to the matrix. + * This function may only be called + * for non-compressed sparsity patterns. + * + * If the entry already exists, nothing + * bad happens. + */ + void add (const unsigned int i, const unsigned int j); + + /** + * This matrix adds a whole connectivity + * list to the sparsity structure + * respresented by this object. It assumes + * the #rowcols# array to be a list of + * indices which are all linked together, + * i.e. all entries + * #(rowcols[i], rowcols[j])# for all + * #i,j=0...n# for this sparsity pattern + * are created. #n# is assumed to be the + * number of elements pointed to by + * #rowcols#. + */ + void add_matrix (const unsigned int n, const int* rowcols); + + ////////// + void add_matrix (const unsigned int m, const unsigned int n, + const int* rows, const int* cols); + + /** + * Print the sparsity of the matrix + * in a format that #gnuplot# understands + * and which can be used to plot the + * sparsity pattern in a graphical + * way. The format consists of pairs + * #i j# of nonzero elements, each + * representing one entry of this + * matrix, one per line of the output + * file. Indices are counted from + * zero on, as usual. Since sparsity + * patterns are printed in the same + * way as matrices are displayed, we + * print the negative of the column + * index, which means that the + * #(0,0)# element is in the top left + * rather than in the bottom left + * corner. + * + * Print the sparsity pattern in + * gnuplot by setting the data style + * to dots or points and use the + * #plot# command. + */ + void print_gnuplot (ostream &out) const; + + /** + * Return number of rows of this + * matrix, which equals the dimension + * of the image space. + */ + unsigned int n_rows () const; + + /** + * Return number of columns of this + * matrix, which equals the dimension + * of the range space. + */ + unsigned int n_cols () const; + + /** + * Number of entries in a specific row. + */ + unsigned int row_length (const unsigned int row) const; + + /** + * Access to column number field. + * Return the column number of + * the #index#th entry in #row#. + */ + unsigned int column_number (const unsigned int row, + const unsigned int index) const; + + /** + * Compute the bandwidth of the matrix + * represented by this structure. The + * bandwidth is the maximum of + * $|i-j|$ for which the index pair + * $(i,j)$ represents a nonzero entry + * of the matrix. + */ + unsigned int bandwidth () const; + + /** + * Return the number of nonzero elements of + * this matrix. Actually, it returns the + * number of entries in the sparsity + * pattern; if any of the entries should + * happen to be zero, it is counted + * anyway. + * + * This function may only be called if the + * matrix struct is compressed. It does not + * make too much sense otherwise anyway. + */ + unsigned int n_nonzero_elements () const; + + /** + * Return whether the structure is + * compressed or not. + */ + bool is_compressed () const; + + /** + * This is kind of an expert mode. Get + * access to the rowstart array, but + * read-only. + * + * Use of this function is highly + * deprecated. Use #row_length# + * and #column_number# instead. + * + * Though the return value is declared + * #const#, you should be aware that it + * may change if you call any nonconstant + * function of objects which operate on + * it. + * + * You should use this interface very + * carefully and only if you are absolutely + * sure to know what you do. You should + * also note that the structure of these + * arrays may change over time. + * If you change the layout yourself, you + * should also rename this function to + * avoid programs relying on outdated + * information! */ + const unsigned int * get_rowstart_indices () const; + + /** + * This is kind of an expert mode: get + * access to the colnums array, but + * readonly. + * + * Use of this function is highly + * deprecated. Use #row_length# + * and #column_number# instead. + * + * Though the return value is declared + * #const#, you should be aware that it + * may change if you call any nonconstant + * function of objects which operate on + * it. + * + * You should use this interface very + * carefully and only if you are absolutely + * sure to know what you do. You should + * also note that the structure of these + * arrays may change over time. + * If you change the layout yourself, you + * should also rename this function to + * avoid programs relying on outdated + * information! + */ + const int * get_column_numbers () const; + + + /** + * Exception + */ + DeclException1 (ExcInvalidNumber, + int, + << "The provided number is invalid here: " << arg1); + /** + * Exception + */ + DeclException2 (ExcInvalidIndex, + int, int, + << "The given index " << arg1 + << " should be less than " << arg2 << "."); + /** + * Exception + */ + DeclException2 (ExcNotEnoughSpace, + int, int, + << "Upon entering a new entry to row " << arg1 + << ": there was no free entry any more. " << endl + << "(Maximum number of entries for this row: " + << arg2 << "; maybe the matrix is already compressed?)"); + /** + * Exception + */ + DeclException0 (ExcNotCompressed); + /** + * Exception + */ + DeclException0 (ExcMatrixIsCompressed); + /** + * Exception + */ + DeclException0 (ExcEmptyObject); + /** + * Exception + */ + DeclException0 (ExcInternalError); + /** + * Exception + */ + DeclException0 (ExcIO); + /** + * Exception + */ + DeclException0 (ExcInvalidConstructorCall); + /** + * Exception + */ + DeclException0 (ExcNotSquare); + + private: + /** + * Maximum number of rows that can + * be stored in the #row_start# array. + * Since reallocation of that array + * only happens if the present one is + * too small, but never when the size + * of this matrix structure shrinks, + * #max_dim# might be larger than + * #rows# and in this case #row_start# + * has more elements than are used. + */ + unsigned int max_dim; + + /** + * Number of rows that this sparsity + * structure shall represent. + */ + unsigned int rows; + + /** + * Number of columns that this sparsity + * structure shall represent. + */ + unsigned int cols; + + /** + * Size of the actually allocated array + * #colnums#. Here, the same applies as + * for the #rowstart# array, i.e. it + * may be larger than the actually used + * part of the array. + */ + unsigned int max_vec_len; + + /** + * Maximum number of elements per + * row. This is set to the value + * given to the #reinit# function + * (or to the constructor), or to + * the maximum row length + * computed from the vectors in + * case the more flexible + * constructors or reinit + * versions are called. Its value + * is more or less meaningsless + * after #compress()# has been + * called. + */ + unsigned int max_row_length; + + /** + * Array which hold for each row which + * is the first element in #colnums# + * belonging to that row. Note that + * the size of the array is one larger + * than the number of rows, because + * the last element is used for + * #row=rows#, i.e. the row past the + * last used one. The value of + * #rowstart[rows]# equals the index + * of the element past the end in + * #colnums#; this way, we are able to + * write loops like + * #for (i=rowstart[k]; i friend class SparseMatrix; +}; + + + + +/*---------------------- Inline functions -----------------------------------*/ + + + +inline +unsigned int +SparsityPattern::n_rows () const +{ + return rows; +}; + + + +inline +unsigned int +SparsityPattern::n_cols () const +{ + return cols; +}; + + + +inline +bool +SparsityPattern::is_compressed () const +{ + return compressed; +}; + + + +inline +const unsigned int * +SparsityPattern::get_rowstart_indices () const +{ + return rowstart; +}; + + + +inline +const int * +SparsityPattern::get_column_numbers () const +{ + return colnums; +}; + + +inline +unsigned int +SparsityPattern::row_length (const unsigned int row) const +{ + Assert(row -SparseMatrixStruct::SparseMatrixStruct () : +SparsityPattern::SparsityPattern () : max_dim(0), max_vec_len(0), rowstart(0), @@ -26,7 +26,7 @@ SparseMatrixStruct::SparseMatrixStruct () : -SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &s) : +SparsityPattern::SparsityPattern (const SparsityPattern &s) : Subscriptor(), max_dim(0), max_vec_len(0), @@ -43,9 +43,9 @@ SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &s) : -SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row) +SparsityPattern::SparsityPattern (const unsigned int m, + const unsigned int n, + const unsigned int max_per_row) : max_dim(0), max_vec_len(0), rowstart(0), @@ -56,9 +56,9 @@ SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, -SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, - const unsigned int n, - const vector &row_lengths) +SparsityPattern::SparsityPattern (const unsigned int m, + const unsigned int n, + const vector &row_lengths) : max_dim(0), max_vec_len(0), rowstart(0), @@ -69,8 +69,8 @@ SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, -SparseMatrixStruct::SparseMatrixStruct (const unsigned int n, - const unsigned int max_per_row) +SparsityPattern::SparsityPattern (const unsigned int n, + const unsigned int max_per_row) : max_dim(0), max_vec_len(0), rowstart(0), @@ -81,8 +81,8 @@ SparseMatrixStruct::SparseMatrixStruct (const unsigned int n, -SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, - const vector &row_lengths) +SparsityPattern::SparsityPattern (const unsigned int m, + const vector &row_lengths) : max_dim(0), max_vec_len(0), rowstart(0), @@ -92,9 +92,9 @@ SparseMatrixStruct::SparseMatrixStruct (const unsigned int m, }; -SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &original, - const unsigned int max_per_row, - const unsigned int extra_off_diagonals) +SparsityPattern::SparsityPattern (const SparsityPattern &original, + const unsigned int max_per_row, + const unsigned int extra_off_diagonals) : max_dim(0), max_vec_len(0), rowstart(0), @@ -180,7 +180,7 @@ SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &original, -SparseMatrixStruct::~SparseMatrixStruct () +SparsityPattern::~SparsityPattern () { if (rowstart != 0) delete[] rowstart; if (colnums != 0) delete[] colnums; @@ -188,8 +188,8 @@ SparseMatrixStruct::~SparseMatrixStruct () -SparseMatrixStruct & -SparseMatrixStruct::operator = (const SparseMatrixStruct &s) +SparsityPattern & +SparsityPattern::operator = (const SparsityPattern &s) { Assert (s.rowstart == 0, ExcInvalidConstructorCall()); Assert (s.colnums == 0, ExcInvalidConstructorCall()); @@ -208,9 +208,9 @@ SparseMatrixStruct::operator = (const SparseMatrixStruct &s) void -SparseMatrixStruct::reinit (const unsigned int m, - const unsigned int n, - const unsigned int max_per_row) +SparsityPattern::reinit (const unsigned int m, + const unsigned int n, + const unsigned int max_per_row) { // simply map this function to the // other #reinit# function @@ -221,9 +221,9 @@ SparseMatrixStruct::reinit (const unsigned int m, void -SparseMatrixStruct::reinit (const unsigned int m, - const unsigned int n, - const vector &row_lengths) +SparsityPattern::reinit (const unsigned int m, + const unsigned int n, + const vector &row_lengths) { Assert (((m==0) && (n==0)) || (*max_element(row_lengths.begin(), row_lengths.end()) > 0), ExcInvalidNumber(*max_element(row_lengths.begin(), row_lengths.end()))); @@ -300,7 +300,7 @@ SparseMatrixStruct::reinit (const unsigned int m, void -SparseMatrixStruct::compress () +SparsityPattern::compress () { Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject()); @@ -405,7 +405,7 @@ SparseMatrixStruct::compress () bool -SparseMatrixStruct::empty () const { +SparsityPattern::empty () const { // let's try to be on the safe side of // life by using multiple possibilities in // the check for emptiness... (sorry for @@ -431,7 +431,7 @@ SparseMatrixStruct::empty () const { unsigned int -SparseMatrixStruct::max_entries_per_row () const +SparsityPattern::max_entries_per_row () const { // if compress() has not yet been // called, we can get the maximum @@ -453,7 +453,7 @@ SparseMatrixStruct::max_entries_per_row () const int -SparseMatrixStruct::operator () (const unsigned int i, const unsigned int j) const +SparsityPattern::operator () (const unsigned int i, const unsigned int j) const { Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject()); Assert (i #include #include -#include +#include #include #include #include @@ -360,8 +360,8 @@ void TestCases::run (ParameterHandler &prm) { cout << " Renumbering degrees of freedom..." << endl; DoFRenumbering::Cuthill_McKee (*dof); - SparseMatrixStruct sparsity (dof->n_dofs(), - dof->max_couplings_between_dofs()); + SparsityPattern sparsity (dof->n_dofs(), + dof->max_couplings_between_dofs()); DoFTools::make_sparsity_pattern (*dof, sparsity); diff --git a/tests/big-tests/multigrid/multigrid.cc b/tests/big-tests/multigrid/multigrid.cc index 86d512190e..e48fd7e987 100644 --- a/tests/big-tests/multigrid/multigrid.cc +++ b/tests/big-tests/multigrid/multigrid.cc @@ -128,7 +128,7 @@ class PoissonProblem { /** * Sparsity pattern of the system matrix. */ - SparseMatrixStruct system_sparsity; + SparsityPattern system_sparsity; /** * System matrix. diff --git a/tests/deal.II/dof_test.cc b/tests/deal.II/dof_test.cc index 1939908acb..710dffbc4e 100644 --- a/tests/deal.II/dof_test.cc +++ b/tests/deal.II/dof_test.cc @@ -298,8 +298,8 @@ void TestCases::run (const unsigned int test_case) deallog << " Renumbering degrees of freedom..." << endl; DoFRenumbering::Cuthill_McKee (*dof); - SparseMatrixStruct sparsity (dof->n_dofs(), - dof->max_couplings_between_dofs()); + SparsityPattern sparsity (dof->n_dofs(), + dof->max_couplings_between_dofs()); DoFTools::make_sparsity_pattern (*dof, sparsity); diff --git a/tests/deal.II/mg.cc b/tests/deal.II/mg.cc index eac08ddf67..47698cab7b 100644 --- a/tests/deal.II/mg.cc +++ b/tests/deal.II/mg.cc @@ -96,7 +96,7 @@ int main() deallog << "DoFs " << size << endl; deallog << "Levels: " << tr.n_levels() << endl; - SparseMatrixStruct structure(size, dof.max_couplings_between_dofs()); + SparsityPattern structure(size, dof.max_couplings_between_dofs()); DoFTools::make_sparsity_pattern(dof, structure); structure.compress(); @@ -115,7 +115,7 @@ int main() solver.solve(A,u,f,precondition); u = 0.; - vector mgstruct(tr.n_levels()); + vector mgstruct(tr.n_levels()); MGMatrix > mgA(0,tr.n_levels()-1); for (unsigned int i=0;i solver(control, mem); - vector mgstruct(tr.n_levels()); + vector mgstruct(tr.n_levels()); MGMatrix > mgA(0,tr.n_levels()-1); for (unsigned int i=0;i const Quadrature &quadrature; const Quadrature &quadrature_face; ConstraintMatrix constraints; - SparseMatrixStruct system_sparsity; + SparsityPattern system_sparsity; SparseMatrix mass_matrix, laplace_matrix; Vector u, v; StatisticData statistic_data; @@ -1147,7 +1147,7 @@ class UserMatrix : public SparseMatrix { * The first parameter is simply passed * down to the base class. */ - UserMatrix (const SparseMatrixStruct &sparsity, + UserMatrix (const SparsityPattern &sparsity, Preconditioning p) : SparseMatrix(sparsity), preconditioning (p) {}; diff --git a/tests/lac/mg.cc b/tests/lac/mg.cc index dd2779769a..0279dfb26d 100644 --- a/tests/lac/mg.cc +++ b/tests/lac/mg.cc @@ -112,7 +112,7 @@ int main() deallog << "Level " << level << " size " << size << endl; // Make matrix - vector structure(maxlevel+1); + vector structure(maxlevel+1); MGMatrix > A(minlevel,maxlevel); FDMatrix testproblem(size, size); diff --git a/tests/lac/solver.cc b/tests/lac/solver.cc index 3c126b0adb..daa9700d0e 100644 --- a/tests/lac/solver.cc +++ b/tests/lac/solver.cc @@ -51,7 +51,7 @@ int main() // Make matrix FDMatrix testproblem(size, size); - SparseMatrixStruct structure(dim, dim, 5); + SparsityPattern structure(dim, dim, 5); testproblem.build_structure(structure); structure.compress(); SparseMatrix A(structure); diff --git a/tests/lac/testmatrix.cc b/tests/lac/testmatrix.cc index 2b3ae8afd4..a0bd9ae234 100644 --- a/tests/lac/testmatrix.cc +++ b/tests/lac/testmatrix.cc @@ -9,7 +9,7 @@ FDMatrix::FDMatrix(unsigned int nx, unsigned int ny) {} void -FDMatrix::build_structure(SparseMatrixStruct& structure) const +FDMatrix::build_structure(SparsityPattern& structure) const { for(unsigned int i=0;i<=ny-2;i++) { @@ -118,7 +118,7 @@ FDMGTransfer::FDMGTransfer(unsigned int nx, unsigned int ny, void FDMGTransfer::build_matrix(unsigned int nx, unsigned int ny, - SparseMatrixStruct& structure, SparseMatrix& matrix) + SparsityPattern& structure, SparseMatrix& matrix) { structure.reinit((nx-1)*(ny-1),(2*nx-1)*(2*ny-1),9); diff --git a/tests/lac/testmatrix.h b/tests/lac/testmatrix.h index 7b9f0e8e3f..a81ca7210b 100644 --- a/tests/lac/testmatrix.h +++ b/tests/lac/testmatrix.h @@ -20,7 +20,7 @@ class FDMatrix /** * Generate the matrix structure. */ - void build_structure(SparseMatrixStruct& structure) const; + void build_structure(SparsityPattern& structure) const; /** * Fill the matrix with values. @@ -87,7 +87,7 @@ class FDMGTransfer /** * Prolongation matrix structures. */ - vector structures; + vector structures; /** * Prolongation matrices. */ @@ -101,5 +101,5 @@ class FDMGTransfer * fine to coarse (#vmult#). */ void build_matrix(unsigned int nx, unsigned int ny, - SparseMatrixStruct&, SparseMatrix&); + SparsityPattern&, SparseMatrix&); };