From: Dustin Kumor Date: Fri, 24 Aug 2018 09:13:37 +0000 (+0200) Subject: Fixed bug in member function AffineConstraints::add_entries X-Git-Tag: v9.1.0-rc1~781^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9799b4760b1e9c45dd8f2eaddb598381ea024718;p=dealii.git 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. --- 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); } }