include/deal.II/grid/grid_in.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: grid_in.h 25459 2012-04-27 09:18:38Z bangerth @f$
00003 //
00004 //    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__grid_in_h
00013 #define __deal2__grid_in_h
00014 
00015 
00016 #include <deal.II/base/config.h>
00017 #include <deal.II/base/exceptions.h>
00018 #include <deal.II/base/smartpointer.h>
00019 #include <deal.II/base/point.h>
00020 #include <iostream>
00021 #include <vector>
00022 #include <string>
00023 
00024 DEAL_II_NAMESPACE_OPEN
00025 
00026 template <int dim, int space_dim> class Triangulation;
00027 template <int dim> struct CellData;
00028 struct SubCellData;
00029 
00030 
00261 template <int dim, int spacedim=dim>
00262 class GridIn
00263 {
00264   public:
00273     enum Format
00274     {
00276           Default,
00278           unv,
00280           ucd,
00282           dbmesh,
00284           xda,
00286           msh,
00288           netcdf,
00290           tecplot
00291     };
00292 
00296     GridIn ();
00297 
00302     void attach_triangulation (Triangulation<dim,spacedim> &tria);
00303 
00310     void read (std::istream &in, Format format=Default);
00311 
00320     void read (const std::string &in, Format format=Default);
00321 
00333     void read_unv(std::istream &in);
00334 
00339     void read_ucd (std::istream &in);
00340 
00346     void read_dbmesh (std::istream &in);
00347 
00353     void read_xda (std::istream &in);
00354 
00371     void read_msh (std::istream &in);
00372 
00383     void read_netcdf (const std::string &filename);
00384 
00391     void read_tecplot (std::istream &in);
00392 
00397     static std::string default_suffix (const Format format);
00398 
00403     static Format parse_format (const std::string &format_name);
00404 
00412     static std::string get_format_names ();
00413 
00417     DeclException1(ExcUnknownSectionType,
00418                    int,
00419                    << "The section type <" << arg1 << "> in an UNV "
00420                    << "input file is not implemented.");
00421 
00425     DeclException1(ExcUnknownElementType,
00426                    int,
00427                    << "The element type <" << arg1 << "> in an UNV "
00428                    << "input file is not implemented.");
00429 
00433     DeclException1 (ExcUnknownIdentifier,
00434                     std::string,
00435                     << "The identifier <" << arg1 << "> as name of a "
00436                     << "part in an UCD input file is unknown or the "
00437                     << "respective input routine is not implemented."
00438                     << "(Maybe the space dimension of triangulation and "
00439                     << "input file do not match?");
00443     DeclException0 (ExcNoTriangulationSelected);
00447     DeclException2 (ExcInvalidVertexIndex,
00448                     int, int,
00449                     << "Trying to access invalid vertex index " << arg2
00450                     << " while creating cell " << arg1);
00454     DeclException0 (ExcInvalidDBMeshFormat);
00458     DeclException1 (ExcInvalidDBMESHInput,
00459                     std::string,
00460                     << "The string <" << arg1 << "> is not recognized at the present"
00461                     << " position of a DB Mesh file.");
00462 
00466     DeclException1 (ExcDBMESHWrongDimension,
00467                     int,
00468                     << "The specified dimension " << arg1
00469                     << " is not the same as that of the triangulation to be created.");
00470 
00471     DeclException1 (ExcInvalidGMSHInput,
00472                     std::string,
00473                     << "The string <" << arg1 << "> is not recognized at the present"
00474                     << " position of a Gmsh Mesh file.");
00475 
00476     DeclException1 (ExcGmshUnsupportedGeometry,
00477                     int,
00478                     << "The Element Identifier <" << arg1 << "> is not "
00479                     << "supported in the Deal.II Library.\n"
00480                     << "Supported elements are: \n"
00481                     << "ELM-TYPE\n"
00482                     << "1 Line (2 nodes, 1 edge).\n"
00483                     << "3 Quadrilateral (4 nodes, 4 edges).\n"
00484                     << "5 Hexahedron (8 nodes, 12 edges, 6 faces).\n"
00485                     << "15 Point (1 node, ignored when read)");
00486 
00487 
00488     DeclException0 (ExcGmshNoCellInformation);
00489   protected:
00494     SmartPointer<Triangulation<dim,spacedim>,GridIn<dim,spacedim> > tria;
00495 
00541     static void debug_output_grid (const std::vector<CellData<dim> > &cells,
00542                                    const std::vector<Point<spacedim> > &vertices,
00543                                    std::ostream &out);
00544 
00545   private:
00546 
00553     static void skip_empty_lines (std::istream &in);
00554 
00569     static void skip_comment_lines (std::istream    &in,
00570                                     const char  comment_start);
00571 
00582     static void parse_tecplot_header(std::string   &header,
00583                                      std::vector<unsigned int> &tecplot2deal,
00584                                      unsigned int  &n_vars,
00585                                      unsigned int  &n_vertices,
00586                                      unsigned int  &n_cells,
00587                                      std::vector<unsigned int> &IJK,
00588                                      bool          &structured,
00589                                      bool          &blocked);
00590 
00595     Format default_format;
00596 };
00597 
00598 
00599 
00600 /* -------------- declaration of explicit specializations ------------- */
00601 
00602 #ifndef DOXYGEN
00603 
00604 template <>
00605 void
00606 GridIn<2>::debug_output_grid (const std::vector<CellData<2> > &cells,
00607                               const std::vector<Point<2> >    &vertices,
00608                               std::ostream                    &out);
00609 
00610 
00611 template <>
00612 void
00613 GridIn<2,3>::debug_output_grid (const std::vector<CellData<2> > &cells,
00614                               const std::vector<Point<3> >    &vertices,
00615                               std::ostream                    &out);
00616 template <>
00617 void
00618 GridIn<3>::debug_output_grid (const std::vector<CellData<3> > &cells,
00619                               const std::vector<Point<3> >    &vertices,
00620                               std::ostream                    &out);
00621 
00622 #endif // DOXYGEN
00623 
00624 DEAL_II_NAMESPACE_CLOSE
00625 
00626 #endif
00627 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Tue May 22 2012 12:06:09 by doxygen 1.7.3