Reference documentation for deal.II version Git cd5f69ed86 2019-12-07 22:13:35 -0500
\(\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  {
872  Vtk(const bool output_cells = true,
873  const bool output_faces = true,
874  const bool output_edges = true,
875  const bool output_only_relevant = true)
876  : output_cells(output_cells)
877  , output_faces(output_faces)
878  , output_edges(output_edges)
879  , output_only_relevant(output_only_relevant)
880  {}
881 
886 
891 
896 
902  };
903 
904 
911  struct Vtu : public DataOutBase::VtkFlags
912  {};
913 } // namespace GridOutFlags
914 
915 
916 
992 class GridOut
993 {
994 public:
1001  {
1023  vtu
1024  };
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
1075  write_gnuplot(const Triangulation<dim, spacedim> &tria,
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 
1120  template <int dim, int spacedim>
1121  void
1122  write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1123 
1153  template <int dim, int spacedim>
1154  void
1155  write_eps(const Triangulation<dim, spacedim> &tria,
1156  std::ostream & out,
1157  const Mapping<dim, spacedim> * mapping = nullptr) const;
1158 
1177  template <int dim, int spacedim>
1178  void
1179  write_xfig(const Triangulation<dim, spacedim> &tria,
1180  std::ostream & out,
1181  const Mapping<dim, spacedim> * mapping = nullptr) const;
1182 
1203  void
1204  write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1205 
1211  template <int dim, int spacedim>
1212  void
1213  write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1214 
1215 
1230  template <int dim, int spacedim>
1231  void
1232  write_mathgl(const Triangulation<dim, spacedim> &tria,
1233  std::ostream & out) const;
1234 
1273  template <int dim, int spacedim>
1274  void
1275  write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1276 
1294  template <int dim, int spacedim>
1295  void
1296  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1297 
1328  template <int dim, int spacedim>
1329  void
1330  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1331  const std::string &filename_without_extension,
1332  const bool view_levels = false,
1333  const bool include_artificial = false) const;
1334 
1339  template <int dim, int spacedim>
1340  void
1341  write(const Triangulation<dim, spacedim> &tria,
1342  std::ostream & out,
1343  const OutputFormat output_format,
1344  const Mapping<dim, spacedim> * mapping = nullptr) const;
1345 
1349  template <int dim, int spacedim>
1350  void
1351  write(const Triangulation<dim, spacedim> &tria,
1352  std::ostream & out,
1353  const Mapping<dim, spacedim> * mapping = nullptr) const;
1354 
1358  void
1359  set_flags(const GridOutFlags::DX &flags);
1360 
1364  void
1365  set_flags(const GridOutFlags::Msh &flags);
1366 
1370  void
1371  set_flags(const GridOutFlags::Ucd &flags);
1372 
1376  void
1377  set_flags(const GridOutFlags::Gnuplot &flags);
1378 
1382  void
1383  set_flags(const GridOutFlags::Eps<1> &flags);
1384 
1388  void
1389  set_flags(const GridOutFlags::Eps<2> &flags);
1390 
1394  void
1395  set_flags(const GridOutFlags::Eps<3> &flags);
1396 
1400  void
1401  set_flags(const GridOutFlags::XFig &flags);
1402 
1406  void
1407  set_flags(const GridOutFlags::Svg &flags);
1408 
1412  void
1413  set_flags(const GridOutFlags::MathGL &flags);
1414 
1418  void
1419  set_flags(const GridOutFlags::Vtk &flags);
1420 
1424  void
1425  set_flags(const GridOutFlags::Vtu &flags);
1426 
1441  static std::string
1442  default_suffix(const OutputFormat output_format);
1443 
1448  std::string
1449  default_suffix() const;
1450 
1464  static OutputFormat
1465  parse_output_format(const std::string &format_name);
1466 
1472  static std::string
1473  get_output_format_names();
1474 
1478  static void
1480 
1484  void
1486 
1491  std::size_t
1492  memory_consumption() const;
1493 
1498 
1499 private:
1504 
1509 
1515 
1521 
1527 
1533 
1539 
1545 
1550 
1555 
1560 
1565 
1570 
1596  template <int dim, int spacedim>
1597  unsigned int
1598  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1599  const unsigned int next_element_index,
1600  std::ostream & out) const;
1601 
1605  unsigned int
1606  write_msh_faces(const Triangulation<1, 1> &tria,
1607  const unsigned int next_element_index,
1608  std::ostream & out) const;
1613  unsigned int
1614  write_msh_faces(const Triangulation<1, 2> &tria,
1615  const unsigned int next_element_index,
1616  std::ostream & out) const;
1617  unsigned int
1618  write_msh_faces(const Triangulation<1, 3> &tria,
1619  const unsigned int next_element_index,
1620  std::ostream & out) const;
1621 
1622 
1623 
1649  template <int dim, int spacedim>
1650  unsigned int
1651  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1652  const unsigned int next_element_index,
1653  std::ostream & out) const;
1654 
1658  unsigned int
1659  write_msh_lines(const Triangulation<1, 1> &tria,
1660  const unsigned int next_element_index,
1661  std::ostream & out) const;
1662 
1667  unsigned int
1668  write_msh_lines(const Triangulation<1, 2> &tria,
1669  const unsigned int next_element_index,
1670  std::ostream & out) const;
1671  unsigned int
1672  write_msh_lines(const Triangulation<1, 3> &tria,
1673  const unsigned int next_element_index,
1674  std::ostream & out) const;
1678  unsigned int
1679  write_msh_lines(const Triangulation<2, 2> &tria,
1680  const unsigned int next_element_index,
1681  std::ostream & out) const;
1686  unsigned int
1687  write_msh_lines(const Triangulation<2, 3> &tria,
1688  const unsigned int next_element_index,
1689  std::ostream & out) const;
1690 
1716  template <int dim, int spacedim>
1717  unsigned int
1718  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1719  const unsigned int next_element_index,
1720  std::ostream & out) const;
1721 
1725  unsigned int
1726  write_ucd_faces(const Triangulation<1, 1> &tria,
1727  const unsigned int next_element_index,
1728  std::ostream & out) const;
1729 
1734  unsigned int
1735  write_ucd_faces(const Triangulation<1, 2> &tria,
1736  const unsigned int next_element_index,
1737  std::ostream & out) const;
1738  unsigned int
1739  write_ucd_faces(const Triangulation<1, 3> &tria,
1740  const unsigned int next_element_index,
1741  std::ostream & out) const;
1742 
1743 
1769  template <int dim, int spacedim>
1770  unsigned int
1771  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1772  const unsigned int next_element_index,
1773  std::ostream & out) const;
1774 
1778  unsigned int
1779  write_ucd_lines(const Triangulation<1, 1> &tria,
1780  const unsigned int next_element_index,
1781  std::ostream & out) const;
1786  unsigned int
1787  write_ucd_lines(const Triangulation<1, 2> &tria,
1788  const unsigned int next_element_index,
1789  std::ostream & out) const;
1790  unsigned int
1791  write_ucd_lines(const Triangulation<1, 3> &tria,
1792  const unsigned int next_element_index,
1793  std::ostream & out) const;
1794 
1795 
1799  unsigned int
1800  write_ucd_lines(const Triangulation<2, 2> &tria,
1801  const unsigned int next_element_index,
1802  std::ostream & out) const;
1807  unsigned int
1808  write_ucd_lines(const Triangulation<2, 3> &tria,
1809  const unsigned int next_element_index,
1810  std::ostream & out) const;
1811 
1812 
1825  template <int dim, int spacedim>
1826  unsigned int
1827  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1828 
1833  unsigned int
1834  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1835 
1840  unsigned int
1841  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1842  unsigned int
1843  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1844 
1857  template <int dim, int spacedim>
1858  unsigned int
1859  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1860 
1865  unsigned int
1866  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1867 
1872  unsigned int
1873  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1874  unsigned int
1875  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1876 
1881  unsigned int
1882  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1887  unsigned int
1888  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1889 };
1890 
1891 
1892 
1893 DEAL_II_NAMESPACE_CLOSE
1894 
1895 #endif
OutputFormat default_format
Definition: grid_out.h:1503
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:1005
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:1538
unsigned int height
Definition: grid_out.h:679
OutputFormat
Definition: grid_out.h:1000
Convert the level number into the cell color.
Definition: grid_out.h:751
write() calls write_eps()
Definition: grid_out.h:1009
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:1011
bool output_only_relevant
Definition: grid_out.h:901
GridOutFlags::Vtk vtk_flags
Definition: grid_out.h:1564
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:1526
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:1559
write() calls write_mathgl()
Definition: grid_out.h:1019
GridOutFlags::DX dx_flags
Definition: grid_out.h:1508
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1514
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1532
write() calls write_gnuplot()
Definition: grid_out.h:1007
bool label_material_id
Definition: grid_out.h:787
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:872
GridOutFlags::XFig xfig_flags
Definition: grid_out.h:1549
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:1520
Background background
Definition: grid_out.h:726
Do nothing in write()
Definition: grid_out.h:1003
float cell_font_scaling
Definition: grid_out.h:773
write() calls write_xfig()
Definition: grid_out.h:1013
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:1015
write() calls write_svg()
Definition: grid_out.h:1017
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1554
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:1544
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:1569
unsigned int width
Definition: grid_out.h:685
write() calls write_vtk()
Definition: grid_out.h:1021