Reference documentation for deal.II version 8.4.2
grid_in.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__grid_in_h
17 #define dealii__grid_in_h
18 
19 
20 #include <deal.II/base/config.h>
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/smartpointer.h>
23 #include <deal.II/base/point.h>
24 #include <iostream>
25 #include <vector>
26 #include <string>
27 
28 DEAL_II_NAMESPACE_OPEN
29 
30 template <int dim, int space_dim> class Triangulation;
31 template <int dim> struct CellData;
32 struct SubCellData;
33 
34 
295 template <int dim, int spacedim=dim>
296 class GridIn
297 {
298 public:
303  enum Format
304  {
325  };
326 
330  GridIn ();
331 
336 
341  void read (std::istream &in, Format format=Default);
342 
348  void read (const std::string &in, Format format=Default);
349 
355  void read_vtk(std::istream &in);
356 
364  void read_unv(std::istream &in);
365 
369  void read_ucd (std::istream &in);
370 
407  void read_abaqus (std::istream &in);
408 
412  void read_dbmesh (std::istream &in);
413 
417  void read_xda (std::istream &in);
418 
428  void read_msh (std::istream &in);
429 
436  void read_netcdf (const std::string &filename);
437 
442  void read_tecplot (std::istream &in);
443 
447  static std::string default_suffix (const Format format);
448 
452  static Format parse_format (const std::string &format_name);
453 
459  static std::string get_format_names ();
460 
464  DeclException1(ExcUnknownSectionType,
465  int,
466  << "The section type <" << arg1 << "> in an UNV "
467  << "input file is not implemented.");
468 
472  DeclException1(ExcUnknownElementType,
473  int,
474  << "The element type <" << arg1 << "> in an UNV "
475  << "input file is not implemented.");
476 
480  DeclException1 (ExcUnknownIdentifier,
481  std::string,
482  << "The identifier <" << arg1 << "> as name of a "
483  << "part in an UCD input file is unknown or the "
484  << "respective input routine is not implemented."
485  << "(Maybe the space dimension of triangulation and "
486  << "input file do not match?");
490  DeclException0 (ExcNoTriangulationSelected);
494  DeclException2 (ExcInvalidVertexIndex,
495  int, int,
496  << "While creating cell " << arg1
497  << ", you are referencing a vertex with index " << arg2
498  << " but no vertex with this index has been described in the input file.");
502  DeclException0 (ExcInvalidDBMeshFormat);
506  DeclException1 (ExcInvalidDBMESHInput,
507  std::string,
508  << "The string <" << arg1 << "> is not recognized at the present"
509  << " position of a DB Mesh file.");
510 
514  DeclException1 (ExcDBMESHWrongDimension,
515  int,
516  << "The specified dimension " << arg1
517  << " is not the same as that of the triangulation to be created.");
518 
519  DeclException1 (ExcInvalidGMSHInput,
520  std::string,
521  << "The string <" << arg1 << "> is not recognized at the present"
522  << " position of a Gmsh Mesh file.");
523 
524  DeclException1 (ExcGmshUnsupportedGeometry,
525  int,
526  << "The Element Identifier <" << arg1 << "> is not "
527  << "supported in the deal.II library when "
528  << "reading meshes in " << dim << " dimensions.\n"
529  << "Supported elements are: \n"
530  << "ELM-TYPE\n"
531  << "1 Line (2 nodes, 1 edge).\n"
532  << "3 Quadrilateral (4 nodes, 4 edges).\n"
533  << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
534  << "15 Point (1 node, ignored when read)");
535 
536 
537  DeclException0 (ExcGmshNoCellInformation);
538 protected:
543 
564  static void debug_output_grid (const std::vector<CellData<dim> > &cells,
565  const std::vector<Point<spacedim> > &vertices,
566  std::ostream &out);
567 
568 private:
569 
574  static void skip_empty_lines (std::istream &in);
575 
583  static void skip_comment_lines (std::istream &in,
584  const char comment_start);
585 
593  static void parse_tecplot_header(std::string &header,
594  std::vector<unsigned int> &tecplot2deal,
595  unsigned int &n_vars,
596  unsigned int &n_vertices,
597  unsigned int &n_cells,
598  std::vector<unsigned int> &IJK,
599  bool &structured,
600  bool &blocked);
601 
606 };
607 
608 /* -------------- declaration of explicit specializations ------------- */
609 
610 #ifndef DOXYGEN
611 
612 template <>
613 void
614 GridIn<2>::debug_output_grid (const std::vector<CellData<2> > &cells,
615  const std::vector<Point<2> > &vertices,
616  std::ostream &out);
617 
618 
619 template <>
620 void
621 GridIn<2,3>::debug_output_grid (const std::vector<CellData<2> > &cells,
622  const std::vector<Point<3> > &vertices,
623  std::ostream &out);
624 template <>
625 void
626 GridIn<3>::debug_output_grid (const std::vector<CellData<3> > &cells,
627  const std::vector<Point<3> > &vertices,
628  std::ostream &out);
629 
630 #endif // DOXYGEN
631 
632 DEAL_II_NAMESPACE_CLOSE
633 
634 #endif
static std::string get_format_names()
Definition: grid_in.cc:2893
Use read_abaqus()
Definition: grid_in.h:312
Format
Definition: grid_in.h:303
Use read_vtk()
Definition: grid_in.h:324
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition: grid_in.h:542
Use read_unv()
Definition: grid_in.h:308
Use read_xda()
Definition: grid_in.h:316
DeclException2(ExcInvalidVertexIndex, int, int,<< "While creating cell "<< arg1<< ", you are referencing a vertex with index "<< arg2<< " but no vertex with this index has been described in the input file.")
static Format parse_format(const std::string &format_name)
Definition: grid_in.cc:2837
static void skip_empty_lines(std::istream &in)
Definition: grid_in.cc:2510
void read_vtk(std::istream &in)
Definition: grid_in.cc:98
DeclException0(ExcNoTriangulationSelected)
Use read_ucd()
Definition: grid_in.h:310
void read_dbmesh(std::istream &in)
Definition: grid_in.cc:870
void read_tecplot(std::istream &in)
Definition: grid_in.cc:2503
static void parse_tecplot_header(std::string &header, std::vector< unsigned int > &tecplot2deal, unsigned int &n_vars, unsigned int &n_vertices, unsigned int &n_cells, std::vector< unsigned int > &IJK, bool &structured, bool &blocked)
Definition: grid_in.cc:2071
DeclException1(ExcUnknownSectionType, int,<< "The section type <"<< arg1<< "> in an UNV "<< "input file is not implemented.")
Use read_msh()
Definition: grid_in.h:318
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition: grid_in.cc:2539
void read_ucd(std::istream &in)
Definition: grid_in.cc:613
GridIn()
Definition: grid_in.cc:84
void read_abaqus(std::istream &in)
Definition: grid_in.cc:838
Use read_tecplot()
Definition: grid_in.h:322
void read_xda(std::istream &in)
Definition: grid_in.cc:1036
void read_msh(std::istream &in)
Definition: grid_in.cc:1194
Use read_dbmesh()
Definition: grid_in.h:314
void read_netcdf(const std::string &filename)
static std::string default_suffix(const Format format)
Definition: grid_in.cc:2805
void read_unv(std::istream &in)
Definition: grid_in.cc:384
void read(std::istream &in, Format format=Default)
Definition: grid_in.cc:2749
Use GridIn::default_format stored in this object.
Definition: grid_in.h:306
static void debug_output_grid(const std::vector< CellData< dim > > &cells, const std::vector< Point< spacedim > > &vertices, std::ostream &out)
Definition: grid_in.cc:2563
void attach_triangulation(Triangulation< dim, spacedim > &tria)
Definition: grid_in.cc:90
Use read_netcdf()
Definition: grid_in.h:320
Format default_format
Definition: grid_in.h:605