]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement the creation of sparsity patterns for the levelwise matrices.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 26 Aug 1998 08:56:43 +0000 (08:56 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 26 Aug 1998 08:56:43 +0000 (08:56 +0000)
git-svn-id: https://svn.dealii.org/trunk@523 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/mg_dof_handler.h
deal.II/deal.II/include/multigrid/mg_dof_handler.h
deal.II/deal.II/source/dofs/mg_dof_handler.cc
deal.II/deal.II/source/multigrid/mg_dof_handler.cc

index 0e52401f3750e54df73d3c6c39b902a8c4c35693..34840ddd180c69ae87eaefc96028c1b124e5081b 100644 (file)
@@ -156,6 +156,26 @@ class MGDoFHandler : public DoFHandler<dim> {
                                const bool use_constraints         = false,
                                const vector<int> &starting_points = vector<int>());
 
+                                    /**
+                                     * Write the sparsity structure of the
+                                     * matrix belonging to the specified
+                                     * #level# including constrained
+                                     * degrees of freedom into the
+                                     * matrix structure. The sparsity pattern
+                                     * does not include entries introduced by
+                                     * the elimination of constrained nodes.
+                                     * The sparsity
+                                     * pattern is not compressed, since if
+                                     * you want to call
+                                     * #ConstraintMatrix::condense(1)#
+                                     * afterwards, new entries have to be
+                                     * added. However, if you don't want to call
+                                     * #ConstraintMatrix::condense(1)#, you
+                                     * have to compress the matrix yourself,
+                                     * using #dSMatrixStruct::compress()#.
+                                     */
+    void make_sparsity_pattern (const unsigned int level,
+                               dSMatrixStruct    &sparsity) const; 
 
                                     /*--------------------------------------*/
     
@@ -623,6 +643,22 @@ class MGDoFHandler : public DoFHandler<dim> {
                                     /*@}*/
 
                                     /*---------------------------------------*/
+
+                                    /**
+                                     * Return the number of degrees of freedom
+                                     * on the specified level.
+                                     * Included in this number are those
+                                     * DoFs which are constrained by
+                                     * hanging nodes.
+                                     */
+    unsigned int n_dofs (const unsigned int level) const;
+
+                                    /**
+                                     * Exception.
+                                     */
+    DeclException1 (ExcInvalidLevel,
+                   int,
+                   << "The level index " << arg1 << "was not in the valid range.");
     
   private:
 
index 0e52401f3750e54df73d3c6c39b902a8c4c35693..34840ddd180c69ae87eaefc96028c1b124e5081b 100644 (file)
@@ -156,6 +156,26 @@ class MGDoFHandler : public DoFHandler<dim> {
                                const bool use_constraints         = false,
                                const vector<int> &starting_points = vector<int>());
 
+                                    /**
+                                     * Write the sparsity structure of the
+                                     * matrix belonging to the specified
+                                     * #level# including constrained
+                                     * degrees of freedom into the
+                                     * matrix structure. The sparsity pattern
+                                     * does not include entries introduced by
+                                     * the elimination of constrained nodes.
+                                     * The sparsity
+                                     * pattern is not compressed, since if
+                                     * you want to call
+                                     * #ConstraintMatrix::condense(1)#
+                                     * afterwards, new entries have to be
+                                     * added. However, if you don't want to call
+                                     * #ConstraintMatrix::condense(1)#, you
+                                     * have to compress the matrix yourself,
+                                     * using #dSMatrixStruct::compress()#.
+                                     */
+    void make_sparsity_pattern (const unsigned int level,
+                               dSMatrixStruct    &sparsity) const; 
 
                                     /*--------------------------------------*/
     
@@ -623,6 +643,22 @@ class MGDoFHandler : public DoFHandler<dim> {
                                     /*@}*/
 
                                     /*---------------------------------------*/
+
+                                    /**
+                                     * Return the number of degrees of freedom
+                                     * on the specified level.
+                                     * Included in this number are those
+                                     * DoFs which are constrained by
+                                     * hanging nodes.
+                                     */
+    unsigned int n_dofs (const unsigned int level) const;
+
+                                    /**
+                                     * Exception.
+                                     */
+    DeclException1 (ExcInvalidLevel,
+                   int,
+                   << "The level index " << arg1 << "was not in the valid range.");
     
   private:
 
index bb3d7d999fd6107a4c5b22c2aad1a998c99c4252..d9f1a8b2137f69eeb4381202bf1dd5bf3b45f244 100644 (file)
@@ -10,7 +10,7 @@
 #include <grid/tria.h>
 #include <grid/geometry_info.h>
 #include <fe/fe.h>
-
+#include <lac/dsmatrix.h>
 
 
 /* ------------------------ MGVertexDoFs ----------------------------------- */
@@ -962,6 +962,40 @@ MGDoFHandler<2>::distribute_dofs_on_cell (active_cell_iterator &cell,
 
 
 
+template <int dim>
+unsigned int MGDoFHandler<dim>::n_dofs (const unsigned int level) const {
+  Assert (level < mg_used_dofs.size(), ExcInvalidLevel(level));
+  
+  return mg_used_dofs[level];
+};
+
+
+
+template <int dim>
+void MGDoFHandler<dim>::make_sparsity_pattern (const unsigned int  level,
+                                              dSMatrixStruct     &sparsity) const {
+  Assert (selected_fe != 0, ExcNoFESelected());
+  Assert (sparsity.n_rows() == n_dofs(level),
+         ExcDifferentDimensions (sparsity.n_rows(), n_dofs(level)));
+  Assert (sparsity.n_cols() == n_dofs(level),
+         ExcDifferentDimensions (sparsity.n_cols(), n_dofs(level)));
+
+  const unsigned int total_dofs = selected_fe->total_dofs;
+  vector<int> dofs_on_this_cell(total_dofs);
+  cell_iterator cell = begin_active(level),
+               endc = end(level);
+  for (; cell!=endc; ++cell) 
+    {
+      cell->get_mg_dof_indices (dofs_on_this_cell);
+                                      // make sparsity pattern for this cell
+      for (unsigned int i=0; i<total_dofs; ++i)
+       for (unsigned int j=0; j<total_dofs; ++j)
+         sparsity.add (dofs_on_this_cell[i],
+                       dofs_on_this_cell[j]);
+    };
+};
+
+
 
 
 #if deal_II_dimension == 1
index bb3d7d999fd6107a4c5b22c2aad1a998c99c4252..d9f1a8b2137f69eeb4381202bf1dd5bf3b45f244 100644 (file)
@@ -10,7 +10,7 @@
 #include <grid/tria.h>
 #include <grid/geometry_info.h>
 #include <fe/fe.h>
-
+#include <lac/dsmatrix.h>
 
 
 /* ------------------------ MGVertexDoFs ----------------------------------- */
@@ -962,6 +962,40 @@ MGDoFHandler<2>::distribute_dofs_on_cell (active_cell_iterator &cell,
 
 
 
+template <int dim>
+unsigned int MGDoFHandler<dim>::n_dofs (const unsigned int level) const {
+  Assert (level < mg_used_dofs.size(), ExcInvalidLevel(level));
+  
+  return mg_used_dofs[level];
+};
+
+
+
+template <int dim>
+void MGDoFHandler<dim>::make_sparsity_pattern (const unsigned int  level,
+                                              dSMatrixStruct     &sparsity) const {
+  Assert (selected_fe != 0, ExcNoFESelected());
+  Assert (sparsity.n_rows() == n_dofs(level),
+         ExcDifferentDimensions (sparsity.n_rows(), n_dofs(level)));
+  Assert (sparsity.n_cols() == n_dofs(level),
+         ExcDifferentDimensions (sparsity.n_cols(), n_dofs(level)));
+
+  const unsigned int total_dofs = selected_fe->total_dofs;
+  vector<int> dofs_on_this_cell(total_dofs);
+  cell_iterator cell = begin_active(level),
+               endc = end(level);
+  for (; cell!=endc; ++cell) 
+    {
+      cell->get_mg_dof_indices (dofs_on_this_cell);
+                                      // make sparsity pattern for this cell
+      for (unsigned int i=0; i<total_dofs; ++i)
+       for (unsigned int j=0; j<total_dofs; ++j)
+         sparsity.add (dofs_on_this_cell[i],
+                       dofs_on_this_cell[j]);
+    };
+};
+
+
 
 
 #if deal_II_dimension == 1

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.