Reference documentation for deal.II version Git ac854ef673 2021-03-06 10:09:45 +0100
\(\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 
260 
273 
277  Gnuplot(const bool write_cell_number = false,
278  const unsigned int n_extra_curved_line_points = 2,
279  const bool curved_inner_cells = false,
280  const bool write_additional_boundary_lines = true);
281 
285  static void
287 
291  void
293  };
294 
307  {
313  enum SizeType
314  {
322  height
323  };
324 
329 
337  unsigned int size;
338 
342  double line_width;
343 
351 
363 
371 
375  EpsFlagsBase(const SizeType size_type = width,
376  const unsigned int size = 300,
377  const double line_width = 0.5,
378  const bool color_lines_on_user_flag = false,
379  const unsigned int n_boundary_face_points = 2,
380  const bool color_lines_level = false);
384  static void
386 
390  void
392  };
393 
394 
405  template <int dim>
406  struct Eps
407  {};
408 
414  template <>
415  struct Eps<1> : public EpsFlagsBase
416  {
420  Eps(const SizeType size_type = width,
421  const unsigned int size = 300,
422  const double line_width = 0.5,
423  const bool color_lines_on_user_flag = false,
424  const unsigned int n_boundary_face_points = 2);
428  static void
430 
434  void
436  };
437 
438 
444  template <>
445  struct Eps<2> : public EpsFlagsBase
446  {
464 
470 
474  Eps(const SizeType size_type = width,
475  const unsigned int size = 300,
476  const double line_width = 0.5,
477  const bool color_lines_on_user_flag = false,
478  const unsigned int n_boundary_face_points = 2,
479  const bool write_cell_numbers = false,
480  const bool write_cell_number_level = true,
481  const bool write_vertex_numbers = false,
482  const bool color_lines_level = false);
486  static void
488 
492  void
494  };
495 
501  template <>
502  struct Eps<3> : public EpsFlagsBase
503  {
509  double azimut_angle;
510 
519  double turn_angle;
520 
524  Eps(const SizeType size_type = width,
525  const unsigned int size = 300,
526  const double line_width = 0.5,
527  const bool color_lines_on_user_flag = false,
528  const unsigned int n_boundary_face_points = 2,
529  const double azimut_angle = 60,
530  const double turn_angle = 30);
534  static void
536 
540  void
542  };
543 
549  struct XFig
550  {
555 
559  enum Coloring
560  {
568  level_subdomain_id
569  } color_by;
570 
578 
583 
588 
594 
601 
607 
614 
619 
624 
628  XFig();
632  static void
634 
638  void
640  };
641 
642 
655  struct Svg
656  {
661  unsigned int height;
662 
667  unsigned int width;
668 
672  unsigned int line_thickness;
677 
681  bool margin;
682 
687  {
692 
697 
703  };
704 
709 
710  // View angles for the perspective view of the grid; Default is 0, 0 (top
711  // view).
712 
717 
722 
726  enum Coloring
727  {
737  level_subdomain_id
738  };
739 
741 
745 
751 
760 
765 
770 
775 
780 
789 
795 
801 
805  Svg(const unsigned int line_thickness = 2,
806  const unsigned int boundary_line_thickness = 4,
807  const bool margin = true,
808  const Background background = white,
809  const int azimuth_angle = 0,
810  const int polar_angle = 0,
811  const Coloring coloring = level_number,
812  const bool convert_level_number_to_height = false,
813  const bool label_level_number = false,
814  const bool label_cell_index = false,
815  const bool label_material_id = false,
816  const bool label_subdomain_id = false,
817  const bool draw_colorbar = false,
818  const bool draw_legend = false,
819  const bool label_boundary_id = false);
820  };
821 
827  struct MathGL
828  {
832  MathGL();
833 
838 
842  static void
844 
848  void
850  };
851 
852 
859  struct Vtk : public DataOutBase::VtkFlags
860  {
864  Vtk(const bool output_cells = true,
865  const bool output_faces = true,
866  const bool output_edges = true,
867  const bool output_only_relevant = true)
868  : output_cells(output_cells)
869  , output_faces(output_faces)
870  , output_edges(output_edges)
871  , output_only_relevant(output_only_relevant)
872  {}
873 
878 
883 
888 
894  };
895 
896 
905  struct Vtu : public DataOutBase::VtkFlags
906  {
907  Vtu(const bool serialize_triangulation = false)
908  : serialize_triangulation(serialize_triangulation)
909  {}
910 
915  };
916 } // namespace GridOutFlags
917 
918 
919 
992 class GridOut
993 {
994 public:
1001  {
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
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 
1101 #ifdef DEAL_II_GMSH_WITH_API
1102 
1142  template <int dim, int spacedim>
1143  void
1144  write_msh(const Triangulation<dim, spacedim> &tria,
1145  const std::string & filename) const;
1146 #endif
1147 
1167  template <int dim, int spacedim>
1168  void
1169  write_ucd(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1170 
1200  template <int dim, int spacedim>
1201  void
1203  std::ostream & out,
1204  const Mapping<dim, spacedim> * mapping = nullptr) const;
1205 
1224  template <int dim, int spacedim>
1225  void
1226  write_xfig(const Triangulation<dim, spacedim> &tria,
1227  std::ostream & out,
1228  const Mapping<dim, spacedim> * mapping = nullptr) const;
1229 
1250  void
1251  write_svg(const Triangulation<2, 2> &tria, std::ostream &out) const;
1252 
1258  template <int dim, int spacedim>
1259  void
1260  write_svg(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1261 
1262 
1277  template <int dim, int spacedim>
1278  void
1279  write_mathgl(const Triangulation<dim, spacedim> &tria,
1280  std::ostream & out) const;
1281 
1318  template <int dim, int spacedim>
1319  void
1320  write_vtk(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1321 
1339  template <int dim, int spacedim>
1340  void
1341  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1342 
1373  template <int dim, int spacedim>
1374  void
1375  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1376  const std::string &filename_without_extension,
1377  const bool view_levels = false,
1378  const bool include_artificial = false) const;
1379 
1384  template <int dim, int spacedim>
1385  void
1386  write(const Triangulation<dim, spacedim> &tria,
1387  std::ostream & out,
1388  const OutputFormat output_format,
1389  const Mapping<dim, spacedim> * mapping = nullptr) const;
1390 
1394  template <int dim, int spacedim>
1395  void
1396  write(const Triangulation<dim, spacedim> &tria,
1397  std::ostream & out,
1398  const Mapping<dim, spacedim> * mapping = nullptr) const;
1399 
1403  void
1404  set_flags(const GridOutFlags::DX &flags);
1405 
1409  void
1410  set_flags(const GridOutFlags::Msh &flags);
1411 
1415  void
1416  set_flags(const GridOutFlags::Ucd &flags);
1417 
1421  void
1422  set_flags(const GridOutFlags::Gnuplot &flags);
1423 
1427  void
1428  set_flags(const GridOutFlags::Eps<1> &flags);
1429 
1433  void
1434  set_flags(const GridOutFlags::Eps<2> &flags);
1435 
1439  void
1440  set_flags(const GridOutFlags::Eps<3> &flags);
1441 
1445  void
1446  set_flags(const GridOutFlags::XFig &flags);
1447 
1451  void
1452  set_flags(const GridOutFlags::Svg &flags);
1453 
1457  void
1458  set_flags(const GridOutFlags::MathGL &flags);
1459 
1463  void
1464  set_flags(const GridOutFlags::Vtk &flags);
1465 
1469  void
1470  set_flags(const GridOutFlags::Vtu &flags);
1471 
1486  static std::string
1487  default_suffix(const OutputFormat output_format);
1488 
1493  std::string
1494  default_suffix() const;
1495 
1509  static OutputFormat
1510  parse_output_format(const std::string &format_name);
1511 
1517  static std::string
1519 
1523  static void
1525 
1529  void
1531 
1536  std::size_t
1537  memory_consumption() const;
1538 
1543 
1544 private:
1549 
1554 
1560 
1566 
1572 
1578 
1584 
1590 
1595 
1600 
1605 
1610 
1615 
1641  template <int dim, int spacedim>
1642  unsigned int
1643  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1644  const unsigned int next_element_index,
1645  std::ostream & out) const;
1646 
1650  unsigned int
1651  write_msh_faces(const Triangulation<1, 1> &tria,
1652  const unsigned int next_element_index,
1653  std::ostream & out) const;
1658  unsigned int
1659  write_msh_faces(const Triangulation<1, 2> &tria,
1660  const unsigned int next_element_index,
1661  std::ostream & out) const;
1662  unsigned int
1663  write_msh_faces(const Triangulation<1, 3> &tria,
1664  const unsigned int next_element_index,
1665  std::ostream & out) const;
1666 
1667 
1668 
1694  template <int dim, int spacedim>
1695  unsigned int
1696  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1697  const unsigned int next_element_index,
1698  std::ostream & out) const;
1699 
1703  unsigned int
1704  write_msh_lines(const Triangulation<1, 1> &tria,
1705  const unsigned int next_element_index,
1706  std::ostream & out) const;
1707 
1712  unsigned int
1713  write_msh_lines(const Triangulation<1, 2> &tria,
1714  const unsigned int next_element_index,
1715  std::ostream & out) const;
1716 
1721  unsigned int
1722  write_msh_lines(const Triangulation<1, 3> &tria,
1723  const unsigned int next_element_index,
1724  std::ostream & out) const;
1728  unsigned int
1729  write_msh_lines(const Triangulation<2, 2> &tria,
1730  const unsigned int next_element_index,
1731  std::ostream & out) const;
1736  unsigned int
1737  write_msh_lines(const Triangulation<2, 3> &tria,
1738  const unsigned int next_element_index,
1739  std::ostream & out) const;
1740 
1766  template <int dim, int spacedim>
1767  unsigned int
1768  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1769  const unsigned int next_element_index,
1770  std::ostream & out) const;
1771 
1775  unsigned int
1776  write_ucd_faces(const Triangulation<1, 1> &tria,
1777  const unsigned int next_element_index,
1778  std::ostream & out) const;
1779 
1784  unsigned int
1785  write_ucd_faces(const Triangulation<1, 2> &tria,
1786  const unsigned int next_element_index,
1787  std::ostream & out) const;
1788  unsigned int
1789  write_ucd_faces(const Triangulation<1, 3> &tria,
1790  const unsigned int next_element_index,
1791  std::ostream & out) const;
1792 
1793 
1819  template <int dim, int spacedim>
1820  unsigned int
1821  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1822  const unsigned int next_element_index,
1823  std::ostream & out) const;
1824 
1828  unsigned int
1829  write_ucd_lines(const Triangulation<1, 1> &tria,
1830  const unsigned int next_element_index,
1831  std::ostream & out) const;
1836  unsigned int
1837  write_ucd_lines(const Triangulation<1, 2> &tria,
1838  const unsigned int next_element_index,
1839  std::ostream & out) const;
1844  unsigned int
1845  write_ucd_lines(const Triangulation<1, 3> &tria,
1846  const unsigned int next_element_index,
1847  std::ostream & out) const;
1848 
1849 
1853  unsigned int
1854  write_ucd_lines(const Triangulation<2, 2> &tria,
1855  const unsigned int next_element_index,
1856  std::ostream & out) const;
1861  unsigned int
1862  write_ucd_lines(const Triangulation<2, 3> &tria,
1863  const unsigned int next_element_index,
1864  std::ostream & out) const;
1865 
1866 
1879  template <int dim, int spacedim>
1880  unsigned int
1881  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1882 
1887  unsigned int
1888  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1889 
1894  unsigned int
1895  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1896 
1901  unsigned int
1902  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1903 
1916  template <int dim, int spacedim>
1917  unsigned int
1918  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1919 
1924  unsigned int
1925  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1926 
1931  unsigned int
1932  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1933 
1938  unsigned int
1939  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1940 
1945  unsigned int
1946  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1951  unsigned int
1952  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1953 };
1954 
1955 
1956 
1958 
1959 #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:1548
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:53
bool serialize_triangulation
Definition: grid_out.h:914
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:1005
bool write_additional_boundary_lines
Definition: grid_out.h:272
Coloring coloring
Definition: grid_out.h:740
unsigned int n_boundary_face_points
Definition: grid_out.h:582
No cell coloring.
Definition: grid_out.h:729
GridOutFlags::Eps< 2 > eps_flags_2
Definition: grid_out.h:1583
unsigned int height
Definition: grid_out.h:661
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:1000
Convert the level number into the cell color.
Definition: grid_out.h:733
write() calls write_eps()
Definition: grid_out.h:1009
unsigned int line_thickness
Definition: grid_out.h:672
bool convert_level_number_to_height
Definition: grid_out.h:744
bool write_diameter
Definition: grid_out.h:71
unsigned int boundary_line_thickness
Definition: grid_out.h:676
bool label_boundary_id
Definition: grid_out.h:788
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:94
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:893
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:1609
Point< 2 > scaling
Definition: grid_out.h:587
bool label_cell_index
Definition: grid_out.h:764
GridOutFlags::Gnuplot gnuplot_flags
Definition: grid_out.h:1571
std::string default_suffix(const OutputFormat output_format)
static ::ExceptionBase & ExcInvalidState()
Convert the global subdomain id into the cell color.
Definition: grid_out.h:566
Convert the material id into the cell color.
Definition: grid_out.h:562
GridOutFlags::MathGL mathgl_flags
Definition: grid_out.h:1604
write() calls write_mathgl()
Definition: grid_out.h:1019
GridOutFlags::DX dx_flags
Definition: grid_out.h:1553
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1559
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1577
write() calls write_gnuplot()
Definition: grid_out.h:1007
bool label_material_id
Definition: grid_out.h:769
Abstract base class for mapping classes.
Definition: mapping.h:303
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:864
GridOutFlags::XFig xfig_flags
Definition: grid_out.h:1594
bool label_subdomain_id
Definition: grid_out.h:774
#define DeclException0(Exception0)
Definition: exceptions.h:470
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:394
OutputFormat parse_output_format(const std::string &format_name)
bool label_level_subdomain_id
Definition: grid_out.h:779
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:735
GridOutFlags::Ucd ucd_flags
Definition: grid_out.h:1565
Background background
Definition: grid_out.h:708
Do nothing in write()
Definition: grid_out.h:1003
float cell_font_scaling
Definition: grid_out.h:755
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:564
unsigned int n_boundary_face_points
Definition: grid_out.h:362
Point< 2 > offset
Definition: grid_out.h:593
write() calls write_msh()
Definition: grid_out.h:1015
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:393
write() calls write_svg()
Definition: grid_out.h:1017
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1599
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:731
float level_height_factor
Definition: grid_out.h:750
GridOutFlags::Eps< 3 > eps_flags_3
Definition: grid_out.h:1589
Vtu(const bool serialize_triangulation=false)
Definition: grid_out.h:907
static void declare_parameters(ParameterHandler &param)
Definition: grid_out.cc:66
bool label_level_number
Definition: grid_out.h:759
std::string get_output_format_names()
GridOutFlags::Vtu vtu_flags
Definition: grid_out.h:1614
unsigned int width
Definition: grid_out.h:667
write() calls write_vtk()
Definition: grid_out.h:1021
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)