From 9799b4760b1e9c45dd8f2eaddb598381ea024718 Mon Sep 17 00:00:00 2001 From: Dustin Kumor Date: Fri, 24 Aug 2018 11:13:37 +0200 Subject: [PATCH] Fixed bug in member function AffineConstraints::add_entries Although it is stated in the code comments that already existing entries are skipped they are added nevertheless and thus lead to duplicates in the constraint matrix. This bug was fixed by introducing a bool variable indicating the currently treated column-value-pair to be added or not. --- include/deal.II/lac/affine_constraints.templates.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/deal.II/lac/affine_constraints.templates.h b/include/deal.II/lac/affine_constraints.templates.h index 9807792007..57845147f2 100644 --- a/include/deal.II/lac/affine_constraints.templates.h +++ b/include/deal.II/lac/affine_constraints.templates.h @@ -252,7 +252,7 @@ AffineConstraints::add_entries( { Assert(line_n != col_val_pair.first, ExcMessage("Can't constrain a degree of freedom to itself")); - + bool entry_exists = false; for (const std::pair &entry : line.entries) if (entry.first == col_val_pair.first) { @@ -262,10 +262,12 @@ AffineConstraints::add_entries( col_val_pair.first, entry.second, col_val_pair.second)); + entry_exists = true; break; } - line.entries.push_back(col_val_pair); + if (entry_exists == false) + line_ptr->entries.push_back(*col_val_pair); } } -- 2.39.5