4 #ifndef DUNE_GRID_IO_FILE_VTK_VTKSEQUENCEWRITERBASE_HH 5 #define DUNE_GRID_IO_FILE_VTK_VTKSEQUENCEWRITERBASE_HH 15 #include <dune/common/path.hh> 30 template<
class Gr
idView>
33 std::shared_ptr<VTKWriter<GridView> > vtkWriter_;
34 std::vector<double> timesteps_;
35 std::string name_,path_,extendpath_;
46 const std::string& name,
47 const std::string& path,
48 const std::string& extendpath,
51 : vtkWriter_(vtkWriter),
52 name_(name), path_(path),
53 extendpath_(extendpath),
63 vtkWriter_->addCellData(p);
72 void addCellData (
const V &v,
const std::string &name,
int ncomps=1)
74 vtkWriter_->addCellData(v, name, ncomps);
80 vtkWriter_->addVertexData(p);
91 vtkWriter_->addVertexData(v, name, ncomps);
103 unsigned int count = timesteps_.size();
104 timesteps_.push_back(time);
108 vtkWriter_->write(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" 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 = 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;
A base class for grid functions with any return type and dimension.
Definition: function.hh:38
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:72
Writer for the ouput of grid functions in the vtk format.Writes arbitrary grid functions (living on c...
Definition: vtkwriter.hh:87
void addCellData(const std::shared_ptr< const typename VTKWriter< GridView >::VTKFunction > &p)
Adds a field of cell data to the VTK file.
Definition: vtksequencewriterbase.hh:61
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:40
Common stuff for the VTKWriter.
VTKSequenceWriterBase(std::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:45
std::string getEndiannessString()
determine endianness of this C++ implementation
Definition: common.hh:278
void write(double time, VTK::OutputType type=VTK::ascii)
Writes VTK data for the given time,.
Definition: vtksequencewriterbase.hh:100
Base class to write pvd-files which contains a list of all collected vtk-files.
Definition: vtksequencewriterbase.hh:31
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:89
Include standard header files.
Definition: agrid.hh:59
Output to the file is in ascii.
Definition: common.hh:42
~VTKSequenceWriterBase()
Definition: vtksequencewriterbase.hh:58
Provides file i/o for the visualization toolkit.
void addVertexData(const std::shared_ptr< const typename VTKWriter< GridView >::VTKFunction > &p)
Adds a field of vertex data to the VTK file.
Definition: vtksequencewriterbase.hh:78