Reference documentation for deal.II version 9.2.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\}}\)
grid_out.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2020 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
33 class ParameterHandler;
34 template <int dim, int spacedim>
35 class Triangulation;
36 template <int dim, int spacedim>
37 class Mapping;
38 #endif
39 
40 
49 namespace 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 
266 
272 
285 
289  Gnuplot(const bool write_cell_number = false,
290  const unsigned int n_extra_curved_line_points = 2,
291  const bool curved_inner_cells = false,
292  const bool write_additional_boundary_lines = true);
293 
298  Gnuplot(const Gnuplot &flags);
299 
304  Gnuplot &
305  operator=(const Gnuplot &flags);
306 
310  static void
312 
316  void
318  };
319 
332  {
338  enum SizeType
339  {
347  height
348  };
349 
354 
362  unsigned int size;
363 
367  double line_width;
368 
376 
388 
396 
400  EpsFlagsBase(const SizeType size_type = width,
401  const unsigned int size = 300,
402  const double line_width = 0.5,
403  const bool color_lines_on_user_flag = false,
404  const unsigned int n_boundary_face_points = 2,
405  const bool color_lines_level = false);
409  static void
411 
415  void
417  };
418 
419 
430  template <int dim>
431  struct Eps
432  {};
433 
439  template <>
440  struct Eps<1> : public EpsFlagsBase
441  {
445  Eps(const SizeType size_type = width,
446  const unsigned int size = 300,
447  const double line_width = 0.5,
448  const bool color_lines_on_user_flag = false,
449  const unsigned int n_boundary_face_points = 2);
453  static void
455 
459  void
461  };
462 
463 
469  template <>
470  struct Eps<2> : public EpsFlagsBase
471  {
489 
495 
499  Eps(const SizeType size_type = width,
500  const unsigned int size = 300,
501  const double line_width = 0.5,
502  const bool color_lines_on_user_flag = false,
503  const unsigned int n_boundary_face_points = 2,
504  const bool write_cell_numbers = false,
505  const bool write_cell_number_level = true,
506  const bool write_vertex_numbers = false,
507  const bool color_lines_level = false);
511  static void
513 
517  void
519  };
520 
526  template <>
527  struct Eps<3> : public EpsFlagsBase
528  {
534  double azimut_angle;
535 
544  double turn_angle;
545 
549  Eps(const SizeType size_type = width,
550  const unsigned int size = 300,
551  const double line_width = 0.5,
552  const bool color_lines_on_user_flag = false,
553  const unsigned int n_boundary_face_points = 2,
554  const double azimut_angle = 60,
555  const double turn_angle = 30);
559  static void
561 
565  void
567  };
568 
574  struct XFig
575  {
580 
584  enum Coloring
585  {
593  level_subdomain_id
594  } color_by;
595 
603 
608 
613 
619 
626 
632 
639 
644 
649 
653  XFig();
657  static void
659 
663  void
665  };
666 
667 
680  struct Svg
681  {
686  unsigned int height;
687 
692  unsigned int width;
693 
697  unsigned int line_thickness;
702 
706  bool margin;
707 
712  {
717 
722 
728  };
729 
734 
735  // View angles for the perspective view of the grid; Default is 0, 0 (top
736  // view).
737 
742 
747 
751  enum Coloring
752  {
762  level_subdomain_id
763  };
764 
766 
770 
776 
785 
790 
795 
800 
805 
814 
820 
826 
830  Svg(const unsigned int line_thickness = 2,
831  const unsigned int boundary_line_thickness = 4,
832  const bool margin = true,
833  const Background background = white,
834  const int azimuth_angle = 0,
835  const int polar_angle = 0,
836  const Coloring coloring = level_number,
837  const bool convert_level_number_to_height = false,
838  const bool label_level_number = false,
839  const bool label_cell_index = false,
840  const bool label_material_id = false,
841  const bool label_subdomain_id = false,
842  const bool draw_colorbar = false,
843  const bool draw_legend = false,
844  const bool label_boundary_id = false);
845  };
846 
852  struct MathGL
853  {
857  MathGL();
858 
863 
867  static void
869 
873  void
875  };
876 
877 
884  struct Vtk : public DataOutBase::VtkFlags
885  {
889  Vtk(const bool output_cells = true,
890  const bool output_faces = true,
891  const bool output_edges = true,
892  const bool output_only_relevant = true)
893  : output_cells(output_cells)
894  , output_faces(output_faces)
895  , output_edges(output_edges)
896  , output_only_relevant(output_only_relevant)
897  {}
898 
903 
908 
913 
919  };
920 
921 
930  struct Vtu : public DataOutBase::VtkFlags
931  {
932  Vtu(const bool serialize_triangulation = false)
933  : serialize_triangulation(serialize_triangulation)
934  {}
935 
940  };
941 } // namespace GridOutFlags
942 
943 
944 
1020 class GridOut
1021 {
1022 public:
1029  {
1052  };
1053 
1057  GridOut();
1058 
1067  template <int dim, int spacedim>
1068  void
1069  write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1070 
1101  template <int dim, int spacedim>
1102  void
1104  std::ostream & out,
1105  const Mapping<dim, spacedim> * mapping = nullptr) const;
1106 
1125  template <int dim, int spacedim>
1126  void
1127  write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1128 
1148  template <int dim, int spacedim>
1149  void
1150  write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1151 
1181  template <int dim, int spacedim>
1182  void
1184  std::ostream & out,
1185  const Mapping<dim, spacedim> * mapping = nullptr) const;
1186 
1205  template <int dim, int spacedim>
1206  void
1207  write_xfig(const Triangulation<dim, spacedim> &tria,
1208  std::ostream & out,
1209  const Mapping<dim, spacedim> * mapping = nullptr) const;
1210 
1231  void
1232  write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1233 
1239  template <int dim, int spacedim>
1240  void
1241  write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1242 
1243 
1258  template <int dim, int spacedim>
1259  void
1260  write_mathgl(const Triangulation<dim, spacedim> &tria,
1261  std::ostream & out) const;
1262 
1301  template <int dim, int spacedim>
1302  void
1303  write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1304 
1322  template <int dim, int spacedim>
1323  void
1324  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1325 
1356  template <int dim, int spacedim>
1357  void
1358  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1359  const std::string &filename_without_extension,
1360  const bool view_levels = false,
1361  const bool include_artificial = false) const;
1362 
1367  template <int dim, int spacedim>
1368  void
1369  write(const Triangulation<dim, spacedim> &tria,
1370  std::ostream & out,
1371  const OutputFormat output_format,
1372  const Mapping<dim, spacedim> * mapping = nullptr) const;
1373 
1377  template <int dim, int spacedim>
1378  void
1379  write(const Triangulation<dim, spacedim> &tria,
1380  std::ostream & out,
1381  const Mapping<dim, spacedim> * mapping = nullptr) const;
1382 
1386  void
1387  set_flags(const GridOutFlags::DX &flags);
1388 
1392  void
1393  set_flags(const GridOutFlags::Msh &flags);
1394 
1398  void
1399  set_flags(const GridOutFlags::Ucd &flags);
1400 
1404  void
1405  set_flags(const GridOutFlags::Gnuplot &flags);
1406 
1410  void
1411  set_flags(const GridOutFlags::Eps<1> &flags);
1412 
1416  void
1417  set_flags(const GridOutFlags::Eps<2> &flags);
1418 
1422  void
1423  set_flags(const GridOutFlags::Eps<3> &flags);
1424 
1428  void
1429  set_flags(const GridOutFlags::XFig &flags);
1430 
1434  void
1435  set_flags(const GridOutFlags::Svg &flags);
1436 
1440  void
1441  set_flags(const GridOutFlags::MathGL &flags);
1442 
1446  void
1447  set_flags(const GridOutFlags::Vtk &flags);
1448 
1452  void
1453  set_flags(const GridOutFlags::Vtu &flags);
1454 
1469  static std::string
1470  default_suffix(const OutputFormat output_format);
1471 
1476  std::string
1477  default_suffix() const;
1478 
1492  static OutputFormat
1493  parse_output_format(const std::string &format_name);
1494 
1500  static std::string
1502 
1506  static void
1508 
1512  void
1514 
1519  std::size_t
1520  memory_consumption() const;
1521 
1526 
1527 private:
1532 
1537 
1543 
1549 
1555 
1561 
1567 
1573 
1578 
1583 
1588 
1593 
1598 
1624  template <int dim, int spacedim>
1625  unsigned int
1626  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1627  const unsigned int next_element_index,
1628  std::ostream & out) const;
1629 
1633  unsigned int
1634  write_msh_faces(const Triangulation<1, 1> &tria,
1635  const unsigned int next_element_index,
1636  std::ostream & out) const;
1641  unsigned int
1642  write_msh_faces(const Triangulation<1, 2> &tria,
1643  const unsigned int next_element_index,
1644  std::ostream & out) const;
1645  unsigned int
1646  write_msh_faces(const Triangulation<1, 3> &tria,
1647  const unsigned int next_element_index,
1648  std::ostream & out) const;
1649 
1650 
1651 
1677  template <int dim, int spacedim>
1678  unsigned int
1679  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1680  const unsigned int next_element_index,
1681  std::ostream & out) const;
1682 
1686  unsigned int
1687  write_msh_lines(const Triangulation<1, 1> &tria,
1688  const unsigned int next_element_index,
1689  std::ostream & out) const;
1690 
1695  unsigned int
1696  write_msh_lines(const Triangulation<1, 2> &tria,
1697  const unsigned int next_element_index,
1698  std::ostream & out) const;
1699 
1704  unsigned int
1705  write_msh_lines(const Triangulation<1, 3> &tria,
1706  const unsigned int next_element_index,
1707  std::ostream & out) const;
1711  unsigned int
1712  write_msh_lines(const Triangulation<2, 2> &tria,
1713  const unsigned int next_element_index,
1714  std::ostream & out) const;
1719  unsigned int
1720  write_msh_lines(const Triangulation<2, 3> &tria,
1721  const unsigned int next_element_index,
1722  std::ostream & out) const;
1723 
1749  template <int dim, int spacedim>
1750  unsigned int
1751  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1752  const unsigned int next_element_index,
1753  std::ostream & out) const;
1754 
1758  unsigned int
1759  write_ucd_faces(const Triangulation<1, 1> &tria,
1760  const unsigned int next_element_index,
1761  std::ostream & out) const;
1762 
1767  unsigned int
1768  write_ucd_faces(const Triangulation<1, 2> &tria,
1769  const unsigned int next_element_index,
1770  std::ostream & out) const;
1771  unsigned int
1772  write_ucd_faces(const Triangulation<1, 3> &tria,
1773  const unsigned int next_element_index,
1774  std::ostream & out) const;
1775 
1776 
1802  template <int dim, int spacedim>
1803  unsigned int
1804  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1805  const unsigned int next_element_index,
1806  std::ostream & out) const;
1807 
1811  unsigned int
1812  write_ucd_lines(const Triangulation<1, 1> &tria,
1813  const unsigned int next_element_index,
1814  std::ostream & out) const;
1819  unsigned int
1820  write_ucd_lines(const Triangulation<1, 2> &tria,
1821  const unsigned int next_element_index,
1822  std::ostream & out) const;
1827  unsigned int
1828  write_ucd_lines(const Triangulation<1, 3> &tria,
1829  const unsigned int next_element_index,
1830  std::ostream & out) const;
1831 
1832 
1836  unsigned int
1837  write_ucd_lines(const Triangulation<2, 2> &tria,
1838  const unsigned int next_element_index,
1839  std::ostream & out) const;
1844  unsigned int
1845  write_ucd_lines(const Triangulation<2, 3> &tria,
1846  const unsigned int next_element_index,
1847  std::ostream & out) const;
1848 
1849 
1862  template <int dim, int spacedim>
1863  unsigned int
1864  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1865 
1870  unsigned int
1871  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1872 
1877  unsigned int
1878  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1879 
1884  unsigned int
1885  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1886 
1899  template <int dim, int spacedim>
1900  unsigned int
1901  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1902 
1907  unsigned int
1908  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1909 
1914  unsigned int
1915  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1916 
1921  unsigned int
1922  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1923 
1928  unsigned int
1929  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1934  unsigned int
1935  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1936 };
1937 
1938 
1939 
1941 
1942 #endif
void write_ucd(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 UcdFlags &flags, std::ostream &out)
OutputFormat default_format
Definition: grid_out.h:1531
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)
Definition: grid_out.cc:49
bool serialize_triangulation
Definition: grid_out.h:939
types::global_dof_index size_type
Definition: cuda_kernels.h:45
bool write_cells
Definition: grid_out.h:61
write() calls write_dx()
Definition: grid_out.h:1033
bool write_additional_boundary_lines
Definition: grid_out.h:284
Coloring coloring
Definition: grid_out.h:765
unsigned int n_boundary_face_points
Definition: grid_out.h:607
No cell coloring.
Definition: grid_out.h:754
GridOutFlags::Eps< 2 > eps_flags_2
Definition: grid_out.h:1566
unsigned int height
Definition: grid_out.h:686
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)
OutputFormat
Definition: grid_out.h:1028
Convert the level number into the cell color.
Definition: grid_out.h:758
write() calls write_eps()
Definition: grid_out.h:1037
unsigned int line_thickness
Definition: grid_out.h:697
bool convert_level_number_to_height
Definition: grid_out.h:769
bool write_diameter
Definition: grid_out.h:71
unsigned int boundary_line_thickness
Definition: grid_out.h:701
bool label_boundary_id
Definition: grid_out.h:813
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 parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:90
unsigned int n_extra_curved_line_points
Definition: grid_out.h:253
bool write_all_faces
Definition: grid_out.h:82
write() calls write_ucd()
Definition: grid_out.h:1039
bool output_only_relevant
Definition: grid_out.h:918
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)
GridOutFlags::Vtk vtk_flags
Definition: grid_out.h:1592
Point< 2 > scaling
Definition: grid_out.h:612
bool label_cell_index
Definition: grid_out.h:789
GridOutFlags::Gnuplot gnuplot_flags
Definition: grid_out.h:1554
std::string default_suffix(const OutputFormat output_format)
static ::ExceptionBase & ExcInvalidState()
Convert the global subdomain id into the cell color.
Definition: grid_out.h:591
unsigned int & n_boundary_face_points
Definition: grid_out.h:265
Convert the material id into the cell color.
Definition: grid_out.h:587
GridOutFlags::MathGL mathgl_flags
Definition: grid_out.h:1587
write() calls write_mathgl()
Definition: grid_out.h:1047
GridOutFlags::DX dx_flags
Definition: grid_out.h:1536
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1542
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1560
write() calls write_gnuplot()
Definition: grid_out.h:1035
bool label_material_id
Definition: grid_out.h:794
Abstract base class for mapping classes.
Definition: mapping.h:302
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:889
GridOutFlags::XFig xfig_flags
Definition: grid_out.h:1577
bool label_subdomain_id
Definition: grid_out.h:799
#define DeclException0(Exception0)
Definition: exceptions.h:473
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
OutputFormat parse_output_format(const std::string &format_name)
bool label_level_subdomain_id
Definition: grid_out.h:804
void write_svg(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 SvgFlags &flags, std::ostream &out)
void write_dx(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 DXFlags &flags, std::ostream &out)
Convert the subdomain id into the cell color.
Definition: grid_out.h:760
GridOutFlags::Ucd ucd_flags
Definition: grid_out.h:1548
Background background
Definition: grid_out.h:733
Do nothing in write()
Definition: grid_out.h:1031
float cell_font_scaling
Definition: grid_out.h:780
write() calls write_xfig()
Definition: grid_out.h:1041
bool write_faces
Definition: grid_out.h:66
Convert the level into the cell color.
Definition: grid_out.h:589
unsigned int n_boundary_face_points
Definition: grid_out.h:387
Point< 2 > offset
Definition: grid_out.h:618
write() calls write_msh()
Definition: grid_out.h:1043
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
write() calls write_svg()
Definition: grid_out.h:1045
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1582
bool write_measure
Definition: grid_out.h:76
void write_vtk(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)
Convert the material id into the cell color (default)
Definition: grid_out.h:756
float level_height_factor
Definition: grid_out.h:775
GridOutFlags::Eps< 3 > eps_flags_3
Definition: grid_out.h:1572
Vtu(const bool serialize_triangulation=false)
Definition: grid_out.h:932
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:62
bool label_level_number
Definition: grid_out.h:784
std::string get_output_format_names()
#define DEAL_II_DEPRECATED
Definition: config.h:98
GridOutFlags::Vtu vtu_flags
Definition: grid_out.h:1597
unsigned int width
Definition: grid_out.h:692
write() calls write_vtk()
Definition: grid_out.h:1049
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)