]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
limit the number of entries in a ConstraintMatrix generated while close()ing to detec...
authorheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 29 Aug 2012 18:55:32 +0000 (18:55 +0000)
committerheister <heister@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 29 Aug 2012 18:55:32 +0000 (18:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@26156 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/source/lac/constraint_matrix.cc

index 51befc61459dffdadb68460d3e4bb7246145b028..216cdc8b87d6e2d6c7805a3fa6e66aa4de0380b9 100644 (file)
@@ -238,6 +238,25 @@ void ConstraintMatrix::close ()
                                          &check_zero_weight),
                          line->entries.end());
 
+
+
+#ifdef DEBUG
+  // In debug mode we are computing an estimate for the maximum number
+  // of constraints so that we can bail out if there is a cycle in the
+  // constraints (which is easier than searching for cycles in the graph).
+  //
+  // Let us figure out the largest dof index first
+  unsigned int largest_idx = 0;
+  for (std::vector<ConstraintLine>::iterator line = lines.begin();
+             line!=lines.end(); ++line)
+    {
+      for (ConstraintLine::Entries::iterator it = line->entries.begin();it!=line->entries.end();++it)
+        {
+          largest_idx=std::max(largest_idx, it->first);
+        }
+    }
+#endif
+
                                    // replace references to dofs that
                                    // are themselves constrained. note
                                    // that because we may replace
@@ -289,6 +308,10 @@ void ConstraintMatrix::close ()
                 &&
                 is_constrained (line->entries[entry].first))
               {
+                // if we have more than 2*the largest index entries in a constrained line,
+                // we have hit a cycle for sure.
+                Assert(line->entries.size()/2<largest_idx, ExcMessage("Cycle found in constraints!"));
+
                                                  // ok, this entry is
                                                  // further
                                                  // constrained:

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.