deal.II version GIT relicensing-2055-gd703fda1ad 2024-10-30 20:00:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
grid_out.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 1999 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_grid_out_h
16#define dealii_grid_out_h
17
18
19
20#include <deal.II/base/config.h>
21
24#include <deal.II/base/point.h>
25
26#include <string>
27
29
30// Forward declarations
31#ifndef DOXYGEN
33template <int dim, int spacedim>
35class Triangulation;
36template <int dim, int spacedim>
37class Mapping;
38#endif
39
40
49namespace GridOutFlags
50{
56 struct DX
57 {
62
67
72
77
83
87 DX(const bool write_cells = true,
88 const bool write_faces = false,
89 const bool write_diameter = false,
90 const bool write_measure = false,
91 const bool write_all_faces = true);
92
96 static void
98
102 void
104 };
105
111 struct Msh
112 {
141
145 Msh(const bool write_faces = false, const bool write_lines = false);
149 static void
151
155 void
157 };
158
159
165 struct Ucd
166 {
177
191
207
211 Ucd(const bool write_preamble = false,
212 const bool write_faces = false,
213 const bool write_lines = false);
214
218 static void
220
224 void
226 };
227
228
234 struct Gnuplot
235 {
246
254
260
273
277 Gnuplot(const bool write_cell_number = false,
278 const unsigned int n_extra_curved_line_points = 2,
279 const bool curved_inner_cells = false,
280 const bool write_additional_boundary_lines = true);
281
285 static void
287
291 void
293 };
294
307 {
314 {
322 height
323 };
324
329
337 unsigned int size;
338
343
351
363
371
376 const unsigned int size = 300,
377 const double line_width = 0.5,
378 const bool color_lines_on_user_flag = false,
379 const unsigned int n_boundary_face_points = 2,
380 const bool color_lines_level = false);
384 static void
386
390 void
392 };
393
394
405 template <int dim>
406 struct Eps
407 {};
408
414 template <>
415 struct Eps<1> : public EpsFlagsBase
416 {
420 Eps(const SizeType size_type = width,
421 const unsigned int size = 300,
422 const double line_width = 0.5,
423 const bool color_lines_on_user_flag = false,
424 const unsigned int n_boundary_face_points = 2);
428 static void
429 declare_parameters(ParameterHandler &param);
430
434 void
435 parse_parameters(ParameterHandler &param);
436 };
437
438
444 template <>
445 struct Eps<2> : public EpsFlagsBase
446 {
464
470
474 Eps(const SizeType size_type = width,
475 const unsigned int size = 300,
476 const double line_width = 0.5,
477 const bool color_lines_on_user_flag = false,
478 const unsigned int n_boundary_face_points = 2,
479 const bool write_cell_numbers = false,
480 const bool write_cell_number_level = true,
481 const bool write_vertex_numbers = false,
482 const bool color_lines_level = false);
486 static void
487 declare_parameters(ParameterHandler &param);
488
492 void
493 parse_parameters(ParameterHandler &param);
494 };
495
501 template <>
502 struct Eps<3> : public EpsFlagsBase
503 {
510
520
524 Eps(const SizeType size_type = width,
525 const unsigned int size = 300,
526 const double line_width = 0.5,
527 const bool color_lines_on_user_flag = false,
528 const unsigned int n_boundary_face_points = 2,
529 const double azimut_angle = 60,
530 const double turn_angle = 30);
534 static void
535 declare_parameters(ParameterHandler &param);
536
540 void
541 parse_parameters(ParameterHandler &param);
542 };
543
641
642
655 struct Svg
656 {
661 unsigned int height;
662
667 unsigned int width;
668
672 unsigned int line_thickness;
677
681 bool margin;
682
687 {
692
697
702 dealii
703 };
704
709
710 // View angles for the perspective view of the grid; Default is 0, 0 (top
711 // view).
712
717
722
739
741
745
751
760
765
770
775
780
789
795
801
805 Svg(const unsigned int line_thickness = 2,
806 const unsigned int boundary_line_thickness = 4,
807 const bool margin = true,
809 const int azimuth_angle = 0,
810 const int polar_angle = 0,
812 const bool convert_level_number_to_height = false,
813 const bool label_level_number = false,
814 const bool label_cell_index = false,
815 const bool label_material_id = false,
816 const bool label_subdomain_id = false,
817 const bool draw_colorbar = false,
818 const bool draw_legend = false,
819 const bool label_boundary_id = false);
820 };
821
827 struct MathGL
828 {
832 MathGL();
833
838
842 static void
844
848 void
850 };
851
852
860 {
864 Vtk(const bool output_cells = true,
865 const bool output_faces = true,
866 const bool output_edges = true,
867 const bool output_only_relevant = true)
872 {}
873
878
883
888
894 };
895
896
916} // namespace GridOutFlags
917
918
919
993{
994public:
1025
1029 GridOut();
1030
1039 template <int dim, int spacedim>
1040 void
1041 write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1042
1073 template <int dim, int spacedim>
1074 void
1076 std::ostream &out,
1077 const Mapping<dim, spacedim> *mapping = nullptr) const;
1078
1097 template <int dim, int spacedim>
1098 void
1099 write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1100
1101#ifdef DEAL_II_GMSH_WITH_API
1142 template <int dim, int spacedim>
1143 void
1145 const std::string &filename) const;
1146#endif
1147
1167 template <int dim, int spacedim>
1168 void
1169 write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1170
1200 template <int dim, int spacedim>
1201 void
1203 std::ostream &out,
1204 const Mapping<dim, spacedim> *mapping = nullptr) const;
1205
1224 template <int dim, int spacedim>
1225 void
1227 std::ostream &out,
1228 const Mapping<dim, spacedim> *mapping = nullptr) const;
1229
1250 void
1251 write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1252
1258 template <int dim, int spacedim>
1259 void
1260 write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1261
1262
1277 template <int dim, int spacedim>
1278 void
1280 std::ostream &out) const;
1281
1318 template <int dim, int spacedim>
1319 void
1320 write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1321
1340 template <int dim, int spacedim>
1341 void
1342 write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1343
1374 template <int dim, int spacedim>
1375 void
1377 const std::string &filename_without_extension,
1378 const bool view_levels = false,
1379 const bool include_artificial = false) const;
1380
1385 template <int dim, int spacedim>
1386 void
1388 std::ostream &out,
1389 const OutputFormat output_format,
1390 const Mapping<dim, spacedim> *mapping = nullptr) const;
1391
1395 template <int dim, int spacedim>
1396 void
1398 std::ostream &out,
1399 const Mapping<dim, spacedim> *mapping = nullptr) const;
1400
1404 void
1405 set_flags(const GridOutFlags::DX &flags);
1406
1410 void
1411 set_flags(const GridOutFlags::Msh &flags);
1412
1416 void
1417 set_flags(const GridOutFlags::Ucd &flags);
1418
1422 void
1423 set_flags(const GridOutFlags::Gnuplot &flags);
1424
1428 void
1429 set_flags(const GridOutFlags::Eps<1> &flags);
1430
1434 void
1435 set_flags(const GridOutFlags::Eps<2> &flags);
1436
1440 void
1441 set_flags(const GridOutFlags::Eps<3> &flags);
1442
1446 void
1447 set_flags(const GridOutFlags::XFig &flags);
1448
1452 void
1453 set_flags(const GridOutFlags::Svg &flags);
1454
1458 void
1459 set_flags(const GridOutFlags::MathGL &flags);
1460
1464 void
1465 set_flags(const GridOutFlags::Vtk &flags);
1466
1470 void
1471 set_flags(const GridOutFlags::Vtu &flags);
1472
1487 static std::string
1488 default_suffix(const OutputFormat output_format);
1489
1494 std::string
1495 default_suffix() const;
1496
1510 static OutputFormat
1511 parse_output_format(const std::string &format_name);
1512
1518 static std::string
1520
1524 static void
1526
1530 void
1532
1537 std::size_t
1538 memory_consumption() const;
1539
1544
1545private:
1550
1555
1561
1567
1573
1579
1585
1591
1596
1601
1606
1611
1616
1642 template <int dim, int spacedim>
1643 unsigned int
1645 const unsigned int next_element_index,
1646 std::ostream &out) const;
1647
1651 unsigned int
1653 const unsigned int next_element_index,
1654 std::ostream &out) const;
1659 unsigned int
1661 const unsigned int next_element_index,
1662 std::ostream &out) const;
1663 unsigned int
1665 const unsigned int next_element_index,
1666 std::ostream &out) const;
1667
1668
1669
1695 template <int dim, int spacedim>
1696 unsigned int
1698 const unsigned int next_element_index,
1699 std::ostream &out) const;
1700
1704 unsigned int
1706 const unsigned int next_element_index,
1707 std::ostream &out) const;
1708
1713 unsigned int
1715 const unsigned int next_element_index,
1716 std::ostream &out) const;
1717
1722 unsigned int
1724 const unsigned int next_element_index,
1725 std::ostream &out) const;
1729 unsigned int
1731 const unsigned int next_element_index,
1732 std::ostream &out) const;
1737 unsigned int
1739 const unsigned int next_element_index,
1740 std::ostream &out) const;
1741
1767 template <int dim, int spacedim>
1768 unsigned int
1770 const unsigned int next_element_index,
1771 std::ostream &out) const;
1772
1776 unsigned int
1778 const unsigned int next_element_index,
1779 std::ostream &out) const;
1780
1785 unsigned int
1787 const unsigned int next_element_index,
1788 std::ostream &out) const;
1789 unsigned int
1791 const unsigned int next_element_index,
1792 std::ostream &out) const;
1793
1794
1820 template <int dim, int spacedim>
1821 unsigned int
1823 const unsigned int next_element_index,
1824 std::ostream &out) const;
1825
1829 unsigned int
1831 const unsigned int next_element_index,
1832 std::ostream &out) const;
1837 unsigned int
1839 const unsigned int next_element_index,
1840 std::ostream &out) const;
1845 unsigned int
1847 const unsigned int next_element_index,
1848 std::ostream &out) const;
1849
1850
1854 unsigned int
1856 const unsigned int next_element_index,
1857 std::ostream &out) const;
1862 unsigned int
1864 const unsigned int next_element_index,
1865 std::ostream &out) const;
1866
1867
1880 template <int dim, int spacedim>
1881 unsigned int
1883
1888 unsigned int
1889 n_boundary_faces(const Triangulation<1, 1> &tria) const;
1890
1895 unsigned int
1896 n_boundary_faces(const Triangulation<1, 2> &tria) const;
1897
1902 unsigned int
1903 n_boundary_faces(const Triangulation<1, 3> &tria) const;
1904
1917 template <int dim, int spacedim>
1918 unsigned int
1920
1925 unsigned int
1926 n_boundary_lines(const Triangulation<1, 1> &tria) const;
1927
1932 unsigned int
1933 n_boundary_lines(const Triangulation<1, 2> &tria) const;
1934
1939 unsigned int
1940 n_boundary_lines(const Triangulation<1, 3> &tria) const;
1941
1946 unsigned int
1947 n_boundary_lines(const Triangulation<2, 2> &tria) const;
1952 unsigned int
1953 n_boundary_lines(const Triangulation<2, 3> &tria) const;
1954};
1955
1956
1957
1959
1960#endif
unsigned int n_boundary_faces(const Triangulation< dim, spacedim > &tria) const
Definition grid_out.cc:3779
GridOutFlags::Vtu vtu_flags
Definition grid_out.h:1615
GridOutFlags::Eps< 2 > eps_flags_2
Definition grid_out.h:1584
unsigned int write_ucd_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:4100
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:700
void write_svg(const Triangulation< 2, 2 > &tria, std::ostream &out) const
Definition grid_out.cc:1702
void set_flags(const GridOutFlags::DX &flags)
Definition grid_out.cc:471
GridOutFlags::Eps< 1 > eps_flags_1
Definition grid_out.h:1578
GridOutFlags::XFig xfig_flags
Definition grid_out.h:1595
unsigned int write_ucd_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:4058
void write_mathgl(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:2982
std::string default_suffix() const
Definition grid_out.cc:593
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:651
static OutputFormat parse_output_format(const std::string &format_name)
Definition grid_out.cc:601
void write_vtk(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:3305
GridOutFlags::Gnuplot gnuplot_flags
Definition grid_out.h:1572
void write_msh(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:1021
unsigned int write_msh_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:3938
void write_eps(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:5124
static std::string get_output_format_names()
Definition grid_out.cc:644
GridOutFlags::Eps< 3 > eps_flags_3
Definition grid_out.h:1590
void write(const Triangulation< dim, spacedim > &tria, std::ostream &out, const OutputFormat output_format, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:5134
void write_vtu(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:3544
GridOutFlags::Ucd ucd_flags
Definition grid_out.h:1566
void write_dx(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:781
std::size_t memory_consumption() const
Definition grid_out.cc:746
unsigned int n_boundary_lines(const Triangulation< dim, spacedim > &tria) const
Definition grid_out.cc:3795
GridOutFlags::DX dx_flags
Definition grid_out.h:1554
unsigned int write_msh_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:3899
void write_ucd(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:1126
GridOutFlags::Svg svg_flags
Definition grid_out.h:1600
OutputFormat default_format
Definition grid_out.h:1549
void write_xfig(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:1243
void write_gnuplot(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:4608
GridOutFlags::Vtk vtk_flags
Definition grid_out.h:1610
GridOutFlags::Msh msh_flags
Definition grid_out.h:1560
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
Definition grid_out.cc:3591
@ vtk
write() calls write_vtk()
Definition grid_out.h:1021
@ eps
write() calls write_eps()
Definition grid_out.h:1009
@ msh
write() calls write_msh()
Definition grid_out.h:1015
@ xfig
write() calls write_xfig()
Definition grid_out.h:1013
@ dx
write() calls write_dx()
Definition grid_out.h:1005
@ ucd
write() calls write_ucd()
Definition grid_out.h:1011
@ gnuplot
write() calls write_gnuplot()
Definition grid_out.h:1007
@ mathgl
write() calls write_mathgl()
Definition grid_out.h:1019
@ svg
write() calls write_svg()
Definition grid_out.h:1017
@ none
Do nothing in write()
Definition grid_out.h:1003
@ vtu
write() calls write_vtu()
Definition grid_out.h:1023
GridOutFlags::MathGL mathgl_flags
Definition grid_out.h:1605
Abstract base class for mapping classes.
Definition mapping.h:318
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:175
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#define DeclException0(Exception0)
Definition exceptions.h:466
static ::ExceptionBase & ExcInvalidState()
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:66
bool write_all_faces
Definition grid_out.h:82
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:94
bool write_diameter
Definition grid_out.h:71
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:198
unsigned int n_boundary_face_points
Definition grid_out.h:362
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:231
unsigned int n_extra_curved_line_points
Definition grid_out.h:253
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:175
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:167
bool write_additional_boundary_lines
Definition grid_out.h:272
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:457
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:451
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:118
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:110
bool label_level_number
Definition grid_out.h:759
unsigned int height
Definition grid_out.h:661
bool label_level_subdomain_id
Definition grid_out.h:779
bool label_subdomain_id
Definition grid_out.h:774
Background background
Definition grid_out.h:708
unsigned int line_thickness
Definition grid_out.h:672
bool convert_level_number_to_height
Definition grid_out.h:744
float cell_font_scaling
Definition grid_out.h:755
Coloring coloring
Definition grid_out.h:740
@ level_subdomain_id
Convert the level subdomain id into the cell color.
Definition grid_out.h:737
@ subdomain_id
Convert the subdomain id into the cell color.
Definition grid_out.h:735
@ none
No cell coloring.
Definition grid_out.h:729
@ material_id
Convert the material id into the cell color (default)
Definition grid_out.h:731
@ level_number
Convert the level number into the cell color.
Definition grid_out.h:733
unsigned int width
Definition grid_out.h:667
unsigned int boundary_line_thickness
Definition grid_out.h:676
float level_height_factor
Definition grid_out.h:750
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:136
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:145
Vtk(const bool output_cells=true, const bool output_faces=true, const bool output_edges=true, const bool output_only_relevant=true)
Definition grid_out.h:864
bool output_only_relevant
Definition grid_out.h:893
bool serialize_triangulation
Definition grid_out.h:914
Vtu(const bool serialize_triangulation=false)
Definition grid_out.h:907
unsigned int n_boundary_face_points
Definition grid_out.h:582
Point< 2 > scaling
Definition grid_out.h:587
@ level_number
Convert the level into the cell color.
Definition grid_out.h:564
@ material_id
Convert the material id into the cell color.
Definition grid_out.h:562
@ level_subdomain_id
Convert the level subdomain id into the cell color.
Definition grid_out.h:568
@ subdomain_id
Convert the global subdomain id into the cell color.
Definition grid_out.h:566
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:397
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:381
Point< 2 > offset
Definition grid_out.h:593
enum GridOutFlags::XFig::Coloring color_by