Reference documentation for deal.II version 9.1.1
\(\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 class ParameterHandler;
32 template <int dim, int spacedim>
33 class Triangulation;
34 template <int dim, int spacedim>
35 class Mapping;
36 
37 
46 namespace GridOutFlags
47 {
53  struct DX
54  {
59 
64 
69 
74 
80 
84  DX(const bool write_cells = true,
85  const bool write_faces = false,
86  const bool write_diameter = false,
87  const bool write_measure = false,
88  const bool write_all_faces = true);
89 
93  static void
95 
99  void
101  };
102 
108  struct Msh
109  {
138 
142  Msh(const bool write_faces = false, const bool write_lines = false);
146  static void
148 
152  void
154  };
155 
156 
162  struct Ucd
163  {
174 
188 
204 
208  Ucd(const bool write_preamble = false,
209  const bool write_faces = false,
210  const bool write_lines = false);
211 
215  static void
217 
221  void
223  };
224 
225 
231  struct Gnuplot
232  {
243 
251 
262  DEAL_II_DEPRECATED unsigned int &n_boundary_face_points;
263 
269 
282 
286  Gnuplot(const bool write_cell_number = false,
287  const unsigned int n_extra_curved_line_points = 2,
288  const bool curved_inner_cells = false,
289  const bool write_additional_boundary_lines = true);
290 
295  Gnuplot(const Gnuplot &flags);
296 
301  Gnuplot &
302  operator=(const Gnuplot &flags);
303 
307  static void
309 
313  void
315  };
316 
329  {
335  enum SizeType
336  {
345  };
346 
351 
359  unsigned int size;
360 
364  double line_width;
365 
373 
385 
393 
398  const unsigned int size = 300,
399  const double line_width = 0.5,
400  const bool color_lines_on_user_flag = false,
401  const unsigned int n_boundary_face_points = 2,
402  const bool color_lines_level = false);
406  static void
408 
412  void
414  };
415 
416 
427  template <int dim>
428  struct Eps
429  {};
430 
436  template <>
437  struct Eps<1> : public EpsFlagsBase
438  {
442  Eps(const SizeType size_type = width,
443  const unsigned int size = 300,
444  const double line_width = 0.5,
445  const bool color_lines_on_user_flag = false,
446  const unsigned int n_boundary_face_points = 2);
450  static void
451  declare_parameters(ParameterHandler &param);
452 
456  void
457  parse_parameters(ParameterHandler &param);
458  };
459 
460 
466  template <>
467  struct Eps<2> : public EpsFlagsBase
468  {
486 
492 
496  Eps(const SizeType size_type = width,
497  const unsigned int size = 300,
498  const double line_width = 0.5,
499  const bool color_lines_on_user_flag = false,
500  const unsigned int n_boundary_face_points = 2,
501  const bool write_cell_numbers = false,
502  const bool write_cell_number_level = true,
503  const bool write_vertex_numbers = false,
504  const bool color_lines_level = false);
508  static void
509  declare_parameters(ParameterHandler &param);
510 
514  void
515  parse_parameters(ParameterHandler &param);
516  };
517 
523  template <>
524  struct Eps<3> : public EpsFlagsBase
525  {
531  double azimut_angle;
532 
541  double turn_angle;
542 
546  Eps(const SizeType size_type = width,
547  const unsigned int size = 300,
548  const double line_width = 0.5,
549  const bool color_lines_on_user_flag = false,
550  const unsigned int n_boundary_face_points = 2,
551  const double azimut_angle = 60,
552  const double turn_angle = 30);
556  static void
557  declare_parameters(ParameterHandler &param);
558 
562  void
563  parse_parameters(ParameterHandler &param);
564  };
565 
571  struct XFig
572  {
577 
581  enum Coloring
582  {
591  } color_by;
592 
600 
605 
610 
616 
623 
629 
636 
641 
646 
650  XFig();
654  static void
656 
660  void
662  };
663 
664 
670  struct Svg
671  {
674  unsigned int height;
677  unsigned int width;
679  unsigned int line_thickness;
682 
684  bool margin;
685 
690  {
698  };
699 
700  Background background;
701 
702  // View angles for the perspective view of the grid; Default is 0, 0 (top
703  // view).
712 
716  enum Coloring
717  {
728  };
729 
730  Coloring coloring;
731 
735 
739 
752 
759 
763  Svg(const unsigned int line_thickness = 2,
764  const unsigned int boundary_line_thickness = 4,
765  bool margin = true,
766  const Background background = white,
767  const int azimuth_angle = 0,
768  const int polar_angle = 0,
769  const Coloring coloring = level_number,
770  const bool convert_level_number_to_height = false,
771  const bool label_level_number = true,
772  const bool label_cell_index = true,
773  const bool label_material_id = false,
774  const bool label_subdomain_id = false,
775  const bool draw_colorbar = true,
776  const bool draw_legend = true);
777  };
778 
784  struct MathGL
785  {
789  MathGL();
790 
795 
799  static void
801 
805  void
807  };
808 
809 
816  struct Vtk : public DataOutBase::VtkFlags
817  {};
818 
819 
826  struct Vtu : public DataOutBase::VtkFlags
827  {};
828 } // namespace GridOutFlags
829 
830 
831 
907 class GridOut
908 {
909 public:
916  {
920  dx,
939  };
940 
944  GridOut();
945 
954  template <int dim, int spacedim>
955  void
956  write_dx(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
957 
988  template <int dim, int spacedim>
989  void
991  std::ostream & out,
992  const Mapping<dim, spacedim> * mapping = nullptr) const;
993 
1012  template <int dim, int spacedim>
1013  void
1014  write_msh(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1015 
1035  template <int dim, int spacedim>
1036  void
1037  write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1038 
1068  template <int dim, int spacedim>
1069  void
1071  std::ostream & out,
1072  const Mapping<dim, spacedim> * mapping = nullptr) const;
1073 
1092  template <int dim, int spacedim>
1093  void
1095  std::ostream & out,
1096  const Mapping<dim, spacedim> * mapping = nullptr) const;
1097 
1116  void
1117  write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1118 
1124  template <int dim, int spacedim>
1125  void
1126  write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1127 
1128 
1143  template <int dim, int spacedim>
1144  void
1146  std::ostream & out) const;
1147 
1186  template <int dim, int spacedim>
1187  void
1188  write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1189 
1207  template <int dim, int spacedim>
1208  void
1209  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1210 
1241  template <int dim, int spacedim>
1242  void
1244  const std::string &filename_without_extension,
1245  const bool view_levels = false,
1246  const bool include_artificial = false) const;
1247 
1252  template <int dim, int spacedim>
1253  void
1254  write(const Triangulation<dim, spacedim> &tria,
1255  std::ostream & out,
1256  const OutputFormat output_format,
1257  const Mapping<dim, spacedim> * mapping = nullptr) const;
1258 
1262  template <int dim, int spacedim>
1263  void
1264  write(const Triangulation<dim, spacedim> &tria,
1265  std::ostream & out,
1266  const Mapping<dim, spacedim> * mapping = nullptr) const;
1267 
1271  void
1272  set_flags(const GridOutFlags::DX &flags);
1273 
1277  void
1278  set_flags(const GridOutFlags::Msh &flags);
1279 
1283  void
1284  set_flags(const GridOutFlags::Ucd &flags);
1285 
1289  void
1290  set_flags(const GridOutFlags::Gnuplot &flags);
1291 
1295  void
1296  set_flags(const GridOutFlags::Eps<1> &flags);
1297 
1301  void
1302  set_flags(const GridOutFlags::Eps<2> &flags);
1303 
1307  void
1308  set_flags(const GridOutFlags::Eps<3> &flags);
1309 
1313  void
1314  set_flags(const GridOutFlags::XFig &flags);
1315 
1319  void
1320  set_flags(const GridOutFlags::Svg &flags);
1321 
1325  void
1326  set_flags(const GridOutFlags::MathGL &flags);
1327 
1331  void
1332  set_flags(const GridOutFlags::Vtk &flags);
1333 
1337  void
1338  set_flags(const GridOutFlags::Vtu &flags);
1339 
1354  static std::string
1355  default_suffix(const OutputFormat output_format);
1356 
1361  std::string
1362  default_suffix() const;
1363 
1377  static OutputFormat
1378  parse_output_format(const std::string &format_name);
1379 
1385  static std::string
1387 
1391  static void
1393 
1397  void
1399 
1404  std::size_t
1405  memory_consumption() const;
1406 
1411 
1412 private:
1417 
1422 
1428 
1434 
1440 
1446 
1452 
1458 
1463 
1468 
1473 
1478 
1483 
1509  template <int dim, int spacedim>
1510  unsigned int
1512  const unsigned int next_element_index,
1513  std::ostream & out) const;
1514 
1518  unsigned int
1520  const unsigned int next_element_index,
1521  std::ostream & out) const;
1526  unsigned int
1528  const unsigned int next_element_index,
1529  std::ostream & out) const;
1530  unsigned int
1532  const unsigned int next_element_index,
1533  std::ostream & out) const;
1534 
1535 
1536 
1562  template <int dim, int spacedim>
1563  unsigned int
1565  const unsigned int next_element_index,
1566  std::ostream & out) const;
1567 
1571  unsigned int
1573  const unsigned int next_element_index,
1574  std::ostream & out) const;
1575 
1580  unsigned int
1582  const unsigned int next_element_index,
1583  std::ostream & out) const;
1584  unsigned int
1586  const unsigned int next_element_index,
1587  std::ostream & out) const;
1591  unsigned int
1593  const unsigned int next_element_index,
1594  std::ostream & out) const;
1599  unsigned int
1601  const unsigned int next_element_index,
1602  std::ostream & out) const;
1603 
1629  template <int dim, int spacedim>
1630  unsigned int
1632  const unsigned int next_element_index,
1633  std::ostream & out) const;
1634 
1638  unsigned int
1640  const unsigned int next_element_index,
1641  std::ostream & out) const;
1642 
1647  unsigned int
1649  const unsigned int next_element_index,
1650  std::ostream & out) const;
1651  unsigned int
1653  const unsigned int next_element_index,
1654  std::ostream & out) const;
1655 
1656 
1682  template <int dim, int spacedim>
1683  unsigned int
1685  const unsigned int next_element_index,
1686  std::ostream & out) const;
1687 
1691  unsigned int
1693  const unsigned int next_element_index,
1694  std::ostream & out) const;
1699  unsigned int
1701  const unsigned int next_element_index,
1702  std::ostream & out) const;
1703  unsigned int
1705  const unsigned int next_element_index,
1706  std::ostream & out) const;
1707 
1708 
1712  unsigned int
1714  const unsigned int next_element_index,
1715  std::ostream & out) const;
1720  unsigned int
1722  const unsigned int next_element_index,
1723  std::ostream & out) const;
1724 
1725 
1736  static Point<2> svg_project_point(Point<3> point,
1737  Point<3> camera_position,
1738  Point<3> camera_direction,
1739  Point<3> camera_horizontal,
1740  float camera_focus);
1741 
1754  template <int dim, int spacedim>
1755  unsigned int
1757 
1762  unsigned int
1763  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1764 
1769  unsigned int
1770  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1771  unsigned int
1772  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1773 
1786  template <int dim, int spacedim>
1787  unsigned int
1789 
1794  unsigned int
1795  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1796 
1801  unsigned int
1802  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1803  unsigned int
1804  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1805 
1810  unsigned int
1811  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1816  unsigned int
1817  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1818 };
1819 
1820 
1821 
1822 DEAL_II_NAMESPACE_CLOSE
1823 
1824 #endif
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:193
Use white background.
Definition: grid_out.h:694
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:716
unsigned int n_boundary_faces(const Triangulation< dim, spacedim > &tria) const
Definition: grid_out.cc:3369
OutputFormat default_format
Definition: grid_out.h:1416
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
static OutputFormat parse_output_format(const std::string &format_name)
Definition: grid_out.cc:617
bool margin
Margin around the plotted area.
Definition: grid_out.h:684
bool write_cells
Definition: grid_out.h:58
write() calls write_dx()
Definition: grid_out.h:920
bool write_additional_boundary_lines
Definition: grid_out.h:281
void write_xfig(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition: grid_out.cc:1316
unsigned int n_boundary_face_points
Definition: grid_out.h:604
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:467
No cell coloring.
Definition: grid_out.h:719
GridOutFlags::Eps< 2 > eps_flags_2
Definition: grid_out.h:1451
unsigned int height
Definition: grid_out.h:674
OutputFormat
Definition: grid_out.h:915
void write_vtu(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:3157
Use transparent value of SVG.
Definition: grid_out.h:692
GridOut()
Definition: grid_out.cc:481
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:249
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:3187
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:399
Convert the level number into the cell color.
Definition: grid_out.h:723
write() calls write_eps()
Definition: grid_out.h:924
unsigned int line_thickness
Thickness of the lines between cells.
Definition: grid_out.h:679
bool convert_level_number_to_height
Definition: grid_out.h:734
bool write_diameter
Definition: grid_out.h:68
static Point< 2 > svg_project_point(Point< 3 > point, Point< 3 > camera_position, Point< 3 > camera_direction, Point< 3 > camera_horizontal, float camera_focus)
Definition: grid_out.cc:3748
void write_mathgl(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:2721
unsigned int boundary_line_thickness
Thickness of lines at the boundary.
Definition: grid_out.h:681
unsigned int write_msh_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:3492
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:88
unsigned int n_extra_curved_line_points
Definition: grid_out.h:250
bool write_all_faces
Definition: grid_out.h:79
write() calls write_ucd()
Definition: grid_out.h:926
void write_gnuplot(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition: grid_out.cc:4221
unsigned int n_boundary_lines(const Triangulation< dim, spacedim > &tria) const
Definition: grid_out.cc:3386
GridOutFlags::Vtk vtk_flags
Definition: grid_out.h:1477
Point< 2 > scaling
Definition: grid_out.h:609
bool label_cell_index
Write cell index into each cell. Defaults to true.
Definition: grid_out.h:745
GridOutFlags::Gnuplot gnuplot_flags
Definition: grid_out.h:1439
void write_svg(const Triangulation< 2, 2 > &tria, std::ostream &out) const
Definition: grid_out.cc:1530
Convert the global subdomain id into the cell color.
Definition: grid_out.h:588
unsigned int & n_boundary_face_points
Definition: grid_out.h:262
Convert the material id into the cell color.
Definition: grid_out.h:584
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:185
std::size_t memory_consumption() const
Definition: grid_out.cc:762
GridOutFlags::MathGL mathgl_flags
Definition: grid_out.h:1472
write() calls write_mathgl()
Definition: grid_out.h:934
GridOutFlags::DX dx_flags
Definition: grid_out.h:1421
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1427
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1445
write() calls write_gnuplot()
Definition: grid_out.h:922
bool label_material_id
Write material id of each cell. Defaults to false.
Definition: grid_out.h:747
EpsFlagsBase(const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const bool color_lines_on_user_flag=false, const unsigned int n_boundary_face_points=2, const bool color_lines_level=false)
Definition: grid_out.cc:200
Abstract base class for mapping classes.
Definition: dof_tools.h:57
GridOutFlags::XFig xfig_flags
Definition: grid_out.h:1462
bool label_subdomain_id
Write subdomain id of each cell. Defaults to false.
Definition: grid_out.h:749
#define DeclException0(Exception0)
Definition: exceptions.h:473
Ucd(const bool write_preamble=false, const bool write_faces=false, const bool write_lines=false)
Definition: grid_out.cc:119
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:667
bool label_level_subdomain_id
Write level subdomain id of each cell. Defaults to false.
Definition: grid_out.h:751
static std::string get_output_format_names()
Definition: grid_out.cc:660
Convert the subdomain id into the cell color.
Definition: grid_out.h:725
Msh(const bool write_faces=false, const bool write_lines=false)
Definition: grid_out.cc:98
void write_vtk(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:2994
GridOutFlags::Ucd ucd_flags
Definition: grid_out.h:1433
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:130
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:216
Do nothing in write()
Definition: grid_out.h:918
float cell_font_scaling
Scaling of the font for cell annotations. Defaults to 1.
Definition: grid_out.h:741
Convert the level subdomain id into the cell color.
Definition: grid_out.h:590
write() calls write_xfig()
Definition: grid_out.h:928
Convert the level subdomain id into the cell color.
Definition: grid_out.h:727
bool write_faces
Definition: grid_out.h:63
Convert the level into the cell color.
Definition: grid_out.h:586
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:112
unsigned int n_boundary_face_points
Definition: grid_out.h:384
Point< 2 > offset
Definition: grid_out.h:615
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:104
unsigned int write_ucd_faces(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:3657
write() calls write_msh()
Definition: grid_out.h:930
void write_ucd(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:1191
unsigned int write_ucd_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:3700
write() calls write_svg()
Definition: grid_out.h:932
unsigned int write_msh_lines(const Triangulation< dim, spacedim > &tria, const unsigned int next_element_index, std::ostream &out) const
Definition: grid_out.cc:3536
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1467
Svg(const unsigned int line_thickness=2, const unsigned int boundary_line_thickness=4, bool margin=true, const Background background=white, const int azimuth_angle=0, const int polar_angle=0, const Coloring coloring=level_number, const bool convert_level_number_to_height=false, const bool label_level_number=true, const bool label_cell_index=true, const bool label_material_id=false, const bool label_subdomain_id=false, const bool draw_colorbar=true, const bool draw_legend=true)
Definition: grid_out.cc:427
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:415
void write_eps(const Triangulation< dim, spacedim > &tria, std::ostream &out, const Mapping< dim, spacedim > *mapping=nullptr) const
Definition: grid_out.cc:4755
bool write_measure
Definition: grid_out.h:73
Convert the material id into the cell color (default)
Definition: grid_out.h:721
float level_height_factor
Definition: grid_out.h:738
GridOutFlags::Eps< 3 > eps_flags_3
Definition: grid_out.h:1457
static ::ExceptionBase & ExcInvalidState()
write() calls write_vtu()
Definition: grid_out.h:938
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:60
void set_flags(const GridOutFlags::DX &flags)
Definition: grid_out.cc:487
bool label_level_number
Write level number into each cell. Defaults to true.
Definition: grid_out.h:743
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:139
void write_dx(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:797
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:4765
Gnuplot & operator=(const Gnuplot &flags)
Definition: grid_out.cc:172
GridOutFlags::Vtu vtu_flags
Definition: grid_out.h:1482
unsigned int width
Definition: grid_out.h:677
write() calls write_vtk()
Definition: grid_out.h:936
void parse_parameters(ParameterHandler &param)
Definition: grid_out.cc:473
Gnuplot(const bool write_cell_number=false, const unsigned int n_extra_curved_line_points=2, const bool curved_inner_cells=false, const bool write_additional_boundary_lines=true)
Definition: grid_out.cc:148
void write_msh(const Triangulation< dim, spacedim > &tria, std::ostream &out) const
Definition: grid_out.cc:1044
std::string default_suffix() const
Definition: grid_out.cc:609