From 06284aec96990c3ae44ef02b8868c3947fca1948 Mon Sep 17 00:00:00 2001 From: kronbichler Date: Mon, 27 Jun 2011 16:31:46 +0000 Subject: [PATCH] Implement ConstraintMatrix::merge() for constraint matrices localized by an IndexSet (same IndexSet on both CM). git-svn-id: https://svn.dealii.org/trunk@23867 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/source/lac/constraint_matrix.cc | 26 ++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 4608085593..b3e01a6663 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -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::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::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::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::const_iterator line=lines.begin(); - line!=lines.end(); ++line, ++counter) - lines_cache[line->line] = counter; if (object_was_sorted == true) close (); } -- 2.39.5