4#ifndef DUNE_VTKWRITER_HH
5#define DUNE_VTKWRITER_HH
24#include <dune/geometry/referenceelements.hh>
26#include <dune/grid/common/gridenums.hh>
30#include <dune/grid/io/file/vtk/pvtuwriter.hh>
31#include <dune/grid/io/file/vtk/streams.hh>
32#include <dune/grid/io/file/vtk/vtuwriter.hh>
53 template<
class F,
class E,
class =
void >
58 template<
class F,
class E >
59 struct IsBindable< F, E,
void_t< decltype(
std::declval< F & >().bind( std::declval< const E & >() ) ), decltype( std::declval< F & >().unbind() ) > >
64 template<
class F,
class =
void >
65 struct HasLocalFunction
70 struct HasLocalFunction< F,
void_t< decltype( localFunction(
std::declval< F& >() ) ) > >
77 template <
class Gr
idView>
78 class VTKSequenceWriterBase;
79 template <
class Gr
idView>
80 class VTKSequenceWriter;
90 template<
class Gr
idView >
114 typedef typename GridView::template
Codim< 0 >
115 ::template Partition< VTK_Partition >::Iterator
117 typedef typename GridView::template
Codim< n >
118 ::template Partition< VTK_Partition >::Iterator
121 typedef typename GridCellIterator::Reference EntityReference;
123 typedef typename GridView::template
Codim< 0 >
124 ::Entity::Geometry::LocalCoordinate Coordinate;
131 switch( VTK_Partition )
163 virtual void bind(
const Entity& e) = 0;
172 virtual void write(
const Coordinate& pos,
Writer& w, std::size_t count)
const = 0;
184 using Function =
typename std::decay<F>::type;
186 template<
typename F_>
188 : _f(std::forward<F_>(f))
191 virtual void bind(
const Entity& e)
201 virtual void write(
const Coordinate& pos,
Writer& w, std::size_t count)
const
211 void do_write(
Writer& w,
const R& r, std::size_t count, std::true_type)
const
213 for (std::size_t i = 0; i < count; ++i)
218 void do_write(Writer& w,
const R& r, std::size_t count, std::false_type)
const
232 using Function =
typename std::decay<F>::type;
234 template<
typename F_>
236 : _f(std::forward<F_>(f))
240 virtual void bind(
const Entity& e)
250 virtual void write(
const Coordinate& pos,
Writer& w, std::size_t count)
const
252 auto globalPos = element_->geometry().global(pos);
253 auto r = _f(globalPos);
256 for (std::size_t i = 0; i < count; ++i)
266 const Entity* element_;
278 virtual void bind(
const Entity& e)
288 virtual void write(
const Coordinate& pos,
Writer& w, std::size_t count)
const
290 for (std::size_t i = 0; i < count; ++i)
291 w.
write(_f->evaluate(i,*_entity,pos));
296 std::shared_ptr< const VTKFunction > _f;
297 const Entity* _entity;
302 template<typename F, std::enable_if_t<Impl::IsBindable<F, Entity>::value,
int> = 0>
310 template<typename F, std::enable_if_t<not Impl::IsBindable<F, Entity>::value && Impl::HasLocalFunction<F>::value,
int> = 0>
313 typename
std::decay<decltype(localFunction(
std::forward<F>(f)))>::type
314 > >(localFunction(
std::forward<F>(f))))
320 template<typename F, std::enable_if_t<not Impl::IsBindable<F, Entity>::value && not Impl::HasLocalFunction<F>::value,
int> = 0>
330 vtkFunctionPtr->
name(),
331 vtkFunctionPtr->ncomps() > 1 ? VTK::FieldInfo::Type::vector : VTK::FieldInfo::Type::scalar,
332 vtkFunctionPtr->ncomps(),
333 vtkFunctionPtr->precision()
350 void bind(
const Entity& e)
const
367 std::shared_ptr<FunctionWrapperBase> _f;
372 typedef typename std::list<VTKLocalFunction>::const_iterator FunctionIterator;
393 CellIterator cellBegin()
const
395 return gridView_.template begin< 0, VTK_Partition >();
398 CellIterator cellEnd()
const
400 return gridView_.template end< 0, VTK_Partition >();
421 GridCellIterator git;
422 GridCellIterator gend;
428 std::vector<bool> visited;
436 void basicIncrement ()
441 const int numCorners = git->subEntities(n);
442 if( cornerIndexDune == numCorners )
444 offset += numCorners;
448 while( (git != gend) && skipEntity( git->partitionType() ) )
454 const GridCellIterator & end,
457 git(x), gend(end), datamode(dm), cornerIndexDune(0),
458 vertexmapper(vm), visited(vm.
size(),
false),
461 if (datamode == VTK::conforming && git != gend)
462 visited[vertexmapper.
subIndex(*git,cornerIndexDune,n)] =
true;
468 case VTK::conforming :
469 while(visited[vertexmapper.
subIndex(*git,cornerIndexDune,n)])
472 if (git == gend)
return;
474 visited[vertexmapper.
subIndex(*git,cornerIndexDune,n)] =
true;
476 case VTK::nonconforming :
483 return git == cit.git
484 && cornerIndexDune == cit.cornerIndexDune
485 && datamode == cit.datamode;
487 EntityReference dereference()
const
494 return cornerIndexDune;
499 return referenceElement<DT,n>(git->type())
500 .position(cornerIndexDune,n);
504 VertexIterator vertexBegin ()
const
506 return VertexIterator( gridView_.template begin< 0, VTK_Partition >(),
507 gridView_.template end< 0, VTK_Partition >(),
508 datamode, *vertexmapper );
511 VertexIterator vertexEnd ()
const
513 return VertexIterator( gridView_.template end< 0, VTK_Partition >(),
514 gridView_.template end< 0, VTK_Partition >(),
515 datamode, *vertexmapper );
536 GridCellIterator git;
537 GridCellIterator gend;
546 const std::vector<int> & number;
555 const GridCellIterator & end,
558 const std::vector<int> & num) :
559 git(x), gend(end), datamode(dm), cornerIndexVTK(0),
561 number(num), offset(0) {}
567 const int numCorners = git->subEntities(n);
568 if( cornerIndexVTK == numCorners )
570 offset += numCorners;
574 while( (git != gend) && skipEntity( git->partitionType() ) )
580 return git == cit.git
581 && cornerIndexVTK == cit.cornerIndexVTK
582 && datamode == cit.datamode;
584 EntityReference dereference()
const
597 case VTK::conforming :
599 number[vertexmapper.
subIndex(*git,VTK::renumber(*git,cornerIndexVTK),
601 case VTK::nonconforming :
602 return offset + VTK::renumber(*git,cornerIndexVTK);
609 CornerIterator cornerBegin ()
const
611 return CornerIterator( gridView_.template begin< 0, VTK_Partition >(),
612 gridView_.template end< 0, VTK_Partition >(),
613 datamode, *vertexmapper, number );
616 CornerIterator cornerEnd ()
const
618 return CornerIterator( gridView_.template end< 0, VTK_Partition >(),
619 gridView_.template end< 0, VTK_Partition >(),
620 datamode, *vertexmapper, number );
635 : gridView_( gridView ),
638 polyhedralCellsPresent_( checkForPolyhedralCells() )
690 template<
class Container>
691 void addCellData (
const Container& v,
const std::string &name,
int ncomps = 1,
695 for (
int c=0; c<ncomps; ++c) {
696 std::stringstream compName;
699 compName <<
"[" << c <<
"]";
701 addCellData(std::shared_ptr< const VTKFunction >(p));
755 template<
class Container>
756 void addVertexData (
const Container& v,
const std::string &name,
int ncomps=1,
760 for (
int c=0; c<ncomps; ++c) {
761 std::stringstream compName;
764 compName <<
"[" << c <<
"]";
779 {
return coordPrec; }
798 std::string
write (
const std::string &name,
801 return write( name, type, gridView_.
comm().rank(), gridView_.
comm().size() );
830 std::string
pwrite (
const std::string & name,
const std::string & path,
const std::string & extendpath,
833 return pwrite( name, path, extendpath, type, gridView_.
comm().rank(), gridView_.
comm().size() );
850 const std::string& path,
851 int commRank,
int commSize)
const
853 std::ostringstream s;
854 if(path.size() > 0) {
856 if(path[path.size()-1] !=
'/')
859 s <<
's' << std::setw(4) << std::setfill(
'0') << commSize <<
'-';
860 s <<
'p' << std::setw(4) << std::setfill(
'0') << commRank <<
'-';
881 const std::string& path,
884 std::ostringstream s;
885 if(path.size() > 0) {
887 if(path[path.size()-1] !=
'/')
890 s <<
's' << std::setw(4) << std::setfill(
'0') << commSize <<
'-';
913 const std::string& path)
const
915 static const std::string extension =
936 std::string
write (
const std::string &name,
944 return pwrite(name,
"",
"", type, commRank, commSize);
954 file.exceptions(std::ios_base::badbit | std::ios_base::failbit |
955 std::ios_base::eofbit);
958 file.open( pieceName.c_str(), std::ios::binary );
961 std::cerr <<
"Filename: " << pieceName <<
" could not be opened" << std::endl;
964 if (! file.is_open())
966 writeDataFile( file );
996 std::string
pwrite(
const std::string& name,
const std::string& path,
997 const std::string& extendpath,
1006 file.exceptions(std::ios_base::badbit | std::ios_base::failbit |
1007 std::ios_base::eofbit);
1008 std::string piecepath =
concatPaths(path, extendpath);
1009 std::string relpiecepath =
relativePath(path, piecepath);
1016 file.open(fullname.c_str(),std::ios::binary);
1019 std::cerr <<
"Filename: " << fullname <<
" could not be opened" << std::endl;
1022 if (! file.is_open())
1024 writeDataFile(file);
1026 gridView_.
comm().barrier();
1032 file.open(fullname.c_str());
1033 if (! file.is_open())
1035 writeParallelHeader(file,name,relpiecepath, commSize );
1038 gridView_.
comm().barrier();
1061 void writeParallelHeader(std::ostream& s,
const std::string& piecename,
1062 const std::string& piecepath,
const int commSize)
1065 (n == 1) ? VTK::polyData : VTK::unstructuredGrid;
1073 std::string scalars, vectors;
1074 std::tie(scalars,vectors) = getDataNames(vertexdata);
1075 writer.beginPointData(scalars, vectors);
1077 for (
auto it = vertexdata.begin(),
1078 end = vertexdata.end();
1082 unsigned writecomps = it->fieldInfo().size();
1083 if(writecomps == 2) writecomps = 3;
1084 writer.addArray(it->name(), writecomps, it->fieldInfo().precision());
1086 writer.endPointData();
1090 std::string scalars, vectors;
1091 std::tie(scalars,vectors) = getDataNames(celldata);
1092 writer.beginCellData(scalars, vectors);
1094 for (
auto it = celldata.begin(),
1095 end = celldata.end();
1099 unsigned writecomps = it->fieldInfo().size();
1100 if(writecomps == 2) writecomps = 3;
1101 writer.addArray(it->name(), writecomps, it->fieldInfo().precision());
1103 writer.endCellData();
1106 writer.beginPoints();
1107 writer.addArray(
"Coordinates", 3, coordPrec);
1111 for(
int i = 0; i < commSize; ++i )
1116 writer.addPiece(fullname);
1123 void writeDataFile (std::ostream& s)
1125 VTK::FileType fileType =
1126 (n == 1) ? VTK::polyData : VTK::unstructuredGrid;
1128 VTK::VTUWriter writer(s, outputtype, fileType);
1132 if (datamode == VTK::conforming)
1134 number.resize(vertexmapper->
size());
1135 for (std::vector<int>::size_type i=0; i<number.size(); i++) number[i] = -1;
1139 writer.beginMain(ncells, nvertices);
1140 writeAllData(writer);
1144 if(writer.beginAppended())
1145 writeAllData(writer);
1146 writer.endAppended();
1148 delete vertexmapper; number.clear();
1151 void writeAllData(VTK::VTUWriter& writer) {
1166 std::string getFormatString()
const
1168 if (outputtype==VTK::ascii)
1170 if (outputtype==VTK::base64)
1172 if (outputtype==VTK::appendedraw)
1174 if (outputtype==VTK::appendedbase64)
1176 DUNE_THROW(IOError,
"VTKWriter: unsupported OutputType" << outputtype);
1179 std::string getTypeString()
const
1184 return "UnstructuredGrid";
1198 const int subEntities = it->subEntities(n);
1199 for (
int i=0; i<subEntities; ++i)
1202 if (datamode == VTK::conforming)
1204 int alpha = vertexmapper->
subIndex(*it,i,n);
1205 if (number[alpha]<0)
1206 number[alpha] = nvertices++;
1216 template<
typename T>
1217 std::tuple<std::string,std::string> getDataNames(
const T& data)
const
1219 std::string scalars =
"";
1220 for (
auto it = data.begin(),
1226 scalars = it->name();
1230 std::string vectors =
"";
1231 for (
auto it = data.begin(),
1237 vectors = it->name();
1240 return std::make_tuple(scalars,vectors);
1243 template<
typename Data,
typename Iterator>
1244 void writeData(VTK::VTUWriter& writer,
const Data& data,
const Iterator begin,
const Iterator end,
int nentries)
1246 for (
auto it = data.begin(),
1251 const auto& f = *it;
1252 VTK::FieldInfo fieldInfo = f.fieldInfo();
1253 std::size_t writecomps = fieldInfo.size();
1254 switch (fieldInfo.type())
1262 DUNE_THROW(IOError,
"Cannot write VTK vectors with more than 3 components (components was " << writecomps <<
")");
1266 DUNE_THROW(NotImplemented,
"VTK output for tensors not implemented yet");
1268 std::shared_ptr<VTK::DataArrayWriter> p
1269 (writer.makeArrayWriter(f.name(), writecomps, nentries, fieldInfo.precision()));
1270 if(!p->writeIsNoop())
1271 for (Iterator eit = begin; eit!=end; ++eit)
1273 const Entity & e = *eit;
1275 f.write(eit.position(),*p);
1279 for (std::size_t j=fieldInfo.size(); j < writecomps; ++j)
1288 if(celldata.size() == 0)
1291 std::string scalars, vectors;
1292 std::tie(scalars,vectors) = getDataNames(celldata);
1295 writeData(writer,celldata,cellBegin(),cellEnd(),ncells);
1302 if(vertexdata.size() == 0)
1305 std::string scalars, vectors;
1306 std::tie(scalars,vectors) = getDataNames(vertexdata);
1309 writeData(writer,vertexdata,vertexBegin(),vertexEnd(),nvertices);
1318 std::shared_ptr<VTK::DataArrayWriter> p
1320 if(!p->writeIsNoop()) {
1325 for (
int j=0; j<
std::min(dimw,3); j++)
1326 p->write((*vit).geometry().corner(vit.localindex())[j]);
1327 for (
int j=
std::min(dimw,3); j<3; j++)
1344 std::shared_ptr<VTK::DataArrayWriter> p1
1345 (writer.
makeArrayWriter(
"connectivity", 1, ncorners, VTK::Precision::int32));
1346 if(!p1->writeIsNoop())
1353 std::shared_ptr<VTK::DataArrayWriter> p2
1354 (writer.
makeArrayWriter(
"offsets", 1, ncells, VTK::Precision::int32));
1355 if(!p2->writeIsNoop()) {
1359 offset += it->subEntities(n);
1369 std::shared_ptr<VTK::DataArrayWriter> p3
1372 if(!p3->writeIsNoop())
1376 int vtktype = VTK::geometryType(it->type());
1384 if( polyhedralCellsPresent_ )
1394 bool checkForPolyhedralCells()
const
1397 for(
const auto& geomType : gridView_.
indexSet().types( 0 ) )
1399 if( VTK::geometryType( geomType ) == VTK::polyhedron )
1410 if( ! faceVertices_ )
1412 faceVertices_.reset(
new std::pair< std::vector<int>, std::vector<int> > () );
1414 fillFaceVertices( cornerBegin(), cornerEnd(), gridView_.
indexSet(),
1415 faceVertices_->first, faceVertices_->second );
1418 std::vector< int >& faces = faceVertices_->first;
1419 std::vector< int >& faceOffsets = faceVertices_->second;
1420 assert(
int(faceOffsets.size()) == ncells );
1423 std::shared_ptr<VTK::DataArrayWriter> p4
1424 (writer.
makeArrayWriter(
"faces", 1, faces.size(), VTK::Precision::int32));
1425 if(!p4->writeIsNoop())
1427 for(
const auto& face : faces )
1433 std::shared_ptr<VTK::DataArrayWriter> p5
1434 (writer.
makeArrayWriter(
"faceoffsets", 1, ncells, VTK::Precision::int32));
1435 if(!p5->writeIsNoop())
1437 for(
const auto& offset : faceOffsets )
1438 p5->write( offset );
1441 faceVertices_.reset();
1446 template <
class CornerIterator,
class IndexSet,
class T>
1447 inline void fillFaceVertices( CornerIterator it,
1448 const CornerIterator end,
1450 std::vector<T>& faces,
1451 std::vector<T>& faceOffsets )
1453 if( n == 3 && it != end )
1457 faces.reserve( 15 * ncells );
1458 faceOffsets.clear();
1459 faceOffsets.reserve( ncells );
1464 int elIndex = indexSet.
index( element );
1465 std::vector< T > vertices;
1466 vertices.reserve( 30 );
1467 for( ; it != end; ++it )
1469 const Cell& cell = *it ;
1470 const int cellIndex = indexSet.
index( cell ) ;
1471 if( elIndex != cellIndex )
1473 fillFacesForElement( element, indexSet, vertices, offset, faces, faceOffsets );
1477 elIndex = cellIndex ;
1479 vertices.push_back( it.id() );
1483 fillFacesForElement( element, indexSet, vertices, offset, faces, faceOffsets );
1487 template <
class Entity,
class IndexSet,
class T>
1488 static void fillFacesForElement(
const Entity& element,
1489 const IndexSet& indexSet,
1490 const std::vector<T>& vertices,
1492 std::vector<T>& faces,
1493 std::vector<T>& faceOffsets )
1497 std::map< T, T > vxMap;
1500 const int nVertices = element.subEntities( dim );
1501 for(
int vx = 0; vx < nVertices; ++ vx )
1503 const int vxIdx = indexSet.subIndex( element, vx, dim );
1504 vxMap[ vxIdx ] = vertices[ vx ];
1508 const int nFaces = element.subEntities( 1 );
1510 faces.push_back( nFaces );
1513 for(
int fce = 0; fce < nFaces; ++ fce )
1516 const auto face = element.template subEntity< 1 > ( fce );
1519 const int nVxFace = face.subEntities( dim );
1520 faces.push_back( nVxFace );
1522 for(
int i=0; i<nVxFace; ++i )
1524 const T vxIndex = indexSet.subIndex( face, i, dim );
1525 assert( vxMap.find( vxIndex ) != vxMap.end() );
1526 faces.push_back( vxMap[ vxIndex ] );
1532 faceOffsets.push_back( offset );
1537 std::list<VTKLocalFunction> celldata;
1538 std::list<VTKLocalFunction> vertexdata;
1548 VertexMapper* vertexmapper;
1551 std::vector<int> number;
1552 VTK::DataMode datamode;
1553 VTK::Precision coordPrec;
1556 const bool polyhedralCellsPresent_;
1559 std::shared_ptr< std::pair< std::vector<int>, std::vector<int> > > faceVertices_;
1562 VTK::OutputType outputtype;
vector space out of a tensor product of fields.
Definition: fvector.hh:96
Base class for stl conformant forward iterators.
Definition: iteratorfacades.hh:139
Base class template for function classes.
Definition: function.hh:29
Grid view abstract base class.
Definition: gridview.hh:60
Default exception class for I/O errors.
Definition: exceptions.hh:229
Index Set Interface base class.
Definition: indexidset.hh:76
IndexType index(const typename Traits::template Codim< cc >::Entity &e) const
Map entity to index. The result of calling this method with an entity that is not in the index set is...
Definition: indexidset.hh:111
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:200
Index subIndex(const typename GV::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
Map subentity of codim 0 entity to starting index in array for dof block.
Definition: mcmgmapper.hh:268
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:287
Default exception for dummy implementations.
Definition: exceptions.hh:261
Take a vector and interpret it as cell data for the VTKWriter.
Definition: function.hh:95
Take a vector and interpret it as point data for the VTKWriter.
Definition: function.hh:203
A base class for grid functions with any return type and dimension.
Definition: function.hh:40
Base class to write pvd-files which contains a list of all collected vtk-files.
Definition: vtksequencewriterbase.hh:32
Writer for the ouput of grid functions in the vtk format.
Definition: vtksequencewriter.hh:28
Iterator over the grids elements.
Definition: vtkwriter.hh:381
CellIterator(const GridCellIterator &x)
construct a CellIterator from the gridview's Iterator.
Definition: vtkwriter.hh:384
const FieldVector< DT, n > position() const
Definition: vtkwriter.hh:387
Iterate over the elements' corners.
Definition: vtkwriter.hh:535
int id() const
Process-local consecutive zero-starting vertex id.
Definition: vtkwriter.hh:593
Type erasure wrapper for VTK data sets.
Definition: vtkwriter.hh:152
void unbind() const
Unbind the data set from the currently bound entity.
Definition: vtkwriter.hh:356
VTKLocalFunction(F &&f, VTK::FieldInfo fieldInfo)
Construct a VTKLocalFunction for a dune-functions style LocalFunction.
Definition: vtkwriter.hh:303
std::string name() const
Returns the name of the data set.
Definition: vtkwriter.hh:338
const VTK::FieldInfo & fieldInfo() const
Returns the VTK::FieldInfo for the data set.
Definition: vtkwriter.hh:344
void bind(const Entity &e) const
Bind the data set to grid entity e.
Definition: vtkwriter.hh:350
VTKLocalFunction(const std::shared_ptr< const VTKFunction > &vtkFunctionPtr)
Construct a VTKLocalFunction for a legacy VTKFunction.
Definition: vtkwriter.hh:327
void write(const Coordinate &pos, Writer &w) const
Write the value of the data set at local coordinate pos to the writer w.
Definition: vtkwriter.hh:362
Iterate over the grid's vertices.
Definition: vtkwriter.hh:420
FieldVector< DT, n > position() const
position of vertex inside the entity
Definition: vtkwriter.hh:497
int localindex() const
index of vertex within the entity, in Dune-numbering
Definition: vtkwriter.hh:492
Writer for the ouput of grid functions in the vtk format.
Definition: vtkwriter.hh:91
void addCellData(const Container &v, const std::string &name, int ncomps=1, VTK::Precision prec=VTK::Precision::float32)
Add a grid function (represented by container) that lives on the cells of the grid to the visualizati...
Definition: vtkwriter.hh:691
void clear()
clear list of registered functions
Definition: vtkwriter.hh:771
std::string write(const std::string &name, VTK::OutputType type=VTK::ascii)
write output (interface might change later)
Definition: vtkwriter.hh:798
std::string getParallelHeaderName(const std::string &name, const std::string &path, int commSize) const
return name of a parallel header file
Definition: vtkwriter.hh:880
void addVertexData(const std::shared_ptr< const VTKFunction > &p)
Add a grid function that lives on the vertices of the grid to the visualization.
Definition: vtkwriter.hh:709
std::string getSerialPieceName(const std::string &name, const std::string &path) const
return name of a serial piece file
Definition: vtkwriter.hh:912
void addCellData(const std::shared_ptr< const VTKFunction > &p)
Add a grid function that lives on the cells of the grid to the visualization.
Definition: vtkwriter.hh:645
void addVertexData(F &&f, VTK::FieldInfo vtkFieldInfo)
Add a function by sampling it on the grid vertices.
Definition: vtkwriter.hh:734
virtual void writeCellData(VTK::VTUWriter &writer)
write cell data
Definition: vtkwriter.hh:1286
std::string getParallelPieceName(const std::string &name, const std::string &path, int commRank, int commSize) const
return name of a parallel piece file
Definition: vtkwriter.hh:849
virtual void countEntities(int &nvertices, int &ncells, int &ncorners)
count the vertices, cells and corners
Definition: vtkwriter.hh:1188
virtual void writeGridCells(VTK::VTUWriter &writer)
write the connectivity array
Definition: vtkwriter.hh:1338
virtual void writeCellFaces(VTK::VTUWriter &writer)
write the connectivity array
Definition: vtkwriter.hh:1408
std::string write(const std::string &name, VTK::OutputType type, const int commRank, const int commSize)
write output (interface might change later)
Definition: vtkwriter.hh:936
VTK::Precision coordPrecision() const
get the precision with which coordinates are written out
Definition: vtkwriter.hh:778
virtual void writeGridPoints(VTK::VTUWriter &writer)
write the positions of vertices
Definition: vtkwriter.hh:1314
virtual void writeVertexData(VTK::VTUWriter &writer)
write vertex data
Definition: vtkwriter.hh:1300
void addCellData(F &&f, VTK::FieldInfo vtkFieldInfo)
Add a function by sampling it on the element centers.
Definition: vtkwriter.hh:670
void addVertexData(const Container &v, const std::string &name, int ncomps=1, VTK::Precision prec=VTK::Precision::float32)
Add a grid function (represented by container) that lives on the vertices of the grid to the visualiz...
Definition: vtkwriter.hh:756
virtual ~VTKWriter()
destructor
Definition: vtkwriter.hh:782
VTKWriter(const GridView &gridView, VTK::DataMode dm=VTK::conforming, VTK::Precision coordPrecision=VTK::Precision::float32)
Construct a VTKWriter working on a specific GridView.
Definition: vtkwriter.hh:632
std::string pwrite(const std::string &name, const std::string &path, const std::string &extendpath, VTK::OutputType ot, const int commRank, const int commSize)
write output; interface might change later
Definition: vtkwriter.hh:996
std::string pwrite(const std::string &name, const std::string &path, const std::string &extendpath, VTK::OutputType type=VTK::ascii)
write output (interface might change later)
Definition: vtkwriter.hh:830
base class for data array writers
Definition: dataarraywriter.hh:54
void write(T data)
write one element of data
Definition: dataarraywriter.hh:67
Descriptor struct for VTK fields.
Definition: common.hh:376
@ tensor
tensor field (always 3x3)
@ vector
vector-valued field (always 3D, will be padded if necessary)
std::string name() const
The name of the data field.
Definition: common.hh:400
Dump a .vtu/.vtp files contents to a stream.
Definition: pvtuwriter.hh:60
Dump a .vtu/.vtp files contents to a stream.
Definition: vtuwriter.hh:96
DataArrayWriter * makeArrayWriter(const std::string &name, unsigned ncomps, unsigned nitems, Precision prec)
acquire a DataArrayWriter
Definition: vtuwriter.hh:378
void endCellData()
finish CellData section
Definition: vtuwriter.hh:218
void beginCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:272
void endPointData()
finish PointData section
Definition: vtuwriter.hh:180
void beginCellData(const std::string &scalars="", const std::string &vectors="")
start CellData section
Definition: vtuwriter.hh:203
void beginPointData(const std::string &scalars="", const std::string &vectors="")
start PointData section
Definition: vtuwriter.hh:165
void endPoints()
finish section for the point coordinates
Definition: vtuwriter.hh:247
void endCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:283
void beginPoints()
start section for the point coordinates
Definition: vtuwriter.hh:236
Data array writers for the VTKWriter.
A few common exception classes.
Common stuff for the VTKWriter.
Precision
which precision to use when writing out data to vtk files
Definition: common.hh:319
OutputType
How the bulk data should be stored in the file.
Definition: common.hh:42
FileType
which type of VTK file to write
Definition: common.hh:300
DataMode
Whether to produce conforming or non-conforming output.
Definition: common.hh:66
Functions for VTK output.
typename Impl::voider< Types... >::type void_t
Is void for all valid input types (see N3911). The workhorse for C++11 SFINAE-techniques.
Definition: typetraits.hh:40
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:172
Traits::Grid Grid
type of the grid
Definition: gridview.hh:77
const CollectiveCommunication & comm() const
obtain collective communication object
Definition: gridview.hh:246
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:80
Grid::ctype ctype
type used for coordinates in grid
Definition: gridview.hh:124
@ dimension
The dimension of the grid.
Definition: gridview.hh:127
@ dimensionworld
The dimension of the world the grid lives in.
Definition: gridview.hh:131
decltype(auto) ifElse(const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc)
A conditional expression.
Definition: hybridutilities.hh:355
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:160
std::string relativePath(const std::string &newbase, const std::string &p)
compute a relative path between two paths
Definition: path.cc:151
std::string concatPaths(const std::string &base, const std::string &p)
concatenate two paths
Definition: path.cc:30
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:87
Utility class for handling nested indentation in output.
This file implements iterator facade classes for writing stl conformant iterators.
Mapper for multiple codim and multiple geometry types.
Dune namespace.
Definition: alignedallocator.hh:14
Utilities for handling filesystem paths.
Static tag representing a codimension.
Definition: dimension.hh:22
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:196
Type trait to determine whether an instance of T has an operator[](I), i.e. whether it can be indexed...
Definition: typetraits.hh:230
Base class for polymorphic container of underlying data set.
Definition: vtkwriter.hh:160
virtual void write(const Coordinate &pos, Writer &w, std::size_t count) const =0
Evaluate data set at local position pos inside the current entity and write result to w.
virtual void unbind()=0
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
virtual void bind(const Entity &e)=0
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Type erasure implementation for functions conforming to the dune-functions LocalFunction interface.
Definition: vtkwriter.hh:183
virtual void write(const Coordinate &pos, Writer &w, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:201
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:196
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:191
Type erasure implementation for C++ functions, i.e., functions that can be evaluated in global coordi...
Definition: vtkwriter.hh:231
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:245
virtual void write(const Coordinate &pos, Writer &w, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:250
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:240
Type erasure implementation for legacy VTKFunctions.
Definition: vtkwriter.hh:272
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:283
virtual void write(const Coordinate &pos, Writer &w, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:288
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:278
Traits for type conversions and type information.