]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve an assertion. 12565/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 12 Jul 2021 18:56:34 +0000 (12:56 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 12 Jul 2021 18:56:34 +0000 (12:56 -0600)
include/deal.II/grid/grid_in.h
source/grid/grid_in.cc

index 8eb754b84bf86da5f26b6768af71472e50f1eeb8..42d77772f36775ecb1838a89d50fa6109ea867e3 100644 (file)
@@ -822,7 +822,17 @@ public:
                  << "15 Point (1 node, ignored when read)");
 
 
-  DeclException0(ExcGmshNoCellInformation);
+  DeclException2(
+    ExcGmshNoCellInformation,
+    unsigned int,
+    unsigned int,
+    "While reading a gmsh file, the reader function did not find "
+    "any cells. This sometimes happens if the file only contains a "
+    "surface mesh, but not a volume mesh."
+    "\n\n"
+    "The reader function did find " +
+      std::to_string(arg1) + " lines and " + std::to_string(arg2) +
+      " facets (surface triangles or quadrilaterals).");
 
 protected:
   /**
index 71268f7b1e002d87a2d73d29177a57a96b7997f8..46ea8035b61d6609f95bff752d4f148af95165d0 100644 (file)
@@ -1836,7 +1836,7 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
                 else if (cell_type == 5) // hex
                   nod_num = 8;
               }
-            else
+            else // file format version 4.0 and later
               {
                 // ignore tag
                 int tag;
@@ -1876,11 +1876,11 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
                      Point (1 node).
             */
 
-            if (((cell_type == 1) && (dim == 1)) ||
-                ((cell_type == 2) && (dim == 2)) ||
-                ((cell_type == 3) && (dim == 2)) ||
-                ((cell_type == 4) && (dim == 3)) ||
-                ((cell_type == 5) && (dim == 3)))
+            if (((cell_type == 1) && (dim == 1)) || // a line in 1d
+                ((cell_type == 2) && (dim == 2)) || // a triangle in 2d
+                ((cell_type == 3) && (dim == 2)) || // a quadrilateral in 2d
+                ((cell_type == 4) && (dim == 3)) || // a tet in 3d
+                ((cell_type == 5) && (dim == 3)))   // a hex in 3d
               // found a cell
               {
                 unsigned int vertices_per_cell = 0;
@@ -1958,7 +1958,8 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
                       vertex_indices[cells.back().vertices[i]];
                   }
               }
-            else if ((cell_type == 1) && ((dim == 2) || (dim == 3)))
+            else if ((cell_type == 1) &&
+                     ((dim == 2) || (dim == 3))) // a line in 2d or 3d
               // boundary info
               {
                 subcelldata.boundary_lines.emplace_back();
@@ -1996,7 +1997,8 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
                       vertex = numbers::invalid_unsigned_int;
                     }
               }
-            else if ((cell_type == 2 || cell_type == 3) && (dim == 3))
+            else if ((cell_type == 2 || cell_type == 3) &&
+                     (dim == 3)) // a triangle or a quad in 3d
               // boundary info
               {
                 unsigned int vertices_per_cell = 0;
@@ -2080,7 +2082,7 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
       }
     AssertDimension(global_cell, n_cells);
   }
-  // Assert we reached the end of the block
+  // Assert that we reached the end of the block
   in >> line;
   static const std::string end_elements_marker[] = {"$ENDELM", "$EndElements"};
   AssertThrow(line == end_elements_marker[gmsh_file_format == 10 ? 0 : 1],
@@ -2092,7 +2094,9 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
   AssertThrow(in, ExcIO());
 
   // check that we actually read some cells.
-  AssertThrow(cells.size() > 0, ExcGmshNoCellInformation());
+  AssertThrow(cells.size() > 0,
+              ExcGmshNoCellInformation(subcelldata.boundary_lines.size(),
+                                       subcelldata.boundary_quads.size()));
 
   // TODO: the functions below (GridTools::delete_unused_vertices(),
   // GridTools::invert_all_negative_measure_cells(),

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.