]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Implement ConstraintMatrix::merge() for constraint matrices localized by an IndexSet...
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 27 Jun 2011 16:31:46 +0000 (16:31 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 27 Jun 2011 16:31:46 +0000 (16:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@23867 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/lac/constraint_matrix.cc

index 460808559361c522426dd53bd19f1380101ef781..b3e01a6663ce598519f5789a66a6bd3d16a3e9ca 100644 (file)
@@ -171,6 +171,9 @@ void ConstraintMatrix::add_selected_constraints
   (const ConstraintMatrix &constraints,
    const IndexSet         &filter)
 {
+  if (constraints.n_constraints() == 0)
+    return;
+
   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();
@@ -545,9 +548,8 @@ void
 ConstraintMatrix::merge (const ConstraintMatrix &other_constraints,
                         const MergeConflictBehavior merge_conflict_behavior)
 {
-                                  //TODO: this doesn't work with IndexSets yet. [TH]
-  AssertThrow(local_lines.size()==0, ExcNotImplemented());
-  AssertThrow(other_constraints.local_lines.size()==0, ExcNotImplemented());
+  AssertThrow(local_lines == other_constraints.local_lines,
+             ExcNotImplemented());
 
                                   // store the previous state with
                                   // respect to sorting
@@ -584,7 +586,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints,
                                           // constrained, or if we won't take
                                           // the constraint from the other
                                           // object, then simply copy it over
-         if (!other_constraints.is_constrained(line->entries[i].first)
+         if (other_constraints.is_constrained(line->entries[i].first) == false
              ||
              ((merge_conflict_behavior != right_object_wins)
               &&
@@ -615,7 +617,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints,
                                                              j->second*weight));
 
              line->inhomogeneity += other_constraints.get_inhomogeneity(line->entries[i].first) *
-                                    line->entries[i].second;
+                                    weight;
            }
        }
                                       // finally exchange old and
@@ -630,7 +632,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints,
   for (std::vector<ConstraintLine>::const_iterator
         line=other_constraints.lines.begin();
        line!=other_constraints.lines.end(); ++line)
-    if (!is_constrained(line->line))
+    if (is_constrained(line->line) == false)
       lines.push_back (*line);
     else
       {
@@ -665,15 +667,17 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints,
          }
       }
 
+                               // update the lines cache
+  unsigned int counter = 0;
+  for (std::vector<ConstraintLine>::const_iterator line=lines.begin();
+       line!=lines.end(); ++line, ++counter)
+    lines_cache[calculate_line_index(line->line)] = counter;
+
                                   // if the object was sorted before,
                                   // then make sure it is so
-                                  // afterwards as well. otherwise
+                                  // afterward as well. otherwise
                                   // leave everything in the unsorted
                                   // state
-  unsigned int counter = 0;
-  for (std::vector<ConstraintLine>::const_iterator line=lines.begin();
-       line!=lines.end(); ++line, ++counter)
-    lines_cache[line->line] = counter;
   if (object_was_sorted == true)
     close ();
 }

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.