vtkstructuredgridwriter.hh 2.44 KB
Newer Older
1
2
3
4
5
6
#pragma once

#include <array>
#include <iosfwd>
#include <map>

7
#include <dune/vtk/filewriter.hh>
Stenger, Florian's avatar
Stenger, Florian committed
8
9
#include <dune/vtk/function.hh>
#include <dune/vtk/types.hh>
10
#include <dune/vtk/datacollectors/structureddatacollector.hh>
11
#include <dune/vtk/utility/concepts.hh>
12

13
#include <dune/vtk/vtkwriterinterface.hh>
14

15
namespace Dune
16
{
17
18
19
20
21
  /// File-Writer for StructuredGrid VTK .vts files
  /**
   * Requirement:
   * - DataCollector must be a model of \ref StructuredDataCollector
   **/
22
  template <class GridView, class DataCollector = Vtk::StructuredDataCollector<GridView>>
23
  class VtkStructuredGridWriter
24
      : public VtkWriterInterface<GridView, DataCollector>
25
  {
26
    using Super = VtkWriterInterface<GridView, DataCollector>;
27
28
29
    using pos_type = typename Super::pos_type;

  public:
30
31
    /// forwarding constructor to \ref VtkWriterInterface
    using Super::Super;
32
33
34

  private:
    /// Write a serial VTK file in Unstructured format
35
    virtual void writeSerialFile (std::ofstream& out) const override;
36
37
38
39

    /// Write a parallel VTK file `pfilename.pvtu` in Unstructured format,
    /// with `size` the number of pieces and serial files given by `pfilename_p[i].vtu`
    /// for [i] in [0,...,size).
40
    virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override;
41
42
43
44
45
46

    virtual std::string fileExtension () const override
    {
      return "vts";
    }

47
48
    virtual void writeGridAppended (std::ofstream& out, std::vector<std::uint64_t>& blocks) const override;

49
50
51
52
  private:
    using Super::dataCollector_;
    using Super::format_;
    using Super::datatype_;
53
    using Super::headertype_;
54
55
56
57
58
59

    // attached data
    using Super::pointData_;
    using Super::cellData_;
  };

60
  // deduction guides
61
62
63
  template <class GridView, class... Args,
    Vtk::IsGridView<GridView> = true>
  VtkStructuredGridWriter(GridView, Args...)
Stenger, Florian's avatar
Stenger, Florian committed
64
    -> VtkStructuredGridWriter<GridView, Vtk::StructuredDataCollector<GridView>>;
65

66
67
68
  template <class DataCollector, class... Args,
    Vtk::IsDataCollector<DataCollector> = true>
  VtkStructuredGridWriter(DataCollector&, Args...)
69
70
    -> VtkStructuredGridWriter<typename DataCollector::GridView, DataCollector>;

71
72
73
  template <class DataCollector, class... Args,
    Vtk::IsDataCollector<DataCollector> = true>
  VtkStructuredGridWriter(std::shared_ptr<DataCollector>, Args...)
74
75
    -> VtkStructuredGridWriter<typename DataCollector::GridView, DataCollector>;

76
} // end namespace Dune
77

78
#include "vtkstructuredgridwriter.impl.hh"