From 4af0606726c4e3b8c83694527bfc6098786652cc Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 18 Jan 2017 11:28:28 +0100 Subject: [PATCH] Allow merging with different lines only if explicitly requested --- include/deal.II/lac/constraint_matrix.h | 10 ++++++---- source/lac/constraint_matrix.cc | 9 ++++++++- tests/lac/constraints_merge_10.cc | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index 3c3e758873..02535c099c 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -360,15 +360,17 @@ public: * However, this behavior can be changed by providing a different value for * the second argument. * - * If both this object and the object given as argument are initialized with - * an IndexSet object, local_lines is set to the union of these IndexSet - * objects. + * By default, merging two ConstraintMatrix objects that are initialized + * with different IndexSet objects is not allowed. + * This behavior can be altered by setting @p allow_different_local_lines + * appropriately. * * Merging a ConstraintMatrix that is initialized with an IndexSet * and one that is not initialized with an IndexSet is not yet implemented. */ void merge (const ConstraintMatrix &other_constraints, - const MergeConflictBehavior merge_conflict_behavior = no_conflicts_allowed); + const MergeConflictBehavior merge_conflict_behavior = no_conflicts_allowed, + const bool allow_different_local_lines = false); /** * Shift all entries of this matrix down @p offset rows and over @p offset diff --git a/source/lac/constraint_matrix.cc b/source/lac/constraint_matrix.cc index 29f61125cb..f0b0c1cbdf 100644 --- a/source/lac/constraint_matrix.cc +++ b/source/lac/constraint_matrix.cc @@ -475,8 +475,15 @@ void ConstraintMatrix::close () void ConstraintMatrix::merge (const ConstraintMatrix &other_constraints, - const MergeConflictBehavior merge_conflict_behavior) + const MergeConflictBehavior merge_conflict_behavior, + const bool allow_different_local_lines) { + (void) allow_different_local_lines; + Assert(allow_different_local_lines || + local_lines == other_constraints.local_lines, + ExcMessage("local_lines for this and the other objects are not the same " + "although allow_different_local_lines is false.")); + // store the previous state with respect to sorting const bool object_was_sorted = sorted; sorted = false; diff --git a/tests/lac/constraints_merge_10.cc b/tests/lac/constraints_merge_10.cc index 7d0fc2dec1..48a6fa0d31 100644 --- a/tests/lac/constraints_merge_10.cc +++ b/tests/lac/constraints_merge_10.cc @@ -103,7 +103,7 @@ void merge_check () // now merge the two and print the // results - c1.merge (c2); + c1.merge (c2, ConstraintMatrix::no_conflicts_allowed, true); c1.print(deallog.get_file_stream()); }; } -- 2.39.5