17 #include <deal.II/base/path_search.h> 18 #include <deal.II/base/utilities.h> 19 #include <deal.II/base/exceptions.h> 21 #include <deal.II/grid/grid_in.h> 22 #include <deal.II/grid/tria.h> 23 #include <deal.II/grid/grid_reordering.h> 24 #include <deal.II/grid/grid_tools.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/scene.h> 42 #include <assimp/postprocess.h> 46 DEAL_II_NAMESPACE_OPEN
59 template <
int spacedim>
61 assign_1d_boundary_ids (
const std::map<unsigned int, types::boundary_id> &boundary_ids,
64 if (boundary_ids.size() > 0)
66 cell = triangulation.begin_active();
67 cell != triangulation.end(); ++cell)
68 for (
unsigned int f=0; f<GeometryInfo<1>::faces_per_cell; ++f)
69 if (boundary_ids.find(cell->vertex_index(f)) != boundary_ids.end())
72 ExcMessage (
"You are trying to prescribe boundary ids on the face " 73 "of a 1d cell (i.e., on a vertex), but this face is not actually at " 74 "the boundary of the mesh. This is not allowed."));
75 cell->face(f)->set_boundary_id (boundary_ids.find(cell->vertex_index(f))->second);
80 template <
int dim,
int spacedim>
82 assign_1d_boundary_ids (
const std::map<unsigned int, types::boundary_id> &,
91 template <
int dim,
int spacedim>
93 tria(nullptr, typeid(*this).name()), default_format(ucd)
97 template <
int dim,
int spacedim>
105 template <
int dim,
int spacedim>
117 text[0] =
"# vtk DataFile Version 3.0";
120 text[3] =
"DATASET UNSTRUCTURED_GRID";
122 for (
unsigned int i = 0; i < 4; ++i)
127 ExcMessage(std::string(
"While reading VTK file, failed to find a header line with text <") +
134 std::vector< Point<spacedim> > vertices;
135 std::vector< CellData<dim> > cells;
144 if (keyword ==
"POINTS")
146 unsigned int n_vertices;
149 in.ignore(256,
'\n');
151 for (
unsigned int vertex = 0; vertex < n_vertices; ++vertex)
155 in >> x(0) >> x(1) >> x(2);
157 vertices.emplace_back();
158 for (
unsigned int d=0; d<spacedim; ++d)
159 vertices.back()(d) = x(d);
165 ExcMessage (
"While reading VTK file, failed to find POINTS section"));
169 std::string checkline;
171 in.ignore(256,
'\n');
173 getline(in,checkline);
174 if (checkline.compare(
"") != 0)
183 if (keyword ==
"CELLS")
185 unsigned int n_geometric_objects;
186 in >> n_geometric_objects;
191 for (
unsigned int count = 0; count < n_geometric_objects; count++)
205 cells.emplace_back();
207 for (
unsigned int j = 0; j < type; j++)
208 in >> cells.back().vertices[j];
210 cells.back().material_id = 0;
217 for (
unsigned int j = 0; j < type; j++)
225 ExcMessage (
"While reading VTK file, unknown file type encountered"));
231 for (
unsigned int count = 0; count < n_geometric_objects; count++)
243 cells.emplace_back();
245 for (
unsigned int j = 0; j < type; j++)
246 in >> cells.back().vertices[j];
248 cells.back().material_id = 0;
257 for (
unsigned int j = 0; j < type; j++)
267 ExcMessage (
"While reading VTK file, unknown file type encountered"));
272 ExcMessage (
"While reading VTK file, failed to find CELLS section"));
278 if (keyword ==
"CELL_TYPES")
280 in.ignore(256,
'\n');
282 while (!in.fail() && !in.eof())
285 if (keyword !=
"12" && keyword !=
"9")
294 if (keyword ==
"CELL_DATA")
305 ExcMessage (
"The VTK reader found a CELL_DATA statement " 306 "that lists a total of " 308 " cell data objects, but this needs to " 309 "equal the number of cells (which is " 311 ") plus the number of quads (" 313 " in 3d or the number of lines (" 319 std::string textnew[2];
320 textnew[0] =
"SCALARS MaterialID double";
321 textnew[1] =
"LOOKUP_TABLE default";
323 in.ignore(256,
'\n');
325 for (
unsigned int i = 0; i < 2; i++)
327 getline(in, linenew);
329 if (linenew.size() > textnew[0].size())
330 linenew.resize(textnew[0].size());
333 ExcMessage (std::string(
"While reading VTK file, failed to find <") +
334 textnew[i] +
"> section"));
341 for (
unsigned int i = 0; i < cells.size(); i++)
345 cells[i].material_id = id;
350 for (
unsigned int i = 0; i < subcelldata.
boundary_quads.size(); i++)
359 for (
unsigned int i = 0; i < subcelldata.
boundary_lines.size(); i++)
379 tria->create_triangulation_compatibility(vertices,
387 ExcMessage (
"While reading VTK file, failed to find CELLS section"));
392 template <
int dim,
int spacedim>
399 skip_comment_lines(in,
'#');
410 AssertThrow(tmp == 2411, ExcUnknownSectionType(tmp));
412 std::vector< Point<spacedim> > vertices;
413 std::map<int, int> vertex_indices;
430 in >> dummy >> dummy >> dummy;
433 in >> x[0] >> x[1] >> x[2];
435 vertices.emplace_back();
437 for (
unsigned int d = 0; d < spacedim; d++)
438 vertices.back()(d) = x[d];
440 vertex_indices[no] = no_vertex;
452 AssertThrow(tmp == 2412, ExcUnknownSectionType(tmp));
454 std::vector< CellData<dim> > cells;
457 std::map<int, int> cell_indices;
458 std::map<int, int> line_indices;
459 std::map<int, int> quad_indices;
478 in >> type >> dummy >> dummy >> dummy >> dummy;
480 AssertThrow((type == 11)||(type == 44)||(type == 94)||(type == 115), ExcUnknownElementType(type));
482 if ( (((type == 44)||(type == 94))&&(dim == 2)) || ((type == 115)&&(dim == 3)) )
484 cells.emplace_back();
487 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; v++)
488 in >> cells.back().vertices[v];
490 cells.back().material_id = 0;
492 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; v++)
493 cells.back().vertices[v] = vertex_indices[cells.back().vertices[v]];
495 cell_indices[no] = no_cell;
499 else if ( ((type == 11)&&(dim == 2)) || ((type == 11)&&(dim == 3)) )
502 in >> dummy >> dummy >> dummy;
507 for (
unsigned int v = 0; v < 2; v++)
512 for (
unsigned int v = 0; v < 2; v++)
515 line_indices[no] = no_line;
519 else if ( ((type == 44)||(type == 94)) && (dim == 3) )
524 for (
unsigned int v = 0; v < 4; v++)
529 for (
unsigned int v = 0; v < 4; v++)
532 quad_indices[no] = no_quad;
540 +
"> when running in dim=" 559 AssertThrow((tmp == 2467)||(tmp == 2477), ExcUnknownSectionType(tmp));
575 in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> n_entities;
580 const unsigned int n_lines = (n_entities%2 == 0)?(n_entities/2):((n_entities+1)/2);
582 for (
unsigned int line = 0; line < n_lines; line++)
584 unsigned int n_fragments;
586 if (line == n_lines-1)
587 n_fragments = (n_entities%2 == 0)?(2):(1);
591 for (
unsigned int no_fragment = 0; no_fragment < n_fragments; no_fragment++)
594 in >> dummy >> no >> dummy >> dummy;
596 if ( cell_indices.count(no) > 0 )
597 cells[cell_indices[no]].material_id =
id;
599 if ( line_indices.count(no) > 0 )
602 if ( quad_indices.count(no) > 0 )
621 tria->create_triangulation_compatibility(vertices,
628 template <
int dim,
int spacedim>
630 const bool apply_all_indicators_to_manifolds)
636 skip_comment_lines (in,
'#');
639 unsigned int n_vertices;
640 unsigned int n_cells;
651 std::vector<Point<spacedim> > vertices (n_vertices);
655 std::map<int,int> vertex_indices;
657 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
665 >> x[0] >> x[1] >> x[2];
668 for (
unsigned int d=0; d<spacedim; ++d)
669 vertices[vertex](d) = x[d];
673 vertex_indices[vertex_number] = vertex;
677 std::vector<CellData<dim> > cells;
680 for (
unsigned int cell=0; cell<n_cells; ++cell)
689 std::string cell_type;
693 unsigned int material_id;
699 if (((cell_type ==
"line") && (dim == 1)) ||
700 ((cell_type ==
"quad") && (dim == 2)) ||
701 ((cell_type ==
"hex" ) && (dim == 3)))
705 cells.emplace_back ();
706 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
707 in >> cells.back().vertices[i];
710 Assert(material_id<= std::numeric_limits<types::material_id>::max(),
711 ExcIndexRange(material_id,0,std::numeric_limits<types::material_id>::max()));
720 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
721 if (vertex_indices.find (cells.back().vertices[i]) != vertex_indices.end())
723 cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]];
733 else if ((cell_type ==
"line") && ((dim == 2) || (dim == 3)))
741 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
742 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
747 if (apply_all_indicators_to_manifolds)
756 for (
unsigned int i=0; i<2; ++i)
757 if (vertex_indices.find (subcelldata.
boundary_lines.back().vertices[i]) !=
758 vertex_indices.end())
772 else if ((cell_type ==
"quad") && (dim == 3))
782 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
783 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
788 if (apply_all_indicators_to_manifolds)
797 for (
unsigned int i=0; i<4; ++i)
798 if (vertex_indices.find (subcelldata.
boundary_quads.back().vertices[i]) !=
799 vertex_indices.end())
816 AssertThrow (
false, ExcUnknownIdentifier(cell_type));
831 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
842 void read_in_abaqus (std::istream &in);
843 void write_out_avs_ucd (std::ostream &out)
const;
846 const double tolerance;
848 std::vector<double> get_global_node_numbers (
const int face_cell_no,
849 const int face_cell_face_no)
const;
852 std::vector< std::vector<double> > node_list;
854 std::vector< std::vector<double> > cell_list;
856 std::vector< std::vector<double> > face_list;
858 std::map< std::string, std::vector<int> > elsets_list;
862 template <
int dim,
int spacedim>
864 const bool apply_all_indicators_to_manifolds)
872 Abaqus_to_UCD<dim> abaqus_to_ucd;
873 abaqus_to_ucd.read_in_abaqus(in);
875 std::stringstream in_ucd;
876 abaqus_to_ucd.write_out_avs_ucd(in_ucd);
884 read_ucd(in_ucd, apply_all_indicators_to_manifolds);
886 catch (std::exception &exc)
889 <<
"Exception on processing internal UCD data: " << std::endl
893 AssertThrow(
false,
ExcMessage(
"Internal conversion from ABAQUS file to UCD format was unsuccessful. " 894 "More information is provided in an error message printed above. " 895 "Are you sure that your ABAQUS mesh file conforms with the requirements " 896 "listed in the documentation?"));
900 AssertThrow(
false,
ExcMessage(
"Internal conversion from ABAQUS file to UCD format was unsuccessful. " 901 "Are you sure that your ABAQUS mesh file conforms with the requirements " 902 "listed in the documentation?"));
907 template <
int dim,
int spacedim>
916 skip_comment_lines (in,
'#');
923 ExcInvalidDBMESHInput(line));
925 skip_empty_lines (in);
929 AssertThrow (line==
"Dimension", ExcInvalidDBMESHInput(line));
930 unsigned int dimension;
932 AssertThrow (dimension == dim, ExcDBMESHWrongDimension(dimension));
933 skip_empty_lines (in);
946 while (getline(in,line), line.find(
"# END")==std::string::npos)
948 skip_empty_lines (in);
953 AssertThrow (line==
"Vertices", ExcInvalidDBMESHInput(line));
955 unsigned int n_vertices;
959 std::vector<Point<spacedim> > vertices (n_vertices);
960 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
963 for (
unsigned int d=0; d<dim; ++d)
964 in >> vertices[vertex][d];
970 skip_empty_lines(in);
976 AssertThrow (line==
"Edges", ExcInvalidDBMESHInput(line));
978 unsigned int n_edges;
980 for (
unsigned int edge=0; edge<n_edges; ++edge)
983 in >> dummy >> dummy;
989 skip_empty_lines(in);
998 AssertThrow (line==
"CrackedEdges", ExcInvalidDBMESHInput(line));
1001 for (
unsigned int edge=0; edge<n_edges; ++edge)
1004 in >> dummy >> dummy;
1010 skip_empty_lines(in);
1016 AssertThrow (line==
"Quadrilaterals", ExcInvalidDBMESHInput(line));
1018 std::vector<CellData<dim> > cells;
1020 unsigned int n_cells;
1022 for (
unsigned int cell=0; cell<n_cells; ++cell)
1026 cells.emplace_back ();
1027 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1029 in >> cells.back().vertices[i];
1033 (static_cast<unsigned int>(cells.back().vertices[i]) <= vertices.size()),
1036 --cells.back().vertices[i];
1044 skip_empty_lines(in);
1052 while (getline(in,line), ((line.find(
"End")==std::string::npos) && (in)))
1068 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1073 template <
int dim,
int spacedim>
1092 unsigned int n_vertices;
1093 unsigned int n_cells;
1103 for (
unsigned int i=0; i<8; ++i)
1107 std::vector<CellData<2> > cells (n_cells);
1110 for (
unsigned int cell=0; cell<n_cells; ++cell)
1121 for (
unsigned int i=0; i<4; ++i)
1122 in >> cells[cell].vertices[i];
1128 std::vector<Point<2> > vertices (n_vertices);
1129 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
1134 in >> x[0] >> x[1] >> x[2];
1137 for (
unsigned int d=0;
d<2; ++
d)
1138 vertices[vertex](d) = x[
d];
1147 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1158 static const unsigned int xda_to_dealII_map[] = {0,1,5,4,3,2,6,7};
1165 unsigned int n_vertices;
1166 unsigned int n_cells;
1176 for (
unsigned int i=0; i<8; ++i)
1180 std::vector<CellData<3> > cells (n_cells);
1183 for (
unsigned int cell=0; cell<n_cells; ++cell)
1194 unsigned int xda_ordered_nodes[8];
1196 for (
unsigned int i=0; i<8; ++i)
1197 in >> xda_ordered_nodes[i];
1199 for (
unsigned int i=0; i<8; i++)
1200 cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]];
1206 std::vector<Point<3> > vertices (n_vertices);
1207 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
1212 in >> x[0] >> x[1] >> x[2];
1215 for (
unsigned int d=0;
d<3; ++
d)
1216 vertices[vertex](d) = x[
d];
1225 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1231 template <
int dim,
int spacedim>
1237 unsigned int n_vertices;
1238 unsigned int n_cells;
1245 unsigned int gmsh_file_format = 0;
1246 if (line ==
"@f$NOD")
1247 gmsh_file_format = 1;
1248 else if (line ==
"@f$MeshFormat")
1249 gmsh_file_format = 2;
1256 if (gmsh_file_format == 2)
1259 unsigned int file_type, data_size;
1261 in >> version >> file_type >> data_size;
1263 Assert ( (version >= 2.0) &&
1275 ExcInvalidGMSHInput(line));
1280 if (line ==
"@f$PhysicalNames")
1286 while (line !=
"@f$EndPhysicalNames");
1294 ExcInvalidGMSHInput(line));
1299 std::vector<Point<spacedim> > vertices (n_vertices);
1303 std::map<int,int> vertex_indices;
1305 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
1312 >> x[0] >> x[1] >> x[2];
1314 for (
unsigned int d=0; d<spacedim; ++d)
1315 vertices[vertex](d) = x[d];
1317 vertex_indices[vertex_number] = vertex;
1322 static const std::string end_nodes_marker[] = {
"@f$ENDNOD",
"@f$EndNodes" };
1323 AssertThrow (line==end_nodes_marker[gmsh_file_format-1],
1324 ExcInvalidGMSHInput(line));
1328 static const std::string begin_elements_marker[] = {
"@f$ELM",
"@f$Elements" };
1329 AssertThrow (line==begin_elements_marker[gmsh_file_format-1],
1330 ExcInvalidGMSHInput(line));
1337 std::vector<CellData<dim> > cells;
1339 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
1341 for (
unsigned int cell=0; cell<n_cells; ++cell)
1350 unsigned int cell_type;
1351 unsigned int material_id;
1352 unsigned int nod_num;
1367 unsigned int elm_number;
1371 switch (gmsh_file_format)
1386 unsigned int n_tags;
1393 for (
unsigned int i=1; i<n_tags; ++i)
1421 if (((cell_type == 1) && (dim == 1)) ||
1422 ((cell_type == 3) && (dim == 2)) ||
1423 ((cell_type == 5) && (dim == 3)))
1427 ExcMessage (
"Number of nodes does not coincide with the " 1428 "number required for this object"));
1431 cells.emplace_back ();
1432 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1433 in >> cells.back().vertices[i];
1436 Assert(material_id<= std::numeric_limits<types::material_id>::max(),
1437 ExcIndexRange(material_id,0,std::numeric_limits<types::material_id>::max()));
1446 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1448 AssertThrow (vertex_indices.find (cells.back().vertices[i]) !=
1449 vertex_indices.end(),
1450 ExcInvalidVertexIndexGmsh(cell, elm_number,
1451 cells.back().vertices[i]));
1454 cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]];
1457 else if ((cell_type == 1) && ((dim == 2) || (dim == 3)))
1465 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
1466 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
1476 for (
unsigned int i=0; i<2; ++i)
1477 if (vertex_indices.find (subcelldata.
boundary_lines.back().vertices[i]) !=
1478 vertex_indices.end())
1492 else if ((cell_type == 3) && (dim == 3))
1502 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
1503 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
1513 for (
unsigned int i=0; i<4; ++i)
1514 if (vertex_indices.find (subcelldata.
boundary_quads.back().vertices[i]) !=
1515 vertex_indices.end())
1530 else if (cell_type == 15)
1533 unsigned int node_index = 0;
1534 switch (gmsh_file_format)
1538 for (
unsigned int i=0; i<nod_num; ++i)
1554 boundary_ids_1d[vertex_indices[node_index]] = material_id;
1565 ExcMessage(
"Found triangles while reading a file " 1566 "in gmsh format. deal.II does not " 1567 "support triangles"));
1569 ExcMessage(
"Found tetrahedra while reading a file " 1570 "in gmsh format. deal.II does not " 1571 "support tetrahedra"));
1573 AssertThrow (
false, ExcGmshUnsupportedGeometry(cell_type));
1579 static const std::string end_elements_marker[] = {
"@f$ENDELM",
"@f$EndElements" };
1580 AssertThrow (line==end_elements_marker[gmsh_file_format-1],
1581 ExcInvalidGMSHInput(line));
1590 AssertThrow(cells.size() > 0, ExcGmshNoCellInformation());
1599 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1604 assign_1d_boundary_ids (boundary_ids_1d, *tria);
1637 #ifndef DEAL_II_WITH_NETCDF 1641 const unsigned int dim=2;
1642 const unsigned int spacedim=2;
1666 const unsigned int coord=1;
1672 const unsigned int x2d=0;
1673 const unsigned int y2d=2;
1682 NcFile nc (filename.c_str());
1686 NcDim *elements_dim=nc.get_dim(
"no_of_elements");
1688 const unsigned int n_cells=elements_dim->size();
1692 NcDim *marker_dim=nc.get_dim(
"no_of_markers");
1694 const unsigned int n_markers=marker_dim->size();
1696 NcVar *marker_var=nc.get_var(
"marker");
1700 marker_var->get_dim(0)->size())==n_markers,
ExcIO());
1702 std::vector<int> marker(n_markers);
1705 marker_var->get(&*marker.begin(), n_markers);
1710 NcDim *bquads_dim=nc.get_dim(
"no_of_surfacequadrilaterals");
1712 const unsigned int n_bquads=bquads_dim->size();
1714 NcVar *bmarker_var=nc.get_var(
"boundarymarker_of_surfaces");
1718 bmarker_var->get_dim(0)->size())==n_bquads,
ExcIO());
1720 std::vector<int> bmarker(n_bquads);
1721 bmarker_var->get(&*bmarker.begin(), n_bquads);
1726 std::map<int, unsigned int> n_bquads_per_bmarker;
1727 for (
unsigned int i=0; i<n_markers; ++i)
1731 AssertThrow(n_bquads_per_bmarker.find(marker[i])==
1732 n_bquads_per_bmarker.end(),
ExcIO());
1734 n_bquads_per_bmarker[marker[i]]=
1735 count(bmarker.begin(), bmarker.end(), marker[i]);
1754 NcDim *quad_vertices_dim=nc.get_dim(
"points_per_surfacequadrilateral");
1756 const unsigned int vertices_per_quad=quad_vertices_dim->size();
1759 NcVar *vertex_indices_var=nc.get_var(
"points_of_surfacequadrilaterals");
1763 vertex_indices_var->get_dim(0)->size())==n_bquads,
ExcIO());
1765 vertex_indices_var->get_dim(1)->size())==vertices_per_quad,
ExcIO());
1767 std::vector<int> vertex_indices(n_bquads*vertices_per_quad);
1768 vertex_indices_var->get(&*vertex_indices.begin(), n_bquads, vertices_per_quad);
1770 for (
unsigned int i=0; i<vertex_indices.size(); ++i)
1777 NcDim *vertices_dim=nc.get_dim(
"no_of_points");
1779 const unsigned int n_vertices=vertices_dim->size();
1781 NcVar *points_xc=nc.get_var(
"points_xc");
1782 NcVar *points_yc=nc.get_var(
"points_yc");
1783 NcVar *points_zc=nc.get_var(
"points_zc");
1791 static_cast<int>(n_vertices),
ExcIO());
1793 static_cast<int>(n_vertices),
ExcIO());
1795 static_cast<int>(n_vertices),
ExcIO());
1796 std::vector<std::vector<double> > point_values(
1797 3, std::vector<double> (n_vertices));
1798 points_xc->get(&*point_values[0].begin(), n_vertices);
1799 points_yc->get(&*point_values[1].begin(), n_vertices);
1800 points_zc->get(&*point_values[2].begin(), n_vertices);
1803 std::vector<Point<spacedim> > vertices (n_vertices);
1804 for (
unsigned int i=0; i<n_vertices; ++i)
1806 vertices[i](0)=point_values[x2d][i];
1807 vertices[i](1)=point_values[y2d][i];
1813 std::map<int, bool> zero_plane_markers;
1814 for (
unsigned int quad=0; quad<n_bquads; ++quad)
1816 bool zero_plane=
true;
1817 for (
unsigned int i=0; i<vertices_per_quad; ++i)
1818 if (point_values[coord][vertex_indices[quad*vertices_per_quad+i]]!=0)
1825 zero_plane_markers[bmarker[quad]]=
true;
1827 unsigned int sum_of_zero_plane_cells=0;
1828 for (std::map<int, bool>::const_iterator iter=zero_plane_markers.begin();
1829 iter != zero_plane_markers.end(); ++iter)
1830 sum_of_zero_plane_cells+=n_bquads_per_bmarker[iter->first];
1836 std::vector<CellData<dim> > cells(n_cells);
1837 for (
unsigned int quad=0, cell=0; quad<n_bquads; ++quad)
1839 bool zero_plane=
false;
1840 for (std::map<int, bool>::const_iterator iter=zero_plane_markers.begin();
1841 iter != zero_plane_markers.end(); ++iter)
1842 if (bmarker[quad]==iter->first)
1850 for (
unsigned int i=0; i<vertices_per_quad; ++i)
1852 Assert(point_values[coord][vertex_indices[
1854 cells[cell].vertices[i]=vertex_indices[quad*vertices_per_quad+i];
1863 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1871 #ifndef DEAL_II_WITH_NETCDF 1878 const unsigned int dim=3;
1879 const unsigned int spacedim=3;
1885 NcFile nc (filename.c_str());
1889 NcDim *elements_dim=nc.get_dim(
"no_of_elements");
1891 const unsigned int n_cells=elements_dim->size();
1893 NcDim *hexes_dim=nc.get_dim(
"no_of_hexaeders");
1895 const unsigned int n_hexes=hexes_dim->size();
1897 ExcMessage(
"deal.II can handle purely hexaedral grids, only."));
1903 NcDim *hex_vertices_dim=nc.get_dim(
"points_per_hexaeder");
1905 const unsigned int vertices_per_hex=hex_vertices_dim->size();
1908 NcVar *vertex_indices_var=nc.get_var(
"points_of_hexaeders");
1912 vertex_indices_var->get_dim(0)->size())==n_cells,
ExcIO());
1914 vertex_indices_var->get_dim(1)->size())==vertices_per_hex,
ExcIO());
1916 std::vector<int> vertex_indices(n_cells*vertices_per_hex);
1919 vertex_indices_var->get(&*vertex_indices.begin(), n_cells, vertices_per_hex);
1921 for (
unsigned int i=0; i<vertex_indices.size(); ++i)
1928 NcDim *vertices_dim=nc.get_dim(
"no_of_points");
1930 const unsigned int n_vertices=vertices_dim->size();
1932 NcVar *points_xc=nc.get_var(
"points_xc");
1933 NcVar *points_yc=nc.get_var(
"points_yc");
1934 NcVar *points_zc=nc.get_var(
"points_zc");
1942 static_cast<int>(n_vertices),
ExcIO());
1944 static_cast<int>(n_vertices),
ExcIO());
1946 static_cast<int>(n_vertices),
ExcIO());
1947 std::vector<std::vector<double> > point_values(
1948 3, std::vector<double> (n_vertices));
1949 points_xc->get(&*point_values[0].begin(), n_vertices);
1950 points_yc->get(&*point_values[1].begin(), n_vertices);
1951 points_zc->get(&*point_values[2].begin(), n_vertices);
1954 std::vector<Point<spacedim> > vertices (n_vertices);
1955 for (
unsigned int i=0; i<n_vertices; ++i)
1957 vertices[i](0)=point_values[0][i];
1958 vertices[i](1)=point_values[1][i];
1959 vertices[i](2)=point_values[2][i];
1963 std::vector<CellData<dim> > cells(n_cells);
1964 for (
unsigned int cell=0; cell<n_cells; ++cell)
1965 for (
unsigned int i=0; i<vertices_per_hex; ++i)
1966 cells[cell].vertices[i]=vertex_indices[cell*vertices_per_hex+i];
1977 NcDim *quad_vertices_dim=nc.get_dim(
"points_per_surfacequadrilateral");
1979 const unsigned int vertices_per_quad=quad_vertices_dim->size();
1982 NcVar *bvertex_indices_var=nc.get_var(
"points_of_surfacequadrilaterals");
1985 const unsigned int n_bquads=bvertex_indices_var->get_dim(0)->size();
1987 bvertex_indices_var->get_dim(1)->size())==
1990 std::vector<int> bvertex_indices(n_bquads*vertices_per_quad);
1991 bvertex_indices_var->get(&*bvertex_indices.begin(), n_bquads, vertices_per_quad);
1996 NcDim *bquads_dim=nc.get_dim(
"no_of_surfacequadrilaterals");
1999 bquads_dim->size())==n_bquads,
ExcIO());
2001 NcVar *bmarker_var=nc.get_var(
"boundarymarker_of_surfaces");
2005 bmarker_var->get_dim(0)->size())==n_bquads,
ExcIO());
2007 std::vector<int> bmarker(n_bquads);
2008 bmarker_var->get(&*bmarker.begin(), n_bquads);
2014 for (
unsigned int i=0; i<bmarker.size(); ++i)
2023 for (
unsigned int i=0; i<n_bquads; ++i)
2025 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
2029 = static_cast<types::boundary_id>(bmarker[i]);
2035 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
2040 template <
int dim,
int spacedim>
2042 std::vector<unsigned int> &tecplot2deal,
2043 unsigned int &n_vars,
2044 unsigned int &n_vertices,
2045 unsigned int &n_cells,
2046 std::vector<unsigned int> &IJK,
2060 DEAL_II_FALLTHROUGH;
2063 DEAL_II_FALLTHROUGH;
2071 std::transform(header.begin(),header.end(),header.begin(),::toupper);
2075 std::replace(header.begin(),header.end(),
'\t',
' ');
2076 std::replace(header.begin(),header.end(),
',',
' ');
2077 std::replace(header.begin(),header.end(),
'\n',
' ');
2081 std::string::size_type pos=header.find(
'=');
2083 while (pos!=static_cast<std::string::size_type>(std::string::npos))
2084 if (header[pos+1]==
' ')
2085 header.erase(pos+1,1);
2086 else if (header[pos-1]==
' ')
2088 header.erase(pos-1,1);
2092 pos=header.find(
'=',++pos);
2098 for (
unsigned int i=0; i<entries.size(); ++i)
2110 while (entries[i][0]==
'"')
2112 if (entries[i]==
"\"X\"")
2113 tecplot2deal[0]=n_vars;
2114 else if (entries[i]==
"\"Y\"")
2120 tecplot2deal[1]=n_vars;
2122 else if (entries[i]==
"\"Z\"")
2128 tecplot2deal[2]=n_vars;
2138 ExcMessage(
"Tecplot file must contain at least one variable for each dimension"));
2139 for (
unsigned int d=1; d<dim; ++d)
2141 ExcMessage(
"Tecplot file must contain at least one variable for each dimension."));
2195 ExcMessage(
"Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1."));
2201 ExcMessage(
"Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2."));
2216 for (
unsigned int d=0; d<dim; ++d)
2219 ExcMessage(
"Tecplot file does not contain a complete and consistent set of parameters"));
2221 n_cells*=(IJK[d]-1);
2227 ExcMessage(
"Tecplot file does not contain a complete and consistent set of parameters"));
2233 n_cells=*std::max_element(IJK.begin(),IJK.end());
2235 ExcMessage(
"Tecplot file does not contain a complete and consistent set of parameters"));
2245 const unsigned int dim=2;
2246 const unsigned int spacedim=2;
2251 skip_comment_lines (in,
'#');
2254 std::string line, header;
2261 std::string letters =
"abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ";
2264 while (line.find_first_of(letters)!=std::string::npos)
2273 std::vector<unsigned int> tecplot2deal(dim);
2274 std::vector<unsigned int> IJK(dim);
2275 unsigned int n_vars,
2281 parse_tecplot_header(header,
2282 tecplot2deal,n_vars,n_vertices,n_cells,IJK,
2283 structured,blocked);
2291 std::vector<Point<spacedim> > vertices(n_vertices+1);
2294 std::vector<CellData<dim> > cells(n_cells);
2310 unsigned int next_index=0;
2314 if (tecplot2deal[0]==0)
2320 for (
unsigned int i=1; i<first_var.size()+1; ++i)
2321 vertices[i](0) = std::strtod (first_var[i-1].c_str(), &endptr);
2326 for (
unsigned int j=first_var.size()+1; j<n_vertices+1; ++j)
2327 in>>vertices[j](next_index);
2334 for (
unsigned int i=1; i<n_vars; ++i)
2343 if (next_index==dim && structured)
2346 if ((next_index<dim) && (i==tecplot2deal[next_index]))
2349 for (
unsigned int j=1; j<n_vertices+1; ++j)
2350 in>>vertices[j](next_index);
2357 for (
unsigned int j=1; j<n_vertices+1; ++j)
2369 std::vector<double> vars(n_vars);
2376 for (
unsigned int d=0;
d<dim; ++
d)
2377 vertices[1](d) = std::strtod (first_vertex[tecplot2deal[d]].c_str(), &endptr);
2381 for (
unsigned int v=2; v<n_vertices+1; ++v)
2383 for (
unsigned int i=0; i<n_vars; ++i)
2389 for (
unsigned int i=0; i<dim; ++i)
2390 vertices[v](i)=vars[tecplot2deal[i]];
2398 unsigned int I=IJK[0],
2401 unsigned int cell=0;
2403 for (
unsigned int j=0; j<J-1; ++j)
2404 for (
unsigned int i=1; i<I; ++i)
2406 cells[cell].vertices[0]=i+ j *I;
2407 cells[cell].vertices[1]=i+1+j *I;
2408 cells[cell].vertices[2]=i+1+(j+1)*I;
2409 cells[cell].vertices[3]=i +(j+1)*I;
2413 std::vector<unsigned int> boundary_vertices(2*I+2*J-4);
2415 for (
unsigned int i=1; i<I+1; ++i)
2417 boundary_vertices[k]=i;
2419 boundary_vertices[k]=i+(J-1)*I;
2422 for (
unsigned int j=1; j<J-1; ++j)
2424 boundary_vertices[k]=1+j*I;
2426 boundary_vertices[k]=I+j*I;
2442 for (
unsigned int i=0; i<n_cells; ++i)
2453 for (
unsigned int j=0; j<GeometryInfo<dim>::vertices_per_cell; ++j)
2454 in>>cells[i].vertices[j];
2469 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
2474 template <
int dim,
int spacedim>
2482 template <
int dim,
int spacedim>
2484 const unsigned int mesh_index,
2485 const bool remove_duplicates,
2487 const bool ignore_unsupported_types)
2489 #ifdef DEAL_II_WITH_ASSIMP 2494 Assimp::Importer importer;
2497 const aiScene *scene = importer.ReadFile( filename.c_str(),
2498 aiProcess_RemoveComponent |
2499 aiProcess_JoinIdenticalVertices |
2500 aiProcess_ImproveCacheLocality |
2501 aiProcess_SortByPType |
2502 aiProcess_OptimizeGraph |
2503 aiProcess_OptimizeMeshes);
2511 (mesh_index < scene->mNumMeshes),
2517 scene->mNumMeshes : mesh_index+1);
2520 std::vector<Point<spacedim> > vertices;
2521 std::vector<CellData<dim> > cells;
2525 unsigned int v_offset=0;
2526 unsigned int c_offset=0;
2529 for (
unsigned int m=start_mesh; m<end_mesh; ++m)
2531 const aiMesh *mesh = scene->mMeshes[m];
2535 if ( (dim == 2) && mesh->mPrimitiveTypes != aiPrimitiveType_POLYGON)
2538 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
2539 "/" + std::to_string(scene->mNumMeshes)));
2542 else if ( (dim == 1) && mesh->mPrimitiveTypes != aiPrimitiveType_LINE)
2545 ExcMessage(
"Incompatible mesh " + std::to_string(m) +
2546 "/" + std::to_string(scene->mNumMeshes)));
2550 const unsigned int n_vertices = mesh->mNumVertices;
2551 const aiVector3D *mVertices = mesh->mVertices;
2554 const unsigned int n_faces = mesh->mNumFaces;
2555 const aiFace *mFaces = mesh->mFaces;
2557 vertices.resize(v_offset+n_vertices);
2558 cells.resize(c_offset+n_faces);
2560 for (
unsigned int i=0; i<n_vertices; ++i)
2561 for (
unsigned int d=0; d<spacedim; ++d)
2562 vertices[i+v_offset][d] = mVertices[i][d];
2564 unsigned int valid_cell = c_offset;
2565 for (
unsigned int i=0; i<n_faces; ++i)
2569 for (
unsigned int f=0; f<GeometryInfo<dim>::vertices_per_cell; ++f)
2571 cells[valid_cell].vertices[f] = mFaces[i].mIndices[f]+v_offset;
2579 ExcMessage(
"Face " + std::to_string(i) +
" of mesh " 2580 + std::to_string(m) +
" has " 2581 + std::to_string(mFaces[i].mNumIndices)
2582 +
" vertices. We expected only " 2586 cells.resize(valid_cell);
2591 v_offset += n_vertices;
2592 c_offset = valid_cell;
2596 if (cells.size() == 0)
2599 if (remove_duplicates)
2604 unsigned int n_verts = 0;
2605 while (n_verts != vertices.size())
2607 n_verts = vertices.size();
2608 std::vector<unsigned int> considered_vertices;
2610 considered_vertices, tol);
2615 if (dim == spacedim)
2621 tria->create_triangulation_compatibility(vertices, cells, subcelldata);
2623 tria->create_triangulation(vertices, cells, subcelldata);
2627 (void) remove_duplicates;
2629 (void) ignore_unsupported_types;
2635 template <
int dim,
int spacedim>
2648 if (std::find_if (line.begin(), line.end(),
2649 std::bind (std::not_equal_to<char>(),std::placeholders::_1,
' '))
2653 for (
int i=line.length()-1; i>=0; --i)
2654 in.putback (line[i]);
2664 template <
int dim,
int spacedim>
2666 const char comment_start)
2671 while (in.get(c) && c == comment_start)
2674 while (in.get() !=
'\n')
2684 skip_empty_lines(in);
2689 template <
int dim,
int spacedim>
2702 const std::vector<
Point<2> > &vertices,
2705 double min_x = vertices[cells[0].vertices[0]](0),
2706 max_x = vertices[cells[0].vertices[0]](0),
2707 min_y = vertices[cells[0].vertices[0]](1),
2708 max_y = vertices[cells[0].vertices[0]](1);
2710 for (
unsigned int i=0; i<cells.size(); ++i)
2712 for (
unsigned int v=0; v<4; ++v)
2714 const Point<2> &p = vertices[cells[i].vertices[v]];
2726 out <<
"# cell " << i << std::endl;
2728 for (
unsigned int f=0; f<4; ++f)
2729 center += vertices[cells[i].vertices[f]];
2732 out <<
"set label \"" << i <<
"\" at " 2733 << center(0) <<
',' << center(1)
2738 for (
unsigned int f=0; f<2; ++f)
2739 out <<
"set arrow from " 2740 << vertices[cells[i].vertices[f]](0) <<
',' 2741 << vertices[cells[i].vertices[f]](1)
2743 << vertices[cells[i].vertices[(f+1)%4]](0) <<
',' 2744 << vertices[cells[i].vertices[(f+1)%4]](1)
2747 for (
unsigned int f=2; f<4; ++f)
2748 out <<
"set arrow from " 2749 << vertices[cells[i].vertices[(f+1)%4]](0) <<
',' 2750 << vertices[cells[i].vertices[(f+1)%4]](1)
2752 << vertices[cells[i].vertices[f]](0) <<
',' 2753 << vertices[cells[i].vertices[f]](1)
2760 <<
"set nokey" << std::endl
2761 <<
"pl [" << min_x <<
':' << max_x <<
"][" 2762 << min_y <<
':' << max_y <<
"] " 2763 << min_y << std::endl
2764 <<
"pause -1" << std::endl;
2772 const std::vector<
Point<3> > &vertices,
2775 for (
unsigned int cell=0; cell<cells.size(); ++cell)
2778 out << vertices[cells[cell].vertices[0]]
2780 << vertices[cells[cell].vertices[1]]
2781 << std::endl << std::endl << std::endl;
2783 out << vertices[cells[cell].vertices[1]]
2785 << vertices[cells[cell].vertices[2]]
2786 << std::endl << std::endl << std::endl;
2788 out << vertices[cells[cell].vertices[3]]
2790 << vertices[cells[cell].vertices[2]]
2791 << std::endl << std::endl << std::endl;
2793 out << vertices[cells[cell].vertices[0]]
2795 << vertices[cells[cell].vertices[3]]
2796 << std::endl << std::endl << std::endl;
2798 out << vertices[cells[cell].vertices[4]]
2800 << vertices[cells[cell].vertices[5]]
2801 << std::endl << std::endl << std::endl;
2803 out << vertices[cells[cell].vertices[5]]
2805 << vertices[cells[cell].vertices[6]]
2806 << std::endl << std::endl << std::endl;
2808 out << vertices[cells[cell].vertices[7]]
2810 << vertices[cells[cell].vertices[6]]
2811 << std::endl << std::endl << std::endl;
2813 out << vertices[cells[cell].vertices[4]]
2815 << vertices[cells[cell].vertices[7]]
2816 << std::endl << std::endl << std::endl;
2818 out << vertices[cells[cell].vertices[0]]
2820 << vertices[cells[cell].vertices[4]]
2821 << std::endl << std::endl << std::endl;
2823 out << vertices[cells[cell].vertices[1]]
2825 << vertices[cells[cell].vertices[5]]
2826 << std::endl << std::endl << std::endl;
2828 out << vertices[cells[cell].vertices[2]]
2830 << vertices[cells[cell].vertices[6]]
2831 << std::endl << std::endl << std::endl;
2833 out << vertices[cells[cell].vertices[3]]
2835 << vertices[cells[cell].vertices[7]]
2836 << std::endl << std::endl << std::endl;
2842 template <
int dim,
int spacedim>
2850 if (format == Default)
2851 name = search.
find(filename);
2853 name = search.
find(filename, default_suffix(format));
2855 std::ifstream in(name.c_str());
2857 if (format == Default)
2859 const std::string::size_type slashpos = name.find_last_of(
'/');
2860 const std::string::size_type dotpos = name.find_last_of(
'.');
2861 if (dotpos < name.length()
2862 && (dotpos > slashpos || slashpos == std::string::npos))
2864 std::string ext = name.substr(dotpos+1);
2865 format = parse_format(ext);
2868 if (format == netcdf)
2869 read_netcdf(filename);
2875 template <
int dim,
int spacedim>
2879 if (format == Default)
2880 format = default_format;
2914 "Use the read_netcdf(string &filename) " 2915 "functions, instead."));
2924 "Use the read_assimp(string &filename, ...) " 2925 "functions, instead."));
2936 template <
int dim,
int spacedim>
2962 return ".unknown_format";
2968 template <
int dim,
int spacedim>
2972 if (format_name ==
"dbmesh")
2975 if (format_name ==
"msh")
2978 if (format_name ==
"unv")
2981 if (format_name ==
"vtk")
2985 if (format_name ==
"inp")
2988 if (format_name ==
"ucd")
2991 if (format_name ==
"xda")
2994 if (format_name ==
"netcdf")
2997 if (format_name ==
"nc")
3000 if (format_name ==
"tecplot")
3003 if (format_name ==
"dat")
3006 if (format_name ==
"plt")
3025 template <
int dim,
int spacedim>
3028 return "dbmesh|msh|unv|vtk|ucd|abaqus|xda|netcdf|tecplot|assimp";
3034 Abaqus_to_UCD<dim>::Abaqus_to_UCD ()
3042 template <
class T>
bool 3044 const std::string &s,
3045 std::ios_base& (*f) (std::ios_base &))
3047 std::istringstream iss (s);
3048 return ! (iss >> f >> t).fail();
3053 extract_int (
const std::string &s)
3056 for (
unsigned int i = 0; i<s.size(); ++i)
3065 from_string(number, tmp, std::dec);
3071 Abaqus_to_UCD<dim>::read_in_abaqus (std::istream &input_stream)
3079 std::getline (input_stream, line);
3081 while (!input_stream.fail() && !input_stream.eof())
3083 std::transform(line.begin(), line.end(), line.begin(), ::toupper);
3085 if (line.compare (
"*HEADING") == 0 ||
3086 line.compare (0, 2,
"**") == 0 ||
3087 line.compare (0, 5,
"*PART") == 0)
3090 while (!input_stream.fail() && !input_stream.eof())
3092 std::getline (input_stream, line);
3097 else if (line.compare (0, 5,
"*NODE") == 0)
3106 while (!input_stream.fail() && !input_stream.eof())
3108 std::getline (input_stream, line);
3112 std::vector <double> node (dim+1);
3114 std::istringstream iss (line);
3116 for (
unsigned int i = 0; i < dim+1; ++i)
3117 iss >> node[i] >> comma;
3119 node_list.push_back (node);
3122 else if (line.compare (0, 8,
"*ELEMENT") == 0)
3137 const std::string before_material =
"ELSET=EB";
3138 const std::size_t idx = line.find (before_material);
3139 if (idx != std::string::npos)
3141 from_string (material, line.substr (idx + before_material.size()), std::dec);
3146 std::getline (input_stream, line);
3147 while (!input_stream.fail() && !input_stream.eof())
3152 std::istringstream iss (line);
3159 std::vector <double> cell (n_data_per_cell);
3160 for (
unsigned int i = 0; i < n_data_per_cell; ++i)
3161 iss >> cell[i] >> comma;
3164 cell[0] =
static_cast<double> (material);
3165 cell_list.push_back (cell);
3167 std::getline (input_stream, line);
3170 else if (line.compare (0, 8,
"*SURFACE") == 0)
3181 const std::string name_key =
"NAME=";
3182 const std::size_t name_idx_start = line.find(name_key) + name_key.size();
3183 std::size_t name_idx_end = line.find(
',', name_idx_start);
3184 if (name_idx_end == std::string::npos)
3186 name_idx_end = line.size();
3188 const int b_indicator = extract_int(line.substr(name_idx_start, name_idx_end - name_idx_start));
3194 std::getline (input_stream, line);
3195 while (!input_stream.fail() && !input_stream.eof())
3201 std::transform(line.begin(), line.end(), line.begin(), ::toupper);
3205 std::istringstream iss (line);
3211 std::vector <double> quad_node_list;
3212 const std::string elset_name = line.substr(0, line.find(
','));
3213 if (elsets_list.count(elset_name) != 0)
3217 iss >> stmp >> temp >> face_number;
3219 const std::vector<int> cells = elsets_list[elset_name];
3220 for (
unsigned int i = 0; i <cells.size(); ++i)
3223 quad_node_list = get_global_node_numbers (el_idx, face_number);
3224 quad_node_list.insert (quad_node_list.begin(), b_indicator);
3226 face_list.push_back (quad_node_list);
3233 iss >> el_idx >> comma >> temp >> face_number;
3234 quad_node_list = get_global_node_numbers (el_idx, face_number);
3235 quad_node_list.insert (quad_node_list.begin(), b_indicator);
3237 face_list.push_back (quad_node_list);
3240 std::getline (input_stream, line);
3243 else if (line.compare (0, 6,
"*ELSET") == 0)
3247 std::string elset_name;
3249 const std::string elset_key =
"*ELSET, ELSET=";
3250 const std::size_t idx = line.find(elset_key);
3251 if (idx != std::string::npos)
3253 const std::string comma =
",";
3254 const std::size_t first_comma = line.find(comma);
3255 const std::size_t second_comma = line.find(comma, first_comma+1);
3256 const std::size_t elset_name_start = line.find(elset_key) + elset_key.size();
3257 elset_name = line.substr(elset_name_start, second_comma-elset_name_start);
3266 std::vector<int> elements;
3267 const std::size_t generate_idx = line.find(
"GENERATE");
3268 if (generate_idx != std::string::npos)
3271 std::getline (input_stream, line);
3272 std::istringstream iss (line);
3279 iss >> elid_start >> comma >> elid_end;
3281 if (iss.rdbuf()->in_avail() != 0)
3282 iss >> comma >> elis_step;
3283 for (
int i = elid_start; i <= elid_end; i+= elis_step)
3285 elements.push_back(i);
3287 elsets_list[elset_name] = elements;
3289 std::getline (input_stream, line);
3294 std::getline (input_stream, line);
3295 while (!input_stream.fail() && !input_stream.eof())
3300 std::istringstream iss (line);
3305 iss >> elid >> comma;
3306 elements.push_back (elid);
3309 std::getline (input_stream, line);
3312 elsets_list[elset_name] = elements;
3317 else if (line.compare (0, 5,
"*NSET") == 0)
3320 while (!input_stream.fail() && !input_stream.eof())
3322 std::getline (input_stream, line);
3327 else if (line.compare(0, 14,
"*SOLID SECTION") == 0)
3330 const std::string elset_key =
"ELSET=";
3331 const std::size_t elset_start = line.find(
"ELSET=") + elset_key.size();
3332 const std::size_t elset_end = line.find(
',', elset_start+1);
3333 const std::string elset_name = line.substr(elset_start, elset_end-elset_start);
3338 const std::string material_key =
"MATERIAL=";
3339 const std::size_t last_equal = line.find(
"MATERIAL=") + material_key.size();
3340 const std::size_t material_id_start = line.find(
'-', last_equal);
3342 from_string(material_id, line.substr(material_id_start+1), std::dec);
3345 const std::vector<int> &elset_cells = elsets_list[elset_name];
3346 for (
unsigned int i = 0; i < elset_cells.size(); ++i)
3348 const int cell_id = elset_cells[i] - 1;
3354 std::getline (input_stream, line);
3363 Abaqus_to_UCD<dim>::get_global_node_numbers (
const int face_cell_no,
3364 const int face_cell_face_no)
const 3374 if (face_cell_face_no == 1)
3376 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3377 quad_node_list[1] = cell_list[face_cell_no - 1][2];
3379 else if (face_cell_face_no == 2)
3381 quad_node_list[0] = cell_list[face_cell_no - 1][2];
3382 quad_node_list[1] = cell_list[face_cell_no - 1][3];
3384 else if (face_cell_face_no == 3)
3386 quad_node_list[0] = cell_list[face_cell_no - 1][3];
3387 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3389 else if (face_cell_face_no == 4)
3391 quad_node_list[0] = cell_list[face_cell_no - 1][4];
3392 quad_node_list[1] = cell_list[face_cell_no - 1][1];
3401 if (face_cell_face_no == 1)
3403 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3404 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3405 quad_node_list[2] = cell_list[face_cell_no - 1][3];
3406 quad_node_list[3] = cell_list[face_cell_no - 1][2];
3408 else if (face_cell_face_no == 2)
3410 quad_node_list[0] = cell_list[face_cell_no - 1][5];
3411 quad_node_list[1] = cell_list[face_cell_no - 1][8];
3412 quad_node_list[2] = cell_list[face_cell_no - 1][7];
3413 quad_node_list[3] = cell_list[face_cell_no - 1][6];
3415 else if (face_cell_face_no == 3)
3417 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3418 quad_node_list[1] = cell_list[face_cell_no - 1][2];
3419 quad_node_list[2] = cell_list[face_cell_no - 1][6];
3420 quad_node_list[3] = cell_list[face_cell_no - 1][5];
3422 else if (face_cell_face_no == 4)
3424 quad_node_list[0] = cell_list[face_cell_no - 1][2];
3425 quad_node_list[1] = cell_list[face_cell_no - 1][3];
3426 quad_node_list[2] = cell_list[face_cell_no - 1][7];
3427 quad_node_list[3] = cell_list[face_cell_no - 1][6];
3429 else if (face_cell_face_no == 5)
3431 quad_node_list[0] = cell_list[face_cell_no - 1][3];
3432 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3433 quad_node_list[2] = cell_list[face_cell_no - 1][8];
3434 quad_node_list[3] = cell_list[face_cell_no - 1][7];
3436 else if (face_cell_face_no == 6)
3438 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3439 quad_node_list[1] = cell_list[face_cell_no - 1][5];
3440 quad_node_list[2] = cell_list[face_cell_no - 1][8];
3441 quad_node_list[3] = cell_list[face_cell_no - 1][4];
3453 return quad_node_list;
3458 Abaqus_to_UCD<dim>::write_out_avs_ucd (std::ostream &output)
const 3467 const boost::io::ios_base_all_saver formatting_saver(output);
3471 output <<
"# Abaqus to UCD mesh conversion" << std::endl;
3472 output <<
"# Mesh type: AVS UCD" << std::endl;
3497 output << node_list.size() <<
"\t" 3498 << (cell_list.size() + face_list.size()) <<
"\t0\t0\t0" 3502 output.precision (8);
3506 for (
unsigned int ii = 0; ii < node_list.size(); ++ii)
3509 output << node_list[ii][0] <<
"\t";
3512 output.setf (std::ios::scientific, std::ios::floatfield);
3513 for (
unsigned int jj = 1; jj < dim + 1; ++jj)
3516 if (std::abs (node_list[ii][jj]) > tolerance)
3517 output << static_cast<double> (node_list[ii][jj]) <<
"\t";
3519 output << 0.0 <<
"\t";
3522 output << 0.0 <<
"\t";
3524 output << std::endl;
3525 output.unsetf (std::ios::floatfield);
3529 for (
unsigned int ii = 0; ii < cell_list.size(); ++ii)
3531 output << ii + 1 <<
"\t" 3532 << cell_list[ii][0] <<
"\t" 3533 << (dim == 2 ?
"quad" :
"hex") <<
"\t";
3534 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_cell + 1; ++jj)
3535 output << cell_list[ii][jj] <<
"\t";
3537 output << std::endl;
3541 for (
unsigned int ii = 0; ii < face_list.size(); ++ii)
3545 << face_list[ii][0] <<
"\t" 3546 << (dim == 2 ?
"line" :
"quad") <<
"\t";
3547 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_face + 1; ++jj)
3548 output << face_list[ii][jj] <<
"\t";
3550 output << std::endl;
3557 #include "grid_in.inst" 3559 DEAL_II_NAMESPACE_CLOSE
std::vector< CellData< 1 > > boundary_lines
static std::string get_format_names()
static const unsigned int invalid_unsigned_int
static ::ExceptionBase & ExcNoTriangulationSelected()
static ::ExceptionBase & ExcIO()
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
#define AssertThrow(cond, exc)
static ::ExceptionBase & ExcInvalidVertexIndex(int arg1, int arg2, int arg3)
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)
void read_dbmesh(std::istream &in)
void read_tecplot(std::istream &in)
static ::ExceptionBase & ExcInvalidState()
static ::ExceptionBase & ExcMessage(std::string arg1)
bool check_consistency(const unsigned int dim) const
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()
#define Assert(cond, exc)
static void invert_all_cells_of_negative_grid(const std::vector< Point< spacedim > > &all_vertices, std::vector< CellData< dim > > &original_cells)
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 void reorder_cells(std::vector< CellData< dim > > &original_cells, const bool use_new_style_ordering=false)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
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< 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 & ExcNotImplemented()
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)
void read_abaqus(std::istream &in, const bool apply_all_indicators_to_manifolds=false)
static void debug_output_grid(const std::vector< CellData< dim > > &cells, const std::vector< Point< spacedim > > &vertices, std::ostream &out)
const types::material_id invalid_material_id
void attach_triangulation(Triangulation< dim, spacedim > &tria)
static ::ExceptionBase & ExcInternalError()