]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Separate the SparseMatrixStruct class into a file of its own and rename it to Sparsit...
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 26 Jan 2000 08:58:03 +0000 (08:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 26 Jan 2000 08:58:03 +0000 (08:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@2266 0785d39b-7218-0410-832d-ea1e28bc413d

61 files changed:
deal.II/deal.II/Attic/examples/dof/dof_test.cc
deal.II/deal.II/Attic/examples/multigrid/multigrid.cc
deal.II/deal.II/Attic/examples/step-by-step/step-2/step-2.cc
deal.II/deal.II/Attic/examples/step-by-step/step-3/step-3.cc
deal.II/deal.II/Attic/examples/step-by-step/step-4/step-4.cc
deal.II/deal.II/Attic/examples/step-by-step/step-5/step-5.cc
deal.II/deal.II/Attic/examples/step-by-step/step-6/step-6.cc
deal.II/deal.II/Attic/examples/step-by-step/step-8/step-8.cc
deal.II/deal.II/include/dofs/dof_accessor.templates.h
deal.II/deal.II/include/dofs/dof_constraints.h
deal.II/deal.II/include/dofs/dof_constraints.templates.h
deal.II/deal.II/include/dofs/dof_handler.h
deal.II/deal.II/include/dofs/dof_tools.h
deal.II/deal.II/include/dofs/mg_dof_tools.h
deal.II/deal.II/include/multigrid/mg_dof_tools.h
deal.II/deal.II/include/multigrid/multigrid.h
deal.II/deal.II/include/numerics/base.h
deal.II/deal.II/include/numerics/dof_renumbering.h
deal.II/deal.II/include/numerics/matrices.h
deal.II/deal.II/include/numerics/multigrid.h
deal.II/deal.II/source/dofs/dof_accessor.cc
deal.II/deal.II/source/dofs/dof_constraints.cc
deal.II/deal.II/source/dofs/dof_renumbering.cc
deal.II/deal.II/source/dofs/dof_tools.cc
deal.II/deal.II/source/dofs/mg_dof_accessor.cc
deal.II/deal.II/source/dofs/mg_dof_handler.cc
deal.II/deal.II/source/dofs/mg_dof_tools.cc
deal.II/deal.II/source/multigrid/mg_dof_accessor.cc
deal.II/deal.II/source/multigrid/mg_dof_handler.cc
deal.II/deal.II/source/multigrid/mg_dof_tools.cc
deal.II/deal.II/source/multigrid/mg_smoother.cc
deal.II/deal.II/source/multigrid/multigrid.cc
deal.II/deal.II/source/numerics/matrices.cc
deal.II/deal.II/source/numerics/mg_smoother.cc
deal.II/deal.II/source/numerics/multigrid.cc
deal.II/deal.II/source/numerics/vectors.cc
deal.II/examples/step-2/step-2.cc
deal.II/examples/step-3/step-3.cc
deal.II/examples/step-4/step-4.cc
deal.II/examples/step-5/step-5.cc
deal.II/examples/step-6/step-6.cc
deal.II/examples/step-8/step-8.cc
deal.II/lac/include/lac/precondition_block.templates.h
deal.II/lac/include/lac/solver_selector.h
deal.II/lac/include/lac/sparse_ilu.h
deal.II/lac/include/lac/sparse_ilu.templates.h
deal.II/lac/include/lac/sparse_matrix.h
deal.II/lac/include/lac/sparse_matrix.templates.h
deal.II/lac/include/lac/sparse_vanka.templates.h
deal.II/lac/include/lac/sparsity_pattern.h [new file with mode: 0644]
deal.II/lac/source/sparsity_pattern.cc [moved from deal.II/lac/source/sparse_matrix.cc with 89% similarity]
tests/big-tests/dof/dof_test.cc
tests/big-tests/multigrid/multigrid.cc
tests/deal.II/dof_test.cc
tests/deal.II/mg.cc
tests/deal.II/mglocal.cc
tests/deal.II/wave-test-3.cc
tests/lac/mg.cc
tests/lac/solver.cc
tests/lac/testmatrix.cc
tests/lac/testmatrix.h

index 4c46d77b3f4bca6df5dbce7ad60397c18c20774b..d820d9c111abb6d35f3f4ae9078cfd63769e6ce4 100644 (file)
@@ -12,7 +12,7 @@
 #include <grid/tria_iterator.h>
 #include <grid/tria_accessor.h>
 #include <grid/grid_generator.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <base/parameter_handler.h>
 #include <dofs/dof_constraints.h>
 #include <numerics/dof_renumbering.h>
@@ -360,8 +360,8 @@ void TestCases<dim>::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);
index 86d512190e62bd307b38daa175760e127cf54e43..e48fd7e98751b1ec4432ec0222f6cd457126137d 100644 (file)
@@ -128,7 +128,7 @@ class PoissonProblem {
                                     /**
                                      * Sparsity pattern of the system matrix.
                                      */
-    SparseMatrixStruct  system_sparsity;
+    SparsityPattern      system_sparsity;
 
                                     /**
                                      * System matrix.
index e39eda858bcfbf9aedab78eadf789ae0b8ab24c6..181571a7bca76f2ff61af62bae8cc2d898cb7f9d 100644 (file)
@@ -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:
index 10e649fe44aca1680ccd847d829ef3bdc9e79256..448bae97f8fbda25e9c0b40b83be2e93c01afdb9 100644 (file)
@@ -128,7 +128,7 @@ class LaplaceProblem
                                     // system matrix resulting from
                                     // the discretization of the
                                     // Laplace equation...
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> 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
index 9b45c7d7f57b2edba6f5c5ac6ba255fe8cd95651..805feb5f533bf1eec706660da21055da8f246d58 100644 (file)
@@ -75,7 +75,7 @@ class LaplaceProblem
     FEQ1<dim>            fe;
     DoFHandler<dim>      dof_handler;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index 21ad88c48405e8d0f188ed80b8b387cab1f3662e..4f389ee25744a0b49a5fde2575230006cfc39b6f 100644 (file)
@@ -72,7 +72,7 @@ class LaplaceProblem
     FEQ1<dim>            fe;
     DoFHandler<dim>      dof_handler;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index b26124a9af8e0c650b9d9f0603d9c8c1e93bc60d..aa281775eded6218787c6d38750042f67370bec3 100644 (file)
@@ -121,7 +121,7 @@ class LaplaceProblem
                                     // hanging nodes:
     ConstraintMatrix     hanging_node_constraints;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index 93d6d2c47f115e1f8ab638a9a1b7668a7e572eba..5b03e6e1e3151016895a0322a86dc92699c7fcc3 100644 (file)
@@ -86,7 +86,7 @@ class ElasticProblem
 
     ConstraintMatrix     hanging_node_constraints;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index 161b79d68356cff45da0d044d7af1bb1ad7dad46..d8515f2fc6ca259d6b74a286f2d6b237b52f458a 100644 (file)
 #include <grid/tria_iterator.templates.h>
 #include <fe/fe.h>
 
-#include <lac/vector.h>
-#include <lac/full_matrix.h>
-#include <lac/sparse_matrix.h>
-
 #include <vector>
 
 
index ae3a955c9d6a72acd0c0a321fd879e45a0633427..4b4500ed1b29f685b7c3f45cc092ae3b1b2492d8 100644 (file)
@@ -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
index 5c2f975c32fc1e7a85ced7ee0b66061e60a31cc0..854aa7e35b63a661a377e7ab307c756895a30542 100644 (file)
@@ -1,9 +1,20 @@
+/*----------------------------   dof_constraints.templates.h     ---------------------------*/
+/*      $Id$                 */
+#ifndef __dof_constraints_templates_H
+#define __dof_constraints_templates_H
+/*----------------------------   dof_constraints.templates.h     ---------------------------*/
+
+
+#include <dofs/dof_constraints.h>
+#include <lac/sparse_matrix.h>
+
+
 template<typename number>
 void
 ConstraintMatrix::condense (const SparseMatrix<number> &uncondensed,
                            SparseMatrix<number>       &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<typename number>
 void
 ConstraintMatrix::condense (SparseMatrix<number> &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<number> &vec) const
 };
 
 
+
+
+
+/*----------------------------   dof_constraints.templates.h     ---------------------------*/
+/* end of #ifndef __dof_constraints_templates_H */
+#endif
+/*----------------------------   dof_constraints.templates.h     ---------------------------*/
index e0c7e591112845c8434f4da034da8091f7bc6c97..775ba3c8ae7effb36021d92f320a966829dc44fe 100644 (file)
@@ -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
index 517e678e6709c1ff1859227b677252ac2f084da2..07cfc35692f00c25a150eade5775997f9506d496 100644 (file)
@@ -84,12 +84,12 @@ class DoFTools
                                      * afterwards.
                                      *
                                      * Remember using
-                                     * #SparseMatrixStruct::compress()#
+                                     * #SparsityPattern::compress()#
                                      * after generating the pattern.
                                      */
     template<int dim>
     static void make_sparsity_pattern (const DoFHandler<dim> &dof,
-                                      SparseMatrixStruct    &sparsity_pattern);
+                                      SparsityPattern       &sparsity_pattern);
 
                                     /**
                                      * Locate non-zero entries for
@@ -149,7 +149,7 @@ class DoFTools
     template<int dim>
     static void make_sparsity_pattern (const DoFHandler<dim>       &dof,
                                       const vector<vector<bool> > &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<dim> &dof,
                                    const vector<int>     &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<dim>& dof,
                                    const typename DoFHandler<dim>::FunctionMap &boundary_indicators,
                                    const vector<int>  &dof_to_boundary_mapping,
-                                   SparseMatrixStruct &sparsity); 
+                                   SparsityPattern    &sparsity); 
 
                                     /**
                                      * Generate sparsity pattern for
@@ -239,7 +239,7 @@ class DoFTools
                                      */
     template<int dim>
     static void make_flux_sparsity_pattern (const DoFHandler<dim> &dof_handler,
-                                           SparseMatrixStruct    &sparsity_pattern);
+                                           SparsityPattern       &sparsity_pattern);
     
                                     /**
                                      * Make up the constraints which
index 4b7714b2e7e76a2ad8448b46437da86be4e22df3..c97e55e53c03ccdbd5c2c2fd962bcd5afe3c1a34 100644 (file)
@@ -44,13 +44,13 @@ class MGDoFTools
                                      * #ConstraintMatrix::condense(1)#,
                                      * you have to compress the
                                      * matrix yourself, using
-                                     * #SparseMatrixStruct::compress()#.
+                                     * #SparsityPattern::compress()#.
                                      */
     template <int dim>
     static void
     make_sparsity_pattern (const MGDoFHandler<dim> &dof_handler,
                           const unsigned int       level,
-                          SparseMatrixStruct      &sparsity);
+                          SparsityPattern         &sparsity);
 };
 
 
index 4b7714b2e7e76a2ad8448b46437da86be4e22df3..c97e55e53c03ccdbd5c2c2fd962bcd5afe3c1a34 100644 (file)
@@ -44,13 +44,13 @@ class MGDoFTools
                                      * #ConstraintMatrix::condense(1)#,
                                      * you have to compress the
                                      * matrix yourself, using
-                                     * #SparseMatrixStruct::compress()#.
+                                     * #SparsityPattern::compress()#.
                                      */
     template <int dim>
     static void
     make_sparsity_pattern (const MGDoFHandler<dim> &dof_handler,
                           const unsigned int       level,
-                          SparseMatrixStruct      &sparsity);
+                          SparsityPattern         &sparsity);
 };
 
 
index bdac914ff0f53c73f9f1fa3df8d6d5e587ee2732..16f83a9083d4f93779e2324749c36af5f413b0c8 100644 (file)
@@ -8,7 +8,6 @@
 #include <base/smartpointer.h>
 #include <lac/forward_declarations.h>
 #include <grid/forward_declarations.h>
-#include <lac/sparse_matrix.h>
 #include <lac/vector.h>
 #include <lac/mgbase.h>
 
@@ -194,16 +193,21 @@ class MGTransferPrebuilt : public MGTransferBase
 
   private:
 
-    vector<SparseMatrixStruct>   prolongation_sparsities;
+                                    /**
+                                     * Sparsity patterns for the
+                                     * prolongation matrices on each
+                                     * level.
+                                     */
+    vector<SparsityPattern>      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<SparseMatrix<float> > prolongation_matrices;
 };
 
index 1b0834b2c30504743ebe8332ddb51d2b6a4a5b5c..a153b14737427cd3147da733685eec2857bf26be 100644 (file)
@@ -210,22 +210,22 @@ class ProblemBase {
                                     /**
                                      * Sparsity pattern of the system matrix.
                                      */
-    SparseMatrixStruct      system_sparsity;
+    SparsityPattern      system_sparsity;
 
                                     /**
                                      * System matrix.
                                      */
-    SparseMatrix<double>    system_matrix;
+    SparseMatrix<double> system_matrix;
 
                                     /**
                                      * Vector storing the right hand side.
                                      */
-    Vector<double>             right_hand_side;
+    Vector<double>       right_hand_side;
 
                                     /**
                                      * Solution vector.
                                      */
-    Vector<double>             solution;
+    Vector<double>       solution;
 
                                     /**
                                      * List of constraints introduced by
index 33a2cf70b71660688e0bf0cad491e1622df6dc93..37395e2abefc0311f054c4df6ad527e220f4e5f1 100644 (file)
@@ -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
index 695163e894ac7818d773baad3b370a0d60d13859..0cf81a99b2065ff67744819c0a7c71400a8446e5 100644 (file)
@@ -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<dim>::make_sparsity_pattern#
  * function.
index bdac914ff0f53c73f9f1fa3df8d6d5e587ee2732..16f83a9083d4f93779e2324749c36af5f413b0c8 100644 (file)
@@ -8,7 +8,6 @@
 #include <base/smartpointer.h>
 #include <lac/forward_declarations.h>
 #include <grid/forward_declarations.h>
-#include <lac/sparse_matrix.h>
 #include <lac/vector.h>
 #include <lac/mgbase.h>
 
@@ -194,16 +193,21 @@ class MGTransferPrebuilt : public MGTransferBase
 
   private:
 
-    vector<SparseMatrixStruct>   prolongation_sparsities;
+                                    /**
+                                     * Sparsity patterns for the
+                                     * prolongation matrices on each
+                                     * level.
+                                     */
+    vector<SparsityPattern>      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<SparseMatrix<float> > prolongation_matrices;
 };
 
index 674bbdacb808e52f9caac92593023a4343997418..3cc5bf2623a8338c1f43eb5ca201769242e7a8be 100644 (file)
@@ -12,7 +12,6 @@
 #include <fe/fe.h>
 
 #include <lac/vector.h>
-#include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
 
 #include <vector>
index ce0cd63e92f34ce8f028efd79837a3ec1a799659..b07515369a849282838259e5a32e13594eb46f0b 100644 (file)
@@ -4,7 +4,7 @@
 
 
 #include <dofs/dof_constraints.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <lac/vector.h>
 #include <iostream>
 #include <algorithm>
@@ -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(),
index 402788c30bf73893efb5d729fd7db4537cf47dd1..576a66fa1f3d9e6714fa6ac267831b5e1c6e9d96 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <dofs/dof_accessor.h>
 #include <grid/tria_iterator.h>
 #include <dofs/dof_handler.h>
@@ -23,8 +23,8 @@ void DoFRenumbering::Cuthill_McKee (DoFHandler<dim>   &dof_handler,
                                    const bool         use_constraints,
                                    const vector<int> &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<dim>      &dof_handler,
                                    const bool              reversed_numbering,
                                    const vector<int>      &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();
index bf6eca37261698cd92d616419df08932c4d01713..95faa5439edaa03adbd28bbd4f4c7f4a6b828993 100644 (file)
@@ -11,7 +11,7 @@
 #include <fe/fe.h>
 #include <fe/fe_system.h>
 #include <dofs/dof_tools.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <lac/vector.h>
 
 #include <algorithm>
@@ -19,8 +19,8 @@
 
 template <int dim>
 void
-DoFTools::make_sparsity_pattern (const DoFHandler<dim>dof,
-                                SparseMatrixStruct &sparsity)
+DoFTools::make_sparsity_pattern (const DoFHandler<dim> &dof,
+                                SparsityPattern       &sparsity)
 {
   const unsigned int n_dofs = dof.n_dofs();
 
@@ -47,9 +47,9 @@ DoFTools::make_sparsity_pattern (const DoFHandler<dim>& dof,
 
 template <int dim>
 void
-DoFTools::make_sparsity_pattern (const DoFHandler<dim>dof,
-                                       const vector<vector<bool> > &mask,
-                                       SparseMatrixStruct          &sparsity)
+DoFTools::make_sparsity_pattern (const DoFHandler<dim>       &dof,
+                                const vector<vector<bool> > &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<dim>& dof,
 
 template <>
 void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<1>&,
-                                                   const vector<int>  &,
-                                                   SparseMatrixStruct &)
+                                              const vector<int>  &,
+                                              SparsityPattern    &)
 {
     Assert (false, ExcInternalError());
 };
@@ -109,7 +109,7 @@ void
 DoFTools::make_boundary_sparsity_pattern (const DoFHandler<1>&,
                                          const DoFHandler<1>::FunctionMap  &,
                                          const vector<int>  &,
-                                         SparseMatrixStruct &)
+                                         SparsityPattern    &)
 {
   Assert (false, ExcInternalError());
 }
@@ -122,7 +122,7 @@ template <int dim>
 void
 DoFTools::make_boundary_sparsity_pattern (const DoFHandler<dim>& dof,
                                          const vector<int>  &dof_to_boundary_mapping,
-                                         SparseMatrixStruct &sparsity)
+                                         SparsityPattern    &sparsity)
 {
   const unsigned int n_dofs = dof.n_dofs();
 
@@ -164,7 +164,7 @@ template <int dim>
 void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<dim>& dof,
                                               const DoFHandler<dim>::FunctionMap  &boundary_indicators,
                                               const vector<int>  &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<dim>& dof,
 
 template<int dim>
 void
-DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim>dof,
-                                     SparseMatrixStruct &sparsity)
+DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim> &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<deal_II_dimension>& dof,
-                                     SparseMatrixStruct &sparsity);
+                                     SparsityPattern    &sparsity);
 template void
 DoFTools::make_boundary_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
                                          const vector<int>  &,
-                                         SparseMatrixStruct &);
+                                         SparsityPattern    &);
 template void
 DoFTools::make_boundary_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
                                          const DoFHandler<deal_II_dimension>::FunctionMap  &boundary_indicators,
                                          const vector<int>  &dof_to_boundary_mapping,
-                                         SparseMatrixStruct &sparsity);
+                                         SparsityPattern    &sparsity);
 #endif
 
 template void
 DoFTools::make_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
-                                              SparseMatrixStruct &sparsity);
+                                              SparsityPattern    &sparsity);
 
 template void 
 DoFTools::make_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
                                 const vector<vector<bool> > &mask,
-                                SparseMatrixStruct          &sparsity);
+                                SparsityPattern             &sparsity);
 
 template
 void
index 27cc111a4dcc338f091f191e55480099cfd06474..3af8742a173cfcd9aac822422ec9fbc564a628a2 100644 (file)
@@ -11,8 +11,8 @@
 #include <fe/fe.h>
 
 #include <lac/vector.h>
-#include <lac/full_matrix.h>
-#include <lac/sparse_matrix.h>
+
+
 
 
 
index db54f243d7b39fd3d1d75efb3ea4d44645b47556..d880f442b161aba62d8c335f19a5cf7639086e36 100644 (file)
@@ -12,7 +12,6 @@
 #include <grid/tria.h>
 #include <grid/geometry_info.h>
 #include <fe/fe.h>
-#include <lac/sparse_matrix.h>
 
 #include <algorithm>
 
index e66eec73576d24baafff0dbac16af721b8474282..2fbb4da48cdca05ab3659fa24bca40c0453cae85 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <dofs/mg_dof_handler.h>
 #include <dofs/mg_dof_accessor.h>
 #include <grid/tria_iterator.h>
@@ -11,7 +11,7 @@
 template <int dim>
 void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<dim> &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<dim> &mg_dof_handler,
 // explicit instantiations
 template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<deal_II_dimension> &,
                                                 const unsigned int,
-                                                SparseMatrixStruct &);
+                                                SparsityPattern &);
 
index 27cc111a4dcc338f091f191e55480099cfd06474..3af8742a173cfcd9aac822422ec9fbc564a628a2 100644 (file)
@@ -11,8 +11,8 @@
 #include <fe/fe.h>
 
 #include <lac/vector.h>
-#include <lac/full_matrix.h>
-#include <lac/sparse_matrix.h>
+
+
 
 
 
index db54f243d7b39fd3d1d75efb3ea4d44645b47556..d880f442b161aba62d8c335f19a5cf7639086e36 100644 (file)
@@ -12,7 +12,6 @@
 #include <grid/tria.h>
 #include <grid/geometry_info.h>
 #include <fe/fe.h>
-#include <lac/sparse_matrix.h>
 
 #include <algorithm>
 
index e66eec73576d24baafff0dbac16af721b8474282..2fbb4da48cdca05ab3659fa24bca40c0453cae85 100644 (file)
@@ -1,6 +1,6 @@
 /* $Id$ */
 
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <dofs/mg_dof_handler.h>
 #include <dofs/mg_dof_accessor.h>
 #include <grid/tria_iterator.h>
@@ -11,7 +11,7 @@
 template <int dim>
 void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<dim> &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<dim> &mg_dof_handler,
 // explicit instantiations
 template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<deal_II_dimension> &,
                                                 const unsigned int,
-                                                SparseMatrixStruct &);
+                                                SparsityPattern &);
 
index 2b68b6ba36f500edb1fc123ef889995dd5f63bc2..9b6a5b4e9783b96f3a10b31763c7c468bef6b949 100644 (file)
@@ -8,6 +8,7 @@
 #include <numerics/multigrid.h>
 #include <numerics/mg_smoother.h>
 #include <lac/vector.h>
+#include <lac/sparse_matrix.h>
 
 #include <algorithm>
 
index 1b23f08634331ea7581f28c2cc00e1cb57ea79ff..5ac6408d953dd50e4558c99d5d0237b3a2a661d0 100644 (file)
@@ -10,7 +10,7 @@
 #include <numerics/multigrid.templates.h>
 #include <numerics/mg_smoother.h>
 #include <lac/vector.h>
-
+#include <lac/sparse_matrix.h>
 
 
 /* --------------------------------- MG ------------------------------------ */
@@ -91,7 +91,7 @@ void MGTransferPrebuilt::build_matrices (const MGDoFHandler<dim> &mg_dof)
                                   // level which have children
   for (unsigned int level=0; level<n_levels-1; ++level)
     {
-      prolongation_sparsities.push_back (SparseMatrixStruct());
+      prolongation_sparsities.push_back (SparsityPattern ());
                                       // reset the dimension of the structure.
                                       // note that for the number of entries
                                       // per row, the number of mother dofs
index 3de2be66b8e4ba6f4b5d0f98f193d58b94c62df5..90c482d3730e0cf58e07f0b4d9edf96c39a5c82f 100644 (file)
@@ -507,10 +507,10 @@ void MatrixTools<dim>::apply_boundary_values (const map<int,double> &boundary_va
     return;
   
   
-  map<int,double>::const_iterator dof  = boundary_values.begin(),
-                                 endd = boundary_values.end();
+  map<int,double>::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();
 
index 2b68b6ba36f500edb1fc123ef889995dd5f63bc2..9b6a5b4e9783b96f3a10b31763c7c468bef6b949 100644 (file)
@@ -8,6 +8,7 @@
 #include <numerics/multigrid.h>
 #include <numerics/mg_smoother.h>
 #include <lac/vector.h>
+#include <lac/sparse_matrix.h>
 
 #include <algorithm>
 
index 1b23f08634331ea7581f28c2cc00e1cb57ea79ff..5ac6408d953dd50e4558c99d5d0237b3a2a661d0 100644 (file)
@@ -10,7 +10,7 @@
 #include <numerics/multigrid.templates.h>
 #include <numerics/mg_smoother.h>
 #include <lac/vector.h>
-
+#include <lac/sparse_matrix.h>
 
 
 /* --------------------------------- MG ------------------------------------ */
@@ -91,7 +91,7 @@ void MGTransferPrebuilt::build_matrices (const MGDoFHandler<dim> &mg_dof)
                                   // level which have children
   for (unsigned int level=0; level<n_levels-1; ++level)
     {
-      prolongation_sparsities.push_back (SparseMatrixStruct());
+      prolongation_sparsities.push_back (SparsityPattern ());
                                       // reset the dimension of the structure.
                                       // note that for the number of entries
                                       // per row, the number of mother dofs
index ee06fe990a65a532e9000cc8ff965c8cb5410d07..ae03cc021682a05a27f26a7308c9c77dad97b702 100644 (file)
@@ -411,9 +411,9 @@ void VectorTools::project (const DoFHandler<dim>    &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<dim>    &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,
index e39eda858bcfbf9aedab78eadf789ae0b8ab24c6..181571a7bca76f2ff61af62bae8cc2d898cb7f9d 100644 (file)
@@ -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:
index 10e649fe44aca1680ccd847d829ef3bdc9e79256..448bae97f8fbda25e9c0b40b83be2e93c01afdb9 100644 (file)
@@ -128,7 +128,7 @@ class LaplaceProblem
                                     // system matrix resulting from
                                     // the discretization of the
                                     // Laplace equation...
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> 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
index 9b45c7d7f57b2edba6f5c5ac6ba255fe8cd95651..805feb5f533bf1eec706660da21055da8f246d58 100644 (file)
@@ -75,7 +75,7 @@ class LaplaceProblem
     FEQ1<dim>            fe;
     DoFHandler<dim>      dof_handler;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index 21ad88c48405e8d0f188ed80b8b387cab1f3662e..4f389ee25744a0b49a5fde2575230006cfc39b6f 100644 (file)
@@ -72,7 +72,7 @@ class LaplaceProblem
     FEQ1<dim>            fe;
     DoFHandler<dim>      dof_handler;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index b26124a9af8e0c650b9d9f0603d9c8c1e93bc60d..aa281775eded6218787c6d38750042f67370bec3 100644 (file)
@@ -121,7 +121,7 @@ class LaplaceProblem
                                     // hanging nodes:
     ConstraintMatrix     hanging_node_constraints;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index 93d6d2c47f115e1f8ab638a9a1b7668a7e572eba..5b03e6e1e3151016895a0322a86dc92699c7fcc3 100644 (file)
@@ -86,7 +86,7 @@ class ElasticProblem
 
     ConstraintMatrix     hanging_node_constraints;
 
-    SparseMatrixStruct   sparsity_pattern;
+    SparsityPattern      sparsity_pattern;
     SparseMatrix<double> system_matrix;
 
     Vector<double>       solution;
index a7c147d60ec4ed11b45f51b6aff0fd871d1ccf04..386549ac3f039e90ad5044a0b251cc7d642339bf 100644 (file)
@@ -15,6 +15,7 @@ PreconditionBlock<number,inverse_type>::PreconditionBlock ():
                A(0)  {};
 
 
+
 template <typename number, typename inverse_type>
 PreconditionBlock<number,inverse_type>::~PreconditionBlock ()
 {
@@ -22,6 +23,8 @@ PreconditionBlock<number,inverse_type>::~PreconditionBlock ()
     inverse.erase(inverse.begin(), inverse.end());
 }
 
+
+
 template <typename number, typename inverse_type>
 void PreconditionBlock<number,inverse_type>::clear ()
 {
@@ -30,6 +33,8 @@ void PreconditionBlock<number,inverse_type>::clear ()
   blocksize=0;
 }
 
+
+
 template <typename number, typename inverse_type>
 void PreconditionBlock<number,inverse_type>::use_matrix(
   const SparseMatrix<number> &M)
@@ -38,18 +43,21 @@ void PreconditionBlock<number,inverse_type>::use_matrix(
 }
 
 
+
 template <typename number, typename inverse_type>
 void PreconditionBlock<number,inverse_type>::set_block_size(unsigned int bsize) {
   blocksize=bsize;
 }
 
 
+
 template <typename number, typename inverse_type>
 unsigned int PreconditionBlock<number,inverse_type>::block_size() const {
   return blocksize;
 }
 
 
+
 template <typename number, typename inverse_type>
 void PreconditionBlock<number,inverse_type>::invert_diagblocks()
 {
@@ -119,10 +127,12 @@ PreconditionBlockSOR<number,inverse_type>::PreconditionBlockSOR(const number ome
                omega(omega)  {}
 
 
+
 template<typename number, typename inverse_type>
 PreconditionBlockSOR<number,inverse_type>::~PreconditionBlockSOR(){}
 
 
+
 template <typename number, typename inverse_type>
 template <typename number2>
 void PreconditionBlockSOR<number,inverse_type>::operator() (Vector<number2> &dst,
@@ -137,9 +147,9 @@ void PreconditionBlockSOR<number,inverse_type>::operator() (Vector<number2> &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<number2> b_cell(blocksize), x_cell(blocksize);
 
index 410b8108c784b676a36216755c59817a85bdef56..c1b4c3c48f827be893d81ff49187ea3e94b62f2c 100644 (file)
@@ -5,9 +5,8 @@
 #define __solver_selector_H
 /*----------------------------   solver_selector.h     ---------------------------*/
 
-#include <lac/solver.h>
 #include <base/smartpointer.h>
-#include <lac/sparse_matrix.h>
+#include <lac/solver.h>
 #include <lac/vector.h>
 #include <lac/vector_memory.h>
 #include <lac/solver_control.h>
@@ -17,7 +16,7 @@
 #include <lac/vector_memory.h>
 #include <lac/solver_richardson.h>
 #include <lac/precondition.h>
-
+#include <lac/forward_declarations.h>
 
 
 /**
index 9e13efa130fcd5a143a828d369ddaa87158b19f1..51b9fac3c7b3fe6e13d641e6f1156a4d2c0aeb4b 100644 (file)
@@ -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<number>
                                      *
                                      * You have to initialize
                                      * the matrix before usage with
-                                     * #reinit(SparseMatrixStruct)#.
+                                     * #reinit(SparsityPattern)#.
                                      */
     SparseILU ();
 
@@ -112,7 +112,7 @@ class SparseILU : protected SparseMatrix<number>
                                      * 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<number>
                                      * function is not publically visible
                                      * any more.
                                      */
-    void reinit (const SparseMatrixStruct &sparsity);
+    void reinit (const SparsityPattern &sparsity);
 
                                     /**
                                      * Perform the incomplete LU factorization
index 4f0acff54a6f99b98ac5766b62bbd884702cad21..c7b91ecb97612536e207fe2ad46be93d74cc6f2b 100644 (file)
@@ -20,7 +20,7 @@ SparseILU<number>::SparseILU ()
 
 
 template <typename number>
-SparseILU<number>::SparseILU (const SparseMatrixStruct &sparsity) :
+SparseILU<number>::SparseILU (const SparsityPattern &sparsity) :
                SparseMatrix<number> (sparsity)
 {};
 
@@ -35,7 +35,7 @@ void SparseILU<number>::reinit ()
 
 
 template <typename number>
-void SparseILU<number>::reinit (const SparseMatrixStruct &sparsity)
+void SparseILU<number>::reinit (const SparsityPattern &sparsity)
 {
   SparseMatrix<number>::reinit (sparsity);
 };
@@ -108,7 +108,7 @@ void SparseILU<number>::decompose (const SparseMatrix<somenumber> &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();
   
index 06865ca0c624e3f63d5a63a3c70c98abae255797..d93459ae6705c2eafe3987913a234864e0fc4e34 100644 (file)
 #include <base/exceptions.h>
 #include <base/subscriptor.h>
 #include <base/smartpointer.h>
-
-#include <vector>
-
-
-//forward declarations
-template <typename number> class Vector;
-template <typename number> 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<unsigned int> &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<unsigned int> &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<unsigned int> &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<rowstart[k+1]; ++i)#
-                                     * also for the last row.
-                                     *
-                                     * Note that the actual size of the
-                                     * allocated memory may be larger than
-                                     * the region that is used. The actual
-                                     * number of elements that was allocated
-                                     * is stored in #max_dim#.
-                                     */
-    unsigned int *rowstart;
-
-                                    /**
-                                     * Array of column numbers. In this array,
-                                     * we store for each non-zero element its
-                                     * column number. The column numbers for
-                                     * the elements in row #r# are stored
-                                     * within the index range
-                                     * #rowstart[r]...rowstart[r+1]#. Therefore
-                                     * to find out whether a given element
-                                     * #(r,c)# exists, we have to check
-                                     * whether the column number #c# exists in
-                                     * the abovementioned range within this
-                                     * array. If it exists, say at position
-                                     * #p# within this array, the value of
-                                     * the respective element in the sparse
-                                     * matrix will also be at position #p#
-                                     * of the values array of that class.
-                                     *
-                                     * At the beginning, all elements of
-                                     * this array are set to #-1# indicating
-                                     * invalid (unused) column numbers
-                                     * (however, note that if this object
-                                     * refers to a square matrix, the diagonal
-                                     * elements are preset, see below). Now, if
-                                     * nonzero elements are added, one column
-                                     * number in the row's respective range
-                                     * after the other is set to the column
-                                     * number of the added element. When
-                                     * compress is called, unused elements
-                                     * (indicated by column numbers #-1#)
-                                     * are eliminated by copying the column
-                                     * number of subsequent rows and the
-                                     * column numbers within each row (with
-                                     * the exception of the diagonal element)
-                                     * are sorted, such that finding whether
-                                     * an element exists and determining its
-                                     * position can be done by a binary search.
-                                     *
-                                     * If this object represents a square
-                                     * matrix, the first element in each
-                                     * row always denotes the diagonal
-                                     * element, i.e.
-                                     * #colnums[rowstart[r]]==r#.
-                                     */
-    int *colnums;
-
-                                    /**
-                                     * Store whether the #compress# function
-                                     * was called for this object.
-                                     */
-    bool compressed;
-
-    
-    template <typename number> friend class SparseMatrix;
-};
-
+#include <lac/sparsity_pattern.h>
 
 
 
@@ -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<const SparseMatrixStruct> cols;
+    SmartPointer<const SparsityPattern> 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<rows, ExcIndexRange(row,0,rows));
-  return rowstart[row+1]-rowstart[row];
-}
-
-inline
-unsigned int
-SparseMatrixStruct::column_number (const unsigned int row,
-                                  const unsigned int index) const
-{
-  Assert(row<rows, ExcIndexRange(row,0,rows));
-  Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
-
-  return colnums[rowstart[row]+index];
-}
-
-
-inline
-unsigned int
-SparseMatrixStruct::n_nonzero_elements () const
-{
-  Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
-  Assert (compressed, ExcNotCompressed());
-  return rowstart[rows]-rowstart[0];
-};
  
 
 template <typename number>
@@ -1423,7 +688,8 @@ void SparseMatrix<number>::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<number>::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<number>::diag_element (const unsigned int i)
 };
 
 
+
 template <typename number>
 inline
 number
@@ -1495,7 +763,7 @@ SparseMatrix<number>::raw_entry(unsigned int row, unsigned int index) const
   Assert(index<cols->row_length(row), ExcIndexRange(index,0,cols->row_length(row)));
 
   return val[cols->rowstart[row]+index];
-}
+};
 
 
 
index e9fcb5eda7bbc14380c0c3979ad8919d88bd221e..b0223fa581fcfc9f1385ef3ff4b865cd1f23ffd0 100644 (file)
@@ -63,7 +63,7 @@ SparseMatrix<number>::operator = (const SparseMatrix<number> &m)
 
 
 template <typename number>
-SparseMatrix<number>::SparseMatrix (const SparseMatrixStruct &c) :
+SparseMatrix<number>::SparseMatrix (const SparsityPattern &c) :
                cols(&c),
                val(0),
                max_len(0)
@@ -118,7 +118,7 @@ SparseMatrix<number>::reinit ()
 
 template <typename number>
 void
-SparseMatrix<number>::reinit (const SparseMatrixStruct &sparsity)
+SparseMatrix<number>::reinit (const SparsityPattern &sparsity)
 {
   if (cols != 0)
     cols->unsubscribe();
@@ -881,7 +881,7 @@ SparseMatrix<number>::SSOR (Vector<somenumber>& dst, const number om) const
 
 
 template <typename number>
-const SparseMatrixStruct &
+const SparsityPattern &
 SparseMatrix<number>::get_sparsity_pattern () const
 {
   Assert (cols != 0, ExcMatrixNotInitialized());
index 25875fd708d3498f7fde28847bb78f4d6c3028f2..8ed7e4e1ea9acb73498316c99615790ce32a34dc 100644 (file)
@@ -49,7 +49,7 @@ SparseVanka<number>::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<unsigned int, unsigned int> local_index;
@@ -67,7 +67,7 @@ SparseVanka<number>::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<number>::operator ()(Vector<number2>       &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<number>::operator ()(Vector<number2>       &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 (file)
index 0000000..41a65bb
--- /dev/null
@@ -0,0 +1,755 @@
+/*----------------------------   sparsity_pattern.h     ---------------------------*/
+/*      $Id$                 */
+#ifndef __sparsity_pattern_H
+#define __sparsity_pattern_H
+/*----------------------------   sparsity_pattern.h     ---------------------------*/
+
+
+
+#include <base/exceptions.h>
+#include <base/subscriptor.h>
+#include <lac/forward_declarations.h>
+
+#include <vector>
+
+
+
+
+/**
+ * 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<unsigned int> &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<unsigned int> &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<unsigned int> &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<rowstart[k+1]; ++i)#
+                                     * also for the last row.
+                                     *
+                                     * Note that the actual size of the
+                                     * allocated memory may be larger than
+                                     * the region that is used. The actual
+                                     * number of elements that was allocated
+                                     * is stored in #max_dim#.
+                                     */
+    unsigned int *rowstart;
+
+                                    /**
+                                     * Array of column numbers. In this array,
+                                     * we store for each non-zero element its
+                                     * column number. The column numbers for
+                                     * the elements in row #r# are stored
+                                     * within the index range
+                                     * #rowstart[r]...rowstart[r+1]#. Therefore
+                                     * to find out whether a given element
+                                     * #(r,c)# exists, we have to check
+                                     * whether the column number #c# exists in
+                                     * the abovementioned range within this
+                                     * array. If it exists, say at position
+                                     * #p# within this array, the value of
+                                     * the respective element in the sparse
+                                     * matrix will also be at position #p#
+                                     * of the values array of that class.
+                                     *
+                                     * At the beginning, all elements of
+                                     * this array are set to #-1# indicating
+                                     * invalid (unused) column numbers
+                                     * (however, note that if this object
+                                     * refers to a square matrix, the diagonal
+                                     * elements are preset, see below). Now, if
+                                     * nonzero elements are added, one column
+                                     * number in the row's respective range
+                                     * after the other is set to the column
+                                     * number of the added element. When
+                                     * compress is called, unused elements
+                                     * (indicated by column numbers #-1#)
+                                     * are eliminated by copying the column
+                                     * number of subsequent rows and the
+                                     * column numbers within each row (with
+                                     * the exception of the diagonal element)
+                                     * are sorted, such that finding whether
+                                     * an element exists and determining its
+                                     * position can be done by a binary search.
+                                     *
+                                     * If this object represents a square
+                                     * matrix, the first element in each
+                                     * row always denotes the diagonal
+                                     * element, i.e.
+                                     * #colnums[rowstart[r]]==r#.
+                                     */
+    int *colnums;
+
+                                    /**
+                                     * Store whether the #compress# function
+                                     * was called for this object.
+                                     */
+    bool compressed;
+
+    
+    template <typename number> 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<rows, ExcIndexRange(row,0,rows));
+  return rowstart[row+1]-rowstart[row];
+}
+
+inline
+unsigned int
+SparsityPattern::column_number (const unsigned int row,
+                                  const unsigned int index) const
+{
+  Assert(row<rows, ExcIndexRange(row,0,rows));
+  Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
+
+  return colnums[rowstart[row]+index];
+}
+
+
+inline
+unsigned int
+SparsityPattern::n_nonzero_elements () const
+{
+  Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
+  Assert (compressed, ExcNotCompressed());
+  return rowstart[rows]-rowstart[0];
+};
+
+
+
+/*----------------------------   sparsity_pattern.h     ---------------------------*/
+/* end of #ifndef __sparsity_pattern_H */
+#endif
+/*----------------------------   sparsity_pattern.h     ---------------------------*/
similarity index 89%
rename from deal.II/lac/source/sparse_matrix.cc
rename to deal.II/lac/source/sparsity_pattern.cc
index 3df0ce0b8735d5128fddfecb04940e0933583c38..6785747d26217a8d90f04b99fcd63d5cf292c5d9 100644 (file)
@@ -15,7 +15,7 @@
 #include <numeric>
 
 
-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<unsigned int> &row_lengths) 
+SparsityPattern::SparsityPattern (const unsigned int          m,
+                                 const unsigned int          n,
+                                 const vector<unsigned int> &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<unsigned int> &row_lengths) 
+SparsityPattern::SparsityPattern (const unsigned int          m,
+                                 const vector<unsigned int> &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<unsigned int> &row_lengths)
+SparsityPattern::reinit (const unsigned int m,
+                        const unsigned int n,
+                        const vector<unsigned int> &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<rows, ExcInvalidIndex(i,rows));
@@ -496,7 +496,7 @@ SparseMatrixStruct::operator () (const unsigned int i, const unsigned int j) con
 
 
 void
-SparseMatrixStruct::add (const unsigned int i, const unsigned int j)
+SparsityPattern::add (const unsigned int i, const unsigned int j)
 {
   Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
   Assert (i<rows, ExcInvalidIndex(i,rows));
@@ -525,7 +525,7 @@ SparseMatrixStruct::add (const unsigned int i, const unsigned int j)
 
 
 void
-SparseMatrixStruct::add_matrix (const unsigned int n, const int* rowcols)
+SparsityPattern::add_matrix (const unsigned int n, const int* rowcols)
 {
   Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
   for (unsigned int i=0; i<n; ++i)
@@ -536,8 +536,8 @@ SparseMatrixStruct::add_matrix (const unsigned int n, const int* rowcols)
 
 
 void
-SparseMatrixStruct::add_matrix (const unsigned int m, const unsigned int n,
-                               const int* rows, const int* cols)
+SparsityPattern::add_matrix (const unsigned int m, const unsigned int n,
+                            const int* rows, const int* cols)
 {
   Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
   for (unsigned i=0; i<m; ++i)
@@ -548,7 +548,7 @@ SparseMatrixStruct::add_matrix (const unsigned int m, const unsigned int n,
 
 
 void
-SparseMatrixStruct::print_gnuplot (ostream &out) const
+SparsityPattern::print_gnuplot (ostream &out) const
 {
   Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
   for (unsigned int i=0; i<rows; ++i)
@@ -562,7 +562,7 @@ SparseMatrixStruct::print_gnuplot (ostream &out) const
 
 
 unsigned int
-SparseMatrixStruct::bandwidth () const
+SparsityPattern::bandwidth () const
 {
   Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());  
   unsigned int b=0;
@@ -580,6 +580,3 @@ SparseMatrixStruct::bandwidth () const
   return b;
 };
 
-
-
-
index 4c46d77b3f4bca6df5dbce7ad60397c18c20774b..d820d9c111abb6d35f3f4ae9078cfd63769e6ce4 100644 (file)
@@ -12,7 +12,7 @@
 #include <grid/tria_iterator.h>
 #include <grid/tria_accessor.h>
 #include <grid/grid_generator.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
 #include <base/parameter_handler.h>
 #include <dofs/dof_constraints.h>
 #include <numerics/dof_renumbering.h>
@@ -360,8 +360,8 @@ void TestCases<dim>::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);
index 86d512190e62bd307b38daa175760e127cf54e43..e48fd7e98751b1ec4432ec0222f6cd457126137d 100644 (file)
@@ -128,7 +128,7 @@ class PoissonProblem {
                                     /**
                                      * Sparsity pattern of the system matrix.
                                      */
-    SparseMatrixStruct  system_sparsity;
+    SparsityPattern      system_sparsity;
 
                                     /**
                                      * System matrix.
index 1939908acb7478d657441d29406bcefd4c248fd1..710dffbc4ed4bc919845414483ef3f1a4ec8a729 100644 (file)
@@ -298,8 +298,8 @@ void TestCases<dim>::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);
index eac08ddf67c095749a32e66d8175da07d6efd19a..47698cab7b9f4dbd81cf200d1a538a504bd3acac 100644 (file)
@@ -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<SparseMatrixStruct> mgstruct(tr.n_levels());
+         vector<SparsityPattern> mgstruct(tr.n_levels());
          MGMatrix<SparseMatrix<double> > mgA(0,tr.n_levels()-1);
          for (unsigned int i=0;i<tr.n_levels();++i)
            {
index 065230e1438b40702766ce54d6f9bcc63d3b735f..4978314ebf21d8ae5d0df4456d16d3694adf39ac 100644 (file)
@@ -104,7 +104,7 @@ int main()
       for (unsigned int step=1;step < 5; ++step)
        {
          deallog << "smoothing-steps" << step << endl;
-         SparseMatrixStruct structure(size, dof.max_couplings_between_dofs());
+         SparsityPattern structure(size, dof.max_couplings_between_dofs());
          DoFTools::make_sparsity_pattern(dof, structure);
 
          ConstraintMatrix hanging_nodes;
@@ -128,7 +128,7 @@ int main()
          SolverControl control(20, 1.e-12, true);
          SolverRichardson<> solver(control, mem);
          
-         vector<SparseMatrixStruct> mgstruct(tr.n_levels());
+         vector<SparsityPattern> mgstruct(tr.n_levels());
          MGMatrix<SparseMatrix<double> > mgA(0,tr.n_levels()-1);
          for (unsigned int i=0;i<tr.n_levels();++i)
            {
index 8d208b454cf53a0c5afe703a5a5f5cd37e08fac6..dd0d47a5a8a07ff1f56a15b4e628420c2113a151 100644 (file)
@@ -90,7 +90,7 @@ class TimeStep_Wave :  public virtual TimeStepBase_Wave<dim>
     const Quadrature<dim>    &quadrature;
     const Quadrature<dim-1>  &quadrature_face;
     ConstraintMatrix          constraints;
-    SparseMatrixStruct        system_sparsity;
+    SparsityPattern           system_sparsity;
     SparseMatrix<double>       mass_matrix, laplace_matrix;
     Vector<double>             u, v;
     StatisticData              statistic_data;
@@ -1147,7 +1147,7 @@ class UserMatrix :  public SparseMatrix<double> {
                                      * The first parameter is simply passed
                                      * down to the base class.
                                      */
-    UserMatrix (const SparseMatrixStruct &sparsity,
+    UserMatrix (const SparsityPattern &sparsity,
                Preconditioning       p) :
                    SparseMatrix<double>(sparsity),
                    preconditioning (p) {};
index dd2779769a2f5d0a73a28cf14618ab33601a74ce..0279dfb26d8322f74a39cbda913fe955370a572b 100644 (file)
@@ -112,7 +112,7 @@ int main()
       deallog << "Level " << level << " size " << size << endl;
 
                                       // Make matrix
-      vector<SparseMatrixStruct >  structure(maxlevel+1);
+      vector<SparsityPattern>  structure(maxlevel+1);
       MGMatrix<SparseMatrix<double> > A(minlevel,maxlevel);
 
       FDMatrix testproblem(size, size);
index 3c126b0adbfe81978863e4803f999a6534bc9d12..daa9700d0e1e8765c06d44465c71bc74cc773dd1 100644 (file)
@@ -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<double>  A(structure);
index 2b3ae8afd4c53ea819b690f0b0996a80162d609e..a0bd9ae234acba9c127001088e4f66fb6911d8f6 100644 (file)
@@ -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<double>& matrix)
+                          SparsityPattern& structure, SparseMatrix<double>& matrix)
 {
   structure.reinit((nx-1)*(ny-1),(2*nx-1)*(2*ny-1),9);
   
index 7b9f0e8e3fc3f058b322b57684c25199ffb2dbf7..a81ca7210bb8b0654681163c46825868659e6aac 100644 (file)
@@ -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<SparseMatrixStruct > structures;
+    vector<SparsityPattern> structures;
                                     /**
                                      * Prolongation matrices.
                                      */
@@ -101,5 +101,5 @@ class FDMGTransfer
                                      * fine to coarse (#vmult#).
                                      */
     void build_matrix(unsigned int nx, unsigned int ny,
-                     SparseMatrixStruct&, SparseMatrix<double>&);
+                     SparsityPattern&, SparseMatrix<double>&);
 };

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.