17 #include <deal.II/base/exceptions.h> 18 #include <deal.II/base/path_search.h> 19 #include <deal.II/base/utilities.h> 21 #include <deal.II/grid/grid_in.h> 22 #include <deal.II/grid/grid_reordering.h> 23 #include <deal.II/grid/grid_tools.h> 24 #include <deal.II/grid/tria.h> 26 #include <boost/io/ios_state.hpp> 35 #ifdef DEAL_II_WITH_NETCDF 36 # include <netcdfcpp.h> 39 #ifdef DEAL_II_WITH_ASSIMP 40 # include <assimp/Importer.hpp> 41 # include <assimp/postprocess.h> 42 # include <assimp/scene.h> 46 DEAL_II_NAMESPACE_OPEN
59 template <
int spacedim>
61 assign_1d_boundary_ids(
62 const std::map<unsigned int, types::boundary_id> &boundary_ids,
65 if (boundary_ids.size() > 0)
68 cell != triangulation.
end();
70 for (
unsigned int f = 0; f < GeometryInfo<1>::faces_per_cell; ++f)
71 if (boundary_ids.find(cell->vertex_index(f)) != boundary_ids.end())
76 "You are trying to prescribe boundary ids on the face " 77 "of a 1d cell (i.e., on a vertex), but this face is not actually at " 78 "the boundary of the mesh. This is not allowed."));
79 cell->face(f)->set_boundary_id(
80 boundary_ids.find(cell->vertex_index(f))->second);
85 template <
int dim,
int spacedim>
87 assign_1d_boundary_ids(
const std::map<unsigned int, types::boundary_id> &,
96 template <
int dim,
int spacedim>
98 : tria(nullptr, typeid(*this).name())
103 template <
int dim,
int spacedim>
112 template <
int dim,
int spacedim>
125 text[0] =
"# vtk DataFile Version 3.0";
128 text[3] =
"DATASET UNSTRUCTURED_GRID";
130 for (
unsigned int i = 0; i < 4; ++i)
135 line.compare(text[i]) == 0,
138 "While reading VTK file, failed to find a header line with text <") +
145 std::vector<Point<spacedim>> vertices;
146 std::vector<CellData<dim>> cells;
155 if (keyword ==
"POINTS")
157 unsigned int n_vertices;
163 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
167 in >> x(0) >> x(1) >> x(2);
169 vertices.emplace_back();
170 for (
unsigned int d = 0; d < spacedim; ++d)
171 vertices.back()(d) = x(d);
178 "While reading VTK file, failed to find POINTS section"));
183 std::string checkline;
188 getline(in, checkline);
189 if (checkline.compare(
"") != 0)
199 if (keyword ==
"CELLS")
201 unsigned int n_geometric_objects;
202 in >> n_geometric_objects;
203 in.ignore(256,
'\n');
207 for (
unsigned int count = 0; count < n_geometric_objects; count++)
220 cells.emplace_back();
222 for (
unsigned int j = 0; j < type; j++)
223 in >> cells.back().vertices[j];
225 cells.back().material_id = 0;
232 for (
unsigned int j = 0; j < type;
243 "While reading VTK file, unknown file type encountered"));
249 for (
unsigned int count = 0; count < n_geometric_objects; count++)
261 cells.emplace_back();
263 for (
unsigned int j = 0; j < type; j++)
264 in >> cells.back().vertices[j];
266 cells.back().material_id = 0;
275 for (
unsigned int j = 0; j < type;
288 "While reading VTK file, unknown file type encountered"));
294 "While reading VTK file, failed to find CELLS section"));
304 in.ignore(256,
'\n');
306 while (!in.fail() && !in.eof())
309 if (keyword !=
"12" && keyword !=
"9")
319 if (keyword ==
"CELL_DATA")
325 n_ids == cells.size() +
330 "The VTK reader found a CELL_DATA statement " 331 "that lists a total of " +
333 " cell data objects, but this needs to " 334 "equal the number of cells (which is " +
336 ") plus the number of quads (" +
338 " in 3d or the number of lines (" +
344 std::string textnew[2];
345 textnew[0] =
"SCALARS MaterialID double";
346 textnew[1] =
"LOOKUP_TABLE default";
348 in.ignore(256,
'\n');
350 for (
unsigned int i = 0; i < 2; i++)
352 getline(in, linenew);
354 if (linenew.size() > textnew[0].size())
355 linenew.resize(textnew[0].size());
360 "While reading VTK file, failed to find <") +
361 textnew[i] +
"> section"));
368 for (
unsigned int i = 0; i < cells.size(); i++)
372 cells[i].material_id = id;
406 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
413 "While reading VTK file, failed to find CELLS section"));
418 template <
int dim,
int spacedim>
439 std::vector<Point<spacedim>> vertices;
458 in >> dummy >> dummy >> dummy;
461 in >> x[0] >> x[1] >> x[2];
463 vertices.emplace_back();
465 for (
unsigned int d = 0; d < spacedim; d++)
466 vertices.back()(d) = x[d];
468 vertex_indices[no] = no_vertex;
482 std::vector<CellData<dim>> cells;
509 in >> type >> dummy >> dummy >> dummy >> dummy;
511 AssertThrow((type == 11) || (type == 44) || (type == 94) || (type == 115),
514 if ((((type == 44) || (type == 94)) && (dim == 2)) ||
515 ((type == 115) && (dim == 3)))
517 cells.emplace_back();
520 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell;
522 in >> cells.back().vertices[v];
524 cells.back().material_id = 0;
526 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell;
528 cells.back().vertices[v] = vertex_indices[cells.back().vertices[v]];
530 cell_indices[no] = no_cell;
534 else if (((type == 11) && (dim == 2)) ||
535 ((type == 11) && (dim == 3)))
538 in >> dummy >> dummy >> dummy;
543 for (
unsigned int v = 0; v < 2; v++)
548 for (
unsigned int v = 0; v < 2; v++)
552 line_indices[no] = no_line;
556 else if (((type == 44) || (type == 94)) && (dim == 3))
561 for (
unsigned int v = 0; v < 4; v++)
566 for (
unsigned int v = 0; v < 4; v++)
570 quad_indices[no] = no_quad;
578 "> when running in dim=" +
613 in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >>
619 const unsigned int n_lines =
620 (n_entities % 2 == 0) ? (n_entities / 2) : ((n_entities + 1) / 2);
622 for (
unsigned int line = 0; line < n_lines; line++)
624 unsigned int n_fragments;
626 if (line == n_lines - 1)
627 n_fragments = (n_entities % 2 == 0) ? (2) : (1);
631 for (
unsigned int no_fragment = 0; no_fragment < n_fragments;
635 in >> dummy >> no >> dummy >> dummy;
637 if (cell_indices.count(no) > 0)
638 cells[cell_indices[no]].material_id =
id;
640 if (line_indices.count(no) > 0)
644 if (quad_indices.count(no) > 0)
662 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
667 template <
int dim,
int spacedim>
670 const bool apply_all_indicators_to_manifolds)
679 unsigned int n_vertices;
680 unsigned int n_cells;
683 in >> n_vertices >> n_cells >> dummy
689 std::vector<Point<spacedim>> vertices(n_vertices);
693 std::map<int, int> vertex_indices;
695 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
702 in >> vertex_number >> x[0] >> x[1] >> x[2];
705 for (
unsigned int d = 0; d < spacedim; ++d)
706 vertices[vertex](d) = x[d];
710 vertex_indices[vertex_number] = vertex;
714 std::vector<CellData<dim>> cells;
717 for (
unsigned int cell = 0; cell < n_cells; ++cell)
726 std::string cell_type;
730 unsigned int material_id;
736 if (((cell_type ==
"line") && (dim == 1)) ||
737 ((cell_type ==
"quad") && (dim == 2)) ||
738 ((cell_type ==
"hex") && (dim == 3)))
742 cells.emplace_back();
743 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell;
745 in >> cells.back().vertices[i];
748 Assert(material_id <= std::numeric_limits<types::material_id>::max(),
751 std::numeric_limits<types::material_id>::max()));
757 cells.back().material_id =
762 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell;
764 if (vertex_indices.find(cells.back().vertices[i]) !=
765 vertex_indices.end())
767 cells.back().vertices[i] =
768 vertex_indices[cells.back().vertices[i]];
774 cells.back().vertices[i]));
779 else if ((cell_type ==
"line") && ((dim == 2) || (dim == 3)))
787 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
790 std::numeric_limits<types::boundary_id>::max()));
798 if (apply_all_indicators_to_manifolds)
807 for (
unsigned int i = 0; i < 2; ++i)
808 if (vertex_indices.find(
810 vertex_indices.end())
825 else if ((cell_type ==
"quad") && (dim == 3))
835 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
838 std::numeric_limits<types::boundary_id>::max()));
846 if (apply_all_indicators_to_manifolds)
855 for (
unsigned int i = 0; i < 4; ++i)
856 if (vertex_indices.find(
858 vertex_indices.end())
890 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
902 read_in_abaqus(std::istream &in);
904 write_out_avs_ucd(std::ostream &out)
const;
907 const double tolerance;
910 get_global_node_numbers(
const int face_cell_no,
911 const int face_cell_face_no)
const;
914 std::vector<std::vector<double>> node_list;
917 std::vector<std::vector<double>> cell_list;
919 std::vector<std::vector<double>> face_list;
922 std::map<std::string, std::vector<int>> elsets_list;
926 template <
int dim,
int spacedim>
929 const bool apply_all_indicators_to_manifolds)
937 Abaqus_to_UCD<dim> abaqus_to_ucd;
938 abaqus_to_ucd.read_in_abaqus(in);
940 std::stringstream in_ucd;
941 abaqus_to_ucd.write_out_avs_ucd(in_ucd);
949 read_ucd(in_ucd, apply_all_indicators_to_manifolds);
951 catch (std::exception &exc)
953 std::cerr <<
"Exception on processing internal UCD data: " << std::endl
954 << exc.what() << std::endl;
959 "Internal conversion from ABAQUS file to UCD format was unsuccessful. " 960 "More information is provided in an error message printed above. " 961 "Are you sure that your ABAQUS mesh file conforms with the requirements " 962 "listed in the documentation?"));
969 "Internal conversion from ABAQUS file to UCD format was unsuccessful. " 970 "Are you sure that your ABAQUS mesh file conforms with the requirements " 971 "listed in the documentation?"));
976 template <
int dim,
int spacedim>
999 unsigned int dimension;
1015 while (getline(in, line), line.find(
"# END") == std::string::npos)
1024 unsigned int n_vertices;
1028 std::vector<Point<spacedim>> vertices(n_vertices);
1029 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1032 for (
unsigned int d = 0; d < dim; ++d)
1033 in >> vertices[vertex][d];
1047 unsigned int n_edges;
1049 for (
unsigned int edge = 0; edge < n_edges; ++edge)
1052 in >> dummy >> dummy;
1070 for (
unsigned int edge = 0; edge < n_edges; ++edge)
1073 in >> dummy >> dummy;
1087 std::vector<CellData<dim>> cells;
1089 unsigned int n_cells;
1091 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1095 cells.emplace_back();
1096 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell; ++i)
1098 in >> cells.back().vertices[i];
1101 (static_cast<unsigned int>(cells.back().vertices[i]) <=
1105 --cells.back().vertices[i];
1121 while (getline(in, line), ((line.find(
"End") == std::string::npos) && (in)))
1138 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
1143 template <
int dim,
int spacedim>
1164 unsigned int n_vertices;
1165 unsigned int n_cells;
1175 for (
unsigned int i = 0; i < 8; ++i)
1179 std::vector<CellData<2>> cells(n_cells);
1182 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1192 for (
unsigned int i = 0; i < 4; ++i)
1193 in >> cells[cell].vertices[i];
1199 std::vector<Point<2>> vertices(n_vertices);
1200 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1205 in >> x[0] >> x[1] >> x[2];
1208 for (
unsigned int d = 0; d < 2; ++d)
1209 vertices[vertex](d) = x[d];
1218 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
1230 static const unsigned int xda_to_dealII_map[] = {0, 1, 5, 4, 3, 2, 6, 7};
1237 unsigned int n_vertices;
1238 unsigned int n_cells;
1248 for (
unsigned int i = 0; i < 8; ++i)
1252 std::vector<CellData<3>> cells(n_cells);
1255 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1265 unsigned int xda_ordered_nodes[8];
1267 for (
unsigned int i = 0; i < 8; ++i)
1268 in >> xda_ordered_nodes[i];
1270 for (
unsigned int i = 0; i < 8; i++)
1271 cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]];
1277 std::vector<Point<3>> vertices(n_vertices);
1278 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1283 in >> x[0] >> x[1] >> x[2];
1286 for (
unsigned int d = 0; d < 3; ++d)
1287 vertices[vertex](d) = x[d];
1296 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
1301 template <
int dim,
int spacedim>
1308 unsigned int n_vertices;
1309 unsigned int n_cells;
1316 unsigned int gmsh_file_format = 0;
1317 if (line ==
"@f$NOD")
1318 gmsh_file_format = 1;
1319 else if (line ==
"@f$MeshFormat")
1320 gmsh_file_format = 2;
1327 if (gmsh_file_format == 2)
1330 unsigned int file_type, data_size;
1332 in >> version >> file_type >> data_size;
1349 if (line ==
"@f$PhysicalNames")
1355 while (line !=
"@f$EndPhysicalNames");
1367 std::vector<Point<spacedim>> vertices(n_vertices);
1371 std::map<int, int> vertex_indices;
1373 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
1379 in >> vertex_number >> x[0] >> x[1] >> x[2];
1381 for (
unsigned int d = 0; d < spacedim; ++d)
1382 vertices[vertex](d) = x[d];
1384 vertex_indices[vertex_number] = vertex;
1389 static const std::string end_nodes_marker[] = {
"@f$ENDNOD",
"@f$EndNodes"};
1390 AssertThrow(line == end_nodes_marker[gmsh_file_format - 1],
1395 static const std::string begin_elements_marker[] = {
"@f$ELM",
"@f$Elements"};
1396 AssertThrow(line == begin_elements_marker[gmsh_file_format - 1],
1404 std::vector<CellData<dim>> cells;
1406 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
1408 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1417 unsigned int cell_type;
1418 unsigned int material_id;
1419 unsigned int nod_num;
1434 unsigned int elm_number;
1438 switch (gmsh_file_format)
1453 unsigned int n_tags;
1460 for (
unsigned int i = 1; i < n_tags; ++i)
1488 if (((cell_type == 1) && (dim == 1)) ||
1489 ((cell_type == 3) && (dim == 2)) || ((cell_type == 5) && (dim == 3)))
1493 ExcMessage(
"Number of nodes does not coincide with the " 1494 "number required for this object"));
1497 cells.emplace_back();
1498 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell;
1500 in >> cells.back().vertices[i];
1503 Assert(material_id <= std::numeric_limits<types::material_id>::max(),
1506 std::numeric_limits<types::material_id>::max()));
1512 cells.back().material_id =
1517 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell;
1520 AssertThrow(vertex_indices.find(cells.back().vertices[i]) !=
1521 vertex_indices.end(),
1524 cells.back().vertices[i]));
1527 cells.back().vertices[i] =
1528 vertex_indices[cells.back().vertices[i]];
1531 else if ((cell_type == 1) && ((dim == 2) || (dim == 3)))
1539 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
1542 std::numeric_limits<types::boundary_id>::max()));
1555 for (
unsigned int i = 0; i < 2; ++i)
1556 if (vertex_indices.find(
1558 vertex_indices.end())
1573 else if ((cell_type == 3) && (dim == 3))
1583 Assert(material_id <= std::numeric_limits<types::boundary_id>::max(),
1586 std::numeric_limits<types::boundary_id>::max()));
1599 for (
unsigned int i = 0; i < 4; ++i)
1600 if (vertex_indices.find(
1602 vertex_indices.end())
1616 else if (cell_type == 15)
1619 unsigned int node_index = 0;
1620 switch (gmsh_file_format)
1624 for (
unsigned int i = 0; i < nod_num; ++i)
1640 boundary_ids_1d[vertex_indices[node_index]] = material_id;
1651 ExcMessage(
"Found triangles while reading a file " 1652 "in gmsh format. deal.II does not " 1653 "support triangles"));
1655 ExcMessage(
"Found tetrahedra while reading a file " 1656 "in gmsh format. deal.II does not " 1657 "support tetrahedra"));
1665 static const std::string end_elements_marker[] = {
"@f$ENDELM",
"@f$EndElements"};
1666 AssertThrow(line == end_elements_marker[gmsh_file_format - 1],
1682 if (dim == spacedim)
1686 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
1691 assign_1d_boundary_ids(boundary_ids_1d, *
tria);
1729 #ifndef DEAL_II_WITH_NETCDF 1733 const unsigned int dim = 2;
1734 const unsigned int spacedim = 2;
1758 const unsigned int coord = 1;
1764 const unsigned int x2d = 0;
1765 const unsigned int y2d = 2;
1774 NcFile nc(filename.c_str());
1778 NcDim *elements_dim = nc.get_dim(
"no_of_elements");
1780 const unsigned int n_cells = elements_dim->size();
1784 NcDim *marker_dim = nc.get_dim(
"no_of_markers");
1786 const unsigned int n_markers = marker_dim->size();
1788 NcVar *marker_var = nc.get_var(
"marker");
1791 AssertThrow(static_cast<unsigned int>(marker_var->get_dim(0)->size()) ==
1795 std::vector<int> marker(n_markers);
1798 marker_var->get(&*marker.begin(), n_markers);
1803 NcDim *bquads_dim = nc.get_dim(
"no_of_surfacequadrilaterals");
1805 const unsigned int n_bquads = bquads_dim->size();
1807 NcVar *bmarker_var = nc.get_var(
"boundarymarker_of_surfaces");
1810 AssertThrow(static_cast<unsigned int>(bmarker_var->get_dim(0)->size()) ==
1814 std::vector<int> bmarker(n_bquads);
1815 bmarker_var->get(&*bmarker.begin(), n_bquads);
1820 std::map<int, unsigned int> n_bquads_per_bmarker;
1821 for (
unsigned int i = 0; i < n_markers; ++i)
1825 AssertThrow(n_bquads_per_bmarker.find(marker[i]) ==
1826 n_bquads_per_bmarker.end(),
1829 n_bquads_per_bmarker[marker[i]] =
1830 count(bmarker.begin(), bmarker.end(), marker[i]);
1849 NcDim *quad_vertices_dim = nc.get_dim(
"points_per_surfacequadrilateral");
1851 const unsigned int vertices_per_quad = quad_vertices_dim->size();
1855 NcVar *vertex_indices_var = nc.get_var(
"points_of_surfacequadrilaterals");
1859 vertex_indices_var->get_dim(0)->size()) == n_bquads,
1862 vertex_indices_var->get_dim(1)->size()) == vertices_per_quad,
1865 std::vector<int> vertex_indices(n_bquads * vertices_per_quad);
1866 vertex_indices_var->get(&*vertex_indices.begin(),
1870 for (
unsigned int i = 0; i < vertex_indices.size(); ++i)
1877 NcDim *vertices_dim = nc.get_dim(
"no_of_points");
1879 const unsigned int n_vertices = vertices_dim->size();
1881 NcVar *points_xc = nc.get_var(
"points_xc");
1882 NcVar *points_yc = nc.get_var(
"points_yc");
1883 NcVar *points_zc = nc.get_var(
"points_zc");
1890 AssertThrow(points_yc->get_dim(0)->size() ==
static_cast<int>(n_vertices),
1892 AssertThrow(points_zc->get_dim(0)->size() ==
static_cast<int>(n_vertices),
1894 AssertThrow(points_xc->get_dim(0)->size() ==
static_cast<int>(n_vertices),
1896 std::vector<std::vector<double>> point_values(
1897 3, std::vector<double>(n_vertices));
1898 points_xc->get(&*point_values[0].begin(), n_vertices);
1899 points_yc->get(&*point_values[1].begin(), n_vertices);
1900 points_zc->get(&*point_values[2].begin(), n_vertices);
1903 std::vector<Point<spacedim>> vertices(n_vertices);
1904 for (
unsigned int i = 0; i < n_vertices; ++i)
1906 vertices[i](0) = point_values[x2d][i];
1907 vertices[i](1) = point_values[y2d][i];
1913 std::map<int, bool> zero_plane_markers;
1914 for (
unsigned int quad = 0; quad < n_bquads; ++quad)
1916 bool zero_plane =
true;
1917 for (
unsigned int i = 0; i < vertices_per_quad; ++i)
1918 if (point_values[coord][vertex_indices[quad * vertices_per_quad + i]] !=
1926 zero_plane_markers[bmarker[quad]] =
true;
1928 unsigned int sum_of_zero_plane_cells = 0;
1929 for (std::map<int, bool>::const_iterator iter = zero_plane_markers.begin();
1930 iter != zero_plane_markers.end();
1932 sum_of_zero_plane_cells += n_bquads_per_bmarker[iter->first];
1938 std::vector<CellData<dim>> cells(n_cells);
1939 for (
unsigned int quad = 0, cell = 0; quad < n_bquads; ++quad)
1941 bool zero_plane =
false;
1942 for (std::map<int, bool>::const_iterator iter =
1943 zero_plane_markers.begin();
1944 iter != zero_plane_markers.end();
1946 if (bmarker[quad] == iter->first)
1954 for (
unsigned int i = 0; i < vertices_per_quad; ++i)
1958 [vertex_indices[quad * vertices_per_quad + i]] == 0,
1960 cells[cell].vertices[i] =
1961 vertex_indices[quad * vertices_per_quad + i];
1970 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
1979 #ifndef DEAL_II_WITH_NETCDF 1986 const unsigned int dim = 3;
1987 const unsigned int spacedim = 3;
1993 NcFile nc(filename.c_str());
1997 NcDim *elements_dim = nc.get_dim(
"no_of_elements");
1999 const unsigned int n_cells = elements_dim->size();
2001 NcDim *hexes_dim = nc.get_dim(
"no_of_hexaeders");
2003 const unsigned int n_hexes = hexes_dim->size();
2005 ExcMessage(
"deal.II can handle purely hexaedral grids, only."));
2011 NcDim *hex_vertices_dim = nc.get_dim(
"points_per_hexaeder");
2013 const unsigned int vertices_per_hex = hex_vertices_dim->size();
2017 NcVar *vertex_indices_var = nc.get_var(
"points_of_hexaeders");
2021 vertex_indices_var->get_dim(0)->size()) == n_cells,
2024 vertex_indices_var->get_dim(1)->size()) == vertices_per_hex,
2027 std::vector<int> vertex_indices(n_cells * vertices_per_hex);
2030 vertex_indices_var->get(&*vertex_indices.begin(), n_cells, vertices_per_hex);
2032 for (
unsigned int i = 0; i < vertex_indices.size(); ++i)
2039 NcDim *vertices_dim = nc.get_dim(
"no_of_points");
2041 const unsigned int n_vertices = vertices_dim->size();
2043 NcVar *points_xc = nc.get_var(
"points_xc");
2044 NcVar *points_yc = nc.get_var(
"points_yc");
2045 NcVar *points_zc = nc.get_var(
"points_zc");
2052 AssertThrow(points_yc->get_dim(0)->size() ==
static_cast<int>(n_vertices),
2054 AssertThrow(points_zc->get_dim(0)->size() ==
static_cast<int>(n_vertices),
2056 AssertThrow(points_xc->get_dim(0)->size() ==
static_cast<int>(n_vertices),
2058 std::vector<std::vector<double>> point_values(
2059 3, std::vector<double>(n_vertices));
2060 points_xc->get(&*point_values[0].begin(), n_vertices);
2061 points_yc->get(&*point_values[1].begin(), n_vertices);
2062 points_zc->get(&*point_values[2].begin(), n_vertices);
2065 std::vector<Point<spacedim>> vertices(n_vertices);
2066 for (
unsigned int i = 0; i < n_vertices; ++i)
2068 vertices[i](0) = point_values[0][i];
2069 vertices[i](1) = point_values[1][i];
2070 vertices[i](2) = point_values[2][i];
2074 std::vector<CellData<dim>> cells(n_cells);
2075 for (
unsigned int cell = 0; cell < n_cells; ++cell)
2076 for (
unsigned int i = 0; i < vertices_per_hex; ++i)
2077 cells[cell].vertices[i] = vertex_indices[cell * vertices_per_hex + i];
2088 NcDim *quad_vertices_dim = nc.get_dim(
"points_per_surfacequadrilateral");
2090 const unsigned int vertices_per_quad = quad_vertices_dim->size();
2094 NcVar *bvertex_indices_var = nc.get_var(
"points_of_surfacequadrilaterals");
2097 const unsigned int n_bquads = bvertex_indices_var->get_dim(0)->size();
2099 bvertex_indices_var->get_dim(1)->size()) ==
2103 std::vector<int> bvertex_indices(n_bquads * vertices_per_quad);
2104 bvertex_indices_var->get(&*bvertex_indices.begin(),
2111 NcDim *bquads_dim = nc.get_dim(
"no_of_surfacequadrilaterals");
2113 AssertThrow(static_cast<unsigned int>(bquads_dim->size()) == n_bquads,
2116 NcVar *bmarker_var = nc.get_var(
"boundarymarker_of_surfaces");
2119 AssertThrow(static_cast<unsigned int>(bmarker_var->get_dim(0)->size()) ==
2123 std::vector<int> bmarker(n_bquads);
2124 bmarker_var->get(&*bmarker.begin(), n_bquads);
2130 for (
unsigned int i = 0; i < bmarker.size(); ++i)
2131 Assert(0 <= bmarker[i] && static_cast<types::boundary_id>(bmarker[i]) !=
2139 for (
unsigned int i = 0; i < n_bquads; ++i)
2141 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face; ++v)
2145 static_cast<types::boundary_id>(bmarker[i]);
2152 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
2157 template <
int dim,
int spacedim>
2160 std::string & header,
2161 std::vector<unsigned int> &tecplot2deal,
2162 unsigned int & n_vars,
2163 unsigned int & n_vertices,
2164 unsigned int & n_cells,
2165 std::vector<unsigned int> &IJK,
2179 DEAL_II_FALLTHROUGH;
2182 DEAL_II_FALLTHROUGH;
2190 std::transform(header.begin(), header.end(), header.begin(), ::toupper);
2194 std::replace(header.begin(), header.end(),
'\t',
' ');
2195 std::replace(header.begin(), header.end(),
',',
' ');
2196 std::replace(header.begin(), header.end(),
'\n',
' ');
2200 std::string::size_type pos = header.find(
'=');
2202 while (pos != static_cast<std::string::size_type>(std::string::npos))
2203 if (header[pos + 1] ==
' ')
2204 header.erase(pos + 1, 1);
2205 else if (header[pos - 1] ==
' ')
2207 header.erase(pos - 1, 1);
2211 pos = header.find(
'=', ++pos);
2214 std::vector<std::string> entries =
2218 for (
unsigned int i = 0; i < entries.size(); ++i)
2227 tecplot2deal[0] = 0;
2230 while (entries[i][0] ==
'"')
2232 if (entries[i] ==
"\"X\"")
2233 tecplot2deal[0] = n_vars;
2234 else if (entries[i] ==
"\"Y\"")
2240 tecplot2deal[1] = n_vars;
2242 else if (entries[i] ==
"\"Z\"")
2248 tecplot2deal[2] = n_vars;
2260 "Tecplot file must contain at least one variable for each dimension"));
2261 for (
unsigned int d = 1; d < dim; ++d)
2263 tecplot2deal[d] > 0,
2265 "Tecplot file must contain at least one variable for each dimension."));
2270 "ZONETYPE=FELINESEG") &&
2274 "ZONETYPE=FEQUADRILATERAL") &&
2278 "ZONETYPE=FEBRICK") &&
2286 "The tecplot file contains an unsupported ZONETYPE."));
2289 "DATAPACKING=POINT"))
2292 "DATAPACKING=BLOCK"))
2315 "ET=QUADRILATERAL") &&
2327 "The tecplot file contains an unsupported ElementType."));
2335 dim > 1 || IJK[1] == 1,
2337 "Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1."));
2343 dim > 2 || IJK[2] == 1,
2345 "Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2."));
2360 for (
unsigned int d = 0; d < dim; ++d)
2365 "Tecplot file does not contain a complete and consistent set of parameters"));
2366 n_vertices *= IJK[d];
2367 n_cells *= (IJK[d] - 1);
2375 "Tecplot file does not contain a complete and consistent set of parameters"));
2381 n_cells = *std::max_element(IJK.begin(), IJK.end());
2385 "Tecplot file does not contain a complete and consistent set of parameters"));
2395 const unsigned int dim = 2;
2396 const unsigned int spacedim = 2;
2404 std::string line, header;
2411 std::string letters =
"abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ";
2414 while (line.find_first_of(letters) != std::string::npos)
2416 header +=
" " + line;
2423 std::vector<unsigned int> tecplot2deal(dim);
2424 std::vector<unsigned int> IJK(dim);
2425 unsigned int n_vars, n_vertices, n_cells;
2426 bool structured, blocked;
2443 std::vector<Point<spacedim>> vertices(n_vertices + 1);
2446 std::vector<CellData<dim>> cells(n_cells);
2462 unsigned int next_index = 0;
2466 if (tecplot2deal[0] == 0)
2470 std::vector<std::string> first_var =
2473 for (
unsigned int i = 1; i < first_var.size() + 1; ++i)
2474 vertices[i](0) = std::strtod(first_var[i - 1].c_str(), &endptr);
2479 for (
unsigned int j = first_var.size() + 1; j < n_vertices + 1; ++j)
2480 in >> vertices[j](next_index);
2487 for (
unsigned int i = 1; i < n_vars; ++i)
2496 if (next_index == dim && structured)
2499 if ((next_index < dim) && (i == tecplot2deal[next_index]))
2502 for (
unsigned int j = 1; j < n_vertices + 1; ++j)
2503 in >> vertices[j](next_index);
2510 for (
unsigned int j = 1; j < n_vertices + 1; ++j)
2522 std::vector<double> vars(n_vars);
2527 std::vector<std::string> first_vertex =
2530 for (
unsigned int d = 0; d < dim; ++d)
2532 std::strtod(first_vertex[tecplot2deal[d]].c_str(), &endptr);
2536 for (
unsigned int v = 2; v < n_vertices + 1; ++v)
2538 for (
unsigned int i = 0; i < n_vars; ++i)
2544 for (
unsigned int i = 0; i < dim; ++i)
2545 vertices[v](i) = vars[tecplot2deal[i]];
2553 unsigned int I = IJK[0], J = IJK[1];
2555 unsigned int cell = 0;
2557 for (
unsigned int j = 0; j < J - 1; ++j)
2558 for (
unsigned int i = 1; i < I; ++i)
2560 cells[cell].vertices[0] = i + j * I;
2561 cells[cell].vertices[1] = i + 1 + j * I;
2562 cells[cell].vertices[2] = i + 1 + (j + 1) * I;
2563 cells[cell].vertices[3] = i + (j + 1) * I;
2567 std::vector<unsigned int> boundary_vertices(2 * I + 2 * J - 4);
2569 for (
unsigned int i = 1; i < I + 1; ++i)
2571 boundary_vertices[k] = i;
2573 boundary_vertices[k] = i + (J - 1) * I;
2576 for (
unsigned int j = 1; j < J - 1; ++j)
2578 boundary_vertices[k] = 1 + j * I;
2580 boundary_vertices[k] = I + j * I;
2599 for (
unsigned int i = 0; i < n_cells; ++i)
2610 for (
unsigned int j = 0; j < GeometryInfo<dim>::vertices_per_cell;
2612 in >> cells[i].vertices[j];
2628 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
2633 template <
int dim,
int spacedim>
2642 template <
int dim,
int spacedim>
2645 const unsigned int mesh_index,
2646 const bool remove_duplicates,
2648 const bool ignore_unsupported_types)
2650 #ifdef DEAL_II_WITH_ASSIMP 2655 Assimp::Importer importer;
2658 const aiScene *scene =
2659 importer.ReadFile(filename.c_str(),
2660 aiProcess_RemoveComponent |
2661 aiProcess_JoinIdenticalVertices |
2662 aiProcess_ImproveCacheLocality | aiProcess_SortByPType |
2663 aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes);
2669 ExcMessage(
"Input file contains no meshes."));
2672 (mesh_index < scene->mNumMeshes),
2675 unsigned int start_mesh =
2677 unsigned int end_mesh =
2682 std::vector<Point<spacedim>> vertices;
2683 std::vector<CellData<dim>> cells;
2687 unsigned int v_offset = 0;
2688 unsigned int c_offset = 0;
2691 for (
unsigned int m = start_mesh; m < end_mesh; ++m)
2693 const aiMesh *mesh = scene->mMeshes[m];
2697 if ((dim == 2) && mesh->mPrimitiveTypes != aiPrimitiveType_POLYGON)
2700 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
2701 "/" + std::to_string(scene->mNumMeshes)));
2704 else if ((dim == 1) && mesh->mPrimitiveTypes != aiPrimitiveType_LINE)
2707 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
2708 "/" + std::to_string(scene->mNumMeshes)));
2712 const unsigned int n_vertices = mesh->mNumVertices;
2713 const aiVector3D * mVertices = mesh->mVertices;
2716 const unsigned int n_faces = mesh->mNumFaces;
2717 const aiFace * mFaces = mesh->mFaces;
2719 vertices.resize(v_offset + n_vertices);
2720 cells.resize(c_offset + n_faces);
2722 for (
unsigned int i = 0; i < n_vertices; ++i)
2723 for (
unsigned int d = 0; d < spacedim; ++d)
2724 vertices[i + v_offset][d] = mVertices[i][d];
2726 unsigned int valid_cell = c_offset;
2727 for (
unsigned int i = 0; i < n_faces; ++i)
2731 for (
unsigned int f = 0; f < GeometryInfo<dim>::vertices_per_cell;
2734 cells[valid_cell].vertices[f] =
2735 mFaces[i].mIndices[f] + v_offset;
2743 ExcMessage(
"Face " + std::to_string(i) +
" of mesh " +
2744 std::to_string(m) +
" has " +
2745 std::to_string(mFaces[i].mNumIndices) +
2746 " vertices. We expected only " +
2751 cells.resize(valid_cell);
2756 v_offset += n_vertices;
2757 c_offset = valid_cell;
2761 if (cells.size() == 0)
2764 if (remove_duplicates)
2769 unsigned int n_verts = 0;
2770 while (n_verts != vertices.size())
2772 n_verts = vertices.size();
2773 std::vector<unsigned int> considered_vertices;
2775 vertices, cells, subcelldata, considered_vertices, tol);
2780 if (dim == spacedim)
2786 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
2788 tria->create_triangulation(vertices, cells, subcelldata);
2792 (void)remove_duplicates;
2794 (void)ignore_unsupported_types;
2800 template <
int dim,
int spacedim>
2814 if (std::find_if(line.begin(),
2816 std::bind(std::not_equal_to<char>(),
2817 std::placeholders::_1,
2818 ' ')) != line.end())
2821 for (
int i = line.length() - 1; i >= 0; --i)
2822 in.putback(line[i]);
2832 template <
int dim,
int spacedim>
2835 const char comment_start)
2840 while (in.get(c) && c == comment_start)
2843 while (in.get() !=
'\n')
2858 template <
int dim,
int spacedim>
2873 const std::vector<
Point<2>> & vertices,
2876 double min_x = vertices[cells[0].vertices[0]](0),
2877 max_x = vertices[cells[0].vertices[0]](0),
2878 min_y = vertices[cells[0].vertices[0]](1),
2879 max_y = vertices[cells[0].vertices[0]](1);
2881 for (
unsigned int i = 0; i < cells.size(); ++i)
2883 for (
unsigned int v = 0; v < 4; ++v)
2885 const Point<2> &p = vertices[cells[i].vertices[v]];
2897 out <<
"# cell " << i << std::endl;
2899 for (
unsigned int f = 0; f < 4; ++f)
2900 center += vertices[cells[i].vertices[f]];
2903 out <<
"set label \"" << i <<
"\" at " << center(0) <<
',' << center(1)
2904 <<
" center" << std::endl;
2907 for (
unsigned int f = 0; f < 2; ++f)
2908 out <<
"set arrow from " << vertices[cells[i].vertices[f]](0) <<
',' 2909 << vertices[cells[i].vertices[f]](1) <<
" to " 2910 << vertices[cells[i].vertices[(f + 1) % 4]](0) <<
',' 2911 << vertices[cells[i].vertices[(f + 1) % 4]](1) << std::endl;
2913 for (
unsigned int f = 2; f < 4; ++f)
2914 out <<
"set arrow from " << vertices[cells[i].vertices[(f + 1) % 4]](0)
2915 <<
',' << vertices[cells[i].vertices[(f + 1) % 4]](1) <<
" to " 2916 << vertices[cells[i].vertices[f]](0) <<
',' 2917 << vertices[cells[i].vertices[f]](1) << std::endl;
2923 <<
"set nokey" << std::endl
2924 <<
"pl [" << min_x <<
':' << max_x <<
"][" << min_y <<
':' << max_y
2925 <<
"] " << min_y << std::endl
2926 <<
"pause -1" << std::endl;
2934 const std::vector<
Point<3>> & vertices,
2937 for (
unsigned int cell = 0; cell < cells.size(); ++cell)
2940 out << vertices[cells[cell].vertices[0]] << std::endl
2941 << vertices[cells[cell].vertices[1]] << std::endl
2945 out << vertices[cells[cell].vertices[1]] << std::endl
2946 << vertices[cells[cell].vertices[2]] << std::endl
2950 out << vertices[cells[cell].vertices[3]] << std::endl
2951 << vertices[cells[cell].vertices[2]] << std::endl
2955 out << vertices[cells[cell].vertices[0]] << std::endl
2956 << vertices[cells[cell].vertices[3]] << std::endl
2960 out << vertices[cells[cell].vertices[4]] << std::endl
2961 << vertices[cells[cell].vertices[5]] << std::endl
2965 out << vertices[cells[cell].vertices[5]] << std::endl
2966 << vertices[cells[cell].vertices[6]] << std::endl
2970 out << vertices[cells[cell].vertices[7]] << std::endl
2971 << vertices[cells[cell].vertices[6]] << std::endl
2975 out << vertices[cells[cell].vertices[4]] << std::endl
2976 << vertices[cells[cell].vertices[7]] << std::endl
2980 out << vertices[cells[cell].vertices[0]] << std::endl
2981 << vertices[cells[cell].vertices[4]] << std::endl
2985 out << vertices[cells[cell].vertices[1]] << std::endl
2986 << vertices[cells[cell].vertices[5]] << std::endl
2990 out << vertices[cells[cell].vertices[2]] << std::endl
2991 << vertices[cells[cell].vertices[6]] << std::endl
2995 out << vertices[cells[cell].vertices[3]] << std::endl
2996 << vertices[cells[cell].vertices[7]] << std::endl
3004 template <
int dim,
int spacedim>
3013 name = search.
find(filename);
3017 std::ifstream in(name.c_str());
3021 const std::string::size_type slashpos = name.find_last_of(
'/');
3022 const std::string::size_type dotpos = name.find_last_of(
'.');
3023 if (dotpos < name.length() &&
3024 (dotpos > slashpos || slashpos == std::string::npos))
3026 std::string ext = name.substr(dotpos + 1);
3037 template <
int dim,
int spacedim>
3076 ExcMessage(
"There is no read_netcdf(istream &) function. " 3077 "Use the read_netcdf(string &filename) " 3078 "functions, instead."));
3087 ExcMessage(
"There is no read_assimp(istream &) function. " 3088 "Use the read_assimp(string &filename, ...) " 3089 "functions, instead."));
3100 template <
int dim,
int spacedim>
3127 return ".unknown_format";
3133 template <
int dim,
int spacedim>
3137 if (format_name ==
"dbmesh")
3140 if (format_name ==
"msh")
3143 if (format_name ==
"unv")
3146 if (format_name ==
"vtk")
3150 if (format_name ==
"inp")
3153 if (format_name ==
"ucd")
3156 if (format_name ==
"xda")
3159 if (format_name ==
"netcdf")
3162 if (format_name ==
"nc")
3165 if (format_name ==
"tecplot")
3168 if (format_name ==
"dat")
3171 if (format_name ==
"plt")
3190 template <
int dim,
int spacedim>
3194 return "dbmesh|msh|unv|vtk|ucd|abaqus|xda|netcdf|tecplot|assimp";
3200 Abaqus_to_UCD<dim>::Abaqus_to_UCD()
3211 from_string(T &t,
const std::string &s, std::ios_base &(*f)(std::ios_base &))
3213 std::istringstream iss(s);
3214 return !(iss >> f >> t).fail();
3219 extract_int(
const std::string &s)
3222 for (
unsigned int i = 0; i < s.size(); ++i)
3231 from_string(number, tmp, std::dec);
3237 Abaqus_to_UCD<dim>::read_in_abaqus(std::istream &input_stream)
3245 std::getline(input_stream, line);
3247 while (!input_stream.fail() && !input_stream.eof())
3249 std::transform(line.begin(), line.end(), line.begin(), ::toupper);
3251 if (line.compare(
"*HEADING") == 0 || line.compare(0, 2,
"**") == 0 ||
3252 line.compare(0, 5,
"*PART") == 0)
3255 while (!input_stream.fail() && !input_stream.eof())
3257 std::getline(input_stream, line);
3262 else if (line.compare(0, 5,
"*NODE") == 0)
3271 while (!input_stream.fail() && !input_stream.eof())
3273 std::getline(input_stream, line);
3277 std::vector<double> node(dim + 1);
3279 std::istringstream iss(line);
3281 for (
unsigned int i = 0; i < dim + 1; ++i)
3282 iss >> node[i] >> comma;
3284 node_list.push_back(node);
3287 else if (line.compare(0, 8,
"*ELEMENT") == 0)
3302 const std::string before_material =
"ELSET=EB";
3303 const std::size_t idx = line.find(before_material);
3304 if (idx != std::string::npos)
3306 from_string(material,
3307 line.substr(idx + before_material.size()),
3313 std::getline(input_stream, line);
3314 while (!input_stream.fail() && !input_stream.eof())
3319 std::istringstream iss(line);
3325 const unsigned int n_data_per_cell =
3327 std::vector<double> cell(n_data_per_cell);
3328 for (
unsigned int i = 0; i < n_data_per_cell; ++i)
3329 iss >> cell[i] >> comma;
3332 cell[0] =
static_cast<double>(material);
3333 cell_list.push_back(cell);
3335 std::getline(input_stream, line);
3338 else if (line.compare(0, 8,
"*SURFACE") == 0)
3349 const std::string name_key =
"NAME=";
3350 const std::size_t name_idx_start =
3351 line.find(name_key) + name_key.size();
3352 std::size_t name_idx_end = line.find(
',', name_idx_start);
3353 if (name_idx_end == std::string::npos)
3355 name_idx_end = line.size();
3357 const int b_indicator = extract_int(
3358 line.substr(name_idx_start, name_idx_end - name_idx_start));
3365 std::getline(input_stream, line);
3366 while (!input_stream.fail() && !input_stream.eof())
3372 std::transform(line.begin(),
3380 std::istringstream iss(line);
3387 std::vector<double> quad_node_list;
3388 const std::string elset_name = line.substr(0, line.find(
','));
3389 if (elsets_list.count(elset_name) != 0)
3393 iss >> stmp >> temp >> face_number;
3395 const std::vector<int> cells = elsets_list[elset_name];
3396 for (
unsigned int i = 0; i < cells.size(); ++i)
3400 get_global_node_numbers(el_idx, face_number);
3401 quad_node_list.insert(quad_node_list.begin(),
3404 face_list.push_back(quad_node_list);
3411 iss >> el_idx >> comma >> temp >> face_number;
3413 get_global_node_numbers(el_idx, face_number);
3414 quad_node_list.insert(quad_node_list.begin(), b_indicator);
3416 face_list.push_back(quad_node_list);
3419 std::getline(input_stream, line);
3422 else if (line.compare(0, 6,
"*ELSET") == 0)
3426 std::string elset_name;
3428 const std::string elset_key =
"*ELSET, ELSET=";
3429 const std::size_t idx = line.find(elset_key);
3430 if (idx != std::string::npos)
3432 const std::string comma =
",";
3433 const std::size_t first_comma = line.find(comma);
3434 const std::size_t second_comma =
3435 line.find(comma, first_comma + 1);
3436 const std::size_t elset_name_start =
3437 line.find(elset_key) + elset_key.size();
3438 elset_name = line.substr(elset_name_start,
3439 second_comma - elset_name_start);
3449 std::vector<int> elements;
3450 const std::size_t generate_idx = line.find(
"GENERATE");
3451 if (generate_idx != std::string::npos)
3454 std::getline(input_stream, line);
3455 std::istringstream iss(line);
3464 iss >> elid_start >> comma >> elid_end;
3466 if (iss.rdbuf()->in_avail() != 0)
3467 iss >> comma >> elis_step;
3468 for (
int i = elid_start; i <= elid_end; i += elis_step)
3470 elements.push_back(i);
3472 elsets_list[elset_name] = elements;
3474 std::getline(input_stream, line);
3479 std::getline(input_stream, line);
3480 while (!input_stream.fail() && !input_stream.eof())
3485 std::istringstream iss(line);
3490 iss >> elid >> comma;
3491 elements.push_back(elid);
3494 std::getline(input_stream, line);
3497 elsets_list[elset_name] = elements;
3502 else if (line.compare(0, 5,
"*NSET") == 0)
3505 while (!input_stream.fail() && !input_stream.eof())
3507 std::getline(input_stream, line);
3512 else if (line.compare(0, 14,
"*SOLID SECTION") == 0)
3515 const std::string elset_key =
"ELSET=";
3516 const std::size_t elset_start =
3517 line.find(
"ELSET=") + elset_key.size();
3518 const std::size_t elset_end = line.find(
',', elset_start + 1);
3519 const std::string elset_name =
3520 line.substr(elset_start, elset_end - elset_start);
3525 const std::string material_key =
"MATERIAL=";
3526 const std::size_t last_equal =
3527 line.find(
"MATERIAL=") + material_key.size();
3528 const std::size_t material_id_start = line.find(
'-', last_equal);
3529 int material_id = 0;
3530 from_string(material_id,
3531 line.substr(material_id_start + 1),
3535 const std::vector<int> &elset_cells = elsets_list[elset_name];
3536 for (
unsigned int i = 0; i < elset_cells.size(); ++i)
3538 const int cell_id = elset_cells[i] - 1;
3539 cell_list[cell_id][0] = material_id;
3544 std::getline(input_stream, line);
3553 Abaqus_to_UCD<dim>::get_global_node_numbers(
const int face_cell_no,
3554 const int face_cell_face_no)
const 3564 if (face_cell_face_no == 1)
3566 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3567 quad_node_list[1] = cell_list[face_cell_no - 1][2];
3569 else if (face_cell_face_no == 2)
3571 quad_node_list[0] = cell_list[face_cell_no - 1][2];
3572 quad_node_list[1] = cell_list[face_cell_no - 1][3];
3574 else if (face_cell_face_no == 3)
3576 quad_node_list[0] = cell_list[face_cell_no - 1][3];
3577 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3579 else if (face_cell_face_no == 4)
3581 quad_node_list[0] = cell_list[face_cell_no - 1][4];
3582 quad_node_list[1] = cell_list[face_cell_no - 1][1];
3592 if (face_cell_face_no == 1)
3594 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3595 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3596 quad_node_list[2] = cell_list[face_cell_no - 1][3];
3597 quad_node_list[3] = cell_list[face_cell_no - 1][2];
3599 else if (face_cell_face_no == 2)
3601 quad_node_list[0] = cell_list[face_cell_no - 1][5];
3602 quad_node_list[1] = cell_list[face_cell_no - 1][8];
3603 quad_node_list[2] = cell_list[face_cell_no - 1][7];
3604 quad_node_list[3] = cell_list[face_cell_no - 1][6];
3606 else if (face_cell_face_no == 3)
3608 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3609 quad_node_list[1] = cell_list[face_cell_no - 1][2];
3610 quad_node_list[2] = cell_list[face_cell_no - 1][6];
3611 quad_node_list[3] = cell_list[face_cell_no - 1][5];
3613 else if (face_cell_face_no == 4)
3615 quad_node_list[0] = cell_list[face_cell_no - 1][2];
3616 quad_node_list[1] = cell_list[face_cell_no - 1][3];
3617 quad_node_list[2] = cell_list[face_cell_no - 1][7];
3618 quad_node_list[3] = cell_list[face_cell_no - 1][6];
3620 else if (face_cell_face_no == 5)
3622 quad_node_list[0] = cell_list[face_cell_no - 1][3];
3623 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3624 quad_node_list[2] = cell_list[face_cell_no - 1][8];
3625 quad_node_list[3] = cell_list[face_cell_no - 1][7];
3627 else if (face_cell_face_no == 6)
3629 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3630 quad_node_list[1] = cell_list[face_cell_no - 1][5];
3631 quad_node_list[2] = cell_list[face_cell_no - 1][8];
3632 quad_node_list[3] = cell_list[face_cell_no - 1][4];
3645 return quad_node_list;
3650 Abaqus_to_UCD<dim>::write_out_avs_ucd(std::ostream &output)
const 3659 const boost::io::ios_base_all_saver formatting_saver(output);
3663 output <<
"# Abaqus to UCD mesh conversion" << std::endl;
3664 output <<
"# Mesh type: AVS UCD" << std::endl;
3689 output << node_list.size() <<
"\t" << (cell_list.size() + face_list.size())
3690 <<
"\t0\t0\t0" << std::endl;
3693 output.precision(8);
3697 for (
unsigned int ii = 0; ii < node_list.size(); ++ii)
3700 output << node_list[ii][0] <<
"\t";
3703 output.setf(std::ios::scientific, std::ios::floatfield);
3704 for (
unsigned int jj = 1; jj < dim + 1; ++jj)
3707 if (std::abs(node_list[ii][jj]) > tolerance)
3708 output << static_cast<double>(node_list[ii][jj]) <<
"\t";
3710 output << 0.0 <<
"\t";
3713 output << 0.0 <<
"\t";
3715 output << std::endl;
3716 output.unsetf(std::ios::floatfield);
3720 for (
unsigned int ii = 0; ii < cell_list.size(); ++ii)
3722 output << ii + 1 <<
"\t" << cell_list[ii][0] <<
"\t" 3723 << (dim == 2 ?
"quad" :
"hex") <<
"\t";
3724 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_cell + 1;
3726 output << cell_list[ii][jj] <<
"\t";
3728 output << std::endl;
3732 for (
unsigned int ii = 0; ii < face_list.size(); ++ii)
3734 output << ii + 1 <<
"\t" << face_list[ii][0] <<
"\t" 3735 << (dim == 2 ?
"line" :
"quad") <<
"\t";
3736 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_face + 1;
3738 output << face_list[ii][jj] <<
"\t";
3740 output << std::endl;
3747 #include "grid_in.inst" 3749 DEAL_II_NAMESPACE_CLOSE
std::vector< CellData< 1 > > boundary_lines
static std::string get_format_names()
static void reorder_cells(std::vector< CellData< dim >> &original_cells, const bool use_new_style_ordering=false)
static const unsigned int invalid_unsigned_int
cell_iterator end() const
static::ExceptionBase & ExcIO()
bool check_consistency(const unsigned int dim) const
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
static::ExceptionBase & ExcUnknownElementType(int arg1)
#define AssertThrow(cond, exc)
static::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static Format parse_format(const std::string &format_name)
static void skip_empty_lines(std::istream &in)
void read_vtk(std::istream &in)
static::ExceptionBase & ExcDBMESHWrongDimension(int arg1)
void read_dbmesh(std::istream &in)
void read_tecplot(std::istream &in)
static::ExceptionBase & ExcInvalidState()
static::ExceptionBase & ExcMessage(std::string arg1)
static::ExceptionBase & ExcImpossibleInDim(int arg1)
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)
static::ExceptionBase & ExcNeedsNetCDF()
static::ExceptionBase & ExcInvalidVertexIndexGmsh(int arg1, int arg2, int arg3)
#define Assert(cond, exc)
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
static void skip_comment_lines(std::istream &in, const char comment_start)
bool match_at_string_start(const std::string &name, const std::string &pattern)
void read_ucd(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
static::ExceptionBase & ExcNeedsAssimp()
static::ExceptionBase & ExcInvalidDBMESHInput(std::string arg1)
static void debug_output_grid(const std::vector< CellData< dim >> &cells, const std::vector< Point< spacedim >> &vertices, std::ostream &out)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
static::ExceptionBase & ExcUnknownIdentifier(std::string arg1)
std::string find(const std::string &filename, const char *open_mode="r")
void read_xda(std::istream &in)
void read_msh(std::istream &in)
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter= ' ')
std::vector< CellData< 2 > > boundary_quads
void read_netcdf(const std::string &filename)
static std::string default_suffix(const Format format)
void read_unv(std::istream &in)
void read(std::istream &in, Format format=Default)
static::ExceptionBase & ExcNoTriangulationSelected()
static::ExceptionBase & ExcNotImplemented()
static::ExceptionBase & ExcInvalidDBMeshFormat()
static void invert_all_cells_of_negative_grid(const std::vector< Point< spacedim >> &all_vertices, std::vector< CellData< dim >> &original_cells)
const types::boundary_id internal_face_boundary_id
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)
Use GridIn::default_format stored in this object.
active_cell_iterator begin_active(const unsigned int level=0) const
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
static::ExceptionBase & ExcInvalidGMSHInput(std::string arg1)
static::ExceptionBase & ExcGmshUnsupportedGeometry(int arg1)
const types::material_id invalid_material_id
static::ExceptionBase & ExcUnknownSectionType(int arg1)
void attach_triangulation(Triangulation< dim, spacedim > &tria)
static::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2)
static::ExceptionBase & ExcGmshNoCellInformation()
static::ExceptionBase & ExcInternalError()