dune-vtk 2.12
Loading...
Searching...
No Matches
pvdwriter.hh
Go to the documentation of this file.
1#pragma once
2
3#include <iosfwd>
4#include <memory>
5#include <optional>
6#include <string>
7#include <vector>
8#include <tuple>
9
11#include <dune/vtk/types.hh>
13
14namespace Dune::Vtk
15{
17 template <class W>
19 : public Vtk::FileWriter
20 {
21 using Self = PvdWriter;
22
23 public:
25 using Writer = W;
26
27 public:
30 : vtkWriter_(std::move(vtkWriter))
31 , format_(vtkWriter_->getFormat())
32 , datatype_(vtkWriter_->getDatatype())
33 {}
34
36 explicit PvdWriter (Writer& vtkWriter)
38 {}
39
41 template <class... Args,
42 disableCopyMove<Self,Args...> = 0>
43 explicit PvdWriter (Args&&... args)
44 : PvdWriter(std::make_shared<Writer>(std::forward<Args>(args)...))
45 {}
46
48
58 void writeTimestep (double time, std::string const& fn, std::optional<std::string> dir = {},
59 bool writeCollection = true) const;
60
62 // NOTE: requires an aforegoing call to \ref writeTimestep
68 std::string write (std::string const& fn, std::optional<std::string> dir = {}) const override;
69
71 template <class Function, class... Args>
72 PvdWriter& addPointData (Function const& fct, Args&&... args)
73 {
74 vtkWriter_->addPointData(fct, std::forward<Args>(args)...);
75 return *this;
76 }
77
79 template <class Function, class... Args>
80 PvdWriter& addCellData (Function const& fct, Args&&... args)
81 {
82 vtkWriter_->addCellData(fct, std::forward<Args>(args)...);
83 return *this;
84 }
85
86 protected:
88 void writeFile (std::ofstream& out) const;
89
90 private:
91 std::shared_ptr<Writer> vtkWriter_;
94
96 };
97
98} // end namespace Dune::Vtk
99
100namespace Dune
101{
102 template <class VtkWriter>
103 class [[deprecated("Use Vtk::PvdWriter instead.")]] PvdWriter
104 : public Vtk::PvdWriter<VtkWriter>
105 {
106 using Base = Vtk::PvdWriter<VtkWriter>;
107 public:
108 using Base::Base;
109 };
110
111} // end namespace Dune
112
113#include "pvdwriter.impl.hh"
STL namespace.
Definition writer.hh:16
FormatTypes
Type used for representing the output format.
Definition types.hh:19
DataTypes
Definition types.hh:51
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Definition filewriter.hh:9
Definition function.hh:18
File-Writer for ParaView .pvd files.
Definition pvdwriter.hh:20
PvdWriter & addCellData(Function const &fct, Args &&... args)
Attach cell data to the writer,.
Definition pvdwriter.hh:80
W Writer
Type of the Vtk writer to call on each timestep.
Definition pvdwriter.hh:25
PvdWriter(std::shared_ptr< Writer > vtkWriter)
Constructor. Stores the shared_ptr to the vtk writer.
Definition pvdwriter.hh:29
PvdWriter(Args &&... args)
Constructor, creates a VtkWriter with constructor arguments forwarded.
Definition pvdwriter.hh:43
PvdWriter(Writer &vtkWriter)
Constructor. Stores the references to the passed vtk writer in a non-destroying shared_ptr.
Definition pvdwriter.hh:36
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:62
PvdWriter & addPointData(Function const &fct, Args &&... args)
Attach point data to the writer,.
Definition pvdwriter.hh:72
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:14
void writeFile(std::ofstream &out) const
Write a series of vtk files in a .pvd ParaView Data file.
Definition pvdwriter.impl.hh:91