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>
12 
14 
15 namespace Dune
16 {
18 
22  template <class GridView, class DataCollector = Vtk::StructuredDataCollector<GridView>>
24  : public VtkWriterInterface<GridView, DataCollector>
25  {
27  using pos_type = typename Super::pos_type;
28 
29  public:
31  using Super::Super;
32 
33  private:
35  virtual void writeSerialFile (std::ofstream& out) const override;
36 
40  virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override;
41 
42  void writeCoordinates (std::ofstream& out, std::vector<pos_type>& offsets,
43  std::optional<std::size_t> timestep = {}) const;
44 
45  template <class T>
46  std::array<std::uint64_t, 3> writeCoordinatesAppended (std::ofstream& out) const;
47 
48  virtual std::string fileExtension () const override
49  {
50  return "vtr";
51  }
52 
53  virtual void writeGridAppended (std::ofstream& out, std::vector<std::uint64_t>& blocks) const override;
54 
55  private:
57  using Super::format_;
58  using Super::datatype_;
59  using Super::headertype_;
60 
61  // attached data
62  using Super::pointData_;
63  using Super::cellData_;
64  };
65 
66  // deduction guides
67  template <class GridView, class... Args,
69  VtkRectilinearGridWriter(GridView, Args...)
71 
72  template <class DataCollector, class... Args,
74  VtkRectilinearGridWriter(DataCollector&, Args...)
76 
77  template <class DataCollector, class... Args,
79  VtkRectilinearGridWriter(std::shared_ptr<DataCollector>, Args...)
81 
82 } // end namespace Dune
83 
Definition: writer.hh:13
VtkRectilinearGridWriter(GridView, Args...) -> VtkRectilinearGridWriter< GridView, Vtk::StructuredDataCollector< GridView >>
decltype((std::declval< GV >().grid(), std::declval< GV >().indexSet(), std::declval< GV >().size(0), std::declval< GV >().size(std::declval< Dune::GeometryType >()), CheckTypes< typename GV::Grid, typename GV::IndexSet >{}, true)) IsGridView
Definition: concepts.hh:27
decltype((std::declval< DC & >().update(), std::declval< DC >().numPoints(), std::declval< DC >().numCells(), CheckTypes< typename DC::GridView >{}, true)) IsDataCollector
Definition: concepts.hh:18
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:25