dune-vtk 2.12
Loading...
Searching...
No Matches
pvdwriter.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3#pragma once
4
5#include <iosfwd>
6#include <memory>
7#include <optional>
8#include <string>
9#include <vector>
10#include <tuple>
11
13#include <dune/vtk/types.hh>
15
16namespace Dune::Vtk
17{
19 template <class W>
21 : public Vtk::FileWriter
22 {
23 using Self = PvdWriter;
24
25 public:
27 using Writer = W;
28
29 public:
32 : vtkWriter_(std::move(vtkWriter))
33 , format_(vtkWriter_->getFormat())
34 , datatype_(vtkWriter_->getDatatype())
35 {}
36
38 explicit PvdWriter (Writer& vtkWriter)
40 {}
41
43 template <class... Args,
44 disableCopyMove<Self,Args...> = 0>
45 explicit PvdWriter (Args&&... args)
46 : PvdWriter(std::make_shared<Writer>(std::forward<Args>(args)...))
47 {}
48
50
60 void writeTimestep (double time, std::string const& fn, std::optional<std::string> dir = {},
61 bool writeCollection = true) const;
62
64 // NOTE: requires an aforegoing call to \ref writeTimestep
70 std::string write (std::string const& fn, std::optional<std::string> dir = {}) const override;
71
73 template <class Function, class... Args>
75 {
76 vtkWriter_->addPointData(fct, std::forward<Args>(args)...);
77 return *this;
78 }
79
81 template <class Function, class... Args>
83 {
84 vtkWriter_->addCellData(fct, std::forward<Args>(args)...);
85 return *this;
86 }
87
88 protected:
90 void writeFile (std::ofstream& out) const;
91
92 private:
93 std::shared_ptr<Writer> vtkWriter_;
96
98 };
99
100} // end namespace Dune::Vtk
101
102namespace Dune
103{
104 template <class VtkWriter>
105 class [[deprecated("Use Vtk::PvdWriter instead.")]] PvdWriter
106 : public Vtk::PvdWriter<VtkWriter>
107 {
108 using Base = Vtk::PvdWriter<VtkWriter>;
109 public:
110 using Base::Base;
111 };
112
113} // end namespace Dune
114
115#include "pvdwriter.impl.hh"
STL namespace.
Definition datacollector.hh:19
FormatTypes
Type used for representing the output format.
Definition types.hh:21
DataTypes
Definition types.hh:53
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20
Definition filewriter.hh:11
Definition function.hh:20
File-Writer for ParaView .pvd files.
Definition pvdwriter.hh:22
PvdWriter & addCellData(Function const &fct, Args &&... args)
Attach cell data to the writer,.
Definition pvdwriter.hh:82
W Writer
Type of the Vtk writer to call on each timestep.
Definition pvdwriter.hh:27
PvdWriter(std::shared_ptr< Writer > vtkWriter)
Constructor. Stores the shared_ptr to the vtk writer.
Definition pvdwriter.hh:31
PvdWriter(Args &&... args)
Constructor, creates a VtkWriter with constructor arguments forwarded.
Definition pvdwriter.hh:45
PvdWriter(Writer &vtkWriter)
Constructor. Stores the references to the passed vtk writer in a non-destroying shared_ptr.
Definition pvdwriter.hh:38
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:64
PvdWriter & addPointData(Function const &fct, Args &&... args)
Attach point data to the writer,.
Definition pvdwriter.hh:74
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:16
void writeFile(std::ofstream &out) const
Write a series of vtk files in a .pvd ParaView Data file.
Definition pvdwriter.impl.hh:93