Reference documentation for deal.II version Git 73c87d96ef 2021-11-30 22:54:44 +0100
\(\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 - 2021 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
525 
579  void
580  read_msh(const std::string &filename);
581 #endif
582 
618  void
619  read_comsol_mphtxt(std::istream &in);
620 
625  void
626  read_tecplot(std::istream &in);
627 
662  void
663  read_assimp(const std::string &filename,
664  const unsigned int mesh_index = numbers::invalid_unsigned_int,
665  const bool remove_duplicates = true,
666  const double tol = 1e-12,
667  const bool ignore_unsupported_element_types = true);
668 
678  {
683  std::vector<std::vector<int>> id_to_sideset_ids;
684  };
685 
743  read_exodusii(const std::string &filename,
744  const bool apply_all_indicators_to_manifolds = false);
745 
749  static std::string
750  default_suffix(const Format format);
751 
755  static Format
756  parse_format(const std::string &format_name);
757 
763  static std::string
765 
770  int,
771  << "The section type <" << arg1 << "> in an UNV "
772  << "input file is not implemented.");
773 
778  int,
779  << "The element type <" << arg1 << "> in an UNV "
780  << "input file is not implemented.");
781 
786  std::string,
787  << "The identifier <" << arg1 << "> as name of a "
788  << "part in an UCD input file is unknown or the "
789  << "respective input routine is not implemented."
790  << "(Maybe the space dimension of triangulation and "
791  << "input file do not match?");
796  "No Triangulation has been attached to this GridIn object "
797  "so that nothing can be filled during any read function "
798  "calls. Please pass a reference to the Triangulation tria "
799  "to be filled in the constructor GridIn(tria) or attach "
800  "it with the function call GridIn::attach_triangulation().");
806  int,
807  int,
808  << "While creating cell " << arg1
809  << ", you are referencing a vertex with index " << arg2
810  << " but no vertex with this index has been described in the input file.");
816  int,
817  int,
818  int,
819  << "While creating cell " << arg1 << " (which is numbered as " << arg2
820  << " in the input file), you are referencing a vertex with index " << arg3
821  << " but no vertex with this index has been described in the input file.");
830  std::string,
831  << "The string <" << arg1
832  << "> is not recognized at the present"
833  << " position of a DB Mesh file.");
834 
840  int,
841  << "The specified dimension " << arg1
842  << " is not the same as that of the triangulation to be created.");
843 
845  std::string,
846  << "The string <" << arg1
847  << "> is not recognized at the present"
848  << " position of a Gmsh Mesh file.");
849 
851  int,
852  << "The Element Identifier <" << arg1 << "> is not "
853  << "supported in the deal.II library when "
854  << "reading meshes in " << dim << " dimensions.\n"
855  << "Supported elements are: \n"
856  << "ELM-TYPE\n"
857  << "1 Line (2 nodes, 1 edge).\n"
858  << "3 Quadrilateral (4 nodes, 4 edges).\n"
859  << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
860  << "15 Point (1 node, ignored when read)");
861 
862 
865  unsigned int,
866  unsigned int,
867  "While reading a gmsh file, the reader function did not find "
868  "any cells. This sometimes happens if the file only contains a "
869  "surface mesh, but not a volume mesh."
870  "\n\n"
871  "The reader function did find " +
872  std::to_string(arg1) + " lines and " + std::to_string(arg2) +
873  " facets (surface triangles or quadrilaterals).");
874 
875 protected:
880 
901  static void
902  debug_output_grid(const std::vector<CellData<dim>> & cells,
903  const std::vector<Point<spacedim>> &vertices,
904  std::ostream & out);
905 
906 private:
911  static void
912  skip_empty_lines(std::istream &in);
913 
921  static void
922  skip_comment_lines(std::istream &in, const char comment_start);
923 
931  static void
932  parse_tecplot_header(std::string & header,
933  std::vector<unsigned int> &tecplot2deal,
934  unsigned int & n_vars,
935  unsigned int & n_vertices,
936  unsigned int & n_cells,
937  std::vector<unsigned int> &IJK,
938  bool & structured,
939  bool & blocked);
940 
945 };
946 
947 /* -------------- declaration of explicit specializations ------------- */
948 
949 #ifndef DOXYGEN
950 
951 template <>
952 void
953 GridIn<2>::debug_output_grid(const std::vector<CellData<2>> &cells,
954  const std::vector<Point<2>> & vertices,
955  std::ostream & out);
956 
957 
958 template <>
959 void
960 GridIn<2, 3>::debug_output_grid(const std::vector<CellData<2>> &cells,
961  const std::vector<Point<3>> & vertices,
962  std::ostream & out);
963 template <>
964 void
965 GridIn<3>::debug_output_grid(const std::vector<CellData<3>> &cells,
966  const std::vector<Point<3>> & vertices,
967  std::ostream & out);
968 #endif // DOXYGEN
969 
971 
972 #endif
static std::string get_format_names()
Definition: grid_in.cc:4334
std::vector< std::vector< int > > id_to_sideset_ids
Definition: grid_in.h:683
static const unsigned int invalid_unsigned_int
Definition: types.h:196
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:532
Use read_abaqus()
Definition: grid_in.h:327
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Use read_vtu()
Definition: grid_in.h:339
void read_msh(std::istream &in)
Definition: grid_in.cc:1997
Format
Definition: grid_in.h:318
Use read_vtk()
Definition: grid_in.h:337
static ::ExceptionBase & ExcUnknownElementType(int arg1)
Use read_unv()
Definition: grid_in.h:323
Use read_xda()
Definition: grid_in.h:331
static ::ExceptionBase & ExcGmshNoCellInformation(unsigned int arg1, unsigned int arg2)
static Format parse_format(const std::string &format_name)
Definition: grid_in.cc:4277
static void skip_empty_lines(std::istream &in)
Definition: grid_in.cc:3931
static ::ExceptionBase & ExcDBMESHWrongDimension(int arg1)
void read_vtk(std::istream &in)
Definition: grid_in.cc:129
void read_vtu(std::istream &in)
Definition: grid_in.cc:593
Use read_ucd()
Definition: grid_in.h:325
void read_dbmesh(std::istream &in)
Definition: grid_in.cc:1217
void read_tecplot(std::istream &in)
Definition: grid_in.cc:3393
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:2919
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:509
static ::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition: grid_in.h:879
Use read_msh()
Definition: grid_in.h:333
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition: grid_in.cc:3961
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:487
void read_comsol_mphtxt(std::istream &in)
Definition: grid_in.cc:1451
#define DeclException0(Exception0)
Definition: exceptions.h:464
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:898
std::string to_string(const T &t)
Definition: patterns.h:2329
static ::ExceptionBase & ExcInvalidDBMESHInput(std::string arg1)
Point< 3 > vertices[4]
GridIn()
Definition: grid_in.cc:103
static void debug_output_grid(const std::vector< CellData< dim >> &cells, const std::vector< Point< spacedim >> &vertices, std::ostream &out)
Definition: grid_in.cc:3987
Use read_tecplot()
Definition: grid_in.h:335
ExodusIIData read_exodusii(const std::string &filename, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:3763
static ::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition: tria.cc:13721
void read_xda(std::istream &in)
Definition: grid_in.cc:1383
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
Use read_dbmesh()
Definition: grid_in.h:329
static std::string default_suffix(const Format format)
Definition: grid_in.cc:4242
void read_unv(std::istream &in)
Definition: grid_in.cc:620
void read(std::istream &in, Format format=Default)
Definition: grid_in.cc:4175
static ::ExceptionBase & ExcNoTriangulationSelected()
static ::ExceptionBase & ExcInvalidDBMeshFormat()
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition: exceptions.h:555
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:3402
Use GridIn::default_format stored in this object.
Definition: grid_in.h:321
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition: grid_in.cc:1161
static ::ExceptionBase & ExcInvalidGMSHInput(std::string arg1)
static ::ExceptionBase & ExcGmshUnsupportedGeometry(int arg1)
Use read_exodusii()
Definition: grid_in.h:343
static ::ExceptionBase & ExcUnknownSectionType(int arg1)
void attach_triangulation(Triangulation< dim, spacedim > &tria)
Definition: grid_in.cc:120
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2)
Use read_assimp()
Definition: grid_in.h:341
Format default_format
Definition: grid_in.h:944