From: heister Date: Wed, 29 Aug 2012 18:55:32 +0000 (+0000) Subject: limit the number of entries in a ConstraintMatrix generated while close()ing to detec... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=322fa7d250b824110287b8f150c55f34764200e9;p=dealii-svn.git limit the number of entries in a ConstraintMatrix generated while close()ing to detect complicated cycles. git-svn-id: https://svn.dealii.org/trunk@26156 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 51befc6145..216cdc8b87 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -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::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