Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
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 
51 class ParameterHandler;
52 class XDMFEntry;
53 
219 namespace DataOutBase
220 {
245  template <int dim, int spacedim = dim>
246  struct Patch
247  {
251  static const unsigned int space_dim = spacedim;
252 
266 
273  unsigned int neighbors[dim > 0 ? GeometryInfo<dim>::faces_per_cell : 1];
274 
279  unsigned int patch_index;
280 
286  unsigned int n_subdivisions;
287 
310 
324 
329  Patch();
330 
335  bool
336  operator==(const Patch &patch) const;
337 
344  std::size_t
345  memory_consumption() const;
346 
350  void
351  swap(Patch<dim, spacedim> &other_patch);
352 
356  static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
357 
368  int,
369  int,
370  << "It is not possible to have a structural dimension of " << arg1
371  << " to be larger than the space dimension of the surrounding"
372  << " space " << arg2);
374  };
375 
376 
377 
395  template <int spacedim>
396  struct Patch<0, spacedim>
397  {
401  static const unsigned int space_dim = spacedim;
402 
412 
417  static unsigned int neighbors[1];
418 
423  unsigned int patch_index;
424 
434  static unsigned int n_subdivisions;
435 
457 
471 
476  Patch();
477 
482  bool
483  operator==(const Patch &patch) const;
484 
491  std::size_t
492  memory_consumption() const;
493 
497  void swap(Patch<0, spacedim> &other_patch);
498 
502  static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
503 
514  int,
515  int,
516  << "It is not possible to have a structural dimension of " << arg1
517  << " to be larger than the space dimension of the surrounding"
518  << " space " << arg2);
520  };
521 
522 
534  template <typename FlagsType>
536  {
544  static void
546 
554  void
556 
563  std::size_t
564  memory_consumption() const;
565  };
566 
567 
568  template <typename FlagsType>
569  void
571  {}
572 
573 
574  template <typename FlagsType>
575  void
577  {}
578 
579 
580  template <typename FlagsType>
581  std::size_t
583  {
584  return sizeof(FlagsType);
585  }
586 
587 
593  struct DXFlags : public OutputFlagsBase<DXFlags>
594  {
609 
614 
620 
624  DXFlags(const bool write_neighbors = false,
625  const bool int_binary = false,
626  const bool coordinates_binary = false,
627  const bool data_binary = false);
628 
633  static void
635 
642  void
644  };
645 
651  struct UcdFlags : public OutputFlagsBase<UcdFlags>
652  {
663 
667  UcdFlags(const bool write_preamble = false);
668 
673  static void
675 
682  void
684  };
685 
691  struct GnuplotFlags : public OutputFlagsBase<GnuplotFlags>
692  {
697  GnuplotFlags();
698 
702  GnuplotFlags(const std::vector<std::string> &space_dimension_labels);
703 
719  std::vector<std::string> space_dimension_labels;
720 
725  std::size_t
726  memory_consumption() const;
727 
733  "There should be at least one space dimension per spatial "
734  "dimension (extras are ignored).");
735  };
736 
743  struct PovrayFlags : public OutputFlagsBase<PovrayFlags>
744  {
750  bool smooth;
751 
758 
766 
770  PovrayFlags(const bool smooth = false,
771  const bool bicubic_patch = false,
772  const bool external_data = false);
773 
778  static void
780 
787  void
789  };
790 
791 
798  struct EpsFlags : public OutputFlagsBase<EpsFlags>
799  {
806  unsigned int height_vector;
807 
812  unsigned int color_vector;
813 
819  enum SizeType
820  {
825  };
826 
831 
839  unsigned int size;
840 
844  double line_width;
845 
851  double azimut_angle;
852 
876  double turn_angle;
877 
888  double z_scaling;
889 
896  bool draw_mesh;
897 
915 
925 
929  struct RgbValues
930  {
931  float red;
932  float green;
933  float blue;
934 
939  bool
940  is_grey() const;
941  };
942 
950  using ColorFunction = RgbValues (*)(const double value,
951  const double min_value,
952  const double max_value);
953 
960 
961 
970  static RgbValues
971  default_color_function(const double value,
972  const double min_value,
973  const double max_value);
974 
980  static RgbValues
981  grey_scale_color_function(const double value,
982  const double min_value,
983  const double max_value);
984 
991  static RgbValues
992  reverse_grey_scale_color_function(const double value,
993  const double min_value,
994  const double max_value);
995 
999  EpsFlags(const unsigned int height_vector = 0,
1000  const unsigned int color_vector = 0,
1001  const SizeType size_type = width,
1002  const unsigned int size = 300,
1003  const double line_width = 0.5,
1004  const double azimut_angle = 60,
1005  const double turn_angle = 30,
1006  const double z_scaling = 1.0,
1007  const bool draw_mesh = true,
1008  const bool draw_cells = true,
1009  const bool shade_cells = true,
1011 
1019  static void
1021 
1028  void
1029  parse_parameters(const ParameterHandler &prm);
1030  };
1031 
1038  struct GmvFlags : public OutputFlagsBase<GmvFlags>
1039  {};
1040 
1046  struct TecplotFlags : public OutputFlagsBase<TecplotFlags>
1047  {
1055  DEAL_II_DEPRECATED const char *tecplot_binary_file_name;
1056 
1061  const char *zone_name;
1062 
1069 
1076  DEAL_II_DEPRECATED
1077  TecplotFlags(const char * tecplot_binary_file_name = nullptr,
1078  const char * zone_name = nullptr,
1079  const double solution_time = -1.0);
1080 
1085  std::size_t
1086  memory_consumption() const;
1087  };
1088 
1094  struct VtkFlags : public OutputFlagsBase<VtkFlags>
1095  {
1106  double time;
1107 
1118  unsigned int cycle;
1119 
1127 
1133  {
1152  };
1153 
1159 
1178 
1182  VtkFlags(
1183  const double time = std::numeric_limits<double>::min(),
1184  const unsigned int cycle = std::numeric_limits<unsigned int>::min(),
1185  const bool print_date_and_time = true,
1187  const bool write_higher_order_cells = false);
1188  };
1189 
1190 
1196  struct SvgFlags : public OutputFlagsBase<SvgFlags>
1197  {
1201  unsigned int height;
1202 
1207  unsigned int width;
1208 
1215  unsigned int height_vector;
1216 
1220  int azimuth_angle, polar_angle;
1221 
1222  unsigned int line_thickness;
1223 
1227  bool margin;
1228 
1233 
1237  SvgFlags(const unsigned int height_vector = 0,
1238  const int azimuth_angle = 37,
1239  const int polar_angle = 45,
1240  const unsigned int line_thickness = 1,
1241  const bool margin = true,
1242  const bool draw_colorbar = true);
1243  };
1244 
1245 
1253  : public OutputFlagsBase<Deal_II_IntermediateFlags>
1254  {
1261  static const unsigned int format_version;
1262  };
1263 
1270  {
1280 
1286 
1290  DataOutFilterFlags(const bool filter_duplicate_vertices = false,
1291  const bool xdmf_hdf5_output = false);
1292 
1297  static void
1299 
1306  void
1307  parse_parameters(const ParameterHandler &prm);
1308 
1313  std::size_t
1314  memory_consumption() const;
1315  };
1316 
1339  {
1340  public:
1344  DataOutFilter();
1345 
1351 
1357  template <int dim>
1358  void
1359  write_point(const unsigned int index, const Point<dim> &p);
1360 
1364  template <int dim>
1365  void
1366  write_cell(const unsigned int index,
1367  const unsigned int start,
1368  const unsigned int d1,
1369  const unsigned int d2,
1370  const unsigned int d3);
1371 
1378  void
1379  write_data_set(const std::string & name,
1380  const unsigned int dimension,
1381  const unsigned int set_num,
1382  const Table<2, double> &data_vectors);
1383 
1388  void
1389  fill_node_data(std::vector<double> &node_data) const;
1390 
1395  void
1396  fill_cell_data(const unsigned int local_node_offset,
1397  std::vector<unsigned int> &cell_data) const;
1398 
1402  std::string
1403  get_data_set_name(const unsigned int set_num) const;
1404 
1408  unsigned int
1409  get_data_set_dim(const unsigned int set_num) const;
1410 
1415  const double *
1416  get_data_set(const unsigned int set_num) const;
1417 
1422  unsigned int
1423  n_nodes() const;
1424 
1429  unsigned int
1430  n_cells() const;
1431 
1436  unsigned int
1437  n_data_sets() const;
1438 
1442  void
1443  flush_points();
1444 
1448  void
1449  flush_cells();
1450 
1451 
1452  private:
1456  struct Point3Comp
1457  {
1458  bool
1459  operator()(const Point<3> &one, const Point<3> &two) const
1460  {
1461  /*
1462  * The return statement below is an optimized version of the following
1463  * code:
1464  *
1465  * for (unsigned int d=0; d<3; ++d)
1466  * {
1467  * if (one(d) < two(d))
1468  * return true;
1469  * else if (one(d) > two(d))
1470  * return false;
1471  * }
1472  * return false;
1473  */
1474 
1475  return (one(0) < two(0) ||
1476  (!(two(0) < one(0)) &&
1477  (one(1) < two(1) || (!(two(1) < one(1)) && one(2) < two(2)))));
1478  }
1479  };
1480 
1481  using Map3DPoint = std::multimap<Point<3>, unsigned int, Point3Comp>;
1482 
1487 
1494  unsigned int node_dim;
1495 
1502  unsigned int vertices_per_cell;
1503 
1507  Map3DPoint existing_points;
1508 
1512  std::map<unsigned int, unsigned int> filtered_points;
1513 
1517  std::map<unsigned int, unsigned int> filtered_cells;
1518 
1522  std::vector<std::string> data_set_names;
1523 
1527  std::vector<unsigned int> data_set_dims;
1528 
1532  std::vector<std::vector<double>> data_sets;
1533 
1537  void
1538  internal_add_cell(const unsigned int cell_index,
1539  const unsigned int pt_index);
1540  };
1541 
1542 
1547  {
1552 
1557 
1562 
1567 
1572 
1577 
1582 
1587 
1592 
1600 
1605 
1610 
1615 
1620 
1625  };
1626 
1632  template <int dim, int spacedim>
1633  DEAL_II_DEPRECATED void
1634  write_dx(
1635  const std::vector<Patch<dim, spacedim>> &patches,
1636  const std::vector<std::string> & data_names,
1637  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1638  & nonscalar_data_ranges,
1639  const DXFlags &flags,
1640  std::ostream & out);
1641 
1645  template <int dim, int spacedim>
1646  void
1647  write_dx(
1648  const std::vector<Patch<dim, spacedim>> &patches,
1649  const std::vector<std::string> & data_names,
1650  const std::vector<
1651  std::tuple<unsigned int,
1652  unsigned int,
1653  std::string,
1655  & nonscalar_data_ranges,
1656  const DXFlags &flags,
1657  std::ostream & out);
1658 
1664  template <int spacedim>
1665  DEAL_II_DEPRECATED void
1666  write_eps(
1667  const std::vector<Patch<2, spacedim>> &patches,
1668  const std::vector<std::string> & data_names,
1669  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1670  & nonscalar_data_ranges,
1671  const EpsFlags &flags,
1672  std::ostream & out);
1673 
1681  template <int dim, int spacedim>
1682  DEAL_II_DEPRECATED void
1683  write_eps(
1684  const std::vector<Patch<dim, spacedim>> &patches,
1685  const std::vector<std::string> & data_names,
1686  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1687  & nonscalar_data_ranges,
1688  const EpsFlags &flags,
1689  std::ostream & out);
1690 
1735  template <int spacedim>
1736  void
1737  write_eps(
1738  const std::vector<Patch<2, spacedim>> &patches,
1739  const std::vector<std::string> & data_names,
1740  const std::vector<
1741  std::tuple<unsigned int,
1742  unsigned int,
1743  std::string,
1745  & nonscalar_data_ranges,
1746  const EpsFlags &flags,
1747  std::ostream & out);
1748 
1756  template <int dim, int spacedim>
1757  DEAL_II_DEPRECATED void
1758  write_eps(
1759  const std::vector<Patch<dim, spacedim>> &patches,
1760  const std::vector<std::string> & data_names,
1761  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1762  & nonscalar_data_ranges,
1763  const EpsFlags &flags,
1764  std::ostream & out);
1765 
1771  template <int dim, int spacedim>
1772  void
1773  write_eps(
1774  const std::vector<Patch<dim, spacedim>> &patches,
1775  const std::vector<std::string> & data_names,
1776  const std::vector<
1777  std::tuple<unsigned int,
1778  unsigned int,
1779  std::string,
1781  & nonscalar_data_ranges,
1782  const EpsFlags &flags,
1783  std::ostream & out);
1784 
1790  template <int dim, int spacedim>
1791  DEAL_II_DEPRECATED void
1792  write_gmv(
1793  const std::vector<Patch<dim, spacedim>> &patches,
1794  const std::vector<std::string> & data_names,
1795  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1796  & nonscalar_data_ranges,
1797  const GmvFlags &flags,
1798  std::ostream & out);
1799 
1809  template <int dim, int spacedim>
1810  void
1811  write_gmv(
1812  const std::vector<Patch<dim, spacedim>> &patches,
1813  const std::vector<std::string> & data_names,
1814  const std::vector<
1815  std::tuple<unsigned int,
1816  unsigned int,
1817  std::string,
1819  & nonscalar_data_ranges,
1820  const GmvFlags &flags,
1821  std::ostream & out);
1822 
1828  template <int dim, int spacedim>
1829  DEAL_II_DEPRECATED void
1830  write_gnuplot(
1831  const std::vector<Patch<dim, spacedim>> &patches,
1832  const std::vector<std::string> & data_names,
1833  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1834  & nonscalar_data_ranges,
1835  const GnuplotFlags &flags,
1836  std::ostream & out);
1837 
1894  template <int dim, int spacedim>
1895  void
1896  write_gnuplot(
1897  const std::vector<Patch<dim, spacedim>> &patches,
1898  const std::vector<std::string> & data_names,
1899  const std::vector<
1900  std::tuple<unsigned int,
1901  unsigned int,
1902  std::string,
1904  & nonscalar_data_ranges,
1905  const GnuplotFlags &flags,
1906  std::ostream & out);
1907 
1914  template <int dim, int spacedim>
1915  DEAL_II_DEPRECATED void
1916  write_povray(
1917  const std::vector<Patch<dim, spacedim>> &patches,
1918  const std::vector<std::string> & data_names,
1919  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1920  & nonscalar_data_ranges,
1921  const PovrayFlags &flags,
1922  std::ostream & out);
1923 
1969  template <int dim, int spacedim>
1970  void
1971  write_povray(
1972  const std::vector<Patch<dim, spacedim>> &patches,
1973  const std::vector<std::string> & data_names,
1974  const std::vector<
1975  std::tuple<unsigned int,
1976  unsigned int,
1977  std::string,
1979  & nonscalar_data_ranges,
1980  const PovrayFlags &flags,
1981  std::ostream & out);
1982 
1991  template <int dim, int spacedim>
1992  DEAL_II_DEPRECATED void
1993  write_tecplot(
1994  const std::vector<Patch<dim, spacedim>> &patches,
1995  const std::vector<std::string> & data_names,
1996  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
1997  & nonscalar_data_ranges,
1998  const TecplotFlags &flags,
1999  std::ostream & out);
2000 
2007  template <int dim, int spacedim>
2008  void
2009  write_tecplot(
2010  const std::vector<Patch<dim, spacedim>> &patches,
2011  const std::vector<std::string> & data_names,
2012  const std::vector<
2013  std::tuple<unsigned int,
2014  unsigned int,
2015  std::string,
2017  & nonscalar_data_ranges,
2018  const TecplotFlags &flags,
2019  std::ostream & out);
2020 
2027  template <int dim, int spacedim>
2028  DEAL_II_DEPRECATED void
2030  const std::vector<Patch<dim, spacedim>> &patches,
2031  const std::vector<std::string> & data_names,
2032  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2033  & nonscalar_data_ranges,
2034  const TecplotFlags &flags,
2035  std::ostream & out);
2036 
2058  template <int dim, int spacedim>
2059  DEAL_II_DEPRECATED void
2061  const std::vector<Patch<dim, spacedim>> &patches,
2062  const std::vector<std::string> & data_names,
2063  const std::vector<
2064  std::tuple<unsigned int,
2065  unsigned int,
2066  std::string,
2068  & nonscalar_data_ranges,
2069  const TecplotFlags &flags,
2070  std::ostream & out);
2071 
2078  template <int dim, int spacedim>
2079  DEAL_II_DEPRECATED void
2080  write_ucd(
2081  const std::vector<Patch<dim, spacedim>> &patches,
2082  const std::vector<std::string> & data_names,
2083  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2084  & nonscalar_data_ranges,
2085  const UcdFlags &flags,
2086  std::ostream & out);
2087 
2102  template <int dim, int spacedim>
2103  void
2104  write_ucd(
2105  const std::vector<Patch<dim, spacedim>> &patches,
2106  const std::vector<std::string> & data_names,
2107  const std::vector<
2108  std::tuple<unsigned int,
2109  unsigned int,
2110  std::string,
2112  & nonscalar_data_ranges,
2113  const UcdFlags &flags,
2114  std::ostream & out);
2115 
2123  template <int dim, int spacedim>
2124  DEAL_II_DEPRECATED void
2125  write_vtk(
2126  const std::vector<Patch<dim, spacedim>> &patches,
2127  const std::vector<std::string> & data_names,
2128  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2129  & nonscalar_data_ranges,
2130  const VtkFlags &flags,
2131  std::ostream & out);
2132 
2152  template <int dim, int spacedim>
2153  void
2154  write_vtk(
2155  const std::vector<Patch<dim, spacedim>> &patches,
2156  const std::vector<std::string> & data_names,
2157  const std::vector<
2158  std::tuple<unsigned int,
2159  unsigned int,
2160  std::string,
2162  & nonscalar_data_ranges,
2163  const VtkFlags &flags,
2164  std::ostream & out);
2165 
2173  template <int dim, int spacedim>
2174  DEAL_II_DEPRECATED void
2175  write_vtu(
2176  const std::vector<Patch<dim, spacedim>> &patches,
2177  const std::vector<std::string> & data_names,
2178  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2179  & nonscalar_data_ranges,
2180  const VtkFlags &flags,
2181  std::ostream & out);
2182 
2206  template <int dim, int spacedim>
2207  void
2208  write_vtu(
2209  const std::vector<Patch<dim, spacedim>> &patches,
2210  const std::vector<std::string> & data_names,
2211  const std::vector<
2212  std::tuple<unsigned int,
2213  unsigned int,
2214  std::string,
2216  & nonscalar_data_ranges,
2217  const VtkFlags &flags,
2218  std::ostream & out);
2219 
2225  void
2226  write_vtu_header(std::ostream &out, const VtkFlags &flags);
2227 
2234  void
2235  write_vtu_footer(std::ostream &out);
2236 
2245  template <int dim, int spacedim>
2246  DEAL_II_DEPRECATED void
2248  const std::vector<Patch<dim, spacedim>> &patches,
2249  const std::vector<std::string> & data_names,
2250  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2251  & nonscalar_data_ranges,
2252  const VtkFlags &flags,
2253  std::ostream & out);
2254 
2261  template <int dim, int spacedim>
2262  void
2264  const std::vector<Patch<dim, spacedim>> &patches,
2265  const std::vector<std::string> & data_names,
2266  const std::vector<
2267  std::tuple<unsigned int,
2268  unsigned int,
2269  std::string,
2271  & nonscalar_data_ranges,
2272  const VtkFlags &flags,
2273  std::ostream & out);
2274 
2285  DEAL_II_DEPRECATED
2286  void
2288  std::ostream & out,
2289  const std::vector<std::string> &piece_names,
2290  const std::vector<std::string> &data_names,
2291  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2292  &nonscalar_data_ranges);
2293 
2335  void
2337  std::ostream & out,
2338  const std::vector<std::string> &piece_names,
2339  const std::vector<std::string> &data_names,
2340  const std::vector<
2341  std::tuple<unsigned int,
2342  unsigned int,
2343  std::string,
2345  &nonscalar_data_ranges);
2346 
2397  void
2399  std::ostream & out,
2400  const std::vector<std::pair<double, std::string>> &times_and_names);
2401 
2413  void
2414  write_visit_record(std::ostream & out,
2415  const std::vector<std::string> &piece_names);
2416 
2444  void
2445  write_visit_record(std::ostream & out,
2446  const std::vector<std::vector<std::string>> &piece_names);
2447 
2480  void
2482  std::ostream &out,
2483  const std::vector<std::pair<double, std::vector<std::string>>>
2484  &times_and_piece_names);
2485 
2491  template <int spacedim>
2492  DEAL_II_DEPRECATED void
2493  write_svg(
2494  const std::vector<Patch<2, spacedim>> &patches,
2495  const std::vector<std::string> & data_names,
2496  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2497  & nonscalar_data_ranges,
2498  const SvgFlags &flags,
2499  std::ostream & out);
2500 
2521  template <int spacedim>
2522  void
2523  write_svg(
2524  const std::vector<Patch<2, spacedim>> &patches,
2525  const std::vector<std::string> & data_names,
2526  const std::vector<
2527  std::tuple<unsigned int,
2528  unsigned int,
2529  std::string,
2531  & nonscalar_data_ranges,
2532  const SvgFlags &flags,
2533  std::ostream & out);
2534 
2546  template <int dim, int spacedim>
2547  DEAL_II_DEPRECATED void
2549  const std::vector<Patch<dim, spacedim>> &patches,
2550  const std::vector<std::string> & data_names,
2551  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2552  & nonscalar_data_ranges,
2553  const Deal_II_IntermediateFlags &flags,
2554  std::ostream & out);
2555 
2593  template <int dim, int spacedim>
2594  void
2596  const std::vector<Patch<dim, spacedim>> &patches,
2597  const std::vector<std::string> & data_names,
2598  const std::vector<
2599  std::tuple<unsigned int,
2600  unsigned int,
2601  std::string,
2603  & nonscalar_data_ranges,
2604  const Deal_II_IntermediateFlags &flags,
2605  std::ostream & out);
2606 
2611  template <int dim, int spacedim>
2612  void
2613  write_hdf5_parallel(const std::vector<Patch<dim, spacedim>> &patches,
2614  const DataOutFilter & data_filter,
2615  const std::string & filename,
2616  MPI_Comm comm);
2617 
2625  template <int dim, int spacedim>
2626  void
2627  write_hdf5_parallel(const std::vector<Patch<dim, spacedim>> &patches,
2628  const DataOutFilter & data_filter,
2629  const bool write_mesh_file,
2630  const std::string & mesh_filename,
2631  const std::string &solution_filename,
2632  MPI_Comm comm);
2633 
2642  template <int dim, int spacedim>
2643  DEAL_II_DEPRECATED void
2645  const std::vector<Patch<dim, spacedim>> &patches,
2646  const std::vector<std::string> & data_names,
2647  const std::vector<std::tuple<unsigned int, unsigned int, std::string>>
2648  & nonscalar_data_ranges,
2649  DataOutFilter &filtered_data);
2650 
2657  template <int dim, int spacedim>
2658  void
2660  const std::vector<Patch<dim, spacedim>> &patches,
2661  const std::vector<std::string> & data_names,
2662  const std::vector<
2663  std::tuple<unsigned int,
2664  unsigned int,
2665  std::string,
2667  & nonscalar_data_ranges,
2668  DataOutFilter &filtered_data);
2669 
2681  std::pair<unsigned int, unsigned int>
2682  determine_intermediate_format_dimensions(std::istream &input);
2683 
2695  OutputFormat
2696  parse_output_format(const std::string &format_name);
2697 
2703  std::string
2705 
2726  std::string
2727  default_suffix(const OutputFormat output_format);
2728 
2738  int,
2739  int,
2740  << "The number of points in this data set is " << arg1
2741  << ", but we expected " << arg2
2742  << " in each space direction.");
2747  "You are trying to write graphical data into a file, but "
2748  "no data is available in the intermediate format that "
2749  "the DataOutBase functions require. Did you forget to "
2750  "call a function such as DataOut::build_patches()?");
2755  "The error code of one of the Tecplot functions was "
2756  "not zero as expected.");
2761  char *,
2762  << "There was an error opening Tecplot file " << arg1
2763  << " for output.");
2764 
2766 } // namespace DataOutBase
2767 
2768 
2769 
2877 template <int dim, int spacedim = dim>
2879 {
2880 public:
2884  DataOutInterface();
2885 
2890  virtual ~DataOutInterface() = default;
2891 
2896  void
2897  write_dx(std::ostream &out) const;
2898 
2903  void
2904  write_eps(std::ostream &out) const;
2905 
2910  void
2911  write_gmv(std::ostream &out) const;
2912 
2917  void
2918  write_gnuplot(std::ostream &out) const;
2919 
2924  void
2925  write_povray(std::ostream &out) const;
2926 
2931  void
2932  write_tecplot(std::ostream &out) const;
2933 
2941  DEAL_II_DEPRECATED
2942  void
2943  write_tecplot_binary(std::ostream &out) const;
2944 
2949  void
2950  write_ucd(std::ostream &out) const;
2951 
2963  void
2964  write_vtk(std::ostream &out) const;
2965 
2980  void
2981  write_vtu(std::ostream &out) const;
2982 
2991  void
2992  write_vtu_in_parallel(const std::string &filename, MPI_Comm comm) const;
2993 
3027  void
3028  write_pvtu_record(std::ostream & out,
3029  const std::vector<std::string> &piece_names) const;
3030 
3035  void
3036  write_svg(std::ostream &out) const;
3037 
3048  void
3049  write_deal_II_intermediate(std::ostream &out) const;
3050 
3056  XDMFEntry
3057  create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter,
3058  const std::string & h5_filename,
3059  const double cur_time,
3060  MPI_Comm comm) const;
3061 
3067  XDMFEntry
3068  create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter,
3069  const std::string & h5_mesh_filename,
3070  const std::string & h5_solution_filename,
3071  const double cur_time,
3072  MPI_Comm comm) const;
3073 
3098  void
3099  write_xdmf_file(const std::vector<XDMFEntry> &entries,
3100  const std::string & filename,
3101  MPI_Comm comm) const;
3102 
3117  void
3119  const std::string & filename,
3120  MPI_Comm comm) const;
3121 
3129  void
3131  const bool write_mesh_file,
3132  const std::string & mesh_filename,
3133  const std::string & solution_filename,
3134  MPI_Comm comm) const;
3135 
3142  void
3143  write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const;
3144 
3145 
3154  void
3155  write(std::ostream & out,
3156  const DataOutBase::OutputFormat output_format =
3158 
3163  void
3164  set_default_format(const DataOutBase::OutputFormat default_format);
3165 
3166 
3171  template <typename FlagType>
3172  void
3173  set_flags(const FlagType &flags);
3174 
3175 
3183  std::string
3184  default_suffix(const DataOutBase::OutputFormat output_format =
3186 
3201  static void
3203 
3211  void
3213 
3219  std::size_t
3220  memory_consumption() const;
3221 
3222 protected:
3230  virtual const std::vector<DataOutBase::Patch<dim, spacedim>> &
3231  get_patches() const = 0;
3232 
3237  virtual std::vector<std::string>
3238  get_dataset_names() const = 0;
3239 
3247  DEAL_II_DEPRECATED
3248  virtual std::vector<std::tuple<unsigned int, unsigned int, std::string>>
3249  get_vector_data_ranges() const;
3250 
3269  virtual std::vector<
3270  std::tuple<unsigned int,
3271  unsigned int,
3272  std::string,
3274  get_nonscalar_data_ranges() const;
3275 
3282  void
3283  validate_dataset_names() const;
3284 
3285 
3291  unsigned int default_subdivisions;
3292 
3293 private:
3300 
3306 
3312 
3318 
3324 
3330 
3336 
3342 
3348 
3354 
3360 };
3361 
3362 
3363 
3412 template <int dim, int spacedim = dim>
3413 class DataOutReader : public DataOutInterface<dim, spacedim>
3414 {
3415 public:
3421  void
3422  read(std::istream &in);
3423 
3447  void
3448  merge(const DataOutReader<dim, spacedim> &other);
3449 
3454  "You are trying to merge two sets of patches for which the "
3455  "declared names of the variables do not match.");
3460  "You are trying to merge two sets of patches for which the "
3461  "number of subdivisions or the number of vector components "
3462  "do not match.");
3467  int,
3468  int,
3469  int,
3470  int,
3471  << "Either the dimensions <" << arg1 << "> and <" << arg2
3472  << "> or the space dimensions <" << arg3 << "> and <" << arg4
3473  << "> do not match!");
3474 
3475 protected:
3484  virtual const std::vector<::DataOutBase::Patch<dim, spacedim>> &
3485  get_patches() const override;
3486 
3493  virtual std::vector<std::string>
3494  get_dataset_names() const override;
3495 
3514  virtual std::vector<
3515  std::tuple<unsigned int,
3516  unsigned int,
3517  std::string,
3519  get_nonscalar_data_ranges() const override;
3520 
3521 private:
3526  std::vector<::DataOutBase::Patch<dim, spacedim>> patches;
3527  std::vector<std::string> dataset_names;
3528 
3533  std::vector<
3534  std::tuple<unsigned int,
3535  unsigned int,
3536  std::string,
3539 };
3540 
3541 
3542 
3551 {
3552 public:
3556  XDMFEntry();
3557 
3563  XDMFEntry(const std::string &filename,
3564  const double time,
3565  const unsigned int nodes,
3566  const unsigned int cells,
3567  const unsigned int dim);
3568 
3573  XDMFEntry(const std::string &mesh_filename,
3574  const std::string &solution_filename,
3575  const double time,
3576  const unsigned int nodes,
3577  const unsigned int cells,
3578  const unsigned int dim);
3579 
3583  XDMFEntry(const std::string &mesh_filename,
3584  const std::string &solution_filename,
3585  const double time,
3586  const unsigned int nodes,
3587  const unsigned int cells,
3588  const unsigned int dim,
3589  const unsigned int spacedim);
3590 
3594  void
3595  add_attribute(const std::string &attr_name, const unsigned int dimension);
3596 
3600  template <class Archive>
3601  void
3602  serialize(Archive &ar, const unsigned int /*version*/)
3603  {
3606  }
3607 
3612  std::string
3613  get_xdmf_content(const unsigned int indent_level) const;
3614 
3615 private:
3619  bool valid;
3620 
3624  std::string h5_sol_filename;
3625 
3629  std::string h5_mesh_filename;
3630 
3634  double entry_time;
3635 
3639  unsigned int num_nodes;
3640 
3644  unsigned int num_cells;
3645 
3649  unsigned int dimension;
3650 
3655  unsigned int space_dimension;
3656 
3660  std::map<std::string, unsigned int> attribute_dims;
3661 };
3662 
3663 
3664 
3665 /* -------------------- inline functions ------------------- */
3666 
3667 namespace DataOutBase
3668 {
3669  inline bool
3671  {
3672  return (red == green) && (red == blue);
3673  }
3674 
3675 
3676  /* -------------------- template functions ------------------- */
3677 
3686  template <int dim, int spacedim>
3687  std::ostream &
3688  operator<<(std::ostream &out, const Patch<dim, spacedim> &patch);
3689 
3690 
3691 
3700  template <int dim, int spacedim>
3701  std::istream &
3702  operator>>(std::istream &in, Patch<dim, spacedim> &patch);
3703 } // namespace DataOutBase
3704 
3705 
3706 DEAL_II_NAMESPACE_CLOSE
3707 
3708 #endif
static void declare_parameters(ParameterHandler &prm)
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
static const unsigned int invalid_unsigned_int
Definition: types.h:173
unsigned int space_dimension
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
void parse_parameters(const ParameterHandler &prm)
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, MPI_Comm comm) const
void write_tecplot_binary(std::ostream &out) const
std::size_t memory_consumption() const
void set_flags(const FlagType &flags)
virtual std::vector< std::string > get_dataset_names() const =0
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)
void write_data_set(const std::string &name, const unsigned int dimension, const unsigned int set_num, const Table< 2, double > &data_vectors)
static ::ExceptionBase & ExcIncompatibleDatasetNames()
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)
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const override
unsigned int num_cells
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
void write_vtu_in_parallel(const std::string &filename, MPI_Comm comm) const
void parse_parameters(const ParameterHandler &prm)
void swap(Patch< dim, spacedim > &other_patch)
void merge(const DataOutReader< dim, spacedim > &other)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
unsigned int n_nodes() const
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)
static RgbValues default_color_function(const double value, const double min_value, const double max_value)
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
virtual std::vector< std::string > get_dataset_names() const override
void write_vtk(std::ostream &out) const
unsigned int get_data_set_dim(const unsigned int set_num) const
unsigned int default_subdivisions
std::vector< unsigned int > data_set_dims
Point< spacedim > vertices[GeometryInfo< dim >::vertices_per_cell]
std::string get_xdmf_content(const unsigned int indent_level) const
std::vector< std::vector< double > > data_sets
static void declare_parameters(ParameterHandler &prm)
void fill_cell_data(const unsigned int local_node_offset, std::vector< unsigned int > &cell_data) const
std::map< std::string, unsigned int > attribute_dims
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
void parse_parameters(ParameterHandler &prm)
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_ucd(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
Scale to given height.
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
unsigned int neighbors[dim > 0 ? GeometryInfo< dim >::faces_per_cell :1]
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
DataOutBase::DataOutFilterFlags flags
SvgFlags(const unsigned int height_vector=0, const int azimuth_angle=37, const int polar_angle=45, const unsigned int line_thickness=1, const bool margin=true, const bool draw_colorbar=true)
unsigned int n_data_sets() const
std::string default_suffix(const OutputFormat output_format)
EpsFlags(const unsigned int height_vector=0, const unsigned int color_vector=0, const SizeType size_type=width, const unsigned int size=300, const double line_width=0.5, const double azimut_angle=60, const double turn_angle=30, const double z_scaling=1.0, const bool draw_mesh=true, const bool draw_cells=true, const bool shade_cells=true, const ColorFunction color_function=&default_color_function)
unsigned int patch_index
static ::ExceptionBase & ExcNotEnoughSpaceDimensionLabels()
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
std::vector< std::string > space_dimension_labels
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
void write_point(const unsigned int index, const Point< dim > &p)
unsigned int n_cells() const
std::size_t memory_consumption() const
void serialize(Archive &ar, const unsigned int)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:518
TecplotFlags(const char *tecplot_binary_file_name=nullptr, const char *zone_name=nullptr, const double solution_time=-1.0)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
std::vector< std::string > data_set_names
void add_attribute(const std::string &attr_name, const unsigned int dimension)
void write_tecplot(std::ostream &out) const
DXFlags(const bool write_neighbors=false, const bool int_binary=false, const bool coordinates_binary=false, const bool data_binary=false)
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)
std::size_t memory_consumption() const
void write_cell(const unsigned int index, const unsigned int start, const unsigned int d1, const unsigned int d2, const unsigned int d3)
DataOutBase::Deal_II_IntermediateFlags deal_II_intermediate_flags
void read(std::istream &in)
#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_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, MPI_Comm comm) const
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
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
virtual const std::vector< DataOutBase::Patch< dim, spacedim > > & get_patches() const =0
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
void write_svg(std::ostream &out) const
unsigned int n_subdivisions
DataOutBase::TecplotFlags tecplot_flags
void parse_parameters(const ParameterHandler &prm)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string > > get_vector_data_ranges() const
Scale to given width.
DataOutBase::SvgFlags svg_flags
unsigned int dimension
std::string h5_sol_filename
static ::ExceptionBase & ExcIncompatiblePatchLists()
void parse_parameters(const ParameterHandler &prm)
std::string h5_mesh_filename
void fill_node_data(std::vector< double > &node_data) const
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static void declare_parameters(ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
bool operator==(const Patch &patch) const
void write_eps(std::ostream &out) 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)
void write_deal_II_intermediate(std::ostream &out) const
static void declare_parameters(ParameterHandler &prm)
static const unsigned int no_neighbor
DataOutBase::GmvFlags gmv_flags
DataOutBase::VtkFlags vtk_flags
std::size_t memory_consumption() const
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)
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
static const unsigned int format_version
const double * get_data_set(const unsigned int set_num) const
VtkFlags(const double time=std::numeric_limits< double >::min(), const unsigned int cycle=std::numeric_limits< unsigned int >::min(), const bool print_date_and_time=true, const ZlibCompressionLevel compression_level=best_compression, const bool write_higher_order_cells=false)
void write_povray(std::ostream &out) const
static const unsigned int space_dim
DataOutBase::GnuplotFlags gnuplot_flags
void set_default_format(const DataOutBase::OutputFormat default_format)
void write_gmv(std::ostream &out) const
unsigned int num_nodes
PovrayFlags(const bool smooth=false, const bool bicubic_patch=false, const bool external_data=false)
void internal_add_cell(const unsigned int cell_index, const unsigned int pt_index)
#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::size_t memory_consumption() const
void validate_dataset_names() const
static void declare_parameters(ParameterHandler &prm)
DataOutBase::EpsFlags eps_flags
void write_dx(std::ostream &out) const
std::string get_data_set_name(const unsigned int set_num) const
static ::ExceptionBase & ExcIncompatibleDimensions(int arg1, int arg2, int arg3, int arg4)
std::size_t memory_consumption() const
std::map< unsigned int, unsigned int > filtered_points
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const
void write_gnuplot(std::ostream &out) const
static unsigned int n_subdivisions
void write_vtu(std::ostream &out) const
UcdFlags(const bool write_preamble=false)
void parse_parameters(const ParameterHandler &prm)
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
virtual ~DataOutInterface()=default
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()
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, MPI_Comm comm) const