22#include <boost/algorithm/string.hpp>
23#include <boost/archive/binary_iarchive.hpp>
24#include <boost/io/ios_state.hpp>
25#include <boost/property_tree/ptree.hpp>
26#include <boost/property_tree/xml_parser.hpp>
27#include <boost/serialization/serialization.hpp>
29#ifdef DEAL_II_GMSH_WITH_API
44#ifdef DEAL_II_WITH_ASSIMP
45# include <assimp/Importer.hpp>
46# include <assimp/postprocess.h>
47# include <assimp/scene.h>
50#ifdef DEAL_II_TRILINOS_WITH_SEACAS
77 template <
int spacedim>
79 assign_1d_boundary_ids(
84 for (
auto &cell : triangulation.active_cell_iterators())
86 if (cell->face(face_no)->at_boundary())
87 for (
const auto &pair : boundary_ids)
88 if (cell->face(face_no)->vertex(0) == pair.
first)
90 cell->face(face_no)->set_boundary_id(pair.second);
96 template <
int dim,
int spacedim>
98 assign_1d_boundary_ids(
110 template <
int dim,
int spacedim>
118 const auto n_hypercube_vertices =
119 ReferenceCells::get_hypercube<dim>().n_vertices();
120 bool is_only_hypercube =
true;
122 if (cell.vertices.
size() != n_hypercube_vertices)
124 is_only_hypercube =
false;
129 if constexpr (dim == spacedim)
132 if (is_only_hypercube)
137template <
int dim,
int spacedim>
139 : tria(nullptr, typeid(*this).name())
140 , default_format(ucd)
145template <
int dim,
int spacedim>
147 : tria(&t, typeid(*this).name())
148 , default_format(ucd)
153template <
int dim,
int spacedim>
162template <
int dim,
int spacedim>
167 std::string vtk_version;
178 text[3] =
"DATASET UNSTRUCTURED_GRID";
180 for (
unsigned int i = 0; i < 4; ++i)
186 if (i == 2 || i == 3)
188 line.compare(text[i]) == 0,
191 "While reading VTK file, failed to find a header line with text <") +
196 vtk_version = text[0].substr(23, 3);
202 std::vector<Point<spacedim>> vertices;
203 std::vector<CellData<dim>> cells;
212 if (keyword ==
"POINTS")
214 unsigned int n_vertices;
219 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
223 in >> x[0] >> x[1] >> x[2];
225 vertices.emplace_back();
226 for (
unsigned int d = 0; d < spacedim; ++d)
227 vertices.back()[d] = x[d];
234 "While reading VTK file, failed to find POINTS section"));
238 unsigned int n_geometric_objects = 0;
240 std::vector<unsigned int> n_points_per_cell;
242 if (keyword ==
"CELLS")
245 std::vector<unsigned int> cell_types;
247 std::streampos oldpos = in.tellg();
250 while (in >> keyword)
251 if (keyword ==
"CELL_TYPES")
255 cell_types.resize(n_ints);
257 for (
unsigned int i = 0; i < n_ints; ++i)
266 in >> n_geometric_objects;
269 if (vtk_version ==
"5.1")
275 keyword ==
"OFFSETS",
277 "While reading VTK file, failed to find OFFSETS array which must exist in a VTK file with version 5.1."));
281 unsigned int n_offsets = n_geometric_objects;
289 unsigned int new_index = 0;
290 unsigned int old_index = 0;
293 for (
unsigned int p = 0; p < n_offsets; ++p)
295 unsigned int n_points_per_cell_tmp;
303 "While reading VTK file, the first index in the OFFSETS array should be 0"));
306 n_points_per_cell_tmp = new_index - old_index;
307 n_points_per_cell.push_back(n_points_per_cell_tmp);
309 old_index = new_index;
313 n_points_per_cell.size() == cell_types.size(),
315 "The number of cells inferred from the OFFSETS array (" +
316 std::to_string(n_points_per_cell.size()) +
317 ") does not match the number of entries in the CELL_TYPES array (" +
318 std::to_string(cell_types.size()) +
")"));
324 keyword ==
"CONNECTIVITY",
326 "While reading VTK file, failed to find CONNECTIVITY array which must exist in a VTK file containing an OFFSETS array."));
332 n_geometric_objects = n_points_per_cell.size();
336 if constexpr (dim == 3)
338 for (
unsigned int count = 0; count < n_geometric_objects; ++count)
340 unsigned int n_vertices;
342 if (vtk_version ==
"3.0")
344 else if (vtk_version ==
"5.1")
346 n_vertices = n_points_per_cell[count];
351 "Unknown VTK version encountered...Only VTK versions 3.0 and 5.1 are supported."));
354 if (cell_types[count] == 10 || cell_types[count] == 12)
362 cells.emplace_back(n_vertices);
364 for (
unsigned int j = 0; j < n_vertices;
366 in >> cells.back().vertices[j];
370 if (cell_types[count] == 12)
372 std::swap(cells.back().vertices[2],
373 cells.back().vertices[3]);
374 std::swap(cells.back().vertices[6],
375 cells.back().vertices[7]);
378 cells.back().material_id = 0;
381 else if (cell_types[count] == 5 || cell_types[count] == 9)
390 for (
unsigned int j = 0; j < n_vertices;
397 else if (cell_types[count] == 3)
401 for (
unsigned int j = 0; j < n_vertices;
412 "While reading VTK file, unknown cell type encountered"));
415 else if constexpr (dim == 2)
417 for (
unsigned int count = 0; count < n_geometric_objects; ++count)
419 unsigned int n_vertices;
421 if (vtk_version ==
"3.0")
423 else if (vtk_version ==
"5.1")
425 n_vertices = n_points_per_cell[count];
430 "Unknown VTK version encountered...Only VTK versions 3.0 and 5.1 are supported."));
433 if (cell_types[count] == 5 || cell_types[count] == 9)
440 cells.emplace_back(n_vertices);
442 for (
unsigned int j = 0; j < n_vertices;
444 in >> cells.back().vertices[j];
448 if (cell_types[count] == 9)
452 std::swap(cells.back().vertices[2],
453 cells.back().vertices[3]);
456 cells.back().material_id = 0;
459 else if (cell_types[count] == 3)
465 for (
unsigned int j = 0; j < n_vertices;
478 "While reading VTK file, unknown cell type encountered"));
481 else if constexpr (dim == 1)
483 for (
unsigned int count = 0; count < n_geometric_objects; ++count)
485 unsigned int n_vertices;
486 if (vtk_version ==
"3.0")
488 else if (vtk_version ==
"5.1")
490 n_vertices = n_points_per_cell[count];
495 "Unknown VTK version encountered...Only VTK versions 3.0 and 5.1 are supported."));
498 cell_types[count] == 3 && n_vertices == 2,
500 "While reading VTK file, unknown cell type encountered"));
501 cells.emplace_back(n_vertices);
503 for (
unsigned int j = 0; j < n_vertices; ++j)
504 in >> cells.back().vertices[j];
506 cells.back().material_id = 0;
512 "While reading VTK file, failed to find CELLS section"));
519 keyword ==
"CELL_TYPES",
521 "While reading VTK file, missing CELL_TYPES section. Found <" +
522 keyword +
"> instead.")));
527 n_ints == n_geometric_objects,
528 ExcMessage(
"The VTK reader found a CELL_DATA statement "
529 "that lists a total of " +
531 " cell data objects, but this needs to "
532 "equal the number of cells (which is " +
534 ") plus the number of quads (" +
536 " in 3d or the number of lines (" +
541 for (
unsigned int i = 0; i < n_ints; ++i)
548 while (in >> keyword)
550 if (keyword ==
"CELL_DATA")
556 n_ids == n_geometric_objects,
558 "The VTK reader found a CELL_DATA statement "
559 "that lists a total of " +
561 " cell data objects, but this needs to "
562 "equal the number of cells (which is " +
564 ") plus the number of quads (" +
566 " in 3d or the number of lines (" +
570 const std::vector<std::string> data_sets{
"MaterialID",
574 for (
unsigned int i = 0; i < data_sets.size(); ++i)
577 if (keyword ==
"SCALARS")
582 std::string field_name;
584 if (std::find(data_sets.begin(),
586 field_name) == data_sets.end())
598 std::getline(in, line);
602 std::min(
static_cast<std::size_t
>(3),
603 line.size() - 1)) ==
"int",
605 "While reading VTK file, material- and manifold IDs can only have type 'int'."));
609 keyword ==
"LOOKUP_TABLE",
611 "While reading VTK file, missing keyword 'LOOKUP_TABLE'."));
615 keyword ==
"default",
617 "While reading VTK file, missing keyword 'default'."));
624 for (
unsigned int i = 0; i < cells.size(); ++i)
628 if (field_name ==
"MaterialID")
629 cells[i].material_id =
631 else if (field_name ==
"ManifoldID")
632 cells[i].manifold_id =
638 if constexpr (dim == 3)
644 if (field_name ==
"MaterialID")
645 boundary_quad.material_id =
647 else if (field_name ==
"ManifoldID")
648 boundary_quad.manifold_id =
657 if (field_name ==
"MaterialID")
658 boundary_line.material_id =
660 else if (field_name ==
"ManifoldID")
661 boundary_line.manifold_id =
667 else if constexpr (dim == 2)
673 if (field_name ==
"MaterialID")
674 boundary_line.material_id =
676 else if (field_name ==
"ManifoldID")
677 boundary_line.manifold_id =
687 std::streampos oldpos = in.tellg();
689 if (keyword ==
"SCALARS")
700 else if (keyword ==
"FIELD")
702 unsigned int n_fields;
705 keyword ==
"FieldData",
707 "While reading VTK file, missing keyword FieldData"));
711 for (
unsigned int i = 0; i < n_fields; ++i)
713 std::string section_name;
714 std::string data_type;
715 unsigned int temp, n_ids;
721 n_ids == n_geometric_objects,
723 "The VTK reader found a FIELD statement "
724 "that lists a total of " +
726 " cell data objects, but this needs to equal the number of cells (which is " +
728 ") plus the number of quads (" +
731 " in 3d or the number of lines (" +
738 for (
unsigned int j = 0; j < n_ids; ++j)
741 if (j < cells.size())
744 this->cell_data[section_name] = std::move(temp_data);
755 apply_grid_fixup_functions(vertices, cells, subcelldata);
756 tria->create_triangulation(vertices, cells, subcelldata);
761 "While reading VTK file, failed to find CELLS section"));
764template <
int dim,
int spacedim>
765const std::map<std::string, Vector<double>> &
768 return this->cell_data;
771template <
int dim,
int spacedim>
775 namespace pt = boost::property_tree;
777 pt::read_xml(in, tree);
778 auto section = tree.get_optional<std::string>(
"VTKFile.dealiiData");
782 "While reading a VTU file, failed to find dealiiData section. "
783 "Notice that we can only read grid files in .vtu format that "
784 "were created by the deal.II library, using a call to "
785 "GridOut::write_vtu(), where the flag "
786 "GridOutFlags::Vtu::serialize_triangulation is set to true."));
790 const auto string_archive =
792 std::istringstream in_stream(string_archive);
793 boost::archive::binary_iarchive ia(in_stream);
798template <
int dim,
int spacedim>
802 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
806 skip_comment_lines(in,
'#');
817 "Expected '-1' before and after a section."));
829 std::getline(in, line);
831 boost::algorithm::trim(line);
832 if (line.compare(
"-1") == 0)
843 std::vector<Point<spacedim>> vertices;
862 in >> dummy >> dummy >> dummy;
865 in >> x[0] >> x[1] >> x[2];
867 vertices.emplace_back();
869 for (
unsigned int d = 0; d < spacedim; ++d)
870 vertices.back()[d] = x[d];
884 AssertThrow(tmp == 2412, ExcUnknownSectionType(tmp));
886 std::vector<CellData<dim>> cells;
913 in >> type >> dummy >> dummy >> dummy >> dummy;
915 AssertThrow((type == 11) || (type == 44) || (type == 94) || (type == 115),
916 ExcUnknownElementType(type));
918 if ((((type == 44) || (type == 94)) && (dim == 2)) ||
919 ((type == 115) && (dim == 3)))
921 const auto reference_cell = ReferenceCells::get_hypercube<dim>();
922 cells.emplace_back();
927 .vertices[reference_cell.unv_vertex_to_deal_vertex(v)];
929 cells.back().material_id = 0;
932 cells.back().vertices[v] =
vertex_indices[cells.back().vertices[v]];
934 cell_indices[object_index] = n_cells;
938 else if (((type == 11) && (dim == 2)) ||
939 ((type == 11) && (dim == 3)))
942 in >> dummy >> dummy >> dummy;
947 for (
unsigned int &vertex :
953 for (
unsigned int &vertex :
957 line_indices[object_index] = n_lines;
961 else if (((type == 44) || (type == 94)) && (dim == 3))
972 .vertices[reference_cell.unv_vertex_to_deal_vertex(v)];
976 for (
unsigned int &vertex :
980 quad_indices[object_index] = n_quads;
988 "> when running in dim=" +
1007 AssertThrow((tmp == 2467) || (tmp == 2477), ExcUnknownSectionType(tmp));
1023 in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >>
1034 std::getline(in, line);
1037 "The line before the line containing an ID has too "
1038 "many entries. This is not a valid UNV file."));
1040 std::getline(in, line);
1042 std::istringstream id_stream(line);
1045 !id_stream.fail() && id_stream.eof(),
1047 "The given UNV file contains a boundary or material id set to '" +
1049 "', which cannot be parsed as a fixed-width integer, whereas "
1050 "deal.II only supports integer boundary and material ids. To fix "
1051 "this, ensure that all such ids are given integer values."));
1054 id <=
long(std::numeric_limits<types::material_id>::max()),
1055 ExcMessage(
"The provided integer id '" + std::to_string(
id) +
1056 "' is not convertible to either types::material_id nor "
1057 "types::boundary_id."));
1059 const unsigned int n_lines =
1060 (n_entities % 2 == 0) ? (n_entities / 2) : ((n_entities + 1) / 2);
1062 for (
unsigned int line = 0; line < n_lines; ++line)
1064 unsigned int n_fragments;
1066 if (line == n_lines - 1)
1067 n_fragments = (n_entities % 2 == 0) ? (2) : (1);
1071 for (
unsigned int no_fragment = 0; no_fragment < n_fragments;
1075 in >> dummy >> no >> dummy >> dummy;
1077 if (cell_indices.count(no) > 0)
1078 cells[cell_indices[no]].material_id = id;
1080 if (line_indices.count(no) > 0)
1084 if (quad_indices.count(no) > 0)
1092 apply_grid_fixup_functions(vertices, cells, subcelldata);
1093 tria->create_triangulation(vertices, cells, subcelldata);
1098template <
int dim,
int spacedim>
1101 const bool apply_all_indicators_to_manifolds)
1103 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1107 skip_comment_lines(in,
'#');
1110 unsigned int n_vertices;
1111 unsigned int n_cells;
1114 in >> n_vertices >> n_cells >> dummy
1120 std::vector<Point<spacedim>> vertices(n_vertices);
1126 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1133 in >> vertex_number >> x[0] >> x[1] >> x[2];
1136 for (
unsigned int d = 0; d < spacedim; ++d)
1137 vertices[vertex][d] = x[d];
1145 std::vector<CellData<dim>> cells;
1148 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1157 std::string cell_type;
1161 unsigned int material_id;
1167 if (((dim == 1) && (cell_type ==
"line")) ||
1168 ((dim == 2) && (cell_type ==
"quad")) ||
1169 ((dim == 3) && (cell_type ==
"hex")))
1173 cells.emplace_back();
1178 Assert(material_id <= std::numeric_limits<types::material_id>::max(),
1181 std::numeric_limits<types::material_id>::max()));
1186 if (apply_all_indicators_to_manifolds)
1187 cells.back().manifold_id =
1189 cells.back().material_id = material_id;
1197 cells.back().vertices[i] =
1203 ExcInvalidVertexIndex(cell,
1204 cells.back().vertices[i]));
1209 else if (((dim == 2) || (dim == 3)) && (cell_type ==
"line"))
1217 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
1220 std::numeric_limits<types::boundary_id>::max()));
1229 if (apply_all_indicators_to_manifolds)
1246 for (
unsigned int &vertex :
1254 AssertThrow(
false, ExcInvalidVertexIndex(cell, vertex));
1258 else if ((dim == 3) && (cell_type ==
"quad"))
1267 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
1270 std::numeric_limits<types::boundary_id>::max()));
1279 if (apply_all_indicators_to_manifolds)
1296 for (
unsigned int &vertex :
1304 Assert(
false, ExcInvalidVertexIndex(cell, vertex));
1310 AssertThrow(
false, ExcUnknownIdentifier(cell_type));
1315 apply_grid_fixup_functions(vertices, cells, subcelldata);
1316 tria->create_triangulation(vertices, cells, subcelldata);
1321 template <
int dim,
int spacedim>
1328 read_in_abaqus(std::istream &in);
1330 write_out_avs_ucd(std::ostream &out)
const;
1333 const double tolerance;
1336 get_global_node_numbers(
const int face_cell_no,
1337 const int face_cell_face_no)
const;
1340 std::vector<std::vector<double>> node_list;
1343 std::vector<std::vector<double>> cell_list;
1345 std::vector<std::vector<double>> face_list;
1348 std::map<std::string, std::vector<int>> elsets_list;
1352template <
int dim,
int spacedim>
1355 const bool apply_all_indicators_to_manifolds)
1357 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1362 Assert((spacedim == 2 && dim == spacedim) ||
1363 (spacedim == 3 && (dim == spacedim || dim == spacedim - 1)),
1369 Abaqus_to_UCD<dim, spacedim> abaqus_to_ucd;
1370 abaqus_to_ucd.read_in_abaqus(in);
1372 std::stringstream in_ucd;
1373 abaqus_to_ucd.write_out_avs_ucd(in_ucd);
1381 read_ucd(in_ucd, apply_all_indicators_to_manifolds);
1383 catch (std::exception &exc)
1385 std::cerr <<
"Exception on processing internal UCD data: " << std::endl
1386 << exc.what() << std::endl;
1391 "Internal conversion from ABAQUS file to UCD format was unsuccessful. "
1392 "More information is provided in an error message printed above. "
1393 "Are you sure that your ABAQUS mesh file conforms with the requirements "
1394 "listed in the documentation?"));
1401 "Internal conversion from ABAQUS file to UCD format was unsuccessful. "
1402 "Are you sure that your ABAQUS mesh file conforms with the requirements "
1403 "listed in the documentation?"));
1408template <
int dim,
int spacedim>
1412 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1418 skip_comment_lines(in,
'#');
1424 AssertThrow(line ==
"MeshVersionFormatted 0", ExcInvalidDBMESHInput(line));
1426 skip_empty_lines(in);
1430 AssertThrow(line ==
"Dimension", ExcInvalidDBMESHInput(line));
1431 unsigned int dimension;
1433 AssertThrow(dimension == dim, ExcDBMESHWrongDimension(dimension));
1434 skip_empty_lines(in);
1447 while (getline(in, line), line.find(
"# END") == std::string::npos)
1449 skip_empty_lines(in);
1454 AssertThrow(line ==
"Vertices", ExcInvalidDBMESHInput(line));
1456 unsigned int n_vertices;
1460 std::vector<Point<spacedim>> vertices(n_vertices);
1461 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1464 for (
unsigned int d = 0; d < dim; ++d)
1465 in >> vertices[vertex][d];
1471 skip_empty_lines(in);
1477 AssertThrow(line ==
"Edges", ExcInvalidDBMESHInput(line));
1479 unsigned int n_edges;
1481 for (
unsigned int edge = 0; edge < n_edges; ++edge)
1484 in >> dummy >> dummy;
1490 skip_empty_lines(in);
1499 AssertThrow(line ==
"CrackedEdges", ExcInvalidDBMESHInput(line));
1502 for (
unsigned int edge = 0; edge < n_edges; ++edge)
1505 in >> dummy >> dummy;
1511 skip_empty_lines(in);
1517 AssertThrow(line ==
"Quadrilaterals", ExcInvalidDBMESHInput(line));
1519 constexpr std::array<unsigned int, 8> local_vertex_numbering = {
1520 {0, 1, 5, 4, 2, 3, 7, 6}};
1521 std::vector<CellData<dim>> cells;
1523 unsigned int n_cells;
1525 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1529 cells.emplace_back();
1533 cells.back().vertices[dim == 3 ? local_vertex_numbering[i] :
1537 (
static_cast<unsigned int>(cells.back().vertices[i]) <=
1539 ExcInvalidVertexIndex(cell, cells.back().vertices[i]));
1541 --cells.back().vertices[i];
1549 skip_empty_lines(in);
1557 while (getline(in, line), ((line.find(
"End") == std::string::npos) && (in)))
1563 apply_grid_fixup_functions(vertices, cells, subcelldata);
1564 tria->create_triangulation(vertices, cells, subcelldata);
1569template <
int dim,
int spacedim>
1573 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1576 const auto reference_cell = ReferenceCells::get_hypercube<dim>();
1580 std::getline(in, line);
1582 unsigned int n_vertices;
1583 unsigned int n_cells;
1587 std::getline(in, line);
1590 std::getline(in, line);
1593 for (
unsigned int i = 0; i < 8; ++i)
1594 std::getline(in, line);
1597 std::vector<CellData<dim>> cells(n_cells);
1608 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell; ++i)
1609 in >> cell.vertices[reference_cell.exodusii_vertex_to_deal_vertex(i)];
1613 std::vector<Point<spacedim>> vertices(n_vertices);
1616 for (
unsigned int d = 0; d < spacedim; ++d)
1618 for (
unsigned int d = spacedim; d < 3; ++d)
1627 apply_grid_fixup_functions(vertices, cells, subcelldata);
1628 tria->create_triangulation(vertices, cells, subcelldata);
1633template <
int dim,
int spacedim>
1637 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
1650 std::stringstream whole_file;
1655 std::getline(in, line);
1663 if ((line.size() > 0) && (line.back() ==
'\r'))
1664 line.erase(line.size() - 1);
1669 if (line.find(
'#') != std::string::npos)
1670 line.erase(line.find(
'#'), std::string::npos);
1671 while ((line.size() > 0) && (line.back() ==
' '))
1672 line.erase(line.size() - 1);
1674 if (line.size() > 0)
1675 whole_file <<
'\n' << line;
1694 unsigned int version_major, version_minor;
1695 whole_file >> version_major >> version_minor;
1696 AssertThrow((version_major == 0) && (version_minor == 1),
1697 ExcMessage(
"deal.II can currently only read version 0.1 "
1698 "of the mphtxt file format."));
1703 unsigned int n_tags;
1704 whole_file >> n_tags;
1705 for (
unsigned int i = 0; i < n_tags; ++i)
1708 while (whole_file.peek() ==
'\n')
1710 std::getline(whole_file, dummy);
1716 unsigned int n_types;
1717 whole_file >> n_types;
1718 for (
unsigned int i = 0; i < n_types; ++i)
1721 while (whole_file.peek() ==
'\n')
1723 std::getline(whole_file, dummy);
1743 whole_file >> dummy >> dummy >> dummy;
1747 while (whole_file.peek() ==
'\n')
1749 std::getline(whole_file, s);
1751 ExcMessage(
"Expected '4 Mesh', but got '" + s +
"'."));
1754 unsigned int version;
1755 whole_file >> version;
1759 unsigned int file_space_dim;
1760 whole_file >> file_space_dim;
1764 "The mesh file uses a different number of space dimensions "
1765 "than the triangulation you want to read it into."));
1767 unsigned int n_vertices;
1768 whole_file >> n_vertices;
1770 unsigned int starting_vertex_index;
1771 whole_file >> starting_vertex_index;
1773 std::vector<Point<spacedim>> vertices(n_vertices);
1774 for (
unsigned int v = 0; v < n_vertices; ++v)
1775 whole_file >> vertices[v];
1805 std::vector<CellData<dim>> cells;
1808 unsigned int n_types;
1809 whole_file >> n_types;
1810 for (
unsigned int type = 0; type < n_types; ++type)
1817 whole_file >> dummy;
1821 std::string object_name;
1822 whole_file >> object_name;
1824 const std::set<std::string> known_object_names = {
1825 "vtx",
"edg",
"tri",
"quad",
"tet",
"prism"
1829 AssertThrow(known_object_names.find(object_name) !=
1830 known_object_names.end(),
1831 ExcMessage(
"The input file contains a cell type <" +
1833 "> that the reader does not "
1834 "current support"));
1836 unsigned int n_vertices_per_element;
1837 whole_file >> n_vertices_per_element;
1839 unsigned int n_elements;
1840 whole_file >> n_elements;
1843 if ((dim >= 3) && (object_name ==
"tet"))
1846 ExcMessage(
"Tetrahedra should not appear in input files "
1847 "for 1d or 2d meshes."));
1850 else if ((dim >= 3) && (object_name ==
"prism"))
1854 "Prisms (wedges) should not appear in input files "
1855 "for 1d or 2d meshes."));
1858 else if ((dim >= 2) && (object_name ==
"tri"))
1861 ExcMessage(
"Triangles should not appear in input files "
1865 else if ((dim >= 2) && (object_name ==
"quad"))
1869 "Quadrilaterals should not appear in input files "
1873 else if (object_name ==
"edg")
1877 else if (object_name ==
"vtx")
1900 ReferenceCells::max_n_vertices<dim>()>
1901 vertices_for_this_element(n_vertices_per_element);
1902 for (
unsigned int e = 0; e < n_elements; ++e)
1905 for (
unsigned int v = 0; v < n_vertices_per_element; ++v)
1907 whole_file >> vertices_for_this_element[v];
1908 vertices_for_this_element[v] -= starting_vertex_index;
1912 ((object_name ==
"tet") || (object_name ==
"prism")))
1914 if constexpr (dim == 3)
1916 cells.emplace_back();
1917 cells.back().vertices = vertices_for_this_element;
1922 else if ((dim >= 2) &&
1923 ((object_name ==
"tri") || (object_name ==
"quad")))
1925 if constexpr (dim == 2)
1927 cells.emplace_back();
1928 cells.back().vertices = vertices_for_this_element;
1934 vertices_for_this_element.begin(),
1935 vertices_for_this_element.end());
1938 else if (object_name ==
"edg")
1940 if constexpr (dim == 1)
1942 cells.emplace_back();
1943 cells.back().vertices = vertices_for_this_element;
1949 vertices_for_this_element.begin(),
1950 vertices_for_this_element.end());
1953 else if (object_name ==
"vtx")
1964 unsigned int n_geom_entity_indices;
1965 whole_file >> n_geom_entity_indices;
1967 (n_geom_entity_indices == n_elements),
1974 if (n_geom_entity_indices != 0)
1976 for (
unsigned int e = 0; e < n_geom_entity_indices; ++e)
1979 unsigned int geometric_entity_index;
1980 whole_file >> geometric_entity_index;
1981 if (object_name ==
"vtx")
1983 else if (object_name ==
"edg")
1985 if constexpr (dim == 1)
1986 cells[cells.size() - n_elements + e].material_id =
1987 geometric_entity_index;
1992 .boundary_id = geometric_entity_index;
1994 else if ((dim >= 2) &&
1995 ((object_name ==
"tri") || (object_name ==
"quad")))
1997 if constexpr (dim == 2)
1998 cells[cells.size() - n_elements + e].material_id =
1999 geometric_entity_index;
2004 .boundary_id = geometric_entity_index;
2006 else if ((dim >= 3) &&
2007 ((object_name ==
"tet") || (object_name ==
"prism")))
2009 if constexpr (dim == 3)
2010 cells[cells.size() - n_elements + e].material_id =
2011 geometric_entity_index;
2027 tria->create_triangulation(vertices, cells, {});
2032 if constexpr (dim >= 2)
2037 if (line.vertices[1] < line.vertices[0])
2038 std::swap(line.vertices[0], line.vertices[1]);
2043 return std::lexicographical_compare(a.vertices.begin(),
2061 if constexpr (dim >= 3)
2065 Assert((face.vertices.size() == 3) || (face.vertices.size() == 4),
2067 std::sort(face.vertices.begin(), face.vertices.end());
2072 return std::lexicographical_compare(a.vertices.begin(),
2080 if constexpr (dim >= 2)
2082 for (
const auto &cell : tria->active_cell_iterators())
2083 for (
const auto &face : cell->face_iterators())
2084 if (face->at_boundary())
2088 if constexpr (dim == 2)
2090 std::array<unsigned int, 2> face_vertex_indices = {
2091 {face->vertex_index(0), face->vertex_index(1)}};
2092 if (face_vertex_indices[0] > face_vertex_indices[1])
2093 std::swap(face_vertex_indices[0], face_vertex_indices[1]);
2099 face_vertex_indices,
2101 const std::array<unsigned int, 2>
2102 &face_vertex_indices) ->
bool {
2103 return std::lexicographical_compare(
2106 face_vertex_indices.begin(),
2107 face_vertex_indices.end());
2111 (p->vertices[0] == face_vertex_indices[0]) &&
2112 (p->vertices[1] == face_vertex_indices[1]))
2114 face->set_boundary_id(p->boundary_id);
2117 else if constexpr (dim == 3)
2127 face_vertex_indices(face->n_vertices());
2128 for (
unsigned int v = 0; v < face->n_vertices(); ++v)
2129 face_vertex_indices[v] = face->vertex_index(v);
2130 std::sort(face_vertex_indices.
begin(),
2131 face_vertex_indices.
end());
2134 const auto p = std::lower_bound(
2137 face_vertex_indices,
2139 const auto &face_vertex_indices) ->
bool {
2140 return std::lexicographical_compare(
2143 face_vertex_indices.begin(),
2144 face_vertex_indices.end());
2148 (std::equal(p->vertices.begin(),
2150 face_vertex_indices.
begin(),
2151 face_vertex_indices.
end())))
2153 face->set_boundary_id(p->boundary_id);
2158 for (
unsigned int e = 0; e < face->n_lines(); ++e)
2160 const auto edge = face->line(e);
2162 std::array<unsigned int, 2> edge_vertex_indices = {
2163 {edge->vertex_index(0), edge->vertex_index(1)}};
2164 if (edge_vertex_indices[0] > edge_vertex_indices[1])
2165 std::swap(edge_vertex_indices[0],
2166 edge_vertex_indices[1]);
2172 edge_vertex_indices,
2174 const std::array<unsigned int, 2>
2175 &edge_vertex_indices) ->
bool {
2176 return std::lexicographical_compare(
2179 edge_vertex_indices.begin(),
2180 edge_vertex_indices.end());
2184 (p->vertices[0] == edge_vertex_indices[0]) &&
2185 (p->vertices[1] == edge_vertex_indices[1]))
2187 edge->set_boundary_id(p->boundary_id);
2197template <
int dim,
int spacedim>
2201 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
2204 unsigned int n_vertices;
2205 unsigned int n_cells;
2211 std::array<std::map<int, int>, 4> tag_maps;
2214 std::string stripped_file;
2218 while (std::getline(input_stream, line))
2220 if (line ==
"@f$Comments")
2222 while (std::getline(input_stream, line))
2224 if (line ==
"@f$EndComments")
2231 stripped_file += line +
'\n';
2235 std::istringstream in(stripped_file);
2240 unsigned int gmsh_file_format = 0;
2241 if (line ==
"@f$NOD")
2242 gmsh_file_format = 10;
2243 else if (line ==
"@f$MeshFormat")
2244 gmsh_file_format = 20;
2250 if (gmsh_file_format == 20)
2253 unsigned int file_type, data_size;
2255 in >> version >> file_type >> data_size;
2258 gmsh_file_format =
static_cast<unsigned int>(version * 10);
2266 AssertThrow(line ==
"@f$EndMeshFormat", ExcInvalidGMSHInput(line));
2270 if (line ==
"@f$PhysicalNames")
2276 while (line !=
"@f$EndPhysicalNames");
2281 if (line ==
"@f$Entities")
2283 unsigned long n_points, n_curves, n_surfaces, n_volumes;
2285 in >> n_points >> n_curves >> n_surfaces >> n_volumes;
2286 for (
unsigned int i = 0; i < n_points; ++i)
2290 unsigned int n_physicals;
2291 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2295 if (gmsh_file_format > 40)
2297 in >> tag >> box_min_x >> box_min_y >> box_min_z >>
2299 box_max_x = box_min_x;
2300 box_max_y = box_min_y;
2301 box_max_z = box_min_z;
2305 in >> tag >> box_min_x >> box_min_y >> box_min_z >>
2306 box_max_x >> box_max_y >> box_max_z >> n_physicals;
2311 ExcMessage(
"More than one tag is not supported!"));
2313 int physical_tag = 0;
2314 for (
unsigned int j = 0; j < n_physicals; ++j)
2316 tag_maps[0][tag] = physical_tag;
2318 for (
unsigned int i = 0; i < n_curves; ++i)
2322 unsigned int n_physicals;
2323 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2327 in >> tag >> box_min_x >> box_min_y >> box_min_z >> box_max_x >>
2328 box_max_y >> box_max_z >> n_physicals;
2332 ExcMessage(
"More than one tag is not supported!"));
2334 int physical_tag = 0;
2335 for (
unsigned int j = 0; j < n_physicals; ++j)
2337 tag_maps[1][tag] = physical_tag;
2342 for (
unsigned int j = 0; j < n_points; ++j)
2346 for (
unsigned int i = 0; i < n_surfaces; ++i)
2350 unsigned int n_physicals;
2351 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2355 in >> tag >> box_min_x >> box_min_y >> box_min_z >> box_max_x >>
2356 box_max_y >> box_max_z >> n_physicals;
2360 ExcMessage(
"More than one tag is not supported!"));
2362 int physical_tag = 0;
2363 for (
unsigned int j = 0; j < n_physicals; ++j)
2365 tag_maps[2][tag] = physical_tag;
2370 for (
unsigned int j = 0; j < n_curves; ++j)
2373 for (
unsigned int i = 0; i < n_volumes; ++i)
2377 unsigned int n_physicals;
2378 double box_min_x, box_min_y, box_min_z, box_max_x, box_max_y,
2382 in >> tag >> box_min_x >> box_min_y >> box_min_z >> box_max_x >>
2383 box_max_y >> box_max_z >> n_physicals;
2387 ExcMessage(
"More than one tag is not supported!"));
2389 int physical_tag = 0;
2390 for (
unsigned int j = 0; j < n_physicals; ++j)
2392 tag_maps[3][tag] = physical_tag;
2397 for (
unsigned int j = 0; j < n_surfaces; ++j)
2401 AssertThrow(line ==
"@f$EndEntities", ExcInvalidGMSHInput(line));
2406 if (line ==
"@f$PartitionedEntities")
2412 while (line !=
"@f$EndPartitionedEntities");
2419 AssertThrow(line ==
"@f$Nodes", ExcInvalidGMSHInput(line));
2423 int n_entity_blocks = 1;
2424 if (gmsh_file_format > 40)
2428 in >> n_entity_blocks >> n_vertices >> min_node_tag >> max_node_tag;
2430 else if (gmsh_file_format == 40)
2432 in >> n_entity_blocks >> n_vertices;
2436 std::vector<Point<spacedim>> vertices(n_vertices);
2443 unsigned int global_vertex = 0;
2444 for (
int entity_block = 0; entity_block < n_entity_blocks; ++entity_block)
2447 unsigned long numNodes;
2449 if (gmsh_file_format < 40)
2451 numNodes = n_vertices;
2458 int tagEntity, dimEntity;
2459 in >> tagEntity >> dimEntity >> parametric >> numNodes;
2462 std::vector<int> vertex_numbers;
2464 if (gmsh_file_format > 40)
2465 for (
unsigned long vertex_per_entity = 0;
2466 vertex_per_entity < numNodes;
2467 ++vertex_per_entity)
2469 in >> vertex_number;
2470 vertex_numbers.push_back(vertex_number);
2473 for (
unsigned long vertex_per_entity = 0; vertex_per_entity < numNodes;
2474 ++vertex_per_entity, ++global_vertex)
2480 if (gmsh_file_format > 40)
2482 vertex_number = vertex_numbers[vertex_per_entity];
2483 in >> x[0] >> x[1] >> x[2];
2486 in >> vertex_number >> x[0] >> x[1] >> x[2];
2489 global_vertex < n_vertices,
2491 "The Gmsh file lists more nodes than were declared in the "
2492 "header of the @f$Nodes section."));
2494 for (
unsigned int d = 0; d < spacedim; ++d)
2495 vertices[global_vertex][d] = x[d];
2500 if (parametric != 0)
2515 const std::array<std::string, 2> end_nodes_marker{{
"@f$ENDNOD",
"@f$EndNodes"}};
2516 AssertThrow(line == end_nodes_marker[gmsh_file_format == 10 ? 0 : 1],
2517 ExcInvalidGMSHInput(line));
2521 const std::array<std::string, 2> begin_elements_marker{{
"@f$ELM",
"@f$Elements"}};
2522 AssertThrow(line == begin_elements_marker[gmsh_file_format == 10 ? 0 : 1],
2523 ExcInvalidGMSHInput(line));
2526 if (gmsh_file_format > 40)
2530 in >> n_entity_blocks >> n_cells >> min_node_tag >> max_node_tag;
2532 else if (gmsh_file_format == 40)
2534 in >> n_entity_blocks >> n_cells;
2538 n_entity_blocks = 1;
2545 std::vector<CellData<dim>> cells;
2547 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
2553 std::map<unsigned int, unsigned int> vertex_counts;
2556 constexpr std::array<unsigned int, 8> local_vertex_numbering = {
2557 {0, 1, 5, 4, 2, 3, 7, 6}};
2558 unsigned int global_cell = 0;
2559 for (
int entity_block = 0; entity_block < n_entity_blocks; ++entity_block)
2561 unsigned int material_id;
2562 unsigned long numElements;
2565 if (gmsh_file_format < 40)
2569 numElements = n_cells;
2571 else if (gmsh_file_format == 40)
2574 unsigned int dimEntity;
2575 in >> tagEntity >> dimEntity >> cell_type >> numElements;
2577 ExcInvalidGMSHInput(std::to_string(dimEntity)));
2578 material_id = tag_maps[dimEntity][tagEntity];
2584 unsigned int dimEntity;
2585 in >> dimEntity >> tagEntity >> cell_type >> numElements;
2587 ExcInvalidGMSHInput(std::to_string(dimEntity)));
2588 material_id = tag_maps[dimEntity][tagEntity];
2591 for (
unsigned int cell_per_entity = 0; cell_per_entity < numElements;
2592 ++cell_per_entity, ++global_cell)
2601 unsigned int nod_num;
2622 unsigned int elm_number = 0;
2623 if (gmsh_file_format < 40)
2629 if (gmsh_file_format < 20)
2635 else if (gmsh_file_format < 40)
2640 unsigned int n_tags;
2647 for (
unsigned int i = 1; i < n_tags; ++i)
2652 else if (cell_type == 2)
2654 else if (cell_type == 3)
2656 else if (cell_type == 4)
2658 else if (cell_type == 5)
2669 else if (cell_type == 2)
2671 else if (cell_type == 3)
2673 else if (cell_type == 4)
2675 else if (cell_type == 5)
2701 if (((cell_type == 1) && (dim == 1)) ||
2702 ((cell_type == 2) && (dim == 2)) ||
2703 ((cell_type == 3) && (dim == 2)) ||
2704 ((cell_type == 4) && (dim == 3)) ||
2705 ((cell_type == 5) && (dim == 3)))
2708 unsigned int vertices_per_cell = 0;
2710 vertices_per_cell = 2;
2711 else if (cell_type == 2)
2712 vertices_per_cell = 3;
2713 else if (cell_type == 3)
2714 vertices_per_cell = 4;
2715 else if (cell_type == 4)
2716 vertices_per_cell = 4;
2717 else if (cell_type == 5)
2718 vertices_per_cell = 8;
2722 "Number of nodes does not coincide with the "
2723 "number required for this object"));
2726 cells.emplace_back();
2729 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
2732 if (vertices_per_cell ==
2735 local_vertex_numbering[i] :
2743 std::numeric_limits<types::material_id>::max(),
2747 std::numeric_limits<types::material_id>::max()));
2758 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
2762 ExcInvalidVertexIndexGmsh(cell_per_entity,
2767 if constexpr (dim == 1)
2768 vertex_counts[vertex] += 1u;
2772 else if ((cell_type == 1) &&
2773 ((dim == 2) || (dim == 3)))
2782 std::numeric_limits<types::boundary_id>::max(),
2786 std::numeric_limits<types::boundary_id>::max()));
2799 for (
unsigned int &vertex :
2808 ExcInvalidVertexIndex(cell_per_entity,
2813 else if ((cell_type == 2 || cell_type == 3) &&
2817 unsigned int vertices_per_cell = 0;
2820 vertices_per_cell = 3;
2821 else if (cell_type == 3)
2822 vertices_per_cell = 4;
2830 for (
unsigned int i = 0; i < vertices_per_cell; ++i)
2835 std::numeric_limits<types::boundary_id>::max(),
2839 std::numeric_limits<types::boundary_id>::max()));
2852 for (
unsigned int &vertex :
2861 ExcInvalidVertexIndex(cell_per_entity,
2866 else if (cell_type == 15)
2869 unsigned int node_index = 0;
2870 if (gmsh_file_format < 20)
2885 if constexpr (dim == 1)
2890 AssertThrow(
false, ExcGmshUnsupportedGeometry(cell_type));
2898 const std::array<std::string, 2> end_elements_marker{
2899 {
"@f$ENDELM",
"@f$EndElements"}};
2900 AssertThrow(line == end_elements_marker[gmsh_file_format == 10 ? 0 : 1],
2901 ExcInvalidGMSHInput(line));
2913 if constexpr (dim == 1)
2914 for (
const auto &pair : vertex_counts)
2915 if (pair.second == 1u)
2916 boundary_id_pairs.emplace_back(vertices[pair.first],
2917 boundary_ids_1d[pair.first]);
2919 apply_grid_fixup_functions(vertices, cells, subcelldata);
2920 tria->create_triangulation(vertices, cells, subcelldata);
2924 if constexpr (dim == 1)
2925 assign_1d_boundary_ids(boundary_id_pairs, *tria);
2930template <
int dim,
int spacedim>
2934#ifdef DEAL_II_GMSH_WITH_API
2935 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
2937 const std::map<int, std::uint8_t> gmsh_to_dealii_type = {
2938 {{15, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {7, 5}, {6, 6}, {5, 7}}};
2941 const std::array<std::vector<unsigned int>, 8> gmsh_to_dealii = {
2948 {{0, 1, 2, 3, 4, 5}},
2949 {{0, 1, 3, 2, 4, 5, 7, 6}}}};
2951 std::vector<Point<spacedim>> vertices;
2952 std::vector<CellData<dim>> cells;
2954 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
2960 std::map<unsigned int, unsigned int> vertex_counts;
2962# if DEAL_II_GMSH_WITH_API_VERSION_GTE(4, 9, 4)
2964 ExcMessage(
"The GMSH API may only be called after GMSH is "
2965 "initialized, e.g., via the InitFinalize or "
2966 "MPI_InitFinalize classes or the gmsh::initialize() "
2969 gmsh::option::setNumber(
"General.Verbosity", 0);
2974 ExcMessage(
"You are trying to read a gmsh file with dimension " +
2975 std::to_string(gmsh::model::getDimension()) +
2976 " into a grid of dimension " + std::to_string(dim)));
2981 gmsh::model::mesh::removeDuplicateNodes();
2982 gmsh::model::mesh::renumberNodes();
2983 std::vector<std::size_t> node_tags;
2984 std::vector<double> coord;
2985 std::vector<double> parametricCoord;
2986 gmsh::model::mesh::getNodes(
2987 node_tags, coord, parametricCoord, -1, -1,
false,
false);
2988 vertices.resize(node_tags.size());
2989 for (
unsigned int i = 0; i < node_tags.size(); ++i)
2993 for (
unsigned int d = 0; d < spacedim; ++d)
2994 vertices[i][d] = coord[i * 3 + d];
2998 for (
unsigned int d = spacedim; d < 3; ++d)
3001 "The grid you are reading contains nodes that are "
3002 "nonzero in the coordinate with index " +
3004 ", but you are trying to save "
3005 "it on a grid embedded in a " +
3006 std::to_string(spacedim) +
" dimensional space."));
3013 std::vector<std::pair<int, int>> entities;
3014 gmsh::model::getEntities(entities);
3016 for (
const auto &[entity_dim, entity_tag] : entities)
3025 std::vector<int> physical_tags;
3026 gmsh::model::getPhysicalGroupsForEntity(entity_dim,
3031 if (physical_tags.size())
3032 for (
auto physical_tag : physical_tags)
3035 gmsh::model::getPhysicalName(entity_dim, physical_tag, name);
3042 std::map<std::string, int> id_names;
3044 bool found_unrecognized_tag =
false;
3045 bool found_boundary_id =
false;
3048 for (
const auto &[name,
id] : id_names)
3050 if (entity_dim == dim && name ==
"MaterialID")
3053 found_boundary_id =
true;
3055 else if (entity_dim < dim && name ==
"BoundaryID")
3058 found_boundary_id =
true;
3060 else if (name ==
"ManifoldID")
3066 found_unrecognized_tag =
true;
3071 if (found_unrecognized_tag && !found_boundary_id)
3072 boundary_id = physical_tag;
3080 boundary_id = physical_tag;
3086 std::vector<int> element_types;
3087 std::vector<std::vector<std::size_t>> element_ids, element_nodes;
3088 gmsh::model::mesh::getElements(
3089 element_types, element_ids, element_nodes, entity_dim, entity_tag);
3091 for (
unsigned int i = 0; i < element_types.size(); ++i)
3093 const auto &type = gmsh_to_dealii_type.at(element_types[i]);
3094 const auto n_vertices = gmsh_to_dealii[type].size();
3095 const auto &elements = element_ids[i];
3096 const auto &nodes = element_nodes[i];
3097 for (
unsigned int j = 0; j < elements.size(); ++j)
3099 if (entity_dim == dim)
3101 cells.emplace_back(n_vertices);
3102 auto &cell = cells.back();
3103 for (
unsigned int v = 0; v < n_vertices; ++v)
3106 nodes[n_vertices * j + gmsh_to_dealii[type][v]] - 1;
3107 if constexpr (dim == 1)
3108 vertex_counts[cell.vertices[v]] += 1u;
3110 cell.manifold_id = manifold_id;
3111 cell.material_id = boundary_id;
3113 else if (entity_dim == 2)
3117 for (
unsigned int v = 0; v < n_vertices; ++v)
3119 nodes[n_vertices * j + gmsh_to_dealii[type][v]] - 1;
3121 face.manifold_id = manifold_id;
3122 face.boundary_id = boundary_id;
3124 else if (entity_dim == 1)
3128 for (
unsigned int v = 0; v < n_vertices; ++v)
3130 nodes[n_vertices * j + gmsh_to_dealii[type][v]] - 1;
3132 line.manifold_id = manifold_id;
3133 line.boundary_id = boundary_id;
3135 else if (entity_dim == 0)
3139 for (
unsigned int j = 0; j < elements.size(); ++j)
3140 boundary_ids_1d[nodes[j] - 1] = boundary_id;
3150 if constexpr (dim == 1)
3151 for (
const auto &pair : vertex_counts)
3152 if (pair.second == 1u)
3153 boundary_id_pairs.emplace_back(vertices[pair.first],
3154 boundary_ids_1d[pair.first]);
3156 apply_grid_fixup_functions(vertices, cells, subcelldata);
3157 tria->create_triangulation(vertices, cells, subcelldata);
3161 if constexpr (dim == 1)
3162 assign_1d_boundary_ids(boundary_id_pairs, *tria);
3173template <
int dim,
int spacedim>
3176 const std::string &file_suffix)
3178#ifdef DEAL_II_GMSH_WITH_API
3179 auto *parallel_tria =
3185 ExcMessage(
"Triangulation is not fully distributed!"));
3188 MPI_Comm mpi_comm = parallel_tria->get_mpi_communicator();
3194 file_prefix +
"_" + std::to_string(rank + 1) +
"." + file_suffix;
3198 fname = file_prefix +
"." + file_suffix;
3205 for (
unsigned int i = 1; i <= nprocs; ++i)
3207 const std::string check_fname =
3208 file_prefix +
"_" + std::to_string(i) +
"." + file_suffix;
3211 ExcMessage(
"Missing mesh file: " + check_fname));
3214 const std::string extra_fname =
3215 file_prefix +
"_" + std::to_string(nprocs + 1) +
"." + file_suffix;
3216 AssertThrow(!std::filesystem::exists(extra_fname),
3217 ExcMessage(
"Expected " + std::to_string(nprocs) +
3218 " mesh files, but found extra: " + extra_fname));
3221 const std::map<int, std::uint8_t> gmsh_to_dealii_type = {
3222 {15, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4}, {7, 5}, {6, 6}, {5, 7}};
3224 const std::array<std::vector<unsigned int>, 8> gmsh_to_dealii = {
3232 {0, 1, 3, 2, 4, 5, 7, 6}}};
3234# if DEAL_II_GMSH_WITH_API_VERSION_GTE(4, 9, 4)
3236 ExcMessage(
"The GMSH API may only be called after GMSH is "
3237 "initialized, e.g., via the InitFinalize or "
3238 "MPI_InitFinalize classes or the gmsh::initialize() "
3241 gmsh::option::setNumber(
"General.Verbosity", 0);
3245 std::map<unsigned long, unsigned int> ghost_map;
3247 std::vector<std::pair<int, int>> entities;
3248 gmsh::model::getEntities(entities);
3250 for (
const auto &e : entities)
3252 const int entity_dim = e.first;
3253 const int entity_tag = e.second;
3255 if (entity_dim == dim)
3257 std::vector<std::size_t> element_tags;
3258 std::vector<int> partitions;
3260 gmsh::model::mesh::getGhostElements(entity_dim,
3265 for (std::size_t i = 0; i < element_tags.size(); ++i)
3266 ghost_map[element_tags[i]] =
3267 static_cast<unsigned int>(partitions[i] - 1);
3271 std::vector<std::size_t> node_tags;
3272 std::vector<double> coords, parametric_coords;
3273 gmsh::model::mesh::getNodes(node_tags, coords, parametric_coords);
3276 triangulation_description;
3277 triangulation_description.
comm = mpi_comm;
3279 triangulation_description.
cell_infos.resize(1);
3283 std::map<std::size_t, unsigned int> node_tag_to_index;
3284 for (
unsigned int i = 0; i < node_tags.size(); ++i)
3286 node_tag_to_index[node_tags[i]] = i;
3287 for (
unsigned int d = 0; d < spacedim; ++d)
3297 std::vector<std::pair<int, int>> physical_groups;
3298 gmsh::model::getPhysicalGroups(physical_groups);
3300 for (
const auto &[physical_dim, physical_tag] : physical_groups)
3302 std::vector<int> physical_entities;
3303 gmsh::model::getEntitiesForPhysicalGroup(physical_dim,
3307 for (
const int ent : physical_entities)
3310 if (physical_dim == dim - 1)
3311 entity_to_boundary[{physical_dim, ent}] = physical_tag;
3312 if (physical_dim == dim)
3313 entity_to_material[{physical_dim, ent}] = physical_tag;
3322 for (
const auto &e : entities)
3323 if (e.first == dim - 1)
3324 if (
auto it = entity_to_boundary.find({e.first, e.second});
3325 it != entity_to_boundary.end())
3329 std::vector<int> element_types;
3330 std::vector<std::vector<std::size_t>> element_ids, element_nodes;
3333 gmsh::model::mesh::getElements(
3334 element_types, element_ids, element_nodes, e.first, e.second);
3336 for (
unsigned int i = 0; i < element_types.size(); ++i)
3338 if (element_ids[i].empty())
3341 const unsigned int n_nodes_per_elem =
3342 element_nodes[i].size() / element_ids[i].size();
3344 for (
unsigned int j = 0; j < element_ids[i].size(); ++j)
3346 std::set<unsigned int> face_vertices;
3347 for (
unsigned int k = 0; k < n_nodes_per_elem; ++k)
3349 std::size_t node_tag =
3350 element_nodes[i][j * n_nodes_per_elem + k];
3351 face_vertices.insert(node_tag_to_index[node_tag]);
3356 boundary_face_map[face_vertices] = boundary_id;
3364 std::size_t total_volume_elements = 0;
3365 for (
const auto &[entity_dim, entity_tag] : entities)
3367 if (entity_dim == dim)
3369 std::vector<int> count_element_types;
3370 std::vector<std::vector<std::size_t>> count_element_ids,
3371 count_element_nodes;
3373 gmsh::model::mesh::getElements(count_element_types,
3375 count_element_nodes,
3379 for (
const auto &count_element_id : count_element_ids)
3380 total_volume_elements += count_element_id.size();
3385 triangulation_description.
coarse_cells.reserve(total_volume_elements);
3387 total_volume_elements);
3388 triangulation_description.
cell_infos[0].reserve(total_volume_elements);
3390 for (
const auto &[entity_dim, entity_tag] : entities)
3392 if (entity_dim == dim)
3394 std::vector<int> element_types;
3395 std::vector<std::vector<std::size_t>> element_ids, element_nodes;
3397 gmsh::model::mesh::getElements(
3398 element_types, element_ids, element_nodes, entity_dim, entity_tag);
3400 for (
unsigned int i = 0; i < element_types.size(); ++i)
3402 if (element_ids[i].empty())
3405 const unsigned int n_vertices =
3406 element_nodes[i].size() / element_ids[i].size();
3408 for (
unsigned int j = 0; j < element_ids[i].size(); ++j)
3411 if (
auto it = entity_to_material.find({dim, entity_tag});
3412 it != entity_to_material.end())
3415 const auto &type = gmsh_to_dealii_type.at(element_types[i]);
3417 for (
unsigned int v = 0; v < n_vertices; ++v)
3419 const std::size_t node_tag =
3421 [j * n_vertices + gmsh_to_dealii[type][v]];
3423 node_tag_to_index.end(),
3425 std::to_string(node_tag) +
3426 " not found in node list!"));
3427 cell.
vertices[v] = node_tag_to_index[node_tag];
3432 CellId(element_ids[i][j], {}).
template to_binary<dim>();
3434 auto it = ghost_map.find(element_ids[i][j]);
3435 if (it != ghost_map.end())
3444 if constexpr (dim > 0)
3448 ReferenceCells::n_vertices_to_reference_cell<dim>(
3452 const unsigned int n_faces = ref_cell.
n_faces();
3454 for (
unsigned int f = 0; f < n_faces; ++f)
3456 std::set<unsigned int> face_vertices;
3458 if constexpr (dim == 1)
3461 face_vertices.insert(cell.
vertices[f]);
3463 else if constexpr (dim == 2)
3470 face_vertices.insert(cell.
vertices[f]);
3471 face_vertices.insert(
3474 else if (ref_cell ==
3477 const unsigned int n_face_vertices =
3480 for (
unsigned int fv = 0;
3481 fv < n_face_vertices;
3484 const unsigned int vertex_index =
3489 default_geometric_orientation);
3490 face_vertices.insert(
3495 else if constexpr (dim == 3)
3498 const unsigned int n_face_vertices =
3500 for (
unsigned int fv = 0; fv < n_face_vertices;
3503 const unsigned int vertex_index =
3508 face_vertices.insert(
3514 if (
auto it = boundary_face_map.find(face_vertices);
3515 it != boundary_face_map.end())
3520 triangulation_description.
coarse_cells.push_back(cell);
3522 .push_back(element_ids[i][j]);
3523 triangulation_description.
cell_infos[0].push_back(cell_info);
3529 triangulation_description.
settings =
3532 parallel_tria->create_triangulation(triangulation_description);
3535# ifdef DEAL_II_WITH_MPI
3536 const int mpi_ierr = MPI_Barrier(mpi_comm);
3549template <
int dim,
int spacedim>
3552 std::string &header,
3553 std::vector<unsigned int> &tecplot2deal,
3554 unsigned int &n_vars,
3555 unsigned int &n_vertices,
3556 unsigned int &n_cells,
3557 std::vector<unsigned int> &IJK,
3582 std::transform(header.begin(),
3585 static_cast<int (*)(
int)
>(std::toupper));
3589 std::replace(header.begin(), header.end(),
'\t',
' ');
3590 std::replace(header.begin(), header.end(),
',',
' ');
3591 std::replace(header.begin(), header.end(),
'\n',
' ');
3595 std::string::size_type pos = header.find(
'=');
3597 while (pos !=
static_cast<std::string::size_type
>(std::string::npos))
3598 if (header[pos + 1] ==
' ')
3599 header.erase(pos + 1, 1);
3600 else if (header[pos - 1] ==
' ')
3602 header.erase(pos - 1, 1);
3606 pos = header.find(
'=', ++pos);
3609 std::vector<std::string> entries =
3613 for (
unsigned int i = 0; i < entries.size(); ++i)
3622 tecplot2deal[0] = 0;
3625 while (entries[i][0] ==
'"')
3627 if (entries[i] ==
"\"X\"")
3628 tecplot2deal[0] = n_vars;
3629 else if (entries[i] ==
"\"Y\"")
3634 if constexpr (dim > 1)
3635 tecplot2deal[1] = n_vars;
3637 else if (entries[i] ==
"\"Z\"")
3642 if constexpr (dim > 2)
3643 tecplot2deal[2] = n_vars;
3655 "Tecplot file must contain at least one variable for each dimension"));
3656 for (
unsigned int d = 1; d < dim; ++d)
3658 tecplot2deal[d] > 0,
3660 "Tecplot file must contain at least one variable for each dimension."));
3665 "ZONETYPE=FELINESEG") &&
3669 "ZONETYPE=FEQUADRILATERAL") &&
3673 "ZONETYPE=FEBRICK") &&
3681 "The tecplot file contains an unsupported ZONETYPE."));
3684 "DATAPACKING=POINT"))
3687 "DATAPACKING=BLOCK"))
3710 "ET=QUADRILATERAL") &&
3722 "The tecplot file contains an unsupported ElementType."));
3730 dim > 1 || IJK[1] == 1,
3732 "Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1."));
3738 dim > 2 || IJK[2] == 1,
3740 "Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2."));
3755 for (
unsigned int d = 0; d < dim; ++d)
3760 "Tecplot file does not contain a complete and consistent set of parameters"));
3761 n_vertices *= IJK[d];
3762 n_cells *= (IJK[d] - 1);
3770 "Tecplot file does not contain a complete and consistent set of parameters"));
3776 n_cells = *std::max_element(IJK.begin(), IJK.end());
3780 "Tecplot file does not contain a complete and consistent set of parameters"));
3790 const unsigned int dim = 2;
3791 const unsigned int spacedim = 2;
3792 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
3796 skip_comment_lines(in,
'#');
3799 std::string line, header;
3806 std::string letters =
"abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ";
3809 while (line.find_first_of(letters) != std::string::npos)
3811 header +=
" " + line;
3818 std::vector<unsigned int> tecplot2deal(dim);
3819 std::vector<unsigned int> IJK(dim);
3820 unsigned int n_vars, n_vertices, n_cells;
3821 bool structured, blocked;
3823 parse_tecplot_header(header,
3838 std::vector<Point<spacedim>> vertices(n_vertices + 1);
3841 std::vector<CellData<dim>> cells(n_cells);
3857 unsigned int next_index = 0;
3861 if (tecplot2deal[0] == 0)
3865 std::vector<std::string> first_var =
3868 for (
unsigned int i = 1; i < first_var.size() + 1; ++i)
3869 vertices[i][0] = std::strtod(first_var[i - 1].c_str(), &endptr);
3874 for (
unsigned int j = first_var.size() + 1; j < n_vertices + 1; ++j)
3875 in >> vertices[j][next_index];
3882 for (
unsigned int i = 1; i < n_vars; ++i)
3891 if (next_index == dim && structured)
3894 if ((next_index < dim) && (i == tecplot2deal[next_index]))
3897 for (
unsigned int j = 1; j < n_vertices + 1; ++j)
3898 in >> vertices[j][next_index];
3905 for (
unsigned int j = 1; j < n_vertices + 1; ++j)
3917 std::vector<double> vars(n_vars);
3922 std::vector<std::string> first_vertex =
3925 for (
unsigned int d = 0; d < dim; ++d)
3927 std::strtod(first_vertex[tecplot2deal[d]].c_str(), &endptr);
3931 for (
unsigned int v = 2; v < n_vertices + 1; ++v)
3933 for (
unsigned int i = 0; i < n_vars; ++i)
3939 for (
unsigned int i = 0; i < dim; ++i)
3940 vertices[v][i] = vars[tecplot2deal[i]];
3948 unsigned int I = IJK[0], J = IJK[1];
3950 unsigned int cell = 0;
3952 for (
unsigned int j = 0; j < J - 1; ++j)
3953 for (
unsigned int i = 1; i < I; ++i)
3955 cells[cell].vertices[0] = i + j * I;
3956 cells[cell].vertices[1] = i + 1 + j * I;
3957 cells[cell].vertices[2] = i + (j + 1) * I;
3958 cells[cell].vertices[3] = i + 1 + (j + 1) * I;
3962 std::vector<unsigned int> boundary_vertices(2 * I + 2 * J - 4);
3964 for (
unsigned int i = 1; i < I + 1; ++i)
3966 boundary_vertices[k] = i;
3968 boundary_vertices[k] = i + (J - 1) * I;
3971 for (
unsigned int j = 1; j < J - 1; ++j)
3973 boundary_vertices[k] = 1 + j * I;
3975 boundary_vertices[k] = I + j * I;
3994 for (
unsigned int i = 0; i < n_cells; ++i)
4011 apply_grid_fixup_functions(vertices, cells, subcelldata);
4012 tria->create_triangulation(vertices, cells, subcelldata);
4017template <
int dim,
int spacedim>
4026template <
int dim,
int spacedim>
4029 const unsigned int mesh_index,
4030 const bool remove_duplicates,
4032 const bool ignore_unsupported_types)
4034#ifdef DEAL_II_WITH_ASSIMP
4039 Assimp::Importer importer;
4042 const aiScene *scene =
4043 importer.ReadFile(filename.c_str(),
4044 aiProcess_RemoveComponent |
4045 aiProcess_JoinIdenticalVertices |
4046 aiProcess_ImproveCacheLocality | aiProcess_SortByPType |
4047 aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);
4053 ExcMessage(
"Input file contains no meshes."));
4056 (mesh_index < scene->mNumMeshes),
4059 unsigned int start_mesh =
4061 unsigned int end_mesh =
4066 std::vector<Point<spacedim>> vertices;
4067 std::vector<CellData<dim>> cells;
4071 unsigned int v_offset = 0;
4072 unsigned int c_offset = 0;
4074 constexpr std::array<unsigned int, 8> local_vertex_numbering = {
4075 {0, 1, 5, 4, 2, 3, 7, 6}};
4077 for (
unsigned int m = start_mesh; m < end_mesh; ++m)
4079 const aiMesh *mesh = scene->mMeshes[m];
4083 if ((dim == 2) && mesh->mPrimitiveTypes != aiPrimitiveType_POLYGON)
4086 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
4087 "/" + std::to_string(scene->mNumMeshes)));
4090 else if ((dim == 1) && mesh->mPrimitiveTypes != aiPrimitiveType_LINE)
4093 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
4094 "/" + std::to_string(scene->mNumMeshes)));
4098 const unsigned int n_vertices = mesh->mNumVertices;
4099 const aiVector3D *mVertices = mesh->mVertices;
4102 const unsigned int n_faces = mesh->mNumFaces;
4103 const aiFace *mFaces = mesh->mFaces;
4105 vertices.resize(v_offset + n_vertices);
4106 cells.resize(c_offset + n_faces);
4108 for (
unsigned int i = 0; i < n_vertices; ++i)
4109 for (
unsigned int d = 0; d < spacedim; ++d)
4110 vertices[i + v_offset][d] = mVertices[i][d];
4112 unsigned int valid_cell = c_offset;
4113 for (
unsigned int i = 0; i < n_faces; ++i)
4120 .vertices[dim == 3 ? local_vertex_numbering[f] :
4122 mFaces[i].mIndices[f] + v_offset;
4124 cells[valid_cell].material_id = m;
4130 ExcMessage(
"Face " + std::to_string(i) +
" of mesh " +
4131 std::to_string(m) +
" has " +
4132 std::to_string(mFaces[i].mNumIndices) +
4133 " vertices. We expected only " +
4138 cells.resize(valid_cell);
4143 v_offset += n_vertices;
4144 c_offset = valid_cell;
4151 if (remove_duplicates)
4156 unsigned int n_verts = 0;
4157 while (n_verts != vertices.size())
4159 n_verts = vertices.size();
4160 std::vector<unsigned int> considered_vertices;
4162 vertices, cells, subcelldata, considered_vertices, tol);
4166 apply_grid_fixup_functions(vertices, cells, subcelldata);
4167 tria->create_triangulation(vertices, cells, subcelldata);
4172 (void)remove_duplicates;
4174 (void)ignore_unsupported_types;
4181template <
int dim,
int spacedim>
4186 ExcMessage(
"The ugrid format reader currently supports only 2- and "
4187 "3-dimensional meshes."));
4188 Assert(tria !=
nullptr, ExcNoTriangulationSelected());
4195 unsigned int n_nodes, n_tris, n_quads, n_tets, n_pyramids, n_wedges, n_hexes;
4196 in >> n_nodes >> n_tris >> n_quads >> n_tets >> n_pyramids >> n_wedges >>
4198 if constexpr (dim == 2)
4200 n_tris + n_quads > 0,
4202 "When reading a 2-dimensional triangulation, "
4203 "there need to be more than zero triangles or quadrilaterals."));
4205 AssertThrow(n_tets + n_pyramids + n_wedges + n_hexes > 0,
4206 ExcMessage(
"When reading a 3-dimensional triangulation, "
4207 "there need to be more than zero tetrahedra, "
4208 "pyramids, wedges, or hexahedra."));
4211 std::vector<Point<spacedim>> vertices(n_nodes);
4218 for (
unsigned int d = spacedim; d < 3; ++d)
4225 "You are reading a mesh in spacedim=" + std::to_string(spacedim) +
4226 " but some of the vertex positions have trailing coordinates "
4227 "that are not zero."));
4232 std::vector<CellData<2>> objects_2d;
4233 objects_2d.reserve(n_tris + n_quads);
4234 for (
unsigned int i = 0; i < n_tris; ++i)
4240 for (
unsigned int &vertex_index :
object.vertices)
4245 objects_2d.emplace_back(
object);
4247 for (
unsigned int i = 0; i < n_quads; ++i)
4252 "Reading quadrilaterals is not currently implemented by the ugrid "
4253 "reader because we do not know the order of vertices and have no example "
4254 "to look at. If you have a test file, please contact us and/or help us "
4255 "implement this missing case."));
4262 for (
auto &
object : objects_2d)
4263 if constexpr (dim == 2)
4264 in >>
object.material_id;
4266 in >>
object.boundary_id;
4270 std::vector<CellData<3>> objects_3d;
4271 objects_3d.reserve(n_tets + n_pyramids + n_wedges + n_hexes);
4272 for (
unsigned int i = 0; i < n_tets; ++i)
4277 "Reading tetrahedra is not currently implemented by the ugrid "
4278 "reader because we do not know the order of vertices and have no example "
4279 "to look at. If you have a test file, please contact us and/or help us "
4280 "implement this missing case."));
4282 for (
unsigned int i = 0; i < n_pyramids; ++i)
4287 "Reading pyramids is not currently implemented by the ugrid "
4288 "reader because we do not know the order of vertices and have no example "
4289 "to look at. If you have a test file, please contact us and/or help us "
4290 "implement this missing case."));
4292 for (
unsigned int i = 0; i < n_wedges; ++i)
4297 "Reading wedges is not currently implemented by the ugrid "
4298 "reader because we do not know the order of vertices and have no example "
4299 "to look at. If you have a test file, please contact us and/or help us "
4300 "implement this missing case."));
4302 for (
unsigned int i = 0; i < n_hexes; ++i)
4307 "Reading hexahdrea is not currently implemented by the ugrid "
4308 "reader because we do not know the order of vertices and have no example "
4309 "to look at. If you have a test file, please contact us and/or help us "
4310 "implement this missing case."));
4333 unsigned int n_lines;
4335 std::vector<CellData<1>> objects_1d(n_lines);
4338 line.vertices.resize(2);
4341 for (
unsigned int &vertex_index : line.vertices)
4348 in >> line.boundary_id;
4352 if constexpr (dim == 2)
4356 tria->create_triangulation(vertices, objects_2d, face_data);
4364#ifdef DEAL_II_TRILINOS_WITH_SEACAS
4373 exodusii_name_to_type(
const std::string &type_name,
4374 const int n_nodes_per_element)
4380 std::string type_name_2 = type_name;
4381 std::transform(type_name_2.begin(),
4383 type_name_2.begin(),
4384 static_cast<int (*)(
int)
>(std::toupper));
4385 const std::string
numbers =
"0123456789";
4386 type_name_2.erase(std::find_first_of(type_name_2.begin(),
4393 if constexpr (dim == 1)
4395 if (type_name_2 ==
"BAR" || type_name_2 ==
"BEAM" ||
4396 type_name_2 ==
"EDGE" || type_name_2 ==
"TRUSS")
4399 else if constexpr (dim == 2)
4401 if (type_name_2 ==
"TRI" || type_name_2 ==
"TRIANGLE")
4403 else if (type_name_2 ==
"QUAD" || type_name_2 ==
"QUADRILATERAL")
4405 else if (type_name_2 ==
"SHELL")
4407 if (n_nodes_per_element == 3)
4413 else if constexpr (dim == 3)
4415 if (type_name_2 ==
"TET" || type_name_2 ==
"TETRA" ||
4416 type_name_2 ==
"TETRAHEDRON")
4418 else if (type_name_2 ==
"PYRA" || type_name_2 ==
"PYRAMID")
4420 else if (type_name_2 ==
"WEDGE")
4422 else if (type_name_2 ==
"HEX" || type_name_2 ==
"HEXAHEDRON")
4426 return ReferenceCells::Invalid<dim>;
4432 template <
int dim,
int spacedim = dim>
4433 std::pair<SubCellData, std::vector<std::vector<int>>>
4434 read_exodusii_sidesets(
const int ex_id,
4435 const int n_sidesets,
4437 const bool apply_all_indicators_to_manifolds)
4440 std::vector<std::vector<int>> b_or_m_id_to_sideset_ids;
4442 b_or_m_id_to_sideset_ids.emplace_back();
4448 if (dim == spacedim && n_sidesets > 0)
4450 std::vector<int> sideset_ids(n_sidesets);
4451 int ierr = ex_get_ids(ex_id, EX_SIDE_SET, sideset_ids.data());
4453 std::sort(sideset_ids.begin(), sideset_ids.end());
4460 std::size_t n_total_sides = 0;
4461 for (
const int &sideset_id : sideset_ids)
4464 int n_distribution_factors = -1;
4466 ierr = ex_get_set_param(ex_id,
4470 &n_distribution_factors);
4473 n_total_sides += std::size_t(n_sides);
4475 std::vector<std::pair<std::size_t, int>> face_sidesets;
4476 face_sidesets.reserve(n_total_sides);
4478 for (
const int &sideset_id : sideset_ids)
4481 int n_distribution_factors = -1;
4483 ierr = ex_get_set_param(ex_id,
4487 &n_distribution_factors);
4491 std::vector<int> elements(n_sides);
4492 std::vector<int> faces(n_sides);
4493 ierr = ex_get_set(ex_id,
4506 for (
int side_n = 0; side_n < n_sides; ++side_n)
4508 const long cell_n = elements[side_n] - 1;
4510 const long face_n = faces[side_n] - 1;
4512 const std::size_t face_id =
4513 cell_n * ReferenceCells::max_n_faces<dim>() + face_n;
4514 face_sidesets.emplace_back(face_id, sideset_id);
4519 std::sort(face_sidesets.begin(), face_sidesets.end());
4524 std::deque<ArrayView<std::pair<std::size_t, int>>>
4525 face_id_to_sideset_ids;
4526 if (face_sidesets.size() > 0)
4528 auto start = face_sidesets.begin();
4529 for (
auto it = face_sidesets.begin() + 1; it < face_sidesets.end();
4531 if (start->first != it->first)
4533 face_id_to_sideset_ids.emplace_back(
4537 face_id_to_sideset_ids.emplace_back(
4544 std::stable_sort(face_id_to_sideset_ids.begin(),
4545 face_id_to_sideset_ids.end(),
4546 [](
const auto &a,
const auto &b) {
4547 return std::lexicographical_compare(
4552 [](const auto &c, const auto &d) {
4553 return c.second < d.second;
4557 if constexpr (dim == 2)
4558 subcelldata.
boundary_lines.reserve(face_id_to_sideset_ids.size());
4559 else if constexpr (dim == 3)
4560 subcelldata.
boundary_quads.reserve(face_id_to_sideset_ids.size());
4562 std::vector<int> face_sideset_ids;
4563 for (
const auto &pairs : face_id_to_sideset_ids)
4565 const std::size_t face_id = pairs[0].first;
4566 Assert(std::all_of(pairs.begin(),
4568 [&](
const auto &a) {
4569 return a.first == face_id;
4572 face_sideset_ids.resize(pairs.size());
4573 for (std::size_t i = 0; i < pairs.size(); ++i)
4574 face_sideset_ids[i] = pairs[i].
second;
4576 if (face_sideset_ids != b_or_m_id_to_sideset_ids.back())
4581 Assert(std::find(b_or_m_id_to_sideset_ids.begin(),
4582 b_or_m_id_to_sideset_ids.end(),
4583 face_sideset_ids) ==
4584 b_or_m_id_to_sideset_ids.end(),
4586 ++current_b_or_m_id;
4587 b_or_m_id_to_sideset_ids.emplace_back(face_sideset_ids.begin(),
4588 face_sideset_ids.end());
4589 Assert(current_b_or_m_id == b_or_m_id_to_sideset_ids.size() - 1,
4593 const unsigned int local_face_n =
4594 face_id % ReferenceCells::max_n_faces<dim>();
4596 cells[face_id / ReferenceCells::max_n_faces<dim>()];
4598 ReferenceCells::n_vertices_to_reference_cell<dim>(
4600 const unsigned int deal_face_n =
4602 const auto face_reference_cell =
4608 if constexpr (dim == 2)
4610 CellData<1> boundary_line(face_reference_cell.n_vertices());
4611 if (apply_all_indicators_to_manifolds)
4612 boundary_line.manifold_id = current_b_or_m_id;
4614 boundary_line.boundary_id = current_b_or_m_id;
4615 for (
unsigned int j = 0; j < face_reference_cell.n_vertices();
4617 boundary_line.vertices[j] =
4619 deal_face_n, j, 0)];
4623 else if constexpr (dim == 3)
4625 CellData<2> boundary_quad(face_reference_cell.n_vertices());
4626 if (apply_all_indicators_to_manifolds)
4627 boundary_quad.manifold_id = current_b_or_m_id;
4629 boundary_quad.boundary_id = current_b_or_m_id;
4630 for (
unsigned int j = 0; j < face_reference_cell.n_vertices();
4632 boundary_quad.vertices[j] =
4634 deal_face_n, j, 0)];
4641 return std::make_pair(std::move(subcelldata),
4642 std::move(b_or_m_id_to_sideset_ids));
4647template <
int dim,
int spacedim>
4650 const std::string &filename,
4651 const bool apply_all_indicators_to_manifolds)
4653#ifdef DEAL_II_TRILINOS_WITH_SEACAS
4655 int component_word_size =
sizeof(double);
4657 int floating_point_word_size = 0;
4658 float ex_version = 0.0;
4660 const int ex_id = ex_open(filename.c_str(),
4662 &component_word_size,
4663 &floating_point_word_size,
4666 ExcMessage(
"ExodusII failed to open the specified input file."));
4669 std::vector<char> string_temp(MAX_LINE_LENGTH + 1,
'\0');
4670 int mesh_dimension = 0;
4673 int n_element_blocks = 0;
4677 int ierr = ex_get_init(ex_id,
4696 std::vector<Point<spacedim>> vertices;
4697 vertices.reserve(n_nodes);
4699 std::vector<double> xs(n_nodes);
4700 std::vector<double> ys(n_nodes);
4701 std::vector<double> zs(n_nodes);
4703 ierr = ex_get_coord(ex_id, xs.data(), ys.data(), zs.data());
4706 for (
int vertex_n = 0; vertex_n < n_nodes; ++vertex_n)
4711 vertices.emplace_back(xs[vertex_n]);
4714 vertices.emplace_back(xs[vertex_n], ys[vertex_n]);
4717 vertices.emplace_back(xs[vertex_n], ys[vertex_n], zs[vertex_n]);
4725 std::vector<int> element_block_ids(n_element_blocks);
4726 ierr = ex_get_ids(ex_id, EX_ELEM_BLOCK, element_block_ids.data());
4729 std::vector<CellData<dim>> cells;
4730 cells.reserve(n_elements);
4734 for (
const int element_block_id : element_block_ids)
4736 std::fill(string_temp.begin(), string_temp.end(),
'\0');
4737 int n_block_elements = 0;
4738 int n_nodes_per_element = 0;
4739 int n_edges_per_element = 0;
4740 int n_faces_per_element = 0;
4741 int n_attributes_per_element = 0;
4744 ierr = ex_get_block(ex_id,
4749 &n_nodes_per_element,
4750 &n_edges_per_element,
4751 &n_faces_per_element,
4752 &n_attributes_per_element);
4755 exodusii_name_to_type<dim>(string_temp.data(), n_nodes_per_element);
4758 "The ExodusII block " + std::to_string(element_block_id) +
4759 " with element type " + std::string(string_temp.data()) +
4760 " does not have a corresponding ReferenceCell<dim> with a"
4761 " dimension matching the topological mesh dimension " +
4762 std::to_string(dim) +
"."));
4769 std::vector<int> connection(n_nodes_per_element * n_block_elements);
4770 ierr = ex_get_conn(ex_id,
4778 for (
unsigned int elem_n = 0; elem_n < connection.size();
4779 elem_n += n_nodes_per_element)
4782 for (
const unsigned int i : type.vertex_indices())
4784 cell.
vertices[type.exodusii_vertex_to_deal_vertex(i)] =
4785 connection[elem_n + i] - 1;
4788 cells.push_back(std::move(cell));
4793 auto pair = read_exodusii_sidesets<dim, spacedim>(
4794 ex_id, n_sidesets, cells, apply_all_indicators_to_manifolds);
4795 ierr = ex_close(ex_id);
4798 apply_grid_fixup_functions(vertices, cells, pair.first);
4799 tria->create_triangulation(vertices, cells, pair.first);
4805 (void)apply_all_indicators_to_manifolds;
4812template <
int dim,
int spacedim>
4826 if (std::find_if(line.begin(), line.end(), [](
const char c) {
4831 for (
int i = line.size() - 1; i >= 0; --i)
4832 in.putback(line[i]);
4842template <
int dim,
int spacedim>
4845 const char comment_start)
4850 while (in.get(c) && c == comment_start)
4853 while (in.get() !=
'\n')
4863 skip_empty_lines(in);
4868template <
int dim,
int spacedim>
4883 const std::vector<
Point<2>> &vertices,
4886 double min_x = vertices[cells[0].vertices[0]][0],
4887 max_x = vertices[cells[0].vertices[0]][0],
4888 min_y = vertices[cells[0].vertices[0]][1],
4889 max_y = vertices[cells[0].vertices[0]][1];
4891 for (
unsigned int i = 0; i < cells.size(); ++i)
4893 for (
const auto vertex : cells[i].vertices)
4895 const Point<2> &p = vertices[vertex];
4907 out <<
"# cell " << i << std::endl;
4909 for (
const auto vertex : cells[i].vertices)
4910 center += vertices[vertex];
4913 out <<
"set label \"" << i <<
"\" at " << center[0] <<
',' << center[1]
4914 <<
" center" << std::endl;
4917 for (
unsigned int f = 0; f < 2; ++f)
4918 out <<
"set arrow from " << vertices[cells[i].vertices[f]][0] <<
','
4919 << vertices[cells[i].vertices[f]][1] <<
" to "
4920 << vertices[cells[i].vertices[(f + 1) % 4]][0] <<
','
4921 << vertices[cells[i].vertices[(f + 1) % 4]][1] << std::endl;
4923 for (
unsigned int f = 2; f < 4; ++f)
4924 out <<
"set arrow from " << vertices[cells[i].vertices[(f + 1) % 4]][0]
4925 <<
',' << vertices[cells[i].vertices[(f + 1) % 4]][1] <<
" to "
4926 << vertices[cells[i].vertices[f]][0] <<
','
4927 << vertices[cells[i].vertices[f]][1] << std::endl;
4933 <<
"set nokey" << std::endl
4934 <<
"pl [" << min_x <<
':' << max_x <<
"][" << min_y <<
':' << max_y
4935 <<
"] " << min_y << std::endl
4936 <<
"pause -1" << std::endl;
4944 const std::vector<
Point<3>> &vertices,
4947 for (
const auto &cell : cells)
4950 out << vertices[cell.
vertices[0]] << std::endl
4951 << vertices[cell.
vertices[1]] << std::endl
4955 out << vertices[cell.
vertices[1]] << std::endl
4956 << vertices[cell.
vertices[2]] << std::endl
4960 out << vertices[cell.
vertices[3]] << std::endl
4961 << vertices[cell.
vertices[2]] << std::endl
4965 out << vertices[cell.
vertices[0]] << std::endl
4966 << vertices[cell.
vertices[3]] << std::endl
4970 out << vertices[cell.
vertices[4]] << std::endl
4971 << vertices[cell.
vertices[5]] << std::endl
4975 out << vertices[cell.
vertices[5]] << std::endl
4976 << vertices[cell.
vertices[6]] << std::endl
4980 out << vertices[cell.
vertices[7]] << std::endl
4981 << vertices[cell.
vertices[6]] << std::endl
4985 out << vertices[cell.
vertices[4]] << std::endl
4986 << vertices[cell.
vertices[7]] << std::endl
4990 out << vertices[cell.
vertices[0]] << std::endl
4991 << vertices[cell.
vertices[4]] << std::endl
4995 out << vertices[cell.
vertices[1]] << std::endl
4996 << vertices[cell.
vertices[5]] << std::endl
5000 out << vertices[cell.
vertices[2]] << std::endl
5001 << vertices[cell.
vertices[6]] << std::endl
5005 out << vertices[cell.
vertices[3]] << std::endl
5006 << vertices[cell.
vertices[7]] << std::endl
5014template <
int dim,
int spacedim>
5021 if (format == Default)
5023 const std::string::size_type slashpos = filename.find_last_of(
'/');
5024 const std::string::size_type dotpos = filename.find_last_of(
'.');
5025 if (dotpos < filename.size() &&
5026 (dotpos > slashpos || slashpos == std::string::npos))
5028 std::string ext = filename.substr(dotpos + 1);
5029 format = parse_format(ext);
5033 if (format == assimp)
5035 read_assimp(filename);
5037 else if (format == exodusii)
5039 read_exodusii(filename);
5043 std::ifstream in(filename);
5049template <
int dim,
int spacedim>
5053 if (format == Default)
5054 format = default_format;
5100 ExcMessage(
"There is no read_assimp(istream &) function. "
5101 "Use the read_assimp(string &filename, ...) "
5102 "functions, instead."));
5107 ExcMessage(
"There is no read_exodusii(istream &) function. "
5108 "Use the read_exodusii(string &filename, ...) "
5109 "function, instead."));
5120template <
int dim,
int spacedim>
5151 return ".unknown_format";
5157template <
int dim,
int spacedim>
5161 if (format_name ==
"dbmesh")
5164 if (format_name ==
"exodusii")
5167 if (format_name ==
"msh")
5170 if (format_name ==
"unv")
5173 if (format_name ==
"vtk")
5176 if (format_name ==
"vtu")
5180 if (format_name ==
"inp")
5183 if (format_name ==
"ucd")
5186 if (format_name ==
"xda")
5189 if (format_name ==
"tecplot")
5192 if (format_name ==
"dat")
5195 if (format_name ==
"ugrid")
5198 if (format_name ==
"plt")
5217template <
int dim,
int spacedim>
5221 return "dbmesh|exodusii|msh|unv|vtk|vtu|ucd|abaqus|xda|tecplot|assimp|ugrid";
5228 template <
int dim,
int spacedim>
5229 Abaqus_to_UCD<dim, spacedim>::Abaqus_to_UCD()
5242 from_string(T &t,
const std::string &s, std::ios_base &(*f)(std::ios_base &))
5244 std::istringstream iss(s);
5245 return !(iss >> f >> t).fail();
5252 extract_int(
const std::string &s)
5255 for (
const char c : s)
5257 if (std::isdigit(c) != 0)
5264 from_string(number, tmp, std::dec);
5270 template <
int dim,
int spacedim>
5272 Abaqus_to_UCD<dim, spacedim>::read_in_abaqus(std::istream &input_stream)
5281 while (std::getline(input_stream, line))
5284 std::transform(line.begin(),
5287 static_cast<int (*)(
int)
>(std::toupper));
5289 if (line.compare(
"*HEADING") == 0 || line.compare(0, 2,
"**") == 0 ||
5290 line.compare(0, 5,
"*PART") == 0)
5293 while (std::getline(input_stream, line))
5299 else if (line.compare(0, 5,
"*NODE") == 0)
5308 while (std::getline(input_stream, line))
5313 std::vector<double> node(spacedim + 1);
5315 std::istringstream iss(line);
5317 for (
unsigned int i = 0; i < spacedim + 1; ++i)
5318 iss >> node[i] >> comma;
5320 node_list.push_back(node);
5323 else if (line.compare(0, 8,
"*ELEMENT") == 0)
5338 const std::string before_material =
"ELSET=EB";
5339 const std::size_t idx = line.find(before_material);
5340 if (idx != std::string::npos)
5342 from_string(material,
5343 line.substr(idx + before_material.size()),
5349 while (std::getline(input_stream, line))
5354 std::istringstream iss(line);
5360 const unsigned int n_data_per_cell =
5362 std::vector<double> cell(n_data_per_cell);
5363 for (
unsigned int i = 0; i < n_data_per_cell; ++i)
5364 iss >> cell[i] >> comma;
5367 cell[0] =
static_cast<double>(material);
5368 cell_list.push_back(cell);
5371 else if (line.compare(0, 8,
"*SURFACE") == 0)
5382 const std::string name_key =
"NAME=";
5383 const std::size_t name_idx_start =
5384 line.find(name_key) + name_key.size();
5385 std::size_t name_idx_end = line.find(
',', name_idx_start);
5386 if (name_idx_end == std::string::npos)
5388 name_idx_end = line.size();
5390 const int b_indicator = extract_int(
5391 line.substr(name_idx_start, name_idx_end - name_idx_start));
5398 while (std::getline(input_stream, line))
5404 std::transform(line.begin(),
5407 static_cast<int (*)(
int)
>(std::toupper));
5412 std::istringstream iss(line);
5419 std::vector<double> quad_node_list;
5420 const std::string elset_name = line.substr(0, line.find(
','));
5421 if (elsets_list.count(elset_name) != 0)
5425 iss >> stmp >> temp >> face_number;
5427 const std::vector<int> cells = elsets_list[elset_name];
5428 for (
const int cell : cells)
5432 get_global_node_numbers(el_idx, face_number);
5433 quad_node_list.insert(quad_node_list.begin(),
5436 face_list.push_back(quad_node_list);
5443 iss >> el_idx >> comma >> temp >> face_number;
5445 get_global_node_numbers(el_idx, face_number);
5446 quad_node_list.insert(quad_node_list.begin(), b_indicator);
5448 face_list.push_back(quad_node_list);
5452 else if (line.compare(0, 6,
"*ELSET") == 0)
5456 std::string elset_name;
5458 const std::string elset_key =
"*ELSET, ELSET=";
5459 const std::size_t idx = line.find(elset_key);
5460 if (idx != std::string::npos)
5462 const std::string comma =
",";
5463 const std::size_t first_comma = line.find(comma);
5464 const std::size_t second_comma =
5465 line.find(comma, first_comma + 1);
5466 const std::size_t elset_name_start =
5467 line.find(elset_key) + elset_key.size();
5468 elset_name = line.substr(elset_name_start,
5469 second_comma - elset_name_start);
5479 std::vector<int> elements;
5480 const std::size_t generate_idx = line.find(
"GENERATE");
5481 if (generate_idx != std::string::npos)
5484 std::getline(input_stream, line);
5485 std::istringstream iss(line);
5495 iss >> elid_start >> comma >> elid_end;
5499 "While reading an ABAQUS file, the reader "
5500 "expected a comma but found a <") +
5501 comma +
"> in the line <" + line +
">."));
5503 elid_start <= elid_end,
5506 "While reading an ABAQUS file, the reader encountered "
5507 "a GENERATE statement in which the upper bound <") +
5509 "> for the element numbers is not larger or equal "
5510 "than the lower bound <" +
5514 if (iss.rdbuf()->in_avail() != 0)
5515 iss >> comma >> elis_step;
5519 "While reading an ABAQUS file, the reader "
5520 "expected a comma but found a <") +
5521 comma +
"> in the line <" + line +
">."));
5523 for (
int i = elid_start; i <= elid_end; i += elis_step)
5524 elements.push_back(i);
5525 elsets_list[elset_name] = elements;
5527 std::getline(input_stream, line);
5532 while (std::getline(input_stream, line))
5537 std::istringstream iss(line);
5542 iss >> elid >> comma;
5547 "While reading an ABAQUS file, the reader "
5548 "expected a comma but found a <") +
5549 comma +
"> in the line <" + line +
">."));
5551 elements.push_back(elid);
5555 elsets_list[elset_name] = elements;
5560 else if (line.compare(0, 5,
"*NSET") == 0)
5563 while (std::getline(input_stream, line))
5569 else if (line.compare(0, 14,
"*SOLID SECTION") == 0)
5573 const std::string elset_key =
"ELSET=";
5574 const std::size_t elset_start =
5575 line.find(
"ELSET=") + elset_key.size();
5576 const std::size_t elset_end = line.find(
',', elset_start + 1);
5577 const std::string elset_name =
5578 line.substr(elset_start, elset_end - elset_start);
5583 const std::string material_key =
"MATERIAL=";
5584 const std::size_t last_equal =
5585 line.find(
"MATERIAL=") + material_key.size();
5586 const std::size_t material_id_start = line.find(
'-', last_equal);
5588 from_string(material_id,
5589 line.substr(material_id_start + 1),
5593 const std::vector<int> &elset_cells = elsets_list[elset_name];
5594 for (
const int elset_cell : elset_cells)
5596 const int cell_id = elset_cell - 1;
5604 template <
int dim,
int spacedim>
5606 Abaqus_to_UCD<dim, spacedim>::get_global_node_numbers(
5607 const int face_cell_no,
5608 const int face_cell_face_no)
const
5613 Assert((face_cell_no >= 1) &&
5614 (
static_cast<typename decltype(cell_list)::
size_type>(
5615 face_cell_no) <= cell_list.size()),
5622 if constexpr (dim == 2)
5624 if (face_cell_face_no == 1)
5626 quad_node_list[0] = cell_list[face_cell_no - 1][1];
5627 quad_node_list[1] = cell_list[face_cell_no - 1][2];
5629 else if (face_cell_face_no == 2)
5631 quad_node_list[0] = cell_list[face_cell_no - 1][2];
5632 quad_node_list[1] = cell_list[face_cell_no - 1][3];
5634 else if (face_cell_face_no == 3)
5636 quad_node_list[0] = cell_list[face_cell_no - 1][3];
5637 quad_node_list[1] = cell_list[face_cell_no - 1][4];
5639 else if (face_cell_face_no == 4)
5641 quad_node_list[0] = cell_list[face_cell_no - 1][4];
5642 quad_node_list[1] = cell_list[face_cell_no - 1][1];
5650 else if constexpr (dim == 3)
5652 if (face_cell_face_no == 1)
5654 quad_node_list[0] = cell_list[face_cell_no - 1][1];
5655 quad_node_list[1] = cell_list[face_cell_no - 1][4];
5656 quad_node_list[2] = cell_list[face_cell_no - 1][3];
5657 quad_node_list[3] = cell_list[face_cell_no - 1][2];
5659 else if (face_cell_face_no == 2)
5661 quad_node_list[0] = cell_list[face_cell_no - 1][5];
5662 quad_node_list[1] = cell_list[face_cell_no - 1][8];
5663 quad_node_list[2] = cell_list[face_cell_no - 1][7];
5664 quad_node_list[3] = cell_list[face_cell_no - 1][6];
5666 else if (face_cell_face_no == 3)
5668 quad_node_list[0] = cell_list[face_cell_no - 1][1];
5669 quad_node_list[1] = cell_list[face_cell_no - 1][2];
5670 quad_node_list[2] = cell_list[face_cell_no - 1][6];
5671 quad_node_list[3] = cell_list[face_cell_no - 1][5];
5673 else if (face_cell_face_no == 4)
5675 quad_node_list[0] = cell_list[face_cell_no - 1][2];
5676 quad_node_list[1] = cell_list[face_cell_no - 1][3];
5677 quad_node_list[2] = cell_list[face_cell_no - 1][7];
5678 quad_node_list[3] = cell_list[face_cell_no - 1][6];
5680 else if (face_cell_face_no == 5)
5682 quad_node_list[0] = cell_list[face_cell_no - 1][3];
5683 quad_node_list[1] = cell_list[face_cell_no - 1][4];
5684 quad_node_list[2] = cell_list[face_cell_no - 1][8];
5685 quad_node_list[3] = cell_list[face_cell_no - 1][7];
5687 else if (face_cell_face_no == 6)
5689 quad_node_list[0] = cell_list[face_cell_no - 1][1];
5690 quad_node_list[1] = cell_list[face_cell_no - 1][5];
5691 quad_node_list[2] = cell_list[face_cell_no - 1][8];
5692 quad_node_list[3] = cell_list[face_cell_no - 1][4];
5705 return quad_node_list;
5708 template <
int dim,
int spacedim>
5710 Abaqus_to_UCD<dim, spacedim>::write_out_avs_ucd(std::ostream &output)
const
5719 const boost::io::ios_base_all_saver formatting_saver(output);
5723 output <<
"# Abaqus to UCD mesh conversion" <<
'\n';
5724 output <<
"# Mesh type: AVS UCD" <<
'\n';
5753 output << node_list.size() <<
"\t" << (cell_list.size() + face_list.size())
5754 <<
"\t0\t0\t0" <<
'\n';
5758 output.setf(std::ios::scientific, std::ios::floatfield);
5759 for (
const auto &node : node_list)
5763 output << static_cast<int>(node[0]) <<
"\t";
5767 for (
unsigned int jj = 1; jj < spacedim + 1; ++jj)
5770 output.precision(16);
5773 if (
std::abs(node[jj]) > tolerance)
5774 output << static_cast<double>(node[jj]) <<
"\t";
5776 output << 0.0 <<
"\t";
5779 output << 0.0 <<
"\t";
5783 output.unsetf(std::ios::floatfield);
5786 for (
unsigned int ii = 0; ii < cell_list.size(); ++ii)
5788 output << ii + 1 <<
"\t" << cell_list[ii][0] <<
"\t"
5789 << (dim == 2 ?
"quad" :
"hex") <<
"\t";
5790 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_cell + 1;
5792 output << cell_list[ii][jj] <<
"\t";
5798 for (
unsigned int ii = 0; ii < face_list.size(); ++ii)
5800 output << ii + 1 <<
"\t" << face_list[ii][0] <<
"\t"
5801 << (dim == 2 ?
"line" :
"quad") <<
"\t";
5802 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_face + 1;
5804 output << face_list[ii][jj] <<
"\t";
5809 output << std::flush;
5815#include "grid/grid_in.inst"
* * for(const auto &cell :triangulation.active_cell_iterators())
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
void read_vtk(std::istream &in)
static void skip_empty_lines(std::istream &in)
void read_partitioned_msh(const std::string &file_prefix, const std::string &file_suffix="msh")
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_ugrid(std::istream &in)
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)
const std::map< std::string, Vector< double > > & get_cell_data() const
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)
constexpr ReferenceCell< dim - 1 > face_reference_cell(const unsigned int face_index) const
constexpr unsigned int n_faces() const
unsigned int face_to_cell_vertices(const unsigned int face, const unsigned int vertex, const types::geometric_orientation face_orientation) const
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
constexpr iterator end() noexcept
constexpr size_type size() const noexcept
constexpr iterator begin() noexcept
#define DEAL_II_NAMESPACE_OPEN
constexpr bool running_in_debug_mode()
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ASSERT_UNREACHABLE()
#define DEAL_II_NOT_IMPLEMENTED()
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 & ExcNeedsGMSHAPI()
static ::ExceptionBase & ExcNeedsExodusII()
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertThrowExodusII(error_code)
#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)
std::vector< index_type > data
types::global_dof_index size_type
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell< dim > &reference_cell)
* * if(update_pressure &update_flags) * compute_pressure(constitutive_request
* * * * std::vector< Number > ThermoPlasticMaterial< dim, ViscoplasticYieldLaw, Number >::get_state_parameters const
constexpr ReferenceCell< 3 > Hexahedron
constexpr ReferenceCell< 2 > Quadrilateral
constexpr ReferenceCell< 1 > Line
constexpr ReferenceCell< 2 > Triangle
constexpr ReferenceCell< 3 > Tetrahedron
constexpr ReferenceCell< 3 > Pyramid
constexpr ReferenceCell< 3 > Wedge
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
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)
constexpr unsigned int invalid_unsigned_int
constexpr types::boundary_id internal_face_boundary_id
constexpr types::boundary_id invalid_boundary_id
constexpr types::manifold_id flat_manifold_id
constexpr types::material_id invalid_material_id
constexpr types::geometric_orientation default_geometric_orientation
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
std_cxx26::inplace_vector< unsigned int, ReferenceCells::max_n_vertices< structdim >()> 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
types::subdomain_id subdomain_id
types::subdomain_id level_subdomain_id
std_cxx26::inplace_vector< std::pair< unsigned int, types::boundary_id >, ReferenceCells::max_n_faces< dim >()> boundary_ids
types::material_id material_id
std::vector< std::vector< CellData< dim > > > cell_infos
std::vector<::CellData< dim > > coarse_cells
std::vector< Point< spacedim > > coarse_cell_vertices
std::vector< types::coarse_cell_id > coarse_cell_index_to_coarse_cell_id