Dune Core Modules (2.6.0)

Writer for the ouput of grid functions in the vtk format. More...

#include <dune/grid/io/file/vtk/vtkwriter.hh>

Classes

class  CellIterator
 Iterator over the grids elements. More...
 
class  CornerIterator
 Iterate over the elements' corners. More...
 
class  VertexIterator
 Iterate over the grid's vertices. More...
 
class  VTKLocalFunction
 Type erasure wrapper for VTK data sets. More...
 

Public Member Functions

 VTKWriter (const GridView &gridView, VTK::DataMode dm=VTK::conforming)
 Construct a VTKWriter working on a specific GridView. More...
 
void addCellData (const std::shared_ptr< const VTKFunction > &p)
 Add a grid function that lives on the cells of the grid to the visualization. More...
 
template<typename F >
void addCellData (F &&f, VTK::FieldInfo vtkFieldInfo)
 Add a grid function that lives on the cells of the grid to the visualization.
 
template<class Container >
void addCellData (const Container &v, const std::string &name, int ncomps=1)
 Add a grid function (represented by container) that lives on the cells of the grid to the visualization. More...
 
void addVertexData (const std::shared_ptr< const VTKFunction > &p)
 Add a grid function that lives on the vertices of the grid to the visualization. More...
 
template<typename F >
void addVertexData (F &&f, VTK::FieldInfo vtkFieldInfo)
 Add a grid function that lives on the vertices of the grid to the visualization.
 
template<class Container >
void addVertexData (const Container &v, const std::string &name, int ncomps=1)
 Add a grid function (represented by container) that lives on the vertices of the grid to the visualization output. More...
 
void clear ()
 clear list of registered functions
 
virtual ~VTKWriter ()
 destructor
 
std::string write (const std::string &name, VTK::OutputType type=VTK::ascii)
 write output (interface might change later) More...
 
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) More...
 

Protected Member Functions

std::string getParallelPieceName (const std::string &name, const std::string &path, int commRank, int commSize) const
 return name of a parallel piece file More...
 
std::string getParallelHeaderName (const std::string &name, const std::string &path, int commSize) const
 return name of a parallel header file More...
 
std::string getSerialPieceName (const std::string &name, const std::string &path) const
 return name of a serial piece file More...
 
std::string write (const std::string &name, VTK::OutputType type, const int commRank, const int commSize)
 write output (interface might change later) More...
 
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 More...
 
virtual void countEntities (int &nvertices, int &ncells, int &ncorners)
 count the vertices, cells and corners
 
virtual void writeCellData (VTK::VTUWriter &writer)
 write cell data
 
virtual void writeVertexData (VTK::VTUWriter &writer)
 write vertex data
 
virtual void writeGridPoints (VTK::VTUWriter &writer)
 write the positions of vertices
 
virtual void writeGridCells (VTK::VTUWriter &writer)
 write the connectivity array
 
virtual void writeCellFaces (VTK::VTUWriter &writer)
 write the connectivity array
 

Detailed Description

template<class GridView>
class Dune::VTKWriter< GridView >

Writer for the ouput of grid functions in the vtk format.

Writes arbitrary grid functions (living on cells or vertices of a grid) to a file suitable for easy visualization with The Visualization Toolkit (VTK).

Constructor & Destructor Documentation

◆ VTKWriter()

template<class GridView >
Dune::VTKWriter< GridView >::VTKWriter ( const GridView gridView,
VTK::DataMode  dm = VTK::conforming 
)
inlineexplicit

Construct a VTKWriter working on a specific GridView.

Parameters
gridViewThe gridView the grid functions live on. (E. g. a LevelGridView.)
dmThe data mode.

Member Function Documentation

◆ addCellData() [1/2]

template<class GridView >
template<class Container >
void Dune::VTKWriter< GridView >::addCellData ( const Container &  v,
const std::string &  name,
int  ncomps = 1 
)
inline

Add a grid function (represented by container) that lives on the cells of the grid to the visualization.

The container has to have random access via operator[] (e.g. std::vector). The value of the grid function for an arbitrary element will be accessed by calling operator[] with the index (corresponding to the index from the MGMC mapper on the grid view) of the element. For vector valued data all components for an element are assumed to be consecutive.

Parameters
vThe container with the values of the grid function for each cell.
nameA name to identify the grid function.
ncompsNumber of components (default is 1).

References Dune::VTKWriter< GridView >::addCellData().

◆ addCellData() [2/2]

template<class GridView >
void Dune::VTKWriter< GridView >::addCellData ( const std::shared_ptr< const VTKFunction > &  p)
inline

Add a grid function that lives on the cells of the grid to the visualization.

Parameters
pstd::shared_ptr to the function to visualize

Referenced by Dune::VTKWriter< GridView >::addCellData().

◆ addVertexData() [1/2]

template<class GridView >
template<class Container >
void Dune::VTKWriter< GridView >::addVertexData ( const Container &  v,
const std::string &  name,
int  ncomps = 1 
)
inline

Add a grid function (represented by container) that lives on the vertices of the grid to the visualization output.

The container has to have random access via operator[] (e.g. std::vector). The value of the grid function for an arbitrary element will be accessed by calling operator[] with the index (corresponding to the index from the MGMC mapper on the grid view) of the vertex. For vector valued data all components for a vertex are assumed to be consecutive.

Parameters
vThe container with the values of the grid function for each vertex.
nameA name to identify the grid function.
ncompsNumber of components (default is 1).

References Dune::VTKWriter< GridView >::addVertexData().

◆ addVertexData() [2/2]

template<class GridView >
void Dune::VTKWriter< GridView >::addVertexData ( const std::shared_ptr< const VTKFunction > &  p)
inline

Add a grid function that lives on the vertices of the grid to the visualization.

Parameters
pstd::shared_ptr to the function to visualize

Referenced by Dune::VTKWriter< GridView >::addVertexData().

◆ getParallelHeaderName()

template<class GridView >
std::string Dune::VTKWriter< GridView >::getParallelHeaderName ( const std::string &  name,
const std::string &  path,
int  commSize 
) const
inlineprotected

return name of a parallel header file

Parameters
nameBase name of the VTK output. This should be without any directory parts and without a filename extension.
pathDirectory part of the resulting header name. May be empty, in which case the resulting name will not have a directory part. If non-empty, may or may not have a trailing '/'. If a trailing slash is missing, one is appended implicitly.
commSizeNumber of processes writing a parallel vtk output.

References Dune::GridView< ViewTraits >::dimension.

Referenced by Dune::VTKWriter< GridView >::pwrite().

◆ getParallelPieceName()

template<class GridView >
std::string Dune::VTKWriter< GridView >::getParallelPieceName ( const std::string &  name,
const std::string &  path,
int  commRank,
int  commSize 
) const
inlineprotected

return name of a parallel piece file

Parameters
nameBase name of the VTK output. This should be without any directory parts and without a filename extension.
pathDirectory part of the resulting piece name. May be empty, in which case the resulting name will not have a directory part. If non-empty, may or may not have a trailing '/'. If a trailing slash is missing, one is appended implicitly.
commRankRank of the process to generate a piece name for.
commSizeNumber of processes writing a parallel vtk output.

References Dune::GridView< ViewTraits >::dimension.

Referenced by Dune::VTKWriter< GridView >::pwrite().

◆ getSerialPieceName()

template<class GridView >
std::string Dune::VTKWriter< GridView >::getSerialPieceName ( const std::string &  name,
const std::string &  path 
) const
inlineprotected

return name of a serial piece file

This is similar to getParallelPieceName, but skips the prefixes for commSize ("s####-") and commRank ("p####-").

Parameters
nameBase name of the VTK output. This should be without any directory parts and without a filename extension.
pathDirectory part of the resulting piece name. May be empty, in which case the resulting name will not have a directory part. If non-empty, may or may not have a trailing '/'. If a trailing slash is missing, one is appended implicitly.

References Dune::concatPaths(), and Dune::GridView< ViewTraits >::dimension.

Referenced by Dune::VTKWriter< GridView >::write().

◆ pwrite() [1/2]

template<class GridView >
std::string Dune::VTKWriter< GridView >::pwrite ( const std::string &  name,
const std::string &  path,
const std::string &  extendpath,
VTK::OutputType  ot,
const int  commRank,
const int  commSize 
)
inlineprotected

write output; interface might change later

Parameters
nameBase name of the output files. This should not contain any directory part and not filename extensions. It will be used both for each processes piece as well as the parallel collection file.
pathDirectory where to put the parallel collection (.pvtu/.pvtp) file. If it is relative, it is taken realtive to the current directory.
extendpathDirectory where to put the piece file (.vtu/.vtp) of this process. If it is relative, it is taken relative to the directory denoted by path.
otHow to encode the data in the file.
commRankRank of the current process.
commSizeNumber of processes taking part in this write operation.
Note
Currently, extendpath may not be absolute unless path is absolute, because that would require the value of the current directory.
Exceptions
NotImplementedExtendpath is absolute but path is relative.
IOErrorFailed to open a file.

References Dune::GridView< ViewTraits >::comm(), Dune::concatPaths(), DUNE_THROW, Dune::VTKWriter< GridView >::getParallelHeaderName(), Dune::VTKWriter< GridView >::getParallelPieceName(), and Dune::relativePath().

◆ pwrite() [2/2]

template<class GridView >
std::string Dune::VTKWriter< GridView >::pwrite ( const std::string &  name,
const std::string &  path,
const std::string &  extendpath,
VTK::OutputType  type = VTK::ascii 
)
inline

write output (interface might change later)

"pwrite" means "path write" (i.e. write somewhere else than the current directory). The "p" does not mean this method has a monopoly on parallel writing, the regular write(const std::string &, VTK::OutputType) method can do that just fine.

Parameters
nameBase name of the output files. This should not contain any directory part and not filename extensions. It will be used both for each processes piece as well as the parallel collection file.
pathDirectory where to put the parallel collection (.pvtu/.pvtp) file. If it is relative, it is taken relative to the current directory.
extendpathDirectory where to put the piece file (.vtu/.vtp) of this process. If it is relative, it is taken relative to the directory denoted by path.
typeHow to encode the data in the file.
Note
Currently, extendpath may not be absolute unless path is absolute, because that would require the value of the current directory.
Exceptions
NotImplementedExtendpath is absolute but path is relative.
IOErrorFailed to open a file.

References Dune::GridView< ViewTraits >::comm(), and Dune::VTKWriter< GridView >::pwrite().

Referenced by Dune::VTKWriter< GridView >::pwrite(), and Dune::VTKWriter< GridView >::write().

◆ write() [1/2]

template<class GridView >
std::string Dune::VTKWriter< GridView >::write ( const std::string &  name,
VTK::OutputType  type,
const int  commRank,
const int  commSize 
)
inlineprotected

write output (interface might change later)

This method can be used in parallel as well as in serial programs. For serial runs (commSize=1) it chooses other names without the "s####-p####-" prefix for the .vtu/.vtp files and omits writing of the .pvtu/pvtp file however. For parallel runs (commSize > 1) it is the same as a call to pwrite() with path="" and extendpath="".

Parameters
nameBase name of the output files. This should not contain any directory part and no filename extensions.
typeHow to encode the data in the file.
commRankRank of the current process.
commSizeNumber of processes taking part in this write operation.

References DUNE_THROW, Dune::VTKWriter< GridView >::getSerialPieceName(), and Dune::VTKWriter< GridView >::pwrite().

◆ write() [2/2]

template<class GridView >
std::string Dune::VTKWriter< GridView >::write ( const std::string &  name,
VTK::OutputType  type = VTK::ascii 
)
inline

write output (interface might change later)

This method can be used in parallel as well as in serial programs. For serial runs (commSize=1) it chooses other names without the "s####-p####-" prefix for the .vtu/.vtp files and omits writing of the .pvtu/pvtp file however. For parallel runs (commSize > 1) it is the same as a call to pwrite() with path="" and extendpath="".

Parameters
[in]namebasic name to write (may not contain a path)
[in]typetype of output (e.g,, ASCII) (optional)

References Dune::GridView< ViewTraits >::comm(), and Dune::VTKWriter< GridView >::write().

Referenced by Dune::VTKWriter< GridView >::write().


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)