Reference documentation for deal.II version GIT relicensing-891-g13379fae33 2024-06-22 22:40: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\}}\)
Loading...
Searching...
No Matches
grid_in.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1999 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_grid_in_h
16#define dealii_grid_in_h
17
18
19#include <deal.II/base/config.h>
20
22#include <deal.II/base/point.h>
24
25#include <iostream>
26#include <string>
27#include <vector>
28
30
31// Forward declarations
32#ifndef DOXYGEN
33template <int dim, int spacedim>
35class Triangulation;
36template <int dim>
37struct CellData;
38#endif
39
309template <int dim, int spacedim = dim>
311{
312public:
344
348 GridIn();
349
354
358 void
360
365 void
366 read(std::istream &in, Format format = Default);
367
373 void
374 read(const std::string &in, Format format = Default);
375
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
522 void
523 read_msh(std::istream &in);
524
525#ifdef DEAL_II_GMSH_WITH_API
583 void
584 read_msh(const std::string &filename);
585#endif
586
623 void
624 read_comsol_mphtxt(std::istream &in);
625
630 void
631 read_tecplot(std::istream &in);
632
667 void
668 read_assimp(const std::string &filename,
669 const unsigned int mesh_index = numbers::invalid_unsigned_int,
670 const bool remove_duplicates = true,
671 const double tol = 1e-12,
672 const bool ignore_unsupported_element_types = true);
673
683 {
688 std::vector<std::vector<int>> id_to_sideset_ids;
689 };
690
748 read_exodusii(const std::string &filename,
749 const bool apply_all_indicators_to_manifolds = false);
750
754 static std::string
755 default_suffix(const Format format);
756
760 static Format
761 parse_format(const std::string &format_name);
762
768 static std::string
770
775 int,
776 << "The section type <" << arg1 << "> in an UNV "
777 << "input file is not implemented.");
778
783 int,
784 << "The element type <" << arg1 << "> in an UNV "
785 << "input file is not implemented.");
786
791 std::string,
792 << "The identifier <" << arg1 << "> as name of a "
793 << "part in an UCD input file is unknown or the "
794 << "respective input routine is not implemented."
795 << "(Maybe the space dimension of triangulation and "
796 << "input file do not match?");
801 "No Triangulation has been attached to this GridIn object "
802 "so that nothing can be filled during any read function "
803 "calls. Please pass a reference to the Triangulation tria "
804 "to be filled in the constructor GridIn(tria) or attach "
805 "it with the function call GridIn::attach_triangulation().");
811 int,
812 int,
813 << "While creating cell " << arg1
814 << ", you are referencing a vertex with index " << arg2
815 << " but no vertex with this index has been described in the input file.");
821 int,
822 int,
823 int,
824 << "While creating cell " << arg1 << " (which is numbered as " << arg2
825 << " in the input file), you are referencing a vertex with index " << arg3
826 << " but no vertex with this index has been described in the input file.");
835 std::string,
836 << "The string <" << arg1
837 << "> is not recognized at the present"
838 << " position of a DB Mesh file.");
839
845 int,
846 << "The specified dimension " << arg1
847 << " is not the same as that of the triangulation to be created.");
848
850 std::string,
851 << "The string <" << arg1
852 << "> is not recognized at the present"
853 << " position of a Gmsh Mesh file.");
854
856 int,
857 << "The Element Identifier <" << arg1 << "> is not "
858 << "supported in the deal.II library when "
859 << "reading meshes in " << dim << " dimensions.\n"
860 << "Supported elements are: \n"
861 << "ELM-TYPE\n"
862 << "1 Line (2 nodes, 1 edge).\n"
863 << "2 Triangle (3 nodes, 3 edges).\n"
864 << "3 Quadrilateral (4 nodes, 4 edges).\n"
865 << "4 Tetrahedron (4 nodes, 6 edges, 4 faces) when in 3d.\n"
866 << "5 Hexahedron (8 nodes, 12 edges, 6 faces) when in 3d.\n"
867 << "15 Point (1 node, ignored when read).");
868
869
872 unsigned int,
873 unsigned int,
874 "While reading a gmsh file, the reader function did not find "
875 "any cells. This sometimes happens if the file only contains a "
876 "surface mesh, but not a volume mesh."
877 "\n\n"
878 "The reader function did find " +
879 std::to_string(arg1) + " lines and " + std::to_string(arg2) +
880 " facets (surface triangles or quadrilaterals).");
881
882protected:
887
908 static void
909 debug_output_grid(const std::vector<CellData<dim>> &cells,
910 const std::vector<Point<spacedim>> &vertices,
911 std::ostream &out);
912
913private:
918 static void
919 skip_empty_lines(std::istream &in);
920
928 static void
929 skip_comment_lines(std::istream &in, const char comment_start);
930
938 static void
939 parse_tecplot_header(std::string &header,
940 std::vector<unsigned int> &tecplot2deal,
941 unsigned int &n_vars,
942 unsigned int &n_vertices,
943 unsigned int &n_cells,
944 std::vector<unsigned int> &IJK,
945 bool &structured,
946 bool &blocked);
947
952};
953
954/* -------------- declaration of explicit specializations ------------- */
955
956#ifndef DOXYGEN
957
958template <>
959void
960GridIn<2>::debug_output_grid(const std::vector<CellData<2>> &cells,
961 const std::vector<Point<2>> &vertices,
962 std::ostream &out);
963
964
965template <>
966void
967GridIn<2, 3>::debug_output_grid(const std::vector<CellData<2>> &cells,
968 const std::vector<Point<3>> &vertices,
969 std::ostream &out);
970template <>
971void
972GridIn<3>::debug_output_grid(const std::vector<CellData<3>> &cells,
973 const std::vector<Point<3>> &vertices,
974 std::ostream &out);
975#endif // DOXYGEN
976
978
979#endif
@ Default
Use GridIn::default_format stored in this object.
Definition grid_in.h:320
@ vtu
Use read_vtu()
Definition grid_in.h:338
@ xda
Use read_xda()
Definition grid_in.h:330
@ tecplot
Use read_tecplot()
Definition grid_in.h:334
@ msh
Use read_msh()
Definition grid_in.h:332
@ ucd
Use read_ucd()
Definition grid_in.h:324
@ dbmesh
Use read_dbmesh()
Definition grid_in.h:328
@ abaqus
Use read_abaqus()
Definition grid_in.h:326
@ assimp
Use read_assimp()
Definition grid_in.h:340
@ unv
Use read_unv()
Definition grid_in.h:322
@ exodusii
Use read_exodusii()
Definition grid_in.h:342
@ vtk
Use read_vtk()
Definition grid_in.h:336
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
Definition grid_in.h:886
void read_vtk(std::istream &in)
Definition grid_in.cc:163
GridIn()
Definition grid_in.cc:137
static void skip_empty_lines(std::istream &in)
Definition grid_in.cc:3938
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:3403
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition grid_in.cc:1169
static std::string default_suffix(const Format format)
Definition grid_in.cc:4249
void read_xda(std::istream &in)
Definition grid_in.cc:1386
void read_comsol_mphtxt(std::istream &in)
Definition grid_in.cc:1450
static void skip_comment_lines(std::istream &in, const char comment_start)
Definition grid_in.cc:3968
void attach_triangulation(Triangulation< dim, spacedim > &tria)
Definition grid_in.cc:154
void read_msh(std::istream &in)
Definition grid_in.cc:2006
static Format parse_format(const std::string &format_name)
Definition grid_in.cc:4284
void read_vtu(std::istream &in)
Definition grid_in.cc:588
void read_tecplot(std::istream &in)
Definition grid_in.cc:3394
Format default_format
Definition grid_in.h:951
ExodusIIData read_exodusii(const std::string &filename, const bool apply_all_indicators_to_manifolds=false)
Definition grid_in.cc:3773
void read_dbmesh(std::istream &in)
Definition grid_in.cc:1225
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
Definition grid_in.cc:915
void read(std::istream &in, Format format=Default)
Definition grid_in.cc:4182
static void debug_output_grid(const std::vector< CellData< dim > > &cells, const std::vector< Point< spacedim > > &vertices, std::ostream &out)
Definition grid_in.cc:3994
static std::string get_format_names()
Definition grid_in.cc:4341
void read_unv(std::istream &in)
Definition grid_in.cc:615
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:2929
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:502
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:177
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
Point< 3 > vertices[4]
#define DeclException0(Exception0)
Definition exceptions.h:471
static ::ExceptionBase & ExcInvalidDBMeshFormat()
static ::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
static ::ExceptionBase & ExcInvalidGMSHInput(std::string arg1)
static ::ExceptionBase & ExcInvalidDBMESHInput(std::string arg1)
static ::ExceptionBase & ExcDBMESHWrongDimension(int arg1)
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2)
static ::ExceptionBase & ExcNoTriangulationSelected()
#define DeclException2(Exception2, type1, type2, outsequence)
Definition exceptions.h:539
static ::ExceptionBase & ExcUnknownElementType(int arg1)
static ::ExceptionBase & ExcGmshNoCellInformation(unsigned int arg1, unsigned int arg2)
static ::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
#define DeclExceptionMsg(Exception, defaulttext)
Definition exceptions.h:494
static ::ExceptionBase & ExcUnknownSectionType(int arg1)
#define DeclException3(Exception3, type1, type2, type3, outsequence)
Definition exceptions.h:562
#define DeclException1(Exception1, type1, outsequence)
Definition exceptions.h:516
static ::ExceptionBase & ExcGmshUnsupportedGeometry(int arg1)
static const unsigned int invalid_unsigned_int
Definition types.h:220
std::vector< std::vector< int > > id_to_sideset_ids
Definition grid_in.h:688