From c94ba06db0ebd3eb4d94e827ceff95235cc781a7 Mon Sep 17 00:00:00 2001 From: bangerth Date: Tue, 5 Jan 2010 09:00:45 +0000 Subject: [PATCH] Add functions that can add multiple lines all at once. git-svn-id: https://svn.dealii.org/trunk@20282 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 9 ++++ deal.II/lac/include/lac/constraint_matrix.h | 46 ++++++++++++++++++++- deal.II/lac/source/constraint_matrix.cc | 22 +++++++++- 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 7c73f506c2..b3ac73415c 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -377,6 +377,15 @@ inconvenience this causes.
    +
  1. +

    + New: There are now two ConstraintMatrix::add_lines functions that can + add several constraints at once. +

    +
    + (WB 2010/01/05) +
  2. +
  3. Improved: The Vector class has been equipped with an improved way to diff --git a/deal.II/lac/include/lac/constraint_matrix.h b/deal.II/lac/include/lac/constraint_matrix.h index 424debc748..a0c6bc392a 100644 --- a/deal.II/lac/include/lac/constraint_matrix.h +++ b/deal.II/lac/include/lac/constraint_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1998, 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 @@ -367,6 +367,50 @@ class ConstraintMatrix : public Subscriptor */ void add_line (const unsigned int line); + /** + * Call the first add_line() function for + * every index i for which + * lines[i] is true. + * + * This function essentially exists to + * allow adding several constraints of + * the form $x_i=0$ all at once, where + * the set of indices $i$ for which these + * constraints should be added are given + * by the argument of this function. On + * the other hand, just as if the + * single-argument add_line() function + * were called repeatedly, the + * constraints can later be modified to + * include linear dependencies using the + * add_entry() function as well as + * inhomogeneities using + * set_inhomogeneity(). + */ + void add_lines (const std::vector &lines); + + /** + * Call the first add_line() function for + * every index i that + * appears in the argument. + * + * This function essentially exists to + * allow adding several constraints of + * the form $x_i=0$ all at once, where + * the set of indices $i$ for which these + * constraints should be added are given + * by the argument of this function. On + * the other hand, just as if the + * single-argument add_line() function + * were called repeatedly, the + * constraints can later be modified to + * include linear dependencies using the + * add_entry() function as well as + * inhomogeneities using + * set_inhomogeneity(). + */ + void add_lines (const std::set &lines); + /** * Add an entry to a given * line. The list of lines is diff --git a/deal.II/lac/source/constraint_matrix.cc b/deal.II/lac/source/constraint_matrix.cc index 362527e2bc..5c1330e671 100644 --- a/deal.II/lac/source/constraint_matrix.cc +++ b/deal.II/lac/source/constraint_matrix.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by the deal.II authors +// Copyright (C) 1998, 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 @@ -90,6 +90,26 @@ ConstraintMatrix::ConstraintLine::memory_consumption () const +void +ConstraintMatrix::add_lines (const std::set &lines) +{ + for (std::set::const_iterator + i = lines.begin(); i != lines.end(); ++i) + add_line (*i); +} + + + +void +ConstraintMatrix::add_lines (const std::vector &lines) +{ + for (unsigned int i=0; i > &col_val_pairs) -- 2.39.5