From: Luca Heltai Date: Tue, 28 Jul 2009 14:48:25 +0000 (+0000) Subject: Added assertion in reading msh file to check that a number of cells != 0 is actually... X-Git-Tag: v8.0.0~7439 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d431d219ef65d35390e3cb08bdaec6142c3277ad;p=dealii.git Added assertion in reading msh file to check that a number of cells != 0 is actually read. git-svn-id: https://svn.dealii.org/trunk@19126 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/grid_in.h b/deal.II/deal.II/include/grid/grid_in.h index 544a79e972..729ab09361 100644 --- a/deal.II/deal.II/include/grid/grid_in.h +++ b/deal.II/deal.II/include/grid/grid_in.h @@ -433,6 +433,9 @@ class GridIn << "3 Quadrilateral (4 nodes, 4 edges).\n" << "5 Hexahedron (8 nodes, 12 edges, 6 faces).\n" << "15 Point (1 node, ignored when read)"); + + + DeclException0 (ExcGmshNoCellInformation); protected: /** * Store address of the triangulation to diff --git a/deal.II/deal.II/source/grid/grid_in.cc b/deal.II/deal.II/source/grid/grid_in.cc index ce76598a96..d976f337ec 100644 --- a/deal.II/deal.II/source/grid/grid_in.cc +++ b/deal.II/deal.II/source/grid/grid_in.cc @@ -583,7 +583,8 @@ void GridIn::read_msh (std::istream &in) in >> version >> file_type >> data_size; - Assert (version == 2.0, ExcNotImplemented()); + Assert ( (version >= 2.0) && + (version <= 2.1), ExcNotImplemented()); Assert (file_type == 0, ExcNotImplemented()); Assert (data_size == sizeof(double), ExcNotImplemented()); @@ -637,6 +638,7 @@ void GridIn::read_msh (std::istream &in) ExcInvalidGMSHInput(line)); in >> n_cells; + // set up array of cells std::vector > cells; SubCellData subcelldata; @@ -842,7 +844,12 @@ void GridIn::read_msh (std::istream &in) AssertThrow (in, ExcIO()); - // do some clean-up on vertices... + // check that we actually read some + // cells. + AssertThrow(cells.size() > 0, ExcGmshNoCellInformation()); + + // do some clean-up on + // vertices... GridTools::delete_unused_vertices (vertices, cells, subcelldata); // ... and cells if(dim==spacedim)