From: heister Date: Wed, 29 Aug 2012 20:14:13 +0000 (+0000) Subject: improve cycle detection X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3bce45172e036b217616b2f81b3c242035cb45a8;p=dealii-svn.git improve cycle detection git-svn-id: https://svn.dealii.org/trunk@26164 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/source/lac/constraint_matrix.cc b/deal.II/source/lac/constraint_matrix.cc index 216cdc8b87..dd99a2e504 100644 --- a/deal.II/source/lac/constraint_matrix.cc +++ b/deal.II/source/lac/constraint_matrix.cc @@ -245,7 +245,9 @@ void ConstraintMatrix::close () // 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 + // Let us figure out the largest dof index. This is an upper bound for the + // number of constraints because it is an approximation for the number of dofs + // in our system. unsigned int largest_idx = 0; for (std::vector::iterator line = lines.begin(); line!=lines.end(); ++line) @@ -290,6 +292,14 @@ void ConstraintMatrix::close () for (std::vector::iterator line = lines.begin(); line!=lines.end(); ++line) { +#ifdef DEBUG + // we need to keep track of how many replacements we do in this line, because we can + // end up in a cycle A->B->C->A without the number of entries growing. + unsigned int n_replacements = 0; +#endif + + + // loop over all entries of // this line (including // ones that we have @@ -308,10 +318,6 @@ 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()/2entries[i].first, constrained_line->entries[i].second * weight)); + +#ifdef DEBUG + // keep track of how many entries we replace in this line. If we do more than + // there are constraints or dofs in our system, we must have a cycle. + ++n_replacements; + Assert(n_replacements/2