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

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

7
#include <dune/vtk/filewriter.hh>
Praetorius, Simon's avatar
Praetorius, Simon committed
8
#include <dune/vtk/forward.hh>
9
10
11
12
#include <dune/vtk/vtkfunction.hh>
#include <dune/vtk/vtktypes.hh>
#include <dune/vtk/datacollectors/structureddatacollector.hh>

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
   **/
Praetorius, Simon's avatar
Praetorius, Simon committed
22
  template <class GridView, class DataCollector>
23
  class VtkStructuredGridWriter
24
      : public VtkWriterInterface<GridView, DataCollector>
25
26
27
  {
    static constexpr int dimension = GridView::dimension;

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

  public:
    /// Constructor, stores the gridView
33
34
35
36
    VtkStructuredGridWriter (GridView const& gridView,
                             Vtk::FormatTypes format = Vtk::BINARY,
                             Vtk::DataTypes datatype = Vtk::FLOAT32)
      : Super(gridView, format, datatype)
37
38
39
40
    {}

  private:
    /// Write a serial VTK file in Unstructured format
41
    virtual void writeSerialFile (std::ofstream& out) const override;
42
43
44
45

    /// 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).
46
    virtual void writeParallelFile (std::ofstream& out, std::string const& pfilename, int size) const override;
47
48
49
50
51
52

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

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

55
56
57
58
59
60
61
62
63
64
  private:
    using Super::dataCollector_;
    using Super::format_;
    using Super::datatype_;

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

65
} // end namespace Dune
66
67

#include "vtkstructuredgridwriter.impl.hh"