#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>
// 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
/* $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 */
#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>
<< 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());
}
/* $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 */
#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>
<< 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());
}
/* $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 */
#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>
{
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());
// 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
// 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