]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
use CompressedSparsityPattern
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 20 Jun 2010 17:53:33 +0000 (17:53 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 20 Jun 2010 17:53:33 +0000 (17:53 +0000)
git-svn-id: https://svn.dealii.org/trunk@21235 0785d39b-7218-0410-832d-ea1e28bc413d

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

index 3a3f92a8be69e5d5a18aed44933b5548b3c49509..de0da46ba679e58d0a342267f3d824e747a62fa6 100644 (file)
@@ -80,6 +80,7 @@
 #include <lac/vector.h>
 #include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
+#include <lac/compressed_sparsity_pattern.h>
 #include <lac/solver_cg.h>
 #include <lac/precondition.h>
 
@@ -259,25 +260,16 @@ void LaplaceProblem::make_grid_and_dofs ()
                                   // As we have seen in the previous example,
                                   // we set up a sparsity pattern for the
                                   // system matrix and tag those entries that
-                                  // might be nonzero. Compared to what we
-                                  // did in step-2, the only change is that
-                                  // instead of giving a magically obtained
-                                  // maximal number of nonzero entries per
-                                  // row, we now use a function in the
-                                  // <code>DoFHandler</code> class that can compute
-                                  // this number for us:
-  sparsity_pattern.reinit (dof_handler.n_dofs(),
-                          dof_handler.n_dofs(),
-                          dof_handler.max_couplings_between_dofs());
-  DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
-  sparsity_pattern.compress();
+                                  // might be nonzero.  
+  CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
+  DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);
+  sparsity_pattern.copy_from(c_sparsity);
 
                                   // Now the sparsity pattern is
-                                  // built and fixed (after
-                                  // `compress' has been called, you
+                                  // built, you
                                   // can't add nonzero entries
-                                  // anymore; the sparsity pattern is
-                                  // `sealed', so to say), we can
+                                  // anymore. The sparsity pattern is
+                                  // `sealed', so to say, and we can
                                   // initialize the matrix itself
                                   // with it. Note that the
                                   // SparsityPattern object does
index 680c59bb4c2cf98156e86625ce076e87b0af9743..8c49529ef25c7dfb0d1f52edf47a2967056c38e3 100644 (file)
@@ -3,7 +3,7 @@
 
 /*    $Id$       */
 /*                                                                */
-/*    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors */
+/*    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by the deal.II authors */
 /*                                                                */
 /*    This file is subject to QPL and may not be  distributed     */
 /*    without copyright and license information. Please refer     */
@@ -33,6 +33,7 @@
 #include <lac/vector.h>
 #include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
+#include <lac/compressed_sparsity_pattern.h>
 #include <lac/solver_cg.h>
 #include <lac/precondition.h>
 
@@ -344,14 +345,12 @@ void LaplaceProblem<dim>::make_grid_and_dofs ()
            << dof_handler.n_dofs()
            << std::endl;
 
-  sparsity_pattern.reinit (dof_handler.n_dofs(),
-                          dof_handler.n_dofs(),
-                          dof_handler.max_couplings_between_dofs());
-  DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
-  sparsity_pattern.compress();
-
+  CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
+  DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);
+  sparsity_pattern.copy_from(c_sparsity);
+  
   system_matrix.reinit (sparsity_pattern);
-
+  
   solution.reinit (dof_handler.n_dofs());
   system_rhs.reinit (dof_handler.n_dofs());
 }
index 86d3b720c5efa2ba3b80ecbb31440edb19f497d6..d140d0a654a3b23155d54285f1e8403cc481361c 100644 (file)
@@ -3,7 +3,7 @@
 
 /*    $Id$       */
 /*                                                                */
-/*    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008 by the deal.II authors */
+/*    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010 by the deal.II authors */
 /*                                                                */
 /*    This file is subject to QPL and may not be  distributed     */
 /*    without copyright and license information. Please refer     */
@@ -21,6 +21,7 @@
 #include <lac/vector.h>
 #include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
+#include <lac/compressed_sparsity_pattern.h>
 #include <lac/solver_cg.h>
 #include <lac/precondition.h>
 #include <grid/tria.h>
@@ -382,14 +383,12 @@ void LaplaceProblem<dim>::setup_system ()
            << dof_handler.n_dofs()
            << std::endl;
 
-  sparsity_pattern.reinit (dof_handler.n_dofs(),
-                          dof_handler.n_dofs(),
-                          dof_handler.max_couplings_between_dofs());
-  DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
-  sparsity_pattern.compress();
-
+  CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
+  DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);
+  sparsity_pattern.copy_from(c_sparsity);
+  
   system_matrix.reinit (sparsity_pattern);
-
+  
   solution.reinit (dof_handler.n_dofs());
   system_rhs.reinit (dof_handler.n_dofs());
 }
index b6d3ae272965e557ccdc222f968515102e19969c..0050d8507bb4e0a199257404788d20f040f63b67 100644 (file)
@@ -3,7 +3,7 @@
 
 /*    $Id$       */
 /*                                                                */
-/*    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008 by the deal.II authors */
+/*    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2006, 2007, 2008, 2010 by the deal.II authors */
 /*                                                                */
 /*    This file is subject to QPL and may not be  distributed     */
 /*    without copyright and license information. Please refer     */
@@ -22,6 +22,7 @@
 #include <lac/vector.h>
 #include <lac/full_matrix.h>
 #include <lac/sparse_matrix.h>
+#include <lac/compressed_sparsity_pattern.h>
 #include <lac/solver_cg.h>
 #include <lac/precondition.h>
 #include <grid/tria.h>
@@ -409,11 +410,6 @@ void LaplaceProblem<dim>::setup_system ()
 {
   dof_handler.distribute_dofs (fe);
 
-  sparsity_pattern.reinit (dof_handler.n_dofs(),
-                          dof_handler.n_dofs(),
-                          dof_handler.max_couplings_between_dofs());
-  DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
-
   solution.reinit (dof_handler.n_dofs());
   system_rhs.reinit (dof_handler.n_dofs());
 
@@ -467,6 +463,15 @@ void LaplaceProblem<dim>::setup_system ()
                                   // added any more:
   hanging_node_constraints.close ();
 
+                                  // Now we first build our
+                                  // compressed sparsity pattern like
+                                  // we did in the previous
+                                  // examples. Nevertheless, we do
+                                  // not copy it to the final
+                                  // sparsity pattern immediately.
+  CompressedSparsityPattern c_sparsity(dof_handler.n_dofs());
+  DoFTools::make_sparsity_pattern (dof_handler, c_sparsity);
+  
                                   // The constrained hanging nodes
                                   // will later be eliminated from
                                   // the linear system of
@@ -483,17 +488,17 @@ void LaplaceProblem<dim>::setup_system ()
                                   // the system matrix and right hand
                                   // side, as well as for the
                                   // sparsity pattern.
-  hanging_node_constraints.condense (sparsity_pattern);
+  hanging_node_constraints.condense (c_sparsity);
 
                                   // Now all non-zero entries of the
                                   // matrix are known (i.e. those
                                   // from regularly assembling the
                                   // matrix and those that were
                                   // introduced by eliminating
-                                  // constraints). We can thus close
-                                  // the sparsity pattern and remove
-                                  // unneeded space:
-  sparsity_pattern.compress();
+                                  // constraints). We can thus copy
+                                  // our intermediate object to
+                                  // the sparsity pattern:
+  sparsity_pattern.copy_from(c_sparsity);
 
                                   // Finally, the so-constructed
                                   // sparsity pattern serves as the

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.