6#ifndef DUNE_VTKWRITER_HH
7#define DUNE_VTKWRITER_HH
21#include <dune/common/visibility.hh>
22#include <dune/common/typetraits.hh>
23#include <dune/common/exceptions.hh>
24#include <dune/common/indent.hh>
25#include <dune/common/iteratorfacades.hh>
26#include <dune/common/path.hh>
27#include <dune/geometry/referenceelements.hh>
29#include <dune/grid/common/gridenums.hh>
34#include <dune/grid/io/file/vtk/pvtuwriter.hh>
35#include <dune/grid/io/file/vtk/streams.hh>
36#include <dune/grid/io/file/vtk/vtuwriter.hh>
57 template<
class F,
class E,
class =
void >
62 template<
class F,
class E >
63 struct IsBindable< F, E,
std::void_t< decltype( std::declval< F & >().bind( std::declval< const E & >() ) ),
64 decltype( std::declval< F & >().unbind() ) > >
69 template<
class F,
class =
void >
70 struct HasLocalFunction
75 struct HasLocalFunction< F,
std::void_t< decltype( localFunction( std::declval< F& >() ) ) > >
82 template <
class Gr
idView>
83 class VTKSequenceWriterBase;
84 template <
class Gr
idView>
85 class VTKSequenceWriter;
95 template<
class Gr
idView >
110 typedef typename GridView::template Codim< 0 >::Entity Cell;
111 typedef typename GridView::template Codim< n >::Entity Vertex;
119 typedef typename GridView::template Codim< 0 >
120 ::template Partition< VTK_Partition >::Iterator
122 typedef typename GridView::template Codim< n >
123 ::template Partition< VTK_Partition >::Iterator
126 typedef typename GridCellIterator::Reference EntityReference;
128 typedef typename GridView::template Codim< 0 >
129 ::Entity::Geometry::LocalCoordinate Coordinate;
136 switch( VTK_Partition )
141 default: DUNE_THROW(NotImplemented,
"Add check for this partition type");
168 virtual void bind(
const Entity& e) = 0;
177 virtual void write(
const Coordinate& pos,
Writer& w, std::size_t count)
const = 0;
190 using Function =
typename std::decay<F>::type;
192 template<
typename F_>
194 : _f(std::forward<F_>(f))
197 virtual void bind(
const Entity& e)
207 virtual void write(
const Coordinate& pos,
Writer& writer, std::size_t count)
const
211 do_write(writer,r,count,IsIndexable<
decltype(r)>());
217 void do_write(
Writer& writer,
const R& r, std::size_t count, std::true_type)
const
219 for (std::size_t i = 0; i < count; ++i)
224 void do_write(Writer& writer,
const R& r, std::size_t count, std::false_type)
const
238 using Function =
typename std::decay<F>::type;
240 template<
typename F_>
242 : _f(std::forward<F_>(f))
246 virtual void bind(
const Entity& e)
256 virtual void write(
const Coordinate& pos,
Writer& writer, std::size_t count)
const
258 auto globalPos = element_->geometry().global(pos);
259 auto r = _f(globalPos);
260 if constexpr (IsIndexable<decltype(r)>()) {
261 for (std::size_t i = 0; i < count; ++i)
271 const Entity* element_;
283 virtual void bind(
const Entity& e)
293 virtual void write(
const Coordinate& pos,
Writer& writer, std::size_t count)
const
295 for (std::size_t i = 0; i < count; ++i)
296 writer.
write(_f->evaluate(i,*_entity,pos));
301 std::shared_ptr< const VTKFunction > _f;
302 const Entity* _entity;
307 template<typename F, std::enable_if_t<Impl::IsBindable<F, Entity>::value,
int> = 0>
315 template<typename F, std::enable_if_t<not Impl::IsBindable<F, Entity>::value && Impl::HasLocalFunction<F>::value,
int> = 0>
318 typename
std::decay<decltype(localFunction(
std::forward<F>(f)))>::type
319 > >(localFunction(
std::forward<F>(f))))
325 template<typename F, std::enable_if_t<not Impl::IsBindable<F, Entity>::value && not Impl::HasLocalFunction<F>::value,
int> = 0>
335 vtkFunctionPtr->
name(),
336 (vtkFunctionPtr->ncomps() == 2 || vtkFunctionPtr->ncomps() == 3) ? VTK::FieldInfo::Type::vector : VTK::FieldInfo::Type::scalar,
337 vtkFunctionPtr->ncomps(),
338 vtkFunctionPtr->precision()
355 void bind(
const Entity& e)
const
369 _f->write(pos,writer,
fieldInfo().size());
372 std::shared_ptr<FunctionWrapperBase> _f;
377 typedef typename std::list<VTKLocalFunction>::const_iterator FunctionIterator;
394 return ReferenceElements<DT,n>::general((*this)->type()).position(0,0);
398 CellIterator cellBegin()
const
400 return gridView_.template begin< 0, VTK_Partition >();
403 CellIterator cellEnd()
const
405 return gridView_.template end< 0, VTK_Partition >();
424 public ForwardIteratorFacade<VertexIterator, const Entity, EntityReference, int>
426 GridCellIterator git;
427 GridCellIterator gend;
433 std::vector<bool> visited;
441 void basicIncrement ()
446 const int numCorners = git->subEntities(n);
447 if( cornerIndexDune == numCorners )
449 offset += numCorners;
453 while( (git != gend) && skipEntity( git->partitionType() ) )
459 const GridCellIterator & end,
462 git(x), gend(end), datamode(dm), cornerIndexDune(0),
463 vertexmapper(vm), visited(vm.
size(),
false),
466 if (datamode == VTK::conforming && git != gend)
467 visited[vertexmapper.
subIndex(*git,cornerIndexDune,n)] =
true;
473 case VTK::conforming :
474 while(visited[vertexmapper.
subIndex(*git,cornerIndexDune,n)])
477 if (git == gend)
return;
479 visited[vertexmapper.
subIndex(*git,cornerIndexDune,n)] =
true;
481 case VTK::nonconforming :
488 return git == cit.git
489 && cornerIndexDune == cit.cornerIndexDune
490 && datamode == cit.datamode;
492 EntityReference dereference()
const
499 return cornerIndexDune;
504 return referenceElement<DT,n>(git->type())
505 .position(cornerIndexDune,n);
509 VertexIterator vertexBegin ()
const
511 return VertexIterator( gridView_.template begin< 0, VTK_Partition >(),
512 gridView_.template end< 0, VTK_Partition >(),
513 datamode, *vertexmapper );
516 VertexIterator vertexEnd ()
const
518 return VertexIterator( gridView_.template end< 0, VTK_Partition >(),
519 gridView_.template end< 0, VTK_Partition >(),
520 datamode, *vertexmapper );
539 public ForwardIteratorFacade<CornerIterator, const Entity, EntityReference, int>
541 GridCellIterator git;
542 GridCellIterator gend;
551 const std::vector<int> & number;
560 const GridCellIterator & end,
563 const std::vector<int> & num) :
564 git(x), gend(end), datamode(dm), cornerIndexVTK(0),
566 number(num), offset(0) {}
572 const int numCorners = git->subEntities(n);
573 if( cornerIndexVTK == numCorners )
575 offset += numCorners;
579 while( (git != gend) && skipEntity( git->partitionType() ) )
585 return git == cit.git
586 && cornerIndexVTK == cit.cornerIndexVTK
587 && datamode == cit.datamode;
589 EntityReference dereference()
const
602 case VTK::conforming :
604 number[vertexmapper.
subIndex(*git,VTK::renumber(*git,cornerIndexVTK),
606 case VTK::nonconforming :
607 return offset + VTK::renumber(*git,cornerIndexVTK);
609 DUNE_THROW(IOError,
"VTKWriter: unsupported DataMode" << datamode);
614 CornerIterator cornerBegin ()
const
616 return CornerIterator( gridView_.template begin< 0, VTK_Partition >(),
617 gridView_.template end< 0, VTK_Partition >(),
618 datamode, *vertexmapper, number );
621 CornerIterator cornerEnd ()
const
623 return CornerIterator( gridView_.template end< 0, VTK_Partition >(),
624 gridView_.template end< 0, VTK_Partition >(),
625 datamode, *vertexmapper, number );
640 : gridView_( gridView ),
643 polyhedralCellsPresent_( checkForPolyhedralCells() )
696 template<
class Container>
697 void addCellData (
const Container& v,
const std::string &name,
int ncomps = 1,
701 for (
int c=0; c<ncomps; ++c) {
702 std::stringstream compName;
705 compName <<
"[" << c <<
"]";
706 VTKFunction* p =
new Function(gridView_, v, compName.str(), ncomps, c, prec);
707 addCellData(std::shared_ptr< const VTKFunction >(p));
762 template<
class Container>
763 void addVertexData (
const Container& v,
const std::string &name,
int ncomps=1,
767 for (
int c=0; c<ncomps; ++c) {
768 std::stringstream compName;
771 compName <<
"[" << c <<
"]";
772 VTKFunction* p =
new Function(gridView_, v, compName.str(), ncomps, c, prec);
786 {
return coordPrec; }
806 std::string
write (
const std::string &name,
809 return write( name, type, gridView_.
comm().rank(), gridView_.
comm().size() );
838 std::string
pwrite (
const std::string & name,
const std::string & path,
const std::string & extendpath,
841 return pwrite( name, path, extendpath, type, gridView_.
comm().rank(), gridView_.
comm().size() );
859 const std::string& path,
860 int commRank,
int commSize)
const
862 std::ostringstream s;
867 if(path[path.size()-1] !=
'/')
871 std::string fileprefix;
874 auto pos = name.rfind(
'/');
875 if( pos != std::string::npos )
878 fileprefix = name.substr( pos+1 );
881 std::string newpath = name.substr(0, pos);
883 if(newpath[name.size()-1] !=
'/')
892 s <<
's' << std::setw(4) << std::setfill(
'0') << commSize <<
'-';
893 const bool writeHeader = commRank < 0;
896 s <<
'p' << std::setw(4) << std::setfill(
'0') << commRank <<
'-';
899 s << fileprefix <<
".";
924 const std::string& path,
944 const std::string& path)
const
946 static const std::string extension =
949 return concatPaths(path, name+extension);
968 std::string
write (
const std::string &name,
977 std::string filename = name;
978 std::string path = std::string(
"");
982 auto pos = name.rfind(
'/');
983 if( pos != std::string::npos )
986 filename = name.substr( pos+1 );
990 path = name.substr(0, pos);
993 return pwrite(filename, path,
"", type, commRank, commSize);
1004 file.exceptions(std::ios_base::badbit | std::ios_base::failbit |
1005 std::ios_base::eofbit);
1008 file.open( pieceName.c_str(), std::ios::binary );
1011 std::cerr <<
"Filename: " << pieceName <<
" could not be opened" << std::endl;
1014 if (! file.is_open())
1015 DUNE_THROW(IOError,
"Could not write to piece file " << pieceName);
1016 writeDataFile( file );
1046 std::string
pwrite(
const std::string& name,
const std::string& path,
1047 const std::string& extendpath,
1049 const int commSize )
1056 file.exceptions(std::ios_base::badbit | std::ios_base::failbit |
1057 std::ios_base::eofbit);
1058 std::string piecepath = concatPaths(path, extendpath);
1059 std::string relpiecepath = relativePath(path, piecepath);
1066 file.open(fullname.c_str(),std::ios::binary);
1069 std::cerr <<
"Filename: " << fullname <<
" could not be opened" << std::endl;
1072 if (! file.is_open())
1073 DUNE_THROW(IOError,
"Could not write to piecefile file " << fullname);
1074 writeDataFile(file);
1076 gridView_.
comm().barrier();
1082 file.open(fullname.c_str());
1083 if (! file.is_open())
1084 DUNE_THROW(IOError,
"Could not write to parallel file " << fullname);
1085 writeParallelHeader(file,name,relpiecepath, commSize );
1088 gridView_.
comm().barrier();
1111 void writeParallelHeader(std::ostream& s,
const std::string& piecename,
1112 const std::string& piecepath,
const int commSize)
1115 (n == 1) ? VTK::polyData : VTK::unstructuredGrid;
1123 std::string scalars, vectors;
1124 std::tie(scalars,vectors) = getDataNames(vertexdata);
1125 writer.beginPointData(scalars, vectors);
1127 for (
auto it = vertexdata.begin(),
1128 end = vertexdata.end();
1132 unsigned writecomps = it->fieldInfo().size();
1136 writer.addArray(it->name(), writecomps, it->fieldInfo().precision());
1138 writer.endPointData();
1142 std::string scalars, vectors;
1143 std::tie(scalars,vectors) = getDataNames(celldata);
1144 writer.beginCellData(scalars, vectors);
1146 for (
auto it = celldata.begin(),
1147 end = celldata.end();
1151 unsigned writecomps = it->fieldInfo().size();
1155 writer.addArray(it->name(), writecomps, it->fieldInfo().precision());
1157 writer.endCellData();
1160 writer.beginPoints();
1161 writer.addArray(
"Coordinates", 3, coordPrec);
1165 for(
int i = 0; i < commSize; ++i )
1170 writer.addPiece(fullname);
1177 void writeDataFile (std::ostream& s)
1179 VTK::FileType fileType =
1180 (n == 1) ? VTK::polyData : VTK::unstructuredGrid;
1182 VTK::VTUWriter writer(s, outputtype, fileType);
1186 if (datamode == VTK::conforming)
1188 number.resize(vertexmapper->
size());
1189 for (std::vector<int>::size_type i=0; i<number.size(); i++) number[i] = -1;
1193 writer.beginMain(ncells, nvertices);
1194 writeAllData(writer);
1198 if(writer.beginAppended())
1199 writeAllData(writer);
1200 writer.endAppended();
1202 delete vertexmapper; number.clear();
1205 void writeAllData(VTK::VTUWriter& writer) {
1220 std::string getFormatString()
const
1222 if (outputtype==VTK::ascii)
1224 if (outputtype==VTK::base64)
1226 if (outputtype==VTK::appendedraw)
1228 if (outputtype==VTK::appendedbase64)
1230 DUNE_THROW(IOError,
"VTKWriter: unsupported OutputType" << outputtype);
1233 std::string getTypeString()
const
1238 return "UnstructuredGrid";
1252 const int subEntities = it->subEntities(n);
1253 for (
int i=0; i<subEntities; ++i)
1256 if (datamode == VTK::conforming)
1258 int alpha = vertexmapper->
subIndex(*it,i,n);
1259 if (number[alpha]<0)
1260 number[alpha] = nvertices_++;
1270 template<
typename T>
1271 std::tuple<std::string,std::string> getDataNames(
const T& data)
const
1273 std::string scalars =
"";
1274 for (
auto it = data.begin(),
1280 scalars = it->name();
1284 std::string vectors =
"";
1285 for (
auto it = data.begin(),
1291 vectors = it->name();
1294 return std::make_tuple(scalars,vectors);
1297 template<
typename Data,
typename Iterator>
1298 void writeData(VTK::VTUWriter& writer,
const Data& data,
const Iterator begin,
const Iterator end,
int nentries)
1300 for (
auto it = data.begin(),
1305 const auto& f = *it;
1306 VTK::FieldInfo fieldInfo = f.fieldInfo();
1307 std::size_t writecomps = fieldInfo.size();
1308 switch (fieldInfo.type())
1316 DUNE_THROW(IOError,
"Cannot write VTK vectors with more than 3 components (components was " << writecomps <<
")");
1320 DUNE_THROW(NotImplemented,
"VTK output for tensors not implemented yet");
1322 std::shared_ptr<VTK::DataArrayWriter> p
1323 (writer.makeArrayWriter(f.name(), writecomps, nentries, fieldInfo.precision()));
1324 if(!p->writeIsNoop())
1325 for (Iterator eit = begin; eit!=end; ++eit)
1327 const Entity & e = *eit;
1329 f.write(eit.position(),*p);
1333 for (std::size_t j=fieldInfo.size(); j < writecomps; ++j)
1342 if(celldata.size() == 0)
1345 std::string scalars, vectors;
1346 std::tie(scalars,vectors) = getDataNames(celldata);
1349 writeData(writer,celldata,cellBegin(),cellEnd(),ncells);
1356 if(vertexdata.size() == 0)
1359 std::string scalars, vectors;
1360 std::tie(scalars,vectors) = getDataNames(vertexdata);
1363 writeData(writer,vertexdata,vertexBegin(),vertexEnd(),nvertices);
1372 std::shared_ptr<VTK::DataArrayWriter> p
1374 if(!p->writeIsNoop()) {
1379 for (
int j=0; j<std::min(dimw,3); j++)
1380 p->write((*vit).geometry().corner(vit.localindex())[j]);
1381 for (
int j=std::min(dimw,3); j<3; j++)
1398 std::shared_ptr<VTK::DataArrayWriter> p1
1399 (writer.
makeArrayWriter(
"connectivity", 1, ncorners, VTK::Precision::int32));
1400 if(!p1->writeIsNoop())
1407 std::shared_ptr<VTK::DataArrayWriter> p2
1408 (writer.
makeArrayWriter(
"offsets", 1, ncells, VTK::Precision::int32));
1409 if(!p2->writeIsNoop()) {
1413 offset += it->subEntities(n);
1423 std::shared_ptr<VTK::DataArrayWriter> p3
1426 if(!p3->writeIsNoop())
1430 int vtktype = VTK::geometryType(it->type());
1438 if( polyhedralCellsPresent_ )
1448 bool checkForPolyhedralCells()
const
1451 for(
const auto& geomType : gridView_.
indexSet().types( 0 ) )
1453 if( VTK::geometryType( geomType ) == VTK::polyhedron )
1456 DUNE_THROW(IOError,
"VTKWriter: grid must support codim 1 entities to be able to write VTK polyhedral cells");
1466 if( ! faceVertices_ )
1468 faceVertices_.reset(
new std::pair< std::vector<int>, std::vector<int> > () );
1470 fillFaceVertices( cornerBegin(), cornerEnd(), gridView_.
indexSet(),
1471 faceVertices_->first, faceVertices_->second );
1474 std::vector< int >& faces = faceVertices_->first;
1475 std::vector< int >& faceOffsets = faceVertices_->second;
1476 assert(
int(faceOffsets.size()) == ncells );
1479 std::shared_ptr<VTK::DataArrayWriter> p4
1480 (writer.
makeArrayWriter(
"faces", 1, faces.size(), VTK::Precision::int32));
1481 if(!p4->writeIsNoop())
1483 for(
const auto& face : faces )
1489 std::shared_ptr<VTK::DataArrayWriter> p5
1490 (writer.
makeArrayWriter(
"faceoffsets", 1, ncells, VTK::Precision::int32));
1491 if(!p5->writeIsNoop())
1493 for(
const auto& offset : faceOffsets )
1494 p5->write( offset );
1497 faceVertices_.reset();
1502 template <
class CornerIterator,
class IndexSet,
class T>
1503 inline void fillFaceVertices( CornerIterator it,
1504 const CornerIterator end,
1506 std::vector<T>& faces,
1507 std::vector<T>& faceOffsets )
1509 if( n == 3 && it != end )
1513 faces.reserve( 15 * ncells );
1514 faceOffsets.clear();
1515 faceOffsets.reserve( ncells );
1520 int elIndex = indexSet.
index( element );
1521 std::vector< T > vertices;
1522 vertices.reserve( 30 );
1523 for( ; it != end; ++it )
1525 const Cell& cell = *it ;
1526 const int cellIndex = indexSet.
index( cell ) ;
1527 if( elIndex != cellIndex )
1529 fillFacesForElement( element, indexSet, vertices, offset, faces, faceOffsets );
1533 elIndex = cellIndex ;
1535 vertices.push_back( it.id() );
1539 fillFacesForElement( element, indexSet, vertices, offset, faces, faceOffsets );
1543 template <
class Entity,
class IndexSet,
class T>
1544 static void fillFacesForElement(
const Entity& element,
1545 const IndexSet& indexSet,
1546 const std::vector<T>& vertices,
1548 std::vector<T>& faces,
1549 std::vector<T>& faceOffsets )
1553 std::map< T, T > vxMap;
1556 const int nVertices = element.subEntities( dim );
1557 for(
int vx = 0; vx < nVertices; ++ vx )
1559 const int vxIdx = indexSet.subIndex( element, vx, dim );
1560 vxMap[ vxIdx ] = vertices[ vx ];
1564 const int nFaces = element.subEntities( 1 );
1566 faces.push_back( nFaces );
1569 for(
int fce = 0; fce < nFaces; ++ fce )
1571 if constexpr (Capabilities::hasEntity<typename GridView::Grid, 1>::v) {
1573 const auto face = element.template subEntity< 1 > ( fce );
1576 const int nVxFace = face.subEntities( dim );
1577 faces.push_back( nVxFace );
1579 for(
int i=0; i<nVxFace; ++i )
1581 const T vxIndex = indexSet.subIndex( face, i, dim );
1582 assert( vxMap.find( vxIndex ) != vxMap.end() );
1583 faces.push_back( vxMap[ vxIndex ] );
1587 DUNE_THROW(IOError,
"VTKWriter: grid must support codim 1 entities to be able to write VTK polyhedral cells");
1592 faceOffsets.push_back( offset );
1597 std::list<VTKLocalFunction> celldata;
1598 std::list<VTKLocalFunction> vertexdata;
1608 VertexMapper* vertexmapper;
1611 std::vector<int> number;
1612 VTK::DataMode datamode;
1613 VTK::Precision coordPrec;
1616 const bool polyhedralCellsPresent_;
1619 std::shared_ptr< std::pair< std::vector<int>, std::vector<int> > > faceVertices_;
1622 VTK::OutputType outputtype;
Grid view abstract base class.
Definition: gridview.hh:66
Index Set Interface base class.
Definition: indexidset.hh:78
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:113
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:129
size_type size() const
Return total number of entities in the entity set managed by the mapper.
Definition: mcmgmapper.hh:204
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:185
Take a vector and interpret it as cell data for the VTKWriter.
Definition: function.hh:97
Take a vector and interpret it as point data for the VTKWriter.
Definition: function.hh:205
A base class for grid functions with any return type and dimension.
Definition: function.hh:42
Base class to write pvd-files which contains a list of all collected vtk-files.
Definition: vtksequencewriterbase.hh:34
Writer for the output of grid functions in the vtk format.
Definition: vtksequencewriter.hh:29
Iterator over the grids elements.
Definition: vtkwriter.hh:386
CellIterator(const GridCellIterator &x)
construct a CellIterator from the gridview's Iterator.
Definition: vtkwriter.hh:389
const FieldVector< DT, n > position() const
Definition: vtkwriter.hh:392
Iterate over the elements' corners.
Definition: vtkwriter.hh:540
int id() const
Process-local consecutive zero-starting vertex id.
Definition: vtkwriter.hh:598
Type erasure wrapper for VTK data sets.
Definition: vtkwriter.hh:157
void write(const Coordinate &pos, Writer &writer) const
Write the value of the data set at local coordinate pos to the writer.
Definition: vtkwriter.hh:367
void unbind() const
Unbind the data set from the currently bound entity.
Definition: vtkwriter.hh:361
VTKLocalFunction(F &&f, VTK::FieldInfo fieldInfo)
Construct a VTKLocalFunction for a dune-functions style LocalFunction.
Definition: vtkwriter.hh:308
std::string name() const
Returns the name of the data set.
Definition: vtkwriter.hh:343
const VTK::FieldInfo & fieldInfo() const
Returns the VTK::FieldInfo for the data set.
Definition: vtkwriter.hh:349
void bind(const Entity &e) const
Bind the data set to grid entity e.
Definition: vtkwriter.hh:355
VTKLocalFunction(const std::shared_ptr< const VTKFunction > &vtkFunctionPtr)
Construct a VTKLocalFunction for a legacy VTKFunction.
Definition: vtkwriter.hh:332
Iterate over the grid's vertices.
Definition: vtkwriter.hh:425
FieldVector< DT, n > position() const
position of vertex inside the entity
Definition: vtkwriter.hh:502
int localindex() const
index of vertex within the entity, in Dune-numbering
Definition: vtkwriter.hh:497
Writer for the output of grid functions in the vtk format.
Definition: vtkwriter.hh:96
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:697
void clear()
clear list of registered functions
Definition: vtkwriter.hh:778
std::string write(const std::string &name, VTK::OutputType type=VTK::ascii)
write output (interface might change later)
Definition: vtkwriter.hh:806
std::string getParallelHeaderName(const std::string &name, const std::string &path, int commSize) const
return name of a parallel header file
Definition: vtkwriter.hh:923
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:715
std::string getSerialPieceName(const std::string &name, const std::string &path) const
return name of a serial piece file
Definition: vtkwriter.hh:943
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:650
void addVertexData(F &&f, VTK::FieldInfo vtkFieldInfo)
Add a function by sampling it on the grid vertices.
Definition: vtkwriter.hh:740
virtual void writeCellData(VTK::VTUWriter &writer)
write cell data
Definition: vtkwriter.hh:1340
virtual void countEntities(int &nvertices_, int &ncells_, int &ncorners_)
count the vertices, cells and corners
Definition: vtkwriter.hh:1242
std::string getParallelPieceName(const std::string &name, const std::string &path, int commRank, int commSize) const
return name of a parallel piece file (or header name)
Definition: vtkwriter.hh:858
virtual void writeGridCells(VTK::VTUWriter &writer)
write the connectivity array
Definition: vtkwriter.hh:1392
virtual void writeCellFaces(VTK::VTUWriter &writer)
write the connectivity array
Definition: vtkwriter.hh:1464
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:968
VTK::Precision coordPrecision() const
get the precision with which coordinates are written out
Definition: vtkwriter.hh:785
virtual void writeGridPoints(VTK::VTUWriter &writer)
write the positions of vertices
Definition: vtkwriter.hh:1368
virtual void writeVertexData(VTK::VTUWriter &writer)
write vertex data
Definition: vtkwriter.hh:1354
void addCellData(F &&f, VTK::FieldInfo vtkFieldInfo)
Add a function by sampling it on the element centers.
Definition: vtkwriter.hh:675
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:763
virtual ~VTKWriter()
destructor
Definition: vtkwriter.hh:789
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:637
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:1046
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:838
base class for data array writers
Definition: dataarraywriter.hh:56
void write(T data)
write one element of data
Definition: dataarraywriter.hh:69
Descriptor struct for VTK fields.
Definition: common.hh:328
@ 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:352
Dump a .vtu/.vtp files contents to a stream.
Definition: pvtuwriter.hh:62
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:381
void endCellData()
finish CellData section
Definition: vtuwriter.hh:220
void beginCells()
start section for the grid cells/PolyData lines
Definition: vtuwriter.hh:274
void endPointData()
finish PointData section
Definition: vtuwriter.hh:182
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
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
A set of traits classes to store static information about grid implementation.
Common stuff for the VTKWriter.
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
DataMode
Whether to produce conforming or non-conforming output.
Definition: common.hh:67
Data array writers for the VTKWriter.
Functions for VTK output.
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:177
Traits::Grid Grid
type of the grid
Definition: gridview.hh:83
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:86
const Communication & comm() const
obtain communication object
Definition: gridview.hh:273
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:134
Grid::ctype ctype
type used for coordinates in grid
Definition: gridview.hh:131
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: gridview.hh:137
MCMGLayout mcmgVertexLayout()
layout for vertices (dim-0 entities)
Definition: mcmgmapper.hh:107
Mapper for multiple codim and multiple geometry types.
Include standard header files.
Definition: agrid.hh:60
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:58
Base class for polymorphic container of underlying data set.
Definition: vtkwriter.hh:165
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:189
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:202
virtual void write(const Coordinate &pos, Writer &writer, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:207
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:197
Type erasure implementation for C++ functions, i.e., functions that can be evaluated in global coordi...
Definition: vtkwriter.hh:237
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
Definition: vtkwriter.hh:251
virtual void write(const Coordinate &pos, Writer &writer, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:256
virtual void bind(const Entity &e)
Bind data set to grid entity - must be called before evaluating (i.e. calling write())
Definition: vtkwriter.hh:246
Type erasure implementation for legacy VTKFunctions.
Definition: vtkwriter.hh:277
virtual void write(const Coordinate &pos, Writer &writer, std::size_t count) const
Evaluate data set at local position pos inside the current entity and write result to w.
Definition: vtkwriter.hh:293
virtual void unbind()
Unbind data set from current grid entity - mostly here for performance and symmetry reasons.
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:283