]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix an error I oversaw beforehand.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 2 Apr 1998 11:13:07 +0000 (11:13 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 2 Apr 1998 11:13:07 +0000 (11:13 +0000)
git-svn-id: https://svn.dealii.org/trunk@115 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/dofs/dof_constraints.cc
deal.II/deal.II/source/dofs/dof_handler.cc

index ba2d1eaf33cf501799745e5a997ec63b765591a1..3beb0fa4790fb7c5e563c2383259eea841a8a6ac 100644 (file)
@@ -91,6 +91,7 @@ void ConstraintMatrix::condense (const dSMatrixStruct &uncondensed,
   Assert (uncondensed.n_rows() == uncondensed.n_cols(),
          ExcMatrixNotSquare());
 
+  
                                   // store for each line of the matrix
                                   // its new line number
                                   // after compression. If the shift is
@@ -102,20 +103,40 @@ void ConstraintMatrix::condense (const dSMatrixStruct &uncondensed,
   vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
   unsigned int                           shift           = 0;
   unsigned int n_rows = (unsigned int)uncondensed.n_rows();
-  for (unsigned int row=0; row!=n_rows; ++row)
-    if (row == (*next_constraint).line)
-      {
-                                        // this line is constrained
-       new_line.push_back (-1);
-                                        // note that #lines# is ordered
-       ++next_constraint;
-       ++shift;
-      }
-    else
-      new_line.push_back (row-shift);
+
+  if (next_constraint == lines.end()) 
+                                    // if no constraint is to be handled
+    for (unsigned int row=0; row!=n_rows; ++row)
+      new_line.push_back (row);
+  else
+    for (unsigned int row=0; row!=n_rows; ++row) 
+      if (row == (*next_constraint).line)
+       {
+                                          // this line is constrained
+         new_line.push_back (-1);
+                                          // note that #lines# is ordered        
+         ++shift;
+         ++next_constraint;
+         if (next_constraint == lines.end())
+                                            // nothing more to do; finish rest
+                                            // of loop
+           {
+             for (unsigned int i=row+1; i<n_rows; ++i)
+               new_line.push_back (i-shift);
+             break;
+           };
+       }
+      else
+       new_line.push_back (row-shift);
 
  
   next_constraint = lines.begin();
+                                  // note: in this loop we need not check
+                                  // whether #next_constraint# is a valid
+                                  // iterator, since #next_constraint# is
+                                  // only evaluated so often as there are
+                                  // entries in new_line[*] which tells us
+                                  // which constraints exist
   for (int row=0; row<uncondensed.n_rows(); ++row)
     if (new_line[row] != -1)
                                       // line not constrained
@@ -279,20 +300,40 @@ void ConstraintMatrix::condense (const dSMatrix &uncondensed,
   vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
   unsigned int                           shift           = 0;
   unsigned int n_rows = (unsigned int)uncondensed_struct.n_rows();
-  for (unsigned int row=0; row!=n_rows; ++row)
-    if (row == (*next_constraint).line)
-      {
-                                        // this line is constrained
-       new_line.push_back (-1);
-                                        // note that #lines# is ordered
-       ++next_constraint;
-       ++shift;
-      }
-    else
-      new_line.push_back (row-shift);
+
+  if (next_constraint == lines.end()) 
+                                    // if no constraint is to be handled
+    for (unsigned int row=0; row!=n_rows; ++row)
+      new_line.push_back (row);
+  else
+    for (unsigned int row=0; row!=n_rows; ++row)
+      if (row == (*next_constraint).line)
+       {
+                                          // this line is constrained
+         new_line.push_back (-1);
+                                          // note that #lines# is ordered
+         ++shift;
+         ++next_constraint;
+         if (next_constraint == lines.end())
+                                            // nothing more to do; finish rest
+                                            // of loop
+           {
+             for (unsigned int i=row+1; i<n_rows; ++i)
+               new_line.push_back (i-shift);
+             break;
+           };
+       }
+      else
+       new_line.push_back (row-shift);
 
  
   next_constraint = lines.begin();
+                                  // note: in this loop we need not check
+                                  // whether #next_constraint# is a valid
+                                  // iterator, since #next_constraint# is
+                                  // only evaluated so often as there are
+                                  // entries in new_line[*] which tells us
+                                  // which constraints exist
   for (int row=0; row<uncondensed_struct.n_rows(); ++row)
     if (new_line[row] != -1)
                                       // line not constrained
@@ -487,20 +528,40 @@ void ConstraintMatrix::condense (const dVector &uncondensed,
   vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
   unsigned int                           shift           = 0;
   unsigned int n_rows = (unsigned int)uncondensed.n();
-  for (unsigned int row=0; row!=n_rows; ++row)
-    if (row == (*next_constraint).line)
-      {
-                                        // this line is constrained
-       new_line.push_back (-1);
-                                        // note that #lines# is ordered
-       ++next_constraint;
-       ++shift;
-      }
-    else
-      new_line.push_back (row-shift);
+
+  if (next_constraint == lines.end()) 
+                                    // if no constraint is to be handled
+    for (unsigned int row=0; row!=n_rows; ++row)
+      new_line.push_back (row);
+  else
+    for (unsigned int row=0; row!=n_rows; ++row)
+      if (row == (*next_constraint).line)
+       {
+                                          // this line is constrained
+         new_line.push_back (-1);
+                                          // note that #lines# is ordered
+         ++shift;
+         ++next_constraint;
+         if (next_constraint == lines.end())
+                                            // nothing more to do; finish rest
+                                            // of loop
+           {
+             for (unsigned int i=row+1; i<n_rows; ++i)
+               new_line.push_back (i-shift);
+             break;
+           };
+       }
+      else
+       new_line.push_back (row-shift);
 
  
   next_constraint = lines.begin();
+                                  // note: in this loop we need not check
+                                  // whether #next_constraint# is a valid
+                                  // iterator, since #next_constraint# is
+                                  // only evaluated so often as there are
+                                  // entries in new_line[*] which tells us
+                                  // which constraints exist
   for (int row=0; row<uncondensed.n(); ++row)
     if (new_line[row] != -1)
                                       // line not constrained
@@ -523,6 +584,10 @@ void ConstraintMatrix::condense (const dVector &uncondensed,
 
 void ConstraintMatrix::condense (dVector &vec) const {
   Assert (sorted == true, ExcMatrixNotClosed());
+
+  if (lines.size() == 0)
+                                    // nothing to do
+    return;
   
   vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
   for (unsigned int row=0; row<(unsigned int)vec.n(); ++row)
@@ -537,6 +602,9 @@ void ConstraintMatrix::condense (dVector &vec) const {
        vec(row) = 0.;
        
        ++next_constraint;
+       if (next_constraint == lines.end())
+                                          // nothing more to do
+         break;
       };
 };
   
@@ -548,7 +616,7 @@ void ConstraintMatrix::distribute (const dVector &condensed,
   Assert (sorted == true, ExcMatrixNotClosed());
   Assert ((unsigned int)condensed.n()+n_constraints() == (unsigned int)uncondensed.n(),
          ExcWrongDimension());
-  
+
                                   // store for each line of the new vector
                                   // its old line number before
                                   // distribution. If the shift is
@@ -560,20 +628,40 @@ void ConstraintMatrix::distribute (const dVector &condensed,
   vector<ConstraintLine>::const_iterator next_constraint = lines.begin();
   unsigned int                           shift           = 0;
   unsigned int n_rows = (unsigned int)uncondensed.n();
-  for (unsigned int row=0; row!=n_rows; ++row)
-    if (row == (*next_constraint).line)
-      {
-                                        // this line is constrained
-       old_line.push_back (-1);
-                                        // note that #lines# is ordered
-       ++next_constraint;
-       ++shift;
-      }
-    else
-      old_line.push_back (row-shift);
+
+  if (next_constraint == lines.end()) 
+                                    // if no constraint is to be handled
+    for (unsigned int row=0; row!=n_rows; ++row)
+      old_line.push_back (row);
+  else
+    for (unsigned int row=0; row!=n_rows; ++row)
+      if (row == (*next_constraint).line)
+       {
+                                          // this line is constrained
+         old_line.push_back (-1);
+                                          // note that #lines# is ordered
+         ++shift;
+         ++next_constraint;
+         if (next_constraint == lines.end())
+                                            // nothing more to do; finish rest
+                                            // of loop
+           {
+             for (unsigned int i=row+1; i<n_rows; ++i)
+               old_line.push_back (i-shift);
+             break;
+           };
+       }
+      else
+       old_line.push_back (row-shift);
 
  
   next_constraint = lines.begin();
+                                  // note: in this loop we need not check
+                                  // whether #next_constraint# is a valid
+                                  // iterator, since #next_constraint# is
+                                  // only evaluated so often as there are
+                                  // entries in new_line[*] which tells us
+                                  // which constraints exist
   for (unsigned int line=0; line<(unsigned int)uncondensed.n(); ++line) 
     if (old_line[line] != -1)
                                       // line was not condensed away
index 53002bf983829af1a8a3a62cee31b32a49f555d5..081fb2d02afff4c005e3bdad54411df83bd5d000 100644 (file)
@@ -1391,39 +1391,44 @@ unsigned int DoFHandler<2>::max_couplings_between_dofs () const {
                                   // get these numbers by drawing pictures
                                   // and counting...
                                   // example:
-                                  // x-----x--x--o
-                                  // |     |  |  |
-                                  // |     x--x--x
-                                  // |     |  |  |
-                                  // x--x--*--x--x
-                                  // |  |  |     |
-                                  // x--x--x     |
-                                  // |  |  |     |
-                                  // o--x--x-----x
+                                  //   |     |     |
+                                  // --x-----x--x--X--
+                                  //   |     |  |  |
+                                  //   |     x--x--x
+                                  //   |     |  |  |
+                                  // --x--x--*--x--x--
+                                  //   |  |  |     |
+                                  //   x--x--x     |
+                                  //   |  |  |     |
+                                  // --X--x--x-----x--
+                                  //   |     |     |
                                   // x = vertices connected with center vertex *;
-                                  //   = total of 17
+                                  //   = total of 19
+                                  // (the X vertices are connected with * if
+                                  // the vertices adjacent to X are hanging
+                                  // nodes)
                                   // count lines -> 28 (don't forget to count
                                   // mother and children separately!)
   switch (tria->max_adjacent_cells())
     {
       case 4:
-           return (17*selected_fe->dofs_per_vertex +
+           return (19*selected_fe->dofs_per_vertex +
                    28*selected_fe->dofs_per_line +
                    8*selected_fe->dofs_per_quad);
       case 5:
-           return (19*selected_fe->dofs_per_vertex +
+           return (21*selected_fe->dofs_per_vertex +
                    31*selected_fe->dofs_per_line +
                    9*selected_fe->dofs_per_quad);
       case 6:
-           return (25*selected_fe->dofs_per_vertex +
+           return (28*selected_fe->dofs_per_vertex +
                    42*selected_fe->dofs_per_line +
                    12*selected_fe->dofs_per_quad);
       case 7:
-           return (27*selected_fe->dofs_per_vertex +
+           return (30*selected_fe->dofs_per_vertex +
                    45*selected_fe->dofs_per_line +
                    13*selected_fe->dofs_per_quad);
       case 8:
-           return (33*selected_fe->dofs_per_vertex +
+           return (37*selected_fe->dofs_per_vertex +
                    56*selected_fe->dofs_per_line +
                    16*selected_fe->dofs_per_quad);
       default:

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.