32#include <boost/algorithm/string.hpp>
33#include <boost/archive/binary_oarchive.hpp>
35#ifdef DEAL_II_GMSH_WITH_API
54 const bool write_faces,
55 const bool write_diameter,
56 const bool write_measure,
57 const bool write_all_faces)
59 , write_faces(write_faces)
60 , write_diameter(write_diameter)
61 , write_measure(write_measure)
62 , write_all_faces(write_all_faces)
71 "Write the mesh connectivity as DX grid cells");
75 "Write faces of cells. These may be boundary faces "
76 "or all faces between mesh cells, according to "
77 "\"Write all faces\"");
81 "If cells are written, additionally write their"
82 " diameter as data for visualization");
86 "Write the volume of each cell as data");
90 "Write all faces, not only boundary");
104 Msh::Msh(
const bool write_faces,
const bool write_lines)
105 : write_faces(write_faces)
106 , write_lines(write_lines)
126 const bool write_faces,
127 const bool write_lines)
128 : write_preamble(write_preamble)
129 , write_faces(write_faces)
130 , write_lines(write_lines)
155 const unsigned int n_extra_curved_line_points,
156 const bool curved_inner_cells,
157 const bool write_additional_boundary_lines)
158 : write_cell_numbers(write_cell_numbers)
159 , n_extra_curved_line_points(n_extra_curved_line_points)
160 , curved_inner_cells(curved_inner_cells)
161 , write_additional_boundary_lines(write_additional_boundary_lines)
183 const unsigned int size,
184 const double line_width,
185 const bool color_lines_on_user_flag,
186 const unsigned int n_boundary_face_points,
187 const bool color_lines_level)
190 , line_width(line_width)
191 , color_lines_on_user_flag(color_lines_on_user_flag)
192 , n_boundary_face_points(n_boundary_face_points)
193 , color_lines_level(color_lines_level)
203 "Depending on this parameter, either the "
205 "of the eps is scaled to \"Size\"");
209 "Size of the output in points");
213 "Width of the lines drawn in points");
217 "Draw lines with user flag set in different color");
221 "Number of points on boundary edges. "
222 "Increase this beyond 2 to see curved boundaries.");
226 "Draw different colors according to grid level.");
233 if (param.
get(
"Size by") == std::string(
"width"))
235 else if (param.
get(
"Size by") == std::string(
"height"))
247 const unsigned int size,
248 const double line_width,
249 const bool color_lines_on_user_flag,
250 const unsigned int n_boundary_face_points)
254 color_lines_on_user_flag,
255 n_boundary_face_points)
273 const unsigned int size,
274 const double line_width,
275 const bool color_lines_on_user_flag,
276 const unsigned int n_boundary_face_points,
277 const bool write_cell_numbers,
278 const bool write_cell_number_level,
279 const bool write_vertex_numbers,
280 const bool color_lines_level)
284 color_lines_on_user_flag,
285 n_boundary_face_points,
287 , write_cell_numbers(write_cell_numbers)
288 , write_cell_number_level(write_cell_number_level)
289 , write_vertex_numbers(write_vertex_numbers)
299 "(2D only) Write cell numbers"
300 " into the centers of cells");
304 "(2D only) if \"Cell number\" is true, write "
305 "numbers in the form level.number");
309 "Write numbers for each vertex");
317 write_cell_numbers = param.
get_bool(
"Cell number");
318 write_cell_number_level = param.
get_bool(
"Level number");
319 write_vertex_numbers = param.
get_bool(
"Vertex number");
325 const unsigned int size,
326 const double line_width,
327 const bool color_lines_on_user_flag,
328 const unsigned int n_boundary_face_points,
329 const double azimut_angle,
330 const double turn_angle)
334 color_lines_on_user_flag,
335 n_boundary_face_points)
336 , azimut_angle(azimut_angle)
337 , turn_angle(turn_angle)
347 "Azimuth of the viw point, that is, the angle "
348 "in the plane from the x-axis.");
352 "Elevation of the view point above the xy-plane.");
360 azimut_angle = 90 - param.
get_double(
"Elevation");
367 : draw_boundary(true)
370 , n_boundary_face_points(0)
376 , boundary_thickness(3)
410 const unsigned int boundary_line_thickness,
413 const int azimuth_angle,
414 const int polar_angle,
416 const bool convert_level_number_to_height,
417 const bool label_level_number,
418 const bool label_cell_index,
419 const bool label_material_id,
420 const bool label_subdomain_id,
421 const bool draw_colorbar,
422 const bool draw_legend,
423 const bool label_boundary_id)
426 , line_thickness(line_thickness)
427 , boundary_line_thickness(boundary_line_thickness)
429 , background(background)
430 , azimuth_angle(azimuth_angle)
431 , polar_angle(polar_angle)
433 , convert_level_number_to_height(convert_level_number_to_height)
434 , level_height_factor(0.3f)
435 , cell_font_scaling(1.f)
436 , label_level_number(label_level_number)
437 , label_cell_index(label_cell_index)
438 , label_material_id(label_material_id)
439 , label_subdomain_id(label_subdomain_id)
440 , label_level_subdomain_id(false)
441 , label_boundary_id(label_boundary_id)
442 , draw_colorbar(draw_colorbar)
443 , draw_legend(draw_legend)
447 : draw_bounding_box(false)
560 switch (output_format)
603 if (format_name ==
"none" || format_name ==
"false")
606 if (format_name ==
"dx")
609 if (format_name ==
"ucd")
612 if (format_name ==
"gnuplot")
615 if (format_name ==
"eps")
618 if (format_name ==
"xfig")
621 if (format_name ==
"msh")
624 if (format_name ==
"svg")
627 if (format_name ==
"mathgl")
630 if (format_name ==
"vtk")
633 if (format_name ==
"vtu")
646 return "none|dx|gnuplot|eps|ucd|xfig|msh|svg|mathgl|vtk|vtu";
779template <
int dim,
int spacedim>
782 std::ostream & out)
const
798 std::vector<unsigned int> renumber(
vertices.size());
801 unsigned int new_number = 0;
802 for (
unsigned int i = 0; i <
vertices.size(); ++i)
804 renumber[i] = new_number++;
808 out <<
"object \"vertices\" class array type float rank 1 shape " << dim
809 <<
" items " << n_vertices <<
" data follows" <<
'\n';
811 for (
unsigned int i = 0; i <
vertices.size(); ++i)
820 const unsigned int n_faces =
828 out <<
"object \"cells\" class array type int rank 1 shape "
829 << n_vertices_per_cell <<
" items " <<
n_cells <<
" data follows"
840 out <<
"attribute \"element type\" string \"";
848 <<
"attribute \"ref\" string \"positions\"" <<
'\n'
853 out <<
"object \"material\" class array type int rank 0 items " <<
n_cells
854 <<
" data follows" <<
'\n';
856 out <<
' ' << cell->material_id();
857 out <<
'\n' <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
859 out <<
"object \"level\" class array type int rank 0 items " <<
n_cells
860 <<
" data follows" <<
'\n';
862 out <<
' ' << cell->level();
863 out <<
'\n' <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
867 out <<
"object \"measure\" class array type float rank 0 items "
868 <<
n_cells <<
" data follows" <<
'\n';
870 out <<
'\t' << cell->measure();
872 <<
"attribute \"dep\" string \"connections\"" <<
'\n'
878 out <<
"object \"diameter\" class array type float rank 0 items "
879 <<
n_cells <<
" data follows" <<
'\n';
881 out <<
'\t' << cell->diameter();
883 <<
"attribute \"dep\" string \"connections\"" <<
'\n'
890 out <<
"object \"faces\" class array type int rank 1 shape "
891 << n_vertices_per_face <<
" items " << n_faces <<
" data follows"
896 for (
const unsigned int f : cell->face_indices())
901 for (
unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_face;
904 << renumber[face->vertex_index(
909 out <<
"attribute \"element type\" string \"";
915 <<
"attribute \"ref\" string \"positions\"" <<
'\n'
921 out <<
"object \"boundary\" class array type int rank 0 items " << n_faces
922 <<
" data follows" <<
'\n';
929 <<
static_cast<std::make_signed<types::boundary_id>::type
>(
930 cell->face(f)->boundary_id());
934 out <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
938 out <<
"object \"face measure\" class array type float rank 0 items "
939 << n_faces <<
" data follows" <<
'\n';
943 out <<
' ' << cell->face(f)->measure();
946 out <<
"attribute \"dep\" string \"connections\"" <<
'\n' <<
'\n';
951 out <<
"object \"face diameter\" class array type float rank 0 items "
952 << n_faces <<
" data follows" <<
'\n';
956 out <<
' ' << cell->face(f)->diameter();
959 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
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'
1104 unsigned int elm_type;
1124 out << cell->active_cell_index() + 1 <<
' ' << elm_type <<
' '
1125 << cell->material_id() <<
' ' << cell->subdomain_id() <<
' '
1126 << cell->n_vertices() <<
' ';
1147 out <<
"@f$ENDELM\n";
1157template <
int dim,
int spacedim>
1160 std::ostream & out)
const
1178 std::time_t time1 = std::time(
nullptr);
1179 std::tm * time = std::localtime(&time1);
1181 <<
"# This file was generated by the deal.II library." <<
'\n'
1182 <<
"# Date = " << time->tm_year + 1900 <<
"/" << time->tm_mon + 1
1183 <<
"/" << time->tm_mday <<
'\n'
1184 <<
"# Time = " << time->tm_hour <<
":" << std::setw(2) << time->tm_min
1185 <<
":" << std::setw(2) << time->tm_sec <<
'\n'
1187 <<
"# For a description of the UCD format see the AVS Developer's guide."
1193 out << n_vertices <<
' '
1203 for (
unsigned int i = 0; i <
vertices.size(); ++i)
1208 for (
unsigned int d = spacedim + 1;
d <= 3; ++
d)
1217 out << cell->active_cell_index() + 1 <<
' ' << cell->material_id() <<
' ';
1274template <
int dim,
int spacedim>
1292 const int spacedim = 2;
1298 out <<
"#FIG 3.2\nLandscape\nCenter\nInches" << std::endl
1299 <<
"A4\n100.00\nSingle"
1302 <<
"-3" << std::endl
1303 <<
"# generated by deal.II GridOut class" << std::endl
1304 <<
"# reduce first number to scale up image" << std::endl
1305 <<
"1200 2" << std::endl;
1308 unsigned int colno = 32;
1309 out <<
"0 " << colno++ <<
" #ff0000" << std::endl;
1310 out <<
"0 " << colno++ <<
" #ff8000" << std::endl;
1311 out <<
"0 " << colno++ <<
" #ffd000" << std::endl;
1312 out <<
"0 " << colno++ <<
" #ffff00" << std::endl;
1313 out <<
"0 " << colno++ <<
" #c0ff00" << std::endl;
1314 out <<
"0 " << colno++ <<
" #80ff00" << std::endl;
1315 out <<
"0 " << colno++ <<
" #00f000" << std::endl;
1316 out <<
"0 " << colno++ <<
" #00f0c0" << std::endl;
1317 out <<
"0 " << colno++ <<
" #00f0ff" << std::endl;
1318 out <<
"0 " << colno++ <<
" #00c0ff" << std::endl;
1319 out <<
"0 " << colno++ <<
" #0080ff" << std::endl;
1320 out <<
"0 " << colno++ <<
" #0040ff" << std::endl;
1321 out <<
"0 " << colno++ <<
" #0000c0" << std::endl;
1322 out <<
"0 " << colno++ <<
" #5000ff" << std::endl;
1323 out <<
"0 " << colno++ <<
" #8000ff" << std::endl;
1324 out <<
"0 " << colno++ <<
" #b000ff" << std::endl;
1325 out <<
"0 " << colno++ <<
" #ff00ff" << std::endl;
1326 out <<
"0 " << colno++ <<
" #ff80ff" << std::endl;
1328 for (
unsigned int i = 0; i < 8; ++i)
1329 out <<
"0 " << colno++ <<
" #" << std::hex << 32 * i + 31 << 32 * i + 31
1330 << 32 * i + 31 << std::dec << std::endl;
1332 for (
unsigned int i = 1; i < 16; ++i)
1333 out <<
"0 " << colno++ <<
" #00" << std::hex << 16 * i + 15 << std::dec
1334 <<
"00" << std::endl;
1336 for (
unsigned int i = 1; i < 16; ++i)
1337 out <<
"0 " << colno++ <<
" #" << std::hex << 16 * i + 15 << 16 * i + 15
1338 << std::dec <<
"00" << std::endl;
1340 for (
unsigned int i = 1; i < 16; ++i)
1341 out <<
"0 " << colno++ <<
" #" << std::hex << 16 * i + 15 << std::dec
1342 <<
"0000" << std::endl;
1344 for (
unsigned int i = 1; i < 16; ++i)
1345 out <<
"0 " << colno++ <<
" #" << std::hex << 16 * i + 15 <<
"00"
1346 << 16 * i + 15 << std::dec << std::endl;
1348 for (
unsigned int i = 1; i < 16; ++i)
1349 out <<
"0 " << colno++ <<
" #0000" << std::hex << 16 * i + 15 << std::dec
1352 for (
unsigned int i = 1; i < 16; ++i)
1353 out <<
"0 " << colno++ <<
" #00" << std::hex << 16 * i + 15 << 16 * i + 15
1354 << std::dec << std::endl;
1376 out << cell->material_id() + 32;
1379 out << cell->level() + 8;
1382 out << cell->subdomain_id() + 32;
1385 out << cell->level_subdomain_id() + 32;
1394 (900 + cell->material_id()))
1400 << nv + 1 << std::endl;
1406 for (
unsigned int k = 0; k <= nv; ++k)
1410 for (
unsigned int d = 0; d < static_cast<unsigned int>(dim); ++
d)
1414 out <<
'\t' << ((
d == 0) ? val : -val);
1419 static const unsigned int face_reorder[4] = {2, 1, 3, 0};
1421 for (
const unsigned int f : face_reorder)
1449 for (
unsigned int k = 0;
1450 k < GeometryInfo<dim>::vertices_per_face;
1454 for (
unsigned int d = 0; d < static_cast<unsigned int>(dim);
1460 out <<
'\t' << ((
d == 0) ? val : -val);
1477#ifdef DEAL_II_GMSH_WITH_API
1478template <
int dim,
int spacedim>
1481 const std::string & filename)
const
1484 const std::array<int, 8> dealii_to_gmsh_type = {{15, 1, 2, 3, 4, 7, 6, 5}};
1487 const std::array<std::vector<unsigned int>, 8> dealii_to_gmsh = {
1494 {{0, 1, 2, 3, 4, 5}},
1495 {{0, 1, 3, 2, 4, 5, 7, 6}}}};
1500 std::vector<double> coords(3 *
vertices.size());
1501 std::vector<std::size_t> nodes(
vertices.size());
1507 for (
unsigned int d = 0;
d < spacedim; ++
d)
1508 coords[i * 3 +
d] = p[
d];
1520 using IdPair = std::pair<types::material_id, types::manifold_id>;
1521 std::map<IdPair, int> id_pair_to_entity_tag;
1522 std::vector<IdPair> all_pairs;
1524 std::set<IdPair> set_of_pairs;
1527 set_of_pairs.insert({cell->material_id(), cell->manifold_id()});
1528 for (
const auto &f : cell->face_iterators())
1530 (f->boundary_id() != 0 &&
1532 set_of_pairs.insert({f->boundary_id(), f->manifold_id()});
1534 for (
const auto l : cell->line_indices())
1536 const auto &f = cell->line(
l);
1538 (f->boundary_id() != 0 &&
1540 set_of_pairs.insert({f->boundary_id(), f->manifold_id()});
1543 all_pairs = {set_of_pairs.begin(), set_of_pairs.end()};
1546 for (
const auto &p : set_of_pairs)
1547 id_pair_to_entity_tag[p] = entity++;
1550 const auto n_entity_tags = id_pair_to_entity_tag.size();
1553 std::vector<std::vector<std::vector<std::size_t>>> element_ids(
1554 n_entity_tags, std::vector<std::vector<std::size_t>>(8));
1555 std::vector<std::vector<std::vector<std::size_t>>> element_nodes(
1556 n_entity_tags, std::vector<std::vector<std::size_t>>(8));
1559 std::size_t element_id = 1;
1561 const auto add_element = [&](
const auto &element,
const int &entity_tag) {
1562 const auto type = element->reference_cell();
1567 for (
const auto v : element->vertex_indices())
1568 element_nodes[entity_tag - 1][type].emplace_back(
1569 element->vertex_index(dealii_to_gmsh[type][v]) + 1);
1572 element_ids[entity_tag - 1][type].emplace_back(element_id);
1580 std::set<std::pair<int, int>> dim_entity_tag;
1582 auto maybe_add_element =
1583 [&](
const auto & element,
1585 const auto struct_dim = element->structure_dimension;
1589 const bool non_default_boundary_or_material_id =
1590 (boundary_or_material_id != 0 &&
1592 const bool non_default_manifold =
1594 if (struct_dim == dim || non_default_boundary_or_material_id ||
1595 non_default_manifold)
1597 const auto entity_tag =
1598 id_pair_to_entity_tag[{boundary_or_material_id,
manifold_id}];
1599 add_element(element, entity_tag);
1600 dim_entity_tag.insert({struct_dim, entity_tag});
1607 maybe_add_element(cell, cell->material_id());
1608 for (
const auto &face : cell->face_iterators())
1609 maybe_add_element(face, face->boundary_id());
1611 for (
const auto l : cell->line_indices())
1612 maybe_add_element(cell->line(
l), cell->line(
l)->boundary_id());
1617 gmsh::option::setNumber(
"General.Verbosity", 0);
1618 gmsh::model::add(
"Grid generated in deal.II");
1619 for (
const auto &p : dim_entity_tag)
1621 gmsh::model::addDiscreteEntity(p.first, p.second);
1622 gmsh::model::mesh::addNodes(p.first, p.second, nodes, coords);
1625 for (
unsigned int entity_tag = 0; entity_tag < n_entity_tags; ++entity_tag)
1626 for (
unsigned int t = 1; t < 8; ++t)
1628 const auto all_element_ids = element_ids[entity_tag][t];
1629 const auto all_element_nodes = element_nodes[entity_tag][t];
1630 const auto gmsh_t = dealii_to_gmsh_type[t];
1631 if (all_element_ids.size() > 0)
1632 gmsh::model::mesh::addElementsByType(entity_tag + 1,
1639 gmsh::model::mesh::reclassifyNodes();
1640 gmsh::model::mesh::removeDuplicateNodes();
1644 for (
const auto &it : dim_entity_tag)
1646 const auto &
d = it.first;
1647 const auto &entity_tag = it.second;
1648 const auto &
boundary_id = all_pairs[entity_tag - 1].first;
1649 const auto &
manifold_id = all_pairs[entity_tag - 1].second;
1651 std::string physical_name;
1662 std::string sep = physical_name !=
"" ?
", " :
"";
1665 sep +
"ManifoldID:" +
1667 const auto physical_tag =
1668 gmsh::model::addPhysicalGroup(
d, {entity_tag}, -1);
1669 if (physical_name !=
"")
1670 gmsh::model::setPhysicalName(
d, physical_tag, physical_name);
1674 gmsh::write(filename);
1699 const float camera_focus)
1705 camera_focus / ((
point - camera_position) * camera_direction);
1708 camera_position + phi * (
point - camera_position);
1710 return {(projection - camera_position - camera_focus * camera_direction) *
1712 (projection - camera_position - camera_focus * camera_direction) *
1719template <
int dim,
int spacedim>
1722 std::ostream & )
const
1725 ExcMessage(
"Mesh output in SVG format is not implemented for anything "
1726 "other than two-dimensional meshes in two-dimensional "
1727 "space. That's because three-dimensional meshes are best "
1728 "viewed in programs that allow changing the viewpoint, "
1729 "but SVG format does not allow this: It is an inherently "
1730 "2d format, and for three-dimensional meshes would "
1731 "require choosing one, fixed viewpoint."
1733 "You probably want to output your mesh in a format such "
1734 "as VTK, VTU, or gnuplot."));
1743 unsigned int min_level, max_level;
1751 Assert(height != 0 || width != 0,
1752 ExcMessage(
"You have to set at least one of width and height"));
1754 unsigned int margin_in_percent = 0;
1756 margin_in_percent = 8;
1759 unsigned int cell_label_font_size;
1772 float x_max_perspective, x_min_perspective;
1773 float y_max_perspective, y_min_perspective;
1775 float x_dimension_perspective, y_dimension_perspective;
1779 double x_min = tria.
begin()->vertex(0)[0];
1780 double x_max = x_min;
1781 double y_min = tria.
begin()->vertex(0)[1];
1782 double y_max = y_min;
1784 double x_dimension, y_dimension;
1786 min_level = max_level = tria.
begin()->level();
1789 std::set<unsigned int> materials;
1792 std::set<unsigned int> levels;
1795 std::set<unsigned int> subdomains;
1798 std::set<int> level_subdomains;
1806 for (
unsigned int vertex_index = 0; vertex_index < cell->n_vertices();
1809 if (cell->vertex(vertex_index)[0] < x_min)
1810 x_min = cell->vertex(vertex_index)[0];
1811 if (cell->vertex(vertex_index)[0] > x_max)
1812 x_max = cell->vertex(vertex_index)[0];
1814 if (cell->vertex(vertex_index)[1] < y_min)
1815 y_min = cell->vertex(vertex_index)[1];
1816 if (cell->vertex(vertex_index)[1] > y_max)
1817 y_max = cell->vertex(vertex_index)[1];
1820 if (
static_cast<unsigned int>(cell->level()) < min_level)
1821 min_level = cell->level();
1822 if (
static_cast<unsigned int>(cell->level()) > max_level)
1823 max_level = cell->level();
1825 materials.insert(cell->material_id());
1826 levels.insert(cell->level());
1827 if (cell->is_active())
1828 subdomains.insert(cell->subdomain_id() + 2);
1829 level_subdomains.insert(cell->level_subdomain_id() + 2);
1832 x_dimension = x_max - x_min;
1833 y_dimension = y_max - y_min;
1836 const unsigned int n_materials = materials.size();
1839 const unsigned int n_levels = levels.size();
1842 const unsigned int n_subdomains = subdomains.size();
1845 const unsigned int n_level_subdomains = level_subdomains.size();
1859 n = n_level_subdomains;
1868 camera_position[0] = 0;
1869 camera_position[1] = 0;
1870 camera_position[2] = 2. *
std::max(x_dimension, y_dimension);
1873 camera_direction[0] = 0;
1874 camera_direction[1] = 0;
1875 camera_direction[2] = -1;
1878 camera_horizontal[0] = 1;
1879 camera_horizontal[1] = 0;
1880 camera_horizontal[2] = 0;
1882 camera_focus = .5 *
std::max(x_dimension, y_dimension);
1888 const double angle_factor = 3.14159265 / 180.;
1891 camera_position_temp[1] =
1894 camera_position_temp[2] =
1898 camera_direction_temp[1] =
1901 camera_direction_temp[2] =
1905 camera_horizontal_temp[1] =
1908 camera_horizontal_temp[2] =
1912 camera_position[1] = camera_position_temp[1];
1913 camera_position[2] = camera_position_temp[2];
1915 camera_direction[1] = camera_direction_temp[1];
1916 camera_direction[2] = camera_direction_temp[2];
1918 camera_horizontal[1] = camera_horizontal_temp[1];
1919 camera_horizontal[2] = camera_horizontal_temp[2];
1922 camera_position_temp[0] =
1925 camera_position_temp[1] =
1929 camera_direction_temp[0] =
1932 camera_direction_temp[1] =
1936 camera_horizontal_temp[0] =
1939 camera_horizontal_temp[1] =
1943 camera_position[0] = camera_position_temp[0];
1944 camera_position[1] = camera_position_temp[1];
1946 camera_direction[0] = camera_direction_temp[0];
1947 camera_direction[1] = camera_direction_temp[1];
1949 camera_horizontal[0] = camera_horizontal_temp[0];
1950 camera_horizontal[1] = camera_horizontal_temp[1];
1953 camera_position[0] = x_min + .5 * x_dimension;
1954 camera_position[1] = y_min + .5 * y_dimension;
1956 camera_position[0] += 2. *
std::max(x_dimension, y_dimension) *
1959 camera_position[1] -= 2. *
std::max(x_dimension, y_dimension) *
1970 float min_level_min_vertex_distance = 0;
1975 (
static_cast<float>(tria.
begin()->level()) /
1976 static_cast<float>(n_levels)) *
1977 std::max(x_dimension, y_dimension);
1980 projection_decomposition = svg_project_point(
1981 point, camera_position, camera_direction, camera_horizontal, camera_focus);
1983 x_max_perspective = projection_decomposition[0];
1984 x_min_perspective = projection_decomposition[0];
1986 y_max_perspective = projection_decomposition[1];
1987 y_min_perspective = projection_decomposition[1];
1991 point[0] = cell->vertex(0)[0];
1992 point[1] = cell->vertex(0)[1];
1999 (
static_cast<float>(cell->level()) /
static_cast<float>(n_levels)) *
2000 std::max(x_dimension, y_dimension);
2003 projection_decomposition = svg_project_point(
point,
2009 if (x_max_perspective < projection_decomposition[0])
2010 x_max_perspective = projection_decomposition[0];
2011 if (x_min_perspective > projection_decomposition[0])
2012 x_min_perspective = projection_decomposition[0];
2014 if (y_max_perspective < projection_decomposition[1])
2015 y_max_perspective = projection_decomposition[1];
2016 if (y_min_perspective > projection_decomposition[1])
2017 y_min_perspective = projection_decomposition[1];
2019 point[0] = cell->vertex(1)[0];
2020 point[1] = cell->vertex(1)[1];
2022 projection_decomposition = svg_project_point(
point,
2028 if (x_max_perspective < projection_decomposition[0])
2029 x_max_perspective = projection_decomposition[0];
2030 if (x_min_perspective > projection_decomposition[0])
2031 x_min_perspective = projection_decomposition[0];
2033 if (y_max_perspective < projection_decomposition[1])
2034 y_max_perspective = projection_decomposition[1];
2035 if (y_min_perspective > projection_decomposition[1])
2036 y_min_perspective = projection_decomposition[1];
2038 point[0] = cell->vertex(2)[0];
2039 point[1] = cell->vertex(2)[1];
2041 projection_decomposition = svg_project_point(
point,
2047 if (x_max_perspective < projection_decomposition[0])
2048 x_max_perspective = projection_decomposition[0];
2049 if (x_min_perspective > projection_decomposition[0])
2050 x_min_perspective = projection_decomposition[0];
2052 if (y_max_perspective < projection_decomposition[1])
2053 y_max_perspective = projection_decomposition[1];
2054 if (y_min_perspective > projection_decomposition[1])
2055 y_min_perspective = projection_decomposition[1];
2057 if (cell->n_vertices() == 4)
2059 point[0] = cell->vertex(3)[0];
2060 point[1] = cell->vertex(3)[1];
2062 projection_decomposition = svg_project_point(
point,
2068 if (x_max_perspective < projection_decomposition[0])
2069 x_max_perspective = projection_decomposition[0];
2070 if (x_min_perspective > projection_decomposition[0])
2071 x_min_perspective = projection_decomposition[0];
2073 if (y_max_perspective < projection_decomposition[1])
2074 y_max_perspective = projection_decomposition[1];
2075 if (y_min_perspective > projection_decomposition[1])
2076 y_min_perspective = projection_decomposition[1];
2079 if (
static_cast<unsigned int>(cell->level()) == min_level)
2080 min_level_min_vertex_distance = cell->minimum_vertex_distance();
2083 x_dimension_perspective = x_max_perspective - x_min_perspective;
2084 y_dimension_perspective = y_max_perspective - y_min_perspective;
2088 width =
static_cast<unsigned int>(
2089 .5 + height * (x_dimension_perspective / y_dimension_perspective));
2090 else if (height == 0)
2091 height =
static_cast<unsigned int>(
2092 .5 + width * (y_dimension_perspective / x_dimension_perspective));
2093 unsigned int additional_width = 0;
2095 unsigned int font_size =
2096 static_cast<unsigned int>(.5 + (height / 100.) * 1.75);
2097 cell_label_font_size =
static_cast<unsigned int>(
2099 min_level_min_vertex_distance /
std::min(x_dimension, y_dimension)));
2106 additional_width =
static_cast<unsigned int>(
2111 additional_width =
static_cast<unsigned int>(
2112 .5 + height * .175);
2124 out <<
"<svg width=\"" << width + additional_width <<
"\" height=\"" << height
2125 <<
"\" xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">" <<
'\n'
2132 <<
" <linearGradient id=\"background_gradient\" gradientUnits=\"userSpaceOnUse\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\""
2133 << height <<
"\">" <<
'\n'
2134 <<
" <stop offset=\"0\" style=\"stop-color:white\"/>" <<
'\n'
2135 <<
" <stop offset=\"1\" style=\"stop-color:lightsteelblue\"/>" <<
'\n'
2136 <<
" </linearGradient>" <<
'\n';
2142 out <<
"<!-- internal style sheet -->" <<
'\n'
2143 <<
"<style type=\"text/css\"><![CDATA[" <<
'\n';
2147 out <<
" rect.background{fill:url(#background_gradient)}" <<
'\n';
2149 out <<
" rect.background{fill:white}" <<
'\n';
2151 out <<
" rect.background{fill:none}" <<
'\n';
2154 out <<
" rect{fill:none; stroke:rgb(25,25,25); stroke-width:"
2156 <<
" text{font-family:Helvetica; text-anchor:middle; fill:rgb(25,25,25)}"
2158 <<
" line{stroke:rgb(25,25,25); stroke-width:"
2160 <<
" path{fill:none; stroke:rgb(25,25,25); stroke-width:"
2162 <<
" circle{fill:white; stroke:black; stroke-width:2}" <<
'\n'
2168 unsigned int labeling_index = 0;
2169 auto materials_it = materials.begin();
2170 auto levels_it = levels.begin();
2171 auto subdomains_it = subdomains.begin();
2172 auto level_subdomains_it = level_subdomains.begin();
2174 for (
unsigned int index = 0; index < n; index++)
2179 h = .6 - (index / (n - 1.)) * .6;
2187 unsigned int i =
static_cast<unsigned int>(h * 6);
2189 double f = h * 6 - i;
2196 r = 255, g =
static_cast<unsigned int>(.5 + 255 * t);
2199 r =
static_cast<unsigned int>(.5 + 255 * q), g = 255;
2202 g = 255,
b =
static_cast<unsigned int>(.5 + 255 * t);
2205 g =
static_cast<unsigned int>(.5 + 255 * q),
b = 255;
2208 r =
static_cast<unsigned int>(.5 + 255 * t),
b = 255;
2211 r = 255,
b =
static_cast<unsigned int>(.5 + 255 * q);
2220 labeling_index = *materials_it++;
2223 labeling_index = *levels_it++;
2226 labeling_index = *subdomains_it++;
2229 labeling_index = *level_subdomains_it++;
2235 out <<
" path.p" << labeling_index <<
"{fill:rgb(" << r <<
',' << g
2236 <<
',' <<
b <<
"); "
2237 <<
"stroke:rgb(25,25,25); stroke-width:"
2240 out <<
" path.ps" << labeling_index <<
"{fill:rgb("
2241 <<
static_cast<unsigned int>(.5 + .75 * r) <<
','
2242 <<
static_cast<unsigned int>(.5 + .75 * g) <<
','
2243 <<
static_cast<unsigned int>(.5 + .75 *
b) <<
"); "
2244 <<
"stroke:rgb(20,20,20); stroke-width:"
2247 out <<
" rect.r" << labeling_index <<
"{fill:rgb(" << r <<
',' << g
2248 <<
',' <<
b <<
"); "
2249 <<
"stroke:rgb(25,25,25); stroke-width:"
2256 out <<
"]]></style>" <<
'\n' <<
'\n';
2259 out <<
" <rect class=\"background\" width=\"" << width <<
"\" height=\""
2260 << height <<
"\"/>" <<
'\n';
2264 unsigned int x_offset = 0;
2267 x_offset =
static_cast<unsigned int>(.5 + (height / 100.) *
2268 (margin_in_percent / 2.));
2270 x_offset =
static_cast<unsigned int>(.5 + height * .025);
2273 <<
" <text x=\"" << x_offset <<
"\" y=\""
2274 <<
static_cast<unsigned int>(.5 + height * .0525) <<
'\"'
2275 <<
" style=\"font-weight:100; fill:lightsteelblue; text-anchor:start; font-family:Courier; font-size:"
2276 <<
static_cast<unsigned int>(.5 + height * .045) <<
"px\">"
2278 <<
"</text>" <<
'\n';
2297 out <<
" <!-- cells -->" <<
'\n';
2299 for (
unsigned int level_index = min_level; level_index <= max_level;
2312 out <<
" class=\"p";
2314 if (!cell->is_active() &&
2321 out << cell->material_id();
2324 out << static_cast<unsigned int>(cell->level());
2327 if (cell->is_active())
2328 out << cell->subdomain_id() + 2;
2333 out << cell->level_subdomain_id() + 2;
2344 point[0] = cell->vertex(0)[0];
2345 point[1] = cell->vertex(0)[1];
2351 (
static_cast<float>(cell->level()) /
2352 static_cast<float>(n_levels)) *
2353 std::max(x_dimension, y_dimension);
2356 projection_decomposition = svg_project_point(
point,
2362 out << static_cast<unsigned int>(
2364 ((projection_decomposition[0] - x_min_perspective) /
2365 x_dimension_perspective) *
2366 (width - (width / 100.) * 2. * margin_in_percent) +
2367 ((width / 100.) * margin_in_percent))
2369 <<
static_cast<unsigned int>(
2370 .5 + height - (height / 100.) * margin_in_percent -
2371 ((projection_decomposition[1] - y_min_perspective) /
2372 y_dimension_perspective) *
2373 (height - (height / 100.) * 2. * margin_in_percent));
2377 point[0] = cell->vertex(1)[0];
2378 point[1] = cell->vertex(1)[1];
2380 projection_decomposition = svg_project_point(
point,
2386 out << static_cast<unsigned int>(
2388 ((projection_decomposition[0] - x_min_perspective) /
2389 x_dimension_perspective) *
2390 (width - (width / 100.) * 2. * margin_in_percent) +
2391 ((width / 100.) * margin_in_percent))
2393 <<
static_cast<unsigned int>(
2394 .5 + height - (height / 100.) * margin_in_percent -
2395 ((projection_decomposition[1] - y_min_perspective) /
2396 y_dimension_perspective) *
2397 (height - (height / 100.) * 2. * margin_in_percent));
2401 if (cell->n_vertices() == 4)
2403 point[0] = cell->vertex(3)[0];
2404 point[1] = cell->vertex(3)[1];
2406 projection_decomposition = svg_project_point(
point,
2412 out << static_cast<unsigned int>(
2414 ((projection_decomposition[0] - x_min_perspective) /
2415 x_dimension_perspective) *
2416 (width - (width / 100.) * 2. * margin_in_percent) +
2417 ((width / 100.) * margin_in_percent))
2419 <<
static_cast<unsigned int>(
2420 .5 + height - (height / 100.) * margin_in_percent -
2421 ((projection_decomposition[1] - y_min_perspective) /
2422 y_dimension_perspective) *
2423 (height - (height / 100.) * 2. * margin_in_percent));
2428 point[0] = cell->vertex(2)[0];
2429 point[1] = cell->vertex(2)[1];
2431 projection_decomposition = svg_project_point(
point,
2437 out << static_cast<unsigned int>(
2439 ((projection_decomposition[0] - x_min_perspective) /
2440 x_dimension_perspective) *
2441 (width - (width / 100.) * 2. * margin_in_percent) +
2442 ((width / 100.) * margin_in_percent))
2444 <<
static_cast<unsigned int>(
2445 .5 + height - (height / 100.) * margin_in_percent -
2446 ((projection_decomposition[1] - y_min_perspective) /
2447 y_dimension_perspective) *
2448 (height - (height / 100.) * 2. * margin_in_percent));
2452 point[0] = cell->vertex(0)[0];
2453 point[1] = cell->vertex(0)[1];
2455 projection_decomposition = svg_project_point(
point,
2461 out << static_cast<unsigned int>(
2463 ((projection_decomposition[0] - x_min_perspective) /
2464 x_dimension_perspective) *
2465 (width - (width / 100.) * 2. * margin_in_percent) +
2466 ((width / 100.) * margin_in_percent))
2468 <<
static_cast<unsigned int>(
2469 .5 + height - (height / 100.) * margin_in_percent -
2470 ((projection_decomposition[1] - y_min_perspective) /
2471 y_dimension_perspective) *
2472 (height - (height / 100.) * 2. * margin_in_percent));
2474 out <<
"\"/>" <<
'\n';
2481 point[0] = cell->center()[0];
2482 point[1] = cell->center()[1];
2488 (
static_cast<float>(cell->level()) /
2489 static_cast<float>(n_levels)) *
2490 std::max(x_dimension, y_dimension);
2493 const double distance_to_camera =
2497 const double distance_factor =
2498 distance_to_camera / (2. *
std::max(x_dimension, y_dimension));
2500 projection_decomposition = svg_project_point(
point,
2506 const unsigned int font_size_this_cell =
2507 static_cast<unsigned int>(
2509 cell_label_font_size *
2510 std::pow(.5, cell->level() - 4. + 3.5 * distance_factor));
2514 <<
static_cast<unsigned int>(
2516 ((projection_decomposition[0] - x_min_perspective) /
2517 x_dimension_perspective) *
2518 (width - (width / 100.) * 2. * margin_in_percent) +
2519 ((width / 100.) * margin_in_percent))
2521 <<
static_cast<unsigned int>(
2522 .5 + height - (height / 100.) * margin_in_percent -
2523 ((projection_decomposition[1] - y_min_perspective) /
2524 y_dimension_perspective) *
2525 (height - (height / 100.) * 2. * margin_in_percent) +
2526 0.5 * font_size_this_cell)
2527 <<
"\" style=\"font-size:" << font_size_this_cell <<
"px\">";
2531 out << cell->level();
2538 out << cell->index();
2547 <<
static_cast<std::make_signed<types::material_id>::type
>(
2548 cell->material_id());
2556 if (cell->is_active())
2558 std::make_signed<types::subdomain_id>::type
>(
2559 cell->subdomain_id());
2572 <<
static_cast<std::make_signed<types::subdomain_id>::type
>(
2573 cell->level_subdomain_id());
2576 out <<
"</text>" <<
'\n';
2583 for (
auto faceIndex : cell->face_indices())
2585 if (cell->at_boundary(faceIndex))
2587 point[0] = cell->face(faceIndex)->vertex(0)[0];
2588 point[1] = cell->face(faceIndex)->vertex(0)[1];
2594 (
static_cast<float>(cell->level()) /
2595 static_cast<float>(n_levels)) *
2596 std::max(x_dimension, y_dimension);
2599 projection_decomposition =
2600 svg_project_point(
point,
2606 out <<
" <line x1=\""
2607 <<
static_cast<unsigned int>(
2609 ((projection_decomposition[0] -
2610 x_min_perspective) /
2611 x_dimension_perspective) *
2613 (width / 100.) * 2. * margin_in_percent) +
2614 ((width / 100.) * margin_in_percent))
2616 <<
static_cast<unsigned int>(
2618 (height / 100.) * margin_in_percent -
2619 ((projection_decomposition[1] -
2620 y_min_perspective) /
2621 y_dimension_perspective) *
2623 (height / 100.) * 2. * margin_in_percent));
2625 point[0] = cell->face(faceIndex)->vertex(1)[0];
2626 point[1] = cell->face(faceIndex)->vertex(1)[1];
2632 (
static_cast<float>(cell->level()) /
2633 static_cast<float>(n_levels)) *
2634 std::max(x_dimension, y_dimension);
2637 projection_decomposition =
2638 svg_project_point(
point,
2645 <<
static_cast<unsigned int>(
2647 ((projection_decomposition[0] -
2648 x_min_perspective) /
2649 x_dimension_perspective) *
2651 (width / 100.) * 2. * margin_in_percent) +
2652 ((width / 100.) * margin_in_percent))
2654 <<
static_cast<unsigned int>(
2656 (height / 100.) * margin_in_percent -
2657 ((projection_decomposition[1] -
2658 y_min_perspective) /
2659 y_dimension_perspective) *
2661 (height / 100.) * 2. * margin_in_percent))
2667 const double distance_to_camera =
std::sqrt(
2671 const double distance_factor =
2672 distance_to_camera /
2673 (2. *
std::max(x_dimension, y_dimension));
2675 const unsigned int font_size_this_edge =
2676 static_cast<unsigned int>(
2677 .5 + .5 * cell_label_font_size *
2679 cell->level() - 4. +
2680 3.5 * distance_factor));
2682 point[0] = cell->face(faceIndex)->center()[0];
2683 point[1] = cell->face(faceIndex)->center()[1];
2689 (
static_cast<float>(cell->level()) /
2690 static_cast<float>(n_levels)) *
2691 std::max(x_dimension, y_dimension);
2694 projection_decomposition =
2695 svg_project_point(
point,
2701 const unsigned int xc =
static_cast<unsigned int>(
2703 ((projection_decomposition[0] - x_min_perspective) /
2704 x_dimension_perspective) *
2706 (width / 100.) * 2. * margin_in_percent) +
2707 ((width / 100.) * margin_in_percent));
2708 const unsigned int yc =
static_cast<unsigned int>(
2709 .5 + height - (height / 100.) * margin_in_percent -
2710 ((projection_decomposition[1] - y_min_perspective) /
2711 y_dimension_perspective) *
2713 (height / 100.) * 2. * margin_in_percent));
2715 out <<
" <circle cx=\"" << xc <<
"\" cy=\"" << yc
2716 <<
"\" r=\"" << font_size_this_edge <<
"\" />"
2719 out <<
" <text x=\"" << xc <<
"\" y=\"" << yc
2720 <<
"\" style=\"font-size:" << font_size_this_edge
2721 <<
"px\" dominant-baseline=\"middle\">"
2722 <<
static_cast<int>(
2723 cell->face(faceIndex)->boundary_id())
2724 <<
"</text>" <<
'\n';
2736 out <<
'\n' <<
" <!-- legend -->" <<
'\n';
2738 additional_width = 0;
2740 additional_width =
static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
2748 unsigned int line_offset = 0;
2749 out <<
" <rect x=\"" << width + additional_width <<
"\" y=\""
2750 <<
static_cast<unsigned int>(.5 + (height / 100.) * margin_in_percent)
2752 <<
static_cast<unsigned int>(.5 + (height / 100.) *
2753 (40. - margin_in_percent))
2754 <<
"\" height=\"" <<
static_cast<unsigned int>(.5 + height * .215)
2757 out <<
" <text x=\""
2758 << width + additional_width +
2759 static_cast<unsigned int>(.5 + (height / 100.) * 1.25)
2761 <<
static_cast<unsigned int>(.5 +
2762 (height / 100.) * margin_in_percent +
2763 (++line_offset) * 1.5 * font_size)
2764 <<
"\" style=\"text-anchor:start; font-weight:bold; font-size:"
2765 << font_size <<
"px\">"
2767 <<
"</text>" <<
'\n';
2771 out <<
" <text x=\""
2772 << width + additional_width +
2773 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2775 <<
static_cast<unsigned int>(.5 +
2776 (height / 100.) * margin_in_percent +
2777 (++line_offset) * 1.5 * font_size)
2778 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2779 << font_size <<
"px\">"
2787 out <<
"</text>" <<
'\n';
2792 out <<
" <text x=\""
2793 << width + additional_width +
2794 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2796 <<
static_cast<unsigned int>(.5 +
2797 (height / 100.) * margin_in_percent +
2798 (++line_offset) * 1.5 * font_size)
2799 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2800 << font_size <<
"px\">"
2807 out <<
"</text>" <<
'\n';
2812 out <<
" <text x=\""
2813 << width + additional_width +
2814 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2816 <<
static_cast<unsigned int>(.5 +
2817 (height / 100.) * margin_in_percent +
2818 (++line_offset) * 1.5 * font_size)
2819 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2820 << font_size <<
"px\">"
2827 out <<
"</text>" <<
'\n';
2832 out <<
" <text x= \""
2833 << width + additional_width +
2834 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2836 <<
static_cast<unsigned int>(.5 +
2837 (height / 100.) * margin_in_percent +
2838 (++line_offset) * 1.5 * font_size)
2839 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2840 << font_size <<
"px\">"
2846 out <<
"</text>" <<
'\n';
2851 out <<
" <text x= \""
2852 << width + additional_width +
2853 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2855 <<
static_cast<unsigned int>(.5 +
2856 (height / 100.) * margin_in_percent +
2857 (++line_offset) * 1.5 * font_size)
2858 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2859 << font_size <<
"px\">"
2860 <<
"level_subdomain_id"
2861 <<
"</text>" <<
'\n';
2866 out <<
" <text x=\""
2867 << width + additional_width +
2868 static_cast<unsigned int>(.5 + (height / 100.) * 1.25)
2870 <<
static_cast<unsigned int>(.5 +
2871 (height / 100.) * margin_in_percent +
2872 (++line_offset) * 1.5 * font_size)
2873 <<
"\" style=\"text-anchor:start; font-weight:bold; font-size:"
2874 << font_size <<
"px\">"
2876 <<
"</text>" <<
'\n';
2878 out <<
" <text x= \""
2879 << width + additional_width +
2880 static_cast<unsigned int>(.5 + (height / 100.) * 2.)
2882 <<
static_cast<unsigned int>(.5 +
2883 (height / 100.) * margin_in_percent +
2884 (++line_offset) * 1.5 * font_size)
2885 <<
"\" style=\"text-anchor:start; font-style:oblique; font-size:"
2886 << font_size <<
"px\">"
2888 <<
"</text>" <<
'\n';
2896 out <<
" <text x=\"" << width + additional_width <<
"\" y=\""
2897 <<
static_cast<unsigned int>(
2898 .5 + (height / 100.) * margin_in_percent + 13.75 * font_size)
2899 <<
"\" style=\"text-anchor:start; font-size:" << font_size <<
"px\">"
2908 out <<
'\n' <<
" <!-- colorbar -->" <<
'\n';
2910 out <<
" <text x=\"" << width + additional_width <<
"\" y=\""
2911 <<
static_cast<unsigned int>(
2912 .5 + (height / 100.) * (margin_in_percent + 29.) -
2914 <<
"\" style=\"text-anchor:start; font-weight:bold; font-size:"
2915 << font_size <<
"px\">";
2920 out <<
"material_id";
2923 out <<
"level_number";
2926 out <<
"subdomain_id";
2929 out <<
"level_subdomain_id";
2935 out <<
"</text>" <<
'\n';
2937 unsigned int element_height =
static_cast<unsigned int>(
2938 ((height / 100.) * (71. - 2. * margin_in_percent)) / n);
2939 unsigned int element_width =
2940 static_cast<unsigned int>(.5 + (height / 100.) * 2.5);
2942 int labeling_index = 0;
2943 auto materials_it = materials.begin();
2944 auto levels_it = levels.begin();
2945 auto subdomains_it = subdomains.begin();
2946 auto level_subdomains_it = level_subdomains.begin();
2948 for (
unsigned int index = 0; index < n; index++)
2953 labeling_index = *materials_it++;
2956 labeling_index = *levels_it++;
2959 labeling_index = *subdomains_it++;
2962 labeling_index = *level_subdomains_it++;
2968 out <<
" <rect class=\"r" << labeling_index <<
"\" x=\""
2969 << width + additional_width <<
"\" y=\""
2970 <<
static_cast<unsigned int>(.5 + (height / 100.) *
2971 (margin_in_percent + 29)) +
2972 (n - index - 1) * element_height
2973 <<
"\" width=\"" << element_width <<
"\" height=\""
2974 << element_height <<
"\"/>" <<
'\n';
2976 out <<
" <text x=\""
2977 << width + additional_width + 1.5 * element_width <<
"\" y=\""
2978 <<
static_cast<unsigned int>(.5 + (height / 100.) *
2979 (margin_in_percent + 29)) +
2980 (n - index - 1 + .5) * element_height +
2981 static_cast<unsigned int>(.5 + font_size * .35)
2983 <<
" style=\"text-anchor:start; font-size:"
2984 <<
static_cast<unsigned int>(.5 + font_size) <<
"px";
2986 if (index == 0 || index == n - 1)
2987 out <<
"; font-weight:bold";
2989 out <<
"\">" << labeling_index;
2996 out <<
"</text>" <<
'\n';
3004 out <<
'\n' <<
"</svg>";
3020template <
int dim,
int spacedim>
3023 std::ostream & out)
const
3030 const std::time_t time1 = std::time(
nullptr);
3031 const std::tm * time = std::localtime(&time1);
3035 <<
"\n# This file was generated by the deal.II library."
3036 <<
"\n# Date = " << time->tm_year + 1900 <<
"/" << std::setfill(
'0')
3037 << std::setw(2) << time->tm_mon + 1 <<
"/" << std::setfill(
'0')
3038 << std::setw(2) << time->tm_mday <<
"\n# Time = " << std::setfill(
'0')
3039 << std::setw(2) << time->tm_hour <<
":" << std::setfill(
'0')
3040 << std::setw(2) << time->tm_min <<
":" << std::setfill(
'0')
3041 << std::setw(2) << time->tm_sec <<
"\n#"
3042 <<
"\n# For a description of the MathGL script format see the MathGL manual. "
3044 <<
"\n# Note: This file is understood by MathGL v2.1 and higher only, and can "
3045 <<
"\n# be quickly viewed in a graphical environment using \'mglview\'. "
3052 const std::string axes =
"xyz";
3068 out <<
"\nsetsize 800 800";
3069 out <<
"\nrotate 0 0";
3072 out <<
"\nsetsize 800 800";
3073 out <<
"\nrotate 60 40";
3082 <<
"\n# Vertex ordering."
3083 <<
"\n# list <vertex order> <vertex indices>"
3093 out <<
"\nlist f 0 1 2 3"
3098 <<
"\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"
3107 <<
"\n# List of vertices."
3108 <<
"\n# list <id> <vertices>"
3117 for (
unsigned int i = 0; i < dim; ++i)
3124 out <<
"\nlist " << axes[i] << cell->active_cell_index() <<
" ";
3126 out << cell->vertex(j)[i] <<
" ";
3133 <<
"\n# List of cells to quadplot."
3134 <<
"\n# quadplot <vertex order> <id> <style>"
3139 out <<
"\nquadplot f ";
3140 for (
unsigned int j = 0; j < dim; ++j)
3141 out << axes[j] << i <<
" ";
3167 template <
int dim,
int spacedim,
typename ITERATOR,
typename END>
3169 generate_triangulation_patches(
3175 for (; cell !=
end; ++cell)
3180 patch.
data.reinit(5, cell->n_vertices());
3182 for (
const unsigned int v : cell->vertex_indices())
3184 patch.
vertices[v] = cell->vertex(v);
3185 patch.
data(0, v) = cell->level();
3187 static_cast<std::make_signed<types::manifold_id>::type
>(
3188 cell->manifold_id());
3190 static_cast<std::make_signed<types::material_id>::type
>(
3191 cell->material_id());
3192 if (cell->is_active())
3194 static_cast<std::make_signed<types::subdomain_id>::type
>(
3195 cell->subdomain_id());
3197 patch.
data(3, v) = -1;
3199 static_cast<std::make_signed<types::subdomain_id>::type
>(
3200 cell->level_subdomain_id());
3202 patches.push_back(patch);
3208 std::vector<std::string>
3209 triangulation_patch_data_names()
3211 std::vector<std::string> v(5);
3216 v[4] =
"level_subdomain";
3223 std::vector<typename Triangulation<3, 3>::active_line_iterator>
3226 std::vector<typename Triangulation<3, 3>::active_line_iterator> res;
3228 std::vector<bool> flags;
3233 for (
const auto l : face->line_indices())
3235 const auto line = face->line(
l);
3236 if (line->user_flag_set() || line->has_children())
3239 line->set_user_flag();
3240 if (line->at_boundary())
3241 res.emplace_back(line);
3252 template <
int dim,
int spacedim>
3253 std::vector<typename Triangulation<dim, spacedim>::active_line_iterator>
3265 std::vector<typename Triangulation<3, 3>::active_line_iterator>
3268 std::vector<typename Triangulation<3, 3>::active_line_iterator> res;
3270 std::vector<bool> flags;
3275 for (
const auto l : face->line_indices())
3277 const auto line = face->line(
l);
3278 if (line->user_flag_set() || line->has_children())
3281 line->set_user_flag();
3283 (line->boundary_id() != 0 &&
3285 res.emplace_back(line);
3295 template <
int dim,
int spacedim>
3296 std::vector<typename Triangulation<dim, spacedim>::active_line_iterator>
3307 template <
int dim,
int spacedim>
3308 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3311 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3318 res.push_back(face);
3329 template <
int dim,
int spacedim>
3330 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3333 std::vector<typename Triangulation<dim, spacedim>::active_face_iterator>
3340 (face->boundary_id() != 0 &&
3342 res.push_back(face);
3350template <
int dim,
int spacedim>
3353 std::ostream & out)
const
3360 const auto n_vertices =
vertices.size();
3362 out <<
"# vtk DataFile Version 3.0\n"
3363 <<
"Triangulation generated with deal.II\n"
3365 <<
"DATASET UNSTRUCTURED_GRID\n"
3366 <<
"POINTS " << n_vertices <<
" double\n";
3372 for (
unsigned int d = spacedim + 1;
d <= 3; ++
d)
3378 get_relevant_face_iterators(tria) :
3379 get_boundary_face_iterators(tria);
3381 get_relevant_edge_iterators(tria) :
3382 get_boundary_edge_iterators(tria);
3388 "At least one of the flags (output_cells, output_faces, output_edges) has to be enabled!"));
3405 cells_size += cell->n_vertices() + 1;
3408 for (
const auto &face : faces)
3409 cells_size += face->n_vertices() + 1;
3412 for (
const auto &edge : edges)
3413 cells_size += edge->n_vertices() + 1;
3417 out <<
"\nCELLS " <<
n_cells <<
' ' << cells_size <<
'\n';
3432 static const std::array<int, 8> deal_to_vtk_cell_type = {
3433 {1, 3, 5, 9, 10, 14, 13, 12}};
3434 static const std::array<unsigned int, 8> vtk_to_deal_hypercube = {
3435 {0, 1, 3, 2, 4, 5, 7, 6}};
3441 out << cell->n_vertices();
3442 for (
const unsigned int i : cell->vertex_indices())
3451 out << cell->vertex_index(vtk_to_deal_hypercube[i]);
3455 out << cell->vertex_index(i);
3458 static const std::array<unsigned int, 5> permutation_table{
3460 out << cell->vertex_index(permutation_table[i]);
3468 for (
const auto &face : faces)
3470 out << face->n_vertices();
3471 for (
const unsigned int i : face->vertex_indices())
3475 face->n_vertices() ?
3476 vtk_to_deal_hypercube[i] :
3482 for (
const auto &edge : edges)
3485 for (
const unsigned int i : edge->vertex_indices())
3486 out <<
' ' << edge->vertex_index(i);
3491 out <<
"\nCELL_TYPES " <<
n_cells <<
'\n';
3495 out << deal_to_vtk_cell_type[static_cast<int>(cell->reference_cell())]
3501 for (
const auto &face : faces)
3502 out << deal_to_vtk_cell_type[static_cast<int>(face->reference_cell())]
3508 for (
const auto &edge : edges)
3509 out << deal_to_vtk_cell_type[static_cast<int>(edge->reference_cell())]
3512 out <<
"\n\nCELL_DATA " <<
n_cells <<
'\n'
3513 <<
"SCALARS MaterialID int 1\n"
3514 <<
"LOOKUP_TABLE default\n";
3521 out << static_cast<std::make_signed<types::material_id>::type>(
3522 cell->material_id())
3529 for (
const auto &face : faces)
3531 out << static_cast<std::make_signed<types::boundary_id>::type>(
3532 face->boundary_id())
3539 for (
const auto &edge : edges)
3541 out << static_cast<std::make_signed<types::boundary_id>::type>(
3542 edge->boundary_id())
3547 out <<
"\n\nSCALARS ManifoldID int 1\n"
3548 <<
"LOOKUP_TABLE default\n";
3555 out << static_cast<std::make_signed<types::manifold_id>::type>(
3556 cell->manifold_id())
3563 for (
const auto &face : faces)
3565 out << static_cast<std::make_signed<types::manifold_id>::type>(
3566 face->manifold_id())
3573 for (
const auto &edge : edges)
3575 out << static_cast<std::make_signed<types::manifold_id>::type>(
3576 edge->manifold_id())
3589template <
int dim,
int spacedim>
3592 std::ostream & out)
const
3600 std::vector<DataOutBase::Patch<dim, spacedim>> patches;
3602 generate_triangulation_patches(patches, tria.
begin_active(), tria.
end());
3607 triangulation_patch_data_names(),
3609 std::tuple<
unsigned int,
3617 out <<
" </UnstructuredGrid>\n";
3618 out <<
"<dealiiData encoding=\"base64\">";
3619 std::stringstream outstring;
3620 boost::archive::binary_oarchive ia(outstring);
3624 out <<
"\n</dealiiData>\n";
3625 out <<
"</VTKFile>\n";
3636template <
int dim,
int spacedim>
3640 const std::string & filename_without_extension,
3641 const bool view_levels,
3642 const bool include_artificial)
const
3644 std::vector<DataOutBase::Patch<dim, spacedim>> patches;
3645 const unsigned int n_datasets = 4;
3646 std::vector<std::string> data_names;
3647 data_names.emplace_back(
"level");
3648 data_names.emplace_back(
"subdomain");
3649 data_names.emplace_back(
"level_subdomain");
3650 data_names.emplace_back(
"proc_writing");
3664 if (cell->has_children())
3666 if (!include_artificial &&
3670 else if (!include_artificial)
3672 if (cell->has_children() &&
3675 else if (cell->is_active() &&
3676 cell->level_subdomain_id() ==
3683 patch.
data.reinit(n_datasets, n_q_points);
3687 for (
unsigned int vertex = 0; vertex < n_q_points; ++vertex)
3689 patch.
vertices[vertex] = cell->vertex(vertex);
3690 patch.
data(0, vertex) = cell->level();
3691 if (cell->is_active())
3692 patch.
data(1, vertex) =
static_cast<double>(
3693 static_cast<std::make_signed<types::subdomain_id>::type
>(
3694 cell->subdomain_id()));
3696 patch.
data(1, vertex) = -1.0;
3697 patch.
data(2, vertex) =
static_cast<double>(
3698 static_cast<std::make_signed<types::subdomain_id>::type
>(
3699 cell->level_subdomain_id()));
3705 patches.push_back(patch);
3711 std::string new_file = filename_without_extension +
".vtu";
3715 new_file = filename_without_extension +
".proc" +
3720 if (tr->locally_owned_subdomain() == 0)
3722 std::vector<std::string> filenames;
3727 std::size_t pos = filename_without_extension.find_last_of(
'/');
3728 if (pos == std::string::npos)
3732 const unsigned int n_procs =
3734 for (
unsigned int i = 0; i < n_procs; ++i)
3735 filenames.push_back(filename_without_extension.substr(pos) +
3739 const std::string pvtu_filename =
3740 (filename_without_extension +
".pvtu");
3741 std::ofstream pvtu_output(pvtu_filename.c_str());
3760 std::ofstream out(new_file.c_str());
3762 std::tuple<
unsigned int,
3824template <
int dim,
int spacedim>
3829 unsigned int n_faces = 0;
3832 if ((face->at_boundary()) && (face->boundary_id() != 0))
3840template <
int dim,
int spacedim>
3847 std::vector<bool> line_flags;
3851 .clear_user_flags_line();
3853 unsigned int n_lines = 0;
3856 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++
l)
3857 if (cell->line(
l)->at_boundary() && (cell->line(
l)->boundary_id() != 0) &&
3858 (cell->line(
l)->user_flag_set() ==
false))
3861 cell->line(
l)->set_user_flag();
3876 const unsigned int next_element_index,
3877 std::ostream &)
const
3879 return next_element_index;
3885 const unsigned int next_element_index,
3886 std::ostream &)
const
3888 return next_element_index;
3893 const unsigned int next_element_index,
3894 std::ostream &)
const
3896 return next_element_index;
3902 const unsigned int next_element_index,
3903 std::ostream &)
const
3905 return next_element_index;
3910 const unsigned int next_element_index,
3911 std::ostream &)
const
3913 return next_element_index;
3919 const unsigned int next_element_index,
3920 std::ostream &)
const
3922 return next_element_index;
3928 const unsigned int next_element_index,
3929 std::ostream &)
const
3931 return next_element_index;
3936 const unsigned int next_element_index,
3937 std::ostream &)
const
3939 return next_element_index;
3944template <
int dim,
int spacedim>
3947 const unsigned int next_element_index,
3948 std::ostream & out)
const
3950 unsigned int current_element_index = next_element_index;
3953 if (face->at_boundary() && (face->boundary_id() != 0))
3955 out << current_element_index <<
' ';
3967 out << static_cast<unsigned int>(face->boundary_id()) <<
' '
3968 <<
static_cast<unsigned int>(face->boundary_id()) <<
' '
3971 for (
unsigned int vertex = 0;
3972 vertex < GeometryInfo<dim>::vertices_per_face;
3975 << face->vertex_index(
3980 ++current_element_index;
3982 return current_element_index;
3986template <
int dim,
int spacedim>
3989 const unsigned int next_element_index,
3990 std::ostream & out)
const
3992 unsigned int current_element_index = next_element_index;
3997 std::vector<bool> line_flags;
4001 .clear_user_flags_line();
4004 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++
l)
4005 if (cell->line(
l)->at_boundary() && (cell->line(
l)->boundary_id() != 0) &&
4006 (cell->line(
l)->user_flag_set() ==
false))
4008 out << next_element_index <<
" 1 ";
4009 out << static_cast<unsigned int>(cell->line(
l)->boundary_id()) <<
' '
4010 <<
static_cast<unsigned int>(cell->line(
l)->boundary_id())
4013 for (
unsigned int vertex = 0; vertex < 2; ++vertex)
4015 << cell->line(
l)->vertex_index(
4023 ++current_element_index;
4024 cell->line(
l)->set_user_flag();
4032 return current_element_index;
4039 const unsigned int next_element_index,
4040 std::ostream &)
const
4042 return next_element_index;
4047 const unsigned int next_element_index,
4048 std::ostream &)
const
4050 return next_element_index;
4055 const unsigned int next_element_index,
4056 std::ostream &)
const
4058 return next_element_index;
4063 const unsigned int next_element_index,
4064 std::ostream &)
const
4066 return next_element_index;
4071 const unsigned int next_element_index,
4072 std::ostream &)
const
4074 return next_element_index;
4080 const unsigned int next_element_index,
4081 std::ostream &)
const
4083 return next_element_index;
4089 const unsigned int next_element_index,
4090 std::ostream &)
const
4092 return next_element_index;
4097 const unsigned int next_element_index,
4098 std::ostream &)
const
4100 return next_element_index;
4105template <
int dim,
int spacedim>
4108 const unsigned int next_element_index,
4109 std::ostream & out)
const
4111 unsigned int current_element_index = next_element_index;
4115 if (face->at_boundary() && (face->boundary_id() != 0))
4117 out << current_element_index <<
" "
4118 <<
static_cast<unsigned int>(face->boundary_id()) <<
" ";
4131 for (
unsigned int vertex = 0;
4132 vertex < GeometryInfo<dim>::vertices_per_face;
4134 out << face->vertex_index(
4140 ++current_element_index;
4142 return current_element_index;
4147template <
int dim,
int spacedim>
4150 const unsigned int next_element_index,
4151 std::ostream & out)
const
4153 unsigned int current_element_index = next_element_index;
4158 std::vector<bool> line_flags;
4162 .clear_user_flags_line();
4165 for (
unsigned int l = 0; l < GeometryInfo<dim>::lines_per_cell; ++
l)
4166 if (cell->line(
l)->at_boundary() && (cell->line(
l)->boundary_id() != 0) &&
4167 (cell->line(
l)->user_flag_set() ==
false))
4169 out << current_element_index <<
" "
4170 <<
static_cast<unsigned int>(cell->line(
l)->boundary_id())
4173 for (
unsigned int vertex = 0; vertex < 2; ++vertex)
4174 out << cell->line(
l)->vertex_index(
4183 ++current_element_index;
4184 cell->line(
l)->set_user_flag();
4191 return current_element_index;
4208 template <
int spacedim>
4212 while (points.size() > 2)
4215 first_difference /= first_difference.
norm();
4217 second_difference /= second_difference.
norm();
4219 if ((first_difference - second_difference).
norm() < 1
e-10)
4220 points.erase(points.begin() + 1);
4228 template <
int spacedim>
4237 for (
const auto &cell : tria.active_cell_iterators())
4240 out <<
"# cell " << cell <<
'\n';
4242 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4243 << cell->material_id() <<
'\n'
4244 << cell->vertex(1) <<
' ' << cell->level() <<
' '
4245 << cell->material_id() <<
'\n'
4258 template <
int spacedim>
4269 const unsigned int n_additional_points =
4271 const unsigned int n_points = 2 + n_additional_points;
4276 std::vector<
Point<dim - 1>> boundary_points;
4277 if (mapping !=
nullptr)
4279 boundary_points.resize(n_points);
4280 boundary_points[0][0] = 0;
4281 boundary_points[n_points - 1][0] = 1;
4282 for (
unsigned int i = 1; i < n_points - 1; ++i)
4283 boundary_points[i](0) = 1. * i / (n_points - 1);
4285 std::vector<double> dummy_weights(n_points, 1. / n_points);
4286 Quadrature<dim - 1> quadrature(boundary_points, dummy_weights);
4292 for (
const auto &cell : tria.active_cell_iterators())
4295 out <<
"# cell " << cell <<
'\n';
4297 if (mapping ==
nullptr ||
4309 << cell->level() <<
' ' << cell->material_id() <<
'\n';
4310 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4311 << cell->material_id() <<
'\n'
4319 for (
const unsigned int face_no :
4323 spacedim>::face_iterator
4324 face = cell->face(face_no);
4325 if (dim != spacedim || face->at_boundary() ||
4331 std::vector<Point<spacedim>> line_points;
4334 const unsigned int offset = face_no * n_points;
4335 for (
unsigned int i = 0; i < n_points; ++i)
4336 line_points.push_back(
4338 cell, q_projector.
point(offset + i)));
4339 internal::remove_colinear_points(line_points);
4342 out <<
point <<
' ' << cell->level() <<
' '
4343 << cell->material_id() <<
'\n';
4345 out <<
'\n' <<
'\n';
4351 out << face->vertex(0) <<
' ' << cell->level() <<
' '
4352 << cell->material_id() <<
'\n'
4353 << face->vertex(1) <<
' ' << cell->level() <<
' '
4354 << cell->material_id() <<
'\n'
4370 template <
int spacedim>
4381 const unsigned int n_additional_points =
4383 const unsigned int n_points = 2 + n_additional_points;
4387 std::unique_ptr<Quadrature<dim>> q_projector;
4388 std::vector<Point<1>> boundary_points;
4389 if (mapping !=
nullptr)
4391 boundary_points.resize(n_points);
4392 boundary_points[0][0] = 0;
4393 boundary_points[n_points - 1][0] = 1;
4394 for (
unsigned int i = 1; i < n_points - 1; ++i)
4395 boundary_points[i](0) = 1. * i / (n_points - 1);
4397 std::vector<double> dummy_weights(n_points, 1. / n_points);
4401 QIterated<dim - 1> quadrature(quadrature1d, 1);
4402 q_projector = std::make_unique<Quadrature<dim>>(
4406 for (
const auto &cell : tria.active_cell_iterators())
4409 out <<
"# cell " << cell <<
'\n';
4411 if (mapping ==
nullptr || n_points == 2 ||
4412 (!cell->has_boundary_lines() &&
4416 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4417 << cell->material_id() <<
'\n'
4418 << cell->vertex(1) <<
' ' << cell->level() <<
' '
4419 << cell->material_id() <<
'\n'
4420 << cell->vertex(5) <<
' ' << cell->level() <<
' '
4421 << cell->material_id() <<
'\n'
4422 << cell->vertex(4) <<
' ' << cell->level() <<
' '
4423 << cell->material_id() <<
'\n'
4424 << cell->vertex(0) <<
' ' << cell->level() <<
' '
4425 << cell->material_id() <<
'\n'
4428 out << cell->vertex(2) <<
' ' << cell->level() <<
' '
4429 << cell->material_id() <<
'\n'
4430 << cell->vertex(3) <<
' ' << cell->level() <<
' '
4431 << cell->material_id() <<
'\n'
4432 << cell->vertex(7) <<
' ' << cell->level() <<
' '
4433 << cell->material_id() <<
'\n'
4434 << cell->vertex(6) <<
' ' << cell->level() <<
' '
4435 << cell->material_id() <<
'\n'
4436 << cell->vertex(2) <<
' ' << cell->level() <<
' '
4437 << cell->material_id() <<
'\n'
4441 out << cell->vertex(0) <<
' ' << cell->level() <<
' '
4442 << cell->material_id() <<
'\n'
4443 << cell->vertex(2) <<
' ' << cell->level() <<
' '
4444 << cell->material_id() <<
'\n'
4446 out << cell->vertex(1) <<
' ' << cell->level() <<
' '
4447 << cell->material_id() <<
'\n'
4448 << cell->vertex(3) <<
' ' << cell->level() <<
' '
4449 << cell->material_id() <<
'\n'
4451 out << cell->vertex(5) <<
' ' << cell->level() <<
' '
4452 << cell->material_id() <<
'\n'
4453 << cell->vertex(7) <<
' ' << cell->level() <<
' '
4454 << cell->material_id() <<
'\n'
4456 out << cell->vertex(4) <<
' ' << cell->level() <<
' '
4457 << cell->material_id() <<
'\n'
4458 << cell->vertex(6) <<
' ' << cell->level() <<
' '
4459 << cell->material_id() <<
'\n'
4464 for (
const unsigned int face_no :
4468 spacedim>::face_iterator
4469 face = cell->face(face_no);
4471 if (face->at_boundary() &&
4474 const unsigned int offset = face_no * n_points * n_points;
4475 for (
unsigned int i = 0; i < n_points - 1; ++i)
4476 for (
unsigned int j = 0; j < n_points - 1; ++j)
4481 q_projector->point(offset + i * n_points + j));
4482 out << p0 <<
' ' << cell->level() <<
' '
4483 << cell->material_id() <<
'\n';
4487 offset + (i + 1) * n_points + j)))
4488 <<
' ' << cell->level() <<
' '
4489 << cell->material_id() <<
'\n';
4493 offset + (i + 1) * n_points + j + 1)))
4494 <<
' ' << cell->level() <<
' '
4495 << cell->material_id() <<
'\n';
4498 q_projector->point(offset + i * n_points +
4500 <<
' ' << cell->level() <<
' '
4501 << cell->material_id() <<
'\n';
4503 out << p0 <<
' ' << cell->level() <<
' '
4504 << cell->material_id() <<
'\n';
4505 out <<
'\n' <<
'\n';
4510 for (
unsigned int l = 0;
4511 l < GeometryInfo<dim>::lines_per_face;
4514 const typename ::Triangulation<dim, spacedim>::
4515 line_iterator line = face->line(
l);
4518 &
v1 = line->vertex(1);
4519 if (line->at_boundary() ||
4525 std::vector<Point<spacedim>> line_points;
4534 for (
unsigned int i = 0; i < n_points; ++i)
4535 line_points.push_back(
4538 (1 - boundary_points[i][0]) * u0 +
4539 boundary_points[i][0] * u1));
4540 internal::remove_colinear_points(line_points);
4542 out <<
point <<
' ' << cell->level() <<
' '
4543 <<
static_cast<unsigned int>(
4544 cell->material_id())
4548 out <<
v0 <<
' ' << cell->level() <<
' '
4549 << cell->material_id() <<
'\n'
4550 <<
v1 <<
' ' << cell->level() <<
' '
4551 << cell->material_id() <<
'\n';
4553 out <<
'\n' <<
'\n';
4570template <
int dim,
int spacedim>
4594 const unsigned int l)
4614 write_eps(const ::Triangulation<1, 2> &,
4624 write_eps(const ::Triangulation<1, 3> &,
4634 write_eps(const ::Triangulation<2, 3> &,
4645 template <
int dim,
int spacedim>
4647 write_eps(const ::Triangulation<dim, spacedim> &tria,
4653 using LineList = std::list<LineEntry>;
4693 for (
const auto &cell : tria.active_cell_iterators())
4694 for (
const unsigned int line_no : cell->line_indices())
4696 typename ::Triangulation<dim, spacedim>::line_iterator
4697 line = cell->line(line_no);
4709 if (!line->has_children() &&
4710 (mapping ==
nullptr || !line->at_boundary()))
4730 line_list.emplace_back(
4731 Point<2>(line->vertex(0)(0), line->vertex(0)(1)),
4732 Point<2>(line->vertex(1)(0), line->vertex(1)(1)),
4733 line->user_flag_set(),
4743 if (mapping !=
nullptr)
4750 std::vector<
Point<dim - 1>> boundary_points(n_points);
4752 for (
unsigned int i = 0; i < n_points; ++i)
4753 boundary_points[i](0) = 1. * (i + 1) / (n_points + 1);
4755 Quadrature<dim - 1> quadrature(boundary_points);
4763 for (
const auto &cell : tria.active_cell_iterators())
4764 for (
const unsigned int face_no :
4767 const typename ::Triangulation<dim, spacedim>::
4768 face_iterator face = cell->face(face_no);
4770 if (face->at_boundary())
4780 const unsigned int offset = face_no * n_points;
4781 for (
unsigned int i = 0; i < n_points; ++i)
4785 cell, q_projector.point(offset + i)));
4786 const Point<2> p1(p1_dim(0), p1_dim(1));
4788 line_list.emplace_back(p0,
4790 face->user_flag_set(),
4797 const Point<2> p1(p1_dim(0), p1_dim(1));
4798 line_list.emplace_back(p0,
4800 face->user_flag_set(),
4835 const double turn_angle = eps_flags_3.
turn_angle;
4837 -
std::sin(z_angle * 2. * pi / 360.) *
4838 std::sin(turn_angle * 2. * pi / 360.),
4839 +
std::sin(z_angle * 2. * pi / 360.) *
4840 std::cos(turn_angle * 2. * pi / 360.),
4841 -
std::cos(z_angle * 2. * pi / 360.));
4849 ((
Point<dim>(0, 0, 1) * view_direction) * view_direction);
4858 ((
Point<dim>(1, 0, 0) * view_direction) * view_direction) -
4859 ((
Point<dim>(1, 0, 0) * unit_vector1) * unit_vector1));
4863 for (
const auto &cell : tria.active_cell_iterators())
4864 for (
const unsigned int line_no : cell->line_indices())
4866 typename ::Triangulation<dim, spacedim>::line_iterator
4867 line = cell->line(line_no);
4868 line_list.emplace_back(
4869 Point<2>(line->vertex(0) * unit_vector2,
4870 line->vertex(0) * unit_vector1),
4871 Point<2>(line->vertex(1) * unit_vector2,
4872 line->vertex(1) * unit_vector1),
4873 line->user_flag_set(),
4889 double x_min = tria.begin_active()->vertex(0)(0);
4890 double x_max = x_min;
4891 double y_min = tria.begin_active()->vertex(0)(1);
4892 double y_max = y_min;
4893 unsigned int max_level = line_list.begin()->level;
4895 for (LineList::const_iterator line = line_list.begin();
4896 line != line_list.end();
4899 x_min =
std::min(x_min, line->first(0));
4900 x_min =
std::min(x_min, line->second(0));
4902 x_max =
std::max(x_max, line->first(0));
4903 x_max =
std::max(x_max, line->second(0));
4905 y_min =
std::min(y_min, line->first(1));
4906 y_min =
std::min(y_min, line->second(1));
4908 y_max =
std::max(y_max, line->first(1));
4909 y_max =
std::max(y_max, line->second(1));
4911 max_level =
std::max(max_level, line->level);
4919 const double scale =
4920 (eps_flags_base.
size /
4931 std::time_t time1 = std::time(
nullptr);
4932 std::tm * time = std::localtime(&time1);
4933 out <<
"%!PS-Adobe-2.0 EPSF-1.2" <<
'\n'
4934 <<
"%%Title: deal.II Output" <<
'\n'
4935 <<
"%%Creator: the deal.II library" <<
'\n'
4936 <<
"%%Creation Date: " << time->tm_year + 1900 <<
"/"
4937 << time->tm_mon + 1 <<
"/" << time->tm_mday <<
" - "
4938 << time->tm_hour <<
":" << std::setw(2) << time->tm_min <<
":"
4939 << std::setw(2) << time->tm_sec <<
'\n'
4940 <<
"%%BoundingBox: "
4944 <<
static_cast<unsigned int>(
4947 <<
static_cast<unsigned int>(
4957 out <<
"/m {moveto} bind def" <<
'\n'
4958 <<
"/x {lineto stroke} bind def" <<
'\n'
4959 <<
"/b {0 0 0 setrgbcolor} def" <<
'\n'
4960 <<
"/r {1 0 0 setrgbcolor} def" <<
'\n';
4967 out <<
"/l { neg " << (max_level) <<
" add "
4968 << (0.66666 /
std::max(1U, (max_level - 1)))
4969 <<
" mul 1 0.8 sethsbcolor} def" <<
'\n';
4983 << (
"/R {rmoveto} bind def\n"
4984 "/Symbol-Oblique /Symbol findfont [1 0 .167 1 0 0] makefont\n"
4985 "dup length dict begin {1 index /FID eq {pop pop} {def} ifelse} forall\n"
4986 "currentdict end definefont\n"
4987 "/MFshow {{dup dup 0 get findfont exch 1 get scalefont setfont\n"
4988 "[ currentpoint ] exch dup 2 get 0 exch rmoveto dup dup 5 get exch 4 get\n"
4989 "{show} {stringwidth pop 0 rmoveto}ifelse dup 3 get\n"
4990 "{2 get neg 0 exch rmoveto pop} {pop aload pop moveto}ifelse} forall} bind def\n"
4991 "/MFwidth {0 exch {dup 3 get{dup dup 0 get findfont exch 1 get scalefont setfont\n"
4992 "5 get stringwidth pop add}\n"
4993 "{pop} ifelse} forall} bind def\n"
4994 "/MCshow { currentpoint stroke m\n"
4995 "exch dup MFwidth -2 div 3 -1 roll R MFshow } def\n")
4999 out <<
"%%EndProlog" <<
'\n' <<
'\n';
5002 out << eps_flags_base.
line_width <<
" setlinewidth" <<
'\n';
5006 const Point<2> offset(x_min, y_min);
5008 for (LineList::const_iterator line = line_list.begin();
5009 line != line_list.end();
5012 out << line->level <<
" l " << (line->first - offset) *
scale <<
" m "
5013 << (line->second - offset) *
scale <<
" x" <<
'\n';
5018 << (line->first - offset) *
scale <<
" m "
5019 << (line->second - offset) *
scale <<
" x" <<
'\n';
5025 out <<
"(Helvetica) findfont 140 scalefont setfont" <<
'\n';
5027 for (
const auto &cell : tria.active_cell_iterators())
5029 out << (cell->center()(0) - offset(0)) *
scale <<
' '
5030 << (cell->center()(1) - offset(1)) *
scale <<
" m" <<
'\n'
5031 <<
"[ [(Helvetica) 12.0 0.0 true true (";
5035 out << cell->index();
5038 <<
"] -6 MCshow" <<
'\n';
5045 out <<
"(Helvetica) findfont 140 scalefont setfont" <<
'\n';
5051 std::set<unsigned int> treated_vertices;
5052 for (
const auto &cell : tria.active_cell_iterators())
5053 for (
const unsigned int vertex_no : cell->vertex_indices())
5054 if (treated_vertices.find(cell->vertex_index(vertex_no)) ==
5055 treated_vertices.end())
5057 treated_vertices.insert(cell->vertex_index(vertex_no));
5059 out << (cell->vertex(vertex_no)(0) - offset(0)) *
scale <<
' '
5060 << (cell->vertex(vertex_no)(1) - offset(1)) *
scale
5062 <<
"[ [(Helvetica) 10.0 0.0 true true ("
5063 << cell->vertex_index(vertex_no) <<
")] "
5064 <<
"] -6 MCshow" <<
'\n';
5068 out <<
"showpage" <<
'\n';
5080template <
int dim,
int spacedim>
5090template <
int dim,
int spacedim>
5097 switch (output_format)
5147template <
int dim,
int spacedim>
5158#include "grid_out.inst"
void attach_triangulation(const Triangulation< DoFHandlerType::dimension, DoFHandlerType::space_dimension > &)
void add_data_vector(const VectorType &data, const std::vector< std::string > &names, const DataVectorType type=type_automatic, const std::vector< DataComponentInterpretation::DataComponentInterpretation > &data_component_interpretation=std::vector< DataComponentInterpretation::DataComponentInterpretation >())
virtual void build_patches(const unsigned int n_subdivisions=0)
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
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const =0
virtual Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const =0
long int get_integer(const std::string &entry_string) const
bool get_bool(const std::string &entry_name) const
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation="", const bool has_to_be_set=false)
std::string get(const std::string &entry_string) const
double get_double(const std::string &entry_name) const
void enter_subsection(const std::string &subsection)
static Quadrature< dim > project_to_all_faces(const Quadrature< dim - 1 > &quadrature)
const Point< dim > & point(const unsigned int i) const
numbers::NumberTraits< Number >::real_type norm() const
constexpr Tensor< 1, dim, typename ProductType< Number1, Number2 >::type > cross_product_3d(const Tensor< 1, dim, Number1 > &src1, const Tensor< 1, dim, Number2 > &src2)
void save_user_flags_line(std::ostream &out) const
void save(Archive &ar, const unsigned int version) const
cell_iterator begin(const unsigned int level=0) const
virtual types::subdomain_id locally_owned_subdomain() const
unsigned int n_active_cells() const
const std::vector< Point< spacedim > > & get_vertices() const
unsigned int n_used_vertices() const
const std::vector< ReferenceCell > & get_reference_cells() const
cell_iterator end() const
const std::vector< bool > & get_used_vertices() const
active_cell_iterator begin_active(const unsigned int level=0) const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
IteratorRange< active_face_iterator > active_face_iterators() const
IteratorRange< active_cell_iterator > active_cell_iterators() const
IteratorRange< cell_iterator > cell_iterators_on_level(const unsigned int level) const
IteratorRange< cell_iterator > cell_iterators() const
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static ::ExceptionBase & ExcIO()
ReferenceCell reference_cell
static void declare_parameters(ParameterHandler &prm)
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcInvalidState()
#define Assert(cond, exc)
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
#define AssertDimension(dim1, dim2)
void parse_parameters(const ParameterHandler &prm)
static ::ExceptionBase & ExcInternalError()
unsigned int n_subdivisions
bool points_are_available
std::array< unsigned int, GeometryInfo< dim >::faces_per_cell > neighbors
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_cells(const std::vector< Patch< dim, spacedim > > &patches, StreamType &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)
Expression floor(const Expression &x)
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell &reference_cell)
types::global_dof_index size_type
double norm(const FEValuesBase< dim > &fe, const ArrayView< const std::vector< Tensor< 1, dim > > > &Du)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
Tensor< 2, dim, Number > l(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(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)
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
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
TriangulationBase< dim, spacedim > Triangulation
::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 ¶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)
bool write_cell_number_level
void parse_parameters(ParameterHandler ¶m)
bool write_vertex_numbers
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