4 #ifndef DUNE_VTKSEQUENCEBASE_HH
5 #define DUNE_VTKSEQUENCEBASE_HH
14 #include <dune/common/path.hh>
15 #include <dune/common/shared_ptr.hh>
31 template<
class Gr
idView>
34 shared_ptr<VTKWriter<GridView> > vtkWriter_;
35 std::vector<double> timesteps_;
36 std::string name_,path_,extendpath_;
47 const std::string& name,
48 const std::string& path,
49 const std::string& extendpath,
52 : vtkWriter_(vtkWriter),
53 name_(name), path_(path),
54 extendpath_(extendpath),
64 vtkWriter_->addCellData(p);
70 vtkWriter_->addCellData(p);
79 void addCellData (
const V &v,
const std::string &name,
int ncomps=1)
81 vtkWriter_->addCellData(v, name, ncomps);
87 vtkWriter_->addVertexData(p);
93 vtkWriter_->addVertexData(p);
104 vtkWriter_->addVertexData(v, name, ncomps);
116 unsigned int count = timesteps_.size();
117 timesteps_.push_back(time);
121 vtkWriter_->write(concatPaths(path_,seqName(count)),ot);
123 vtkWriter_->pwrite(seqName(count), path_,extendpath_,ot);
127 std::ofstream pvdFile;
128 pvdFile.exceptions(std::ios_base::badbit | std::ios_base::failbit |
129 std::ios_base::eofbit);
130 std::string pvdname = name_ +
".pvd";
131 pvdFile.open(pvdname.c_str());
132 pvdFile <<
"<?xml version=\"1.0\"?> \n"
133 <<
"<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\"> \n"
134 <<
"<Collection> \n";
135 for (
unsigned int i=0; i<=count; i++)
138 std::string piecepath;
139 std::string fullname;
142 fullname = vtkWriter_->getSerialPieceName(seqName(i), piecepath);
145 piecepath = concatPaths(path_, extendpath_);
146 fullname = vtkWriter_->getParallelHeaderName(seqName(i), piecepath, size_);
148 pvdFile <<
"<DataSet timestep=\"" << timesteps_[i]
149 <<
"\" group=\"\" part=\"0\" name=\"\" file=\""
150 << fullname <<
"\"/> \n";
152 pvdFile <<
"</Collection> \n"
153 <<
"</VTKFile> \n" << std::flush;
160 std::string seqName(
unsigned int count)
const
164 n << name_ <<
"-" << std::setw(5) << count;
A base class for grid functions with any return type and dimension.
Definition: function.hh:38
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:40
Base class to write pvd-files which contains a list of all collected vtk-files.
Definition: vtksequencewriterbase.hh:32
void addCellData(const V &v, const std::string &name, int ncomps=1)
Adds a field of cell data to the VTK file.
Definition: vtksequencewriterbase.hh:79
void write(double time, VTK::OutputType ot=VTK::ascii)
Writes VTK data for the given time,.
Definition: vtksequencewriterbase.hh:113
void addVertexData(typename VTKWriter< GridView >::VTKFunction *p)
Adds a field of vertex data to the VTK file.
Definition: vtksequencewriterbase.hh:85
Include standard header files.
Definition: agrid.hh:59
VTKSequenceWriterBase(shared_ptr< VTKWriter< GridView > > vtkWriter, const std::string &name, const std::string &path, const std::string &extendpath, int rank, int size)
Set up the VTKSequenceWriterBase class.
Definition: vtksequencewriterbase.hh:46
void addCellData(const shared_ptr< const typename VTKWriter< GridView >::VTKFunction > &p)
Adds a field of cell data to the VTK file.
Definition: vtksequencewriterbase.hh:62
Common stuff for the VTKWriter.
~VTKSequenceWriterBase()
Definition: vtksequencewriterbase.hh:59
void addVertexData(const typename VTKWriter< GridView >::VTKFunctionPtr &p)
Adds a field of vertex data to the VTK file.
Definition: vtksequencewriterbase.hh:91
Provides file i/o for the visualization toolkit.
Output to the file is in ascii.
Definition: common.hh:42
shared_ptr< const VTKFunction > VTKFunctionPtr
Definition: vtkwriter.hh:114
void addCellData(typename VTKWriter< GridView >::VTKFunction *p)
Adds a field of cell data to the VTK file.
Definition: vtksequencewriterbase.hh:68
void addVertexData(const V &v, const std::string &name, int ncomps=1)
Adds a field of vertex data to the VTK file.
Definition: vtksequencewriterbase.hh:102
Writer for the ouput of grid functions in the vtk format.Writes arbitrary grid functions (living on c...
Definition: vtkwriter.hh:63