34#include <boost/archive/binary_oarchive.hpp>
36#ifdef DEAL_II_GMSH_WITH_API
55 const bool write_faces,
56 const bool write_diameter,
57 const bool write_measure,
58 const bool write_all_faces)
59 : write_cells(write_cells)
60 , write_faces(write_faces)
61 , write_diameter(write_diameter)
62 , write_measure(write_measure)
63 , write_all_faces(write_all_faces)
69 param.declare_entry(
"Write cells",
72 "Write the mesh connectivity as DX grid cells");
73 param.declare_entry(
"Write faces",
76 "Write faces of cells. These may be boundary faces "
77 "or all faces between mesh cells, according to "
78 "\"Write all faces\"");
79 param.declare_entry(
"Write diameter",
82 "If cells are written, additionally write their"
83 " diameter as data for visualization");
84 param.declare_entry(
"Write measure",
87 "Write the volume of each cell as data");
88 param.declare_entry(
"Write all faces",
91 "Write all faces, not only boundary");
105 Msh::Msh(
const bool write_faces,
const bool write_lines)
106 : write_faces(write_faces)
107 , write_lines(write_lines)
127 const bool write_faces,
128 const bool write_lines)
129 : write_preamble(write_preamble)
130 , write_faces(write_faces)
131 , write_lines(write_lines)
156 const unsigned int n_extra_curved_line_points,
157 const bool curved_inner_cells,
158 const bool write_additional_boundary_lines)
159 : write_cell_numbers(write_cell_numbers)
160 , n_extra_curved_line_points(n_extra_curved_line_points)
161 , curved_inner_cells(curved_inner_cells)
162 , write_additional_boundary_lines(write_additional_boundary_lines)
184 const unsigned int size,
185 const double line_width,
186 const bool color_lines_on_user_flag,
187 const unsigned int n_boundary_face_points,
188 const bool color_lines_level)
189 : size_type(size_type)
191 , line_width(line_width)
192 , color_lines_on_user_flag(color_lines_on_user_flag)
193 , n_boundary_face_points(n_boundary_face_points)
194 , color_lines_level(color_lines_level)
201 param.declare_entry(
"Size by",
204 "Depending on this parameter, either the "
206 "of the eps is scaled to \"Size\"");
207 param.declare_entry(
"Size",
210 "Size of the output in points");
211 param.declare_entry(
"Line width",
214 "Width of the lines drawn in points");
215 param.declare_entry(
"Color by flag",
218 "Draw lines with user flag set in different color");
219 param.declare_entry(
"Boundary points",
222 "Number of points on boundary edges. "
223 "Increase this beyond 2 to see curved boundaries.");
224 param.declare_entry(
"Color by level",
227 "Draw different colors according to grid level.");
234 if (
param.get(
"Size by") == std::string(
"width"))
236 else if (
param.get(
"Size by") == std::string(
"height"))
248 const unsigned int size,
249 const double line_width,
250 const bool color_lines_on_user_flag,
251 const unsigned int n_boundary_face_points)
255 color_lines_on_user_flag,
256 n_boundary_face_points)
274 const unsigned int size,
275 const double line_width,
276 const bool color_lines_on_user_flag,
277 const unsigned int n_boundary_face_points,
278 const bool write_cell_numbers,
279 const bool write_cell_number_level,
280 const bool write_vertex_numbers,
281 const bool color_lines_level)
285 color_lines_on_user_flag,
286 n_boundary_face_points,
288 , write_cell_numbers(write_cell_numbers)
289 , write_cell_number_level(write_cell_number_level)
290 , write_vertex_numbers(write_vertex_numbers)
297 param.declare_entry(
"Cell number",
300 "(2d only) Write cell numbers"
301 " into the centers of cells");
302 param.declare_entry(
"Level number",
305 "(2d only) if \"Cell number\" is true, write "
306 "numbers in the form level.number");
307 param.declare_entry(
"Vertex number",
310 "Write numbers for each vertex");
318 write_cell_numbers =
param.get_bool(
"Cell number");
319 write_cell_number_level =
param.get_bool(
"Level number");
320 write_vertex_numbers =
param.get_bool(
"Vertex number");
326 const unsigned int size,
327 const double line_width,
328 const bool color_lines_on_user_flag,
329 const unsigned int n_boundary_face_points,
330 const double azimut_angle,
331 const double turn_angle)
335 color_lines_on_user_flag,
336 n_boundary_face_points)
337 , azimut_angle(azimut_angle)
338 , turn_angle(turn_angle)
345 param.declare_entry(
"Azimuth",
348 "Azimuth of the viw point, that is, the angle "
349 "in the plane from the x-axis.");
350 param.declare_entry(
"Elevation",
353 "Elevation of the view point above the xy-plane.");
361 azimut_angle = 90 -
param.get_double(
"Elevation");
362 turn_angle =
param.get_double(
"Azimuth");
368 : draw_boundary(
true)
369 , color_by(material_id)
371 , n_boundary_face_points(0)
377 , boundary_thickness(3)
411 const unsigned int boundary_line_thickness,
414 const int azimuth_angle,
415 const int polar_angle,
417 const bool convert_level_number_to_height,
418 const bool label_level_number,
419 const bool label_cell_index,
420 const bool label_material_id,
421 const bool label_subdomain_id,
422 const bool draw_colorbar,
423 const bool draw_legend,
424 const bool label_boundary_id)
427 , line_thickness(line_thickness)
428 , boundary_line_thickness(boundary_line_thickness)
430 , background(background)
431 , azimuth_angle(azimuth_angle)
432 , polar_angle(polar_angle)
434 , convert_level_number_to_height(convert_level_number_to_height)
435 , level_height_factor(0.3f)
436 , cell_font_scaling(1.f)
437 , label_level_number(label_level_number)
438 , label_cell_index(label_cell_index)
439 , label_material_id(label_material_id)
440 , label_subdomain_id(label_subdomain_id)
441 , label_level_subdomain_id(
false)
442 , label_boundary_id(label_boundary_id)
443 , draw_colorbar(draw_colorbar)
444 , draw_legend(draw_legend)
448 : draw_bounding_box(
false)
467 : default_format(none)
647 return "none|dx|gnuplot|eps|ucd|xfig|msh|svg|mathgl|vtk|vtu";
654 param.declare_entry(
"Format",
658 param.enter_subsection(
"DX");
660 param.leave_subsection();
662 param.enter_subsection(
"Msh");
664 param.leave_subsection();
666 param.enter_subsection(
"Ucd");
668 param.leave_subsection();
670 param.enter_subsection(
"Gnuplot");
672 param.leave_subsection();
674 param.enter_subsection(
"Eps");
679 param.leave_subsection();
681 param.enter_subsection(
"XFig");
683 param.leave_subsection();
685 param.enter_subsection(
"MathGL");
687 param.leave_subsection();
689 param.enter_subsection(
"Vtk");
691 param.leave_subsection();
693 param.enter_subsection(
"Vtu");
695 param.leave_subsection();
705 param.enter_subsection(
"DX");
707 param.leave_subsection();
709 param.enter_subsection(
"Msh");
711 param.leave_subsection();
713 param.enter_subsection(
"Ucd");
715 param.leave_subsection();
717 param.enter_subsection(
"Gnuplot");
719 param.leave_subsection();
721 param.enter_subsection(
"Eps");
725 param.leave_subsection();
727 param.enter_subsection(
"XFig");
729 param.leave_subsection();
731 param.enter_subsection(
"MathGL");
733 param.leave_subsection();
735 param.enter_subsection(
"Vtk");
737 param.leave_subsection();
739 param.enter_subsection(
"Vtu");
741 param.leave_subsection();
780template <
int dim,
int spacedim>
783 std::ostream & out)
const
789 const std::vector<Point<spacedim>> &
vertices =
tria.get_vertices();
790 const std::vector<bool> & vertex_used =
tria.get_used_vertices();
792 const unsigned int n_vertices =
tria.n_used_vertices();
799 std::vector<unsigned int> renumber(
vertices.size());
803 for (
unsigned int i = 0; i <
vertices.size(); ++i)
809 out <<
"object \"vertices\" class array type float rank 1 shape " << dim
810 <<
" items " << n_vertices <<
" data follows" <<
'\n';
812 for (
unsigned int i = 0; i <
vertices.size(); ++i)
820 const unsigned int n_cells =
tria.n_active_cells();
821 const unsigned int n_faces =
829 out <<
"object \"cells\" class array type int rank 1 shape "
833 for (
const auto &cell :
tria.active_cell_iterators())
841 out <<
"attribute \"element type\" string \"";
849 <<
"attribute \"ref\" string \"positions\"" <<
'\n'
854 out <<
"object \"material\" class array type int rank 0 items " << n_cells
855 <<
" data follows" <<
'\n';
856 for (
const auto &cell :
tria.active_cell_iterators())
857 out <<
' ' << cell->material_id();
858 out <<
'\n' <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
860 out <<
"object \"level\" class array type int rank 0 items " << n_cells
861 <<
" data follows" <<
'\n';
862 for (
const auto &cell :
tria.active_cell_iterators())
863 out <<
' ' << cell->level();
864 out <<
'\n' <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
868 out <<
"object \"measure\" class array type float rank 0 items "
869 << n_cells <<
" data follows" <<
'\n';
870 for (
const auto &cell :
tria.active_cell_iterators())
871 out <<
'\t' << cell->measure();
873 <<
"attribute \"dep\" string \"connections\"" <<
'\n'
879 out <<
"object \"diameter\" class array type float rank 0 items "
880 << n_cells <<
" data follows" <<
'\n';
881 for (
const auto &cell :
tria.active_cell_iterators())
882 out <<
'\t' << cell->diameter();
884 <<
"attribute \"dep\" string \"connections\"" <<
'\n'
891 out <<
"object \"faces\" class array type int rank 1 shape "
895 for (
const auto &cell :
tria.active_cell_iterators())
897 for (
const unsigned int f : cell->face_indices())
905 << renumber[face->vertex_index(
910 out <<
"attribute \"element type\" string \"";
916 <<
"attribute \"ref\" string \"positions\"" <<
'\n'
922 out <<
"object \"boundary\" class array type int rank 0 items " << n_faces
923 <<
" data follows" <<
'\n';
924 for (
const auto &cell :
tria.active_cell_iterators())
930 <<
static_cast<std::make_signed<types::boundary_id>::type
>(
931 cell->face(f)->boundary_id());
935 out <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
939 out <<
"object \"face measure\" class array type float rank 0 items "
940 << n_faces <<
" data follows" <<
'\n';
941 for (
const auto &cell :
tria.active_cell_iterators())
944 out <<
' ' << cell->face(f)->measure();
947 out <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
952 out <<
"object \"face diameter\" class array type float rank 0 items "
953 << n_faces <<
" data follows" <<
'\n';
954 for (
const auto &cell :
tria.active_cell_iterators())
957 out <<
' ' << cell->face(f)->diameter();
960 out <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
973 out <<
"object \"deal data\" class field" <<
'\n'
974 <<
"component \"positions\" value \"vertices\"" <<
'\n'
975 <<
"component \"connections\" value \"cells\"" <<
'\n';
979 out <<
"object \"cell data\" class field" <<
'\n'
980 <<
"component \"positions\" value \"vertices\"" <<
'\n'
981 <<
"component \"connections\" value \"cells\"" <<
'\n';
982 out <<
"component \"material\" value \"material\"" <<
'\n';
983 out <<
"component \"level\" value \"level\"" <<
'\n';
985 out <<
"component \"measure\" value \"measure\"" <<
'\n';
987 out <<
"component \"diameter\" value \"diameter\"" <<
'\n';
992 out <<
"object \"face data\" class field" <<
'\n'
993 <<
"component \"positions\" value \"vertices\"" <<
'\n'
994 <<
"component \"connections\" value \"faces\"" <<
'\n';
995 out <<
"component \"boundary\" value \"boundary\"" <<
'\n';
997 out <<
"component \"measure\" value \"face measure\"" <<
'\n';
999 out <<
"component \"diameter\" value \"face diameter\"" <<
'\n';
1002 out <<
'\n' <<
"object \"grid data\" class group" <<
'\n';
1004 out <<
"member \"cells\" value \"cell data\"" <<
'\n';
1006 out <<
"member \"faces\" value \"face data\"" <<
'\n';
1007 out <<
"end" <<
'\n';
1018template <
int dim,
int spacedim>
1021 std::ostream & out)
const
1028 const std::vector<Point<spacedim>> &
vertices =
tria.get_vertices();
1029 const std::vector<bool> & vertex_used =
tria.get_used_vertices();
1031 const unsigned int n_vertices =
tria.n_used_vertices();
1049 out <<
"@f$NOD" <<
'\n' << n_vertices <<
'\n';
1054 for (
unsigned int i = 0; i <
vertices.size(); ++i)
1059 for (
unsigned int d = spacedim + 1; d <= 3; ++d)
1065 out <<
"@f$ENDNOD" <<
'\n'
1067 <<
tria.n_active_cells() +
1073 {0, 1, 5, 4, 2, 3, 7, 6}};
1077 for (
const auto &cell :
tria.active_cell_iterators())
1079 out << cell->active_cell_index() + 1 <<
' '
1080 << cell->reference_cell().gmsh_element_type() <<
' '
1081 << cell->material_id() <<
' ' << cell->subdomain_id() <<
' '
1082 << cell->n_vertices() <<
' ';
1086 for (
const unsigned int vertex : cell->vertex_indices())
1088 if (cell->reference_cell() == ReferenceCells::get_hypercube<dim>())
1089 out << cell->vertex_index(
1094 else if (cell->reference_cell() == ReferenceCells::get_simplex<dim>())
1095 out << cell->vertex_index(vertex) + 1 <<
' ';
1113 out <<
"@f$ENDELM\n";
1123template <
int dim,
int spacedim>
1126 std::ostream & out)
const
1133 const std::vector<Point<spacedim>> &
vertices =
tria.get_vertices();
1134 const std::vector<bool> & vertex_used =
tria.get_used_vertices();
1136 const unsigned int n_vertices =
tria.n_used_vertices();
1144 std::time_t
time1 = std::time(
nullptr);
1145 std::tm * time = std::localtime(&
time1);
1147 <<
"# This file was generated by the deal.II library." <<
'\n'
1148 <<
"# Date = " << time->tm_year + 1900 <<
"/" << time->tm_mon + 1
1149 <<
"/" << time->tm_mday <<
'\n'
1150 <<
"# Time = " << time->tm_hour <<
":" << std::setw(2) << time->tm_min
1151 <<
":" << std::setw(2) << time->tm_sec <<
'\n'
1153 <<
"# For a description of the UCD format see the AVS Developer's guide."
1159 out << n_vertices <<
' '
1160 <<
tria.n_active_cells() +
1169 for (
unsigned int i = 0; i <
vertices.size(); ++i)
1174 for (
unsigned int d = spacedim + 1; d <= 3; ++d)
1181 for (
const auto &cell :
tria.active_cell_iterators())
1183 out << cell->active_cell_index() + 1 <<
' ' << cell->material_id() <<
' ';
1240template <
int dim,
int spacedim>
1258 const int spacedim = 2;
1264 out <<
"#FIG 3.2\nLandscape\nCenter\nInches" << std::endl
1265 <<
"A4\n100.00\nSingle"
1268 <<
"-3" << std::endl
1269 <<
"# generated by deal.II GridOut class" << std::endl
1270 <<
"# reduce first number to scale up image" << std::endl
1271 <<
"1200 2" << std::endl;
1274 unsigned int colno = 32;
1275 out <<
"0 " <<
colno++ <<
" #ff0000" << std::endl;
1276 out <<
"0 " <<
colno++ <<
" #ff8000" << std::endl;
1277 out <<
"0 " <<
colno++ <<
" #ffd000" << std::endl;
1278 out <<
"0 " <<
colno++ <<
" #ffff00" << std::endl;
1279 out <<
"0 " <<
colno++ <<
" #c0ff00" << std::endl;
1280 out <<
"0 " <<
colno++ <<
" #80ff00" << std::endl;
1281 out <<
"0 " <<
colno++ <<
" #00f000" << std::endl;
1282 out <<
"0 " <<
colno++ <<
" #00f0c0" << std::endl;
1283 out <<
"0 " <<
colno++ <<
" #00f0ff" << std::endl;
1284 out <<
"0 " <<
colno++ <<
" #00c0ff" << std::endl;
1285 out <<
"0 " <<
colno++ <<
" #0080ff" << std::endl;
1286 out <<
"0 " <<
colno++ <<
" #0040ff" << std::endl;
1287 out <<
"0 " <<
colno++ <<
" #0000c0" << std::endl;
1288 out <<
"0 " <<
colno++ <<
" #5000ff" << std::endl;
1289 out <<
"0 " <<
colno++ <<
" #8000ff" << std::endl;
1290 out <<
"0 " <<
colno++ <<
" #b000ff" << std::endl;
1291 out <<
"0 " <<
colno++ <<
" #ff00ff" << std::endl;
1292 out <<
"0 " <<
colno++ <<
" #ff80ff" << std::endl;
1294 for (
unsigned int i = 0; i < 8; ++i)
1295 out <<
"0 " <<
colno++ <<
" #" << std::hex << 32 * i + 31 << 32 * i + 31
1296 << 32 * i + 31 << std::dec << std::endl;
1298 for (
unsigned int i = 1; i < 16; ++i)
1299 out <<
"0 " <<
colno++ <<
" #00" << std::hex << 16 * i + 15 << std::dec
1300 <<
"00" << std::endl;
1302 for (
unsigned int i = 1; i < 16; ++i)
1303 out <<
"0 " <<
colno++ <<
" #" << std::hex << 16 * i + 15 << 16 * i + 15
1304 << std::dec <<
"00" << std::endl;
1306 for (
unsigned int i = 1; i < 16; ++i)
1307 out <<
"0 " <<
colno++ <<
" #" << std::hex << 16 * i + 15 << std::dec
1308 <<
"0000" << std::endl;
1310 for (
unsigned int i = 1; i < 16; ++i)
1311 out <<
"0 " <<
colno++ <<
" #" << std::hex << 16 * i + 15 <<
"00"
1312 << 16 * i + 15 << std::dec << std::endl;
1314 for (
unsigned int i = 1; i < 16; ++i)
1315 out <<
"0 " <<
colno++ <<
" #0000" << std::hex << 16 * i + 15 << std::dec
1318 for (
unsigned int i = 1; i < 16; ++i)
1319 out <<
"0 " <<
colno++ <<
" #00" << std::hex << 16 * i + 15 << 16 * i + 15
1320 << std::dec << std::endl;
1327 for (
const auto &cell :
tria.cell_iterators())
1342 out << cell->material_id() + 32;
1345 out << cell->level() + 8;
1348 out << cell->subdomain_id() + 32;
1351 out << cell->level_subdomain_id() + 32;
1360 (900 + cell->material_id()))
1366 <<
nv + 1 << std::endl;
1372 for (
unsigned int k = 0;
k <=
nv; ++
k)
1380 out <<
'\t' << ((d == 0) ? val : -val);
1385 static const unsigned int face_reorder[4] = {2, 1, 3, 0};
1415 for (
unsigned int k = 0;
1426 out <<
'\t' << ((d == 0) ? val : -val);
1443#ifdef DEAL_II_GMSH_WITH_API
1444template <
int dim,
int spacedim>
1447 const std::string &
filename)
const
1453 const std::array<std::vector<unsigned int>, 8>
dealii_to_gmsh = {
1460 {{0, 1, 2, 3, 4, 5}},
1461 {{0, 1, 3, 2, 4, 5, 7, 6}}}};
1466 std::vector<double> coords(3 *
vertices.size());
1473 for (
unsigned int d = 0; d < spacedim; ++d)
1474 coords[i * 3 + d] = p[d];
1486 using IdPair = std::pair<types::material_id, types::manifold_id>;
1491 for (
const auto &cell :
tria.active_cell_iterators())
1493 set_of_pairs.insert({cell->material_id(), cell->manifold_id()});
1494 for (
const auto &f : cell->face_iterators())
1496 (f->boundary_id() != 0 &&
1498 set_of_pairs.insert({f->boundary_id(), f->manifold_id()});
1500 for (
const auto l : cell->line_indices())
1502 const auto &f = cell->line(l);
1504 (f->boundary_id() != 0 &&
1506 set_of_pairs.insert({f->boundary_id(), f->manifold_id()});
1519 std::vector<std::vector<std::vector<std::size_t>>>
element_ids(
1521 std::vector<std::vector<std::vector<std::size_t>>>
element_nodes(
1528 const auto type = element->reference_cell();
1533 for (
const auto v : element->vertex_indices())
1549 [&](
const auto & element,
1551 const auto struct_dim = element->structure_dimension;
1552 const auto manifold_id = element->manifold_id();
1556 (boundary_or_material_id != 0 &&
1571 for (
const auto &cell :
tria.active_cell_iterators())
1574 for (
const auto &face : cell->face_iterators())
1577 for (
const auto l : cell->line_indices())
1583 gmsh::option::setNumber(
"General.Verbosity", 0);
1584 gmsh::model::add(
"Grid generated in deal.II");
1587 gmsh::model::addDiscreteEntity(p.first, p.second);
1588 gmsh::model::mesh::addNodes(p.first, p.second,
nodes, coords);
1592 for (
unsigned int t = 1; t < 8; ++t)
1598 gmsh::model::mesh::addElementsByType(
entity_tag + 1,
1608 const auto &d =
it.first;
1614 if (d == dim && boundary_id != 0)
1616 static_cast<int>(boundary_id));
1617 else if (d < dim && boundary_id != 0)
1627 sep +
"ManifoldID:" +
1630 gmsh::model::addPhysicalGroup(d, {
entity_tag}, -1);
1681template <
int dim,
int spacedim>
1684 std::ostream & )
const
1687 ExcMessage(
"Mesh output in SVG format is not implemented for anything "
1688 "other than two-dimensional meshes in two-dimensional "
1689 "space. That's because three-dimensional meshes are best "
1690 "viewed in programs that allow changing the viewpoint, "
1691 "but SVG format does not allow this: It is an inherently "
1692 "2d format, and for three-dimensional meshes would "
1693 "require choosing one, fixed viewpoint."
1695 "You probably want to output your mesh in a format such "
1696 "as VTK, VTU, or gnuplot."));
1705 unsigned int min_level, max_level;
1713 Assert(height != 0 || width != 0,
1714 ExcMessage(
"You have to set at least one of width and height"));
1748 min_level = max_level =
tria.
begin()->level();
1754 std::set<unsigned int> levels;
1766 for (
const auto &cell :
tria.cell_iterators())
1768 for (
unsigned int vertex_index = 0; vertex_index < cell->n_vertices();
1771 if (cell->vertex(vertex_index)[0] <
x_min)
1772 x_min = cell->vertex(vertex_index)[0];
1773 if (cell->vertex(vertex_index)[0] >
x_max)
1774 x_max = cell->vertex(vertex_index)[0];
1776 if (cell->vertex(vertex_index)[1] <
y_min)
1777 y_min = cell->vertex(vertex_index)[1];
1778 if (cell->vertex(vertex_index)[1] >
y_max)
1779 y_max = cell->vertex(vertex_index)[1];
1782 if (
static_cast<unsigned int>(cell->level()) < min_level)
1783 min_level = cell->level();
1784 if (
static_cast<unsigned int>(cell->level()) > max_level)
1785 max_level = cell->level();
1788 levels.insert(cell->level());
1789 if (cell->is_active())
1801 const unsigned int n_levels = levels.size();
1937 (
static_cast<float>(
tria.
begin()->level()) /
1938 static_cast<float>(n_levels)) *
1951 for (
const auto &cell :
tria.cell_iterators())
1953 point[0] = cell->vertex(0)[0];
1954 point[1] = cell->vertex(0)[1];
1961 (
static_cast<float>(cell->level()) /
static_cast<float>(n_levels)) *
1981 point[0] = cell->vertex(1)[0];
1982 point[1] = cell->vertex(1)[1];
2000 point[0] = cell->vertex(2)[0];
2001 point[1] = cell->vertex(2)[1];
2019 if (cell->n_vertices() == 4)
2021 point[0] = cell->vertex(3)[0];
2022 point[1] = cell->vertex(3)[1];
2041 if (
static_cast<unsigned int>(cell->level()) == min_level)
2050 width =
static_cast<unsigned int>(
2052 else if (height == 0)
2053 height =
static_cast<unsigned int>(
2058 static_cast<unsigned int>(.5 + (height / 100.) * 1.75);
2074 .5 + height * .175);
2086 out <<
"<svg width=\"" << width +
additional_width <<
"\" height=\"" << height
2087 <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" <<
'\n'
2094 <<
" <linearGradient id=\"background_gradient\" gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\""
2095 << height <<
"\">" <<
'\n'
2096 <<
" <stop offset=\"0\" style=\"stop-color:white\"/>" <<
'\n'
2097 <<
" <stop offset=\"1\" style=\"stop-color:lightsteelblue\"/>" <<
'\n'
2098 <<
" </linearGradient>" <<
'\n';
2104 out <<
"<!-- internal style sheet -->" <<
'\n'
2105 <<
"<style type=\"text/css\"><![CDATA[" <<
'\n';
2109 out <<
" rect.background{fill:url(#background_gradient)}" <<
'\n';
2111 out <<
" rect.background{fill:white}" <<
'\n';
2113 out <<
" rect.background{fill:none}" <<
'\n';
2116 out <<
" rect{fill:none; stroke:rgb(25,25,25); stroke-width:"
2118 <<
" text{font-family:Helvetica; text-anchor:middle; fill:rgb(25,25,25)}"
2120 <<
" line{stroke:rgb(25,25,25); stroke-width:"
2122 <<
" path{fill:none; stroke:rgb(25,25,25); stroke-width:"
2124 <<
" circle{fill:white; stroke:black; stroke-width:2}" <<
'\n'
2136 for (
unsigned int index = 0; index < n; ++index)
2141 h = .6 - (index / (n - 1.)) * .6;
2149 unsigned int i =
static_cast<unsigned int>(h * 6);
2151 double f = h * 6 - i;
2158 r = 255,
g =
static_cast<unsigned int>(.5 + 255 * t);
2161 r =
static_cast<unsigned int>(.5 + 255 *
q),
g = 255;
2164 g = 255, b =
static_cast<unsigned int>(.5 + 255 * t);
2167 g =
static_cast<unsigned int>(.5 + 255 *
q), b = 255;
2170 r =
static_cast<unsigned int>(.5 + 255 * t), b = 255;
2173 r = 255, b =
static_cast<unsigned int>(.5 + 255 *
q);
2198 <<
',' << b <<
"); "
2199 <<
"stroke:rgb(25,25,25); stroke-width:"
2203 <<
static_cast<unsigned int>(.5 + .75 * r) <<
','
2204 <<
static_cast<unsigned int>(.5 + .75 *
g) <<
','
2205 <<
static_cast<unsigned int>(.5 + .75 * b) <<
"); "
2206 <<
"stroke:rgb(20,20,20); stroke-width:"
2210 <<
',' << b <<
"); "
2211 <<
"stroke:rgb(25,25,25); stroke-width:"
2218 out <<
"]]></style>" <<
'\n' <<
'\n';
2221 out <<
" <rect class=\"background\" width=\"" << width <<
"\" height=\""
2222 << height <<
"\"/>" <<
'\n';
2229 x_offset =
static_cast<unsigned int>(.5 + (height / 100.) *
2232 x_offset =
static_cast<unsigned int>(.5 + height * .025);
2235 <<
" <text x=\"" <<
x_offset <<
"\" y=\""
2236 <<
static_cast<unsigned int>(.5 + height * .0525) <<
'\"'
2237 <<
" style=\"font-weight:100; fill:lightsteelblue; text-anchor:start; font-family:Courier; font-size:"
2238 <<
static_cast<unsigned int>(.5 + height * .045) <<
"px\">"
2240 <<
"</text>" <<
'\n';
2259 out <<
" <!-- cells -->" <<
'\n';
2274 out <<
" class=\"p";
2276 if (!cell->is_active() &&
2283 out << cell->material_id();
2289 if (cell->is_active())
2290 out << cell->subdomain_id() + 2;
2295 out << cell->level_subdomain_id() + 2;
2306 point[0] = cell->vertex(0)[0];
2307 point[1] = cell->vertex(0)[1];
2313 (
static_cast<float>(cell->level()) /
2314 static_cast<float>(n_levels)) *
2331 <<
static_cast<unsigned int>(
2339 point[0] = cell->vertex(1)[0];
2340 point[1] = cell->vertex(1)[1];
2355 <<
static_cast<unsigned int>(
2363 if (cell->n_vertices() == 4)
2365 point[0] = cell->vertex(3)[0];
2366 point[1] = cell->vertex(3)[1];
2381 <<
static_cast<unsigned int>(
2390 point[0] = cell->vertex(2)[0];
2391 point[1] = cell->vertex(2)[1];
2406 <<
static_cast<unsigned int>(
2414 point[0] = cell->vertex(0)[0];
2415 point[1] = cell->vertex(0)[1];
2430 <<
static_cast<unsigned int>(
2436 out <<
"\"/>" <<
'\n';
2443 point[0] = cell->center()[0];
2444 point[1] = cell->center()[1];
2450 (
static_cast<float>(cell->level()) /
2451 static_cast<float>(n_levels)) *
2469 static_cast<unsigned int>(
2476 <<
static_cast<unsigned int>(
2483 <<
static_cast<unsigned int>(
2493 out << cell->level();
2500 out << cell->index();
2509 <<
static_cast<std::make_signed<types::material_id>::type
>(
2510 cell->material_id());
2518 if (cell->is_active())
2520 std::make_signed<types::subdomain_id>::type
>(
2521 cell->subdomain_id());
2534 <<
static_cast<std::make_signed<types::subdomain_id>::type
>(
2535 cell->level_subdomain_id());
2538 out <<
"</text>" <<
'\n';
2545 for (
auto faceIndex : cell->face_indices())
2549 point[0] = cell->face(
faceIndex)->vertex(0)[0];
2550 point[1] = cell->face(
faceIndex)->vertex(0)[1];
2556 (
static_cast<float>(cell->level()) /
2557 static_cast<float>(n_levels)) *
2568 out <<
" <line x1=\""
2569 <<
static_cast<unsigned int>(
2578 <<
static_cast<unsigned int>(
2587 point[0] = cell->face(
faceIndex)->vertex(1)[0];
2588 point[1] = cell->face(
faceIndex)->vertex(1)[1];
2594 (
static_cast<float>(cell->level()) /
2595 static_cast<float>(n_levels)) *
2607 <<
static_cast<unsigned int>(
2616 <<
static_cast<unsigned int>(
2638 static_cast<unsigned int>(
2641 cell->level() - 4. +
2644 point[0] = cell->face(
faceIndex)->center()[0];
2645 point[1] = cell->face(
faceIndex)->center()[1];
2651 (
static_cast<float>(cell->level()) /
2652 static_cast<float>(n_levels)) *
2663 const unsigned int xc =
static_cast<unsigned int>(
2670 const unsigned int yc =
static_cast<unsigned int>(
2677 out <<
" <circle cx=\"" <<
xc <<
"\" cy=\"" <<
yc
2681 out <<
" <text x=\"" <<
xc <<
"\" y=\"" <<
yc
2683 <<
"px\" dominant-baseline=\"middle\">"
2684 <<
static_cast<int>(
2686 <<
"</text>" <<
'\n';
2698 out <<
'\n' <<
" <!-- legend -->" <<
'\n';
2714 <<
static_cast<unsigned int>(.5 + (height / 100.) *
2716 <<
"\" height=\"" <<
static_cast<unsigned int>(.5 + height * .215)
2719 out <<
" <text x=\""
2721 static_cast<unsigned int>(.5 + (height / 100.) * 1.25)
2723 <<
static_cast<unsigned int>(.5 +
2726 <<
"\" style=\"text-anchor:start; font-weight:bold; font-size:"
2729 <<
"</text>" <<
'\n';
2733 out <<
" <text x=\""
2735 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2737 <<
static_cast<unsigned int>(.5 +
2740 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2749 out <<
"</text>" <<
'\n';
2754 out <<
" <text x=\""
2756 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2758 <<
static_cast<unsigned int>(.5 +
2761 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2769 out <<
"</text>" <<
'\n';
2774 out <<
" <text x=\""
2776 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2778 <<
static_cast<unsigned int>(.5 +
2781 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2789 out <<
"</text>" <<
'\n';
2794 out <<
" <text x= \""
2796 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2798 <<
static_cast<unsigned int>(.5 +
2801 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2808 out <<
"</text>" <<
'\n';
2813 out <<
" <text x= \""
2815 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2817 <<
static_cast<unsigned int>(.5 +
2820 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2822 <<
"level_subdomain_id"
2823 <<
"</text>" <<
'\n';
2828 out <<
" <text x=\""
2830 static_cast<unsigned int>(.5 + (height / 100.) * 1.25)
2832 <<
static_cast<unsigned int>(.5 +
2835 <<
"\" style=\"text-anchor:start; font-weight:bold; font-size:"
2838 <<
"</text>" <<
'\n';
2840 out <<
" <text x= \""
2842 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2844 <<
static_cast<unsigned int>(.5 +
2847 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2850 <<
"</text>" <<
'\n';
2859 <<
static_cast<unsigned int>(
2861 <<
"\" style=\"text-anchor:start; font-size:" <<
font_size <<
"px\">"
2870 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
2873 <<
static_cast<unsigned int>(
2876 <<
"\" style=\"text-anchor:start; font-weight:bold; font-size:"
2882 out <<
"material_id";
2885 out <<
"level_number";
2888 out <<
"subdomain_id";
2891 out <<
"level_subdomain_id";
2897 out <<
"</text>" <<
'\n';
2902 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
2910 for (
unsigned int index = 0; index < n; ++index)
2932 <<
static_cast<unsigned int>(.5 + (height / 100.) *
2938 out <<
" <text x=\""
2940 <<
static_cast<unsigned int>(.5 + (height / 100.) *
2943 static_cast<unsigned int>(.5 +
font_size * .35)
2945 <<
" style=\"text-anchor:start; font-size:"
2946 <<
static_cast<unsigned int>(.5 +
font_size) <<
"px";
2948 if (index == 0 || index == n - 1)
2949 out <<
"; font-weight:bold";
2958 out <<
"</text>" <<
'\n';
2966 out <<
'\n' <<
"</svg>";
2982template <
int dim,
int spacedim>
2985 std::ostream & out)
const
2992 const std::time_t
time1 = std::time(
nullptr);
2993 const std::tm * time = std::localtime(&
time1);
2997 <<
"\n# This file was generated by the deal.II library."
2998 <<
"\n# Date = " << time->tm_year + 1900 <<
"/" << std::setfill(
'0')
2999 << std::setw(2) << time->tm_mon + 1 <<
"/" << std::setfill(
'0')
3000 << std::setw(2) << time->tm_mday <<
"\n# Time = " << std::setfill(
'0')
3001 << std::setw(2) << time->tm_hour <<
":" << std::setfill(
'0')
3002 << std::setw(2) << time->tm_min <<
":" << std::setfill(
'0')
3003 << std::setw(2) << time->tm_sec <<
"\n#"
3004 <<
"\n# For a description of the MathGL script format see the MathGL manual. "
3006 <<
"\n# Note: This file is understood by MathGL v2.1 and higher only, and can "
3007 <<
"\n# be quickly viewed in a graphical environment using \'mglview\'. "
3013 const std::string
axes =
"xyz";
3028 out <<
"\nsetsize 800 800";
3029 out <<
"\nrotate 0 0";
3032 out <<
"\nsetsize 800 800";
3033 out <<
"\nrotate 60 40";
3042 <<
"\n# Vertex ordering."
3043 <<
"\n# list <vertex order> <vertex indices>"
3052 out <<
"\nlist f 0 1 2 3" <<
'\n';
3056 <<
"\nlist f 0 2 4 6 | 1 3 5 7 | 0 4 1 5 | 2 6 3 7 | 0 1 2 3 | 4 5 6 7"
3065 <<
"\n# List of vertices."
3066 <<
"\n# list <id> <vertices>"
3072 for (
const auto &cell :
tria.active_cell_iterators())
3074 for (
unsigned int i = 0; i < dim; ++i)
3081 out <<
"\nlist " <<
axes[i] << cell->active_cell_index() <<
" ";
3083 out << cell->vertex(
j)[i] <<
" ";
3090 <<
"\n# List of cells to quadplot."
3091 <<
"\n# quadplot <vertex order> <id> <style>"
3093 for (
unsigned int i = 0; i <
tria.n_active_cells(); ++i)
3095 out <<
"\nquadplot f ";
3096 for (
unsigned int j = 0;
j < dim; ++
j)
3097 out <<
axes[
j] << i <<
" ";
3122 template <
int dim,
int spacedim,
typename ITERATOR,
typename END>
3130 for (; cell != end; ++cell)
3133 patch.reference_cell = cell->reference_cell();
3134 patch.n_subdivisions = 1;
3135 patch.
data.reinit(5, cell->n_vertices());
3139 patch.vertices[v] = cell->vertex(v);
3142 static_cast<std::make_signed<types::manifold_id>::type
>(
3143 cell->manifold_id());
3145 static_cast<std::make_signed<types::material_id>::type
>(
3146 cell->material_id());
3147 if (cell->is_active())
3149 static_cast<std::make_signed<types::subdomain_id>::type
>(
3150 cell->subdomain_id());
3154 static_cast<std::make_signed<types::subdomain_id>::type
>(
3155 cell->level_subdomain_id());
3157 patches.push_back(
patch);
3163 std::vector<std::string>
3166 std::vector<std::string> v(5);
3171 v[4] =
"level_subdomain";
3178 std::vector<typename Triangulation<3, 3>::active_line_iterator>
3181 std::vector<typename Triangulation<3, 3>::active_line_iterator>
res;
3183 std::vector<bool> flags;
3184 tria.save_user_flags_line(flags);
3187 for (
auto face :
tria.active_face_iterators())
3190 const auto line = face->line(l);
3191 if (line->user_flag_set() || line->has_children())
3194 line->set_user_flag();
3195 if (line->at_boundary())
3196 res.emplace_back(line);
3207 template <
int dim,
int spacedim>
3208 std::vector<typename Triangulation<dim, spacedim>::active_line_iterator>
3220 std::vector<typename Triangulation<3, 3>::active_line_iterator>
3223 std::vector<typename Triangulation<3, 3>::active_line_iterator>
res;
3225 std::vector<bool> flags;
3226 tria.save_user_flags_line(flags);
3229 for (
auto face :
tria.active_face_iterators())
3232 const auto line = face->line(l);
3233 if (line->user_flag_set() || line->has_children())
3236 line->set_user_flag();
3238 (line->boundary_id() != 0 &&
3240 res.emplace_back(line);
3250 template <
int dim,
int spacedim>
3251 std::vector<typename Triangulation<dim, spacedim>::active_line_iterator>
3262 template <
int dim,
int spacedim>
3263 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3266 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3270 for (
auto face :
tria.active_face_iterators())
3273 res.push_back(face);
3284 template <
int dim,
int spacedim>
3285 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3288 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3292 for (
auto face :
tria.active_face_iterators())
3295 (face->boundary_id() != 0 &&
3297 res.push_back(face);
3305template <
int dim,
int spacedim>
3308 std::ostream & out)
const
3313 const std::vector<Point<spacedim>> &
vertices =
tria.get_vertices();
3315 const auto n_vertices =
vertices.size();
3317 out <<
"# vtk DataFile Version 3.0\n"
3318 <<
"Triangulation generated with deal.II\n"
3320 <<
"DATASET UNSTRUCTURED_GRID\n"
3321 <<
"POINTS " << n_vertices <<
" double\n";
3327 for (
unsigned int d = spacedim + 1; d <= 3; ++d)
3343 "At least one of the flags (output_cells, output_faces, output_edges) has to be enabled!"));
3359 for (
const auto &cell :
tria.active_cell_iterators())
3363 for (
const auto &face : faces)
3372 out <<
"\nCELLS " << n_cells <<
' ' <<
cells_size <<
'\n';
3388 {1, 3, 5, 9, 10, 14, 13, 12}};
3390 {0, 1, 3, 2, 4, 5, 7, 6}};
3394 for (
const auto &cell :
tria.active_cell_iterators())
3396 out << cell->n_vertices();
3397 for (
const unsigned int i : cell->vertex_indices())
3400 const auto reference_cell = cell->reference_cell();
3410 out << cell->vertex_index(i);
3423 for (
const auto &face : faces)
3425 out << face->n_vertices();
3426 for (
const unsigned int i : face->vertex_indices())
3430 face->n_vertices() ?
3440 for (
const unsigned int i :
edge->vertex_indices())
3441 out <<
' ' <<
edge->vertex_index(i);
3446 out <<
"\nCELL_TYPES " << n_cells <<
'\n';
3449 for (
const auto &cell :
tria.active_cell_iterators())
3456 for (
const auto &face : faces)
3467 out <<
"\n\nCELL_DATA " << n_cells <<
'\n'
3468 <<
"SCALARS MaterialID int 1\n"
3469 <<
"LOOKUP_TABLE default\n";
3474 for (
const auto &cell :
tria.active_cell_iterators())
3477 cell->material_id())
3484 for (
const auto &face : faces)
3487 face->boundary_id())
3497 edge->boundary_id())
3502 out <<
"\n\nSCALARS ManifoldID int 1\n"
3503 <<
"LOOKUP_TABLE default\n";
3508 for (
const auto &cell :
tria.active_cell_iterators())
3511 cell->manifold_id())
3518 for (
const auto &face : faces)
3521 face->manifold_id())
3531 edge->manifold_id())
3544template <
int dim,
int spacedim>
3547 std::ostream & out)
const
3555 std::vector<DataOutBase::Patch<dim, spacedim>> patches;
3556 patches.reserve(
tria.n_active_cells());
3564 std::tuple<
unsigned int,
3572 out <<
" </UnstructuredGrid>\n";
3573 out <<
"<dealiiData encoding=\"base64\">";
3579 out <<
"\n</dealiiData>\n";
3580 out <<
"</VTKFile>\n";
3591template <
int dim,
int spacedim>
3599 std::vector<DataOutBase::Patch<dim, spacedim>> patches;
3600 const unsigned int n_datasets = 4;
3607 const auto reference_cells =
tria.get_reference_cells();
3611 const auto &reference_cell = reference_cells[0];
3613 const unsigned int n_q_points = reference_cell.n_vertices();
3615 for (
const auto &cell :
tria.cell_iterators())
3619 if (cell->has_children())
3627 if (cell->has_children() &&
3630 else if (cell->is_active() &&
3631 cell->level_subdomain_id() ==
3638 patch.
data.reinit(n_datasets, n_q_points);
3639 patch.points_are_available =
false;
3640 patch.reference_cell = reference_cell;
3642 for (
unsigned int vertex = 0; vertex < n_q_points; ++vertex)
3644 patch.vertices[vertex] = cell->vertex(vertex);
3646 if (cell->is_active())
3647 patch.
data(1, vertex) =
static_cast<double>(
3648 static_cast<std::make_signed<types::subdomain_id>::type
>(
3649 cell->subdomain_id()));
3652 patch.
data(2, vertex) =
static_cast<double>(
3653 static_cast<std::make_signed<types::subdomain_id>::type
>(
3654 cell->level_subdomain_id()));
3658 for (
auto f : reference_cell.face_indices())
3660 patches.push_back(
patch);
3675 if (
tr->locally_owned_subdomain() == 0)
3683 if (
pos == std::string::npos)
3687 const unsigned int n_procs =
3689 for (
unsigned int i = 0; i < n_procs; ++i)
3699 data_out.attach_triangulation(*
tr);
3706 data_out.add_data_vector(
dummy_vector,
"level_subdomain");
3707 data_out.add_data_vector(
dummy_vector,
"proc_writing");
3709 data_out.build_patches();
3715 std::ofstream out(
new_file.c_str());
3717 std::tuple<
unsigned int,
3779template <
int dim,
int spacedim>
3784 unsigned int n_faces = 0;
3786 for (
const auto &face :
tria.active_face_iterators())
3787 if ((face->at_boundary()) && (face->boundary_id() != 0))
3795template <
int dim,
int spacedim>
3806 .clear_user_flags_line();
3808 unsigned int n_lines = 0;
3810 for (
const auto &cell :
tria.active_cell_iterators())
3812 if (cell->line(l)->at_boundary() && (cell->line(l)->boundary_id() != 0) &&
3813 (cell->line(l)->user_flag_set() ==
false))
3816 cell->line(l)->set_user_flag();
3832 std::ostream &)
const
3841 std::ostream &)
const
3849 std::ostream &)
const
3858 std::ostream &)
const
3866 std::ostream &)
const
3875 std::ostream &)
const
3884 std::ostream &)
const
3892 std::ostream &)
const
3899template <
int dim,
int spacedim>
3903 std::ostream & out)
const
3907 for (
const auto &face :
tria.active_face_iterators())
3908 if (face->at_boundary() && (face->boundary_id() != 0))
3911 << face->reference_cell().gmsh_element_type() <<
' ';
3913 <<
static_cast<unsigned int>(face->boundary_id()) <<
' '
3914 << face->n_vertices();
3916 for (
const unsigned int vertex : face->vertex_indices())
3920 << face->vertex_index(
3925 out <<
' ' << face->vertex_index(vertex) + 1;
3938template <
int dim,
int spacedim>
3942 std::ostream & out)
const
3953 .clear_user_flags_line();
3955 for (
const auto &cell :
tria.active_cell_iterators())
3957 if (cell->line(l)->at_boundary() && (cell->line(l)->boundary_id() != 0) &&
3958 (cell->line(l)->user_flag_set() ==
false))
3963 <<
static_cast<unsigned int>(cell->line(l)->boundary_id())
3966 for (
unsigned int vertex = 0; vertex < 2; ++vertex)
3968 << cell->line(l)->vertex_index(
3977 cell->line(l)->set_user_flag();
3993 std::ostream &)
const
4001 std::ostream &)
const
4009 std::ostream &)
const
4017 std::ostream &)
const
4025 std::ostream &)
const
4034 std::ostream &)
const
4043 std::ostream &)
const
4051 std::ostream &)
const
4058template <
int dim,
int spacedim>
4062 std::ostream & out)
const
4067 for (
const auto &face :
tria.active_face_iterators())
4068 if (face->at_boundary() && (face->boundary_id() != 0))
4071 <<
static_cast<unsigned int>(face->boundary_id()) <<
" ";
4084 for (
unsigned int vertex = 0;
4087 out << face->vertex_index(
4100template <
int dim,
int spacedim>
4104 std::ostream & out)
const
4115 .clear_user_flags_line();
4117 for (
const auto &cell :
tria.active_cell_iterators())
4119 if (cell->line(l)->at_boundary() && (cell->line(l)->boundary_id() != 0) &&
4120 (cell->line(l)->user_flag_set() ==
false))
4123 <<
static_cast<unsigned int>(cell->line(l)->boundary_id())
4126 for (
unsigned int vertex = 0; vertex < 2; ++vertex)
4127 out << cell->line(l)->vertex_index(
4137 cell->line(l)->set_user_flag();
4161 template <
int spacedim>
4165 while (points.size() > 2)
4173 points.erase(points.begin() + 1);
4181 template <
int spacedim>
4190 for (
const auto &cell :
tria.active_cell_iterators())
4193 out <<
"# cell " << cell <<
'\n';
4195 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4196 << cell->material_id() <<
'\n'
4197 << cell->vertex(1) <<
' ' << cell->level() <<
' '
4198 << cell->material_id() <<
'\n'
4211 template <
int spacedim>
4229 std::vector<
Point<dim - 1>> boundary_points;
4230 if (mapping !=
nullptr)
4232 boundary_points.resize(n_points);
4233 boundary_points[0][0] = 0;
4234 boundary_points[n_points - 1][0] = 1;
4235 for (
unsigned int i = 1; i < n_points - 1; ++i)
4236 boundary_points[i](0) = 1. * i / (n_points - 1);
4242 ReferenceCells::get_hypercube<dim>(), quadrature);
4246 {0, 1, 5, 4, 2, 3, 7, 6}};
4247 for (
const auto &cell :
tria.active_cell_iterators())
4250 out <<
"# cell " << cell <<
'\n';
4252 if (mapping ==
nullptr ||
4263 out << cell->vertex(dim == 3 ?
4268 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4269 << cell->material_id() <<
'\n'
4277 for (
const unsigned int face_no :
4280 const typename ::Triangulation<dim,
4281 spacedim>::face_iterator
4283 if (dim != spacedim || face->at_boundary() ||
4292 const unsigned int offset =
face_no * n_points;
4293 for (
unsigned int i = 0; i < n_points; ++i)
4295 mapping->transform_unit_to_real_cell(
4303 out <<
'\n' <<
'\n';
4309 out << face->vertex(0) <<
' ' << cell->level() <<
' '
4310 << cell->material_id() <<
'\n'
4311 << face->vertex(1) <<
' ' << cell->level() <<
' '
4312 << cell->material_id() <<
'\n'
4328 template <
int spacedim>
4346 std::vector<Point<1>> boundary_points;
4347 if (mapping !=
nullptr)
4349 boundary_points.resize(n_points);
4350 boundary_points[0][0] = 0;
4351 boundary_points[n_points - 1][0] = 1;
4352 for (
unsigned int i = 1; i < n_points - 1; ++i)
4353 boundary_points[i](0) = 1. * i / (n_points - 1);
4362 ReferenceCells::get_hypercube<dim>(), quadrature));
4365 for (
const auto &cell :
tria.active_cell_iterators())
4368 out <<
"# cell " << cell <<
'\n';
4370 if (mapping ==
nullptr || n_points == 2 ||
4371 (!cell->has_boundary_lines() &&
4377 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4378 << cell->material_id() <<
'\n'
4379 << cell->vertex(1) <<
' ' << cell->level() <<
' '
4380 << cell->material_id() <<
'\n'
4381 << cell->vertex(5) <<
' ' << cell->level() <<
' '
4382 << cell->material_id() <<
'\n'
4383 << cell->vertex(4) <<
' ' << cell->level() <<
' '
4384 << cell->material_id() <<
'\n'
4385 << cell->vertex(0) <<
' ' << cell->level() <<
' '
4386 << cell->material_id() <<
'\n'
4389 out << cell->vertex(2) <<
' ' << cell->level() <<
' '
4390 << cell->material_id() <<
'\n'
4391 << cell->vertex(3) <<
' ' << cell->level() <<
' '
4392 << cell->material_id() <<
'\n'
4393 << cell->vertex(7) <<
' ' << cell->level() <<
' '
4394 << cell->material_id() <<
'\n'
4395 << cell->vertex(6) <<
' ' << cell->level() <<
' '
4396 << cell->material_id() <<
'\n'
4397 << cell->vertex(2) <<
' ' << cell->level() <<
' '
4398 << cell->material_id() <<
'\n'
4402 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4403 << cell->material_id() <<
'\n'
4404 << cell->vertex(2) <<
' ' << cell->level() <<
' '
4405 << cell->material_id() <<
'\n'
4407 out << cell->vertex(1) <<
' ' << cell->level() <<
' '
4408 << cell->material_id() <<
'\n'
4409 << cell->vertex(3) <<
' ' << cell->level() <<
' '
4410 << cell->material_id() <<
'\n'
4412 out << cell->vertex(5) <<
' ' << cell->level() <<
' '
4413 << cell->material_id() <<
'\n'
4414 << cell->vertex(7) <<
' ' << cell->level() <<
' '
4415 << cell->material_id() <<
'\n'
4417 out << cell->vertex(4) <<
' ' << cell->level() <<
' '
4418 << cell->material_id() <<
'\n'
4419 << cell->vertex(6) <<
' ' << cell->level() <<
' '
4420 << cell->material_id() <<
'\n'
4426 for (
const unsigned int v : {0, 1, 2, 0, 3, 2})
4428 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4429 << cell->material_id() <<
'\n';
4433 for (
const unsigned int v : {3, 1})
4435 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4436 << cell->material_id() <<
'\n';
4447 for (
const unsigned int v : {0, 1, 2, 0, 3, 4, 5, 3})
4449 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4450 << cell->material_id() <<
'\n';
4454 for (
const unsigned int v : {1, 4})
4456 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4457 << cell->material_id() <<
'\n';
4461 for (
const unsigned int v : {2, 5})
4463 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4464 << cell->material_id() <<
'\n';
4471 for (
const unsigned int v : {0, 1, 3, 2, 0, 4, 1})
4473 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4474 << cell->material_id() <<
'\n';
4478 for (
const unsigned int v : {2, 4, 3})
4480 out << cell->vertex(v) <<
' ' << cell->level() <<
' '
4481 << cell->material_id() <<
'\n';
4492 for (
const unsigned int face_no :
4495 const typename ::Triangulation<dim,
4496 spacedim>::face_iterator
4499 if (face->at_boundary() &&
4502 const unsigned int offset =
face_no * n_points * n_points;
4503 for (
unsigned int i = 0; i < n_points - 1; ++i)
4504 for (
unsigned int j = 0;
j < n_points - 1; ++
j)
4507 mapping->transform_unit_to_real_cell(
4510 out <<
p0 <<
' ' << cell->level() <<
' '
4511 << cell->material_id() <<
'\n';
4512 out << (mapping->transform_unit_to_real_cell(
4515 offset + (i + 1) * n_points +
j)))
4516 <<
' ' << cell->level() <<
' '
4517 << cell->material_id() <<
'\n';
4518 out << (mapping->transform_unit_to_real_cell(
4521 offset + (i + 1) * n_points +
j + 1)))
4522 <<
' ' << cell->level() <<
' '
4523 << cell->material_id() <<
'\n';
4524 out << (mapping->transform_unit_to_real_cell(
4528 <<
' ' << cell->level() <<
' '
4529 << cell->material_id() <<
'\n';
4531 out <<
p0 <<
' ' << cell->level() <<
' '
4532 << cell->material_id() <<
'\n';
4533 out <<
'\n' <<
'\n';
4538 for (
unsigned int l = 0;
4542 const typename ::Triangulation<dim, spacedim>
::
4546 &
v1 = line->vertex(1);
4547 if (line->at_boundary() ||
4558 u0 = mapping->transform_real_to_unit_cell(cell,
4560 u1 = mapping->transform_real_to_unit_cell(cell,
4562 for (
unsigned int i = 0; i < n_points; ++i)
4564 mapping->transform_unit_to_real_cell(
4566 (1 - boundary_points[i][0]) *
u0 +
4567 boundary_points[i][0] *
u1));
4576 out <<
v0 <<
' ' << cell->level() <<
' '
4577 << cell->material_id() <<
'\n'
4578 <<
v1 <<
' ' << cell->level() <<
' '
4579 << cell->material_id() <<
'\n';
4581 out <<
'\n' <<
'\n';
4598template <
int dim,
int spacedim>
4622 const unsigned int l)
4673 template <
int dim,
int spacedim>
4681 using LineList = std::list<LineEntry>;
4696 const unsigned int n_points =
eps_flags_base.n_boundary_face_points;
4721 for (
const auto &cell :
tria.active_cell_iterators())
4724 typename ::Triangulation<dim, spacedim>::line_iterator
4737 if (!line->has_children() &&
4738 (mapping ==
nullptr || !line->at_boundary()))
4759 Point<2>(line->vertex(0)(0), line->vertex(0)(1)),
4760 Point<2>(line->vertex(1)(0), line->vertex(1)(1)),
4761 line->user_flag_set(),
4771 if (mapping !=
nullptr)
4778 std::vector<
Point<dim - 1>> boundary_points(n_points);
4780 for (
unsigned int i = 0; i < n_points; ++i)
4781 boundary_points[i](0) = 1. * (i + 1) / (n_points + 1);
4783 Quadrature<dim - 1> quadrature(boundary_points);
4786 ReferenceCells::get_hypercube<dim>(), quadrature));
4792 for (
const auto &cell :
tria.active_cell_iterators())
4796 const typename ::Triangulation<dim, spacedim>
::
4799 if (face->at_boundary())
4809 const unsigned int offset =
face_no * n_points;
4810 for (
unsigned int i = 0; i < n_points; ++i)
4813 mapping->transform_unit_to_real_cell(
4819 face->user_flag_set(),
4829 face->user_flag_set(),
4863 const double z_angle = eps_flags_3.azimut_angle;
4864 const double turn_angle = eps_flags_3.turn_angle;
4892 for (
const auto &cell :
tria.active_cell_iterators())
4895 typename ::Triangulation<dim, spacedim>::line_iterator
4902 line->user_flag_set(),
4918 double x_min =
tria.begin_active()->vertex(0)(0);
4920 double y_min =
tria.begin_active()->vertex(0)(1);
4940 max_level =
std::max(max_level, line->level);
4948 const double scale =
4960 std::time_t
time1 = std::time(
nullptr);
4961 std::tm * time = std::localtime(&
time1);
4962 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4963 <<
"%%Title: deal.II Output" <<
'\n'
4964 <<
"%%Creator: the deal.II library" <<
'\n'
4965 <<
"%%Creation Date: " << time->tm_year + 1900 <<
"/"
4966 << time->tm_mon + 1 <<
"/" << time->tm_mday <<
" - "
4967 << time->tm_hour <<
":" << std::setw(2) << time->tm_min <<
":"
4968 << std::setw(2) << time->tm_sec <<
'\n'
4969 <<
"%%BoundingBox: "
4973 <<
static_cast<unsigned int>(
4976 <<
static_cast<unsigned int>(
4986 out <<
"/m {moveto} bind def" <<
'\n'
4987 <<
"/x {lineto stroke} bind def" <<
'\n'
4988 <<
"/b {0 0 0 setrgbcolor} def" <<
'\n'
4989 <<
"/r {1 0 0 setrgbcolor} def" <<
'\n';
4996 out <<
"/l { neg " << (max_level) <<
" add "
4997 << (0.66666 /
std::max(1U, (max_level - 1)))
4998 <<
" mul 1 0.8 sethsbcolor} def" <<
'\n';
5008 if ((dim == 2) && (eps_flags_2.write_cell_numbers ||
5009 eps_flags_2.write_vertex_numbers))
5012 << (
"/R {rmoveto} bind def\n"
5013 "/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont\n"
5014 "dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall\n"
5015 "currentdict end definefont\n"
5016 "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n"
5017 "[ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n"
5018 "{show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n"
5019 "{2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n"
5020 "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n"
5021 "5 get stringwidth pop add}\n"
5022 "{pop} ifelse} forall} bind def\n"
5023 "/MCshow { currentpoint stroke m\n"
5024 "exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n")
5028 out <<
"%%EndProlog" <<
'\n' <<
'\n';
5041 out << line->level <<
" l " << (line->first - offset) *
scale <<
" m "
5042 << (line->second - offset) * scale <<
" x" <<
'\n';
5044 out << ((line->colorize &&
eps_flags_base.color_lines_on_user_flag) ?
5048 << (line->
second - offset) *
scale <<
" x" <<
'\n';
5052 if ((dim == 2) && (eps_flags_2.write_cell_numbers ==
true))
5054 out <<
"(Helvetica) findfont 140 scalefont setfont" <<
'\n';
5056 for (
const auto &cell :
tria.active_cell_iterators())
5058 out << (cell->center()(0) - offset(0)) * scale <<
' '
5059 << (cell->center()(1) - offset(1)) * scale <<
" m" <<
'\n'
5060 <<
"[ [(Helvetica) 12.0 0.0 true true (";
5061 if (eps_flags_2.write_cell_number_level)
5064 out << cell->index();
5067 <<
"] -6 MCshow" <<
'\n';
5072 if ((dim == 2) && (eps_flags_2.write_vertex_numbers ==
true))
5074 out <<
"(Helvetica) findfont 140 scalefont setfont" <<
'\n';
5081 for (
const auto &cell :
tria.active_cell_iterators())
5088 out << (cell->vertex(
vertex_no)(0) - offset(0)) * scale <<
' '
5089 << (cell->vertex(
vertex_no)(1) - offset(1)) * scale
5091 <<
"[ [(Helvetica) 10.0 0.0 true true ("
5092 << cell->vertex_index(
vertex_no) <<
")] "
5093 <<
"] -6 MCshow" <<
'\n';
5097 out <<
"showpage" <<
'\n';
5109template <
int dim,
int spacedim>
5119template <
int dim,
int spacedim>
5176template <
int dim,
int spacedim>
5187#include "grid_out.inst"
value_type * data() const noexcept
const ElementType * const_iterator
unsigned int n_boundary_faces(const Triangulation< dim, spacedim > &tria) const
GridOutFlags::Vtu vtu_flags
GridOutFlags::Eps< 2 > eps_flags_2
unsigned int write_ucd_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
void parse_parameters(ParameterHandler ¶m)
void write_svg(const Triangulation< 2, 2 > &tria, std::ostream &out) const
void set_flags(const GridOutFlags::DX &flags)
GridOutFlags::Eps< 1 > eps_flags_1
GridOutFlags::XFig xfig_flags
unsigned int write_ucd_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
void write_mathgl(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
std::string default_suffix() const
static void declare_parameters(ParameterHandler ¶m)
static OutputFormat parse_output_format(const std::string &format_name)
void write_vtk(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
GridOutFlags::Gnuplot gnuplot_flags
void write_msh(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
unsigned int write_msh_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
void write_eps(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
static std::string get_output_format_names()
GridOutFlags::Eps< 3 > eps_flags_3
void write(const Triangulation< dim, spacedim > &tria, std::ostream &out, const OutputFormat output_format, const Mapping< dim, spacedim > *mapping=nullptr) const
void write_vtu(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
GridOutFlags::Ucd ucd_flags
void write_dx(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
std::size_t memory_consumption() const
unsigned int n_boundary_lines(const Triangulation< dim, spacedim > &tria) const
GridOutFlags::DX dx_flags
unsigned int write_msh_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
void write_ucd(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
GridOutFlags::Svg svg_flags
OutputFormat default_format
void write_xfig(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
void write_gnuplot(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
GridOutFlags::Vtk vtk_flags
GridOutFlags::Msh msh_flags
void write_mesh_per_processor_as_vtu(const Triangulation< dim, spacedim > &tria, const std::string &filename_without_extension, const bool view_levels=false, const bool include_artificial=false) const
@ vtk
write() calls write_vtk()
@ eps
write() calls write_eps()
@ msh
write() calls write_msh()
@ xfig
write() calls write_xfig()
@ dx
write() calls write_dx()
@ ucd
write() calls write_ucd()
@ gnuplot
write() calls write_gnuplot()
@ mathgl
write() calls write_mathgl()
@ svg
write() calls write_svg()
@ none
Do nothing in write()
@ vtu
write() calls write_vtu()
GridOutFlags::MathGL mathgl_flags
static Quadrature< dim > project_to_all_faces(const ReferenceCell &reference_cell, const hp::QCollection< dim - 1 > &quadrature)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcInvalidState()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
DataComponentInterpretation
void write_eps(const std::vector< Patch< 2, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const EpsFlags &flags, std::ostream &out)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
void write_vtu(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_vtu_main(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_vtu_footer(std::ostream &out)
void write_gnuplot(const std::vector< Patch< dim, spacedim > > &patches, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > &nonscalar_data_ranges, const GnuplotFlags &flags, std::ostream &out)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
constexpr const ReferenceCell Tetrahedron
constexpr const ReferenceCell Quadrilateral
constexpr const ReferenceCell Wedge
constexpr const ReferenceCell Pyramid
constexpr const ReferenceCell Triangle
constexpr const ReferenceCell Hexahedron
constexpr const ReferenceCell Vertex
constexpr const ReferenceCell Line
VectorType::value_type * end(VectorType &V)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
std::string encode_base64(const std::vector< unsigned char > &binary_input)
std::string compress(const std::string &input)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
const types::boundary_id invalid_boundary_id
static constexpr double PI
const types::boundary_id internal_face_boundary_id
const types::subdomain_id artificial_subdomain_id
static const unsigned int invalid_unsigned_int
const types::manifold_id flat_manifold_id
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
static void declare_parameters(ParameterHandler &prm)
void parse_parameters(const ParameterHandler &prm)
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > face_indices()
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()
static void declare_parameters(ParameterHandler ¶m)
void parse_parameters(ParameterHandler ¶m)
DX(const bool write_cells=true, const bool write_faces=false, const bool write_diameter=false, const bool write_measure=false, const bool write_all_faces=true)
static void declare_parameters(ParameterHandler ¶m)
bool color_lines_on_user_flag
unsigned int n_boundary_face_points
void parse_parameters(ParameterHandler ¶m)
EpsFlagsBase(const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const bool color_lines_on_user_flag=false, const unsigned int n_boundary_face_points=2, const bool color_lines_level=false)
void parse_parameters(ParameterHandler ¶m)
void parse_parameters(ParameterHandler ¶m)
void parse_parameters(ParameterHandler ¶m)
unsigned int n_extra_curved_line_points
void parse_parameters(ParameterHandler ¶m)
Gnuplot(const bool write_cell_number=false, const unsigned int n_extra_curved_line_points=2, const bool curved_inner_cells=false, const bool write_additional_boundary_lines=true)
static void declare_parameters(ParameterHandler ¶m)
bool write_additional_boundary_lines
void parse_parameters(ParameterHandler ¶m)
static void declare_parameters(ParameterHandler ¶m)
Msh(const bool write_faces=false, const bool write_lines=false)
void parse_parameters(ParameterHandler ¶m)
static void declare_parameters(ParameterHandler ¶m)
bool label_level_subdomain_id
unsigned int line_thickness
bool convert_level_number_to_height
Svg(const unsigned int line_thickness=2, const unsigned int boundary_line_thickness=4, const bool margin=true, const Background background=white, const int azimuth_angle=0, const int polar_angle=0, const Coloring coloring=level_number, const bool convert_level_number_to_height=false, const bool label_level_number=false, const bool label_cell_index=false, const bool label_material_id=false, const bool label_subdomain_id=false, const bool draw_colorbar=false, const bool draw_legend=false, const bool label_boundary_id=false)
@ level_subdomain_id
Convert the level subdomain id into the cell color.
@ subdomain_id
Convert the subdomain id into the cell color.
@ material_id
Convert the material id into the cell color (default)
@ level_number
Convert the level number into the cell color.
unsigned int boundary_line_thickness
float level_height_factor
Ucd(const bool write_preamble=false, const bool write_faces=false, const bool write_lines=false)
static void declare_parameters(ParameterHandler ¶m)
void parse_parameters(ParameterHandler ¶m)
bool output_only_relevant
bool serialize_triangulation
unsigned int n_boundary_face_points
@ level_number
Convert the level into the cell color.
@ material_id
Convert the material id into the cell color.
@ level_subdomain_id
Convert the level subdomain id into the cell color.
@ subdomain_id
Convert the global subdomain id into the cell color.
void parse_parameters(ParameterHandler ¶m)
static void declare_parameters(ParameterHandler ¶m)
enum GridOutFlags::XFig::Coloring color_by
const ::Triangulation< dim, spacedim > & tria