24#include <boost/algorithm/string.hpp>
25#include <boost/archive/binary_iarchive.hpp>
26#include <boost/io/ios_state.hpp>
27#include <boost/property_tree/ptree.hpp>
28#include <boost/property_tree/xml_parser.hpp>
29#include <boost/serialization/serialization.hpp>
31#ifdef DEAL_II_GMSH_WITH_API
42#ifdef DEAL_II_WITH_ASSIMP
43# include <assimp/Importer.hpp>
44# include <assimp/postprocess.h>
45# include <assimp/scene.h>
48#ifdef DEAL_II_TRILINOS_WITH_SEACAS
75 template <
int spacedim>
77 assign_1d_boundary_ids(
84 if (cell->face(face_no)->at_boundary())
85 for (const auto &pair : boundary_ids)
86 if (cell->face(face_no)->vertex(0) == pair.
first)
88 cell->face(face_no)->set_boundary_id(pair.second);
94 template <
int dim,
int spacedim>
96 assign_1d_boundary_ids(
108 template <
int dim,
int spacedim>
116 const auto n_hypercube_vertices =
118 bool is_only_hypercube =
true;
120 if (cell.
vertices.size() != n_hypercube_vertices)
122 is_only_hypercube =
false;
130 if (is_only_hypercube)
135template <
int dim,
int spacedim>
137 : tria(nullptr, typeid(*this).name())
138 , default_format(ucd)
143template <
int dim,
int spacedim>
145 : tria(&t, typeid(*this).name())
146 , default_format(ucd)
151template <
int dim,
int spacedim>
160template <
int dim,
int spacedim>
172 text[0] =
"# vtk DataFile Version 3.0";
175 text[3] =
"DATASET UNSTRUCTURED_GRID";
177 for (
unsigned int i = 0; i < 4; ++i)
182 line.compare(text[i]) == 0,
185 "While reading VTK file, failed to find a header line with text <") +
192 std::vector<Point<spacedim>>
vertices;
193 std::vector<CellData<dim>> cells;
202 if (keyword ==
"POINTS")
204 unsigned int n_vertices;
209 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
213 in >> x[0] >> x[1] >> x[2];
216 for (
unsigned int d = 0; d < spacedim; ++d)
224 "While reading VTK file, failed to find POINTS section"));
228 unsigned int n_geometric_objects = 0;
231 if (keyword ==
"CELLS")
234 std::vector<unsigned int> cell_types;
236 std::streampos oldpos = in.tellg();
239 while (in >> keyword)
240 if (keyword ==
"CELL_TYPES")
244 cell_types.resize(n_ints);
246 for (
unsigned int i = 0; i < n_ints; ++i)
255 in >> n_geometric_objects;
260 for (
unsigned int count = 0; count < n_geometric_objects; ++count)
262 unsigned int n_vertices;
266 if (cell_types[count] == 10 || cell_types[count] == 12)
274 cells.emplace_back(n_vertices);
276 for (
unsigned int j = 0; j < n_vertices;
278 in >> cells.back().vertices[j];
282 if (cell_types[count] == 12)
284 std::swap(cells.back().vertices[2],
285 cells.back().vertices[3]);
286 std::swap(cells.back().vertices[6],
287 cells.back().vertices[7]);
290 cells.back().material_id = 0;
293 else if (cell_types[count] == 5 || cell_types[count] == 9)
302 for (
unsigned int j = 0; j < n_vertices;
309 else if (cell_types[count] == 3)
313 for (
unsigned int j = 0; j < n_vertices;
324 "While reading VTK file, unknown cell type encountered"));
329 for (
unsigned int count = 0; count < n_geometric_objects; ++count)
331 unsigned int n_vertices;
335 if (cell_types[count] == 5 || cell_types[count] == 9)
342 cells.emplace_back(n_vertices);
344 for (
unsigned int j = 0; j < n_vertices;
346 in >> cells.back().vertices[j];
350 if (cell_types[count] == 9)
354 std::swap(cells.back().vertices[2],
355 cells.back().vertices[3]);
358 cells.back().material_id = 0;
361 else if (cell_types[count] == 3)
367 for (
unsigned int j = 0; j < n_vertices;
380 "While reading VTK file, unknown cell type encountered"));
385 for (
unsigned int count = 0; count < n_geometric_objects; ++count)
391 cell_types[count] == 3 && type == 2,
393 "While reading VTK file, unknown cell type encountered"));
394 cells.emplace_back(type);
396 for (
unsigned int j = 0; j < type; ++j)
397 in >> cells.back().vertices[j];
399 cells.back().material_id = 0;
405 "While reading VTK file, failed to find CELLS section"));
412 keyword ==
"CELL_TYPES",
414 "While reading VTK file, missing CELL_TYPES section. Found <" +
415 keyword +
"> instead.")));
419 n_ints == n_geometric_objects,
420 ExcMessage(
"The VTK reader found a CELL_DATA statement "
421 "that lists a total of " +
423 " cell data objects, but this needs to "
424 "equal the number of cells (which is " +
426 ") plus the number of quads (" +
428 " in 3d or the number of lines (" +
433 for (
unsigned int i = 0; i < n_ints; ++i)
437 while (in >> keyword)
438 if (keyword ==
"CELL_DATA")
444 ExcMessage(
"The VTK reader found a CELL_DATA statement "
445 "that lists a total of " +
447 " cell data objects, but this needs to "
448 "equal the number of cells (which is " +
450 ") plus the number of quads (" +
453 " in 3d or the number of lines (" +
458 const std::vector<std::string> data_sets{
"MaterialID",
461 for (
unsigned int i = 0; i < data_sets.size(); ++i)
464 while (in >> keyword)
465 if (keyword ==
"SCALARS")
470 std::string field_name;
472 if (std::find(data_sets.begin(),
474 field_name) == data_sets.end())
486 std::getline(in, line);
489 std::min(
static_cast<std::size_t
>(3),
490 line.size() - 1)) ==
"int",
492 "While reading VTK file, material- and manifold IDs can only have type 'int'."));
496 keyword ==
"LOOKUP_TABLE",
498 "While reading VTK file, missing keyword 'LOOKUP_TABLE'."));
502 keyword ==
"default",
504 "While reading VTK file, missing keyword 'default'."));
511 for (
unsigned int i = 0; i < cells.size(); ++i)
515 if (field_name ==
"MaterialID")
516 cells[i].material_id =
518 else if (field_name ==
"ManifoldID")
519 cells[i].manifold_id =
531 if (field_name ==
"MaterialID")
532 boundary_quad.material_id =
534 else if (field_name ==
"ManifoldID")
535 boundary_quad.manifold_id =
544 if (field_name ==
"MaterialID")
545 boundary_line.material_id =
547 else if (field_name ==
"ManifoldID")
548 boundary_line.manifold_id =
560 if (field_name ==
"MaterialID")
561 boundary_line.material_id =
563 else if (field_name ==
"ManifoldID")
564 boundary_line.manifold_id =
574 apply_grid_fixup_functions(
vertices, cells, subcelldata);
575 tria->create_triangulation(
vertices, cells, subcelldata);
580 "While reading VTK file, failed to find CELLS section"));
585template <
int dim,
int spacedim>
589 namespace pt = boost::property_tree;
591 pt::read_xml(in, tree);
592 auto section = tree.get_optional<std::string>(
"VTKFile.dealiiData");
596 "While reading a VTU file, failed to find dealiiData section. "
597 "Notice that we can only read grid files in .vtu format that "
598 "were created by the deal.II library, using a call to "
599 "GridOut::write_vtu(), where the flag "
600 "GridOutFlags::Vtu::serialize_triangulation is set to true."));
604 const auto string_archive =
606 std::istringstream in_stream(string_archive);
607 boost::archive::binary_iarchive ia(in_stream);
612template <
int dim,
int spacedim>
616 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
620 skip_comment_lines(in,
'#');
631 "Expected '-1' before and after a section."));
643 std::getline(in, line);
645 boost::algorithm::trim(line);
646 if (line.compare(
"-1") == 0)
657 std::vector<Point<spacedim>>
vertices;
676 in >> dummy >> dummy >> dummy;
679 in >> x[0] >> x[1] >> x[2];
683 for (
unsigned int d = 0; d < spacedim; ++d)
698 AssertThrow(tmp == 2412, ExcUnknownSectionType(tmp));
700 std::vector<CellData<dim>> cells;
727 in >> type >> dummy >> dummy >> dummy >> dummy;
729 AssertThrow((type == 11) || (type == 44) || (type == 94) || (type == 115),
730 ExcUnknownElementType(type));
732 if ((((type == 44) || (type == 94)) && (dim == 2)) ||
733 ((type == 115) && (dim == 3)))
736 cells.emplace_back();
741 .vertices[reference_cell.unv_vertex_to_deal_vertex(v)];
743 cells.back().material_id = 0;
746 cells.back().vertices[v] =
vertex_indices[cells.back().vertices[v]];
748 cell_indices[object_index] = n_cells;
752 else if (((type == 11) && (dim == 2)) ||
753 ((type == 11) && (dim == 3)))
756 in >> dummy >> dummy >> dummy;
761 for (
unsigned int &vertex :
767 for (
unsigned int &vertex :
771 line_indices[object_index] = n_lines;
775 else if (((type == 44) || (type == 94)) && (dim == 3))
786 .vertices[reference_cell.unv_vertex_to_deal_vertex(v)];
790 for (
unsigned int &vertex :
794 quad_indices[object_index] = n_quads;
802 "> when running in dim=" +
821 AssertThrow((tmp == 2467) || (tmp == 2477), ExcUnknownSectionType(tmp));
837 in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >>
848 std::getline(in, line);
851 "The line before the line containing an ID has too "
852 "many entries. This is not a valid UNV file."));
854 std::getline(in, line);
856 std::istringstream id_stream(line);
859 !id_stream.fail() && id_stream.eof(),
861 "The given UNV file contains a boundary or material id set to '" +
863 "', which cannot be parsed as a fixed-width integer, whereas "
864 "deal.II only supports integer boundary and material ids. To fix "
865 "this, ensure that all such ids are given integer values."));
868 id <=
long(std::numeric_limits<types::material_id>::max()),
869 ExcMessage(
"The provided integer id '" + std::to_string(
id) +
870 "' is not convertible to either types::material_id nor "
871 "types::boundary_id."));
873 const unsigned int n_lines =
874 (n_entities % 2 == 0) ? (n_entities / 2) : ((n_entities + 1) / 2);
876 for (
unsigned int line = 0; line < n_lines; ++line)
878 unsigned int n_fragments;
880 if (line == n_lines - 1)
881 n_fragments = (n_entities % 2 == 0) ? (2) : (1);
885 for (
unsigned int no_fragment = 0; no_fragment < n_fragments;
889 in >> dummy >> no >> dummy >> dummy;
891 if (cell_indices.count(no) > 0)
892 cells[cell_indices[no]].material_id = id;
894 if (line_indices.count(no) > 0)
898 if (quad_indices.count(no) > 0)
906 apply_grid_fixup_functions(
vertices, cells, subcelldata);
907 tria->create_triangulation(
vertices, cells, subcelldata);
912template <
int dim,
int spacedim>
915 const bool apply_all_indicators_to_manifolds)
917 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
921 skip_comment_lines(in,
'#');
924 unsigned int n_vertices;
925 unsigned int n_cells;
928 in >> n_vertices >> n_cells >> dummy
934 std::vector<Point<spacedim>>
vertices(n_vertices);
940 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
947 in >> vertex_number >> x[0] >> x[1] >> x[2];
950 for (
unsigned int d = 0; d < spacedim; ++d)
959 std::vector<CellData<dim>> cells;
962 for (
unsigned int cell = 0; cell < n_cells; ++cell)
971 std::string cell_type;
975 unsigned int material_id;
981 if (((cell_type ==
"line") && (dim == 1)) ||
982 ((cell_type ==
"quad") && (dim == 2)) ||
983 ((cell_type ==
"hex") && (dim == 3)))
987 cells.emplace_back();
992 Assert(material_id <= std::numeric_limits<types::material_id>::max(),
995 std::numeric_limits<types::material_id>::max()));
1000 if (apply_all_indicators_to_manifolds)
1001 cells.back().manifold_id =
1003 cells.back().material_id = material_id;
1011 cells.back().vertices[i] =
1017 ExcInvalidVertexIndex(cell,
1018 cells.back().vertices[i]));
1023 else if ((cell_type ==
"line") && ((dim == 2) || (dim == 3)))
1031 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
1034 std::numeric_limits<types::boundary_id>::max()));
1043 if (apply_all_indicators_to_manifolds)
1060 for (
unsigned int &vertex :
1068 AssertThrow(
false, ExcInvalidVertexIndex(cell, vertex));
1072 else if ((cell_type ==
"quad") && (dim == 3))
1081 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
1084 std::numeric_limits<types::boundary_id>::max()));
1093 if (apply_all_indicators_to_manifolds)
1110 for (
unsigned int &vertex :
1118 Assert(
false, ExcInvalidVertexIndex(cell, vertex));
1124 AssertThrow(
false, ExcUnknownIdentifier(cell_type));
1129 apply_grid_fixup_functions(
vertices, cells, subcelldata);
1130 tria->create_triangulation(
vertices, cells, subcelldata);
1135 template <
int dim,
int spacedim>
1142 read_in_abaqus(std::istream &in);
1144 write_out_avs_ucd(std::ostream &out)
const;
1147 const double tolerance;
1150 get_global_node_numbers(
const int face_cell_no,
1151 const int face_cell_face_no)
const;
1154 std::vector<std::vector<double>> node_list;
1157 std::vector<std::vector<double>> cell_list;
1159 std::vector<std::vector<double>> face_list;
1162 std::map<std::string, std::vector<int>> elsets_list;
1166template <
int dim,
int spacedim>
1169 const bool apply_all_indicators_to_manifolds)
1171 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1176 Assert((spacedim == 2 && dim == spacedim) ||
1177 (spacedim == 3 && (dim == spacedim || dim == spacedim - 1)),
1183 Abaqus_to_UCD<dim, spacedim> abaqus_to_ucd;
1184 abaqus_to_ucd.read_in_abaqus(in);
1186 std::stringstream in_ucd;
1187 abaqus_to_ucd.write_out_avs_ucd(in_ucd);
1195 read_ucd(in_ucd, apply_all_indicators_to_manifolds);
1197 catch (std::exception &exc)
1199 std::cerr <<
"Exception on processing internal UCD data: " << std::endl
1200 << exc.what() << std::endl;
1205 "Internal conversion from ABAQUS file to UCD format was unsuccessful. "
1206 "More information is provided in an error message printed above. "
1207 "Are you sure that your ABAQUS mesh file conforms with the requirements "
1208 "listed in the documentation?"));
1215 "Internal conversion from ABAQUS file to UCD format was unsuccessful. "
1216 "Are you sure that your ABAQUS mesh file conforms with the requirements "
1217 "listed in the documentation?"));
1222template <
int dim,
int spacedim>
1226 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1232 skip_comment_lines(in,
'#');
1238 AssertThrow(line ==
"MeshVersionFormatted 0", ExcInvalidDBMESHInput(line));
1240 skip_empty_lines(in);
1244 AssertThrow(line ==
"Dimension", ExcInvalidDBMESHInput(line));
1245 unsigned int dimension;
1247 AssertThrow(dimension == dim, ExcDBMESHWrongDimension(dimension));
1248 skip_empty_lines(in);
1261 while (getline(in, line), line.find(
"# END") == std::string::npos)
1263 skip_empty_lines(in);
1268 AssertThrow(line ==
"Vertices", ExcInvalidDBMESHInput(line));
1270 unsigned int n_vertices;
1274 std::vector<Point<spacedim>>
vertices(n_vertices);
1275 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1278 for (
unsigned int d = 0; d < dim; ++d)
1285 skip_empty_lines(in);
1291 AssertThrow(line ==
"Edges", ExcInvalidDBMESHInput(line));
1293 unsigned int n_edges;
1295 for (
unsigned int edge = 0; edge < n_edges; ++edge)
1298 in >> dummy >> dummy;
1304 skip_empty_lines(in);
1313 AssertThrow(line ==
"CrackedEdges", ExcInvalidDBMESHInput(line));
1316 for (
unsigned int edge = 0; edge < n_edges; ++edge)
1319 in >> dummy >> dummy;
1325 skip_empty_lines(in);
1331 AssertThrow(line ==
"Quadrilaterals", ExcInvalidDBMESHInput(line));
1333 static constexpr std::array<unsigned int, 8> local_vertex_numbering = {
1334 {0, 1, 5, 4, 2, 3, 7, 6}};
1335 std::vector<CellData<dim>> cells;
1337 unsigned int n_cells;
1339 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1343 cells.emplace_back();
1347 cells.back().vertices[dim == 3 ? local_vertex_numbering[i] :
1351 (
static_cast<unsigned int>(cells.back().vertices[i]) <=
1353 ExcInvalidVertexIndex(cell, cells.back().vertices[i]));
1355 --cells.back().vertices[i];
1363 skip_empty_lines(in);
1371 while (getline(in, line), ((line.find(
"End") == std::string::npos) && (in)))
1377 apply_grid_fixup_functions(
vertices, cells, subcelldata);
1378 tria->create_triangulation(
vertices, cells, subcelldata);
1383template <
int dim,
int spacedim>
1387 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1394 std::getline(in, line);
1396 unsigned int n_vertices;
1397 unsigned int n_cells;
1401 std::getline(in, line);
1404 std::getline(in, line);
1407 for (
unsigned int i = 0; i < 8; ++i)
1408 std::getline(in, line);
1411 std::vector<CellData<dim>> cells(n_cells);
1422 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell; ++i)
1423 in >> cell.vertices[reference_cell.exodusii_vertex_to_deal_vertex(i)];
1427 std::vector<Point<spacedim>>
vertices(n_vertices);
1430 for (
unsigned int d = 0; d < spacedim; ++d)
1432 for (
unsigned int d = spacedim; d < 3; ++d)
1441 apply_grid_fixup_functions(
vertices, cells, subcelldata);
1442 tria->create_triangulation(
vertices, cells, subcelldata);
1447template <
int dim,
int spacedim>
1451 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1464 std::stringstream whole_file;
1469 std::getline(in, line);
1477 if ((line.size() > 0) && (line.back() ==
'\r'))
1478 line.erase(line.size() - 1);
1483 if (line.find(
'#') != std::string::npos)
1484 line.erase(line.find(
'#'), std::string::npos);
1485 while ((line.size() > 0) && (line.back() ==
' '))
1486 line.erase(line.size() - 1);
1488 if (line.size() > 0)
1489 whole_file <<
'\n' << line;
1508 unsigned int version_major, version_minor;
1509 whole_file >> version_major >> version_minor;
1510 AssertThrow((version_major == 0) && (version_minor == 1),
1511 ExcMessage(
"deal.II can currently only read version 0.1 "
1512 "of the mphtxt file format."));
1517 unsigned int n_tags;
1518 whole_file >> n_tags;
1519 for (
unsigned int i = 0; i < n_tags; ++i)
1522 while (whole_file.peek() ==
'\n')
1524 std::getline(whole_file, dummy);
1530 unsigned int n_types;
1531 whole_file >> n_types;
1532 for (
unsigned int i = 0; i < n_types; ++i)
1535 while (whole_file.peek() ==
'\n')
1537 std::getline(whole_file, dummy);
1557 whole_file >> dummy >> dummy >> dummy;
1561 while (whole_file.peek() ==
'\n')
1563 std::getline(whole_file, s);
1565 ExcMessage(
"Expected '4 Mesh', but got '" + s +
"'."));
1568 unsigned int version;
1569 whole_file >> version;
1573 unsigned int file_space_dim;
1574 whole_file >> file_space_dim;
1578 "The mesh file uses a different number of space dimensions "
1579 "than the triangulation you want to read it into."));
1581 unsigned int n_vertices;
1582 whole_file >> n_vertices;
1584 unsigned int starting_vertex_index;
1585 whole_file >> starting_vertex_index;
1587 std::vector<Point<spacedim>>
vertices(n_vertices);
1588 for (
unsigned int v = 0; v < n_vertices; ++v)
1619 std::vector<CellData<dim>> cells;
1622 unsigned int n_types;
1623 whole_file >> n_types;
1624 for (
unsigned int type = 0; type < n_types; ++type)
1631 whole_file >> dummy;
1635 std::string object_name;
1636 whole_file >> object_name;
1638 static const std::map<std::string, ReferenceCell> name_to_type = {
1648 AssertThrow(name_to_type.find(object_name) != name_to_type.end(),
1649 ExcMessage(
"The input file contains a cell type <" +
1651 "> that the reader does not "
1652 "current support"));
1653 const ReferenceCell object_type = name_to_type.at(object_name);
1655 unsigned int n_vertices_per_element;
1656 whole_file >> n_vertices_per_element;
1658 unsigned int n_elements;
1659 whole_file >> n_elements;
1673 ExcMessage(
"Triangles should not appear in input files "
1681 "Quadrilaterals should not appear in input files "
1688 ExcMessage(
"Tetrahedra should not appear in input files "
1689 "for 1d or 2d meshes."));
1696 "Prisms (wedges) should not appear in input files "
1697 "for 1d or 2d meshes."));
1716 std::vector<unsigned int> vertices_for_this_element(
1717 n_vertices_per_element);
1718 for (
unsigned int e = 0; e < n_elements; ++e)
1721 for (
unsigned int v = 0; v < n_vertices_per_element; ++v)
1723 whole_file >> vertices_for_this_element[v];
1724 vertices_for_this_element[v] -= starting_vertex_index;
1733 cells.emplace_back();
1734 cells.back().vertices = vertices_for_this_element;
1740 vertices_for_this_element;
1748 cells.emplace_back();
1749 cells.back().vertices = vertices_for_this_element;
1755 vertices_for_this_element;
1763 cells.emplace_back();
1764 cells.back().vertices = vertices_for_this_element;
1777 unsigned int n_geom_entity_indices;
1778 whole_file >> n_geom_entity_indices;
1780 (n_geom_entity_indices == n_elements),
1787 if (n_geom_entity_indices != 0)
1789 for (
unsigned int e = 0; e < n_geom_entity_indices; ++e)
1792 unsigned int geometric_entity_index;
1793 whole_file >> geometric_entity_index;
1799 cells[cells.size() - n_elements + e].material_id =
1800 geometric_entity_index;
1805 .boundary_id = geometric_entity_index;
1811 cells[cells.size() - n_elements + e].material_id =
1812 geometric_entity_index;
1817 .boundary_id = geometric_entity_index;
1823 cells[cells.size() - n_elements + e].material_id =
1824 geometric_entity_index;
1840 tria->create_triangulation(
vertices, cells, {});
1850 if (line.vertices[1] < line.vertices[0])
1851 std::swap(line.vertices[0], line.vertices[1]);
1856 return std::lexicographical_compare(a.vertices.begin(),
1878 Assert((face.vertices.size() == 3) || (face.vertices.size() == 4),
1880 std::sort(face.vertices.begin(), face.vertices.end());
1885 return std::lexicographical_compare(a.vertices.begin(),
1895 for (
const auto &cell : tria->active_cell_iterators())
1896 for (
const auto &face : cell->face_iterators())
1897 if (face->at_boundary())
1903 std::array<unsigned int, 2> face_vertex_indices = {
1904 {face->vertex_index(0), face->vertex_index(1)}};
1905 if (face_vertex_indices[0] > face_vertex_indices[1])
1906 std::swap(face_vertex_indices[0], face_vertex_indices[1]);
1912 face_vertex_indices,
1914 const std::array<unsigned int, 2>
1915 &face_vertex_indices) ->
bool {
1916 return std::lexicographical_compare(
1919 face_vertex_indices.begin(),
1920 face_vertex_indices.end());
1924 (p->vertices[0] == face_vertex_indices[0]) &&
1925 (p->vertices[1] == face_vertex_indices[1]))
1927 face->set_boundary_id(p->boundary_id);
1935 std::vector<unsigned int> face_vertex_indices(
1936 face->n_vertices());
1937 for (
unsigned int v = 0; v < face->n_vertices(); ++v)
1938 face_vertex_indices[v] = face->vertex_index(v);
1939 std::sort(face_vertex_indices.begin(),
1940 face_vertex_indices.end());
1946 face_vertex_indices,
1948 const std::vector<unsigned int>
1949 &face_vertex_indices) ->
bool {
1950 return std::lexicographical_compare(
1953 face_vertex_indices.begin(),
1954 face_vertex_indices.end());
1958 (p->vertices == face_vertex_indices))
1960 face->set_boundary_id(p->boundary_id);
1965 for (
unsigned int e = 0; e < face->n_lines(); ++e)
1967 const auto edge = face->line(e);
1969 std::array<unsigned int, 2> edge_vertex_indices = {
1970 {edge->vertex_index(0), edge->vertex_index(1)}};
1971 if (edge_vertex_indices[0] > edge_vertex_indices[1])
1972 std::swap(edge_vertex_indices[0],
1973 edge_vertex_indices[1]);
1979 edge_vertex_indices,
1981 const std::array<unsigned int, 2>
1982 &edge_vertex_indices) ->
bool {
1983 return std::lexicographical_compare(
1986 edge_vertex_indices.begin(),
1987 edge_vertex_indices.end());
1991 (p->vertices[0] == edge_vertex_indices[0]) &&
1992 (p->vertices[1] == edge_vertex_indices[1]))
1994 edge->set_boundary_id(p->boundary_id);
2003template <
int dim,
int spacedim>
2007 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
2010 unsigned int n_vertices;
2011 unsigned int n_cells;
2017 std::array<std::map<int, int>, 4> tag_maps;
2022 unsigned int gmsh_file_format = 0;
2023 if (line ==
"@f$NOD")
2024 gmsh_file_format = 10;
2025 else if (line ==
"@f$MeshFormat")
2026 gmsh_file_format = 20;
2032 if (gmsh_file_format == 20)
2035 unsigned int file_type, data_size;
2037 in >> version >> file_type >> data_size;
2040 gmsh_file_format =
static_cast<unsigned int>(version * 10);
2048 AssertThrow(line ==
"@f$EndMeshFormat", ExcInvalidGMSHInput(line));
2052 if (line ==
"@f$PhysicalNames")
2058 while (line !=
"@f$EndPhysicalNames");
2063 if (line ==
"@f$Entities")
2065 unsigned long n_points, n_curves, n_surfaces, n_volumes;
2067 in >> n_points >> n_curves >> n_surfaces >> n_volumes;
2068 for (
unsigned int i = 0; i < n_points; ++i)
2072 unsigned int n_physicals;
2073 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2077 if (gmsh_file_format > 40)
2079 in >> tag >> box_min_x >> box_min_y >> box_min_z >>
2081 box_max_x = box_min_x;
2082 box_max_y = box_min_y;
2083 box_max_z = box_min_z;
2087 in >> tag >> box_min_x >> box_min_y >> box_min_z >>
2088 box_max_x >> box_max_y >> box_max_z >> n_physicals;
2093 ExcMessage(
"More than one tag is not supported!"));
2095 int physical_tag = 0;
2096 for (
unsigned int j = 0; j < n_physicals; ++j)
2098 tag_maps[0][tag] = physical_tag;
2100 for (
unsigned int i = 0; i < n_curves; ++i)
2104 unsigned int n_physicals;
2105 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2109 in >> tag >> box_min_x >> box_min_y >> box_min_z >> box_max_x >>
2110 box_max_y >> box_max_z >> n_physicals;
2114 ExcMessage(
"More than one tag is not supported!"));
2116 int physical_tag = 0;
2117 for (
unsigned int j = 0; j < n_physicals; ++j)
2119 tag_maps[1][tag] = physical_tag;
2124 for (
unsigned int j = 0; j < n_points; ++j)
2128 for (
unsigned int i = 0; i < n_surfaces; ++i)
2132 unsigned int n_physicals;
2133 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2137 in >> tag >> box_min_x >> box_min_y >> box_min_z >> box_max_x >>
2138 box_max_y >> box_max_z >> n_physicals;
2142 ExcMessage(
"More than one tag is not supported!"));
2144 int physical_tag = 0;
2145 for (
unsigned int j = 0; j < n_physicals; ++j)
2147 tag_maps[2][tag] = physical_tag;
2152 for (
unsigned int j = 0; j < n_curves; ++j)
2155 for (
unsigned int i = 0; i < n_volumes; ++i)
2159 unsigned int n_physicals;
2160 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2164 in >> tag >> box_min_x >> box_min_y >> box_min_z >> box_max_x >>
2165 box_max_y >> box_max_z >> n_physicals;
2169 ExcMessage(
"More than one tag is not supported!"));
2171 int physical_tag = 0;
2172 for (
unsigned int j = 0; j < n_physicals; ++j)
2174 tag_maps[3][tag] = physical_tag;
2179 for (
unsigned int j = 0; j < n_surfaces; ++j)
2183 AssertThrow(line ==
"@f$EndEntities", ExcInvalidGMSHInput(line));
2188 if (line ==
"@f$PartitionedEntities")
2194 while (line !=
"@f$EndPartitionedEntities");
2201 AssertThrow(line ==
"@f$Nodes", ExcInvalidGMSHInput(line));
2205 int n_entity_blocks = 1;
2206 if (gmsh_file_format > 40)
2210 in >> n_entity_blocks >> n_vertices >> min_node_tag >> max_node_tag;
2212 else if (gmsh_file_format == 40)
2214 in >> n_entity_blocks >> n_vertices;
2218 std::vector<Point<spacedim>>
vertices(n_vertices);
2225 unsigned int global_vertex = 0;
2226 for (
int entity_block = 0; entity_block < n_entity_blocks; ++entity_block)
2229 unsigned long numNodes;
2231 if (gmsh_file_format < 40)
2233 numNodes = n_vertices;
2240 int tagEntity, dimEntity;
2241 in >> tagEntity >> dimEntity >> parametric >> numNodes;
2244 std::vector<int> vertex_numbers;
2246 if (gmsh_file_format > 40)
2247 for (
unsigned long vertex_per_entity = 0;
2248 vertex_per_entity < numNodes;
2249 ++vertex_per_entity)
2251 in >> vertex_number;
2252 vertex_numbers.push_back(vertex_number);
2255 for (
unsigned long vertex_per_entity = 0; vertex_per_entity < numNodes;
2256 ++vertex_per_entity, ++global_vertex)
2262 if (gmsh_file_format > 40)
2264 vertex_number = vertex_numbers[vertex_per_entity];
2265 in >> x[0] >> x[1] >> x[2];
2268 in >> vertex_number >> x[0] >> x[1] >> x[2];
2270 for (
unsigned int d = 0; d < spacedim; ++d)
2276 if (parametric != 0)
2291 static const std::string end_nodes_marker[] = {
"@f$ENDNOD",
"@f$EndNodes"};
2292 AssertThrow(line == end_nodes_marker[gmsh_file_format == 10 ? 0 : 1],
2293 ExcInvalidGMSHInput(line));
2297 static const std::string begin_elements_marker[] = {
"@f$ELM",
"@f$Elements"};
2298 AssertThrow(line == begin_elements_marker[gmsh_file_format == 10 ? 0 : 1],
2299 ExcInvalidGMSHInput(line));
2302 if (gmsh_file_format > 40)
2306 in >> n_entity_blocks >> n_cells >> min_node_tag >> max_node_tag;
2308 else if (gmsh_file_format == 40)
2310 in >> n_entity_blocks >> n_cells;
2314 n_entity_blocks = 1;
2321 std::vector<CellData<dim>> cells;
2323 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
2329 std::map<unsigned int, unsigned int> vertex_counts;
2332 static constexpr std::array<unsigned int, 8> local_vertex_numbering = {
2333 {0, 1, 5, 4, 2, 3, 7, 6}};
2334 unsigned int global_cell = 0;
2335 for (
int entity_block = 0; entity_block < n_entity_blocks; ++entity_block)
2337 unsigned int material_id;
2338 unsigned long numElements;
2341 if (gmsh_file_format < 40)
2345 numElements = n_cells;
2347 else if (gmsh_file_format == 40)
2349 int tagEntity, dimEntity;
2350 in >> tagEntity >> dimEntity >> cell_type >> numElements;
2351 material_id = tag_maps[dimEntity][tagEntity];
2356 int tagEntity, dimEntity;
2357 in >> dimEntity >> tagEntity >> cell_type >> numElements;
2358 material_id = tag_maps[dimEntity][tagEntity];
2361 for (
unsigned int cell_per_entity = 0; cell_per_entity < numElements;
2362 ++cell_per_entity, ++global_cell)
2371 unsigned int nod_num;
2392 unsigned int elm_number = 0;
2393 if (gmsh_file_format < 40)
2399 if (gmsh_file_format < 20)
2405 else if (gmsh_file_format < 40)
2410 unsigned int n_tags;
2417 for (
unsigned int i = 1; i < n_tags; ++i)
2422 else if (cell_type == 2)
2424 else if (cell_type == 3)
2426 else if (cell_type == 4)
2428 else if (cell_type == 5)
2439 else if (cell_type == 2)
2441 else if (cell_type == 3)
2443 else if (cell_type == 4)
2445 else if (cell_type == 5)
2471 if (((cell_type == 1) && (dim == 1)) ||
2472 ((cell_type == 2) && (dim == 2)) ||
2473 ((cell_type == 3) && (dim == 2)) ||
2474 ((cell_type == 4) && (dim == 3)) ||
2475 ((cell_type == 5) && (dim == 3)))
2478 unsigned int vertices_per_cell = 0;
2480 vertices_per_cell = 2;
2481 else if (cell_type == 2)
2482 vertices_per_cell = 3;
2483 else if (cell_type == 3)
2484 vertices_per_cell = 4;
2485 else if (cell_type == 4)
2486 vertices_per_cell = 4;
2487 else if (cell_type == 5)
2488 vertices_per_cell = 8;
2492 "Number of nodes does not coincide with the "
2493 "number required for this object"));
2496 cells.emplace_back();
2498 cell.
vertices.resize(vertices_per_cell);
2499 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
2502 if (vertices_per_cell ==
2505 local_vertex_numbering[i] :
2513 std::numeric_limits<types::material_id>::max(),
2517 std::numeric_limits<types::material_id>::max()));
2525 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
2529 ExcInvalidVertexIndexGmsh(cell_per_entity,
2535 vertex_counts[vertex] += 1u;
2539 else if ((cell_type == 1) &&
2540 ((dim == 2) || (dim == 3)))
2549 std::numeric_limits<types::boundary_id>::max(),
2553 std::numeric_limits<types::boundary_id>::max()));
2564 for (
unsigned int &vertex :
2573 ExcInvalidVertexIndex(cell_per_entity,
2578 else if ((cell_type == 2 || cell_type == 3) &&
2582 unsigned int vertices_per_cell = 0;
2585 vertices_per_cell = 3;
2586 else if (cell_type == 3)
2587 vertices_per_cell = 4;
2595 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
2600 std::numeric_limits<types::boundary_id>::max(),
2604 std::numeric_limits<types::boundary_id>::max()));
2615 for (
unsigned int &vertex :
2624 ExcInvalidVertexIndex(cell_per_entity, vertex));
2628 else if (cell_type == 15)
2631 unsigned int node_index = 0;
2632 if (gmsh_file_format < 20)
2652 AssertThrow(
false, ExcGmshUnsupportedGeometry(cell_type));
2660 static const std::string end_elements_marker[] = {
"@f$ENDELM",
"@f$EndElements"};
2661 AssertThrow(line == end_elements_marker[gmsh_file_format == 10 ? 0 : 1],
2662 ExcInvalidGMSHInput(line));
2675 for (
const auto &pair : vertex_counts)
2676 if (pair.second == 1u)
2677 boundary_id_pairs.emplace_back(
vertices[pair.first],
2678 boundary_ids_1d[pair.first]);
2680 apply_grid_fixup_functions(
vertices, cells, subcelldata);
2681 tria->create_triangulation(
vertices, cells, subcelldata);
2686 assign_1d_boundary_ids(boundary_id_pairs, *tria);
2691#ifdef DEAL_II_GMSH_WITH_API
2692template <
int dim,
int spacedim>
2696 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
2698 const std::map<int, std::uint8_t> gmsh_to_dealii_type = {
2699 {{15, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {7, 5}, {6, 6}, {5, 7}}};
2702 const std::array<std::vector<unsigned int>, 8> gmsh_to_dealii = {
2709 {{0, 1, 2, 3, 4, 5}},
2710 {{0, 1, 3, 2, 4, 5, 7, 6}}}};
2712 std::vector<Point<spacedim>>
vertices;
2713 std::vector<CellData<dim>> cells;
2715 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
2721 std::map<unsigned int, unsigned int> vertex_counts;
2724 gmsh::option::setNumber(
"General.Verbosity", 0);
2728 ExcMessage(
"You are trying to read a gmsh file with dimension " +
2729 std::to_string(gmsh::model::getDimension()) +
2730 " into a grid of dimension " + std::to_string(dim)));
2735 gmsh::model::mesh::removeDuplicateNodes();
2736 gmsh::model::mesh::renumberNodes();
2737 std::vector<std::size_t> node_tags;
2738 std::vector<double> coord;
2739 std::vector<double> parametricCoord;
2740 gmsh::model::mesh::getNodes(
2741 node_tags, coord, parametricCoord, -1, -1,
false,
false);
2743 for (
unsigned int i = 0; i < node_tags.size(); ++i)
2747 for (
unsigned int d = 0; d < spacedim; ++d)
2751 for (
unsigned int d = spacedim; d < 3; ++d)
2753 ExcMessage(
"The grid you are reading contains nodes that are "
2754 "nonzero in the coordinate with index " +
2756 ", but you are trying to save "
2757 "it on a grid embedded in a " +
2758 std::to_string(spacedim) +
" dimensional space."));
2765 std::vector<std::pair<int, int>> entities;
2766 gmsh::model::getEntities(entities);
2768 for (
const auto &e : entities)
2771 const int &entity_dim = e.first;
2772 const int &entity_tag = e.second;
2778 std::vector<int> physical_tags;
2779 gmsh::model::getPhysicalGroupsForEntity(entity_dim,
2784 if (physical_tags.size())
2785 for (
auto physical_tag : physical_tags)
2788 gmsh::model::getPhysicalName(entity_dim, physical_tag, name);
2795 std::map<std::string, int> id_names;
2797 bool found_unrecognized_tag =
false;
2798 bool found_boundary_id =
false;
2801 for (
const auto &it : id_names)
2803 const auto &name = it.first;
2804 const auto &
id = it.second;
2805 if (entity_dim == dim && name ==
"MaterialID")
2808 found_boundary_id =
true;
2810 else if (entity_dim < dim && name ==
"BoundaryID")
2813 found_boundary_id =
true;
2815 else if (name ==
"ManifoldID")
2821 found_unrecognized_tag =
true;
2826 if (found_unrecognized_tag && !found_boundary_id)
2827 boundary_id = physical_tag;
2835 boundary_id = physical_tag;
2841 std::vector<int> element_types;
2842 std::vector<std::vector<std::size_t>> element_ids, element_nodes;
2843 gmsh::model::mesh::getElements(
2844 element_types, element_ids, element_nodes, entity_dim, entity_tag);
2846 for (
unsigned int i = 0; i < element_types.size(); ++i)
2848 const auto &type = gmsh_to_dealii_type.at(element_types[i]);
2849 const auto n_vertices = gmsh_to_dealii[type].size();
2850 const auto &elements = element_ids[i];
2851 const auto &nodes = element_nodes[i];
2852 for (
unsigned int j = 0; j < elements.size(); ++j)
2854 if (entity_dim == dim)
2856 cells.emplace_back(n_vertices);
2857 auto &cell = cells.back();
2858 for (
unsigned int v = 0; v < n_vertices; ++v)
2861 nodes[n_vertices * j + gmsh_to_dealii[type][v]] - 1;
2863 vertex_counts[cell.vertices[v]] += 1u;
2865 cell.manifold_id = manifold_id;
2866 cell.material_id = boundary_id;
2868 else if (entity_dim == 2)
2872 for (
unsigned int v = 0; v < n_vertices; ++v)
2874 nodes[n_vertices * j + gmsh_to_dealii[type][v]] - 1;
2876 face.manifold_id = manifold_id;
2877 face.boundary_id = boundary_id;
2879 else if (entity_dim == 1)
2883 for (
unsigned int v = 0; v < n_vertices; ++v)
2885 nodes[n_vertices * j + gmsh_to_dealii[type][v]] - 1;
2887 line.manifold_id = manifold_id;
2888 line.boundary_id = boundary_id;
2890 else if (entity_dim == 0)
2894 for (
unsigned int j = 0; j < elements.size(); ++j)
2895 boundary_ids_1d[nodes[j] - 1] = boundary_id;
2906 for (
const auto &pair : vertex_counts)
2907 if (pair.second == 1u)
2908 boundary_id_pairs.emplace_back(
vertices[pair.first],
2909 boundary_ids_1d[pair.first]);
2911 apply_grid_fixup_functions(
vertices, cells, subcelldata);
2912 tria->create_triangulation(
vertices, cells, subcelldata);
2917 assign_1d_boundary_ids(boundary_id_pairs, *tria);
2926template <
int dim,
int spacedim>
2929 std::string &header,
2930 std::vector<unsigned int> &tecplot2deal,
2931 unsigned int &n_vars,
2932 unsigned int &n_vertices,
2933 unsigned int &n_cells,
2934 std::vector<unsigned int> &IJK,
2959 std::transform(header.begin(), header.end(), header.begin(), ::toupper);
2963 std::replace(header.begin(), header.end(),
'\t',
' ');
2964 std::replace(header.begin(), header.end(),
',',
' ');
2965 std::replace(header.begin(), header.end(),
'\n',
' ');
2969 std::string::size_type pos = header.find(
'=');
2971 while (pos !=
static_cast<std::string::size_type
>(std::string::npos))
2972 if (header[pos + 1] ==
' ')
2973 header.erase(pos + 1, 1);
2974 else if (header[pos - 1] ==
' ')
2976 header.erase(pos - 1, 1);
2980 pos = header.find(
'=', ++pos);
2983 std::vector<std::string> entries =
2987 for (
unsigned int i = 0; i < entries.size(); ++i)
2996 tecplot2deal[0] = 0;
2999 while (entries[i][0] ==
'"')
3001 if (entries[i] ==
"\"X\"")
3002 tecplot2deal[0] = n_vars;
3003 else if (entries[i] ==
"\"Y\"")
3009 tecplot2deal[1] = n_vars;
3011 else if (entries[i] ==
"\"Z\"")
3017 tecplot2deal[2] = n_vars;
3029 "Tecplot file must contain at least one variable for each dimension"));
3030 for (
unsigned int d = 1; d < dim; ++d)
3032 tecplot2deal[d] > 0,
3034 "Tecplot file must contain at least one variable for each dimension."));
3039 "ZONETYPE=FELINESEG") &&
3043 "ZONETYPE=FEQUADRILATERAL") &&
3047 "ZONETYPE=FEBRICK") &&
3055 "The tecplot file contains an unsupported ZONETYPE."));
3058 "DATAPACKING=POINT"))
3061 "DATAPACKING=BLOCK"))
3084 "ET=QUADRILATERAL") &&
3096 "The tecplot file contains an unsupported ElementType."));
3104 dim > 1 || IJK[1] == 1,
3106 "Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1."));
3112 dim > 2 || IJK[2] == 1,
3114 "Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2."));
3129 for (
unsigned int d = 0; d < dim; ++d)
3134 "Tecplot file does not contain a complete and consistent set of parameters"));
3135 n_vertices *= IJK[d];
3136 n_cells *= (IJK[d] - 1);
3144 "Tecplot file does not contain a complete and consistent set of parameters"));
3150 n_cells = *std::max_element(IJK.begin(), IJK.end());
3154 "Tecplot file does not contain a complete and consistent set of parameters"));
3164 const unsigned int dim = 2;
3165 const unsigned int spacedim = 2;
3166 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
3170 skip_comment_lines(in,
'#');
3173 std::string line, header;
3180 std::string letters =
"abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ";
3183 while (line.find_first_of(letters) != std::string::npos)
3185 header +=
" " + line;
3192 std::vector<unsigned int> tecplot2deal(dim);
3193 std::vector<unsigned int> IJK(dim);
3194 unsigned int n_vars, n_vertices, n_cells;
3195 bool structured, blocked;
3197 parse_tecplot_header(header,
3212 std::vector<Point<spacedim>>
vertices(n_vertices + 1);
3215 std::vector<CellData<dim>> cells(n_cells);
3231 unsigned int next_index = 0;
3235 if (tecplot2deal[0] == 0)
3239 std::vector<std::string> first_var =
3242 for (
unsigned int i = 1; i < first_var.size() + 1; ++i)
3243 vertices[i][0] = std::strtod(first_var[i - 1].c_str(), &endptr);
3248 for (
unsigned int j = first_var.size() + 1; j < n_vertices + 1; ++j)
3256 for (
unsigned int i = 1; i < n_vars; ++i)
3265 if (next_index == dim && structured)
3268 if ((next_index < dim) && (i == tecplot2deal[next_index]))
3271 for (
unsigned int j = 1; j < n_vertices + 1; ++j)
3279 for (
unsigned int j = 1; j < n_vertices + 1; ++j)
3291 std::vector<double> vars(n_vars);
3296 std::vector<std::string> first_vertex =
3299 for (
unsigned int d = 0; d < dim; ++d)
3301 std::strtod(first_vertex[tecplot2deal[d]].c_str(), &endptr);
3305 for (
unsigned int v = 2; v < n_vertices + 1; ++v)
3307 for (
unsigned int i = 0; i < n_vars; ++i)
3313 for (
unsigned int i = 0; i < dim; ++i)
3314 vertices[v][i] = vars[tecplot2deal[i]];
3322 unsigned int I = IJK[0], J = IJK[1];
3324 unsigned int cell = 0;
3326 for (
unsigned int j = 0; j < J - 1; ++j)
3327 for (
unsigned int i = 1; i < I; ++i)
3329 cells[cell].vertices[0] = i + j * I;
3330 cells[cell].vertices[1] = i + 1 + j * I;
3331 cells[cell].vertices[2] = i + (j + 1) * I;
3332 cells[cell].vertices[3] = i + 1 + (j + 1) * I;
3336 std::vector<unsigned int> boundary_vertices(2 * I + 2 * J - 4);
3338 for (
unsigned int i = 1; i < I + 1; ++i)
3340 boundary_vertices[k] = i;
3342 boundary_vertices[k] = i + (J - 1) * I;
3345 for (
unsigned int j = 1; j < J - 1; ++j)
3347 boundary_vertices[k] = 1 + j * I;
3349 boundary_vertices[k] = I + j * I;
3368 for (
unsigned int i = 0; i < n_cells; ++i)
3385 apply_grid_fixup_functions(
vertices, cells, subcelldata);
3386 tria->create_triangulation(
vertices, cells, subcelldata);
3391template <
int dim,
int spacedim>
3400template <
int dim,
int spacedim>
3403 const unsigned int mesh_index,
3404 const bool remove_duplicates,
3406 const bool ignore_unsupported_types)
3408#ifdef DEAL_II_WITH_ASSIMP
3413 Assimp::Importer importer;
3416 const aiScene *scene =
3417 importer.ReadFile(filename.c_str(),
3418 aiProcess_RemoveComponent |
3419 aiProcess_JoinIdenticalVertices |
3420 aiProcess_ImproveCacheLocality | aiProcess_SortByPType |
3421 aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);
3427 ExcMessage(
"Input file contains no meshes."));
3430 (mesh_index < scene->mNumMeshes),
3433 unsigned int start_mesh =
3435 unsigned int end_mesh =
3440 std::vector<Point<spacedim>>
vertices;
3441 std::vector<CellData<dim>> cells;
3445 unsigned int v_offset = 0;
3446 unsigned int c_offset = 0;
3448 static constexpr std::array<unsigned int, 8> local_vertex_numbering = {
3449 {0, 1, 5, 4, 2, 3, 7, 6}};
3451 for (
unsigned int m = start_mesh; m < end_mesh; ++m)
3453 const aiMesh *mesh = scene->mMeshes[m];
3457 if ((dim == 2) && mesh->mPrimitiveTypes != aiPrimitiveType_POLYGON)
3460 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
3461 "/" + std::to_string(scene->mNumMeshes)));
3464 else if ((dim == 1) && mesh->mPrimitiveTypes != aiPrimitiveType_LINE)
3467 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
3468 "/" + std::to_string(scene->mNumMeshes)));
3472 const unsigned int n_vertices = mesh->mNumVertices;
3473 const aiVector3D *mVertices = mesh->mVertices;
3476 const unsigned int n_faces = mesh->mNumFaces;
3477 const aiFace *mFaces = mesh->mFaces;
3479 vertices.resize(v_offset + n_vertices);
3480 cells.resize(c_offset + n_faces);
3482 for (
unsigned int i = 0; i < n_vertices; ++i)
3483 for (
unsigned int d = 0; d < spacedim; ++d)
3484 vertices[i + v_offset][d] = mVertices[i][d];
3486 unsigned int valid_cell = c_offset;
3487 for (
unsigned int i = 0; i < n_faces; ++i)
3494 .vertices[dim == 3 ? local_vertex_numbering[f] :
3496 mFaces[i].mIndices[f] + v_offset;
3498 cells[valid_cell].material_id = m;
3504 ExcMessage(
"Face " + std::to_string(i) +
" of mesh " +
3505 std::to_string(m) +
" has " +
3506 std::to_string(mFaces[i].mNumIndices) +
3507 " vertices. We expected only " +
3512 cells.resize(valid_cell);
3517 v_offset += n_vertices;
3518 c_offset = valid_cell;
3525 if (remove_duplicates)
3530 unsigned int n_verts = 0;
3534 std::vector<unsigned int> considered_vertices;
3536 vertices, cells, subcelldata, considered_vertices, tol);
3540 apply_grid_fixup_functions(
vertices, cells, subcelldata);
3541 tria->create_triangulation(
vertices, cells, subcelldata);
3546 (void)remove_duplicates;
3548 (void)ignore_unsupported_types;
3553#ifdef DEAL_II_TRILINOS_WITH_SEACAS
3560 exodusii_name_to_type(
const std::string &type_name,
3561 const int n_nodes_per_element)
3567 std::string type_name_2 = type_name;
3568 std::transform(type_name_2.begin(),
3570 type_name_2.begin(),
3571 [](
unsigned char c) { return std::toupper(c); });
3572 const std::string
numbers =
"0123456789";
3573 type_name_2.erase(std::find_first_of(type_name_2.begin(),
3580 if (type_name_2 ==
"BAR" || type_name_2 ==
"BEAM" ||
3581 type_name_2 ==
"EDGE" || type_name_2 ==
"TRUSS")
3583 else if (type_name_2 ==
"TRI" || type_name_2 ==
"TRIANGLE")
3585 else if (type_name_2 ==
"QUAD" || type_name_2 ==
"QUADRILATERAL")
3587 else if (type_name_2 ==
"SHELL")
3589 if (n_nodes_per_element == 3)
3594 else if (type_name_2 ==
"TET" || type_name_2 ==
"TETRA" ||
3595 type_name_2 ==
"TETRAHEDRON")
3597 else if (type_name_2 ==
"PYRA" || type_name_2 ==
"PYRAMID")
3599 else if (type_name_2 ==
"WEDGE")
3601 else if (type_name_2 ==
"HEX" || type_name_2 ==
"HEXAHEDRON")
3611 template <
int dim,
int spacedim = dim>
3612 std::pair<SubCellData, std::vector<std::vector<int>>>
3613 read_exodusii_sidesets(
const int ex_id,
3614 const int n_side_sets,
3616 const bool apply_all_indicators_to_manifolds)
3619 std::vector<std::vector<int>> b_or_m_id_to_sideset_ids;
3621 b_or_m_id_to_sideset_ids.emplace_back();
3627 if (dim == spacedim && n_side_sets > 0)
3629 std::vector<int> side_set_ids(n_side_sets);
3630 int ierr = ex_get_ids(ex_id, EX_SIDE_SET, side_set_ids.data());
3631 AssertThrowExodusII(ierr);
3639 std::map<std::size_t, std::vector<int>> face_side_sets;
3640 for (
const int side_set_id : side_set_ids)
3643 int n_distribution_factors = -1;
3645 ierr = ex_get_set_param(ex_id,
3649 &n_distribution_factors);
3650 AssertThrowExodusII(ierr);
3653 std::vector<int> elements(n_sides);
3654 std::vector<int> faces(n_sides);
3655 ierr = ex_get_set(ex_id,
3660 AssertThrowExodusII(ierr);
3668 for (
int side_n = 0; side_n < n_sides; ++side_n)
3670 const long element_n = elements[side_n] - 1;
3671 const long face_n = faces[side_n] - 1;
3672 const std::size_t face_id =
3673 element_n * max_faces_per_cell + face_n;
3674 face_side_sets[face_id].push_back(side_set_id);
3680 std::vector<std::pair<std::size_t, std::vector<int>>>
3681 face_id_to_side_sets;
3682 face_id_to_side_sets.reserve(face_side_sets.size());
3683 for (
auto &pair : face_side_sets)
3686 face_id_to_side_sets.emplace_back(std::move(pair));
3690 std::sort(face_id_to_side_sets.begin(),
3691 face_id_to_side_sets.end(),
3692 [](
const auto &a,
const auto &b) {
3693 return std::lexicographical_compare(a.second.begin(),
3704 for (
const auto &pair : face_id_to_side_sets)
3706 const std::size_t face_id = pair.first;
3707 const std::vector<int> &face_sideset_ids = pair.second;
3708 if (face_sideset_ids != b_or_m_id_to_sideset_ids.back())
3713 ++current_b_or_m_id;
3714 b_or_m_id_to_sideset_ids.push_back(face_sideset_ids);
3715 Assert(current_b_or_m_id == b_or_m_id_to_sideset_ids.size() - 1,
3719 const unsigned int local_face_n = face_id % max_faces_per_cell;
3720 const CellData<dim> &cell = cells[face_id / max_faces_per_cell];
3723 const unsigned int deal_face_n =
3734 if (apply_all_indicators_to_manifolds)
3735 boundary_line.manifold_id = current_b_or_m_id;
3737 boundary_line.boundary_id = current_b_or_m_id;
3738 for (
unsigned int j = 0; j < face_reference_cell.
n_vertices();
3740 boundary_line.vertices[j] =
3742 deal_face_n, j, 0)];
3749 if (apply_all_indicators_to_manifolds)
3750 boundary_quad.manifold_id = current_b_or_m_id;
3752 boundary_quad.boundary_id = current_b_or_m_id;
3753 for (
unsigned int j = 0; j < face_reference_cell.
n_vertices();
3755 boundary_quad.vertices[j] =
3757 deal_face_n, j, 0)];
3764 return std::make_pair(std::move(subcelldata),
3765 std::move(b_or_m_id_to_sideset_ids));
3770template <
int dim,
int spacedim>
3773 const std::string &filename,
3774 const bool apply_all_indicators_to_manifolds)
3776#ifdef DEAL_II_TRILINOS_WITH_SEACAS
3778 int component_word_size =
sizeof(double);
3780 int floating_point_word_size = 0;
3781 float ex_version = 0.0;
3783 const int ex_id = ex_open(filename.c_str(),
3785 &component_word_size,
3786 &floating_point_word_size,
3789 ExcMessage(
"ExodusII failed to open the specified input file."));
3792 std::vector<char> string_temp(MAX_LINE_LENGTH + 1,
'\0');
3793 int mesh_dimension = 0;
3796 int n_element_blocks = 0;
3797 int n_node_sets = 0;
3798 int n_side_sets = 0;
3800 int ierr = ex_get_init(ex_id,
3808 AssertThrowExodusII(ierr);
3819 std::vector<Point<spacedim>>
vertices;
3822 std::vector<double> xs(n_nodes);
3823 std::vector<double> ys(n_nodes);
3824 std::vector<double> zs(n_nodes);
3826 ierr = ex_get_coord(ex_id, xs.data(), ys.data(), zs.data());
3827 AssertThrowExodusII(ierr);
3829 for (
int vertex_n = 0; vertex_n < n_nodes; ++vertex_n)
3834 vertices.emplace_back(xs[vertex_n]);
3837 vertices.emplace_back(xs[vertex_n], ys[vertex_n]);
3840 vertices.emplace_back(xs[vertex_n], ys[vertex_n], zs[vertex_n]);
3848 std::vector<int> element_block_ids(n_element_blocks);
3849 ierr = ex_get_ids(ex_id, EX_ELEM_BLOCK, element_block_ids.data());
3850 AssertThrowExodusII(ierr);
3852 std::vector<CellData<dim>> cells;
3853 cells.reserve(n_elements);
3857 for (
const int element_block_id : element_block_ids)
3859 std::fill(string_temp.begin(), string_temp.end(),
'\0');
3860 int n_block_elements = 0;
3861 int n_nodes_per_element = 0;
3862 int n_edges_per_element = 0;
3863 int n_faces_per_element = 0;
3864 int n_attributes_per_element = 0;
3867 ierr = ex_get_block(ex_id,
3872 &n_nodes_per_element,
3873 &n_edges_per_element,
3874 &n_faces_per_element,
3875 &n_attributes_per_element);
3876 AssertThrowExodusII(ierr);
3878 exodusii_name_to_type(string_temp.data(), n_nodes_per_element);
3881 "The ExodusII block " + std::to_string(element_block_id) +
3882 " with element type " + std::string(string_temp.data()) +
3883 " has dimension " + std::to_string(type.get_dimension()) +
3884 ", which does not match the topological mesh dimension " +
3885 std::to_string(dim) +
"."));
3892 std::vector<int> connection(n_nodes_per_element * n_block_elements);
3893 ierr = ex_get_conn(ex_id,
3899 AssertThrowExodusII(ierr);
3901 for (
unsigned int elem_n = 0; elem_n < connection.size();
3902 elem_n += n_nodes_per_element)
3905 for (
const unsigned int i : type.vertex_indices())
3907 cell.
vertices[type.exodusii_vertex_to_deal_vertex(i)] =
3908 connection[elem_n + i] - 1;
3911 cells.push_back(std::move(cell));
3916 auto pair = read_exodusii_sidesets<dim, spacedim>(
3917 ex_id, n_side_sets, cells, apply_all_indicators_to_manifolds);
3918 ierr = ex_close(ex_id);
3919 AssertThrowExodusII(ierr);
3921 apply_grid_fixup_functions(
vertices, cells, pair.first);
3922 tria->create_triangulation(
vertices, cells, pair.first);
3928 (void)apply_all_indicators_to_manifolds;
3935template <
int dim,
int spacedim>
3949 if (std::find_if(line.begin(), line.end(), [](
const char c) {
3954 for (
int i = line.size() - 1; i >= 0; --i)
3955 in.putback(line[i]);
3965template <
int dim,
int spacedim>
3968 const char comment_start)
3973 while (in.get(c) && c == comment_start)
3976 while (in.get() !=
'\n')
3986 skip_empty_lines(in);
3991template <
int dim,
int spacedim>
4009 double min_x =
vertices[cells[0].vertices[0]][0],
4010 max_x =
vertices[cells[0].vertices[0]][0],
4011 min_y =
vertices[cells[0].vertices[0]][1],
4012 max_y =
vertices[cells[0].vertices[0]][1];
4014 for (
unsigned int i = 0; i < cells.size(); ++i)
4016 for (
const auto vertex : cells[i].vertices)
4030 out <<
"# cell " << i << std::endl;
4032 for (
const auto vertex : cells[i].vertices)
4036 out <<
"set label \"" << i <<
"\" at " <<
center[0] <<
',' <<
center[1]
4037 <<
" center" << std::endl;
4040 for (
unsigned int f = 0; f < 2; ++f)
4044 <<
vertices[cells[i].vertices[(f + 1) % 4]][1] << std::endl;
4046 for (
unsigned int f = 2; f < 4; ++f)
4048 <<
',' <<
vertices[cells[i].vertices[(f + 1) % 4]][1] <<
" to "
4056 <<
"set nokey" << std::endl
4057 <<
"pl [" << min_x <<
':' << max_x <<
"][" << min_y <<
':' << max_y
4058 <<
"] " << min_y << std::endl
4059 <<
"pause -1" << std::endl;
4070 for (
const auto &cell : cells)
4137template <
int dim,
int spacedim>
4144 if (format == Default)
4146 const std::string::size_type slashpos = filename.find_last_of(
'/');
4147 const std::string::size_type dotpos = filename.find_last_of(
'.');
4148 if (dotpos < filename.size() &&
4149 (dotpos > slashpos || slashpos == std::string::npos))
4151 std::string ext = filename.substr(dotpos + 1);
4152 format = parse_format(ext);
4156 if (format == assimp)
4158 read_assimp(filename);
4160 else if (format == exodusii)
4162 read_exodusii(filename);
4166 std::ifstream in(filename);
4172template <
int dim,
int spacedim>
4176 if (format == Default)
4177 format = default_format;
4219 ExcMessage(
"There is no read_assimp(istream &) function. "
4220 "Use the read_assimp(string &filename, ...) "
4221 "functions, instead."));
4226 ExcMessage(
"There is no read_exodusii(istream &) function. "
4227 "Use the read_exodusii(string &filename, ...) "
4228 "function, instead."));
4239template <
int dim,
int spacedim>
4268 return ".unknown_format";
4274template <
int dim,
int spacedim>
4278 if (format_name ==
"dbmesh")
4281 if (format_name ==
"exodusii")
4284 if (format_name ==
"msh")
4287 if (format_name ==
"unv")
4290 if (format_name ==
"vtk")
4293 if (format_name ==
"vtu")
4297 if (format_name ==
"inp")
4300 if (format_name ==
"ucd")
4303 if (format_name ==
"xda")
4306 if (format_name ==
"tecplot")
4309 if (format_name ==
"dat")
4312 if (format_name ==
"plt")
4331template <
int dim,
int spacedim>
4335 return "dbmesh|exodusii|msh|unv|vtk|vtu|ucd|abaqus|xda|tecplot|assimp";
4342 template <
int dim,
int spacedim>
4343 Abaqus_to_UCD<dim, spacedim>::Abaqus_to_UCD()
4356 from_string(T &t,
const std::string &s, std::ios_base &(*f)(std::ios_base &))
4358 std::istringstream iss(s);
4359 return !(iss >> f >> t).fail();
4366 extract_int(
const std::string &s)
4369 for (
const char c : s)
4371 if (isdigit(c) != 0)
4378 from_string(number, tmp, std::dec);
4384 template <
int dim,
int spacedim>
4386 Abaqus_to_UCD<dim, spacedim>::read_in_abaqus(std::istream &input_stream)
4395 while (std::getline(input_stream, line))
4398 std::transform(line.begin(), line.end(), line.begin(), ::toupper);
4400 if (line.compare(
"*HEADING") == 0 || line.compare(0, 2,
"**") == 0 ||
4401 line.compare(0, 5,
"*PART") == 0)
4404 while (std::getline(input_stream, line))
4410 else if (line.compare(0, 5,
"*NODE") == 0)
4419 while (std::getline(input_stream, line))
4424 std::vector<double> node(spacedim + 1);
4426 std::istringstream iss(line);
4428 for (
unsigned int i = 0; i < spacedim + 1; ++i)
4429 iss >> node[i] >> comma;
4431 node_list.push_back(node);
4434 else if (line.compare(0, 8,
"*ELEMENT") == 0)
4449 const std::string before_material =
"ELSET=EB";
4450 const std::size_t idx = line.find(before_material);
4451 if (idx != std::string::npos)
4453 from_string(material,
4454 line.substr(idx + before_material.size()),
4460 while (std::getline(input_stream, line))
4465 std::istringstream iss(line);
4471 const unsigned int n_data_per_cell =
4473 std::vector<double> cell(n_data_per_cell);
4474 for (
unsigned int i = 0; i < n_data_per_cell; ++i)
4475 iss >> cell[i] >> comma;
4478 cell[0] =
static_cast<double>(material);
4479 cell_list.push_back(cell);
4482 else if (line.compare(0, 8,
"*SURFACE") == 0)
4493 const std::string name_key =
"NAME=";
4494 const std::size_t name_idx_start =
4495 line.find(name_key) + name_key.size();
4496 std::size_t name_idx_end = line.find(
',', name_idx_start);
4497 if (name_idx_end == std::string::npos)
4499 name_idx_end = line.size();
4501 const int b_indicator = extract_int(
4502 line.substr(name_idx_start, name_idx_end - name_idx_start));
4509 while (std::getline(input_stream, line))
4515 std::transform(line.begin(),
4523 std::istringstream iss(line);
4530 std::vector<double> quad_node_list;
4531 const std::string elset_name = line.substr(0, line.find(
','));
4532 if (elsets_list.count(elset_name) != 0)
4536 iss >> stmp >> temp >> face_number;
4538 const std::vector<int> cells = elsets_list[elset_name];
4539 for (
const int cell : cells)
4543 get_global_node_numbers(el_idx, face_number);
4544 quad_node_list.insert(quad_node_list.begin(),
4547 face_list.push_back(quad_node_list);
4554 iss >> el_idx >> comma >> temp >> face_number;
4556 get_global_node_numbers(el_idx, face_number);
4557 quad_node_list.insert(quad_node_list.begin(), b_indicator);
4559 face_list.push_back(quad_node_list);
4563 else if (line.compare(0, 6,
"*ELSET") == 0)
4567 std::string elset_name;
4569 const std::string elset_key =
"*ELSET, ELSET=";
4570 const std::size_t idx = line.find(elset_key);
4571 if (idx != std::string::npos)
4573 const std::string comma =
",";
4574 const std::size_t first_comma = line.find(comma);
4575 const std::size_t second_comma =
4576 line.find(comma, first_comma + 1);
4577 const std::size_t elset_name_start =
4578 line.find(elset_key) + elset_key.size();
4579 elset_name = line.substr(elset_name_start,
4580 second_comma - elset_name_start);
4590 std::vector<int> elements;
4591 const std::size_t generate_idx = line.find(
"GENERATE");
4592 if (generate_idx != std::string::npos)
4595 std::getline(input_stream, line);
4596 std::istringstream iss(line);
4606 iss >> elid_start >> comma >> elid_end;
4610 "While reading an ABAQUS file, the reader "
4611 "expected a comma but found a <") +
4612 comma +
"> in the line <" + line +
">."));
4614 elid_start <= elid_end,
4617 "While reading an ABAQUS file, the reader encountered "
4618 "a GENERATE statement in which the upper bound <") +
4620 "> for the element numbers is not larger or equal "
4621 "than the lower bound <" +
4625 if (iss.rdbuf()->in_avail() != 0)
4626 iss >> comma >> elis_step;
4630 "While reading an ABAQUS file, the reader "
4631 "expected a comma but found a <") +
4632 comma +
"> in the line <" + line +
">."));
4634 for (
int i = elid_start; i <= elid_end; i += elis_step)
4635 elements.push_back(i);
4636 elsets_list[elset_name] = elements;
4638 std::getline(input_stream, line);
4643 while (std::getline(input_stream, line))
4648 std::istringstream iss(line);
4653 iss >> elid >> comma;
4658 "While reading an ABAQUS file, the reader "
4659 "expected a comma but found a <") +
4660 comma +
"> in the line <" + line +
">."));
4662 elements.push_back(elid);
4666 elsets_list[elset_name] = elements;
4671 else if (line.compare(0, 5,
"*NSET") == 0)
4674 while (std::getline(input_stream, line))
4680 else if (line.compare(0, 14,
"*SOLID SECTION") == 0)
4684 const std::string elset_key =
"ELSET=";
4685 const std::size_t elset_start =
4686 line.find(
"ELSET=") + elset_key.size();
4687 const std::size_t elset_end = line.find(
',', elset_start + 1);
4688 const std::string elset_name =
4689 line.substr(elset_start, elset_end - elset_start);
4694 const std::string material_key =
"MATERIAL=";
4695 const std::size_t last_equal =
4696 line.find(
"MATERIAL=") + material_key.size();
4697 const std::size_t material_id_start = line.find(
'-', last_equal);
4699 from_string(material_id,
4700 line.substr(material_id_start + 1),
4704 const std::vector<int> &elset_cells = elsets_list[elset_name];
4705 for (
const int elset_cell : elset_cells)
4707 const int cell_id = elset_cell - 1;
4715 template <
int dim,
int spacedim>
4717 Abaqus_to_UCD<dim, spacedim>::get_global_node_numbers(
4718 const int face_cell_no,
4719 const int face_cell_face_no)
const
4729 if (face_cell_face_no == 1)
4731 quad_node_list[0] = cell_list[face_cell_no - 1][1];
4732 quad_node_list[1] = cell_list[face_cell_no - 1][2];
4734 else if (face_cell_face_no == 2)
4736 quad_node_list[0] = cell_list[face_cell_no - 1][2];
4737 quad_node_list[1] = cell_list[face_cell_no - 1][3];
4739 else if (face_cell_face_no == 3)
4741 quad_node_list[0] = cell_list[face_cell_no - 1][3];
4742 quad_node_list[1] = cell_list[face_cell_no - 1][4];
4744 else if (face_cell_face_no == 4)
4746 quad_node_list[0] = cell_list[face_cell_no - 1][4];
4747 quad_node_list[1] = cell_list[face_cell_no - 1][1];
4757 if (face_cell_face_no == 1)
4759 quad_node_list[0] = cell_list[face_cell_no - 1][1];
4760 quad_node_list[1] = cell_list[face_cell_no - 1][4];
4761 quad_node_list[2] = cell_list[face_cell_no - 1][3];
4762 quad_node_list[3] = cell_list[face_cell_no - 1][2];
4764 else if (face_cell_face_no == 2)
4766 quad_node_list[0] = cell_list[face_cell_no - 1][5];
4767 quad_node_list[1] = cell_list[face_cell_no - 1][8];
4768 quad_node_list[2] = cell_list[face_cell_no - 1][7];
4769 quad_node_list[3] = cell_list[face_cell_no - 1][6];
4771 else if (face_cell_face_no == 3)
4773 quad_node_list[0] = cell_list[face_cell_no - 1][1];
4774 quad_node_list[1] = cell_list[face_cell_no - 1][2];
4775 quad_node_list[2] = cell_list[face_cell_no - 1][6];
4776 quad_node_list[3] = cell_list[face_cell_no - 1][5];
4778 else if (face_cell_face_no == 4)
4780 quad_node_list[0] = cell_list[face_cell_no - 1][2];
4781 quad_node_list[1] = cell_list[face_cell_no - 1][3];
4782 quad_node_list[2] = cell_list[face_cell_no - 1][7];
4783 quad_node_list[3] = cell_list[face_cell_no - 1][6];
4785 else if (face_cell_face_no == 5)
4787 quad_node_list[0] = cell_list[face_cell_no - 1][3];
4788 quad_node_list[1] = cell_list[face_cell_no - 1][4];
4789 quad_node_list[2] = cell_list[face_cell_no - 1][8];
4790 quad_node_list[3] = cell_list[face_cell_no - 1][7];
4792 else if (face_cell_face_no == 6)
4794 quad_node_list[0] = cell_list[face_cell_no - 1][1];
4795 quad_node_list[1] = cell_list[face_cell_no - 1][5];
4796 quad_node_list[2] = cell_list[face_cell_no - 1][8];
4797 quad_node_list[3] = cell_list[face_cell_no - 1][4];
4810 return quad_node_list;
4813 template <
int dim,
int spacedim>
4815 Abaqus_to_UCD<dim, spacedim>::write_out_avs_ucd(std::ostream &output)
const
4824 const boost::io::ios_base_all_saver formatting_saver(output);
4828 output <<
"# Abaqus to UCD mesh conversion" << std::endl;
4829 output <<
"# Mesh type: AVS UCD" << std::endl;
4858 output << node_list.size() <<
"\t" << (cell_list.size() + face_list.size())
4859 <<
"\t0\t0\t0" << std::endl;
4862 output.precision(8);
4866 for (
const auto &node : node_list)
4869 output << node[0] <<
"\t";
4872 output.setf(std::ios::scientific, std::ios::floatfield);
4873 for (
unsigned int jj = 1; jj < spacedim + 1; ++jj)
4876 if (
std::abs(node[jj]) > tolerance)
4877 output << static_cast<double>(node[jj]) <<
"\t";
4879 output << 0.0 <<
"\t";
4882 output << 0.0 <<
"\t";
4884 output << std::endl;
4885 output.unsetf(std::ios::floatfield);
4889 for (
unsigned int ii = 0; ii < cell_list.size(); ++ii)
4891 output << ii + 1 <<
"\t" << cell_list[ii][0] <<
"\t"
4892 << (dim == 2 ?
"quad" :
"hex") <<
"\t";
4893 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_cell + 1;
4895 output << cell_list[ii][jj] <<
"\t";
4897 output << std::endl;
4901 for (
unsigned int ii = 0; ii < face_list.size(); ++ii)
4903 output << ii + 1 <<
"\t" << face_list[ii][0] <<
"\t"
4904 << (dim == 2 ?
"line" :
"quad") <<
"\t";
4905 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_face + 1;
4907 output << face_list[ii][jj] <<
"\t";
4909 output << std::endl;
4916#include "grid_in.inst"
void read_vtk(std::istream &in)
static void skip_empty_lines(std::istream &in)
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)
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
static std::string default_suffix(const Format format)
void read_xda(std::istream &in)
void read_comsol_mphtxt(std::istream &in)
static void skip_comment_lines(std::istream &in, const char comment_start)
void attach_triangulation(Triangulation< dim, spacedim > &tria)
void read_msh(std::istream &in)
static Format parse_format(const std::string &format_name)
void read_vtu(std::istream &in)
void read_tecplot(std::istream &in)
ExodusIIData read_exodusii(const std::string &filename, const bool apply_all_indicators_to_manifolds=false)
void read_dbmesh(std::istream &in)
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
void read(std::istream &in, Format format=Default)
static void debug_output_grid(const std::vector< CellData< dim > > &cells, const std::vector< Point< spacedim > > &vertices, std::ostream &out)
static std::string get_format_names()
void read_unv(std::istream &in)
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)
unsigned int n_vertices() const
unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const unsigned char face_orientation) const
ReferenceCell face_reference_cell(const unsigned int face_no) const
unsigned int exodusii_face_to_deal_face(const unsigned int face_n) const
static ReferenceCell n_vertices_to_type(const int dim, const unsigned int n_vertices)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_FALLTHROUGH
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcFileNotOpen(std::string arg1)
static ::ExceptionBase & ExcNeedsAssimp()
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
static ::ExceptionBase & ExcImpossibleInDim(int arg1)
static ::ExceptionBase & ExcNeedsExodusII()
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcInvalidState()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
void consistently_order_cells(std::vector< CellData< dim > > &cells)
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Invalid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell & get_hypercube()
constexpr const ReferenceCell Vertex
constexpr const ReferenceCell Line
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
std::vector< unsigned char > decode_base64(const std::string &base64_input)
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
bool match_at_string_start(const std::string &name, const std::string &pattern)
std::string decompress(const std::string &compressed_input)
const types::material_id invalid_material_id
const types::boundary_id internal_face_boundary_id
static const unsigned int invalid_unsigned_int
const types::manifold_id flat_manifold_id
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
std::vector< unsigned int > vertices
types::material_id material_id
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
std::vector< std::vector< int > > id_to_sideset_ids
std::vector< CellData< 2 > > boundary_quads
bool check_consistency(const unsigned int dim) const
std::vector< CellData< 1 > > boundary_lines