]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix an off-by-one bug in a number of places.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 2 May 2006 22:41:06 +0000 (22:41 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 2 May 2006 22:41:06 +0000 (22:41 +0000)
git-svn-id: https://svn.dealii.org/trunk@12989 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/dofs/hp_dof_handler.h
deal.II/deal.II/source/dofs/hp_dof_levels.cc
tests/hp/crash_05/cmp/generic [new file with mode: 0644]

index 4976f2d3570c0b90672b25d3223c972859639300..5a87c038944340dae21603074d04ffa12abf37ca 100644 (file)
@@ -1364,7 +1364,7 @@ namespace hp
        if (this_fe_index == fe_index)
          return *(pointer + 1 + local_index);
        else
-         pointer += (*finite_elements)[this_fe_index].dofs_per_vertex;
+         pointer += (*finite_elements)[this_fe_index].dofs_per_vertex + 1;
       }
   }  
 
@@ -1388,6 +1388,8 @@ namespace hp
     Assert (local_index < (*finite_elements)[fe_index].dofs_per_vertex,
            ExcIndexRange(local_index, 0,
                          (*finite_elements)[fe_index].dofs_per_vertex));
+    Assert (fe_index < finite_elements->size(),
+           ExcInternalError());
 
                                     // hop along the list of index
                                     // sets until we find the one
@@ -1400,15 +1402,22 @@ namespace hp
     unsigned int *pointer              = &vertex_dofs[starting_offset];
     while (true)
       {
-       Assert (*pointer != deal_II_numbers::invalid_unsigned_int,
+       Assert (pointer <= &vertex_dofs.back(), ExcInternalError());
+
+       const unsigned int this_fe_index = *pointer;
+       
+       Assert (this_fe_index != deal_II_numbers::invalid_unsigned_int,
                ExcInternalError());
-       if (*pointer == fe_index)
+       Assert (this_fe_index < finite_elements->size(),
+               ExcInternalError());
+
+       if (this_fe_index == fe_index)
          {
            *(pointer + 1 + local_index) = global_index;
            return;
          }
        else
-         pointer += (*finite_elements)[*pointer].dofs_per_vertex;
+         pointer += (*finite_elements)[this_fe_index].dofs_per_vertex + 1;
       }
   }  
   
index f1df5b11050ec6ed99405914d4d07662e30b861a..9c3db4143e6a34ed7b1edc94e4293e4354ca5763 100644 (file)
@@ -79,7 +79,7 @@ namespace internal
               if (*pointer == fe_index)
                 return *(pointer + 1 + local_index);
               else
-                pointer += dof_handler.get_fe()[*pointer].dofs_per_line;
+                pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1;
             }
         }
     }
@@ -147,7 +147,7 @@ namespace internal
                   return;
                 }
               else
-                pointer += dof_handler.get_fe()[*pointer].dofs_per_line;
+                pointer += dof_handler.get_fe()[*pointer].dofs_per_line + 1;
             }
         }  
     }
@@ -212,7 +212,7 @@ namespace internal
               if (*pointer == fe_index)
                 return *(pointer + 1 + local_index);
               else
-                pointer += dof_handler.get_fe()[*pointer].dofs_per_quad;
+                pointer += dof_handler.get_fe()[*pointer].dofs_per_quad + 1;
             }
         }
     }
@@ -281,7 +281,7 @@ namespace internal
                   return;
                 }
               else
-                pointer += dof_handler.get_fe()[*pointer].dofs_per_quad;
+                pointer += dof_handler.get_fe()[*pointer].dofs_per_quad + 1;
             }
         }  
     }
@@ -346,7 +346,7 @@ namespace internal
               if (*pointer == fe_index)
                 return *(pointer + 1 + local_index);
               else
-                pointer += dof_handler.get_fe()[*pointer].dofs_per_hex;
+                pointer += dof_handler.get_fe()[*pointer].dofs_per_hex + 1;
             }
         }
     }
@@ -415,7 +415,7 @@ namespace internal
                   return;
                 }
               else
-                pointer += dof_handler.get_fe()[*pointer].dofs_per_hex;
+                pointer += dof_handler.get_fe()[*pointer].dofs_per_hex + 1;
             }
         }  
     }
diff --git a/tests/hp/crash_05/cmp/generic b/tests/hp/crash_05/cmp/generic
new file mode 100644 (file)
index 0000000..f8b7620
--- /dev/null
@@ -0,0 +1,44 @@
+
+DEAL::Setting fe_index=0 on cell 1.0
+DEAL::Setting fe_index=1 on cell 1.1
+DEAL::1.0
+DEAL::0 1 
+DEAL::1.1
+DEAL::2 3 
+DEAL::Setting fe_index=0 on cell 1.0
+DEAL::Setting fe_index=1 on cell 1.1
+DEAL::Setting fe_index=2 on cell 1.2
+DEAL::Setting fe_index=3 on cell 1.3
+DEAL::1.0
+DEAL::0 1 2 3 
+DEAL::1.1
+DEAL::4 5 6 7 
+DEAL::1.2
+DEAL::8 9 10 11 
+DEAL::1.3
+DEAL::12 13 14 15 
+DEAL::Setting fe_index=0 on cell 1.0
+DEAL::Setting fe_index=1 on cell 1.1
+DEAL::Setting fe_index=2 on cell 1.2
+DEAL::Setting fe_index=3 on cell 1.3
+DEAL::Setting fe_index=4 on cell 1.4
+DEAL::Setting fe_index=5 on cell 1.5
+DEAL::Setting fe_index=6 on cell 1.6
+DEAL::Setting fe_index=7 on cell 1.7
+DEAL::1.0
+DEAL::0 1 2 3 4 5 6 7 
+DEAL::1.1
+DEAL::8 9 10 11 12 13 14 15 
+DEAL::1.2
+DEAL::16 17 18 19 20 21 22 23 
+DEAL::1.3
+DEAL::24 25 26 27 28 29 30 31 
+DEAL::1.4
+DEAL::32 33 34 35 36 37 38 39 
+DEAL::1.5
+DEAL::40 41 42 43 44 45 46 47 
+DEAL::1.6
+DEAL::48 49 50 51 52 53 54 55 
+DEAL::1.7
+DEAL::56 57 58 59 60 61 62 63 
+DEAL::OK

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.