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

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

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

#include "vtkwriterinterface.hh"
14
15
16
17

namespace Dune { namespace experimental
{
  /// File-Writer for VTK .vtu files
18
  template <class GridView, class DataCollector = StructuredDataCollector<GridView>>
19
  class VtkStructuredGridWriter
20
      : public VtkWriterInterface<GridView, DataCollector>
21
22
23
  {
    static constexpr int dimension = GridView::dimension;

24
    using Super = VtkWriterInterface<GridView, DataCollector>;
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
    using pos_type = typename Super::pos_type;

  public:
    /// Constructor, stores the gridView
    VtkStructuredGridWriter (GridView const& gridView)
      : Super(gridView)
    {}

  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_;
  };

}} // end namespace Dune::experimental

#include "vtkstructuredgridwriter.impl.hh"