]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Previous version of GridIn::read_msh() could not handle files produced on a different...
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 May 2008 19:07:23 +0000 (19:07 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 12 May 2008 19:07:23 +0000 (19:07 +0000)
GridIn::read_msh() now does not complain about types 15 (points) anymore. They are simply ignored

git-svn-id: https://svn.dealii.org/trunk@16078 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_in.h
deal.II/deal.II/source/grid/grid_in.cc

index fbd616001b094b48fb4e42930f833b1f5ecf392b..b8af5d563f3236ecf670c03abc65d24a509fdb32 100644 (file)
@@ -278,7 +278,41 @@ class GridIn
     void read_xda (std::istream &in);
     
                                     /**
-                                     * Read grid data from an msh file.
+                                     * Read grid data from an msh
+                                     * file.
+                                     *
+                                     * The text file read consists of
+                                     * two blocks. The first lists
+                                     * the positions of the mesh
+                                     * nodes and has the format
+                                     *
+                                     * @pre
+                                     * $NOD
+                                     * <n>
+                                     * 1 <x1> <y1> <z1>
+                                     * 2 <x2> <y2> <z2>
+                                     * ...
+                                     * n <xn> <yn> <zn>
+                                     * $ENDNOD
+                                     *
+                                     * The second block lists the
+                                     * connectivity and material id's
+                                     * of the cells and faces. It is
+                                     * enclosed by <tt>$ELM</tt> and
+                                     * <tt>$ENDELM</tt>
+                                     * keywords. deal.II can handle
+                                     * elements which are lines,
+                                     * quadrilaterals or hexahedra
+                                     * only. For convenience, element
+                                     * type 15 (points) are ignored.
+                                     *
+                                     * @note The input function of
+                                     * deal.II does not distinguish
+                                     * between newline and other
+                                     * whitespace. Therefore, deal.II
+                                     * will be able to read files in
+                                     * a slightly more general format
+                                     * than Gmsh.
                                      */
     void read_msh (std::istream &in);
     
@@ -377,7 +411,8 @@ class GridIn
                    << "ELM-TYPE\n"
                    << "1 Line (2 nodes, 1 edge).\n"
                    << "3 Quadrilateral (4 nodes, 4 edges).\n"
-                   << "5 Hexahedron (8 nodes, 12 edges, 6 faces).");
+                   << "5 Hexahedron (8 nodes, 12 edges, 6 faces)."
+                   << "15 Point (1 node, ignored when read)");
   protected:
                                     /**
                                      * Store address of the triangulation to
index 5a43966ab3144ad46ce8e1c03db630e788f5f7f0..885d597f1cd809fa37de5eca7e6cd8cc582869e1 100644 (file)
@@ -556,7 +556,7 @@ void GridIn<dim>::read_msh (std::istream &in)
   unsigned int dummy;
   std::string line;
   
-  getline(in, line);
+  in >> line;
 
   AssertThrow (line=="$NOD",
               ExcInvalidGMSHInput(line));
@@ -583,18 +583,15 @@ void GridIn<dim>::read_msh (std::istream &in)
                                       // store mapping;
       vertex_indices[vertex_number] = vertex;
     };
-  
-                                  // This is needed to flush the last
-                                  // new line
-  getline (in, line);
-  
-                                  // Now read in next bit
-  getline (in, line);
+
+                                  // Assert we reached the end of the block
+  in >> line;
   AssertThrow (line=="$ENDNOD",
               ExcInvalidGMSHInput(line));
 
   
-  getline (in, line);
+                                  // Now read in next bit
+  in >> line;
   AssertThrow (line=="$ELM",
               ExcInvalidGMSHInput(line));
 
@@ -729,10 +726,19 @@ void GridIn<dim>::read_msh (std::istream &in)
              
            }
          else
-                                            // cannot read this
-           AssertThrow (false, ExcGmshUnsupportedGeometry(cell_type));
+           if (cell_type == 15)
+             {
+                                                // Ignore vertices
+             }
+           else
+                                              // cannot read this
+             AssertThrow (false, ExcGmshUnsupportedGeometry(cell_type));
     };
 
+                                  // Assert we reached the end of the block
+  in >> line;
+  AssertThrow (line=="$ENDELM",
+              ExcInvalidGMSHInput(line));
   
                                   // check that no forbidden arrays are used
   Assert (subcelldata.check_consistency(dim), ExcInternalError());

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.