Reference documentation for deal.II version Git e849c0d71e 2019-06-17 10:40:29 -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 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  {
344  height
345  };
346 
351 
359  unsigned int size;
360 
364  double line_width;
365 
373 
385 
393 
397  EpsFlagsBase(const SizeType size_type = width,
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
452 
456  void
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
510 
514  void
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
558 
562  void
564  };
565 
571  struct XFig
572  {
577 
581  enum Coloring
582  {
590  level_subdomain_id
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  {
727  level_subdomain_id
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,
938  vtu
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
990  write_gnuplot(const Triangulation<dim, spacedim> &tria,
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
1070  write_eps(const Triangulation<dim, spacedim> &tria,
1071  std::ostream & out,
1072  const Mapping<dim, spacedim> * mapping = nullptr) const;
1073 
1092  template <int dim, int spacedim>
1093  void
1094  write_xfig(const Triangulation<dim, spacedim> &tria,
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
1145  write_mathgl(const Triangulation<dim, spacedim> &tria,
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
1243  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
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
1386  get_output_format_names();
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
1511  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1512  const unsigned int next_element_index,
1513  std::ostream & out) const;
1514 
1518  unsigned int
1519  write_msh_faces(const Triangulation<1, 1> &tria,
1520  const unsigned int next_element_index,
1521  std::ostream & out) const;
1526  unsigned int
1527  write_msh_faces(const Triangulation<1, 2> &tria,
1528  const unsigned int next_element_index,
1529  std::ostream & out) const;
1530  unsigned int
1531  write_msh_faces(const Triangulation<1, 3> &tria,
1532  const unsigned int next_element_index,
1533  std::ostream & out) const;
1534 
1535 
1536 
1562  template <int dim, int spacedim>
1563  unsigned int
1564  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1565  const unsigned int next_element_index,
1566  std::ostream & out) const;
1567 
1571  unsigned int
1572  write_msh_lines(const Triangulation<1, 1> &tria,
1573  const unsigned int next_element_index,
1574  std::ostream & out) const;
1575 
1580  unsigned int
1581  write_msh_lines(const Triangulation<1, 2> &tria,
1582  const unsigned int next_element_index,
1583  std::ostream & out) const;
1584  unsigned int
1585  write_msh_lines(const Triangulation<1, 3> &tria,
1586  const unsigned int next_element_index,
1587  std::ostream & out) const;
1591  unsigned int
1592  write_msh_lines(const Triangulation<2, 2> &tria,
1593  const unsigned int next_element_index,
1594  std::ostream & out) const;
1599  unsigned int
1600  write_msh_lines(const Triangulation<2, 3> &tria,
1601  const unsigned int next_element_index,
1602  std::ostream & out) const;
1603 
1629  template <int dim, int spacedim>
1630  unsigned int
1631  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1632  const unsigned int next_element_index,
1633  std::ostream & out) const;
1634 
1638  unsigned int
1639  write_ucd_faces(const Triangulation<1, 1> &tria,
1640  const unsigned int next_element_index,
1641  std::ostream & out) const;
1642 
1647  unsigned int
1648  write_ucd_faces(const Triangulation<1, 2> &tria,
1649  const unsigned int next_element_index,
1650  std::ostream & out) const;
1651  unsigned int
1652  write_ucd_faces(const Triangulation<1, 3> &tria,
1653  const unsigned int next_element_index,
1654  std::ostream & out) const;
1655 
1656 
1682  template <int dim, int spacedim>
1683  unsigned int
1684  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1685  const unsigned int next_element_index,
1686  std::ostream & out) const;
1687 
1691  unsigned int
1692  write_ucd_lines(const Triangulation<1, 1> &tria,
1693  const unsigned int next_element_index,
1694  std::ostream & out) const;
1699  unsigned int
1700  write_ucd_lines(const Triangulation<1, 2> &tria,
1701  const unsigned int next_element_index,
1702  std::ostream & out) const;
1703  unsigned int
1704  write_ucd_lines(const Triangulation<1, 3> &tria,
1705  const unsigned int next_element_index,
1706  std::ostream & out) const;
1707 
1708 
1712  unsigned int
1713  write_ucd_lines(const Triangulation<2, 2> &tria,
1714  const unsigned int next_element_index,
1715  std::ostream & out) const;
1720  unsigned int
1721  write_ucd_lines(const Triangulation<2, 3> &tria,
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
1756  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
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
1788  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
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
Use white background.
Definition: grid_out.h:694
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
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
unsigned int n_boundary_face_points
Definition: grid_out.h:604
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
Use transparent value of SVG.
Definition: grid_out.h:692
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
unsigned int boundary_line_thickness
Thickness of lines at the boundary.
Definition: grid_out.h:681
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
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
static ::ExceptionBase & ExcInvalidState()
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
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
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
bool label_level_subdomain_id
Write level subdomain id of each cell. Defaults to false.
Definition: grid_out.h:751
Convert the subdomain id into the cell color.
Definition: grid_out.h:725
GridOutFlags::Ucd ucd_flags
Definition: grid_out.h:1433
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
write() calls write_xfig()
Definition: grid_out.h:928
bool write_faces
Definition: grid_out.h:63
Convert the level into the cell color.
Definition: grid_out.h:586
unsigned int n_boundary_face_points
Definition: grid_out.h:384
Point< 2 > offset
Definition: grid_out.h:615
write() calls write_msh()
Definition: grid_out.h:930
write() calls write_svg()
Definition: grid_out.h:932
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1467
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 void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:60
bool label_level_number
Write level number into each cell. Defaults to true.
Definition: grid_out.h:743
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