Package: dune-vtk
Dune-VtkFile reader and writer for the VTK FormatSummaryProvides structured and unstructured file writers for the VTK XML File Formats
that can be opened in the popular ParaView visualization application. Additionally
a file reader is provided to import VTK files into Dune grid and data objects.Installation Instructionsdune-vtkrequires the DUNE core modules, version 2.7 or later.
Please see thegeneral instructions for building DUNE modulesfor detailed instructions on how to build the module.UsageThe VTK writer works similar to the dune-gridVTKWriter. It needs to be bound
to a GridView and then data can be added to the points or cells in the grid.
Points are not necessarily grid vertices, but any coordinates placed inside the
grid cells, so the data must be provided as GridViewFunction to allow the local
evaluation in arbitrary local coordinates.General interface of a VtkWritertemplate<classGridView,classDataCollector=DefaultDataCollector<GridView>>classVtk[Type]Writer{public:// ConstructorVtk[Type]Writer(GridView,Vtk::FormatTypes=Vtk::FormatTypes::BINARY,Vtk::DataTypes=Vtk::DataTypes::FLOAT32);// Bind data to the writerVtk[Type]Writer&addPointData(Function[,std::stringname,intnumComponents,Vtk::FormatTypes]);Vtk[Type]Writer&addCellData(Function[,std::stringname,intnumComponents,Vtk::FormatTypes]);// Write file with filenamevoidwrite(std::stringfilename);};whereFunctionis either aGridViewFunction, i.e. supportsbind(),unbind(), andlocalFunction(Function), or is a legacyVTKFunctionfrom Dune-Grid. The optional parametersname,numComponentsandformatmay be given for aGridViewFunction.The parameterVtk::FormatTypesis one ofVtk::FormatTypes::ASCII,Vtk::FormatTypes::BINARY, orVtk::FormatTypes::COMPRESSEDandVtk::DataTypesis one ofVtk::DataTypes::FLOAT32, orVtk::DataTypes::FLOAT64. The[Type]of a VtkWriter is one ofUnstructuredGrid,StructuredGrid,RectilinearGrid,ImageData, orTimeseries, see below for details. ADataCollectormay be specified to control how point and cell values are extracted from theGridViewand the bound data. Seedune/vtk/datacollectors/of a list of poissible types. The default datacollector extracts a connected grid with continuous data, where points are grid vertices.See also thesrc/directory for more examples.Comparison with Dune::VTKWriterIn Dune-Grid there is a VTK writer available, that is a bit different from the
proposed one. A comparison:PropertyDune-GridDune-VtkVTK version0.10.1/1.0UnstructuredGridxxPolyData(1d)-StructuredGrid-xRectilinearGrid-xImageData-xASCIIxxBASE64x-APPENDED_RAWxxAPPENDED_BASE64x-BASE64_COMPRESSED--APPENDED_COMPRESSED-xParallel filesxxConforming DataxxNonConforming DataxxQuadratic Data-xHigher-Order Data-xSubdivided Datax-Sequence (PVD)xxTimeseries-xWriters and ReadersDune-Vtk provides nearly all file formats specified in VTK + 2 time series formats:
PVD and VTK-Timeseries.VtkUnstructuredGridWriterImplements a VTK file format for unstructured grids with arbitrary element types
in 1d, 2d, and 3d. Coordinates are specified explicitly and a connectivity table +
element types are specified for all grid elements (of codim 0). Can be used with
all Dune grid types.VtkStructuredGridWriterImplements a writer for grid composed of cube elements (lines, pixels, voxels) with
local numbering similar to Dunescube(d)numbering. The coordinates of the vertices
can be arbitrary but the connectivity is implicitly given and equals that ofDune::YaspGridorDune::SPGrid. Might be chosen as writer for a transformed
structured grid, using, e.g., aGeometryGridmeta-grid. Seesrc/geometrygrid.ccfor an example.VtkRectilinearGridWriterRectilinear grids are tensor-product grids with given coordinates along the x, y,
and z axes. Therefore, the grid must allow to extract these 1d coordinates and a
specialization for aStructuredDataCollectormust be provided, that implements
theordinates()function. By default, it assumes constant grid spacing starting
from a lower left corner. ForYaspGrida specialization is implemented if the
coordinates type isTensorProductCoordinates. Seesrc/structuredgridwriter.ccfor an example.VtkImageDataWriterThemost structuredgrid is composed of axis-parallel cube elements with constant
size along each axis. The is implemented in the VtkImageDataWriter. A specialization
of theStructuredDataCollectormust implementorigin()for the lower left corner,wholeExtent()for the range of cell numbers along each axis in the global grid,extent()for the range in the local grid, andspacing()for the constant grid
spacing in each direction.PvdWriterA sequence writer, i.e. a collection of timestep files, in the ParaView Data (PVD)
format. Supports all VtkWriters for the timestep output. In each timestep a collection
(.pvd) file is created.VtkTimseriesWriterA timeseries is a collection of timesteps stored in one file, instead of separate
files for each timestep value. Since in theVtk::FormatTypes::APPENDEDmode, the data is written
as binary blocks in the appended section of the file and references by an offset
in the XML DataArray attributes, it allows to reuse written data. An example of
usage is when the grid points and cells do not change over time, but just the
point-/cell-data. Then, the grid is written only once and the data is just appended.Timeseries file are create a bit differently from other Vtk file. There, in the
first write the grid points and cells are stored in a separate file, and in each
timestep just the data is written also to temporary files. When you need the timeseries
file, these stored temporaries are collected and combined to one VTK file. Thus,
only the minimum amount of data is written in each timestep. The intermediate files
are stored, by default, in a/tmpfolder, with (hopefully) fast write access.VtkReaderReading unstructured grid files (.vtu files) and creating a new grid, using a GridFactory,
can be performed using theVtkReaderclass. The reader allows to create the grid in
multiple ways, by providing aGridCreatortemplate parameter. TheContinuousGridCreatorreads the connectivity of the grid as it is and assumes that the elements are already
connected correctly. On the other hand, aDiscontinuousGridCreatorreconnects separated
elements, by identifying matching coordinates of the cell vertices. See more possible
grid-creators in the directorydune/vtk/gridcreators.General interface of a VtkReadertemplate<classGrid,classGridCreator=ContinuousGridCreator<Grid>,classFieldType=double>classVtkReader{public:// ConstructorsVtkReader();// Construct a GridCreator with internal stored GridFactoryVtkReader(GridFactory<Grid>&);// Construct a GridCreator referencing the passed GridFactoryVtkReader(GridCreator&);// Reference the passed GridCreator// Read the data from a file with filenamevoidread(std::stringfilename);// Construct the Grid from the data read before.std::unique_ptr<Grid>createGrid()const;// Static method to construct the Grid directlystaticstd::unique_ptr<Grid>createGridFromFile(std::stringfile);// Extract data from the reader_PointDataGridFunction_getPointData(std::stringname)const;_CellDataGridFunction_getCellData(std::stringname)const;};whereGridis a dune grid type providing aGridFactoryspecialization,GridCreator is the policy type implementing how the raw data from the file is transformed in data that can be passed to the GridFactory andFieldType` is the data for for internal storage of value
data from the file, i.e. point-data or cell-data.The grid can either be created using the static methodcreateGridFromFile()or by first
constructing theVtkReaderwith itsGridCreator, callingread()and finallycreateGrid().
The latter allows to access data stored in the reader, like point-data or cell-data.Value from point-data or cell-data cannot be accessed directly, but through the interface
of a grid-function. These grid-functions are provided by thegetPointData()orgetCellData()member functions of the reader. The interface of a dune-functions grid-function concept is
implemented by these two types. The reason why the reader does not provide the data directly
is, that it is quiet complicated to associate the specific value to a DOF in the grid, since
the GridFactory is allows to change the global indexing and even to change to local indexing
in the elements such that even the local element coordinates might need a transformation
compared to that of the element stored in the file. All these renumbering and coordinate
transformations are performed by the grid-functions internally.The VtkReader supports grid creation in parallel. If a partition file .pvtu is
provided, all partitions can be read by either one processor and distributed later on
(SerialGridCreator) or read directly in parallel (ParallelGridCreator). The later
is currently only available in dune-alugrid 2.6.git-cb00bc20c196100dd0d31010fcf7f8d789d49f43