Reference documentation for deal.II version GIT 20f059c89a 2022-12-04 14:55:02+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
grid_in.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2022 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 
23 #include <deal.II/base/point.h>
25 
26 #include <iostream>
27 #include <string>
28 #include <vector>
29 
31 
32 // Forward declarations
33 #ifndef DOXYGEN
34 template <int dim, int space_dim>
35 class Triangulation;
36 template <int dim>
37 struct CellData;
38 #endif
39 
310 template <int dim, int spacedim = dim>
311 class GridIn
312 {
313 public:
318  enum Format
319  {
344  };
345 
349  GridIn();
350 
355 
359  void
361 
366  void
367  read(std::istream &in, Format format = Default);
368 
374  void
375  read(const std::string &in, Format format = Default);
376 
416  void
417  read_vtk(std::istream &in);
418 
433  void
434  read_vtu(std::istream &in);
435 
436 
444  void
445  read_unv(std::istream &in);
446 
456  void
457  read_ucd(std::istream &in,
458  const bool apply_all_indicators_to_manifolds = false);
459 
499  void
500  read_abaqus(std::istream &in,
501  const bool apply_all_indicators_to_manifolds = false);
502 
506  void
507  read_dbmesh(std::istream &in);
508 
512  void
513  read_xda(std::istream &in);
514 
521  void
522  read_msh(std::istream &in);
523 
524 #ifdef DEAL_II_GMSH_WITH_API
580  void
581  read_msh(const std::string &filename);
582 #endif
583 
619  void
620  read_comsol_mphtxt(std::istream &in);
621 
626  void
627  read_tecplot(std::istream &in);
628 
663  void
664  read_assimp(const std::string &filename,
665  const unsigned int mesh_index = numbers::invalid_unsigned_int,
666  const bool remove_duplicates = true,
667  const double tol = 1e-12,
668  const bool ignore_unsupported_element_types = true);
669 
679  {
684  std::vector<std::vector<int>> id_to_sideset_ids;
685  };
686 
744  read_exodusii(const std::string &filename,
745  const bool apply_all_indicators_to_manifolds = false);
746 
750  static std::string
751  default_suffix(const Format format);
752 
756  static Format
757  parse_format(const std::string &format_name);
758 
764  static std::string
766 
771  int,
772  << "The section type <" << arg1 << "> in an UNV "
773  << "input file is not implemented.");
774 
779  int,
780  << "The element type <" << arg1 << "> in an UNV "
781  << "input file is not implemented.");
782 
787  std::string,
788  << "The identifier <" << arg1 << "> as name of a "
789  << "part in an UCD input file is unknown or the "
790  << "respective input routine is not implemented."
791  << "(Maybe the space dimension of triangulation and "
792  << "input file do not match?");
797  "No Triangulation has been attached to this GridIn object "
798  "so that nothing can be filled during any read function "
799  "calls. Please pass a reference to the Triangulation tria "
800  "to be filled in the constructor GridIn(tria) or attach "
801  "it with the function call GridIn::attach_triangulation().");
807  int,
808  int,
809  << "While creating cell " << arg1
810  << ", you are referencing a vertex with index " << arg2
811  << " but no vertex with this index has been described in the input file.");
817  int,
818  int,
819  int,
820  << "While creating cell " << arg1 << " (which is numbered as " << arg2
821  << " in the input file), you are referencing a vertex with index " << arg3
822  << " but no vertex with this index has been described in the input file.");
831  std::string,
832  << "The string <" << arg1
833  << "> is not recognized at the present"
834  << " position of a DB Mesh file.");
835 
841  int,
842  << "The specified dimension " << arg1
843  << " is not the same as that of the triangulation to be created.");
844 
846  std::string,
847  << "The string <" << arg1
848  << "> is not recognized at the present"
849  << " position of a Gmsh Mesh file.");
850 
852  int,
853  << "The Element Identifier <" << arg1 << "> is not "
854  << "supported in the deal.II library when "
855  << "reading meshes in " << dim << " dimensions.\n"
856  << "Supported elements are: \n"
857  << "ELM-TYPE\n"
858  << "1 Line (2 nodes, 1 edge).\n"
859  << "3 Quadrilateral (4 nodes, 4 edges).\n"
860  << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
861  << "15 Point (1 node, ignored when read)");
862 
863 
866  unsigned int,
867  unsigned int,
868  "While reading a gmsh file, the reader function did not find "
869  "any cells. This sometimes happens if the file only contains a "
870  "surface mesh, but not a volume mesh."
871  "\n\n"
872  "The reader function did find " +
873  std::to_string(arg1) + " lines and " + std::to_string(arg2) +
874  " facets (surface triangles or quadrilaterals).");
875 
876 protected:
881 
902  static void
903  debug_output_grid(const std::vector<CellData<dim>> & cells,
904  const std::vector<Point<spacedim>> &vertices,
905  std::ostream & out);
906 
907 private:
912  static void
913  skip_empty_lines(std::istream &in);
914 
922  static void
923  skip_comment_lines(std::istream &in, const char comment_start);
924 
932  static void
933  parse_tecplot_header(std::string & header,
934  std::vector<unsigned int> &tecplot2deal,
935  unsigned int & n_vars,
936  unsigned int & n_vertices,
937  unsigned int & n_cells,
938  std::vector<unsigned int> &IJK,
939  bool & structured,
940  bool & blocked);
941 
946 };
947 
948 /* -------------- declaration of explicit specializations ------------- */
949 
950 #ifndef DOXYGEN
951 
952 template <>
953 void
954 GridIn<2>::debug_output_grid(const std::vector<CellData<2>> &cells,
955  const std::vector<Point<2>> & vertices,
956  std::ostream & out);
957 
958 
959 template <>
960 void
961 GridIn<2, 3>::debug_output_grid(const std::vector<CellData<2>> &cells,
962  const std::vector<Point<3>> & vertices,
963  std::ostream & out);
964 template <>
965 void
966 GridIn<3>::debug_output_grid(const std::vector<CellData<3>> &cells,
967  const std::vector<Point<3>> & vertices,
968  std::ostream & out);
969 #endif // DOXYGEN
970 
972 
973 #endif
Format
Definition: grid_in.h:319
@ Default
Use GridIn::default_format stored in this object.
Definition: grid_in.h:321
@ vtu
Use read_vtu()
Definition: grid_in.h:339
@ xda
Use read_xda()
Definition: grid_in.h:331
@ tecplot
Use read_tecplot()
Definition: grid_in.h:335
@ msh
Use read_msh()
Definition: grid_in.h:333
@ ucd
Use read_ucd()
Definition: grid_in.h:325
@ dbmesh
Use read_dbmesh()
Definition: grid_in.h:329
@ abaqus
Use read_abaqus()
Definition: grid_in.h:327
@ assimp
Use read_assimp()
Definition: grid_in.h:341
@ unv
Use read_unv()
Definition: grid_in.h:323
@ exodusii
Use read_exodusii()
Definition: grid_in.h:343
@ vtk
Use read_vtk()
Definition: grid_in.h:337
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition: grid_in.h:880
void read_vtk(std::istream &in)
Definition: grid_in.cc:159
GridIn()
Definition: grid_in.cc:133
static void skip_empty_lines(std::istream &in)
Definition: grid_in.cc:3858
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:3346
static void debug_output_grid(const std::vector< CellData< dim >> &cells, const std::vector< Point< spacedim >> &vertices, std::ostream &out)
Definition: grid_in.cc:3914
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:1165
static std::string default_suffix(const Format format)
Definition: grid_in.cc:4169
void read_xda(std::istream &in)
Definition: grid_in.cc:1378
void read_comsol_mphtxt(std::istream &in)
Definition: grid_in.cc:1442
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition: grid_in.cc:3888
void attach_triangulation(Triangulation< dim, spacedim > &tria)
Definition: grid_in.cc:150
void read_msh(std::istream &in)
Definition: grid_in.cc:1988
static Format parse_format(const std::string &format_name)
Definition: grid_in.cc:4204
void read_vtu(std::istream &in)
Definition: grid_in.cc:584
void read_tecplot(std::istream &in)
Definition: grid_in.cc:3337
Format default_format
Definition: grid_in.h:945
ExodusIIData read_exodusii(const std::string &filename, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:3704
void read_dbmesh(std::istream &in)
Definition: grid_in.cc:1221
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:911
void read(std::istream &in, Format format=Default)
Definition: grid_in.cc:4102
static std::string get_format_names()
Definition: grid_in.cc:4261
void read_unv(std::istream &in)
Definition: grid_in.cc:611
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:2872
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
Point< 3 > vertices[4]
static ::ExceptionBase & ExcInvalidDBMESHInput(std::string arg1)
static ::ExceptionBase & ExcUnknownElementType(int arg1)
#define DeclException0(Exception0)
Definition: exceptions.h:464
static ::ExceptionBase & ExcNoTriangulationSelected()
static ::ExceptionBase & ExcUnknownSectionType(int arg1)
static ::ExceptionBase & ExcInvalidDBMeshFormat()
static ::ExceptionBase & ExcInvalidGMSHInput(std::string arg1)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:532
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2)
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:487
static ::ExceptionBase & ExcDBMESHWrongDimension(int arg1)
static ::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:555
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
static ::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
static ::ExceptionBase & ExcGmshUnsupportedGeometry(int arg1)
static ::ExceptionBase & ExcGmshNoCellInformation(unsigned int arg1, unsigned int arg2)
std::string to_string(const T &t)
Definition: patterns.h:2394
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:13750
static const unsigned int invalid_unsigned_int
Definition: types.h:206
std::vector< std::vector< int > > id_to_sideset_ids
Definition: grid_in.h:684