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

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

7
8
9
10
11
#include <dune/vtk/filewriter.hh>
#include <dune/vtk/vtkfunction.hh>
#include <dune/vtk/vtktypes.hh>
#include <dune/vtk/datacollectors/structureddatacollector.hh>

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

14
namespace Dune
15
{
16
17
18
19
20
  /// File-Writer for StructuredGrid VTK .vts files
  /**
   * Requirement:
   * - DataCollector must be a model of \ref StructuredDataCollector
   **/
21
  template <class GridView, class DataCollector = StructuredDataCollector<GridView>>
22
  class VtkStructuredGridWriter
23
      : public VtkWriterInterface<GridView, DataCollector>
24
25
26
  {
    static constexpr int dimension = GridView::dimension;

27
    using Super = VtkWriterInterface<GridView, DataCollector>;
28
29
30
31
    using pos_type = typename Super::pos_type;

  public:
    /// Constructor, stores the gridView
32
33
34
35
    VtkStructuredGridWriter (GridView const& gridView,
                             Vtk::FormatTypes format = Vtk::BINARY,
                             Vtk::DataTypes datatype = Vtk::FLOAT32)
      : Super(gridView, format, datatype)
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
    {}

  private:
    /// Write a serial VTK file in Unstructured format
    virtual void writeSerialFile (std::string const& filename) const override;

    /// 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).
    virtual void writeParallelFile (std::string const& pfilename, int size) const override;

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

  private:
    using Super::dataCollector_;
    using Super::format_;
    using Super::datatype_;

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

62
} // end namespace Dune
63
64

#include "vtkstructuredgridwriter.impl.hh"