Reference documentation for deal.II version Git 7026f387cc 2019-10-15 14:19:01 -0400
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
grid_out.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2018 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 
23 #include <deal.II/base/data_out_base.h>
24 #include <deal.II/base/exceptions.h>
25 #include <deal.II/base/point.h>
26 
27 #include <string>
28 
29 DEAL_II_NAMESPACE_OPEN
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 
265  DEAL_II_DEPRECATED unsigned int &n_boundary_face_points;
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 
673  struct Svg
674  {
679  unsigned int height;
680 
685  unsigned int width;
686 
690  unsigned int line_thickness;
695 
699  bool margin;
700 
705  {
710 
715 
721  };
722 
727 
728  // View angles for the perspective view of the grid; Default is 0, 0 (top
729  // view).
730 
735 
740 
744  enum Coloring
745  {
755  level_subdomain_id
756  };
757 
758  Coloring coloring;
759 
763 
769 
778 
783 
788 
793 
798 
804 
810 
814  Svg(const unsigned int line_thickness = 2,
815  const unsigned int boundary_line_thickness = 4,
816  const bool margin = true,
817  const Background background = white,
818  const int azimuth_angle = 0,
819  const int polar_angle = 0,
820  const Coloring coloring = level_number,
821  const bool convert_level_number_to_height = false,
822  const bool label_level_number = false,
823  const bool label_cell_index = false,
824  const bool label_material_id = false,
825  const bool label_subdomain_id = false,
826  const bool draw_colorbar = false,
827  const bool draw_legend = false);
828  };
829 
835  struct MathGL
836  {
840  MathGL();
841 
846 
850  static void
852 
856  void
858  };
859 
860 
867  struct Vtk : public DataOutBase::VtkFlags
868  {};
869 
870 
877  struct Vtu : public DataOutBase::VtkFlags
878  {};
879 } // namespace GridOutFlags
880 
881 
882 
958 class GridOut
959 {
960 public:
967  {
971  dx,
989  vtu
990  };
991 
995  GridOut();
996 
1005  template <int dim, int spacedim>
1006  void
1007  write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1008 
1039  template <int dim, int spacedim>
1040  void
1041  write_gnuplot(const Triangulation<dim, spacedim> &tria,
1042  std::ostream & out,
1043  const Mapping<dim, spacedim> * mapping = nullptr) const;
1044 
1063  template <int dim, int spacedim>
1064  void
1065  write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1066 
1086  template <int dim, int spacedim>
1087  void
1088  write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1089 
1119  template <int dim, int spacedim>
1120  void
1121  write_eps(const Triangulation<dim, spacedim> &tria,
1122  std::ostream & out,
1123  const Mapping<dim, spacedim> * mapping = nullptr) const;
1124 
1143  template <int dim, int spacedim>
1144  void
1145  write_xfig(const Triangulation<dim, spacedim> &tria,
1146  std::ostream & out,
1147  const Mapping<dim, spacedim> * mapping = nullptr) const;
1148 
1169  void
1170  write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1171 
1177  template <int dim, int spacedim>
1178  void
1179  write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1180 
1181 
1196  template <int dim, int spacedim>
1197  void
1198  write_mathgl(const Triangulation<dim, spacedim> &tria,
1199  std::ostream & out) const;
1200 
1239  template <int dim, int spacedim>
1240  void
1241  write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1242 
1260  template <int dim, int spacedim>
1261  void
1262  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1263 
1294  template <int dim, int spacedim>
1295  void
1296  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1297  const std::string &filename_without_extension,
1298  const bool view_levels = false,
1299  const bool include_artificial = false) const;
1300 
1305  template <int dim, int spacedim>
1306  void
1307  write(const Triangulation<dim, spacedim> &tria,
1308  std::ostream & out,
1309  const OutputFormat output_format,
1310  const Mapping<dim, spacedim> * mapping = nullptr) const;
1311 
1315  template <int dim, int spacedim>
1316  void
1317  write(const Triangulation<dim, spacedim> &tria,
1318  std::ostream & out,
1319  const Mapping<dim, spacedim> * mapping = nullptr) const;
1320 
1324  void
1325  set_flags(const GridOutFlags::DX &flags);
1326 
1330  void
1331  set_flags(const GridOutFlags::Msh &flags);
1332 
1336  void
1337  set_flags(const GridOutFlags::Ucd &flags);
1338 
1342  void
1343  set_flags(const GridOutFlags::Gnuplot &flags);
1344 
1348  void
1349  set_flags(const GridOutFlags::Eps<1> &flags);
1350 
1354  void
1355  set_flags(const GridOutFlags::Eps<2> &flags);
1356 
1360  void
1361  set_flags(const GridOutFlags::Eps<3> &flags);
1362 
1366  void
1367  set_flags(const GridOutFlags::XFig &flags);
1368 
1372  void
1373  set_flags(const GridOutFlags::Svg &flags);
1374 
1378  void
1379  set_flags(const GridOutFlags::MathGL &flags);
1380 
1384  void
1385  set_flags(const GridOutFlags::Vtk &flags);
1386 
1390  void
1391  set_flags(const GridOutFlags::Vtu &flags);
1392 
1407  static std::string
1408  default_suffix(const OutputFormat output_format);
1409 
1414  std::string
1415  default_suffix() const;
1416 
1430  static OutputFormat
1431  parse_output_format(const std::string &format_name);
1432 
1438  static std::string
1439  get_output_format_names();
1440 
1444  static void
1446 
1450  void
1452 
1457  std::size_t
1458  memory_consumption() const;
1459 
1464 
1465 private:
1470 
1475 
1481 
1487 
1493 
1499 
1505 
1511 
1516 
1521 
1526 
1531 
1536 
1562  template <int dim, int spacedim>
1563  unsigned int
1564  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1565  const unsigned int next_element_index,
1566  std::ostream & out) const;
1567 
1571  unsigned int
1572  write_msh_faces(const Triangulation<1, 1> &tria,
1573  const unsigned int next_element_index,
1574  std::ostream & out) const;
1579  unsigned int
1580  write_msh_faces(const Triangulation<1, 2> &tria,
1581  const unsigned int next_element_index,
1582  std::ostream & out) const;
1583  unsigned int
1584  write_msh_faces(const Triangulation<1, 3> &tria,
1585  const unsigned int next_element_index,
1586  std::ostream & out) const;
1587 
1588 
1589 
1615  template <int dim, int spacedim>
1616  unsigned int
1617  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1618  const unsigned int next_element_index,
1619  std::ostream & out) const;
1620 
1624  unsigned int
1625  write_msh_lines(const Triangulation<1, 1> &tria,
1626  const unsigned int next_element_index,
1627  std::ostream & out) const;
1628 
1633  unsigned int
1634  write_msh_lines(const Triangulation<1, 2> &tria,
1635  const unsigned int next_element_index,
1636  std::ostream & out) const;
1637  unsigned int
1638  write_msh_lines(const Triangulation<1, 3> &tria,
1639  const unsigned int next_element_index,
1640  std::ostream & out) const;
1644  unsigned int
1645  write_msh_lines(const Triangulation<2, 2> &tria,
1646  const unsigned int next_element_index,
1647  std::ostream & out) const;
1652  unsigned int
1653  write_msh_lines(const Triangulation<2, 3> &tria,
1654  const unsigned int next_element_index,
1655  std::ostream & out) const;
1656 
1682  template <int dim, int spacedim>
1683  unsigned int
1684  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1685  const unsigned int next_element_index,
1686  std::ostream & out) const;
1687 
1691  unsigned int
1692  write_ucd_faces(const Triangulation<1, 1> &tria,
1693  const unsigned int next_element_index,
1694  std::ostream & out) const;
1695 
1700  unsigned int
1701  write_ucd_faces(const Triangulation<1, 2> &tria,
1702  const unsigned int next_element_index,
1703  std::ostream & out) const;
1704  unsigned int
1705  write_ucd_faces(const Triangulation<1, 3> &tria,
1706  const unsigned int next_element_index,
1707  std::ostream & out) const;
1708 
1709 
1735  template <int dim, int spacedim>
1736  unsigned int
1737  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1738  const unsigned int next_element_index,
1739  std::ostream & out) const;
1740 
1744  unsigned int
1745  write_ucd_lines(const Triangulation<1, 1> &tria,
1746  const unsigned int next_element_index,
1747  std::ostream & out) const;
1752  unsigned int
1753  write_ucd_lines(const Triangulation<1, 2> &tria,
1754  const unsigned int next_element_index,
1755  std::ostream & out) const;
1756  unsigned int
1757  write_ucd_lines(const Triangulation<1, 3> &tria,
1758  const unsigned int next_element_index,
1759  std::ostream & out) const;
1760 
1761 
1765  unsigned int
1766  write_ucd_lines(const Triangulation<2, 2> &tria,
1767  const unsigned int next_element_index,
1768  std::ostream & out) const;
1773  unsigned int
1774  write_ucd_lines(const Triangulation<2, 3> &tria,
1775  const unsigned int next_element_index,
1776  std::ostream & out) const;
1777 
1778 
1791  template <int dim, int spacedim>
1792  unsigned int
1793  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1794 
1799  unsigned int
1800  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1801 
1806  unsigned int
1807  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1808  unsigned int
1809  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1810 
1823  template <int dim, int spacedim>
1824  unsigned int
1825  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1826 
1831  unsigned int
1832  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1833 
1838  unsigned int
1839  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1840  unsigned int
1841  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1842 
1847  unsigned int
1848  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1853  unsigned int
1854  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1855 };
1856 
1857 
1858 
1859 DEAL_II_NAMESPACE_CLOSE
1860 
1861 #endif
OutputFormat default_format
Definition: grid_out.h:1469
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:47
bool write_cells
Definition: grid_out.h:61
write() calls write_dx()
Definition: grid_out.h:971
bool write_additional_boundary_lines
Definition: grid_out.h:284
unsigned int n_boundary_face_points
Definition: grid_out.h:607
No cell coloring.
Definition: grid_out.h:747
GridOutFlags::Eps< 2 > eps_flags_2
Definition: grid_out.h:1504
unsigned int height
Definition: grid_out.h:679
OutputFormat
Definition: grid_out.h:966
Convert the level number into the cell color.
Definition: grid_out.h:751
write() calls write_eps()
Definition: grid_out.h:975
unsigned int line_thickness
Definition: grid_out.h:690
bool convert_level_number_to_height
Definition: grid_out.h:762
bool write_diameter
Definition: grid_out.h:71
unsigned int boundary_line_thickness
Definition: grid_out.h:694
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:88
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:977
GridOutFlags::Vtk vtk_flags
Definition: grid_out.h:1530
Point< 2 > scaling
Definition: grid_out.h:612
bool label_cell_index
Definition: grid_out.h:782
GridOutFlags::Gnuplot gnuplot_flags
Definition: grid_out.h:1492
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:1525
write() calls write_mathgl()
Definition: grid_out.h:985
GridOutFlags::DX dx_flags
Definition: grid_out.h:1474
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1480
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1498
write() calls write_gnuplot()
Definition: grid_out.h:973
bool label_material_id
Definition: grid_out.h:787
Abstract base class for mapping classes.
Definition: mapping.h:302
GridOutFlags::XFig xfig_flags
Definition: grid_out.h:1515
bool label_subdomain_id
Definition: grid_out.h:792
#define DeclException0(Exception0)
Definition: exceptions.h:473
bool label_level_subdomain_id
Definition: grid_out.h:797
Convert the subdomain id into the cell color.
Definition: grid_out.h:753
GridOutFlags::Ucd ucd_flags
Definition: grid_out.h:1486
Background background
Definition: grid_out.h:726
Do nothing in write()
Definition: grid_out.h:969
float cell_font_scaling
Definition: grid_out.h:773
write() calls write_xfig()
Definition: grid_out.h:979
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:981
write() calls write_svg()
Definition: grid_out.h:983
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1520
bool write_measure
Definition: grid_out.h:76
Convert the material id into the cell color (default)
Definition: grid_out.h:749
float level_height_factor
Definition: grid_out.h:768
GridOutFlags::Eps< 3 > eps_flags_3
Definition: grid_out.h:1510
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:60
bool label_level_number
Definition: grid_out.h:777
GridOutFlags::Vtu vtu_flags
Definition: grid_out.h:1535
unsigned int width
Definition: grid_out.h:685
write() calls write_vtk()
Definition: grid_out.h:987