Reference documentation for deal.II version 9.1.0-pre
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.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 
368  void
369  read_vtk(std::istream &in);
370 
378  void
379  read_unv(std::istream &in);
380 
389  void
390  read_ucd(std::istream &in,
391  const bool apply_all_indicators_to_manifolds = false);
392 
432  void
433  read_abaqus(std::istream &in,
434  const bool apply_all_indicators_to_manifolds = false);
435 
439  void
440  read_dbmesh(std::istream &in);
441 
445  void
446  read_xda(std::istream &in);
447 
457  void
458  read_msh(std::istream &in);
459 
466  void
467  read_netcdf(const std::string &filename);
468 
473  void
474  read_tecplot(std::istream &in);
475 
510  void
511  read_assimp(const std::string &filename,
512  const unsigned int mesh_index = numbers::invalid_unsigned_int,
513  const bool remove_duplicates = true,
514  const double tol = 1e-12,
515  const bool ignore_unsupported_element_types = true);
516 
520  static std::string
521  default_suffix(const Format format);
522 
526  static Format
527  parse_format(const std::string &format_name);
528 
534  static std::string
536 
541  int,
542  << "The section type <" << arg1 << "> in an UNV "
543  << "input file is not implemented.");
544 
549  int,
550  << "The element type <" << arg1 << "> in an UNV "
551  << "input file is not implemented.");
552 
557  std::string,
558  << "The identifier <" << arg1 << "> as name of a "
559  << "part in an UCD input file is unknown or the "
560  << "respective input routine is not implemented."
561  << "(Maybe the space dimension of triangulation and "
562  << "input file do not match?");
572  int,
573  int,
574  << "While creating cell " << arg1
575  << ", you are referencing a vertex with index " << arg2
576  << " but no vertex with this index has been described in the input file.");
582  int,
583  int,
584  int,
585  << "While creating cell " << arg1 << " (which is numbered as " << arg2
586  << " in the input file), you are referencing a vertex with index " << arg3
587  << " but no vertex with this index has been described in the input file.");
596  std::string,
597  << "The string <" << arg1
598  << "> is not recognized at the present"
599  << " position of a DB Mesh file.");
600 
606  int,
607  << "The specified dimension " << arg1
608  << " is not the same as that of the triangulation to be created.");
609 
611  std::string,
612  << "The string <" << arg1
613  << "> is not recognized at the present"
614  << " position of a Gmsh Mesh file.");
615 
617  int,
618  << "The Element Identifier <" << arg1 << "> is not "
619  << "supported in the deal.II library when "
620  << "reading meshes in " << dim << " dimensions.\n"
621  << "Supported elements are: \n"
622  << "ELM-TYPE\n"
623  << "1 Line (2 nodes, 1 edge).\n"
624  << "3 Quadrilateral (4 nodes, 4 edges).\n"
625  << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
626  << "15 Point (1 node, ignored when read)");
627 
628 
630 
631 protected:
636 
657  static void
658  debug_output_grid(const std::vector<CellData<dim>> & cells,
659  const std::vector<Point<spacedim>> &vertices,
660  std::ostream & out);
661 
662 private:
667  static void
668  skip_empty_lines(std::istream &in);
669 
677  static void
678  skip_comment_lines(std::istream &in, const char comment_start);
679 
687  static void
688  parse_tecplot_header(std::string & header,
689  std::vector<unsigned int> &tecplot2deal,
690  unsigned int & n_vars,
691  unsigned int & n_vertices,
692  unsigned int & n_cells,
693  std::vector<unsigned int> &IJK,
694  bool & structured,
695  bool & blocked);
696 
701 };
702 
703 /* -------------- declaration of explicit specializations ------------- */
704 
705 #ifndef DOXYGEN
706 
707 template <>
708 void
709 GridIn<2>::debug_output_grid(const std::vector<CellData<2>> &cells,
710  const std::vector<Point<2>> & vertices,
711  std::ostream & out);
712 
713 
714 template <>
715 void
716 GridIn<2, 3>::debug_output_grid(const std::vector<CellData<2>> &cells,
717  const std::vector<Point<3>> & vertices,
718  std::ostream & out);
719 template <>
720 void
721 GridIn<3>::debug_output_grid(const std::vector<CellData<3>> &cells,
722  const std::vector<Point<3>> & vertices,
723  std::ostream & out);
724 #endif // DOXYGEN
725 
726 DEAL_II_NAMESPACE_CLOSE
727 
728 #endif
static std::string get_format_names()
Definition: grid_in.cc:3192
static const unsigned int invalid_unsigned_int
Definition: types.h:173
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:420
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:3135
static void skip_empty_lines(std::istream &in)
Definition: grid_in.cc:2802
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:978
void read_tecplot(std::istream &in)
Definition: grid_in.cc:2635
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:2159
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:408
static::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition: grid_in.h:635
Use read_msh()
Definition: grid_in.h:326
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition: grid_in.cc:2834
#define DeclException0(Exception0)
Definition: exceptions.h:385
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:669
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:2860
Use read_tecplot()
Definition: grid_in.h:330
static::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
void read_xda(std::istream &in)
Definition: grid_in.cc:1145
void read_msh(std::istream &in)
Definition: grid_in.cc:1303
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:3102
void read_unv(std::istream &in)
Definition: grid_in.cc:420
void read(std::istream &in, Format format=Default)
Definition: grid_in.cc:3039
static::ExceptionBase & ExcNoTriangulationSelected()
static::ExceptionBase & ExcInvalidDBMeshFormat()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:432
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:2644
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:928
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:700
static::ExceptionBase & ExcGmshNoCellInformation()