From fa68e1ea156f174b3751e030929e81dd9992be30 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Wed, 27 Jan 2010 13:22:36 +0000 Subject: [PATCH] Add function that can extract diagonal subblock from ConstraintMatrix. git-svn-id: https://svn.dealii.org/trunk@20453 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/constraint_matrix.h | 22 +++++++++++++++++++ .../include/lac/constraint_matrix.templates.h | 4 ++-- deal.II/lac/source/constraint_matrix.cc | 22 +++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/deal.II/lac/include/lac/constraint_matrix.h b/deal.II/lac/include/lac/constraint_matrix.h index 14840accc4..789519f156 100644 --- a/deal.II/lac/include/lac/constraint_matrix.h +++ b/deal.II/lac/include/lac/constraint_matrix.h @@ -353,6 +353,28 @@ class ConstraintMatrix : public Subscriptor */ void reinit (const IndexSet & local_constraints = IndexSet()); + + /** + * This function copies the content of @p + * constraints_in with DoFs that are + * element of the IndexSet @p + * filter. Constrained dofs are + * transformed to local index space of + * the filter, and elements not present + * in the IndexSet are ignored. + * + * This function provides an easy way to + * create a ConstraintMatrix for certain + * vector components in a vector-valued + * problem from a full ConstraintMatrix, + * i.e. extracting a diagonal subblock + * from a larger ConstraintMatrix. The + * block is specified by the IndexSet + * argument. + */ + void add_selected_constraints (const ConstraintMatrix &constraints_in, + const IndexSet &filter); + /** * @name Adding constraints * @{ diff --git a/deal.II/lac/include/lac/constraint_matrix.templates.h b/deal.II/lac/include/lac/constraint_matrix.templates.h index 6abc98d0a9..e956c626b4 100644 --- a/deal.II/lac/include/lac/constraint_matrix.templates.h +++ b/deal.II/lac/include/lac/constraint_matrix.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// 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 @@ -1536,7 +1536,7 @@ namespace internals } } } - else if (i>=column_start && i=column_start && i constraints.lines.back().line, + ExcMessage ("Filter needs to be larger than constraint matrix size.")); + for (std::vector::const_iterator line=constraints.lines.begin(); + line!=constraints.lines.end(); ++line) + if (filter.is_element(line->line)) + { + const unsigned int row = filter.index_within_set (line->line); + add_line (row); + set_inhomogeneity (row, line->inhomogeneity); + for (unsigned int i=0; ientries.size(); ++i) + if (filter.is_element(line->entries[i].first)) + add_entry (row, filter.index_within_set (line->entries[i].first), + line->entries[i].second); + } +} + + + void ConstraintMatrix::close () { if (sorted == true) -- 2.39.5