Reference documentation for deal.II version Git 08727cc441 2020-07-02 15:45:42 -0400
\(\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 
1017 class GridOut
1018 {
1019 public:
1026  {
1049  };
1050 
1054  GridOut();
1055 
1064  template <int dim, int spacedim>
1065  void
1066  write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1067 
1098  template <int dim, int spacedim>
1099  void
1101  std::ostream & out,
1102  const Mapping<dim, spacedim> * mapping = nullptr) const;
1103 
1122  template <int dim, int spacedim>
1123  void
1124  write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1125 
1145  template <int dim, int spacedim>
1146  void
1147  write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1148 
1178  template <int dim, int spacedim>
1179  void
1181  std::ostream & out,
1182  const Mapping<dim, spacedim> * mapping = nullptr) const;
1183 
1202  template <int dim, int spacedim>
1203  void
1204  write_xfig(const Triangulation<dim, spacedim> &tria,
1205  std::ostream & out,
1206  const Mapping<dim, spacedim> * mapping = nullptr) const;
1207 
1228  void
1229  write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1230 
1236  template <int dim, int spacedim>
1237  void
1238  write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1239 
1240 
1255  template <int dim, int spacedim>
1256  void
1257  write_mathgl(const Triangulation<dim, spacedim> &tria,
1258  std::ostream & out) const;
1259 
1296  template <int dim, int spacedim>
1297  void
1298  write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1299 
1317  template <int dim, int spacedim>
1318  void
1319  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1320 
1351  template <int dim, int spacedim>
1352  void
1353  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1354  const std::string &filename_without_extension,
1355  const bool view_levels = false,
1356  const bool include_artificial = false) const;
1357 
1362  template <int dim, int spacedim>
1363  void
1364  write(const Triangulation<dim, spacedim> &tria,
1365  std::ostream & out,
1366  const OutputFormat output_format,
1367  const Mapping<dim, spacedim> * mapping = nullptr) const;
1368 
1372  template <int dim, int spacedim>
1373  void
1374  write(const Triangulation<dim, spacedim> &tria,
1375  std::ostream & out,
1376  const Mapping<dim, spacedim> * mapping = nullptr) const;
1377 
1381  void
1382  set_flags(const GridOutFlags::DX &flags);
1383 
1387  void
1388  set_flags(const GridOutFlags::Msh &flags);
1389 
1393  void
1394  set_flags(const GridOutFlags::Ucd &flags);
1395 
1399  void
1400  set_flags(const GridOutFlags::Gnuplot &flags);
1401 
1405  void
1406  set_flags(const GridOutFlags::Eps<1> &flags);
1407 
1411  void
1412  set_flags(const GridOutFlags::Eps<2> &flags);
1413 
1417  void
1418  set_flags(const GridOutFlags::Eps<3> &flags);
1419 
1423  void
1424  set_flags(const GridOutFlags::XFig &flags);
1425 
1429  void
1430  set_flags(const GridOutFlags::Svg &flags);
1431 
1435  void
1436  set_flags(const GridOutFlags::MathGL &flags);
1437 
1441  void
1442  set_flags(const GridOutFlags::Vtk &flags);
1443 
1447  void
1448  set_flags(const GridOutFlags::Vtu &flags);
1449 
1464  static std::string
1465  default_suffix(const OutputFormat output_format);
1466 
1471  std::string
1472  default_suffix() const;
1473 
1487  static OutputFormat
1488  parse_output_format(const std::string &format_name);
1489 
1495  static std::string
1497 
1501  static void
1503 
1507  void
1509 
1514  std::size_t
1515  memory_consumption() const;
1516 
1521 
1522 private:
1527 
1532 
1538 
1544 
1550 
1556 
1562 
1568 
1573 
1578 
1583 
1588 
1593 
1619  template <int dim, int spacedim>
1620  unsigned int
1621  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1622  const unsigned int next_element_index,
1623  std::ostream & out) const;
1624 
1628  unsigned int
1629  write_msh_faces(const Triangulation<1, 1> &tria,
1630  const unsigned int next_element_index,
1631  std::ostream & out) const;
1636  unsigned int
1637  write_msh_faces(const Triangulation<1, 2> &tria,
1638  const unsigned int next_element_index,
1639  std::ostream & out) const;
1640  unsigned int
1641  write_msh_faces(const Triangulation<1, 3> &tria,
1642  const unsigned int next_element_index,
1643  std::ostream & out) const;
1644 
1645 
1646 
1672  template <int dim, int spacedim>
1673  unsigned int
1674  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1675  const unsigned int next_element_index,
1676  std::ostream & out) const;
1677 
1681  unsigned int
1682  write_msh_lines(const Triangulation<1, 1> &tria,
1683  const unsigned int next_element_index,
1684  std::ostream & out) const;
1685 
1690  unsigned int
1691  write_msh_lines(const Triangulation<1, 2> &tria,
1692  const unsigned int next_element_index,
1693  std::ostream & out) const;
1694 
1699  unsigned int
1700  write_msh_lines(const Triangulation<1, 3> &tria,
1701  const unsigned int next_element_index,
1702  std::ostream & out) const;
1706  unsigned int
1707  write_msh_lines(const Triangulation<2, 2> &tria,
1708  const unsigned int next_element_index,
1709  std::ostream & out) const;
1714  unsigned int
1715  write_msh_lines(const Triangulation<2, 3> &tria,
1716  const unsigned int next_element_index,
1717  std::ostream & out) const;
1718 
1744  template <int dim, int spacedim>
1745  unsigned int
1746  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1747  const unsigned int next_element_index,
1748  std::ostream & out) const;
1749 
1753  unsigned int
1754  write_ucd_faces(const Triangulation<1, 1> &tria,
1755  const unsigned int next_element_index,
1756  std::ostream & out) const;
1757 
1762  unsigned int
1763  write_ucd_faces(const Triangulation<1, 2> &tria,
1764  const unsigned int next_element_index,
1765  std::ostream & out) const;
1766  unsigned int
1767  write_ucd_faces(const Triangulation<1, 3> &tria,
1768  const unsigned int next_element_index,
1769  std::ostream & out) const;
1770 
1771 
1797  template <int dim, int spacedim>
1798  unsigned int
1799  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1800  const unsigned int next_element_index,
1801  std::ostream & out) const;
1802 
1806  unsigned int
1807  write_ucd_lines(const Triangulation<1, 1> &tria,
1808  const unsigned int next_element_index,
1809  std::ostream & out) const;
1814  unsigned int
1815  write_ucd_lines(const Triangulation<1, 2> &tria,
1816  const unsigned int next_element_index,
1817  std::ostream & out) const;
1822  unsigned int
1823  write_ucd_lines(const Triangulation<1, 3> &tria,
1824  const unsigned int next_element_index,
1825  std::ostream & out) const;
1826 
1827 
1831  unsigned int
1832  write_ucd_lines(const Triangulation<2, 2> &tria,
1833  const unsigned int next_element_index,
1834  std::ostream & out) const;
1839  unsigned int
1840  write_ucd_lines(const Triangulation<2, 3> &tria,
1841  const unsigned int next_element_index,
1842  std::ostream & out) const;
1843 
1844 
1857  template <int dim, int spacedim>
1858  unsigned int
1859  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1860 
1865  unsigned int
1866  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1867 
1872  unsigned int
1873  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1874 
1879  unsigned int
1880  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1881 
1894  template <int dim, int spacedim>
1895  unsigned int
1896  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1897 
1902  unsigned int
1903  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1904 
1909  unsigned int
1910  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1911 
1916  unsigned int
1917  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1918 
1923  unsigned int
1924  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1929  unsigned int
1930  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1931 };
1932 
1933 
1934 
1936 
1937 #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:1526
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:1030
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:1561
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:1025
Convert the level number into the cell color.
Definition: grid_out.h:758
write() calls write_eps()
Definition: grid_out.h:1034
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:1036
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:1587
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:1549
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:1582
write() calls write_mathgl()
Definition: grid_out.h:1044
GridOutFlags::DX dx_flags
Definition: grid_out.h:1531
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1537
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1555
write() calls write_gnuplot()
Definition: grid_out.h:1032
bool label_material_id
Definition: grid_out.h:794
Abstract base class for mapping classes.
Definition: mapping.h:301
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:1572
bool label_subdomain_id
Definition: grid_out.h:799
#define DeclException0(Exception0)
Definition: exceptions.h:470
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
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:1543
Background background
Definition: grid_out.h:733
Do nothing in write()
Definition: grid_out.h:1028
float cell_font_scaling
Definition: grid_out.h:780
write() calls write_xfig()
Definition: grid_out.h:1038
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:1040
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
write() calls write_svg()
Definition: grid_out.h:1042
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1577
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:1567
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:152
GridOutFlags::Vtu vtu_flags
Definition: grid_out.h:1592
unsigned int width
Definition: grid_out.h:692
write() calls write_vtk()
Definition: grid_out.h:1046
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)