dune-vtk  0.2
vtkrectilineargridwriter.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::StructuredDataCollector<GridView>>
23  : public VtkWriterInterface<GridView, DataCollector>
24  {
26  using pos_type = typename Super::pos_type;
27 
28  public:
30  using Super::Super;
31 
32  private:
34  virtual void writeSerialFile (std::ofstream& out) const override;
35 
39  virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override;
40 
41  void writeCoordinates (std::ofstream& out, std::vector<pos_type>& offsets,
42  std::optional<std::size_t> timestep = {}) const;
43 
44  template <class T>
45  std::array<std::uint64_t, 3> writeCoordinatesAppended (std::ofstream& out) const;
46 
47  virtual std::string fileExtension () const override
48  {
49  return "vtr";
50  }
51 
52  virtual void writeGridAppended (std::ofstream& out, std::vector<std::uint64_t>& blocks) const override;
53 
54  private:
56  using Super::format_;
57  using Super::datatype_;
58  using Super::headertype_;
59 
60  // attached data
61  using Super::pointData_;
62  using Super::cellData_;
63  };
64 
65  // deduction guides
66  template <class GridView,
67  class = std::void_t<typename GridView::IndexSet>>
70 
71  template <class DataCollector,
72  class = std::void_t<typename DataCollector::GridView>>
75 
76  template <class DataCollector,
77  class = std::void_t<typename DataCollector::GridView>>
80 
81 } // end namespace Dune
82 
Definition: datacollectorinterface.hh:9
VtkRectilinearGridWriter(GridView const &, Vtk::FormatTypes=Vtk::FormatTypes::BINARY, Vtk::DataTypes=Vtk::DataTypes::FLOAT32) -> VtkRectilinearGridWriter< GridView, Vtk::StructuredDataCollector< 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
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 RectilinearGrid VTK .vtr files.
Definition: vtkrectilineargridwriter.hh:24