Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
grid_in.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2019 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.md at
12 // the top level directory of deal.II.
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 
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/point.h>
24 #include <deal.II/base/smartpointer.h>
25 
26 #include <iostream>
27 #include <string>
28 #include <vector>
29 
30 DEAL_II_NAMESPACE_OPEN
31 
32 template <int dim, int space_dim>
33 class Triangulation;
34 template <int dim>
35 struct CellData;
36 
303 template <int dim, int spacedim = dim>
304 class GridIn
305 {
306 public:
311  enum Format
312  {
335  };
336 
340  GridIn();
341 
345  void
347 
352  void
353  read(std::istream &in, Format format = Default);
354 
360  void
361  read(const std::string &in, Format format = Default);
362 
401  void
402  read_vtk(std::istream &in);
403 
411  void
412  read_unv(std::istream &in);
413 
423  void
424  read_ucd(std::istream &in,
425  const bool apply_all_indicators_to_manifolds = false);
426 
466  void
467  read_abaqus(std::istream &in,
468  const bool apply_all_indicators_to_manifolds = false);
469 
473  void
474  read_dbmesh(std::istream &in);
475 
479  void
480  read_xda(std::istream &in);
481 
491  void
492  read_msh(std::istream &in);
493 
502  DEAL_II_DEPRECATED void
503  read_netcdf(const std::string &filename);
504 
509  void
510  read_tecplot(std::istream &in);
511 
546  void
547  read_assimp(const std::string &filename,
548  const unsigned int mesh_index = numbers::invalid_unsigned_int,
549  const bool remove_duplicates = true,
550  const double tol = 1e-12,
551  const bool ignore_unsupported_element_types = true);
552 
556  static std::string
557  default_suffix(const Format format);
558 
562  static Format
563  parse_format(const std::string &format_name);
564 
570  static std::string
572 
577  int,
578  << "The section type <" << arg1 << "> in an UNV "
579  << "input file is not implemented.");
580 
585  int,
586  << "The element type <" << arg1 << "> in an UNV "
587  << "input file is not implemented.");
588 
593  std::string,
594  << "The identifier <" << arg1 << "> as name of a "
595  << "part in an UCD input file is unknown or the "
596  << "respective input routine is not implemented."
597  << "(Maybe the space dimension of triangulation and "
598  << "input file do not match?");
608  int,
609  int,
610  << "While creating cell " << arg1
611  << ", you are referencing a vertex with index " << arg2
612  << " but no vertex with this index has been described in the input file.");
618  int,
619  int,
620  int,
621  << "While creating cell " << arg1 << " (which is numbered as " << arg2
622  << " in the input file), you are referencing a vertex with index " << arg3
623  << " but no vertex with this index has been described in the input file.");
632  std::string,
633  << "The string <" << arg1
634  << "> is not recognized at the present"
635  << " position of a DB Mesh file.");
636 
642  int,
643  << "The specified dimension " << arg1
644  << " is not the same as that of the triangulation to be created.");
645 
647  std::string,
648  << "The string <" << arg1
649  << "> is not recognized at the present"
650  << " position of a Gmsh Mesh file.");
651 
653  int,
654  << "The Element Identifier <" << arg1 << "> is not "
655  << "supported in the deal.II library when "
656  << "reading meshes in " << dim << " dimensions.\n"
657  << "Supported elements are: \n"
658  << "ELM-TYPE\n"
659  << "1 Line (2 nodes, 1 edge).\n"
660  << "3 Quadrilateral (4 nodes, 4 edges).\n"
661  << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
662  << "15 Point (1 node, ignored when read)");
663 
664 
666 
667 protected:
672 
693  static void
694  debug_output_grid(const std::vector<CellData<dim>> & cells,
695  const std::vector<Point<spacedim>> &vertices,
696  std::ostream & out);
697 
698 private:
703  static void
704  skip_empty_lines(std::istream &in);
705 
713  static void
714  skip_comment_lines(std::istream &in, const char comment_start);
715 
723  static void
724  parse_tecplot_header(std::string & header,
725  std::vector<unsigned int> &tecplot2deal,
726  unsigned int & n_vars,
727  unsigned int & n_vertices,
728  unsigned int & n_cells,
729  std::vector<unsigned int> &IJK,
730  bool & structured,
731  bool & blocked);
732 
737 };
738 
739 /* -------------- declaration of explicit specializations ------------- */
740 
741 #ifndef DOXYGEN
742 
743 template <>
744 void
745 GridIn<2>::debug_output_grid(const std::vector<CellData<2>> &cells,
746  const std::vector<Point<2>> & vertices,
747  std::ostream & out);
748 
749 
750 template <>
751 void
752 GridIn<2, 3>::debug_output_grid(const std::vector<CellData<2>> &cells,
753  const std::vector<Point<3>> & vertices,
754  std::ostream & out);
755 template <>
756 void
757 GridIn<3>::debug_output_grid(const std::vector<CellData<3>> &cells,
758  const std::vector<Point<3>> & vertices,
759  std::ostream & out);
760 #endif // DOXYGEN
761 
762 DEAL_II_NAMESPACE_CLOSE
763 
764 #endif
static std::string get_format_names()
Definition: grid_in.cc:3536
static const unsigned int invalid_unsigned_int
Definition: types.h:173
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:541
Use read_abaqus()
Definition: grid_in.h:320
Format
Definition: grid_in.h:311
Use read_vtk()
Definition: grid_in.h:332
static ::ExceptionBase & ExcUnknownElementType(int arg1)
Use read_unv()
Definition: grid_in.h:316
Use read_xda()
Definition: grid_in.h:324
static Format parse_format(const std::string &format_name)
Definition: grid_in.cc:3479
static void skip_empty_lines(std::istream &in)
Definition: grid_in.cc:3146
void read_vtk(std::istream &in)
Definition: grid_in.cc:114
static ::ExceptionBase & ExcDBMESHWrongDimension(int arg1)
Use read_ucd()
Definition: grid_in.h:318
void read_dbmesh(std::istream &in)
Definition: grid_in.cc:1080
void read_tecplot(std::istream &in)
Definition: grid_in.cc:2979
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:2504
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
static ::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition: grid_in.h:671
Use read_msh()
Definition: grid_in.h:326
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition: grid_in.cc:3178
#define DeclException0(Exception0)
Definition: exceptions.h:473
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:749
static ::ExceptionBase & ExcInvalidDBMESHInput(std::string arg1)
GridIn()
Definition: grid_in.cc:97
static void debug_output_grid(const std::vector< CellData< dim >> &cells, const std::vector< Point< spacedim >> &vertices, std::ostream &out)
Definition: grid_in.cc:3204
Use read_tecplot()
Definition: grid_in.h:330
static ::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
void read_xda(std::istream &in)
Definition: grid_in.cc:1247
void read_msh(std::istream &in)
Definition: grid_in.cc:1405
Use read_dbmesh()
Definition: grid_in.h:322
void read_netcdf(const std::string &filename)
static std::string default_suffix(const Format format)
Definition: grid_in.cc:3446
void read_unv(std::istream &in)
Definition: grid_in.cc:498
void read(std::istream &in, Format format=Default)
Definition: grid_in.cc:3383
static ::ExceptionBase & ExcNoTriangulationSelected()
static ::ExceptionBase & ExcInvalidDBMeshFormat()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:564
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:2988
Use GridIn::default_format stored in this object.
Definition: grid_in.h:314
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:1024
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:105
Use read_netcdf()
Definition: grid_in.h:328
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2)
Use read_assimp()
Definition: grid_in.h:334
Format default_format
Definition: grid_in.h:736
static ::ExceptionBase & ExcGmshNoCellInformation()