From: wolf Date: Sat, 13 Feb 1999 10:52:00 +0000 (+0000) Subject: Add a feature (adding a line more than once is allowed; this is needed for the 3d... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f12c4deb8c30c3512c0ebff204a151938adc17fa;p=dealii-svn.git Add a feature (adding a line more than once is allowed; this is needed for the 3d case) and fix an outright wrong code snippet which was guarded by a misplaced Assert which seems was never triggered (which implicates that the assumptions in the code above were well thought of). git-svn-id: https://svn.dealii.org/trunk@797 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/dof_constraints.h b/deal.II/deal.II/include/dofs/dof_constraints.h index 92f8c59100..5d76cdf44a 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.h @@ -258,14 +258,7 @@ class ConstraintMatrix { */ void print (ostream &) const; - - /** - * Exception - */ - DeclException1 (ExcLineExists, - unsigned int, - << "The line " << arg1 - << " which is to be created already exists."); + /** * Exception */ diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index 5f89c1f075..1a7ec28737 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -25,12 +25,13 @@ ConstraintMatrix::ConstraintMatrix () : void ConstraintMatrix::add_line (const unsigned int line) { - // check whether line already exists Assert (sorted==false, ExcMatrixIsClosed()); -#ifdef DEBUG + + // check whether line already exists; + // it may, but then we need to quit for (unsigned int i=0; i!=lines.size(); ++i) - Assert (lines[i].line != line, ExcLineExists(line)); -#endif + if (lines[i].line == line) + return; // push a new line to the end of the // list @@ -46,15 +47,20 @@ void ConstraintMatrix::add_entry (const unsigned int line, Assert (sorted==false, ExcMatrixIsClosed()); vector::iterator line_ptr; - if (lines.back().line == line) - line_ptr = &lines.back(); - else - { - for (line_ptr = &lines.back()-1; line_ptr>=lines.begin(); --line_ptr) - if (line_ptr->line == line) - break; - Assert (false, ExcLineInexistant(line)); - }; + const vector::const_iterator start=lines.begin(); + // the usual case is that the line where + // a value is entered is the one we + // added last, so we search backward + for (line_ptr=&lines.back(); line_ptr!=start; --line_ptr) + if (line_ptr->line == line) + break; + + // if the loop didn't break, then + // line_ptr must be begin(). + // we have an error if that doesn't + // point to 'line' then + Assert (line_ptr->line==line, ExcLineInexistant(line)); + #ifdef DEBUG // if in debug mode, check whether an