Reference documentation for deal.II version 9.0.0
grid_in.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2018 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 
299 template <int dim, int spacedim=dim>
300 class GridIn
301 {
302 public:
307  enum Format
308  {
331  };
332 
336  GridIn ();
337 
342 
347  void read (std::istream &in, Format format=Default);
348 
354  void read (const std::string &in, Format format=Default);
355 
361  void read_vtk(std::istream &in);
362 
370  void read_unv(std::istream &in);
371 
380  void read_ucd (std::istream &in,
381  const bool apply_all_indicators_to_manifolds=false);
382 
422  void read_abaqus (std::istream &in,
423  const bool apply_all_indicators_to_manifolds=false);
424 
428  void read_dbmesh (std::istream &in);
429 
433  void read_xda (std::istream &in);
434 
444  void read_msh (std::istream &in);
445 
452  void read_netcdf (const std::string &filename);
453 
458  void read_tecplot (std::istream &in);
459 
494  void read_assimp(const std::string &filename,
495  const unsigned int mesh_index=numbers::invalid_unsigned_int,
496  const bool remove_duplicates=true,
497  const double tol = 1e-12,
498  const bool ignore_unsupported_element_types = true);
499 
503  static std::string default_suffix (const Format format);
504 
508  static Format parse_format (const std::string &format_name);
509 
515  static std::string get_format_names ();
516 
521  int,
522  << "The section type <" << arg1 << "> in an UNV "
523  << "input file is not implemented.");
524 
529  int,
530  << "The element type <" << arg1 << "> in an UNV "
531  << "input file is not implemented.");
532 
537  std::string,
538  << "The identifier <" << arg1 << "> as name of a "
539  << "part in an UCD input file is unknown or the "
540  << "respective input routine is not implemented."
541  << "(Maybe the space dimension of triangulation and "
542  << "input file do not match?");
551  int, int,
552  << "While creating cell " << arg1
553  << ", you are referencing a vertex with index " << arg2
554  << " but no vertex with this index has been described in the input file.");
559  int, int, int,
560  << "While creating cell " << arg1
561  << " (which is numbered as " << arg2
562  << " in the input file), you are referencing a vertex with index " << arg3
563  << " but no vertex with this index has been described in the input file.");
572  std::string,
573  << "The string <" << arg1 << "> is not recognized at the present"
574  << " position of a DB Mesh file.");
575 
580  int,
581  << "The specified dimension " << arg1
582  << " is not the same as that of the triangulation to be created.");
583 
585  std::string,
586  << "The string <" << arg1 << "> is not recognized at the present"
587  << " position of a Gmsh Mesh file.");
588 
590  int,
591  << "The Element Identifier <" << arg1 << "> is not "
592  << "supported in the deal.II library when "
593  << "reading meshes in " << dim << " dimensions.\n"
594  << "Supported elements are: \n"
595  << "ELM-TYPE\n"
596  << "1 Line (2 nodes, 1 edge).\n"
597  << "3 Quadrilateral (4 nodes, 4 edges).\n"
598  << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
599  << "15 Point (1 node, ignored when read)");
600 
601 
603 protected:
608 
629  static void debug_output_grid (const std::vector<CellData<dim> > &cells,
630  const std::vector<Point<spacedim> > &vertices,
631  std::ostream &out);
632 
633 private:
634 
639  static void skip_empty_lines (std::istream &in);
640 
648  static void skip_comment_lines (std::istream &in,
649  const char comment_start);
650 
658  static void parse_tecplot_header(std::string &header,
659  std::vector<unsigned int> &tecplot2deal,
660  unsigned int &n_vars,
661  unsigned int &n_vertices,
662  unsigned int &n_cells,
663  std::vector<unsigned int> &IJK,
664  bool &structured,
665  bool &blocked);
666 
671 };
672 
673 /* -------------- declaration of explicit specializations ------------- */
674 
675 #ifndef DOXYGEN
676 
677 template <>
678 void
679 GridIn<2>::debug_output_grid (const std::vector<CellData<2> > &cells,
680  const std::vector<Point<2> > &vertices,
681  std::ostream &out);
682 
683 
684 template <>
685 void
686 GridIn<2,3>::debug_output_grid (const std::vector<CellData<2> > &cells,
687  const std::vector<Point<3> > &vertices,
688  std::ostream &out);
689 template <>
690 void
691 GridIn<3>::debug_output_grid (const std::vector<CellData<3> > &cells,
692  const std::vector<Point<3> > &vertices,
693  std::ostream &out);
694 #endif // DOXYGEN
695 
696 DEAL_II_NAMESPACE_CLOSE
697 
698 #endif
static std::string get_format_names()
Definition: grid_in.cc:3026
static const unsigned int invalid_unsigned_int
Definition: types.h:173
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:358
Use read_abaqus()
Definition: grid_in.h:316
Format
Definition: grid_in.h:307
Use read_vtk()
Definition: grid_in.h:328
static ::ExceptionBase & ExcUnknownElementType(int arg1)
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition: grid_in.h:607
Use read_unv()
Definition: grid_in.h:312
Use read_xda()
Definition: grid_in.h:320
static Format parse_format(const std::string &format_name)
Definition: grid_in.cc:2970
static void skip_empty_lines(std::istream &in)
Definition: grid_in.cc:2636
void read_vtk(std::istream &in)
Definition: grid_in.cc:106
static ::ExceptionBase & ExcDBMESHWrongDimension(int arg1)
Use read_ucd()
Definition: grid_in.h:314
void read_dbmesh(std::istream &in)
Definition: grid_in.cc:908
void read_tecplot(std::istream &in)
Definition: grid_in.cc:2475
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:2041
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:346
static ::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
Use read_msh()
Definition: grid_in.h:322
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition: grid_in.cc:2665
#define DeclException0(Exception0)
Definition: exceptions.h:323
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:629
static ::ExceptionBase & ExcInvalidDBMESHInput(std::string arg1)
GridIn()
Definition: grid_in.cc:92
Use read_tecplot()
Definition: grid_in.h:326
static ::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
void read_xda(std::istream &in)
Definition: grid_in.cc:1074
void read_msh(std::istream &in)
Definition: grid_in.cc:1232
Use read_dbmesh()
Definition: grid_in.h:318
void read_netcdf(const std::string &filename)
static std::string default_suffix(const Format format)
Definition: grid_in.cc:2938
void read_unv(std::istream &in)
Definition: grid_in.cc:393
void read(std::istream &in, Format format=Default)
Definition: grid_in.cc:2876
static ::ExceptionBase & ExcNoTriangulationSelected()
static ::ExceptionBase & ExcInvalidDBMeshFormat()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:370
void read_assimp(const std::string &filename, const unsigned int mesh_index=numbers::invalid_unsigned_int, const bool remove_duplicates=true, const double tol=1e-12, const bool ignore_unsupported_element_types=true)
Definition: grid_in.cc:2483
Use GridIn::default_format stored in this object.
Definition: grid_in.h:310
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:863
static void debug_output_grid(const std::vector< CellData< dim > > &cells, const std::vector< Point< spacedim > > &vertices, std::ostream &out)
Definition: grid_in.cc:2690
static ::ExceptionBase & ExcInvalidGMSHInput(std::string arg1)
static ::ExceptionBase & ExcGmshUnsupportedGeometry(int arg1)
static ::ExceptionBase & ExcUnknownSectionType(int arg1)
void attach_triangulation(Triangulation< dim, spacedim > &tria)
Definition: grid_in.cc:98
Use read_netcdf()
Definition: grid_in.h:324
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2)
Use read_assimp()
Definition: grid_in.h:330
Format default_format
Definition: grid_in.h:670
static ::ExceptionBase & ExcGmshNoCellInformation()