]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a feature (adding a line more than once is allowed; this is needed for the 3d...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 13 Feb 1999 10:52:00 +0000 (10:52 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 13 Feb 1999 10:52:00 +0000 (10:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@797 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/dof_constraints.h
deal.II/deal.II/source/dofs/dof_constraints.cc

index 92f8c5910025258d520d67e47f647149a41b8032..5d76cdf44a202db96f53b5cfd607a0dd0697f959 100644 (file)
@@ -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
                                      */
index 5f89c1f075bd4c05a5c7348cc36cc1de6510ab52..1a7ec28737dd52c20bc09ae81d257c926f746a53 100644 (file)
@@ -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<ConstraintLine>::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<ConstraintLine>::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

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.