]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add function that can extract diagonal subblock from ConstraintMatrix.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 27 Jan 2010 13:22:36 +0000 (13:22 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 27 Jan 2010 13:22:36 +0000 (13:22 +0000)
git-svn-id: https://svn.dealii.org/trunk@20453 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/constraint_matrix.h
deal.II/lac/include/lac/constraint_matrix.templates.h
deal.II/lac/source/constraint_matrix.cc

index 14840accc47322458d2d5fd7b654db9456d6ae8b..789519f1567462f68dd9c4dd231e6d6f3f029ee1 100644 (file)
@@ -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
                                      * @{
index 6abc98d0a91f4c094d5d0f32fc91c46847970d79..e956c626b43fc2b799b415bffe5b345e053dd9ad 100644 (file)
@@ -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_end) // case 2: can rewrite loop
+    else if (i>=column_start && i<column_end) // case 2: can split loop
       {
        if (global_rows.have_indirect_rows() == false)
          {
index 5c1330e67189ddfcfbadba2709e0a6fc933fa54b..4969878ad6dbcea57bcb3e5b697b9f8fd6c87b56 100644 (file)
@@ -160,6 +160,28 @@ ConstraintMatrix::add_entries (const unsigned int                        line,
 
 
 
+void ConstraintMatrix::add_selected_constraints 
+  (const ConstraintMatrix &constraints,
+   const IndexSet         &filter)
+{
+  Assert (filter.size() > constraints.lines.back().line,
+         ExcMessage ("Filter needs to be larger than constraint matrix size."));
+  for (std::vector<ConstraintLine>::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; i<line->entries.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)

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.