dune-vtk  0.2
vtkunstructuredgridwriter.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <array>
4 #include <iosfwd>
5 #include <map>
6 
7 #include <dune/vtk/filewriter.hh>
8 #include <dune/vtk/function.hh>
9 #include <dune/vtk/types.hh>
11 
13 
14 namespace Dune
15 {
17 
21  template <class GridView, class DataCollector = Vtk::ContinuousDataCollector<GridView>>
23  : public VtkWriterInterface<GridView, DataCollector>
24  {
25  template <class> friend class VtkTimeseriesWriter;
26 
28  using pos_type = typename Super::pos_type;
29 
30  public:
32  using Super::Super;
33 
34  private:
36  virtual void writeSerialFile (std::ofstream& out) const override;
37 
41  virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override;
42 
44 
52  void writeTimeseriesSerialFile (std::ofstream& out,
53  std::string const& filenameMesh,
54  std::vector<std::pair<double, std::string>> const& timesteps,
55  std::vector<std::uint64_t> const& blocks) const;
56 
58  void writeTimeseriesParallelFile (std::ofstream& out,
59  std::string const& pfilename, int size,
60  std::vector<std::pair<double, std::string>> const& timesteps) const;
61 
62  virtual std::string fileExtension () const override
63  {
64  return "vtu";
65  }
66 
67  virtual void writeGridAppended (std::ofstream& out, std::vector<std::uint64_t>& blocks) const override;
68 
69  // Write the element connectivity to the output stream `out`. In case
70  // of binary format, stores the streampos of XML attributes "offset" in the
71  // vector `offsets`.
72  void writeCells (std::ofstream& out,
73  std::vector<pos_type>& offsets,
74  std::optional<std::size_t> timestep = {}) const;
75 
76  void writePointIds (std::ofstream& out,
77  std::vector<pos_type>& offsets,
78  std::optional<std::size_t> timestep = {}) const;
79 
80  private:
82  using Super::format_;
83  using Super::datatype_;
84  using Super::headertype_;
85 
86  // attached data
87  using Super::pointData_;
88  using Super::cellData_;
89  };
90 
91  // deduction guides
92  template <class GridView,
93  class = std::void_t<typename GridView::IndexSet>>
96 
97  template <class DataCollector,
98  class = std::void_t<typename DataCollector::GridView>>
101 
102  template <class DataCollector,
103  class = std::void_t<typename DataCollector::GridView>>
106 
107 } // end namespace Dune
108 
Definition: datacollectorinterface.hh:9
VtkUnstructuredGridWriter(GridView const &, Vtk::FormatTypes=Vtk::FormatTypes::BINARY, Vtk::DataTypes=Vtk::DataTypes::FLOAT32) -> VtkUnstructuredGridWriter< GridView, Vtk::ContinuousDataCollector< GridView >>
FormatTypes
Type used for representing the output format.
Definition: types.hh:21
@ BINARY
Definition: types.hh:23
DataTypes
Definition: types.hh:50
@ FLOAT32
Definition: types.hh:56
File-Writer for Vtk timeseries .vtu files.
Definition: vtktimeserieswriter.hh:25
Interface for file writers for the Vtk XML file formats.
Definition: vtkwriterinterface.hh:25
std::shared_ptr< DataCollector > dataCollector_
Definition: vtkwriterinterface.hh:260
Vtk::FormatTypes format_
Definition: vtkwriterinterface.hh:262
std::vector< VtkFunction > pointData_
Definition: vtkwriterinterface.hh:268
std::vector< VtkFunction > cellData_
Definition: vtkwriterinterface.hh:269
Vtk::DataTypes headertype_
Definition: vtkwriterinterface.hh:264
Vtk::DataTypes datatype_
Definition: vtkwriterinterface.hh:263
typename std::ostream::pos_type pos_type
Definition: vtkwriterinterface.hh:35
File-Writer for VTK .vtu files.
Definition: vtkunstructuredgridwriter.hh:24