dune-vtk  0.2
pvdwriter.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iosfwd>
4 #include <optional>
5 #include <string>
6 #include <vector>
7 #include <tuple>
8 
9 #include <dune/vtk/types.hh>
10 #include <dune/vtk/filewriter.hh>
11 
12 namespace Dune
13 {
15  template <class VtkWriter>
16  class PvdWriter
17  : public Vtk::FileWriter
18  {
19  using Self = PvdWriter;
20 
21  public:
23  template <class... Args,
24  disableCopyMove<Self,Args...> = 0>
25  explicit PvdWriter (Args&&... args)
26  : vtkWriter_{std::forward<Args>(args)...}
27  {
30  }
31 
33 
43  void writeTimestep (double time, std::string const& fn, std::optional<std::string> dir = {},
44  bool writeCollection = true) const;
45 
47  // NOTE: requires an aforegoing call to \ref writeTimestep
53  virtual std::string write (std::string const& fn, std::optional<std::string> dir = {}) const override;
54 
56  template <class Function, class... Args>
57  PvdWriter& addPointData (Function const& fct, Args&&... args)
58  {
59  vtkWriter_.addPointData(fct, std::forward<Args>(args)...);
60  return *this;
61  }
62 
64  template <class Function, class... Args>
65  PvdWriter& addCellData (Function const& fct, Args&&... args)
66  {
67  vtkWriter_.addCellData(fct, std::forward<Args>(args)...);
68  return *this;
69  }
70 
71  protected:
73  void writeFile (std::ofstream& out) const;
74 
75  protected:
79 
80  mutable std::vector<std::pair<double, std::string>> timesteps_;
81  };
82 
83 } // end namespace Dune
84 
85 #include "pvdwriter.impl.hh"
Definition: datacollectorinterface.hh:9
FormatTypes
Type used for representing the output format.
Definition: types.hh:21
DataTypes
Definition: types.hh:50
Definition: filewriter.hh:11
File-Writer for ParaView .pvd files.
Definition: pvdwriter.hh:18
PvdWriter & addCellData(Function const &fct, Args &&... args)
Attach cell data to the writer,.
Definition: pvdwriter.hh:65
Vtk::DataTypes datatype_
Definition: pvdwriter.hh:78
void writeTimestep(double time, std::string const &fn, std::optional< std::string > dir={}, bool writeCollection=true) const
Write the attached data to the file.
Definition: pvdwriter.impl.hh:13
virtual std::string write(std::string const &fn, std::optional< std::string > dir={}) const override
Writes collection of timesteps to .pvd file.
Definition: pvdwriter.impl.hh:53
void writeFile(std::ofstream &out) const
Write a series of vtk files in a .pvd ParaView Data file.
Definition: pvdwriter.impl.hh:82
VtkWriter vtkWriter_
Definition: pvdwriter.hh:76
PvdWriter & addPointData(Function const &fct, Args &&... args)
Attach point data to the writer,.
Definition: pvdwriter.hh:57
std::vector< std::pair< double, std::string > > timesteps_
Definition: pvdwriter.hh:80
Vtk::FormatTypes format_
Definition: pvdwriter.hh:77
PvdWriter(Args &&... args)
Constructor, creates a VtkWriter with constructor arguments forwarded.
Definition: pvdwriter.hh:25
Default choice of VTK Writer for several grid types.
Definition: vtkwriter.hh:40
VtkWriterInterface & addPointData(Function &&fct, Args &&... args)
Attach point data to the writer.
Definition: vtkwriterinterface.hh:106
Vtk::DataTypes getDatatype() const
Definition: vtkwriterinterface.hh:248
VtkWriterInterface & addCellData(Function &&fct, Args &&... args)
Attach cell data to the writer.
Definition: vtkwriterinterface.hh:124
Vtk::FormatTypes getFormat() const
Definition: vtkwriterinterface.hh:242