]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
GridIn::read_xda
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 Feb 2003 15:06:22 +0000 (15:06 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 21 Feb 2003 15:06:22 +0000 (15:06 +0000)
git-svn-id: https://svn.dealii.org/trunk@7208 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/include/grid/grid_in.h
deal.II/deal.II/source/grid/grid_in.cc
deal.II/doc/news/2002/c-3-4.html

index 7745df8ea65b1891830b9e9c3808273ba53fdc62..4e2efeefa62824cc94e11a1706cc42a57a0de1f4 100644 (file)
@@ -73,6 +73,11 @@ class SubCellData;
  * output since we don't know their meaning, but the data that is read
  * is enough to build up the mesh as intended by the mesh generator.
  * This format can be read by the @p{read_dbmesh} function.
+ *
+ * @item @p{XDA} format: this is a rather simple format used by the MGF
+ * code. We don't have an exact specification of the format, but the reader
+ * can read in several example files. If the reader does not grok your files,
+ * it should be fairly simple to extend it.
  * @end{itemize}
  *
  *
@@ -159,6 +164,13 @@ class GridIn
                                      */
     void read_dbmesh (std::istream &);
     
+                                    /**
+                                     * Read grid data from a file
+                                     * containing data in the XDA
+                                     * format.
+                                     */
+    void read_xda (std::istream &);
+    
                                     /**
                                      * Exception
                                      */
index 93c75bdb7e0504662858f40d0c8a8ec8138070f1..4a6485a96fb882eaa8d3eb21899167805dde808a 100644 (file)
@@ -362,6 +362,75 @@ void GridIn<dim>::read_dbmesh (std::istream &in)
 
 
 
+template <int dim>
+void GridIn<dim>::read_xda (std::istream &in)
+{
+  Assert (tria != 0, ExcNoTriangulationSelected());
+  AssertThrow (in, ExcIO());
+
+  std::string line;
+                                  // skip comments at start of file
+  getline (in, line);
+
+
+  unsigned int n_vertices;
+  unsigned int n_cells;
+
+                                  // read cells, throw away rest of line
+  in >> n_cells;
+  getline (in, line);
+
+  in >> n_vertices;
+  getline (in, line);
+
+                                  // ignore following 8 lines
+  for (unsigned int i=0; i<8; ++i)
+    getline (in, line);
+
+                                  // set up array of cells
+  std::vector<CellData<dim> > cells (n_cells);
+  SubCellData subcelldata;
+
+  for (unsigned int cell=0; cell<n_cells; ++cell) 
+    {
+                                      // note that since in the input
+                                      // file we found the number of
+                                      // cells at the top, there
+                                      // should still be input here,
+                                      // so check this:
+      AssertThrow (in, ExcIO());
+      
+      for (unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
+       in >> cells[cell].vertices[i];
+    };
+
+
+  
+                                  // set up array of vertices
+  std::vector<Point<dim> > vertices (n_vertices);
+  for (unsigned int vertex=0; vertex<n_vertices; ++vertex) 
+    {
+      double x[3];
+
+                                      // read vertex
+      in >> x[0] >> x[1] >> x[2];
+
+                                      // store vertex
+      for (unsigned int d=0; d<dim; ++d)
+       vertices[vertex](d) = x[d];
+    };
+  AssertThrow (in, ExcIO());
+
+                                  // do some clean-up on vertices...
+  delete_unused_vertices (vertices, cells, subcelldata);
+                                  // ... and cells
+  GridReordering<dim>::reorder_cells (cells);
+  tria->create_triangulation (vertices, cells, subcelldata);
+}
+
+
+
+
 template <int dim>
 void GridIn<dim>::skip_empty_lines (std::istream &in)
 {    
index c2ba3e5b04b3f933911bd863bf3d3e5dc29391c7..6bac839afa915d9ef544445a54b95fa0d568b63f 100644 (file)
@@ -739,6 +739,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>deal.II</h3>
 
 <ol>
+  <li> <p>
+       New: There is now a function <code
+       class="member">GridIn::read_xda</code> that allows reading
+       grids from a file in XDA format.
+       <br>
+       (WB 2003/02/21)
+       </p>
+
   <li> <p> 
        Changed: Some implementation details of the <code
        class="class">GridReordering</code> class have been moved to a

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.