Reference documentation for deal.II version 9.5.0
\(\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// Copyright (C) 1999 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_grid_out_h
17#define dealii_grid_out_h
18
19
20
21#include <deal.II/base/config.h>
22
25#include <deal.II/base/point.h>
26
27#include <string>
28
30
31// Forward declarations
32#ifndef DOXYGEN
34template <int dim, int spacedim>
36class Triangulation;
37template <int dim, int spacedim>
38class Mapping;
39#endif
40
41
50namespace GridOutFlags
51{
57 struct DX
58 {
63
68
73
78
84
88 DX(const bool write_cells = true,
89 const bool write_faces = false,
90 const bool write_diameter = false,
91 const bool write_measure = false,
92 const bool write_all_faces = true);
93
97 static void
99
103 void
105 };
106
112 struct Msh
113 {
142
146 Msh(const bool write_faces = false, const bool write_lines = false);
150 static void
152
156 void
158 };
159
160
166 struct Ucd
167 {
178
192
208
212 Ucd(const bool write_preamble = false,
213 const bool write_faces = false,
214 const bool write_lines = false);
215
219 static void
221
225 void
227 };
228
229
235 struct Gnuplot
236 {
247
255
261
274
278 Gnuplot(const bool write_cell_number = false,
279 const unsigned int n_extra_curved_line_points = 2,
280 const bool curved_inner_cells = false,
281 const bool write_additional_boundary_lines = true);
282
286 static void
288
292 void
294 };
295
308 {
315 {
323 height
324 };
325
330
338 unsigned int size;
339
344
352
364
372
377 const unsigned int size = 300,
378 const double line_width = 0.5,
379 const bool color_lines_on_user_flag = false,
380 const unsigned int n_boundary_face_points = 2,
381 const bool color_lines_level = false);
385 static void
387
391 void
393 };
394
395
406 template <int dim>
407 struct Eps
408 {};
409
415 template <>
416 struct Eps<1> : public EpsFlagsBase
417 {
421 Eps(const SizeType size_type = width,
422 const unsigned int size = 300,
423 const double line_width = 0.5,
424 const bool color_lines_on_user_flag = false,
425 const unsigned int n_boundary_face_points = 2);
429 static void
430 declare_parameters(ParameterHandler &param);
431
435 void
436 parse_parameters(ParameterHandler &param);
437 };
438
439
445 template <>
446 struct Eps<2> : public EpsFlagsBase
447 {
465
471
475 Eps(const SizeType size_type = width,
476 const unsigned int size = 300,
477 const double line_width = 0.5,
478 const bool color_lines_on_user_flag = false,
479 const unsigned int n_boundary_face_points = 2,
480 const bool write_cell_numbers = false,
481 const bool write_cell_number_level = true,
482 const bool write_vertex_numbers = false,
483 const bool color_lines_level = false);
487 static void
488 declare_parameters(ParameterHandler &param);
489
493 void
494 parse_parameters(ParameterHandler &param);
495 };
496
502 template <>
503 struct Eps<3> : public EpsFlagsBase
504 {
511
521
525 Eps(const SizeType size_type = width,
526 const unsigned int size = 300,
527 const double line_width = 0.5,
528 const bool color_lines_on_user_flag = false,
529 const unsigned int n_boundary_face_points = 2,
530 const double azimut_angle = 60,
531 const double turn_angle = 30);
535 static void
536 declare_parameters(ParameterHandler &param);
537
541 void
542 parse_parameters(ParameterHandler &param);
543 };
544
550 struct XFig
551 {
556
561 {
571
579
584
589
595
602
608
615
620
625
629 XFig();
633 static void
635
639 void
641 };
642
643
656 struct Svg
657 {
662 unsigned int height;
663
668 unsigned int width;
669
673 unsigned int line_thickness;
678
682 bool margin;
683
688 {
693
698
703 dealii
704 };
705
710
711 // View angles for the perspective view of the grid; Default is 0, 0 (top
712 // view).
713
718
723
728 {
739 };
740
742
746
752
761
766
771
776
781
790
796
802
806 Svg(const unsigned int line_thickness = 2,
807 const unsigned int boundary_line_thickness = 4,
808 const bool margin = true,
810 const int azimuth_angle = 0,
811 const int polar_angle = 0,
813 const bool convert_level_number_to_height = false,
814 const bool label_level_number = false,
815 const bool label_cell_index = false,
816 const bool label_material_id = false,
817 const bool label_subdomain_id = false,
818 const bool draw_colorbar = false,
819 const bool draw_legend = false,
820 const bool label_boundary_id = false);
821 };
822
828 struct MathGL
829 {
833 MathGL();
834
839
843 static void
845
849 void
851 };
852
853
861 {
865 Vtk(const bool output_cells = true,
866 const bool output_faces = true,
867 const bool output_edges = true,
868 const bool output_only_relevant = true)
873 {}
874
879
884
889
895 };
896
897
907 {
908 Vtu(const bool serialize_triangulation = false)
910 {}
911
916 };
917} // namespace GridOutFlags
918
919
920
994{
995public:
1002 {
1024 vtu
1026
1030 GridOut();
1031
1040 template <int dim, int spacedim>
1041 void
1042 write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1043
1074 template <int dim, int spacedim>
1075 void
1077 std::ostream & out,
1078 const Mapping<dim, spacedim> * mapping = nullptr) const;
1079
1098 template <int dim, int spacedim>
1099 void
1100 write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1101
1102#ifdef DEAL_II_GMSH_WITH_API
1143 template <int dim, int spacedim>
1144 void
1146 const std::string & filename) const;
1147#endif
1148
1168 template <int dim, int spacedim>
1169 void
1170 write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1171
1201 template <int dim, int spacedim>
1202 void
1204 std::ostream & out,
1205 const Mapping<dim, spacedim> * mapping = nullptr) const;
1206
1225 template <int dim, int spacedim>
1226 void
1228 std::ostream & out,
1229 const Mapping<dim, spacedim> * mapping = nullptr) const;
1230
1251 void
1252 write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1253
1259 template <int dim, int spacedim>
1260 void
1261 write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1262
1263
1278 template <int dim, int spacedim>
1279 void
1281 std::ostream & out) const;
1282
1319 template <int dim, int spacedim>
1320 void
1321 write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1322
1341 template <int dim, int spacedim>
1342 void
1343 write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1344
1375 template <int dim, int spacedim>
1376 void
1378 const std::string &filename_without_extension,
1379 const bool view_levels = false,
1380 const bool include_artificial = false) const;
1381
1386 template <int dim, int spacedim>
1387 void
1389 std::ostream & out,
1390 const OutputFormat output_format,
1391 const Mapping<dim, spacedim> * mapping = nullptr) const;
1392
1396 template <int dim, int spacedim>
1397 void
1399 std::ostream & out,
1400 const Mapping<dim, spacedim> * mapping = nullptr) const;
1401
1405 void
1406 set_flags(const GridOutFlags::DX &flags);
1407
1411 void
1412 set_flags(const GridOutFlags::Msh &flags);
1413
1417 void
1418 set_flags(const GridOutFlags::Ucd &flags);
1419
1423 void
1424 set_flags(const GridOutFlags::Gnuplot &flags);
1425
1429 void
1430 set_flags(const GridOutFlags::Eps<1> &flags);
1431
1435 void
1436 set_flags(const GridOutFlags::Eps<2> &flags);
1437
1441 void
1442 set_flags(const GridOutFlags::Eps<3> &flags);
1443
1447 void
1448 set_flags(const GridOutFlags::XFig &flags);
1449
1453 void
1454 set_flags(const GridOutFlags::Svg &flags);
1455
1459 void
1460 set_flags(const GridOutFlags::MathGL &flags);
1461
1465 void
1466 set_flags(const GridOutFlags::Vtk &flags);
1467
1471 void
1472 set_flags(const GridOutFlags::Vtu &flags);
1473
1488 static std::string
1489 default_suffix(const OutputFormat output_format);
1490
1495 std::string
1496 default_suffix() const;
1497
1511 static OutputFormat
1512 parse_output_format(const std::string &format_name);
1513
1519 static std::string
1521
1525 static void
1527
1531 void
1533
1538 std::size_t
1539 memory_consumption() const;
1540
1545
1546private:
1551
1556
1562
1568
1574
1580
1586
1592
1597
1602
1607
1612
1617
1643 template <int dim, int spacedim>
1644 unsigned int
1646 const unsigned int next_element_index,
1647 std::ostream & out) const;
1648
1652 unsigned int
1654 const unsigned int next_element_index,
1655 std::ostream & out) const;
1660 unsigned int
1662 const unsigned int next_element_index,
1663 std::ostream & out) const;
1664 unsigned int
1666 const unsigned int next_element_index,
1667 std::ostream & out) const;
1668
1669
1670
1696 template <int dim, int spacedim>
1697 unsigned int
1699 const unsigned int next_element_index,
1700 std::ostream & out) const;
1701
1705 unsigned int
1707 const unsigned int next_element_index,
1708 std::ostream & out) const;
1709
1714 unsigned int
1716 const unsigned int next_element_index,
1717 std::ostream & out) const;
1718
1723 unsigned int
1725 const unsigned int next_element_index,
1726 std::ostream & out) const;
1730 unsigned int
1732 const unsigned int next_element_index,
1733 std::ostream & out) const;
1738 unsigned int
1740 const unsigned int next_element_index,
1741 std::ostream & out) const;
1742
1768 template <int dim, int spacedim>
1769 unsigned int
1771 const unsigned int next_element_index,
1772 std::ostream & out) const;
1773
1777 unsigned int
1779 const unsigned int next_element_index,
1780 std::ostream & out) const;
1781
1786 unsigned int
1788 const unsigned int next_element_index,
1789 std::ostream & out) const;
1790 unsigned int
1792 const unsigned int next_element_index,
1793 std::ostream & out) const;
1794
1795
1821 template <int dim, int spacedim>
1822 unsigned int
1824 const unsigned int next_element_index,
1825 std::ostream & out) const;
1826
1830 unsigned int
1832 const unsigned int next_element_index,
1833 std::ostream & out) const;
1838 unsigned int
1840 const unsigned int next_element_index,
1841 std::ostream & out) const;
1846 unsigned int
1848 const unsigned int next_element_index,
1849 std::ostream & out) const;
1850
1851
1855 unsigned int
1857 const unsigned int next_element_index,
1858 std::ostream & out) const;
1863 unsigned int
1865 const unsigned int next_element_index,
1866 std::ostream & out) const;
1867
1868
1881 template <int dim, int spacedim>
1882 unsigned int
1884
1889 unsigned int
1891
1896 unsigned int
1898
1903 unsigned int
1905
1918 template <int dim, int spacedim>
1919 unsigned int
1921
1926 unsigned int
1928
1933 unsigned int
1935
1940 unsigned int
1942
1947 unsigned int
1953 unsigned int
1955};
1956
1957
1958
1960
1961#endif
unsigned int n_boundary_faces(const Triangulation< dim, spacedim > &tria) const
Definition grid_out.cc:3781
GridOutFlags::Vtu vtu_flags
Definition grid_out.h:1616
GridOutFlags::Eps< 2 > eps_flags_2
Definition grid_out.h:1585
unsigned int write_ucd_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:4102
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:701
void write_svg(const Triangulation< 2, 2 > &tria, std::ostream &out) const
Definition grid_out.cc:1701
void set_flags(const GridOutFlags::DX &flags)
Definition grid_out.cc:472
GridOutFlags::Eps< 1 > eps_flags_1
Definition grid_out.h:1579
GridOutFlags::XFig xfig_flags
Definition grid_out.h:1596
unsigned int write_ucd_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:4060
void write_mathgl(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:2984
std::string default_suffix() const
Definition grid_out.cc:594
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:652
static OutputFormat parse_output_format(const std::string &format_name)
Definition grid_out.cc:602
void write_vtk(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:3307
GridOutFlags::Gnuplot gnuplot_flags
Definition grid_out.h:1573
void write_msh(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:1020
unsigned int write_msh_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:3940
void write_eps(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:5111
static std::string get_output_format_names()
Definition grid_out.cc:645
GridOutFlags::Eps< 3 > eps_flags_3
Definition grid_out.h:1591
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:5121
void write_vtu(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:3546
GridOutFlags::Ucd ucd_flags
Definition grid_out.h:1567
void write_dx(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:782
std::size_t memory_consumption() const
Definition grid_out.cc:747
unsigned int n_boundary_lines(const Triangulation< dim, spacedim > &tria) const
Definition grid_out.cc:3797
GridOutFlags::DX dx_flags
Definition grid_out.h:1555
unsigned int write_msh_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition grid_out.cc:3901
void write_ucd(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition grid_out.cc:1125
GridOutFlags::Svg svg_flags
Definition grid_out.h:1601
OutputFormat default_format
Definition grid_out.h:1550
void write_xfig(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:1242
void write_gnuplot(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition grid_out.cc:4600
GridOutFlags::Vtk vtk_flags
Definition grid_out.h:1611
GridOutFlags::Msh msh_flags
Definition grid_out.h:1561
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:3593
@ vtk
write() calls write_vtk()
Definition grid_out.h:1022
@ eps
write() calls write_eps()
Definition grid_out.h:1010
@ msh
write() calls write_msh()
Definition grid_out.h:1016
@ xfig
write() calls write_xfig()
Definition grid_out.h:1014
@ dx
write() calls write_dx()
Definition grid_out.h:1006
@ ucd
write() calls write_ucd()
Definition grid_out.h:1012
@ gnuplot
write() calls write_gnuplot()
Definition grid_out.h:1008
@ mathgl
write() calls write_mathgl()
Definition grid_out.h:1020
@ svg
write() calls write_svg()
Definition grid_out.h:1018
@ none
Do nothing in write()
Definition grid_out.h:1004
@ vtu
write() calls write_vtu()
Definition grid_out.h:1024
GridOutFlags::MathGL mathgl_flags
Definition grid_out.h:1606
Abstract base class for mapping classes.
Definition mapping.h:317
Definition point.h:112
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_CXX20_REQUIRES(condition)
Definition config.h:160
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define DeclException0(Exception0)
Definition exceptions.h:465
static ::ExceptionBase & ExcInvalidState()
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:67
bool write_all_faces
Definition grid_out.h:83
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:95
bool write_diameter
Definition grid_out.h:72
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:199
unsigned int n_boundary_face_points
Definition grid_out.h:363
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:232
unsigned int n_extra_curved_line_points
Definition grid_out.h:254
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:176
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:168
bool write_additional_boundary_lines
Definition grid_out.h:273
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:458
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:452
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:119
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:111
bool label_level_number
Definition grid_out.h:760
unsigned int height
Definition grid_out.h:662
bool label_level_subdomain_id
Definition grid_out.h:780
bool label_subdomain_id
Definition grid_out.h:775
Background background
Definition grid_out.h:709
unsigned int line_thickness
Definition grid_out.h:673
bool convert_level_number_to_height
Definition grid_out.h:745
float cell_font_scaling
Definition grid_out.h:756
Coloring coloring
Definition grid_out.h:741
@ level_subdomain_id
Convert the level subdomain id into the cell color.
Definition grid_out.h:738
@ subdomain_id
Convert the subdomain id into the cell color.
Definition grid_out.h:736
@ none
No cell coloring.
Definition grid_out.h:730
@ material_id
Convert the material id into the cell color (default)
Definition grid_out.h:732
@ level_number
Convert the level number into the cell color.
Definition grid_out.h:734
unsigned int width
Definition grid_out.h:668
unsigned int boundary_line_thickness
Definition grid_out.h:677
float level_height_factor
Definition grid_out.h:751
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:137
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:146
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:865
bool output_only_relevant
Definition grid_out.h:894
bool serialize_triangulation
Definition grid_out.h:915
Vtu(const bool serialize_triangulation=false)
Definition grid_out.h:908
unsigned int n_boundary_face_points
Definition grid_out.h:583
Point< 2 > scaling
Definition grid_out.h:588
@ level_number
Convert the level into the cell color.
Definition grid_out.h:565
@ material_id
Convert the material id into the cell color.
Definition grid_out.h:563
@ level_subdomain_id
Convert the level subdomain id into the cell color.
Definition grid_out.h:569
@ subdomain_id
Convert the global subdomain id into the cell color.
Definition grid_out.h:567
void parse_parameters(ParameterHandler &param)
Definition grid_out.cc:398
static void declare_parameters(ParameterHandler &param)
Definition grid_out.cc:382
Point< 2 > offset
Definition grid_out.h:594
enum GridOutFlags::XFig::Coloring color_by
const ::Triangulation< dim, spacedim > & tria