]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add some assertions.
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 28 Dec 2021 04:30:11 +0000 (21:30 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 28 Dec 2021 04:44:51 +0000 (21:44 -0700)
source/grid/grid_generator.cc

index 1625a626b6d66a0e25ed638dfc9d7d23a1de65ab..6ead87183d38bb74086de82366f794c4cb856472 100644 (file)
@@ -7808,6 +7808,7 @@ namespace GridGenerator
                 vertices.push_back(cell.vertex(v));
               }
 
+            AssertIndexRange(v, local_vertex_indices.size());
             local_vertex_indices[v] = old_to_new_vertex_indices[v_global];
           }
 
@@ -7824,6 +7825,8 @@ namespace GridGenerator
                   cell.face(f)->center(/*respect_manifold*/ true));
               }
 
+            AssertIndexRange(cell.n_vertices() + f,
+                             local_vertex_indices.size());
             local_vertex_indices[cell.n_vertices() + f] =
               face_to_new_vertex_indices[f_global];
           }
@@ -7831,6 +7834,8 @@ namespace GridGenerator
         // (iii) create new midpoint vertex locations for each cell
         if (dim == 2)
           {
+            AssertIndexRange(cell.n_vertices() + cell.n_faces(),
+                             local_vertex_indices.size());
             local_vertex_indices[cell.n_vertices() + cell.n_faces()] =
               vertices.size();
             vertices.push_back(cell.center(/*respect_manifold*/ true));
@@ -7862,6 +7867,8 @@ namespace GridGenerator
               CellData<dim> cell_data(index_vertices.size());
               for (unsigned int i = 0; i < index_vertices.size(); ++i)
                 {
+                  AssertIndexRange(index_vertices[i],
+                                   local_vertex_indices.size());
                   cell_data.vertices[i] =
                     local_vertex_indices[index_vertices[i]];
                   cell_data.material_id =
@@ -7879,6 +7886,8 @@ namespace GridGenerator
               boundary_line.manifold_id = manifold_id;
               for (unsigned int i = 0; i < index_vertices.size(); ++i)
                 {
+                  AssertIndexRange(index_vertices[i],
+                                   local_vertex_indices.size());
                   boundary_line.vertices[i] =
                     local_vertex_indices[index_vertices[i]];
                 }
@@ -7892,6 +7901,8 @@ namespace GridGenerator
               boundary_quad.manifold_id = manifold_id;
               for (unsigned int i = 0; i < index_vertices.size(); ++i)
                 {
+                  AssertIndexRange(index_vertices[i],
+                                   local_vertex_indices.size());
                   boundary_quad.vertices[i] =
                     local_vertex_indices[index_vertices[i]];
                 }
@@ -7904,6 +7915,8 @@ namespace GridGenerator
               boundary_line.manifold_id = manifold_id;
               for (unsigned int i = 0; i < index_vertices.size(); ++i)
                 {
+                  AssertIndexRange(index_vertices[i],
+                                   local_vertex_indices.size());
                   boundary_line.vertices[i] =
                     local_vertex_indices[index_vertices[i]];
                 }
@@ -7988,7 +8001,6 @@ namespace GridGenerator
                      vertex_ids_for_boundary_edges_3d[f])
                   add_cell(1, edge_vertices, bid, mid);
               }
-
             else
               Assert(false, ExcNotImplemented());
           }

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.