6#ifndef DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
7#define DUNE_GRID_IO_FILE_VTK_VTUWRITER_HH
12#include <dune/common/exceptions.hh>
13#include <dune/common/indent.hh>
107 std::string fileType;
108 std::string cellName;
128 fileType =
"PolyData";
132 fileType =
"UnstructuredGrid";
136 DUNE_THROW(IOError,
"VTUWriter: Unknown fileType: " << fileType_);
140 stream << indent <<
"<?xml version=\"1.0\"?>\n";
141 stream << indent <<
"<VTKFile"
142 <<
" type=\"" << fileType <<
"\""
143 <<
" version=\"0.1\""
144 <<
" byte_order=\"" << byteOrder <<
"\">\n";
151 stream << indent <<
"</VTKFile>\n"
168 const std::string& vectors =
"") {
171 stream << indent <<
"<PointData";
172 if(scalars !=
"")
stream <<
" Scalars=\"" << scalars <<
"\"";
173 if(vectors !=
"")
stream <<
" Vectors=\"" << vectors <<
"\"";
186 stream << indent <<
"</PointData>\n";
206 const std::string& vectors =
"") {
209 stream << indent <<
"<CellData";
210 if(scalars !=
"")
stream <<
" Scalars=\"" << scalars <<
"\"";
211 if(vectors !=
"")
stream <<
" Vectors=\"" << vectors <<
"\"";
224 stream << indent <<
"</CellData>\n";
241 stream << indent <<
"<Points>\n";
253 stream << indent <<
"</Points>\n";
277 stream << indent <<
"<" << cellName <<
">\n";
289 stream << indent <<
"</" << cellName <<
">\n";
310 inline void beginMain(
unsigned ncells,
unsigned npoints) {
311 stream << indent <<
"<" << fileType <<
">\n";
313 stream << indent <<
"<Piece"
314 <<
" NumberOf" << cellName <<
"=\"" << ncells <<
"\""
315 <<
" NumberOfPoints=\"" << npoints <<
"\">\n";
322 stream << indent <<
"</Piece>\n";
324 stream << indent <<
"</" << fileType <<
">\n";
349 stream << indent <<
"<AppendedData"
350 <<
" encoding=\"" << encoding <<
"\">\n";
363 stream << indent <<
"</AppendedData>\n";
381 unsigned ncomps,
unsigned nitems,
383 return factory.
make(name, ncomps, nitems, indent, prec);
Data array writers for the VTKWriter.
Common stuff for the VTKWriter.
Include standard header files.
Definition: agrid.hh:60
Precision
which precision to use when writing out data to vtk files
Definition: common.hh:271
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:43
FileType
which type of VTK file to write
Definition: common.hh:252
@ polyData
for .vtp files (PolyData)
Definition: common.hh:254
@ unstructuredGrid
for .vtu files (UnstructuredGrid)
Definition: common.hh:256
std::string getEndiannessString()
determine endianness of this C++ implementation
Definition: common.hh:232
base class for data array writers
Definition: dataarraywriter.hh:56
a factory for DataArrayWriters
Definition: dataarraywriter.hh:462
bool beginAppended()
signal start of the appended section
Definition: dataarraywriter.hh:497
DataArrayWriter * make(const std::string &name, unsigned ncomps, unsigned nitems, const Indent &indent, Precision prec)
create a DataArrayWriter
Definition: dataarraywriter.hh:541
const std::string & appendedEncoding() const
query encoding string for appended data
Definition: dataarraywriter.hh:510
Dump a .vtu/.vtp files contents to a stream.
Definition: vtuwriter.hh:98
DataArrayWriter * makeArrayWriter(const std::string &name, unsigned ncomps, unsigned nitems, Precision prec)
acquire a DataArrayWriter
Definition: vtuwriter.hh:380
bool beginAppended()
start the appended data section
Definition: vtuwriter.hh:345
void endAppended()
finish the appended data section
Definition: vtuwriter.hh:359
VTUWriter(std::ostream &stream_, OutputType outputType, FileType fileType_)
create a VTUWriter object
Definition: vtuwriter.hh:122
std::ostream & stream
Definition: vtuwriter.hh:100
void endCellData()
finish CellData section
Definition: vtuwriter.hh:220
void beginMain(unsigned ncells, unsigned npoints)
start the main PolyData/UnstructuredGrid section
Definition: vtuwriter.hh:310
void beginCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:274
void endPointData()
finish PointData section
Definition: vtuwriter.hh:182
Phase
Definition: vtuwriter.hh:101
@ appended
Definition: vtuwriter.hh:101
@ main
Definition: vtuwriter.hh:101
void beginCellData(const std::string &scalars="", const std::string &vectors="")
start CellData section
Definition: vtuwriter.hh:205
void beginPointData(const std::string &scalars="", const std::string &vectors="")
start PointData section
Definition: vtuwriter.hh:167
void endPoints()
finish section for the point coordinates
Definition: vtuwriter.hh:249
~VTUWriter()
write footer
Definition: vtuwriter.hh:149
void endCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:285
void beginPoints()
start section for the point coordinates
Definition: vtuwriter.hh:238
void endMain()
finish the main PolyData/UnstructuredGrid section
Definition: vtuwriter.hh:320
enum Dune::VTK::VTUWriter::Phase phase