]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fixed bug in member function AffineConstraints<number>::add_entries
authorDustin Kumor <dustin.kumor@tu-dortmund.de>
Fri, 24 Aug 2018 09:13:37 +0000 (11:13 +0200)
committerDustin Kumor <dustin.kumor@tu-dortmund.de>
Fri, 24 Aug 2018 09:52:42 +0000 (11:52 +0200)
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

index 9807792007313a852acb41bcf985997bae4418eb..57845147f26cd19b3d91c0c4beb017d32ff7b1c0 100644 (file)
@@ -252,7 +252,7 @@ AffineConstraints<number>::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<size_type, number> &entry : line.entries)
         if (entry.first == col_val_pair.first)
           {
@@ -262,10 +262,12 @@ AffineConstraints<number>::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);
     }
 }
 

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.