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> 33 #ifdef DEAL_II_WITH_NETCDF 34 #include <netcdfcpp.h> 38 DEAL_II_NAMESPACE_OPEN
51 template <
int spacedim>
53 assign_1d_boundary_indicators (
const std::map<unsigned int, types::boundary_id> &boundary_ids,
56 if (boundary_ids.size() > 0)
59 cell != triangulation.
end(); ++cell)
60 for (
unsigned int f=0; f<GeometryInfo<1>::faces_per_cell; ++f)
61 if (boundary_ids.find(cell->vertex_index(f)) != boundary_ids.end())
64 ExcMessage (
"You are trying to prescribe boundary ids on the face " 65 "of a 1d cell (i.e., on a vertex), but this face is not actually at " 66 "the boundary of the mesh. This is not allowed."));
67 cell->face(f)->set_boundary_id (boundary_ids.find(cell->vertex_index(f))->second);
72 template <
int dim,
int spacedim>
74 assign_1d_boundary_indicators (
const std::map<unsigned int, types::boundary_id> &,
79 Assert (dim != 1, ExcInternalError());
83 template <
int dim,
int spacedim>
85 tria(0, typeid(*this).name()), default_format(ucd)
89 template <
int dim,
int spacedim>
97 template<
int dim,
int spacedim>
100 Assert((dim == 2)||(dim == 3), ExcNotImplemented());
109 text[0] =
"# vtk DataFile Version 3.0";
112 text[3] =
"DATASET UNSTRUCTURED_GRID";
114 for (
unsigned int i = 0; i < 4; ++i)
119 ExcMessage(std::string(
"While reading VTK file, failed to find a header line with text <") +
126 std::vector< Point<spacedim> > vertices;
127 std::vector< CellData<dim> > cells;
129 std::map<int, int> vertex_indices;
130 std::map<int, int> cell_indices;
131 std::map<int, int> quad_indices;
132 std::map<int, int> line_indices;
134 unsigned int no_vertices, no_quads=0, no_lines=0;
142 if (keyword ==
"POINTS")
145 in.ignore(256,
'\n');
147 for (
unsigned int count = 0; count < no_vertices; count++)
151 in >> x(0) >> x(1) >> x(2);
154 for (
unsigned int d=0; d<spacedim; ++d)
155 vertices.back()(d) = x(d);
157 vertex_indices[count] = count;
163 ExcMessage (
"While reading VTK file, failed to find POINTS section"));
167 std::string checkline;
169 in.ignore(256,
'\n');
171 getline(in,checkline);
172 if (checkline.compare(
"") != 0)
179 unsigned int total_cells, no_cells = 0, type;
183 if (keyword ==
"CELLS")
190 for (
unsigned int count = 0; count < total_cells; count++)
199 for (
unsigned int j = 0; j < type; j++)
200 in >> cells.back().vertices[j];
203 cells.back().material_id = 0;
205 for (
unsigned int j = 0; j < type; j++)
207 cells.back().vertices[j] = vertex_indices[cells.back().vertices[j]];
209 cell_indices[count] = count;
218 for (
unsigned int j = 0; j < type; j++)
223 for (
unsigned int j = 0; j < type; j++)
227 quad_indices[no_quads] = no_quads + 1;
233 ExcMessage (
"While reading VTK file, unknown file type encountered"));
239 for (
unsigned int count = 0; count < total_cells; count++)
247 for (
unsigned int j = 0; j < type; j++)
248 in >> cells.back().vertices[j];
250 cells.back().material_id = 0;
252 for (
unsigned int j = 0; j < type; j++)
254 cells.back().vertices[j] = vertex_indices[cells.back().vertices[j]];
256 cell_indices[count] = count;
266 for (
unsigned int j = 0; j < type; j++)
271 for (
unsigned int j = 0; j < type; j++)
275 line_indices[no_lines] = no_lines + 1;
281 ExcMessage (
"While reading VTK file, unknown file type encountered"));
286 ExcMessage (
"While reading VTK file, failed to find CELLS section"));
292 if (keyword ==
"CELL_TYPES")
294 in.ignore(256,
'\n');
299 if (keyword !=
"12" && keyword !=
"9")
308 if (keyword ==
"CELL_DATA")
314 std::string textnew[2];
315 textnew[0] =
"SCALARS MaterialID double";
316 textnew[1] =
"LOOKUP_TABLE default";
318 in.ignore(256,
'\n');
320 for (
unsigned int i = 0; i < 2; i++)
322 getline(in, linenew);
324 if (linenew.size() > textnew[0].size())
325 linenew.resize(textnew[0].size());
328 ExcMessage (std::string(
"While reading VTK file, failed to find <") +
329 textnew[i] +
"> section"));
332 for (
unsigned int i = 0; i < no_cells; i++)
336 cells[cell_indices[i]].material_id = id;
341 for (
unsigned int i = 0; i < no_quads; i++)
350 for (
unsigned int i = 0; i < no_lines; i++)
370 tria->create_triangulation_compatibility(vertices,
378 ExcMessage (
"While reading VTK file, failed to find CELLS section"));
383 template<
int dim,
int spacedim>
386 Assert(
tria != 0, ExcNoTriangulationSelected());
387 Assert((dim == 2)||(dim == 3), ExcNotImplemented());
399 AssertThrow(tmp == 2411, ExcUnknownSectionType(tmp));
401 std::vector< Point<spacedim> > vertices;
402 std::map<int, int> vertex_indices;
419 in >> dummy >> dummy >> dummy;
422 in >> x[0] >> x[1] >> x[2];
426 for (
unsigned int d = 0; d < spacedim; d++)
427 vertices.back()(d) = x[d];
429 vertex_indices[no] = no_vertex;
439 AssertThrow(tmp == 2412, ExcUnknownSectionType(tmp));
441 std::vector< CellData<dim> > cells;
444 std::map<int, int> cell_indices;
445 std::map<int, int> line_indices;
446 std::map<int, int> quad_indices;
465 in >> type >> dummy >> dummy >> dummy >> dummy;
467 AssertThrow((type == 11)||(type == 44)||(type == 94)||(type == 115), ExcUnknownElementType(type));
469 if ( (((type == 44)||(type == 94))&&(dim == 2)) || ((type == 115)&&(dim == 3)) )
474 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; v++)
475 in >> cells.back().vertices[v];
477 cells.back().material_id = 0;
479 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; v++)
480 cells.back().vertices[v] = vertex_indices[cells.back().vertices[v]];
482 cell_indices[no] = no_cell;
486 else if ( ((type == 11)&&(dim == 2)) || ((type == 11)&&(dim == 3)) )
489 in >> dummy >> dummy >> dummy;
494 for (
unsigned int v = 0; v < 2; v++)
499 for (
unsigned int v = 0; v < 2; v++)
502 line_indices[no] = no_line;
506 else if ( ((type == 44)||(type == 94)) && (dim == 3) )
511 for (
unsigned int v = 0; v < 4; v++)
516 for (
unsigned int v = 0; v < 4; v++)
519 quad_indices[no] = no_quad;
527 +
"> when running in dim=" 542 AssertThrow((tmp == 2467)||(tmp == 2477), ExcUnknownSectionType(tmp));
559 in >> dummy >> dummy >> dummy >> dummy >> dummy >> dummy >> n_entities;
564 const unsigned int n_lines = (n_entities%2 == 0)?(n_entities/2):((n_entities+1)/2);
566 for (
unsigned int line = 0; line < n_lines; line++)
568 unsigned int n_fragments;
570 if (line == n_lines-1)
571 n_fragments = (n_entities%2 == 0)?(2):(1);
575 for (
unsigned int no_fragment = 0; no_fragment < n_fragments; no_fragment++)
578 in >> dummy >> no >> dummy >> dummy;
580 if ( cell_indices.count(no) > 0 )
581 cells[cell_indices[no]].material_id =
id;
583 if ( line_indices.count(no) > 0 )
586 if ( quad_indices.count(no) > 0 )
605 tria->create_triangulation_compatibility(vertices,
612 template <
int dim,
int spacedim>
615 Assert (
tria != 0, ExcNoTriangulationSelected());
622 unsigned int n_vertices;
623 unsigned int n_cells;
634 std::vector<Point<spacedim> > vertices (n_vertices);
638 std::map<int,int> vertex_indices;
640 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
648 >> x[0] >> x[1] >> x[2];
651 for (
unsigned int d=0; d<spacedim; ++d)
652 vertices[vertex](d) = x[d];
656 vertex_indices[vertex_number] = vertex;
660 std::vector<CellData<dim> > cells;
663 for (
unsigned int cell=0; cell<n_cells; ++cell)
672 std::string cell_type;
676 unsigned int material_id;
682 if (((cell_type ==
"line") && (dim == 1)) ||
683 ((cell_type ==
"quad") && (dim == 2)) ||
684 ((cell_type ==
"hex" ) && (dim == 3)))
689 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
690 in >> cells.back().vertices[i];
693 Assert(material_id<= std::numeric_limits<types::material_id>::max(),
694 ExcIndexRange(material_id,0,std::numeric_limits<types::material_id>::max()));
703 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
704 if (vertex_indices.find (cells.back().vertices[i]) != vertex_indices.end())
706 cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]];
711 ExcInvalidVertexIndex(cell, cells.back().vertices[i]));
716 else if ((cell_type ==
"line") && ((dim == 2) || (dim == 3)))
724 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
725 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
735 for (
unsigned int i=0; i<2; ++i)
736 if (vertex_indices.find (subcelldata.
boundary_lines.back().vertices[i]) !=
737 vertex_indices.end())
745 ExcInvalidVertexIndex(cell,
751 else if ((cell_type ==
"quad") && (dim == 3))
761 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
762 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
772 for (
unsigned int i=0; i<4; ++i)
773 if (vertex_indices.find (subcelldata.
boundary_quads.back().vertices[i]) !=
774 vertex_indices.end())
782 ExcInvalidVertexIndex(cell,
791 AssertThrow (
false, ExcUnknownIdentifier(cell_type));
806 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
817 void read_in_abaqus (std::istream &in);
818 void write_out_avs_ucd (std::ostream &out)
const;
821 const double tolerance;
823 std::vector<double> get_global_node_numbers (
const int face_cell_no,
824 const int face_cell_face_no)
const;
827 std::vector< std::vector<double> > node_list;
829 std::vector< std::vector<double> > cell_list;
831 std::vector< std::vector<double> > face_list;
833 std::map< std::string, std::vector<int> > elsets_list;
837 template <
int dim,
int spacedim>
840 Assert (
tria != 0, ExcNoTriangulationSelected());
841 Assert (dim==2 || dim==3, ExcNotImplemented());
846 Abaqus_to_UCD<dim> abaqus_to_ucd;
847 abaqus_to_ucd.read_in_abaqus(in);
849 std::stringstream in_ucd;
850 abaqus_to_ucd.write_out_avs_ucd(in_ucd);
862 AssertThrow(
false,
ExcMessage(
"Internal conversion from ABAQUS file to UCD format was unsuccessful. \ 863 Are you sure that your ABAQUS mesh file conforms with the requirements \ 864 listed in the documentation?"));
869 template <
int dim,
int spacedim>
872 Assert (
tria != 0, ExcNoTriangulationSelected());
873 Assert (dim==2, ExcNotImplemented());
885 ExcInvalidDBMESHInput(line));
891 AssertThrow (line==
"Dimension", ExcInvalidDBMESHInput(line));
892 unsigned int dimension;
894 AssertThrow (dimension == dim, ExcDBMESHWrongDimension(dimension));
908 while (getline(in,line), line.find(
"# END")==std::string::npos)
915 AssertThrow (line==
"Vertices", ExcInvalidDBMESHInput(line));
917 unsigned int n_vertices;
921 std::vector<Point<spacedim> > vertices (n_vertices);
922 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
925 for (
unsigned int d=0; d<dim; ++d)
926 in >> vertices[vertex][d];
938 AssertThrow (line==
"Edges", ExcInvalidDBMESHInput(line));
940 unsigned int n_edges;
942 for (
unsigned int edge=0; edge<n_edges; ++edge)
945 in >> dummy >> dummy;
960 AssertThrow (line==
"CrackedEdges", ExcInvalidDBMESHInput(line));
963 for (
unsigned int edge=0; edge<n_edges; ++edge)
966 in >> dummy >> dummy;
978 AssertThrow (line==
"Quadrilaterals", ExcInvalidDBMESHInput(line));
980 std::vector<CellData<dim> > cells;
982 unsigned int n_cells;
984 for (
unsigned int cell=0; cell<n_cells; ++cell)
989 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
991 in >> cells.back().vertices[i];
995 (static_cast<unsigned int>(cells.back().vertices[i]) <= vertices.size()),
996 ExcInvalidVertexIndex(cell, cells.back().vertices[i]));
998 --cells.back().vertices[i];
1014 while (getline(in,line), ((line.find(
"End")==std::string::npos) && (in)))
1030 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1035 template <
int dim,
int spacedim>
1038 Assert (
false, ExcNotImplemented());
1046 Assert (
tria != 0, ExcNoTriangulationSelected());
1054 unsigned int n_vertices;
1055 unsigned int n_cells;
1065 for (
unsigned int i=0; i<8; ++i)
1069 std::vector<CellData<2> > cells (n_cells);
1072 for (
unsigned int cell=0; cell<n_cells; ++cell)
1081 ExcInternalError());
1083 for (
unsigned int i=0; i<4; ++i)
1084 in >> cells[cell].vertices[i];
1090 std::vector<Point<2> > vertices (n_vertices);
1091 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
1096 in >> x[0] >> x[1] >> x[2];
1099 for (
unsigned int d=0; d<2; ++d)
1100 vertices[vertex](d) = x[d];
1109 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1117 Assert (
tria != 0, ExcNoTriangulationSelected());
1120 static const unsigned int xda_to_dealII_map[] = {0,1,5,4,3,2,6,7};
1127 unsigned int n_vertices;
1128 unsigned int n_cells;
1138 for (
unsigned int i=0; i<8; ++i)
1142 std::vector<CellData<3> > cells (n_cells);
1145 for (
unsigned int cell=0; cell<n_cells; ++cell)
1154 ExcInternalError());
1156 unsigned int xda_ordered_nodes[8];
1158 for (
unsigned int i=0; i<8; ++i)
1159 in >> xda_ordered_nodes[i];
1161 for (
unsigned int i=0; i<8; i++)
1162 cells[cell].vertices[i] = xda_ordered_nodes[xda_to_dealII_map[i]];
1168 std::vector<Point<3> > vertices (n_vertices);
1169 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
1174 in >> x[0] >> x[1] >> x[2];
1177 for (
unsigned int d=0; d<3; ++d)
1178 vertices[vertex](d) = x[d];
1187 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1193 template <
int dim,
int spacedim>
1196 Assert (
tria != 0, ExcNoTriangulationSelected());
1199 unsigned int n_vertices;
1200 unsigned int n_cells;
1207 unsigned int gmsh_file_format = 0;
1208 if (line ==
"@f$NOD")
1209 gmsh_file_format = 1;
1210 else if (line ==
"@f$MeshFormat")
1211 gmsh_file_format = 2;
1218 if (gmsh_file_format == 2)
1221 unsigned int file_type, data_size;
1223 in >> version >> file_type >> data_size;
1225 Assert ( (version >= 2.0) &&
1226 (version <= 2.2), ExcNotImplemented());
1227 Assert (file_type == 0, ExcNotImplemented());
1228 Assert (data_size ==
sizeof(
double), ExcNotImplemented());
1237 ExcInvalidGMSHInput(line));
1242 if (line ==
"@f$PhysicalNames")
1248 while (line !=
"@f$EndPhysicalNames");
1256 ExcInvalidGMSHInput(line));
1261 std::vector<Point<spacedim> > vertices (n_vertices);
1265 std::map<int,int> vertex_indices;
1267 for (
unsigned int vertex=0; vertex<n_vertices; ++vertex)
1274 >> x[0] >> x[1] >> x[2];
1276 for (
unsigned int d=0; d<spacedim; ++d)
1277 vertices[vertex](d) = x[d];
1279 vertex_indices[vertex_number] = vertex;
1284 static const std::string end_nodes_marker[] = {
"@f$ENDNOD",
"@f$EndNodes" };
1285 AssertThrow (line==end_nodes_marker[gmsh_file_format-1],
1286 ExcInvalidGMSHInput(line));
1290 static const std::string begin_elements_marker[] = {
"@f$ELM",
"@f$Elements" };
1291 AssertThrow (line==begin_elements_marker[gmsh_file_format-1],
1292 ExcInvalidGMSHInput(line));
1299 std::vector<CellData<dim> > cells;
1301 std::map<unsigned int, types::boundary_id> boundary_ids_1d;
1303 for (
unsigned int cell=0; cell<n_cells; ++cell)
1312 unsigned int cell_type;
1313 unsigned int material_id;
1314 unsigned int nod_num;
1332 switch (gmsh_file_format)
1347 unsigned int n_tags;
1354 for (
unsigned int i=1; i<n_tags; ++i)
1382 if (((cell_type == 1) && (dim == 1)) ||
1383 ((cell_type == 3) && (dim == 2)) ||
1384 ((cell_type == 5) && (dim == 3)))
1388 ExcMessage (
"Number of nodes does not coincide with the " 1389 "number required for this object"));
1393 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1394 in >> cells.back().vertices[i];
1397 Assert(material_id<= std::numeric_limits<types::material_id>::max(),
1398 ExcIndexRange(material_id,0,std::numeric_limits<types::material_id>::max()));
1407 for (
unsigned int i=0; i<GeometryInfo<dim>::vertices_per_cell; ++i)
1409 AssertThrow (vertex_indices.find (cells.back().vertices[i]) !=
1410 vertex_indices.end(),
1411 ExcInvalidVertexIndex(cell, cells.back().vertices[i]));
1414 cells.back().vertices[i] = vertex_indices[cells.back().vertices[i]];
1417 else if ((cell_type == 1) && ((dim == 2) || (dim == 3)))
1425 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
1426 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
1436 for (
unsigned int i=0; i<2; ++i)
1437 if (vertex_indices.find (subcelldata.
boundary_lines.back().vertices[i]) !=
1438 vertex_indices.end())
1446 ExcInvalidVertexIndex(cell,
1452 else if ((cell_type == 3) && (dim == 3))
1462 Assert(material_id<= std::numeric_limits<types::boundary_id>::max(),
1463 ExcIndexRange(material_id,0,std::numeric_limits<types::boundary_id>::max()));
1473 for (
unsigned int i=0; i<4; ++i)
1474 if (vertex_indices.find (subcelldata.
boundary_quads.back().vertices[i]) !=
1475 vertex_indices.end())
1483 ExcInvalidVertexIndex(cell,
1490 else if (cell_type == 15)
1493 unsigned int node_index;
1494 switch (gmsh_file_format)
1498 for (
unsigned int i=0; i<nod_num; ++i)
1512 boundary_ids_1d[vertex_indices[node_index]] = material_id;
1523 ExcMessage(
"Found triangles while reading a file " 1524 "in gmsh format. deal.II does not " 1525 "support triangles"));
1527 ExcMessage(
"Found tetrahedra while reading a file " 1528 "in gmsh format. deal.II does not " 1529 "support tetrahedra"));
1531 AssertThrow (
false, ExcGmshUnsupportedGeometry(cell_type));
1537 static const std::string end_elements_marker[] = {
"@f$ENDELM",
"@f$EndElements" };
1538 AssertThrow (line==end_elements_marker[gmsh_file_format-1],
1539 ExcInvalidGMSHInput(line));
1548 AssertThrow(cells.size() > 0, ExcGmshNoCellInformation());
1557 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1562 assign_1d_boundary_indicators (boundary_ids_1d, *
tria);
1589 Assert(
false, ExcNotImplemented());
1595 #ifndef DEAL_II_WITH_NETCDF 1599 const unsigned int dim=2;
1600 const unsigned int spacedim=2;
1601 const bool output=
false;
1602 Assert (
tria != 0, ExcNoTriangulationSelected());
1625 const unsigned int coord=1;
1631 const unsigned int x2d=0;
1632 const unsigned int y2d=2;
1641 NcFile nc (filename.c_str());
1645 NcDim *elements_dim=nc.get_dim(
"no_of_elements");
1647 const unsigned int n_cells=elements_dim->size();
1651 NcDim *marker_dim=nc.get_dim(
"no_of_markers");
1653 const unsigned int n_markers=marker_dim->size();
1655 NcVar *marker_var=nc.get_var(
"marker");
1659 marker_var->get_dim(0)->size())==n_markers, ExcIO());
1661 std::vector<int> marker(n_markers);
1664 marker_var->get(&*marker.begin(), n_markers);
1668 std::cout <<
"n_cell=" << n_cells << std::endl;
1669 std::cout <<
"marker: ";
1670 for (
unsigned int i=0; i<n_markers; ++i)
1671 std::cout << marker[i] <<
" ";
1672 std::cout << std::endl;
1678 NcDim *bquads_dim=nc.get_dim(
"no_of_surfacequadrilaterals");
1680 const unsigned int n_bquads=bquads_dim->size();
1682 NcVar *bmarker_var=nc.get_var(
"boundarymarker_of_surfaces");
1686 bmarker_var->get_dim(0)->size())==n_bquads, ExcIO());
1688 std::vector<int> bmarker(n_bquads);
1689 bmarker_var->get(&*bmarker.begin(), n_bquads);
1694 std::map<int, unsigned int> n_bquads_per_bmarker;
1695 for (
unsigned int i=0; i<n_markers; ++i)
1699 AssertThrow(n_bquads_per_bmarker.find(marker[i])==
1700 n_bquads_per_bmarker.end(), ExcIO());
1702 n_bquads_per_bmarker[marker[i]]=
1703 count(bmarker.begin(), bmarker.end(), marker[i]);
1719 std::cout <<
"n_bquads_per_bmarker: " << std::endl;
1720 std::map<int, unsigned int>::const_iterator
1721 iter=n_bquads_per_bmarker.begin();
1722 for (; iter!=n_bquads_per_bmarker.end(); ++iter)
1723 std::cout <<
" n_bquads_per_bmarker[" << iter->first
1724 <<
"]=" << iter->second << std::endl;
1731 NcDim *quad_vertices_dim=nc.get_dim(
"points_per_surfacequadrilateral");
1732 AssertThrow(quad_vertices_dim->is_valid(), ExcIO());
1733 const unsigned int vertices_per_quad=quad_vertices_dim->size();
1736 NcVar *vertex_indices_var=nc.get_var(
"points_of_surfacequadrilaterals");
1737 AssertThrow(vertex_indices_var->is_valid(), ExcIO());
1738 AssertThrow(vertex_indices_var->num_dims()==2, ExcIO());
1740 vertex_indices_var->get_dim(0)->size())==n_bquads, ExcIO());
1742 vertex_indices_var->get_dim(1)->size())==vertices_per_quad, ExcIO());
1744 std::vector<int> vertex_indices(n_bquads*vertices_per_quad);
1745 vertex_indices_var->get(&*vertex_indices.begin(), n_bquads, vertices_per_quad);
1747 for (
unsigned int i=0; i<vertex_indices.size(); ++i)
1748 AssertThrow(vertex_indices[i]>=0, ExcInternalError());
1752 std::cout <<
"vertex_indices:" << std::endl;
1753 for (
unsigned int i=0, v=0; i<n_bquads; ++i)
1755 for (
unsigned int j=0; j<vertices_per_quad; ++j)
1756 std::cout << vertex_indices[v++] <<
" ";
1757 std::cout << std::endl;
1765 NcDim *vertices_dim=nc.get_dim(
"no_of_points");
1767 const unsigned int n_vertices=vertices_dim->size();
1769 std::cout <<
"n_vertices=" << n_vertices << std::endl;
1771 NcVar *points_xc=nc.get_var(
"points_xc");
1772 NcVar *points_yc=nc.get_var(
"points_yc");
1773 NcVar *points_zc=nc.get_var(
"points_zc");
1781 static_cast<int>(n_vertices), ExcIO());
1783 static_cast<int>(n_vertices), ExcIO());
1785 static_cast<int>(n_vertices), ExcIO());
1786 std::vector<std::vector<double> > point_values(
1787 3, std::vector<double> (n_vertices));
1788 points_xc->get(&*point_values[0].begin(), n_vertices);
1789 points_yc->get(&*point_values[1].begin(), n_vertices);
1790 points_zc->get(&*point_values[2].begin(), n_vertices);
1793 std::vector<Point<spacedim> > vertices (n_vertices);
1794 for (
unsigned int i=0; i<n_vertices; ++i)
1796 vertices[i](0)=point_values[x2d][i];
1797 vertices[i](1)=point_values[y2d][i];
1803 std::map<int, bool> zero_plane_markers;
1804 for (
unsigned int quad=0; quad<n_bquads; ++quad)
1806 bool zero_plane=
true;
1807 for (
unsigned int i=0; i<vertices_per_quad; ++i)
1808 if (point_values[coord][vertex_indices[quad*vertices_per_quad+i]]!=0)
1815 zero_plane_markers[bmarker[quad]]=
true;
1817 unsigned int sum_of_zero_plane_cells=0;
1818 for (std::map<int, bool>::const_iterator iter=zero_plane_markers.begin();
1819 iter != zero_plane_markers.end(); ++iter)
1821 sum_of_zero_plane_cells+=n_bquads_per_bmarker[iter->first];
1823 std::cout <<
"bmarker=" << iter->first << std::endl;
1825 AssertThrow(sum_of_zero_plane_cells==n_cells, ExcIO());
1830 std::vector<CellData<dim> > cells(n_cells);
1831 for (
unsigned int quad=0, cell=0; quad<n_bquads; ++quad)
1833 bool zero_plane=
false;
1834 for (std::map<int, bool>::const_iterator iter=zero_plane_markers.begin();
1835 iter != zero_plane_markers.end(); ++iter)
1836 if (bmarker[quad]==iter->first)
1844 for (
unsigned int i=0; i<vertices_per_quad; ++i)
1846 Assert(point_values[coord][vertex_indices[
1847 quad*vertices_per_quad+i]]==0, ExcNotImplemented());
1848 cells[cell].vertices[i]=vertex_indices[quad*vertices_per_quad+i];
1857 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
1865 #ifndef DEAL_II_WITH_NETCDF 1872 const unsigned int dim=3;
1873 const unsigned int spacedim=3;
1874 const bool output=
false;
1875 Assert (
tria != 0, ExcNoTriangulationSelected());
1880 NcFile nc (filename.c_str());
1884 NcDim *elements_dim=nc.get_dim(
"no_of_elements");
1886 const unsigned int n_cells=elements_dim->size();
1888 std::cout <<
"n_cell=" << n_cells << std::endl;
1890 NcDim *hexes_dim=nc.get_dim(
"no_of_hexaeders");
1892 const unsigned int n_hexes=hexes_dim->size();
1894 ExcMessage(
"deal.II can handle purely hexaedral grids, only."));
1900 NcDim *hex_vertices_dim=nc.get_dim(
"points_per_hexaeder");
1901 AssertThrow(hex_vertices_dim->is_valid(), ExcIO());
1902 const unsigned int vertices_per_hex=hex_vertices_dim->size();
1905 NcVar *vertex_indices_var=nc.get_var(
"points_of_hexaeders");
1906 AssertThrow(vertex_indices_var->is_valid(), ExcIO());
1907 AssertThrow(vertex_indices_var->num_dims()==2, ExcIO());
1909 vertex_indices_var->get_dim(0)->size())==n_cells, ExcIO());
1911 vertex_indices_var->get_dim(1)->size())==vertices_per_hex, ExcIO());
1913 std::vector<int> vertex_indices(n_cells*vertices_per_hex);
1916 vertex_indices_var->get(&*vertex_indices.begin(), n_cells, vertices_per_hex);
1918 for (
unsigned int i=0; i<vertex_indices.size(); ++i)
1919 AssertThrow(vertex_indices[i]>=0, ExcInternalError());
1923 std::cout <<
"vertex_indices:" << std::endl;
1924 for (
unsigned int cell=0, v=0; cell<n_cells; ++cell)
1926 for (
unsigned int i=0; i<vertices_per_hex; ++i)
1927 std::cout << vertex_indices[v++] <<
" ";
1928 std::cout << std::endl;
1936 NcDim *vertices_dim=nc.get_dim(
"no_of_points");
1938 const unsigned int n_vertices=vertices_dim->size();
1940 std::cout <<
"n_vertices=" << n_vertices << std::endl;
1942 NcVar *points_xc=nc.get_var(
"points_xc");
1943 NcVar *points_yc=nc.get_var(
"points_yc");
1944 NcVar *points_zc=nc.get_var(
"points_zc");
1952 static_cast<int>(n_vertices), ExcIO());
1954 static_cast<int>(n_vertices), ExcIO());
1956 static_cast<int>(n_vertices), ExcIO());
1957 std::vector<std::vector<double> > point_values(
1958 3, std::vector<double> (n_vertices));
1960 const bool switch_y_z=
false;
1961 points_xc->get(&*point_values[0].begin(), n_vertices);
1964 points_yc->get(&*point_values[2].begin(), n_vertices);
1965 points_zc->get(&*point_values[1].begin(), n_vertices);
1969 points_yc->get(&*point_values[1].begin(), n_vertices);
1970 points_zc->get(&*point_values[2].begin(), n_vertices);
1974 std::vector<Point<spacedim> > vertices (n_vertices);
1975 for (
unsigned int i=0; i<n_vertices; ++i)
1977 vertices[i](0)=point_values[0][i];
1978 vertices[i](1)=point_values[1][i];
1979 vertices[i](2)=point_values[2][i];
1983 std::vector<CellData<dim> > cells(n_cells);
1984 for (
unsigned int cell=0; cell<n_cells; ++cell)
1985 for (
unsigned int i=0; i<vertices_per_hex; ++i)
1986 cells[cell].vertices[i]=vertex_indices[cell*vertices_per_hex+i];
1997 NcDim *quad_vertices_dim=nc.get_dim(
"points_per_surfacequadrilateral");
1998 AssertThrow(quad_vertices_dim->is_valid(), ExcIO());
1999 const unsigned int vertices_per_quad=quad_vertices_dim->size();
2002 NcVar *bvertex_indices_var=nc.get_var(
"points_of_surfacequadrilaterals");
2003 AssertThrow(bvertex_indices_var->is_valid(), ExcIO());
2004 AssertThrow(bvertex_indices_var->num_dims()==2, ExcIO());
2005 const unsigned int n_bquads=bvertex_indices_var->get_dim(0)->size();
2007 bvertex_indices_var->get_dim(1)->size())==
2010 std::vector<int> bvertex_indices(n_bquads*vertices_per_quad);
2011 bvertex_indices_var->get(&*bvertex_indices.begin(), n_bquads, vertices_per_quad);
2015 std::cout <<
"bquads: ";
2016 for (
unsigned int i=0; i<n_bquads; ++i)
2018 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
2019 std::cout << bvertex_indices[
2021 std::cout << std::endl;
2028 NcDim *bquads_dim=nc.get_dim(
"no_of_surfacequadrilaterals");
2031 bquads_dim->size())==n_bquads, ExcIO());
2033 NcVar *bmarker_var=nc.get_var(
"boundarymarker_of_surfaces");
2037 bmarker_var->get_dim(0)->size())==n_bquads, ExcIO());
2039 std::vector<int> bmarker(n_bquads);
2040 bmarker_var->get(&*bmarker.begin(), n_bquads);
2046 for (
unsigned int i=0; i<bmarker.size(); ++i)
2053 for (
unsigned int i=0; i<n_bquads; ++i)
2055 for (
unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
2059 = static_cast<types::boundary_id>(bmarker[i]);
2065 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
2070 template <
int dim,
int spacedim>
2072 std::vector<unsigned int> &tecplot2deal,
2073 unsigned int &n_vars,
2074 unsigned int &n_vertices,
2075 unsigned int &n_cells,
2076 std::vector<unsigned int> &IJK,
2080 Assert(tecplot2deal.size()==dim, ExcInternalError());
2081 Assert(IJK.size()==dim, ExcInternalError());
2099 std::transform(header.begin(),header.end(),header.begin(),::toupper);
2103 std::replace(header.begin(),header.end(),
'\t',
' ');
2104 std::replace(header.begin(),header.end(),
',',
' ');
2105 std::replace(header.begin(),header.end(),
'\n',
' ');
2109 std::string::size_type pos=header.find(
"=");
2111 while (pos!=static_cast<std::string::size_type>(std::string::npos))
2112 if (header[pos+1]==
' ')
2113 header.erase(pos+1,1);
2114 else if (header[pos-1]==
' ')
2116 header.erase(pos-1,1);
2120 pos=header.find(
"=",++pos);
2126 for (
unsigned int i=0; i<entries.size(); ++i)
2138 while (entries[i][0]==
'"')
2140 if (entries[i]==
"\"X\"")
2141 tecplot2deal[0]=n_vars;
2142 else if (entries[i]==
"\"Y\"")
2148 tecplot2deal[1]=n_vars;
2150 else if (entries[i]==
"\"Z\"")
2156 tecplot2deal[2]=n_vars;
2166 ExcMessage(
"Tecplot file must contain at least one variable for each dimension"));
2167 for (
unsigned int d=1; d<dim; ++d)
2169 ExcMessage(
"Tecplot file must contain at least one variable for each dimension."));
2223 ExcMessage(
"Parameter 'J=' found in tecplot, although this is only possible for dimensions greater than 1."));
2229 ExcMessage(
"Parameter 'K=' found in tecplot, although this is only possible for dimensions greater than 2."));
2244 for (
unsigned int d=0; d<dim; ++d)
2247 ExcMessage(
"Tecplot file does not contain a complete and consistent set of parameters"));
2249 n_cells*=(IJK[d]-1);
2255 ExcMessage(
"Tecplot file does not contain a complete and consistent set of parameters"));
2261 n_cells=*std::max_element(IJK.begin(),IJK.end());
2263 ExcMessage(
"Tecplot file does not contain a complete and consistent set of parameters"));
2273 const unsigned int dim=2;
2274 const unsigned int spacedim=2;
2275 Assert (
tria != 0, ExcNoTriangulationSelected());
2282 std::string line, header;
2289 std::string letters =
"abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ";
2292 while (line.find_first_of(letters)!=std::string::npos)
2301 std::vector<unsigned int> tecplot2deal(dim);
2302 std::vector<unsigned int> IJK(dim);
2303 unsigned int n_vars,
2310 tecplot2deal,n_vars,n_vertices,n_cells,IJK,
2311 structured,blocked);
2319 std::vector<Point<spacedim> > vertices(n_vertices+1);
2322 std::vector<CellData<dim> > cells(n_cells);
2338 unsigned int next_index=0;
2342 if (tecplot2deal[0]==0)
2348 for (
unsigned int i=1; i<first_var.size()+1; ++i)
2349 vertices[i](0) = std::strtod (first_var[i-1].c_str(), &endptr);
2354 for (
unsigned int j=first_var.size()+1; j<n_vertices+1; ++j)
2355 in>>vertices[j](next_index);
2362 for (
unsigned int i=1; i<n_vars; ++i)
2371 if (next_index==dim && structured)
2374 if ((next_index<dim) && (i==tecplot2deal[next_index]))
2377 for (
unsigned int j=1; j<n_vertices+1; ++j)
2378 in>>vertices[j](next_index);
2385 for (
unsigned int j=1; j<n_vertices+1; ++j)
2389 Assert(next_index==dim, ExcInternalError());
2397 std::vector<double> vars(n_vars);
2404 for (
unsigned int d=0; d<dim; ++d)
2405 vertices[1](d) = std::strtod (first_vertex[tecplot2deal[d]].c_str(), &endptr);
2409 for (
unsigned int v=2; v<n_vertices+1; ++v)
2411 for (
unsigned int i=0; i<n_vars; ++i)
2417 for (
unsigned int i=0; i<dim; ++i)
2418 vertices[v](i)=vars[tecplot2deal[i]];
2426 unsigned int I=IJK[0],
2429 unsigned int cell=0;
2431 for (
unsigned int j=0; j<J-1; ++j)
2432 for (
unsigned int i=1; i<I; ++i)
2434 cells[cell].vertices[0]=i+ j *I;
2435 cells[cell].vertices[1]=i+1+j *I;
2436 cells[cell].vertices[2]=i+1+(j+1)*I;
2437 cells[cell].vertices[3]=i +(j+1)*I;
2440 Assert(cell=n_cells, ExcInternalError());
2441 std::vector<unsigned int> boundary_vertices(2*I+2*J-4);
2443 for (
unsigned int i=1; i<I+1; ++i)
2445 boundary_vertices[k]=i;
2447 boundary_vertices[k]=i+(J-1)*I;
2450 for (
unsigned int j=1; j<J-1; ++j)
2452 boundary_vertices[k]=1+j*I;
2454 boundary_vertices[k]=I+j*I;
2457 Assert(k==boundary_vertices.size(), ExcInternalError());
2470 for (
unsigned int i=0; i<n_cells; ++i)
2481 for (
unsigned int j=0; j<GeometryInfo<dim>::vertices_per_cell; ++j)
2482 in>>cells[i].vertices[j];
2497 tria->create_triangulation_compatibility (vertices, cells, subcelldata);
2502 template <
int dim,
int spacedim>
2505 Assert(
false, ExcNotImplemented());
2509 template <
int dim,
int spacedim>
2522 if (std::find_if (line.begin(), line.end(),
2523 std::bind2nd (std::not_equal_to<char>(),
' '))
2527 for (
int i=line.length()-1; i>=0; --i)
2528 in.putback (line[i]);
2538 template <
int dim,
int spacedim>
2540 const char comment_start)
2545 while ((c=in.get()) == comment_start)
2548 while (in.get() !=
'\n')
2562 template <
int dim,
int spacedim>
2567 Assert (
false, ExcNotImplemented());
2575 const std::vector<
Point<2> > &vertices,
2578 double min_x = vertices[cells[0].vertices[0]](0),
2579 max_x = vertices[cells[0].vertices[0]](0),
2580 min_y = vertices[cells[0].vertices[0]](1),
2581 max_y = vertices[cells[0].vertices[0]](1);
2583 for (
unsigned int i=0; i<cells.size(); ++i)
2585 for (
unsigned int v=0; v<4; ++v)
2587 const Point<2> &p = vertices[cells[i].vertices[v]];
2599 out <<
"# cell " << i << std::endl;
2601 for (
unsigned int f=0; f<4; ++f)
2602 center += vertices[cells[i].vertices[f]];
2605 out <<
"set label \"" << i <<
"\" at " 2606 << center(0) <<
',' << center(1)
2611 for (
unsigned int f=0; f<2; ++f)
2612 out <<
"set arrow from " 2613 << vertices[cells[i].vertices[f]](0) <<
',' 2614 << vertices[cells[i].vertices[f]](1)
2616 << vertices[cells[i].vertices[(f+1)%4]](0) <<
',' 2617 << vertices[cells[i].vertices[(f+1)%4]](1)
2620 for (
unsigned int f=2; f<4; ++f)
2621 out <<
"set arrow from " 2622 << vertices[cells[i].vertices[(f+1)%4]](0) <<
',' 2623 << vertices[cells[i].vertices[(f+1)%4]](1)
2625 << vertices[cells[i].vertices[f]](0) <<
',' 2626 << vertices[cells[i].vertices[f]](1)
2633 <<
"set nokey" << std::endl
2634 <<
"pl [" << min_x <<
':' << max_x <<
"][" 2635 << min_y <<
':' << max_y <<
"] " 2636 << min_y << std::endl
2637 <<
"pause -1" << std::endl;
2645 const std::vector<
Point<3> > &vertices,
2648 for (
unsigned int cell=0; cell<cells.size(); ++cell)
2651 out << vertices[cells[cell].vertices[0]]
2653 << vertices[cells[cell].vertices[1]]
2654 << std::endl << std::endl << std::endl;
2656 out << vertices[cells[cell].vertices[1]]
2658 << vertices[cells[cell].vertices[2]]
2659 << std::endl << std::endl << std::endl;
2661 out << vertices[cells[cell].vertices[3]]
2663 << vertices[cells[cell].vertices[2]]
2664 << std::endl << std::endl << std::endl;
2666 out << vertices[cells[cell].vertices[0]]
2668 << vertices[cells[cell].vertices[3]]
2669 << std::endl << std::endl << std::endl;
2671 out << vertices[cells[cell].vertices[4]]
2673 << vertices[cells[cell].vertices[5]]
2674 << std::endl << std::endl << std::endl;
2676 out << vertices[cells[cell].vertices[5]]
2678 << vertices[cells[cell].vertices[6]]
2679 << std::endl << std::endl << std::endl;
2681 out << vertices[cells[cell].vertices[7]]
2683 << vertices[cells[cell].vertices[6]]
2684 << std::endl << std::endl << std::endl;
2686 out << vertices[cells[cell].vertices[4]]
2688 << vertices[cells[cell].vertices[7]]
2689 << std::endl << std::endl << std::endl;
2691 out << vertices[cells[cell].vertices[0]]
2693 << vertices[cells[cell].vertices[4]]
2694 << std::endl << std::endl << std::endl;
2696 out << vertices[cells[cell].vertices[1]]
2698 << vertices[cells[cell].vertices[5]]
2699 << std::endl << std::endl << std::endl;
2701 out << vertices[cells[cell].vertices[2]]
2703 << vertices[cells[cell].vertices[6]]
2704 << std::endl << std::endl << std::endl;
2706 out << vertices[cells[cell].vertices[3]]
2708 << vertices[cells[cell].vertices[7]]
2709 << std::endl << std::endl << std::endl;
2715 template <
int dim,
int spacedim>
2724 name = search.
find(filename);
2728 std::ifstream in(name.c_str());
2732 const std::string::size_type slashpos = name.find_last_of(
'/');
2733 const std::string::size_type dotpos = name.find_last_of(
'.');
2734 if (dotpos < name.length()
2735 && (dotpos > slashpos || slashpos == std::string::npos))
2737 std::string ext = name.substr(dotpos+1);
2748 template <
int dim,
int spacedim>
2787 "Use the read(_netcdf)(string &filename) " 2788 "functions, instead."));
2798 Assert (
false, ExcInternalError());
2803 template <
int dim,
int spacedim>
2828 Assert (
false, ExcNotImplemented());
2829 return ".unknown_format";
2835 template <
int dim,
int spacedim>
2839 if (format_name ==
"dbmesh")
2842 if (format_name ==
"msh")
2845 if (format_name ==
"unv")
2848 if (format_name ==
"vtk")
2852 if (format_name ==
"inp")
2855 if (format_name ==
"ucd")
2858 if (format_name ==
"xda")
2861 if (format_name ==
"netcdf")
2864 if (format_name ==
"nc")
2867 if (format_name ==
"tecplot")
2870 if (format_name ==
"dat")
2873 if (format_name ==
"plt")
2892 template <
int dim,
int spacedim>
2895 return "dbmesh|msh|unv|vtk|ucd|abaqus|xda|netcdf|tecplot";
2901 Abaqus_to_UCD<dim>::Abaqus_to_UCD ()
2904 AssertThrow(dim==2 || dim==3, ExcNotImplemented());
2909 template <
class T>
bool 2911 const std::string &s,
2912 std::ios_base& (*f) (std::ios_base &))
2914 std::istringstream iss (s);
2915 return ! (iss >> f >> t).fail();
2920 extract_int (
const std::string &s)
2923 for (
unsigned int i = 0; i<s.size(); ++i)
2932 from_string(number, tmp, std::dec);
2938 Abaqus_to_UCD<dim>::read_in_abaqus (std::istream &input_stream)
2946 std::getline (input_stream, line);
2948 while (!input_stream.eof())
2950 std::transform(line.begin(), line.end(), line.begin(), ::toupper);
2952 if (line.compare (
"*HEADING") == 0 ||
2953 line.compare (0, 2,
"**") == 0 ||
2954 line.compare (0, 5,
"*PART") == 0)
2957 while (!input_stream.eof())
2959 std::getline (input_stream, line);
2964 else if (line.compare (0, 5,
"*NODE") == 0)
2973 while (!input_stream.eof())
2975 std::getline (input_stream, line);
2979 std::vector <double> node (dim+1);
2981 std::istringstream iss (line);
2983 for (
unsigned int i = 0; i < dim+1; ++i)
2984 iss >> node[i] >> comma;
2986 node_list.push_back (node);
2989 else if (line.compare (0, 8,
"*ELEMENT") == 0)
3004 const std::string before_material =
"ELSET=EB";
3005 const std::size_t idx = line.find (before_material);
3006 if (idx != std::string::npos)
3008 from_string (material, line.substr (idx + before_material.size()), std::dec);
3013 std::getline (input_stream, line);
3014 while (!input_stream.eof())
3019 std::istringstream iss (line);
3026 std::vector <double> cell (n_data_per_cell);
3027 for (
unsigned int i = 0; i < n_data_per_cell; ++i)
3028 iss >> cell[i] >> comma;
3031 cell[0] =
static_cast<double> (material);
3032 cell_list.push_back (cell);
3034 std::getline (input_stream, line);
3037 else if (line.compare (0, 8,
"*SURFACE") == 0)
3048 const std::string name_key =
"NAME=";
3049 const std::size_t name_idx_start = line.find(name_key) + name_key.size();
3050 std::size_t name_idx_end = line.find(
',', name_idx_start);
3051 if (name_idx_end == std::string::npos)
3053 name_idx_end = line.size();
3055 const int b_indicator = extract_int(line.substr(name_idx_start, name_idx_end - name_idx_start));
3061 std::getline (input_stream, line);
3062 while (!input_stream.eof())
3068 std::transform(line.begin(), line.end(), line.begin(), ::toupper);
3072 std::istringstream iss (line);
3079 std::vector <double> quad_node_list;
3080 const std::string elset_name = line.substr(0, line.find(
','));
3081 if (elsets_list.count(elset_name) != 0)
3085 iss >> stmp >> temp >> face_number;
3087 const std::vector<int> cells = elsets_list[elset_name];
3088 for (
unsigned int i = 0; i <cells.size(); ++i)
3091 quad_node_list = get_global_node_numbers (el_idx, face_number);
3092 quad_node_list.insert (quad_node_list.begin(), b_indicator);
3094 face_list.push_back (quad_node_list);
3100 iss >> el_idx >> comma >> temp >> face_number;
3101 quad_node_list = get_global_node_numbers (el_idx, face_number);
3102 quad_node_list.insert (quad_node_list.begin(), b_indicator);
3104 face_list.push_back (quad_node_list);
3107 std::getline (input_stream, line);
3110 else if (line.compare (0, 6,
"*ELSET") == 0)
3114 std::string elset_name;
3116 const std::string elset_key =
"*ELSET, ELSET=";
3117 const std::size_t idx = line.find(elset_key);
3118 if (idx != std::string::npos)
3120 const std::string comma =
",";
3121 const std::size_t first_comma = line.find(comma);
3122 const std::size_t second_comma = line.find(comma, first_comma+1);
3123 const std::size_t elset_name_start = line.find(elset_key) + elset_key.size();
3124 elset_name = line.substr(elset_name_start, second_comma-elset_name_start);
3133 std::vector<int> elements;
3134 const std::size_t generate_idx = line.find(
"GENERATE");
3135 if (generate_idx != std::string::npos)
3138 std::getline (input_stream, line);
3139 std::istringstream iss (line);
3146 iss >> elid_start >> comma >> elid_end;
3148 if (iss.rdbuf()->in_avail() != 0)
3149 iss >> comma >> elis_step;
3150 for (
int i = elid_start; i <= elid_end; i+= elis_step)
3152 elements.push_back(i);
3154 elsets_list[elset_name] = elements;
3156 std::getline (input_stream, line);
3161 std::getline (input_stream, line);
3162 while (!input_stream.eof())
3167 std::istringstream iss (line);
3172 iss >> elid >> comma;
3173 elements.push_back (elid);
3176 std::getline (input_stream, line);
3179 elsets_list[elset_name] = elements;
3184 else if (line.compare (0, 5,
"*NSET") == 0)
3187 while (!input_stream.eof())
3189 std::getline (input_stream, line);
3194 else if (line.compare(0, 14,
"*SOLID SECTION") == 0)
3197 const std::string elset_key =
"ELSET=";
3198 const std::size_t elset_start = line.find(
"ELSET=") + elset_key.size();
3199 const std::size_t elset_end = line.find(
',', elset_start+1);
3200 const std::string elset_name = line.substr(elset_start, elset_end-elset_start);
3205 const std::string material_key =
"MATERIAL=";
3206 const std::size_t last_equal = line.find(
"MATERIAL=") + material_key.size();
3207 const std::size_t material_id_start = line.find(
'-', last_equal);
3208 int material_id = 0;
3209 from_string(material_id, line.substr(material_id_start+1), std::dec);
3212 const std::vector<int> &elset_cells = elsets_list[elset_name];
3213 for (
unsigned int i = 0; i < elset_cells.size(); ++i)
3215 const int cell_id = elset_cells[i] - 1;
3216 cell_list[cell_id][0] = material_id;
3221 std::getline (input_stream, line);
3230 Abaqus_to_UCD<dim>::get_global_node_numbers (
const int face_cell_no,
3231 const int face_cell_face_no)
const 3241 if (face_cell_face_no == 1)
3243 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3244 quad_node_list[1] = cell_list[face_cell_no - 1][2];
3246 else if (face_cell_face_no == 2)
3248 quad_node_list[0] = cell_list[face_cell_no - 1][2];
3249 quad_node_list[1] = cell_list[face_cell_no - 1][3];
3251 else if (face_cell_face_no == 3)
3253 quad_node_list[0] = cell_list[face_cell_no - 1][3];
3254 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3256 else if (face_cell_face_no == 4)
3258 quad_node_list[0] = cell_list[face_cell_no - 1][4];
3259 quad_node_list[1] = cell_list[face_cell_no - 1][1];
3268 if (face_cell_face_no == 1)
3270 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3271 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3272 quad_node_list[2] = cell_list[face_cell_no - 1][3];
3273 quad_node_list[3] = cell_list[face_cell_no - 1][2];
3275 else if (face_cell_face_no == 2)
3277 quad_node_list[0] = cell_list[face_cell_no - 1][5];
3278 quad_node_list[1] = cell_list[face_cell_no - 1][8];
3279 quad_node_list[2] = cell_list[face_cell_no - 1][7];
3280 quad_node_list[3] = cell_list[face_cell_no - 1][6];
3282 else if (face_cell_face_no == 3)
3284 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3285 quad_node_list[1] = cell_list[face_cell_no - 1][2];
3286 quad_node_list[2] = cell_list[face_cell_no - 1][6];
3287 quad_node_list[3] = cell_list[face_cell_no - 1][5];
3289 else if (face_cell_face_no == 4)
3291 quad_node_list[0] = cell_list[face_cell_no - 1][2];
3292 quad_node_list[1] = cell_list[face_cell_no - 1][3];
3293 quad_node_list[2] = cell_list[face_cell_no - 1][7];
3294 quad_node_list[3] = cell_list[face_cell_no - 1][6];
3296 else if (face_cell_face_no == 5)
3298 quad_node_list[0] = cell_list[face_cell_no - 1][3];
3299 quad_node_list[1] = cell_list[face_cell_no - 1][4];
3300 quad_node_list[2] = cell_list[face_cell_no - 1][8];
3301 quad_node_list[3] = cell_list[face_cell_no - 1][7];
3303 else if (face_cell_face_no == 6)
3305 quad_node_list[0] = cell_list[face_cell_no - 1][1];
3306 quad_node_list[1] = cell_list[face_cell_no - 1][5];
3307 quad_node_list[2] = cell_list[face_cell_no - 1][8];
3308 quad_node_list[3] = cell_list[face_cell_no - 1][4];
3317 AssertThrow(dim==2 || dim==3, ExcNotImplemented());
3320 return quad_node_list;
3325 Abaqus_to_UCD<dim>::write_out_avs_ucd (std::ostream &output)
const 3335 output <<
"# Abaqus to UCD mesh conversion" << std::endl;
3336 output <<
"# Mesh type: AVS UCD" << std::endl;
3362 << node_list.size() <<
"\t" 3363 << (cell_list.size() + face_list.size()) <<
"\t0\t0\t0" 3367 for (
unsigned int ii = 0; ii < node_list.size(); ++ii)
3369 for (
unsigned int jj = 0; jj < dim + 1; ++jj)
3374 output << node_list[ii][jj] <<
"\t";
3379 output.setf (std::ios::scientific,
3380 std::ios::floatfield);
3381 output.precision (8);
3382 if (std::abs (node_list[ii][jj]) > tolerance)
3383 output << static_cast<double> (node_list[ii][jj]) <<
"\t";
3385 output << 0.0 <<
"\t";
3389 output << 0.0 <<
"\t";
3393 output.unsetf (std::ios::floatfield);
3397 for (
unsigned int ii = 0; ii < cell_list.size(); ++ii)
3401 << cell_list[ii][0] <<
"\t" 3402 << (dim == 2 ?
"quad" :
"hex") <<
"\t";
3403 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_cell + 1; ++jj)
3405 << cell_list[ii][jj] <<
"\t";
3412 for (
unsigned int ii = 0; ii < face_list.size(); ++ii)
3416 << face_list[ii][0] <<
"\t" 3417 << (dim == 2 ?
"line" :
"quad") <<
"\t";
3418 for (
unsigned int jj = 1; jj < GeometryInfo<dim>::vertices_per_face + 1; ++jj)
3420 << face_list[ii][jj] <<
"\t";
3430 #include "grid_in.inst" 3432 DEAL_II_NAMESPACE_CLOSE
std::vector< CellData< 1 > > boundary_lines
static std::string get_format_names()
static const unsigned int invalid_unsigned_int
unsigned char material_id
::ExceptionBase & ExcMessage(std::string arg1)
std::pair< int, unsigned int > get_integer_at_position(const std::string &name, const unsigned int position)
SmartPointer< Triangulation< dim, spacedim >, GridIn< dim, spacedim > > tria
std::vector< std::string > break_text_into_lines(const std::string &original_text, const unsigned int width, const char delimiter=' ')
active_cell_iterator begin_active(const unsigned int level=0) const
#define AssertThrow(cond, exc)
static Format parse_format(const std::string &format_name)
static void skip_empty_lines(std::istream &in)
void read_vtk(std::istream &in)
cell_iterator end() const
void read_dbmesh(std::istream &in)
void read_tecplot(std::istream &in)
bool check_consistency(const unsigned int dim) const
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 void reorder_cells(std::vector< CellData< dim > > &original_cells, const bool use_new_style_ordering=false)
#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)
void read_abaqus(std::istream &in)
::ExceptionBase & ExcNeedsNetCDF()
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
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)
unsigned char boundary_id
const types::boundary_id internal_face_boundary_id
Use GridIn::default_format stored in this object.
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)