Reference documentation for deal.II version GIT 8e09676776 2023-03-27 21:15:01+00:00
\(\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\}}\)
data_out_base.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2022 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 
23 #include <deal.II/base/mpi_stub.h>
24 #include <deal.II/base/point.h>
25 #include <deal.II/base/table.h>
26 
28 
30 
31 // To be able to serialize XDMFEntry
32 #include <boost/serialization/map.hpp>
33 
34 #include <limits>
35 #include <string>
36 #include <tuple>
37 #include <typeinfo>
38 #include <vector>
39 
40 // Only include the Tecplot API header if the appropriate files
41 // were detected by configure
42 #ifdef DEAL_II_HAVE_TECPLOT
43 # include <string.h>
44 
45 # include "TECIO.h"
46 #endif
47 
48 #include <ostream>
49 
51 
52 // Forward declarations
53 #ifndef DOXYGEN
54 class ParameterHandler;
55 class XDMFEntry;
56 #endif
57 
207 namespace DataOutBase
208 {
216  enum class CompressionLevel
217  {
225  best_speed,
239  plain_text
240  };
241 
242 
265  template <int dim, int spacedim = dim>
266  struct Patch
267  {
271  static const unsigned int space_dim = spacedim;
272 
290  std::array<Point<spacedim>, GeometryInfo<dim>::vertices_per_cell> vertices;
291 
302  std::array<unsigned int, GeometryInfo<dim>::faces_per_cell> neighbors;
303 
308  unsigned int patch_index;
309 
315  unsigned int n_subdivisions;
316 
339 
353 
358 
363  Patch();
364 
369  bool
370  operator==(const Patch &patch) const;
371 
378  std::size_t
379  memory_consumption() const;
380 
384  void
385  swap(Patch<dim, spacedim> &other_patch);
386 
390  static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
391 
402  int,
403  int,
404  << "It is not possible to have a structural dimension of " << arg1
405  << " to be larger than the space dimension of the surrounding"
406  << " space " << arg2);
408  };
409 
410 
411 
427  template <int spacedim>
428  struct Patch<0, spacedim>
429  {
433  static const unsigned int space_dim = spacedim;
434 
444 
449  static unsigned int neighbors[1];
450 
455  unsigned int patch_index;
456 
466  static const unsigned int n_subdivisions;
467 
489 
503 
510 
515  Patch();
516 
521  bool
522  operator==(const Patch &patch) const;
523 
530  std::size_t
531  memory_consumption() const;
532 
536  void
537  swap(Patch<0, spacedim> &other_patch);
538 
542  static const unsigned int no_neighbor = numbers::invalid_unsigned_int;
543 
554  int,
555  int,
556  << "It is not possible to have a structural dimension of " << arg1
557  << " to be larger than the space dimension of the surrounding"
558  << " space " << arg2);
560  };
561 
562 
574  template <typename FlagsType>
576  {
584  static void
586 
594  void
596 
603  std::size_t
605  };
606 
607 
608  template <typename FlagsType>
609  void
611  {}
612 
613 
614  template <typename FlagsType>
615  void
617  {}
618 
619 
620  template <typename FlagsType>
621  std::size_t
623  {
624  return sizeof(FlagsType);
625  }
626 
627 
633  struct DXFlags : public OutputFlagsBase<DXFlags>
634  {
649 
654 
660 
664  DXFlags(const bool write_neighbors = false,
665  const bool int_binary = false,
666  const bool coordinates_binary = false,
667  const bool data_binary = false);
668 
673  static void
675 
682  void
684  };
685 
691  struct UcdFlags : public OutputFlagsBase<UcdFlags>
692  {
703 
707  UcdFlags(const bool write_preamble = false);
708 
713  static void
715 
722  void
724  };
725 
731  struct GnuplotFlags : public OutputFlagsBase<GnuplotFlags>
732  {
737  GnuplotFlags();
738 
742  GnuplotFlags(const std::vector<std::string> &space_dimension_labels);
743 
759  std::vector<std::string> space_dimension_labels;
760 
765  std::size_t
766  memory_consumption() const;
767 
773  "There should be at least one space dimension per spatial "
774  "dimension (extras are ignored).");
775  };
776 
783  struct PovrayFlags : public OutputFlagsBase<PovrayFlags>
784  {
790  bool smooth;
791 
798 
806 
810  PovrayFlags(const bool smooth = false,
811  const bool bicubic_patch = false,
812  const bool external_data = false);
813 
818  static void
820 
827  void
829  };
830 
831 
838  struct EpsFlags : public OutputFlagsBase<EpsFlags>
839  {
846  unsigned int height_vector;
847 
852  unsigned int color_vector;
853 
859  enum SizeType
860  {
864  height
865  };
866 
871 
879  unsigned int size;
880 
884  double line_width;
885 
891  double azimut_angle;
892 
916  double turn_angle;
917 
928  double z_scaling;
929 
936  bool draw_mesh;
937 
955 
965 
969  struct RgbValues
970  {
971  float red;
972  float green;
973  float blue;
974 
979  bool
980  is_grey() const;
981  };
982 
990  using ColorFunction = RgbValues (*)(const double value,
991  const double min_value,
992  const double max_value);
993 
1000 
1001 
1010  static RgbValues
1011  default_color_function(const double value,
1012  const double min_value,
1013  const double max_value);
1014 
1020  static RgbValues
1021  grey_scale_color_function(const double value,
1022  const double min_value,
1023  const double max_value);
1024 
1031  static RgbValues
1032  reverse_grey_scale_color_function(const double value,
1033  const double min_value,
1034  const double max_value);
1035 
1039  EpsFlags(const unsigned int height_vector = 0,
1040  const unsigned int color_vector = 0,
1041  const SizeType size_type = width,
1042  const unsigned int size = 300,
1043  const double line_width = 0.5,
1044  const double azimut_angle = 60,
1045  const double turn_angle = 30,
1046  const double z_scaling = 1.0,
1047  const bool draw_mesh = true,
1048  const bool draw_cells = true,
1049  const bool shade_cells = true,
1051 
1059  static void
1061 
1068  void
1069  parse_parameters(const ParameterHandler &prm);
1070  };
1071 
1078  struct GmvFlags : public OutputFlagsBase<GmvFlags>
1079  {};
1080 
1086  struct TecplotFlags : public OutputFlagsBase<TecplotFlags>
1087  {
1092  const char *zone_name;
1093 
1100 
1104  TecplotFlags(const char * zone_name = nullptr,
1105  const double solution_time = -1.0);
1106 
1111  std::size_t
1112  memory_consumption() const;
1113  };
1114 
1120  struct VtkFlags : public OutputFlagsBase<VtkFlags>
1121  {
1132  double time;
1133 
1144  unsigned int cycle;
1145 
1153 
1162 
1171 
1177 
1196 
1218  std::map<std::string, std::string> physical_units;
1219 
1224  explicit VtkFlags(
1225  const double time = std::numeric_limits<double>::min(),
1226  const unsigned int cycle = std::numeric_limits<unsigned int>::min(),
1227  const bool print_date_and_time = true,
1230  const bool write_higher_order_cells = false,
1231  const std::map<std::string, std::string> &physical_units = {});
1232  };
1233 
1234 
1240  struct SvgFlags : public OutputFlagsBase<SvgFlags>
1241  {
1245  unsigned int height;
1246 
1251  unsigned int width;
1252 
1259  unsigned int height_vector;
1260 
1265 
1266  unsigned int line_thickness;
1267 
1271  bool margin;
1272 
1277 
1281  SvgFlags(const unsigned int height_vector = 0,
1282  const int azimuth_angle = 37,
1283  const int polar_angle = 45,
1284  const unsigned int line_thickness = 1,
1285  const bool margin = true,
1286  const bool draw_colorbar = true);
1287  };
1288 
1289 
1297  : public OutputFlagsBase<Deal_II_IntermediateFlags>
1298  {
1305  static const unsigned int format_version;
1306  };
1307 
1314  {
1325 
1331 
1335  DataOutFilterFlags(const bool filter_duplicate_vertices = false,
1336  const bool xdmf_hdf5_output = false);
1337 
1342  static void
1344 
1351  void
1352  parse_parameters(const ParameterHandler &prm);
1353 
1358  std::size_t
1360  };
1361 
1394  {
1395  public:
1399  DataOutFilter();
1400 
1406 
1412  template <int dim>
1413  void
1414  write_point(const unsigned int index, const Point<dim> &p);
1415 
1419  template <int dim>
1420  void
1421  write_cell(const unsigned int index,
1422  const unsigned int start,
1423  const std::array<unsigned int, dim> &offsets);
1424 
1429  void
1430  write_cell_single(const unsigned int index,
1431  const unsigned int start,
1432  const unsigned int n_points,
1433  const ReferenceCell &reference_cell);
1434 
1441  void
1442  write_data_set(const std::string & name,
1443  const unsigned int dimension,
1444  const unsigned int set_num,
1445  const Table<2, double> &data_vectors);
1446 
1451  void
1452  fill_node_data(std::vector<double> &node_data) const;
1453 
1458  void
1459  fill_cell_data(const unsigned int local_node_offset,
1460  std::vector<unsigned int> &cell_data) const;
1461 
1465  std::string
1466  get_data_set_name(const unsigned int set_num) const;
1467 
1471  unsigned int
1472  get_data_set_dim(const unsigned int set_num) const;
1473 
1478  const double *
1479  get_data_set(const unsigned int set_num) const;
1480 
1485  unsigned int
1486  n_nodes() const;
1487 
1492  unsigned int
1493  n_cells() const;
1494 
1499  unsigned int
1500  n_data_sets() const;
1501 
1505  void
1506  flush_points();
1507 
1511  void
1512  flush_cells();
1513 
1514 
1515  private:
1519  struct Point3Comp
1520  {
1521  bool
1522  operator()(const Point<3> &one, const Point<3> &two) const
1523  {
1524  /*
1525  * The return statement below is an optimized version of the following
1526  * code:
1527  *
1528  * for (unsigned int d=0; d<3; ++d)
1529  * {
1530  * if (one(d) < two(d))
1531  * return true;
1532  * else if (one(d) > two(d))
1533  * return false;
1534  * }
1535  * return false;
1536  */
1537 
1538  return (one(0) < two(0) ||
1539  (!(two(0) < one(0)) &&
1540  (one(1) < two(1) || (!(two(1) < one(1)) && one(2) < two(2)))));
1541  }
1542  };
1543 
1544  using Map3DPoint = std::multimap<Point<3>, unsigned int, Point3Comp>;
1545 
1550 
1557  unsigned int node_dim;
1558 
1563  unsigned int num_cells;
1564 
1569 
1573  std::map<unsigned int, unsigned int> filtered_points;
1574 
1578  std::map<unsigned int, unsigned int> filtered_cells;
1579 
1583  std::vector<std::string> data_set_names;
1584 
1588  std::vector<unsigned int> data_set_dims;
1589 
1593  std::vector<std::vector<double>> data_sets;
1594 
1598  void
1599  internal_add_cell(const unsigned int cell_index,
1600  const unsigned int pt_index);
1601  };
1602 
1603 
1608  {
1613 
1618 
1623 
1628 
1633 
1638 
1643 
1648 
1653 
1661 
1666 
1671 
1676 
1681 
1685  hdf5
1686  };
1687 
1688 
1692  template <int dim, int spacedim>
1693  void
1694  write_dx(
1695  const std::vector<Patch<dim, spacedim>> &patches,
1696  const std::vector<std::string> & data_names,
1697  const std::vector<
1698  std::tuple<unsigned int,
1699  unsigned int,
1700  std::string,
1702  & nonscalar_data_ranges,
1703  const DXFlags &flags,
1704  std::ostream & out);
1705 
1750  template <int spacedim>
1751  void
1752  write_eps(
1753  const std::vector<Patch<2, spacedim>> &patches,
1754  const std::vector<std::string> & data_names,
1755  const std::vector<
1756  std::tuple<unsigned int,
1757  unsigned int,
1758  std::string,
1760  & nonscalar_data_ranges,
1761  const EpsFlags &flags,
1762  std::ostream & out);
1763 
1769  template <int dim, int spacedim>
1770  void
1771  write_eps(
1772  const std::vector<Patch<dim, spacedim>> &patches,
1773  const std::vector<std::string> & data_names,
1774  const std::vector<
1775  std::tuple<unsigned int,
1776  unsigned int,
1777  std::string,
1779  & nonscalar_data_ranges,
1780  const EpsFlags &flags,
1781  std::ostream & out);
1782 
1783 
1793  template <int dim, int spacedim>
1794  void
1795  write_gmv(
1796  const std::vector<Patch<dim, spacedim>> &patches,
1797  const std::vector<std::string> & data_names,
1798  const std::vector<
1799  std::tuple<unsigned int,
1800  unsigned int,
1801  std::string,
1803  & nonscalar_data_ranges,
1804  const GmvFlags &flags,
1805  std::ostream & out);
1806 
1862  template <int dim, int spacedim>
1863  void
1864  write_gnuplot(
1865  const std::vector<Patch<dim, spacedim>> &patches,
1866  const std::vector<std::string> & data_names,
1867  const std::vector<
1868  std::tuple<unsigned int,
1869  unsigned int,
1870  std::string,
1872  & nonscalar_data_ranges,
1873  const GnuplotFlags &flags,
1874  std::ostream & out);
1875 
1921  template <int dim, int spacedim>
1922  void
1923  write_povray(
1924  const std::vector<Patch<dim, spacedim>> &patches,
1925  const std::vector<std::string> & data_names,
1926  const std::vector<
1927  std::tuple<unsigned int,
1928  unsigned int,
1929  std::string,
1931  & nonscalar_data_ranges,
1932  const PovrayFlags &flags,
1933  std::ostream & out);
1934 
1941  template <int dim, int spacedim>
1942  void
1943  write_tecplot(
1944  const std::vector<Patch<dim, spacedim>> &patches,
1945  const std::vector<std::string> & data_names,
1946  const std::vector<
1947  std::tuple<unsigned int,
1948  unsigned int,
1949  std::string,
1951  & nonscalar_data_ranges,
1952  const TecplotFlags &flags,
1953  std::ostream & out);
1954 
1969  template <int dim, int spacedim>
1970  void
1971  write_ucd(
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 UcdFlags &flags,
1981  std::ostream & out);
1982 
2002  template <int dim, int spacedim>
2003  void
2004  write_vtk(
2005  const std::vector<Patch<dim, spacedim>> &patches,
2006  const std::vector<std::string> & data_names,
2007  const std::vector<
2008  std::tuple<unsigned int,
2009  unsigned int,
2010  std::string,
2012  & nonscalar_data_ranges,
2013  const VtkFlags &flags,
2014  std::ostream & out);
2015 
2016 
2040  template <int dim, int spacedim>
2041  void
2042  write_vtu(
2043  const std::vector<Patch<dim, spacedim>> &patches,
2044  const std::vector<std::string> & data_names,
2045  const std::vector<
2046  std::tuple<unsigned int,
2047  unsigned int,
2048  std::string,
2050  & nonscalar_data_ranges,
2051  const VtkFlags &flags,
2052  std::ostream & out);
2053 
2059  void
2060  write_vtu_header(std::ostream &out, const VtkFlags &flags);
2061 
2068  void
2069  write_vtu_footer(std::ostream &out);
2070 
2077  template <int dim, int spacedim>
2078  void
2080  const std::vector<Patch<dim, spacedim>> &patches,
2081  const std::vector<std::string> & data_names,
2082  const std::vector<
2083  std::tuple<unsigned int,
2084  unsigned int,
2085  std::string,
2087  & nonscalar_data_ranges,
2088  const VtkFlags &flags,
2089  std::ostream & out);
2090 
2132  void
2134  std::ostream & out,
2135  const std::vector<std::string> &piece_names,
2136  const std::vector<std::string> &data_names,
2137  const std::vector<
2138  std::tuple<unsigned int,
2139  unsigned int,
2140  std::string,
2142  & nonscalar_data_ranges,
2143  const VtkFlags &flags);
2144 
2193  void
2195  std::ostream & out,
2196  const std::vector<std::pair<double, std::string>> &times_and_names);
2197 
2209  void
2210  write_visit_record(std::ostream & out,
2211  const std::vector<std::string> &piece_names);
2212 
2240  void
2241  write_visit_record(std::ostream & out,
2242  const std::vector<std::vector<std::string>> &piece_names);
2243 
2276  void
2278  std::ostream &out,
2279  const std::vector<std::pair<double, std::vector<std::string>>>
2280  &times_and_piece_names);
2281 
2302  template <int spacedim>
2303  void
2304  write_svg(
2305  const std::vector<Patch<2, spacedim>> &patches,
2306  const std::vector<std::string> & data_names,
2307  const std::vector<
2308  std::tuple<unsigned int,
2309  unsigned int,
2310  std::string,
2312  & nonscalar_data_ranges,
2313  const SvgFlags &flags,
2314  std::ostream & out);
2315 
2353  template <int dim, int spacedim>
2354  void
2356  const std::vector<Patch<dim, spacedim>> &patches,
2357  const std::vector<std::string> & data_names,
2358  const std::vector<
2359  std::tuple<unsigned int,
2360  unsigned int,
2361  std::string,
2363  & nonscalar_data_ranges,
2364  const Deal_II_IntermediateFlags &flags,
2365  std::ostream & out);
2366 
2375  template <int dim, int spacedim>
2376  void
2378  const std::vector<Patch<dim, spacedim>> &patches,
2379  const std::vector<std::string> & data_names,
2380  const std::vector<
2381  std::tuple<unsigned int,
2382  unsigned int,
2383  std::string,
2385  & nonscalar_data_ranges,
2386  const Deal_II_IntermediateFlags &flags,
2387  const std::string & filename,
2388  const MPI_Comm & comm,
2389  const CompressionLevel compression);
2390 
2395  template <int dim, int spacedim>
2396  void
2397  write_hdf5_parallel(const std::vector<Patch<dim, spacedim>> &patches,
2398  const DataOutFilter & data_filter,
2399  const std::string & filename,
2400  const MPI_Comm & comm);
2401 
2409  template <int dim, int spacedim>
2410  void
2411  write_hdf5_parallel(const std::vector<Patch<dim, spacedim>> &patches,
2412  const DataOutFilter & data_filter,
2413  const bool write_mesh_file,
2414  const std::string & mesh_filename,
2415  const std::string &solution_filename,
2416  const MPI_Comm & comm);
2417 
2424  template <int dim, int spacedim>
2425  void
2427  const std::vector<Patch<dim, spacedim>> &patches,
2428  const std::vector<std::string> & data_names,
2429  const std::vector<
2430  std::tuple<unsigned int,
2431  unsigned int,
2432  std::string,
2434  & nonscalar_data_ranges,
2435  DataOutFilter &filtered_data);
2436 
2448  std::pair<unsigned int, unsigned int>
2449  determine_intermediate_format_dimensions(std::istream &input);
2450 
2462  OutputFormat
2463  parse_output_format(const std::string &format_name);
2464 
2470  std::string
2472 
2493  std::string
2494  default_suffix(const OutputFormat output_format);
2495 
2505  int,
2506  int,
2507  << "The number of points in this data set is " << arg1
2508  << ", but we expected " << arg2
2509  << " in each space direction.");
2514  "You are trying to write graphical data into a file, but "
2515  "no data is available in the intermediate format that "
2516  "the DataOutBase functions require. Did you forget to "
2517  "call a function such as DataOut::build_patches()?");
2522  "The error code of one of the Tecplot functions was "
2523  "not zero as expected.");
2528  char *,
2529  << "There was an error opening Tecplot file " << arg1
2530  << " for output.");
2531 
2533 } // namespace DataOutBase
2534 
2535 
2536 
2643 template <int dim, int spacedim = dim>
2645 {
2646 public:
2650  DataOutInterface();
2651 
2656  virtual ~DataOutInterface() = default;
2657 
2662  void
2663  write_dx(std::ostream &out) const;
2664 
2669  void
2670  write_eps(std::ostream &out) const;
2671 
2676  void
2677  write_gmv(std::ostream &out) const;
2678 
2683  void
2684  write_gnuplot(std::ostream &out) const;
2685 
2690  void
2691  write_povray(std::ostream &out) const;
2692 
2697  void
2698  write_tecplot(std::ostream &out) const;
2699 
2704  void
2705  write_ucd(std::ostream &out) const;
2706 
2718  void
2719  write_vtk(std::ostream &out) const;
2720 
2735  void
2736  write_vtu(std::ostream &out) const;
2737 
2746  void
2747  write_vtu_in_parallel(const std::string &filename,
2748  const MPI_Comm & comm) const;
2749 
2783  void
2784  write_pvtu_record(std::ostream & out,
2785  const std::vector<std::string> &piece_names) const;
2786 
2845  std::string
2847  const std::string &directory,
2848  const std::string &filename_without_extension,
2849  const unsigned int counter,
2850  const MPI_Comm & mpi_communicator,
2851  const unsigned int n_digits_for_counter = numbers::invalid_unsigned_int,
2852  const unsigned int n_groups = 0) const;
2853 
2858  void
2859  write_svg(std::ostream &out) const;
2860 
2871  void
2872  write_deal_II_intermediate(std::ostream &out) const;
2873 
2880  void
2882  const std::string & filename,
2883  const MPI_Comm & comm,
2884  const DataOutBase::CompressionLevel compression) const;
2885 
2891  XDMFEntry
2892  create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter,
2893  const std::string & h5_filename,
2894  const double cur_time,
2895  const MPI_Comm & comm) const;
2896 
2902  XDMFEntry
2903  create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter,
2904  const std::string & h5_mesh_filename,
2905  const std::string & h5_solution_filename,
2906  const double cur_time,
2907  const MPI_Comm & comm) const;
2908 
2933  void
2934  write_xdmf_file(const std::vector<XDMFEntry> &entries,
2935  const std::string & filename,
2936  const MPI_Comm & comm) const;
2937 
2952  void
2954  const std::string & filename,
2955  const MPI_Comm & comm) const;
2956 
2964  void
2966  const bool write_mesh_file,
2967  const std::string & mesh_filename,
2968  const std::string & solution_filename,
2969  const MPI_Comm & comm) const;
2970 
2977  void
2978  write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const;
2979 
2980 
2989  void
2990  write(std::ostream & out,
2991  const DataOutBase::OutputFormat output_format =
2993 
2998  void
3000 
3001 
3006  template <typename FlagType>
3007  void
3008  set_flags(const FlagType &flags);
3009 
3010 
3018  std::string
3019  default_suffix(const DataOutBase::OutputFormat output_format =
3021 
3036  static void
3038 
3046  void
3048 
3054  std::size_t
3055  memory_consumption() const;
3056 
3057 protected:
3065  virtual const std::vector<DataOutBase::Patch<dim, spacedim>> &
3066  get_patches() const = 0;
3067 
3072  virtual std::vector<std::string>
3073  get_dataset_names() const = 0;
3074 
3093  virtual std::vector<
3094  std::tuple<unsigned int,
3095  unsigned int,
3096  std::string,
3098  get_nonscalar_data_ranges() const;
3099 
3106  void
3107  validate_dataset_names() const;
3108 
3109 
3115  unsigned int default_subdivisions;
3116 
3117 private:
3124 
3130 
3136 
3142 
3148 
3154 
3160 
3166 
3172 
3178 
3184 };
3185 
3186 
3187 
3233 template <int dim, int spacedim = dim>
3234 class DataOutReader : public DataOutInterface<dim, spacedim>
3235 {
3236 public:
3242  void
3243  read(std::istream &in);
3244 
3250  void
3251  read_whole_parallel_file(std::istream &in);
3252 
3274  void
3275  merge(const DataOutReader<dim, spacedim> &other);
3276 
3281  "You are trying to merge two sets of patches for which the "
3282  "declared names of the variables do not match.");
3287  "You are trying to merge two sets of patches for which the "
3288  "number of subdivisions or the number of vector components "
3289  "do not match.");
3294  int,
3295  int,
3296  int,
3297  int,
3298  << "Either the dimensions <" << arg1 << "> and <" << arg2
3299  << "> or the space dimensions <" << arg3 << "> and <" << arg4
3300  << "> do not match!");
3301 
3302 protected:
3311  virtual const std::vector<::DataOutBase::Patch<dim, spacedim>> &
3312  get_patches() const override;
3313 
3320  virtual std::vector<std::string>
3321  get_dataset_names() const override;
3322 
3341  virtual std::vector<
3342  std::tuple<unsigned int,
3343  unsigned int,
3344  std::string,
3346  get_nonscalar_data_ranges() const override;
3347 
3348 private:
3353  std::vector<::DataOutBase::Patch<dim, spacedim>> patches;
3354  std::vector<std::string> dataset_names;
3355 
3360  std::vector<
3361  std::tuple<unsigned int,
3362  unsigned int,
3363  std::string,
3366 };
3367 
3368 
3369 
3378 {
3379 public:
3383  XDMFEntry();
3384 
3390  XDMFEntry(const std::string & filename,
3391  const double time,
3392  const std::uint64_t nodes,
3393  const std::uint64_t cells,
3394  const unsigned int dim,
3395  const ReferenceCell &cell_type);
3396 
3402  XDMFEntry(const std::string & filename,
3403  const double time,
3404  const std::uint64_t nodes,
3405  const std::uint64_t cells,
3406  const unsigned int dim);
3407 
3413  XDMFEntry(const std::string & mesh_filename,
3414  const std::string & solution_filename,
3415  const double time,
3416  const std::uint64_t nodes,
3417  const std::uint64_t cells,
3418  const unsigned int dim);
3419 
3424  XDMFEntry(const std::string & mesh_filename,
3425  const std::string & solution_filename,
3426  const double time,
3427  const std::uint64_t nodes,
3428  const std::uint64_t cells,
3429  const unsigned int dim,
3430  const ReferenceCell &cell_type);
3431 
3438  XDMFEntry(const std::string & mesh_filename,
3439  const std::string & solution_filename,
3440  const double time,
3441  const std::uint64_t nodes,
3442  const std::uint64_t cells,
3443  const unsigned int dim,
3444  const unsigned int spacedim);
3445 
3449  XDMFEntry(const std::string & mesh_filename,
3450  const std::string & solution_filename,
3451  const double time,
3452  const std::uint64_t nodes,
3453  const std::uint64_t cells,
3454  const unsigned int dim,
3455  const unsigned int spacedim,
3456  const ReferenceCell &cell_type);
3457 
3461  void
3462  add_attribute(const std::string &attr_name, const unsigned int dimension);
3463 
3469  template <class Archive>
3470  void
3471  serialize(Archive &ar, const unsigned int /*version*/)
3472  {
3475  }
3476 
3481  std::string
3482  get_xdmf_content(const unsigned int indent_level) const;
3483 
3491  std::string
3492  get_xdmf_content(const unsigned int indent_level,
3493  const ReferenceCell &reference_cell) const;
3494 
3495 private:
3499  bool valid;
3500 
3504  std::string h5_sol_filename;
3505 
3509  std::string h5_mesh_filename;
3510 
3514  double entry_time;
3515 
3519  std::uint64_t num_nodes;
3520 
3524  std::uint64_t num_cells;
3525 
3529  unsigned int dimension;
3530 
3535  unsigned int space_dimension;
3536 
3542 
3546  std::map<std::string, unsigned int> attribute_dims;
3547 };
3548 
3549 
3550 
3551 /* -------------------- inline functions ------------------- */
3552 
3553 namespace DataOutBase
3554 {
3555  inline bool
3557  {
3558  return (red == green) && (red == blue);
3559  }
3560 
3561 
3562  /* -------------------- template functions ------------------- */
3563 
3570  template <int dim, int spacedim>
3571  std::ostream &
3572  operator<<(std::ostream &out, const Patch<dim, spacedim> &patch);
3573 
3574 
3575 
3582  template <int dim, int spacedim>
3583  std::istream &
3584  operator>>(std::istream &in, Patch<dim, spacedim> &patch);
3585 } // namespace DataOutBase
3586 
3587 
3589 
3590 #endif
const double * get_data_set(const unsigned int set_num) const
std::map< unsigned int, unsigned int > filtered_points
std::string get_data_set_name(const unsigned int set_num) const
std::multimap< Point< 3 >, unsigned int, Point3Comp > Map3DPoint
void internal_add_cell(const unsigned int cell_index, const unsigned int pt_index)
void write_cell(const unsigned int index, const unsigned int start, const std::array< unsigned int, dim > &offsets)
std::vector< unsigned int > data_set_dims
unsigned int n_nodes() const
void fill_node_data(std::vector< double > &node_data) const
std::vector< std::vector< double > > data_sets
unsigned int get_data_set_dim(const unsigned int set_num) const
void write_data_set(const std::string &name, const unsigned int dimension, const unsigned int set_num, const Table< 2, double > &data_vectors)
std::map< unsigned int, unsigned int > filtered_cells
void write_cell_single(const unsigned int index, const unsigned int start, const unsigned int n_points, const ReferenceCell &reference_cell)
std::vector< std::string > data_set_names
void fill_cell_data(const unsigned int local_node_offset, std::vector< unsigned int > &cell_data) const
void write_point(const unsigned int index, const Point< dim > &p)
unsigned int n_cells() const
DataOutBase::DataOutFilterFlags flags
unsigned int n_data_sets() const
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const
unsigned int default_subdivisions
std::string write_vtu_with_pvtu_record(const std::string &directory, const std::string &filename_without_extension, const unsigned int counter, const MPI_Comm &mpi_communicator, const unsigned int n_digits_for_counter=numbers::invalid_unsigned_int, const unsigned int n_groups=0) const
void parse_parameters(ParameterHandler &prm)
DataOutBase::Deal_II_IntermediateFlags deal_II_intermediate_flags
virtual std::vector< std::string > get_dataset_names() const =0
void write_filtered_data(DataOutBase::DataOutFilter &filtered_data) const
void write_pvtu_record(std::ostream &out, const std::vector< std::string > &piece_names) const
static void declare_parameters(ParameterHandler &prm)
void write_deal_II_intermediate_in_parallel(const std::string &filename, const MPI_Comm &comm, const DataOutBase::CompressionLevel compression) const
void write_hdf5_parallel(const DataOutBase::DataOutFilter &data_filter, const std::string &filename, const MPI_Comm &comm) const
DataOutBase::TecplotFlags tecplot_flags
void write_ucd(std::ostream &out) const
void write_povray(std::ostream &out) const
std::string default_suffix(const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
XDMFEntry create_xdmf_entry(const DataOutBase::DataOutFilter &data_filter, const std::string &h5_filename, const double cur_time, const MPI_Comm &comm) const
void write_vtu_in_parallel(const std::string &filename, const MPI_Comm &comm) const
DataOutBase::GmvFlags gmv_flags
std::size_t memory_consumption() const
void set_default_format(const DataOutBase::OutputFormat default_format)
DataOutBase::PovrayFlags povray_flags
DataOutBase::UcdFlags ucd_flags
void write(std::ostream &out, const DataOutBase::OutputFormat output_format=DataOutBase::default_format) const
virtual const std::vector< DataOutBase::Patch< dim, spacedim > > & get_patches() const =0
DataOutBase::OutputFormat default_fmt
DataOutBase::GnuplotFlags gnuplot_flags
void write_gnuplot(std::ostream &out) const
virtual ~DataOutInterface()=default
void write_vtu(std::ostream &out) const
void write_tecplot(std::ostream &out) const
void write_svg(std::ostream &out) const
DataOutBase::SvgFlags svg_flags
void write_xdmf_file(const std::vector< XDMFEntry > &entries, const std::string &filename, const MPI_Comm &comm) const
void validate_dataset_names() const
void set_flags(const FlagType &flags)
void write_vtk(std::ostream &out) const
DataOutBase::VtkFlags vtk_flags
void write_gmv(std::ostream &out) const
DataOutBase::EpsFlags eps_flags
void write_eps(std::ostream &out) const
DataOutBase::DXFlags dx_flags
void write_dx(std::ostream &out) const
void write_deal_II_intermediate(std::ostream &out) const
void merge(const DataOutReader< dim, spacedim > &other)
void read_whole_parallel_file(std::istream &in)
std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > nonscalar_data_ranges
virtual const std::vector<::DataOutBase::Patch< dim, spacedim > > & get_patches() const override
void read(std::istream &in)
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
virtual std::vector< std::string > get_dataset_names() const override
std::vector< std::string > dataset_names
std::vector<::DataOutBase::Patch< dim, spacedim > > patches
ReferenceCell cell_type
std::uint64_t num_nodes
unsigned int dimension
std::string h5_sol_filename
void serialize(Archive &ar, const unsigned int)
double entry_time
std::string h5_mesh_filename
std::string get_xdmf_content(const unsigned int indent_level) const
void add_attribute(const std::string &attr_name, const unsigned int dimension)
std::uint64_t num_cells
std::map< std::string, unsigned int > attribute_dims
unsigned int space_dimension
#define DEAL_II_DEPRECATED
Definition: config.h:174
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:474
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:475
unsigned int cell_index
Definition: grid_tools.cc:1191
static ::ExceptionBase & ExcIncompatiblePatchLists()
static ::ExceptionBase & ExcIncompatibleDimensions(int arg1, int arg2, int arg3, int arg4)
static ::ExceptionBase & ExcErrorOpeningTecplotFile(char *arg1)
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:579
static ::ExceptionBase & ExcInvalidDatasetSize(int arg1, int arg2)
static ::ExceptionBase & ExcInvalidCombinationOfDimensions(int arg1, int arg2)
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:533
static ::ExceptionBase & ExcNotEnoughSpaceDimensionLabels()
static ::ExceptionBase & ExcIncompatibleDatasetNames()
static ::ExceptionBase & ExcTecplotAPIError()
#define DeclExceptionMsg(Exception, defaulttext)
Definition: exceptions.h:488
static ::ExceptionBase & ExcNoPatches()
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:510
void write_deal_II_intermediate_in_parallel(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 Deal_II_IntermediateFlags &flags, const std::string &filename, const MPI_Comm &comm, const CompressionLevel compression)
std::pair< unsigned int, unsigned int > determine_intermediate_format_dimensions(std::istream &input)
std::ostream & operator<<(std::ostream &out, const Patch< dim, spacedim > &patch)
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)
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)
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)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, const VtkFlags &flags)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, DataOutFilter &filtered_data)
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)
void write_vtu_header(std::ostream &out, const VtkFlags &flags)
void write_pvd_record(std::ostream &out, const std::vector< std::pair< double, std::string >> &times_and_names)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, const Deal_II_IntermediateFlags &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)
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 write_vtu_footer(std::ostream &out)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, const TecplotFlags &flags, std::ostream &out)
OutputFormat parse_output_format(const std::string &format_name)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, const VtkFlags &flags, std::ostream &out)
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)
std::istream & operator>>(std::istream &in, Patch< dim, spacedim > &patch)
std::string get_output_format_names()
void write_visit_record(std::ostream &out, const std::vector< std::string > &piece_names)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, const PovrayFlags &flags, std::ostream &out)
std::string default_suffix(const OutputFormat output_format)
void write_hdf5_parallel(const std::vector< Patch< dim, spacedim >> &patches, const DataOutFilter &data_filter, const std::string &filename, const MPI_Comm &comm)
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, DataComponentInterpretation::DataComponentInterpretation >> &nonscalar_data_ranges, const GmvFlags &flags, std::ostream &out)
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell &reference_cell)
static const types::blas_int one
static const unsigned int invalid_unsigned_int
Definition: types.h:213
void parse_parameters(const ParameterHandler &prm)
DXFlags(const bool write_neighbors=false, const bool int_binary=false, const bool coordinates_binary=false, const bool data_binary=false)
static void declare_parameters(ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
std::size_t memory_consumption() const
void parse_parameters(const ParameterHandler &prm)
DataOutFilterFlags(const bool filter_duplicate_vertices=false, const bool xdmf_hdf5_output=false)
bool operator()(const Point< 3 > &one, const Point< 3 > &two) const
static const unsigned int format_version
static void declare_parameters(ParameterHandler &prm)
static RgbValues default_color_function(const double value, const double min_value, const double max_value)
void parse_parameters(const ParameterHandler &prm)
ColorFunction color_function
RgbValues(*)(const double value, const double min_value, const double max_value) ColorFunction
static RgbValues grey_scale_color_function(const double value, const double min_value, const double max_value)
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 color_vector
static RgbValues reverse_grey_scale_color_function(const double value, const double min_value, const double max_value)
@ width
Scale to given width.
@ height
Scale to given height.
unsigned int height_vector
std::vector< std::string > space_dimension_labels
std::size_t memory_consumption() const
std::size_t memory_consumption() const
static void declare_parameters(ParameterHandler &prm)
void parse_parameters(const ParameterHandler &prm)
static const unsigned int n_subdivisions
static const ReferenceCell reference_cell
std::size_t memory_consumption() const
unsigned int patch_index
ReferenceCell reference_cell
Table< 2, float > data
static const unsigned int no_neighbor
bool operator==(const Patch &patch) const
static const unsigned int space_dim
unsigned int n_subdivisions
std::array< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > vertices
void swap(Patch< dim, spacedim > &other_patch)
std::array< unsigned int, GeometryInfo< dim >::faces_per_cell > neighbors
static void declare_parameters(ParameterHandler &prm)
PovrayFlags(const bool smooth=false, const bool bicubic_patch=false, const bool external_data=false)
void parse_parameters(const ParameterHandler &prm)
unsigned int height_vector
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 line_thickness
std::size_t memory_consumption() const
TecplotFlags(const char *zone_name=nullptr, const double solution_time=-1.0)
void parse_parameters(const ParameterHandler &prm)
static void declare_parameters(ParameterHandler &prm)
UcdFlags(const bool write_preamble=false)
std::map< std::string, std::string > physical_units
static const DataOutBase::CompressionLevel default_compression
static const DataOutBase::CompressionLevel best_compression
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 CompressionLevel compression_level=CompressionLevel::best_compression, const bool write_higher_order_cells=false, const std::map< std::string, std::string > &physical_units={})
static const DataOutBase::CompressionLevel best_speed
DataOutBase::CompressionLevel compression_level
static const DataOutBase::CompressionLevel no_compression
const MPI_Comm & comm