Reference documentation for deal.II version Git f0d1c24e5f 2021-10-18 08:09:39 -0400
\(\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 - 2021 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 
1340  template <int dim, int spacedim>
1341  void
1342  write_vtu(const Triangulation<dim, spacedim> &tria, std::ostream &out) const;
1343 
1374  template <int dim, int spacedim>
1375  void
1376  write_mesh_per_processor_as_vtu(const Triangulation<dim, spacedim> &tria,
1377  const std::string &filename_without_extension,
1378  const bool view_levels = false,
1379  const bool include_artificial = false) const;
1380 
1385  template <int dim, int spacedim>
1386  void
1387  write(const Triangulation<dim, spacedim> &tria,
1388  std::ostream & out,
1389  const OutputFormat output_format,
1390  const Mapping<dim, spacedim> * mapping = nullptr) const;
1391 
1395  template <int dim, int spacedim>
1396  void
1397  write(const Triangulation<dim, spacedim> &tria,
1398  std::ostream & out,
1399  const Mapping<dim, spacedim> * mapping = nullptr) const;
1400 
1404  void
1405  set_flags(const GridOutFlags::DX &flags);
1406 
1410  void
1411  set_flags(const GridOutFlags::Msh &flags);
1412 
1416  void
1417  set_flags(const GridOutFlags::Ucd &flags);
1418 
1422  void
1423  set_flags(const GridOutFlags::Gnuplot &flags);
1424 
1428  void
1429  set_flags(const GridOutFlags::Eps<1> &flags);
1430 
1434  void
1435  set_flags(const GridOutFlags::Eps<2> &flags);
1436 
1440  void
1441  set_flags(const GridOutFlags::Eps<3> &flags);
1442 
1446  void
1447  set_flags(const GridOutFlags::XFig &flags);
1448 
1452  void
1453  set_flags(const GridOutFlags::Svg &flags);
1454 
1458  void
1459  set_flags(const GridOutFlags::MathGL &flags);
1460 
1464  void
1465  set_flags(const GridOutFlags::Vtk &flags);
1466 
1470  void
1471  set_flags(const GridOutFlags::Vtu &flags);
1472 
1487  static std::string
1488  default_suffix(const OutputFormat output_format);
1489 
1494  std::string
1495  default_suffix() const;
1496 
1510  static OutputFormat
1511  parse_output_format(const std::string &format_name);
1512 
1518  static std::string
1520 
1524  static void
1526 
1530  void
1532 
1537  std::size_t
1538  memory_consumption() const;
1539 
1544 
1545 private:
1550 
1555 
1561 
1567 
1573 
1579 
1585 
1591 
1596 
1601 
1606 
1611 
1616 
1642  template <int dim, int spacedim>
1643  unsigned int
1644  write_msh_faces(const Triangulation<dim, spacedim> &tria,
1645  const unsigned int next_element_index,
1646  std::ostream & out) const;
1647 
1651  unsigned int
1652  write_msh_faces(const Triangulation<1, 1> &tria,
1653  const unsigned int next_element_index,
1654  std::ostream & out) const;
1659  unsigned int
1660  write_msh_faces(const Triangulation<1, 2> &tria,
1661  const unsigned int next_element_index,
1662  std::ostream & out) const;
1663  unsigned int
1664  write_msh_faces(const Triangulation<1, 3> &tria,
1665  const unsigned int next_element_index,
1666  std::ostream & out) const;
1667 
1668 
1669 
1695  template <int dim, int spacedim>
1696  unsigned int
1697  write_msh_lines(const Triangulation<dim, spacedim> &tria,
1698  const unsigned int next_element_index,
1699  std::ostream & out) const;
1700 
1704  unsigned int
1705  write_msh_lines(const Triangulation<1, 1> &tria,
1706  const unsigned int next_element_index,
1707  std::ostream & out) const;
1708 
1713  unsigned int
1714  write_msh_lines(const Triangulation<1, 2> &tria,
1715  const unsigned int next_element_index,
1716  std::ostream & out) const;
1717 
1722  unsigned int
1723  write_msh_lines(const Triangulation<1, 3> &tria,
1724  const unsigned int next_element_index,
1725  std::ostream & out) const;
1729  unsigned int
1730  write_msh_lines(const Triangulation<2, 2> &tria,
1731  const unsigned int next_element_index,
1732  std::ostream & out) const;
1737  unsigned int
1738  write_msh_lines(const Triangulation<2, 3> &tria,
1739  const unsigned int next_element_index,
1740  std::ostream & out) const;
1741 
1767  template <int dim, int spacedim>
1768  unsigned int
1769  write_ucd_faces(const Triangulation<dim, spacedim> &tria,
1770  const unsigned int next_element_index,
1771  std::ostream & out) const;
1772 
1776  unsigned int
1777  write_ucd_faces(const Triangulation<1, 1> &tria,
1778  const unsigned int next_element_index,
1779  std::ostream & out) const;
1780 
1785  unsigned int
1786  write_ucd_faces(const Triangulation<1, 2> &tria,
1787  const unsigned int next_element_index,
1788  std::ostream & out) const;
1789  unsigned int
1790  write_ucd_faces(const Triangulation<1, 3> &tria,
1791  const unsigned int next_element_index,
1792  std::ostream & out) const;
1793 
1794 
1820  template <int dim, int spacedim>
1821  unsigned int
1822  write_ucd_lines(const Triangulation<dim, spacedim> &tria,
1823  const unsigned int next_element_index,
1824  std::ostream & out) const;
1825 
1829  unsigned int
1830  write_ucd_lines(const Triangulation<1, 1> &tria,
1831  const unsigned int next_element_index,
1832  std::ostream & out) const;
1837  unsigned int
1838  write_ucd_lines(const Triangulation<1, 2> &tria,
1839  const unsigned int next_element_index,
1840  std::ostream & out) const;
1845  unsigned int
1846  write_ucd_lines(const Triangulation<1, 3> &tria,
1847  const unsigned int next_element_index,
1848  std::ostream & out) const;
1849 
1850 
1854  unsigned int
1855  write_ucd_lines(const Triangulation<2, 2> &tria,
1856  const unsigned int next_element_index,
1857  std::ostream & out) const;
1862  unsigned int
1863  write_ucd_lines(const Triangulation<2, 3> &tria,
1864  const unsigned int next_element_index,
1865  std::ostream & out) const;
1866 
1867 
1880  template <int dim, int spacedim>
1881  unsigned int
1882  n_boundary_faces(const Triangulation<dim, spacedim> &tria) const;
1883 
1888  unsigned int
1889  n_boundary_faces(const Triangulation<1, 1> &tria) const;
1890 
1895  unsigned int
1896  n_boundary_faces(const Triangulation<1, 2> &tria) const;
1897 
1902  unsigned int
1903  n_boundary_faces(const Triangulation<1, 3> &tria) const;
1904 
1917  template <int dim, int spacedim>
1918  unsigned int
1919  n_boundary_lines(const Triangulation<dim, spacedim> &tria) const;
1920 
1925  unsigned int
1926  n_boundary_lines(const Triangulation<1, 1> &tria) const;
1927 
1932  unsigned int
1933  n_boundary_lines(const Triangulation<1, 2> &tria) const;
1934 
1939  unsigned int
1940  n_boundary_lines(const Triangulation<1, 3> &tria) const;
1941 
1946  unsigned int
1947  n_boundary_lines(const Triangulation<2, 2> &tria) const;
1952  unsigned int
1953  n_boundary_lines(const Triangulation<2, 3> &tria) const;
1954 };
1955 
1956 
1957 
1959 
1960 #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:1549
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:1584
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
const ::Triangulation< dim, spacedim > & tria
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:1610
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:1572
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:1605
write() calls write_mathgl()
Definition: grid_out.h:1019
GridOutFlags::DX dx_flags
Definition: grid_out.h:1554
GridOutFlags::Msh msh_flags
Definition: grid_out.h:1560
GridOutFlags::Eps< 1 > eps_flags_1
Definition: grid_out.h:1578
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:1595
bool label_subdomain_id
Definition: grid_out.h:774
#define DeclException0(Exception0)
Definition: exceptions.h:464
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
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:1566
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:400
write() calls write_svg()
Definition: grid_out.h:1017
GridOutFlags::Svg svg_flags
Definition: grid_out.h:1600
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:1590
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:1615
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)