26#ifndef DUMUX_VTKSEQUENCEWRITER_HH
27#define DUMUX_VTKSEQUENCEWRITER_HH
36#include <dune/grid/io/file/vtk/common.hh>
37#include <dune/common/path.hh>
54 template<
class VTKWriter>
57 std::shared_ptr<VTKWriter > vtkWriter_;
58 std::vector<double> timesteps_;
59 std::string name_,path_,extendpath_;
80 const std::string& name,
81 const std::string& path,
82 const std::string& extendpath,
85 : vtkWriter_(vtkWriter),
86 name_(name), path_(path),
87 extendpath_(extendpath),
100 void write (
double time, Dune::VTK::OutputType type = Dune::VTK::ascii)
103 unsigned int count = timesteps_.size();
104 timesteps_.push_back(time);
108 vtkWriter_->write(Dune::concatPaths(path_,seqName(count)),type);
110 vtkWriter_->pwrite(seqName(count), path_,extendpath_,type);
114 std::ofstream pvdFile;
115 pvdFile.exceptions(std::ios_base::badbit | std::ios_base::failbit |
116 std::ios_base::eofbit);
117 std::string pvdname = name_ +
".pvd";
118 pvdFile.open(pvdname.c_str());
119 pvdFile <<
"<?xml version=\"1.0\"?> \n"
120 <<
"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"" << Dune::VTK::getEndiannessString() <<
"\"> \n"
121 <<
"<Collection> \n";
122 for (
unsigned int i=0; i<=count; i++)
125 std::string piecepath;
126 std::string fullname;
129 fullname = vtkWriter_->getSerialPieceName(seqName(i), piecepath);
132 piecepath = Dune::concatPaths(path_, extendpath_);
133 fullname = vtkWriter_->getParallelHeaderName(seqName(i), piecepath, size_);
135 pvdFile <<
"<DataSet timestep=\"" << timesteps_[i]
136 <<
"\" group=\"\" part=\"0\" name=\"\" file=\""
137 << fullname <<
"\"/> \n";
139 pvdFile <<
"</Collection> \n"
140 <<
"</VTKFile> \n" << std::flush;
147 std::string seqName(
unsigned int count)
const
151 n << name_ <<
"-" << std::setw(5) << count;
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
Base class to write pvd-files which contains a list of all collected vtk-files. This is a modified ve...
Definition: vtksequencewriter.hh:56
~VTKSequenceWriter()
Definition: vtksequencewriter.hh:92
VTKSequenceWriter(std::shared_ptr< VTKWriter > vtkWriter, const std::string &name, const std::string &path, const std::string &extendpath, int rank, int size)
Set up the VTKSequenceWriter class.
Definition: vtksequencewriter.hh:79
void write(double time, Dune::VTK::OutputType type=Dune::VTK::ascii)
Writes VTK data for the given time,.
Definition: vtksequencewriter.hh:100