Reference documentation for deal.II version Git b84270a1d4 2020-01-17 16:21:02 -0500
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
data_out_base.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2019 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_data_out_base_h
17 #define dealii_data_out_base_h
18 
19 
20 #include <deal.II/base/config.h>
21 
22 #include <deal.II/base/geometry_info.h>
23 #include <deal.II/base/mpi.h>
24 #include <deal.II/base/point.h>
25 #include <deal.II/base/table.h>
26 
27 #include <deal.II/numerics/data_component_interpretation.h>
28 
29 // To be able to serialize XDMFEntry
30 #include <boost/serialization/map.hpp>
31 
32 #include <limits>
33 #include <string>
34 #include <tuple>
35 #include <typeinfo>
36 #include <vector>
37 
38 // Only include the Tecplot API header if the appropriate files
39 // were detected by configure
40 #ifdef DEAL_II_HAVE_TECPLOT
41 # include <string.h>
42 
43 # include "TECIO.h"
44 #endif
45 
46 #include <ostream>
47 
48 DEAL_II_NAMESPACE_OPEN
49 
50 // Forward declarations
51 #ifndef DOXYGEN
52 class ParameterHandler;
53 class XDMFEntry;
54 #endif
55 
221 namespace DataOutBase
222 {
247  template <int dim, int spacedim = dim>
248  struct Patch
249  {
253  static const unsigned int space_dim = spacedim;
254 
268 
274  std::array<unsigned int, GeometryInfo<dim>::faces_per_cell> neighbors;
275 
280  unsigned int patch_index;
281 
287  unsigned int n_subdivisions;
288 
311 
325 
330  Patch();
331 
336  bool
337  operator==(const Patch &patch) const;
338 
345  std::size_t
346  memory_consumption() const;
347 
351  void
352  swap(Patch<dim, spacedim> &other_patch);
353 
357  static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
358 
369  int,
370  int,
371  << "It is not possible to have a structural dimension of " << arg1
372  << " to be larger than the space dimension of the surrounding"
373  << " space " << arg2);
375  };
376 
377 
378 
396  template <int spacedim>
397  struct Patch<0, spacedim>
398  {
402  static const unsigned int space_dim = spacedim;
403 
413 
418  static unsigned int neighbors[1];
419 
424  unsigned int patch_index;
425 
435  static unsigned int n_subdivisions;
436 
458 
472 
477  Patch();
478 
483  bool
484  operator==(const Patch &patch) const;
485 
492  std::size_t
493  memory_consumption() const;
494 
498  void swap(Patch<0, spacedim> &other_patch);
499 
503  static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
504 
515  int,
516  int,
517  << "It is not possible to have a structural dimension of " << arg1
518  << " to be larger than the space dimension of the surrounding"
519  << " space " << arg2);
521  };
522 
523 
535  template <typename FlagsType>
537  {
545  static void
546  declare_parameters(ParameterHandler &prm);
547 
555  void
556  parse_parameters(const ParameterHandler &prm);
557 
564  std::size_t
565  memory_consumption() const;
566  };
567 
568 
569  template <typename FlagsType>
570  void
572  {}
573 
574 
575  template <typename FlagsType>
576  void
578  {}
579 
580 
581  template <typename FlagsType>
582  std::size_t
584  {
585  return sizeof(FlagsType);
586  }
587 
588 
594  struct DXFlags : public OutputFlagsBase<DXFlags>
595  {
610 
615 
621 
625  DXFlags(const bool write_neighbors = false,
626  const bool int_binary = false,
627  const bool coordinates_binary = false,
628  const bool data_binary = false);
629 
634  static void
635  declare_parameters(ParameterHandler &prm);
636 
643  void
644  parse_parameters(const ParameterHandler &prm);
645  };
646 
652  struct UcdFlags : public OutputFlagsBase<UcdFlags>
653  {
664 
668  UcdFlags(const bool write_preamble = false);
669 
674  static void
675  declare_parameters(ParameterHandler &prm);
676 
683  void
684  parse_parameters(const ParameterHandler &prm);
685  };
686 
692  struct GnuplotFlags : public OutputFlagsBase<GnuplotFlags>
693  {
698  GnuplotFlags();
699 
703  GnuplotFlags(const std::vector<std::string> &space_dimension_labels);
704 
720  std::vector<std::string> space_dimension_labels;
721 
726  std::size_t
727  memory_consumption() const;
728 
733  DeclExceptionMsg(ExcNotEnoughSpaceDimensionLabels,
734  "There should be at least one space dimension per spatial "
735  "dimension (extras are ignored).");
736  };
737 
744  struct PovrayFlags : public OutputFlagsBase<PovrayFlags>
745  {
751  bool smooth;
752 
759 
767 
771  PovrayFlags(const bool smooth = false,
772  const bool bicubic_patch = false,
773  const bool external_data = false);
774 
779  static void
780  declare_parameters(ParameterHandler &prm);
781 
788  void
789  parse_parameters(const ParameterHandler &prm);
790  };
791 
792 
799  struct EpsFlags : public OutputFlagsBase<EpsFlags>
800  {
807  unsigned int height_vector;
808 
813  unsigned int color_vector;
814 
820  enum SizeType
821  {
825  height
826  };
827 
832 
840  unsigned int size;
841 
845  double line_width;
846 
852  double azimut_angle;
853 
877  double turn_angle;
878 
889  double z_scaling;
890 
897  bool draw_mesh;
898 
916 
926 
930  struct RgbValues
931  {
932  float red;
933  float green;
934  float blue;
935 
940  bool
941  is_grey() const;
942  };
943 
951  using ColorFunction = RgbValues (*)(const double value,
952  const double min_value,
953  const double max_value);
954 
961 
962 
971  static RgbValues
972  default_color_function(const double value,
973  const double min_value,
974  const double max_value);
975 
981  static RgbValues
982  grey_scale_color_function(const double value,
983  const double min_value,
984  const double max_value);
985 
992  static RgbValues
993  reverse_grey_scale_color_function(const double value,
994  const double min_value,
995  const double max_value);
996 
1000  EpsFlags(const unsigned int height_vector = 0,
1001  const unsigned int color_vector = 0,
1002  const SizeType size_type = width,
1003  const unsigned int size = 300,
1004  const double line_width = 0.5,
1005  const double azimut_angle = 60,
1006  const double turn_angle = 30,
1007  const double z_scaling = 1.0,
1008  const bool draw_mesh = true,
1009  const bool draw_cells = true,
1010  const bool shade_cells = true,
1011  const ColorFunction color_function = &default_color_function);
1012 
1020  static void
1021  declare_parameters(ParameterHandler &prm);
1022 
1029  void
1030  parse_parameters(const ParameterHandler &prm);
1031  };
1032 
1039  struct GmvFlags : public OutputFlagsBase<GmvFlags>
1040  {};
1041 
1047  struct TecplotFlags : public OutputFlagsBase<TecplotFlags>
1048  {
1056  DEAL_II_DEPRECATED const char *tecplot_binary_file_name;
1057 
1062  const char *zone_name;
1063 
1070 
1077  DEAL_II_DEPRECATED
1078  TecplotFlags(const char * tecplot_binary_file_name = nullptr,
1079  const char * zone_name = nullptr,
1080  const double solution_time = -1.0);
1081 
1086  std::size_t
1087  memory_consumption() const;
1088  };
1089 
1095  struct VtkFlags : public OutputFlagsBase<VtkFlags>
1096  {
1107  double time;
1108 
1119  unsigned int cycle;
1120 
1128 
1134  {
1152  default_compression
1153  };
1154 
1160 
1179 
1183  VtkFlags(
1184  const double time = std::numeric_limits<double>::min(),
1185  const unsigned int cycle = std::numeric_limits<unsigned int>::min(),
1186  const bool print_date_and_time = true,
1187  const ZlibCompressionLevel compression_level = best_compression,
1188  const bool write_higher_order_cells = false);
1189  };
1190 
1191 
1197  struct SvgFlags : public OutputFlagsBase<SvgFlags>
1198  {
1202  unsigned int height;
1203 
1208  unsigned int width;
1209 
1216  unsigned int height_vector;
1217 
1221  int azimuth_angle, polar_angle;
1222 
1223  unsigned int line_thickness;
1224 
1228  bool margin;
1229 
1234 
1238  SvgFlags(const unsigned int height_vector = 0,
1239  const int azimuth_angle = 37,
1240  const int polar_angle = 45,
1241  const unsigned int line_thickness = 1,
1242  const bool margin = true,
1243  const bool draw_colorbar = true);
1244  };
1245 
1246 
1254  : public OutputFlagsBase<Deal_II_IntermediateFlags>
1255  {
1262  static const unsigned int format_version;
1263  };
1264 
1271  {
1281 
1287 
1291  DataOutFilterFlags(const bool filter_duplicate_vertices = false,
1292  const bool xdmf_hdf5_output = false);
1293 
1298  static void
1299  declare_parameters(ParameterHandler &prm);
1300 
1307  void
1308  parse_parameters(const ParameterHandler &prm);
1309 
1314  std::size_t
1315  memory_consumption() const;
1316  };
1317 
1340  {
1341  public:
1345  DataOutFilter();
1346 
1352 
1358  template <int dim>
1359  void
1360  write_point(const unsigned int index, const Point<dim> &p);
1361 
1365  template <int dim>
1366  void
1367  write_cell(const unsigned int index,
1368  const unsigned int start,
1369  const unsigned int d1,
1370  const unsigned int d2,
1371  const unsigned int d3);
1372 
1379  void
1380  write_data_set(const std::string & name,
1381  const unsigned int dimension,
1382  const unsigned int set_num,
1383  const Table<2, double> &data_vectors);
1384 
1389  void
1390  fill_node_data(std::vector<double> &node_data) const;
1391 
1396  void
1397  fill_cell_data(const unsigned int local_node_offset,
1398  std::vector<unsigned int> &cell_data) const;
1399 
1403  std::string
1404  get_data_set_name(const unsigned int set_num) const;
1405 
1409  unsigned int
1410  get_data_set_dim(const unsigned int set_num) const;
1411 
1416  const double *
1417  get_data_set(const unsigned int set_num) const;
1418 
1423  unsigned int
1424  n_nodes() const;
1425 
1430  unsigned int
1431  n_cells() const;
1432 
1437  unsigned int
1438  n_data_sets() const;
1439 
1443  void
1444  flush_points();
1445 
1449  void
1450  flush_cells();
1451 
1452 
1453  private:
1457  struct Point3Comp
1458  {
1459  bool
1460  operator()(const Point<3> &one, const Point<3> &two) const
1461  {
1462  /*
1463  * The return statement below is an optimized version of the following
1464  * code:
1465  *
1466  * for (unsigned int d=0; d<3; ++d)
1467  * {
1468  * if (one(d) < two(d))
1469  * return true;
1470  * else if (one(d) > two(d))
1471  * return false;
1472  * }
1473  * return false;
1474  */
1475 
1476  return (one(0) < two(0) ||
1477  (!(two(0) < one(0)) &&
1478  (one(1) < two(1) || (!(two(1) < one(1)) && one(2) < two(2)))));
1479  }
1480  };
1481 
1482  using Map3DPoint = std::multimap<Point<3>, unsigned int, Point3Comp>;
1483 
1488 
1495  unsigned int node_dim;
1496 
1503  unsigned int vertices_per_cell;
1504 
1508  Map3DPoint existing_points;
1509 
1513  std::map<unsigned int, unsigned int> filtered_points;
1514 
1518  std::map<unsigned int, unsigned int> filtered_cells;
1519 
1523  std::vector<std::string> data_set_names;
1524 
1528  std::vector<unsigned int> data_set_dims;
1529 
1533  std::vector<std::vector<double>> data_sets;
1534 
1538  void
1539  internal_add_cell(const unsigned int cell_index,
1540  const unsigned int pt_index);
1541  };
1542 
1543 
1548  {
1553 
1558 
1563 
1568 
1573 
1578 
1583 
1588 
1593 
1601 
1606 
1611 
1616 
1621 
1626  };
1627 
1633  template <int dim, int spacedim>
1634  DEAL_II_DEPRECATED void
1635  write_dx(
1636  const std::vector<Patch<dim, spacedim>> &patches,
1637  const std::vector<std::string> & data_names,
1638  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1639  & nonscalar_data_ranges,
1640  const DXFlags &flags,
1641  std::ostream & out);
1642 
1646  template <int dim, int spacedim>
1647  void
1648  write_dx(
1649  const std::vector<Patch<dim, spacedim>> &patches,
1650  const std::vector<std::string> & data_names,
1651  const std::vector<
1652  std::tuple<unsigned int,
1653  unsigned int,
1654  std::string,
1656  & nonscalar_data_ranges,
1657  const DXFlags &flags,
1658  std::ostream & out);
1659 
1665  template <int spacedim>
1666  DEAL_II_DEPRECATED void
1667  write_eps(
1668  const std::vector<Patch<2, spacedim>> &patches,
1669  const std::vector<std::string> & data_names,
1670  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1671  & nonscalar_data_ranges,
1672  const EpsFlags &flags,
1673  std::ostream & out);
1674 
1682  template <int dim, int spacedim>
1683  DEAL_II_DEPRECATED void
1684  write_eps(
1685  const std::vector<Patch<dim, spacedim>> &patches,
1686  const std::vector<std::string> & data_names,
1687  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1688  & nonscalar_data_ranges,
1689  const EpsFlags &flags,
1690  std::ostream & out);
1691 
1736  template <int spacedim>
1737  void
1738  write_eps(
1739  const std::vector<Patch<2, spacedim>> &patches,
1740  const std::vector<std::string> & data_names,
1741  const std::vector<
1742  std::tuple<unsigned int,
1743  unsigned int,
1744  std::string,
1746  & nonscalar_data_ranges,
1747  const EpsFlags &flags,
1748  std::ostream & out);
1749 
1757  template <int dim, int spacedim>
1758  DEAL_II_DEPRECATED void
1759  write_eps(
1760  const std::vector<Patch<dim, spacedim>> &patches,
1761  const std::vector<std::string> & data_names,
1762  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1763  & nonscalar_data_ranges,
1764  const EpsFlags &flags,
1765  std::ostream & out);
1766 
1772  template <int dim, int spacedim>
1773  void
1774  write_eps(
1775  const std::vector<Patch<dim, spacedim>> &patches,
1776  const std::vector<std::string> & data_names,
1777  const std::vector<
1778  std::tuple<unsigned int,
1779  unsigned int,
1780  std::string,
1782  & nonscalar_data_ranges,
1783  const EpsFlags &flags,
1784  std::ostream & out);
1785 
1791  template <int dim, int spacedim>
1792  DEAL_II_DEPRECATED void
1793  write_gmv(
1794  const std::vector<Patch<dim, spacedim>> &patches,
1795  const std::vector<std::string> & data_names,
1796  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1797  & nonscalar_data_ranges,
1798  const GmvFlags &flags,
1799  std::ostream & out);
1800 
1810  template <int dim, int spacedim>
1811  void
1812  write_gmv(
1813  const std::vector<Patch<dim, spacedim>> &patches,
1814  const std::vector<std::string> & data_names,
1815  const std::vector<
1816  std::tuple<unsigned int,
1817  unsigned int,
1818  std::string,
1820  & nonscalar_data_ranges,
1821  const GmvFlags &flags,
1822  std::ostream & out);
1823 
1829  template <int dim, int spacedim>
1830  DEAL_II_DEPRECATED void
1831  write_gnuplot(
1832  const std::vector<Patch<dim, spacedim>> &patches,
1833  const std::vector<std::string> & data_names,
1834  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1835  & nonscalar_data_ranges,
1836  const GnuplotFlags &flags,
1837  std::ostream & out);
1838 
1895  template <int dim, int spacedim>
1896  void
1897  write_gnuplot(
1898  const std::vector<Patch<dim, spacedim>> &patches,
1899  const std::vector<std::string> & data_names,
1900  const std::vector<
1901  std::tuple<unsigned int,
1902  unsigned int,
1903  std::string,
1905  & nonscalar_data_ranges,
1906  const GnuplotFlags &flags,
1907  std::ostream & out);
1908 
1915  template <int dim, int spacedim>
1916  DEAL_II_DEPRECATED void
1917  write_povray(
1918  const std::vector<Patch<dim, spacedim>> &patches,
1919  const std::vector<std::string> & data_names,
1920  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1921  & nonscalar_data_ranges,
1922  const PovrayFlags &flags,
1923  std::ostream & out);
1924 
1970  template <int dim, int spacedim>
1971  void
1972  write_povray(
1973  const std::vector<Patch<dim, spacedim>> &patches,
1974  const std::vector<std::string> & data_names,
1975  const std::vector<
1976  std::tuple<unsigned int,
1977  unsigned int,
1978  std::string,
1980  & nonscalar_data_ranges,
1981  const PovrayFlags &flags,
1982  std::ostream & out);
1983 
1992  template <int dim, int spacedim>
1993  DEAL_II_DEPRECATED void
1994  write_tecplot(
1995  const std::vector<Patch<dim, spacedim>> &patches,
1996  const std::vector<std::string> & data_names,
1997  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1998  & nonscalar_data_ranges,
1999  const TecplotFlags &flags,
2000  std::ostream & out);
2001 
2008  template <int dim, int spacedim>
2009  void
2010  write_tecplot(
2011  const std::vector<Patch<dim, spacedim>> &patches,
2012  const std::vector<std::string> & data_names,
2013  const std::vector<
2014  std::tuple<unsigned int,
2015  unsigned int,
2016  std::string,
2018  & nonscalar_data_ranges,
2019  const TecplotFlags &flags,
2020  std::ostream & out);
2021 
2028  template <int dim, int spacedim>
2029  DEAL_II_DEPRECATED void
2031  const std::vector<Patch<dim, spacedim>> &patches,
2032  const std::vector<std::string> & data_names,
2033  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2034  & nonscalar_data_ranges,
2035  const TecplotFlags &flags,
2036  std::ostream & out);
2037 
2059  template <int dim, int spacedim>
2060  DEAL_II_DEPRECATED void
2062  const std::vector<Patch<dim, spacedim>> &patches,
2063  const std::vector<std::string> & data_names,
2064  const std::vector<
2065  std::tuple<unsigned int,
2066  unsigned int,
2067  std::string,
2069  & nonscalar_data_ranges,
2070  const TecplotFlags &flags,
2071  std::ostream & out);
2072 
2079  template <int dim, int spacedim>
2080  DEAL_II_DEPRECATED void
2081  write_ucd(
2082  const std::vector<Patch<dim, spacedim>> &patches,
2083  const std::vector<std::string> & data_names,
2084  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2085  & nonscalar_data_ranges,
2086  const UcdFlags &flags,
2087  std::ostream & out);
2088 
2103  template <int dim, int spacedim>
2104  void
2105  write_ucd(
2106  const std::vector<Patch<dim, spacedim>> &patches,
2107  const std::vector<std::string> & data_names,
2108  const std::vector<
2109  std::tuple<unsigned int,
2110  unsigned int,
2111  std::string,
2113  & nonscalar_data_ranges,
2114  const UcdFlags &flags,
2115  std::ostream & out);
2116 
2124  template <int dim, int spacedim>
2125  DEAL_II_DEPRECATED void
2126  write_vtk(
2127  const std::vector<Patch<dim, spacedim>> &patches,
2128  const std::vector<std::string> & data_names,
2129  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2130  & nonscalar_data_ranges,
2131  const VtkFlags &flags,
2132  std::ostream & out);
2133 
2153  template <int dim, int spacedim>
2154  void
2155  write_vtk(
2156  const std::vector<Patch<dim, spacedim>> &patches,
2157  const std::vector<std::string> & data_names,
2158  const std::vector<
2159  std::tuple<unsigned int,
2160  unsigned int,
2161  std::string,
2163  & nonscalar_data_ranges,
2164  const VtkFlags &flags,
2165  std::ostream & out);
2166 
2174  template <int dim, int spacedim>
2175  DEAL_II_DEPRECATED void
2176  write_vtu(
2177  const std::vector<Patch<dim, spacedim>> &patches,
2178  const std::vector<std::string> & data_names,
2179  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2180  & nonscalar_data_ranges,
2181  const VtkFlags &flags,
2182  std::ostream & out);
2183 
2207  template <int dim, int spacedim>
2208  void
2209  write_vtu(
2210  const std::vector<Patch<dim, spacedim>> &patches,
2211  const std::vector<std::string> & data_names,
2212  const std::vector<
2213  std::tuple<unsigned int,
2214  unsigned int,
2215  std::string,
2217  & nonscalar_data_ranges,
2218  const VtkFlags &flags,
2219  std::ostream & out);
2220 
2226  void
2227  write_vtu_header(std::ostream &out, const VtkFlags &flags);
2228 
2235  void
2236  write_vtu_footer(std::ostream &out);
2237 
2246  template <int dim, int spacedim>
2247  DEAL_II_DEPRECATED void
2249  const std::vector<Patch<dim, spacedim>> &patches,
2250  const std::vector<std::string> & data_names,
2251  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2252  & nonscalar_data_ranges,
2253  const VtkFlags &flags,
2254  std::ostream & out);
2255 
2262  template <int dim, int spacedim>
2263  void
2265  const std::vector<Patch<dim, spacedim>> &patches,
2266  const std::vector<std::string> & data_names,
2267  const std::vector<
2268  std::tuple<unsigned int,
2269  unsigned int,
2270  std::string,
2272  & nonscalar_data_ranges,
2273  const VtkFlags &flags,
2274  std::ostream & out);
2275 
2286  DEAL_II_DEPRECATED
2287  void
2289  std::ostream & out,
2290  const std::vector<std::string> &piece_names,
2291  const std::vector<std::string> &data_names,
2292  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2293  &nonscalar_data_ranges);
2294 
2336  void
2338  std::ostream & out,
2339  const std::vector<std::string> &piece_names,
2340  const std::vector<std::string> &data_names,
2341  const std::vector<
2342  std::tuple<unsigned int,
2343  unsigned int,
2344  std::string,
2346  &nonscalar_data_ranges);
2347 
2398  void
2400  std::ostream & out,
2401  const std::vector<std::pair<double, std::string>> &times_and_names);
2402 
2414  void
2415  write_visit_record(std::ostream & out,
2416  const std::vector<std::string> &piece_names);
2417 
2445  void
2446  write_visit_record(std::ostream & out,
2447  const std::vector<std::vector<std::string>> &piece_names);
2448 
2481  void
2483  std::ostream &out,
2484  const std::vector<std::pair<double, std::vector<std::string>>>
2485  &times_and_piece_names);
2486 
2492  template <int spacedim>
2493  DEAL_II_DEPRECATED void
2494  write_svg(
2495  const std::vector<Patch<2, spacedim>> &patches,
2496  const std::vector<std::string> & data_names,
2497  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2498  & nonscalar_data_ranges,
2499  const SvgFlags &flags,
2500  std::ostream & out);
2501 
2522  template <int spacedim>
2523  void
2524  write_svg(
2525  const std::vector<Patch<2, spacedim>> &patches,
2526  const std::vector<std::string> & data_names,
2527  const std::vector<
2528  std::tuple<unsigned int,
2529  unsigned int,
2530  std::string,
2532  & nonscalar_data_ranges,
2533  const SvgFlags &flags,
2534  std::ostream & out);
2535 
2547  template <int dim, int spacedim>
2548  DEAL_II_DEPRECATED void
2550  const std::vector<Patch<dim, spacedim>> &patches,
2551  const std::vector<std::string> & data_names,
2552  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2553  & nonscalar_data_ranges,
2554  const Deal_II_IntermediateFlags &flags,
2555  std::ostream & out);
2556 
2594  template <int dim, int spacedim>
2595  void
2597  const std::vector<Patch<dim, spacedim>> &patches,
2598  const std::vector<std::string> & data_names,
2599  const std::vector<
2600  std::tuple<unsigned int,
2601  unsigned int,
2602  std::string,
2604  & nonscalar_data_ranges,
2605  const Deal_II_IntermediateFlags &flags,
2606  std::ostream & out);
2607 
2612  template <int dim, int spacedim>
2613  void
2614  write_hdf5_parallel(const std::vector<Patch<dim, spacedim>> &patches,
2615  const DataOutFilter & data_filter,
2616  const std::string & filename,
2617  MPI_Comm comm);
2618 
2626  template <int dim, int spacedim>
2627  void
2628  write_hdf5_parallel(const std::vector<Patch<dim, spacedim>> &patches,
2629  const DataOutFilter & data_filter,
2630  const bool write_mesh_file,
2631  const std::string & mesh_filename,
2632  const std::string &solution_filename,
2633  MPI_Comm comm);
2634 
2643  template <int dim, int spacedim>
2644  DEAL_II_DEPRECATED void
2646  const std::vector<Patch<dim, spacedim>> &patches,
2647  const std::vector<std::string> & data_names,
2648  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2649  & nonscalar_data_ranges,
2650  DataOutFilter &filtered_data);
2651 
2658  template <int dim, int spacedim>
2659  void
2661  const std::vector<Patch<dim, spacedim>> &patches,
2662  const std::vector<std::string> & data_names,
2663  const std::vector<
2664  std::tuple<unsigned int,
2665  unsigned int,
2666  std::string,
2668  & nonscalar_data_ranges,
2669  DataOutFilter &filtered_data);
2670 
2682  std::pair<unsigned int, unsigned int>
2683  determine_intermediate_format_dimensions(std::istream &input);
2684 
2696  OutputFormat
2697  parse_output_format(const std::string &format_name);
2698 
2704  std::string
2706 
2727  std::string
2728  default_suffix(const OutputFormat output_format);
2729 
2739  int,
2740  int,
2741  << "The number of points in this data set is " << arg1
2742  << ", but we expected " << arg2
2743  << " in each space direction.");
2748  "You are trying to write graphical data into a file, but "
2749  "no data is available in the intermediate format that "
2750  "the DataOutBase functions require. Did you forget to "
2751  "call a function such as DataOut::build_patches()?");
2756  "The error code of one of the Tecplot functions was "
2757  "not zero as expected.");
2762  char *,
2763  << "There was an error opening Tecplot file " << arg1
2764  << " for output.");
2765 
2767 } // namespace DataOutBase
2768 
2769 
2770 
2878 template <int dim, int spacedim = dim>
2880 {
2881 public:
2885  DataOutInterface();
2886 
2891  virtual ~DataOutInterface() = default;
2892 
2897  void
2898  write_dx(std::ostream &out) const;
2899 
2904  void
2905  write_eps(std::ostream &out) const;
2906 
2911  void
2912  write_gmv(std::ostream &out) const;
2913 
2918  void
2919  write_gnuplot(std::ostream &out) const;
2920 
2925  void
2926  write_povray(std::ostream &out) const;
2927 
2932  void
2933  write_tecplot(std::ostream &out) const;
2934 
2942  DEAL_II_DEPRECATED
2943  void
2944  write_tecplot_binary(std::ostream &out) const;
2945 
2950  void
2951  write_ucd(std::ostream &out) const;
2952 
2964  void
2965  write_vtk(std::ostream &out) const;
2966 
2981  void
2982  write_vtu(std::ostream &out) const;
2983 
2992  void
2993  write_vtu_in_parallel(const std::string &filename, MPI_Comm comm) const;
2994 
3028  void
3029  write_pvtu_record(std::ostream & out,
3030  const std::vector<std::string> &piece_names) const;
3031 
3091  std::string
3092  write_vtu_with_pvtu_record(
3093  const std::string &directory,
3094  const std::string &filename_without_extension,
3095  const unsigned int counter,
3096  const unsigned int n_digits_for_counter = numbers::invalid_unsigned_int,
3097  const MPI_Comm & mpi_communicator = MPI_COMM_WORLD,
3098  const unsigned int n_groups = 0) const;
3099 
3104  void
3105  write_svg(std::ostream &out) const;
3106 
3117  void
3118  write_deal_II_intermediate(std::ostream &out) const;
3119 
3125  XDMFEntry
3126  create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter,
3127  const std::string & h5_filename,
3128  const double cur_time,
3129  MPI_Comm comm) const;
3130 
3136  XDMFEntry
3137  create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter,
3138  const std::string & h5_mesh_filename,
3139  const std::string & h5_solution_filename,
3140  const double cur_time,
3141  MPI_Comm comm) const;
3142 
3167  void
3168  write_xdmf_file(const std::vector<XDMFEntry> &entries,
3169  const std::string & filename,
3170  MPI_Comm comm) const;
3171 
3186  void
3188  const std::string & filename,
3189  MPI_Comm comm) const;
3190 
3198  void
3200  const bool write_mesh_file,
3201  const std::string & mesh_filename,
3202  const std::string & solution_filename,
3203  MPI_Comm comm) const;
3204 
3211  void
3212  write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const;
3213 
3214 
3223  void
3224  write(std::ostream & out,
3225  const DataOutBase::OutputFormat output_format =
3227 
3232  void
3233  set_default_format(const DataOutBase::OutputFormat default_format);
3234 
3235 
3240  template <typename FlagType>
3241  void
3242  set_flags(const FlagType &flags);
3243 
3244 
3252  std::string
3253  default_suffix(const DataOutBase::OutputFormat output_format =
3255 
3270  static void
3271  declare_parameters(ParameterHandler &prm);
3272 
3280  void
3281  parse_parameters(ParameterHandler &prm);
3282 
3288  std::size_t
3289  memory_consumption() const;
3290 
3291 protected:
3299  virtual const std::vector<DataOutBase::Patch<dim, spacedim>> &
3300  get_patches() const = 0;
3301 
3306  virtual std::vector<std::string>
3307  get_dataset_names() const = 0;
3308 
3316  DEAL_II_DEPRECATED
3317  virtual std::vector<std::tuple<unsigned int, unsigned int, std::string>>
3318  get_vector_data_ranges() const;
3319 
3338  virtual std::vector<
3339  std::tuple<unsigned int,
3340  unsigned int,
3341  std::string,
3343  get_nonscalar_data_ranges() const;
3344 
3351  void
3352  validate_dataset_names() const;
3353 
3354 
3360  unsigned int default_subdivisions;
3361 
3362 private:
3369 
3375 
3381 
3387 
3393 
3399 
3405 
3411 
3417 
3423 
3429 };
3430 
3431 
3432 
3481 template <int dim, int spacedim = dim>
3482 class DataOutReader : public DataOutInterface<dim, spacedim>
3483 {
3484 public:
3490  void
3491  read(std::istream &in);
3492 
3516  void
3517  merge(const DataOutReader<dim, spacedim> &other);
3518 
3523  "You are trying to merge two sets of patches for which the "
3524  "declared names of the variables do not match.");
3529  "You are trying to merge two sets of patches for which the "
3530  "number of subdivisions or the number of vector components "
3531  "do not match.");
3535  DeclException4(ExcIncompatibleDimensions,
3536  int,
3537  int,
3538  int,
3539  int,
3540  << "Either the dimensions <" << arg1 << "> and <" << arg2
3541  << "> or the space dimensions <" << arg3 << "> and <" << arg4
3542  << "> do not match!");
3543 
3544 protected:
3553  virtual const std::vector<::DataOutBase::Patch<dim, spacedim>> &
3554  get_patches() const override;
3555 
3562  virtual std::vector<std::string>
3563  get_dataset_names() const override;
3564 
3583  virtual std::vector<
3584  std::tuple<unsigned int,
3585  unsigned int,
3586  std::string,
3588  get_nonscalar_data_ranges() const override;
3589 
3590 private:
3595  std::vector<::DataOutBase::Patch<dim, spacedim>> patches;
3596  std::vector<std::string> dataset_names;
3597 
3602  std::vector<
3603  std::tuple<unsigned int,
3604  unsigned int,
3605  std::string,
3608 };
3609 
3610 
3611 
3620 {
3621 public:
3625  XDMFEntry();
3626 
3632  XDMFEntry(const std::string &filename,
3633  const double time,
3634  const unsigned int nodes,
3635  const unsigned int cells,
3636  const unsigned int dim);
3637 
3642  XDMFEntry(const std::string &mesh_filename,
3643  const std::string &solution_filename,
3644  const double time,
3645  const unsigned int nodes,
3646  const unsigned int cells,
3647  const unsigned int dim);
3648 
3652  XDMFEntry(const std::string &mesh_filename,
3653  const std::string &solution_filename,
3654  const double time,
3655  const unsigned int nodes,
3656  const unsigned int cells,
3657  const unsigned int dim,
3658  const unsigned int spacedim);
3659 
3663  void
3664  add_attribute(const std::string &attr_name, const unsigned int dimension);
3665 
3669  template <class Archive>
3670  void
3671  serialize(Archive &ar, const unsigned int /*version*/)
3672  {
3673  ar &valid &h5_sol_filename &h5_mesh_filename &entry_time &num_nodes
3674  &num_cells &dimension &space_dimension &attribute_dims;
3675  }
3676 
3681  std::string
3682  get_xdmf_content(const unsigned int indent_level) const;
3683 
3684 private:
3688  bool valid;
3689 
3693  std::string h5_sol_filename;
3694 
3698  std::string h5_mesh_filename;
3699 
3703  double entry_time;
3704 
3708  unsigned int num_nodes;
3709 
3713  unsigned int num_cells;
3714 
3718  unsigned int dimension;
3719 
3724  unsigned int space_dimension;
3725 
3729  std::map<std::string, unsigned int> attribute_dims;
3730 };
3731 
3732 
3733 
3734 /* -------------------- inline functions ------------------- */
3735 
3736 namespace DataOutBase
3737 {
3738  inline bool
3740  {
3741  return (red == green) && (red == blue);
3742  }
3743 
3744 
3745  /* -------------------- template functions ------------------- */
3746 
3755  template <int dim, int spacedim>
3756  std::ostream &
3757  operator<<(std::ostream &out, const Patch<dim, spacedim> &patch);
3758 
3759 
3760 
3769  template <int dim, int spacedim>
3770  std::istream &
3771  operator>>(std::istream &in, Patch<dim, spacedim> &patch);
3772 } // namespace DataOutBase
3773 
3774 
3775 DEAL_II_NAMESPACE_CLOSE
3776 
3777 #endif
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
static const unsigned int invalid_unsigned_int
Definition: types.h:187
unsigned int space_dimension
static ::ExceptionBase & ExcIncompatiblePatchLists()
unsigned int height_vector
void write_vtu_footer(std::ostream &out)
static void declare_parameters(ParameterHandler &prm)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:541
std::size_t memory_consumption() const
void write_vtu_main(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 >> &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
std::map< unsigned int, unsigned int > filtered_cells
void write_gmv(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 >> &nonscalar_data_ranges, const GmvFlags &flags, std::ostream &out)
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names)
unsigned int num_cells
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
void swap(Patch< dim, spacedim > &other_patch)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
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 >> &nonscalar_data_ranges, const SvgFlags &flags, std::ostream &out)
std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > nonscalar_data_ranges
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string >> &times_and_names)
double entry_time
ZlibCompressionLevel compression_level
unsigned int default_subdivisions
std::vector< unsigned int > data_set_dims
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
std::vector< std::vector< double > > data_sets
std::map< std::string, unsigned int > attribute_dims
void write_filtered_data(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 >> &nonscalar_data_ranges, DataOutFilter &filtered_data)
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim >> &patches, const DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm)
void write_tecplot(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 >> &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
const char * tecplot_binary_file_name
void write_deal_II_intermediate(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 >> &nonscalar_data_ranges, const Deal_II_IntermediateFlags &flags, std::ostream &out)
static ::ExceptionBase & ExcNoPatches()
DataOutBase::PovrayFlags povray_flags
static ::ExceptionBase & ExcIncompatibleDatasetNames()
DataOutBase::DataOutFilterFlags flags
std::string default_suffix(const OutputFormat output_format)
unsigned int patch_index
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
std::vector< std::string > space_dimension_labels
void serialize(Archive &ar, const unsigned int)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
std::vector< std::string > data_set_names
void parse_parameters(const ParameterHandler &prm)
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 >> &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
void write_tecplot_binary(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 >> &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
DataOutBase::Deal_II_IntermediateFlags deal_II_intermediate_flags
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:496
std::vector<::DataOutBase::Patch< dim, spacedim > > patches
OutputFormat parse_output_format(const std::string &format_name)
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 >> &nonscalar_data_ranges, const DXFlags &flags, std::ostream &out)
ColorFunction color_function
unsigned int n_subdivisions
DataOutBase::TecplotFlags tecplot_flags
Scale to given width.
DataOutBase::SvgFlags svg_flags
unsigned int dimension
std::string h5_sol_filename
std::string h5_mesh_filename
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
bool operator==(const Patch &patch) const
void write_povray(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 >> &nonscalar_data_ranges, const PovrayFlags &flags, std::ostream &out)
static const unsigned int no_neighbor
DataOutBase::GmvFlags gmv_flags
DataOutBase::VtkFlags vtk_flags
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 >> &nonscalar_data_ranges, const UcdFlags &flags, std::ostream &out)
static const unsigned int format_version
static const unsigned int space_dim
DataOutBase::GnuplotFlags gnuplot_flags
unsigned int num_nodes
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:587
unsigned int color_vector
static ::ExceptionBase & ExcInvalidCombinationOfDimensions(int arg1, int arg2)
DataOutBase::OutputFormat default_fmt
std::array< unsigned int, GeometryInfo< dim >::faces_per_cell > neighbors
DataOutBase::EpsFlags eps_flags
DEAL_II_CONSTEXPR TableIndices< 2 > merge(const TableIndices< 2 > &previous_indices, const unsigned int new_index, const unsigned int position)
std::size_t memory_consumption() const
std::map< unsigned int, unsigned int > filtered_points
static unsigned int n_subdivisions
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names, const std::vector< std::string > &data_names, const std::vector< std::tuple< unsigned int, unsigned int, std::string >> &nonscalar_data_ranges)
std::string get_output_format_names()
Table< 2, float > data
DataOutBase::UcdFlags ucd_flags
unsigned int height_vector
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 >> &nonscalar_data_ranges, const GnuplotFlags &flags, std::ostream &out)
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 >> &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
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 >> &nonscalar_data_ranges, const EpsFlags &flags, std::ostream &out)
static ::ExceptionBase & ExcErrorOpeningTecplotFile(char *arg1)
DataOutBase::DXFlags dx_flags
static ::ExceptionBase & ExcTecplotAPIError()